Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: Source/build/scripts/templates/StyleBuilderFunctions.cpp.tmpl

Issue 340703004: Check before setting initial border image styles (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reorder for readability Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% from 'macros.tmpl' import license %} 1 {% from 'macros.tmpl' import license %}
2 {# 2 {#
3 This file is for property handlers which use the templating engine to 3 This file is for property handlers which use the templating engine to
4 reduce (handwritten) code duplication. 4 reduce (handwritten) code duplication.
5 5
6 The `properties' dict can be used to access a property's parameters in 6 The `properties' dict can be used to access a property's parameters in
7 jinja2 templates (i.e. setter, getter, initial, type_name) 7 jinja2 templates (i.e. setter, getter, initial, type_name)
8 #} 8 #}
9 #include "config.h" 9 #include "config.h"
10 #include "StyleBuilderFunctions.h" 10 #include "StyleBuilderFunctions.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 {% endif %} 149 {% endif %}
150 } 150 }
151 {% endmacro %} 151 {% endmacro %}
152 {{apply_auto('CSSPropertyOrphans')}} 152 {{apply_auto('CSSPropertyOrphans')}}
153 {{apply_auto('CSSPropertyWebkitColumnCount')}} 153 {{apply_auto('CSSPropertyWebkitColumnCount')}}
154 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal', compute_length =true)}} 154 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal', compute_length =true)}}
155 {{apply_auto('CSSPropertyWebkitColumnWidth', compute_length=true)}} 155 {{apply_auto('CSSPropertyWebkitColumnWidth', compute_length=true)}}
156 {{apply_auto('CSSPropertyWidows')}} 156 {{apply_auto('CSSPropertyWidows')}}
157 {{apply_auto('CSSPropertyZIndex')}} 157 {{apply_auto('CSSPropertyZIndex')}}
158 158
159 static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float value)
160 {
161 return length.type() == type && length.value() == value;
162 }
163
164 static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type, float value)
165 {
166 return (lengthTypeAndValueMatch(lengthBox.left(), type, value)
167 && lengthTypeAndValueMatch(lengthBox.right(), type, value)
168 && lengthTypeAndValueMatch(lengthBox.top(), type, value)
169 && lengthTypeAndValueMatch(lengthBox.bottom(), type, value));
170 }
171
172 static bool lengthTypeAndValueMatch(const BorderImageLength& borderImageLength, LengthType type, float value)
173 {
174 return borderImageLength.isLength() && lengthTypeAndValueMatch(borderImageLe ngth.length(), type, value);
175 }
176
177 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, LengthType type, float value)
178 {
179 return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value)
180 && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value)
181 && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value)
182 && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value));
183 }
184
159 {% macro apply_border_image_modifier(property_id, modifier_type) %} 185 {% macro apply_border_image_modifier(property_id, modifier_type) %}
160 {% set is_mask_box = 'MaskBox' in property_id %} 186 {% set is_mask_box = 'MaskBox' in property_id %}
161 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %} 187 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %}
162 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %} 188 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %}
163 {{ declare_initial_function(property_id) }} 189 {{ declare_initial_function(property_id) }}
164 { 190 {
165 NinePieceImage image(state.style()->{{getter}}()); 191 const NinePieceImage& currentImage = state.style()->{{getter}}();
192 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #}
193 {% if modifier_type == 'Outset' %}
194 if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0))
195 return;
196 {% elif modifier_type == 'Repeat' %}
197 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule)
198 return;
199 {% elif modifier_type == 'Slice' and is_mask_box %}
200 // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
201 if (currentImage.fill() == true && lengthTypeAndValueMatch(currentImage.imag eSlices(), Fixed, 0))
202 return;
203 {% elif modifier_type == 'Slice' and not is_mask_box %}
204 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Percent, 100))
205 return;
206 {% elif modifier_type == 'Width' and is_mask_box %}
207 // Masks have a different initial value for widths. Preserve the value of 'a uto' for backwards compatibility.
208 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Auto, 0))
209 return;
210 {% elif modifier_type == 'Width' and not is_mask_box %}
211 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1))
212 return;
213 {% endif %}
214
215 NinePieceImage image(currentImage);
166 {% if modifier_type == 'Outset' %} 216 {% if modifier_type == 'Outset' %}
167 image.setOutset(Length(0, Fixed)); 217 image.setOutset(Length(0, Fixed));
168 {% elif modifier_type == 'Repeat' %} 218 {% elif modifier_type == 'Repeat' %}
169 image.setHorizontalRule(StretchImageRule); 219 image.setHorizontalRule(StretchImageRule);
170 image.setVerticalRule(StretchImageRule); 220 image.setVerticalRule(StretchImageRule);
171 {% elif modifier_type == 'Slice' and is_mask_box %} 221 {% elif modifier_type == 'Slice' and is_mask_box %}
172 // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
173 image.setImageSlices(LengthBox({{ (['Length(0, Fixed)']*4) | join(', ') }})) ; 222 image.setImageSlices(LengthBox({{ (['Length(0, Fixed)']*4) | join(', ') }})) ;
174 image.setFill(true); 223 image.setFill(true);
175 {% elif modifier_type == 'Slice' and not is_mask_box %} 224 {% elif modifier_type == 'Slice' and not is_mask_box %}
176 image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }})); 225 image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }}));
177 image.setFill(false); 226 image.setFill(false);
178 {% elif modifier_type == 'Width' %} 227 {% elif modifier_type == 'Width' %}
179 // Masks have a different initial value for widths. Preserve the value of 'a uto' for backwards compatibility.
180 image.setBorderSlices({{ 'Length(Auto)' if is_mask_box else '1.0' }}); 228 image.setBorderSlices({{ 'Length(Auto)' if is_mask_box else '1.0' }});
181 {% endif %} 229 {% endif %}
182 state.style()->{{setter}}(image); 230 state.style()->{{setter}}(image);
183 } 231 }
184 232
185 {{declare_inherit_function(property_id)}} 233 {{declare_inherit_function(property_id)}}
186 { 234 {
187 NinePieceImage image(state.style()->{{getter}}()); 235 NinePieceImage image(state.style()->{{getter}}());
188 {% if modifier_type == 'Outset' %} 236 {% if modifier_type == 'Outset' %}
189 image.copyOutsetFrom(state.parentStyle()->{{getter}}()); 237 image.copyOutsetFrom(state.parentStyle()->{{getter}}());
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 color, 610 color,
563 svgPaint->uri(), 611 svgPaint->uri(),
564 state.applyPropertyToRegularStyle(), 612 state.applyPropertyToRegularStyle(),
565 state.applyPropertyToVisitedLinkStyle()); 613 state.applyPropertyToVisitedLinkStyle());
566 } 614 }
567 } 615 }
568 {% endmacro %} 616 {% endmacro %}
569 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} 617 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}}
570 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} 618 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}}
571 } // namespace WebCore 619 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698