@@ -102,113 +102,8 @@ namespace blink {
102102 {{convert_and_set_value(property)}}
103103}
104104{% endmacro %}
105- {{apply_auto('CSSPropertyClip')}}
106105{{apply_auto('CSSPropertyZIndex')}}
107106
108- static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float value)
109- {
110- return length.type() == type && length.value() == value;
111- }
112-
113- static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type, float value)
114- {
115- return (lengthTypeAndValueMatch(lengthBox.left(), type, value)
116- && lengthTypeAndValueMatch(lengthBox.right(), type, value)
117- && lengthTypeAndValueMatch(lengthBox.top(), type, value)
118- && lengthTypeAndValueMatch(lengthBox.bottom(), type, value));
119- }
120-
121- static bool lengthTypeAndValueMatch(const BorderImageLength& borderImageLength, LengthType type, float value)
122- {
123- return borderImageLength.isLength() && lengthTypeAndValueMatch(borderImageLength.length(), type, value);
124- }
125-
126- static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengthBox, LengthType type, float value)
127- {
128- return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value)
129- && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value)
130- && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value)
131- && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value));
132- }
133-
134- {% macro apply_border_image_modifier(property_id, modifier_type) %}
135- {{ declare_initial_function(property_id) }}
136- {
137- const NinePieceImage& currentImage = state.style()->borderImage();
138- {# Check for equality in case we can bail out before creating a new NinePieceImage. #}
139- {% if modifier_type == 'Outset' %}
140- if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0))
141- return;
142- {% elif modifier_type == 'Repeat' %}
143- if (currentImage.horizontalRule() == StretchImageRule && currentImage.verticalRule() == StretchImageRule)
144- return;
145- {% elif modifier_type == 'Slice' %}
146- if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.imageSlices(), Percent, 100))
147- return;
148- {% elif modifier_type == 'Width' %}
149- if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1))
150- return;
151- {% endif %}
152-
153- NinePieceImage image(currentImage);
154- {% if modifier_type == 'Outset' %}
155- image.setOutset(Length(0, Fixed));
156- {% elif modifier_type == 'Repeat' %}
157- image.setHorizontalRule(StretchImageRule);
158- image.setVerticalRule(StretchImageRule);
159- {% elif modifier_type == 'Slice' %}
160- image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }}));
161- image.setFill(false);
162- {% elif modifier_type == 'Width' %}
163- image.setBorderSlices(1.0);
164- {% endif %}
165- state.style()->setBorderImage(image);
166- }
167-
168- {{declare_inherit_function(property_id)}}
169- {
170- NinePieceImage image(state.style()->borderImage());
171- {% if modifier_type == 'Outset' %}
172- image.copyOutsetFrom(state.parentStyle()->borderImage());
173- {% elif modifier_type == 'Repeat' %}
174- image.copyRepeatFrom(state.parentStyle()->borderImage());
175- {% elif modifier_type == 'Slice' %}
176- image.copyImageSlicesFrom(state.parentStyle()->borderImage());
177- {% elif modifier_type == 'Width' %}
178- image.copyBorderSlicesFrom(state.parentStyle()->borderImage());
179- {% endif %}
180- state.style()->setBorderImage(image);
181- }
182-
183- {{declare_value_function(property_id)}}
184- {
185- NinePieceImage image(state.style()->borderImage());
186- {% if modifier_type == 'Outset' %}
187- image.setOutset(state.styleMap().mapNinePieceImageQuad(value));
188- {% elif modifier_type == 'Repeat' %}
189- state.styleMap().mapNinePieceImageRepeat(value, image);
190- {% elif modifier_type == 'Slice' %}
191- state.styleMap().mapNinePieceImageSlice(value, image);
192- {% elif modifier_type == 'Width' %}
193- image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value));
194- {% endif %}
195- state.style()->setBorderImage(image);
196- }
197- {% endmacro %}
198- {{apply_border_image_modifier('CSSPropertyBorderImageOutset', 'Outset')}}
199- {{apply_border_image_modifier('CSSPropertyBorderImageRepeat', 'Repeat')}}
200- {{apply_border_image_modifier('CSSPropertyBorderImageSlice', 'Slice')}}
201- {{apply_border_image_modifier('CSSPropertyBorderImageWidth', 'Width')}}
202-
203- {% macro apply_value_border_image_source(property_id) %}
204- {{declare_value_function(property_id)}}
205- {
206- {% set property = properties[property_id] %}
207- {{set_value(property)}}(state.styleImage({{property_id}}, value));
208- }
209- {% endmacro %}
210- {{apply_value_border_image_source('CSSPropertyBorderImageSource')}}
211-
212107{% macro apply_color(property_id, initial_color='StyleColor::currentColor') %}
213108{% set property = properties[property_id] %}
214109{{declare_initial_function(property_id)}}
0 commit comments