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

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

Issue 1153353002: Fast path when setting border-image-width to initial always fails (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed review comments Created 5 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
« 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 {% endmacro %} 151 {% endmacro %}
152 {{apply_auto('CSSPropertyClip')}} 152 {{apply_auto('CSSPropertyClip')}}
153 {{apply_auto('CSSPropertyOrphans')}} 153 {{apply_auto('CSSPropertyOrphans')}}
154 {{apply_auto('CSSPropertyWebkitColumnCount')}} 154 {{apply_auto('CSSPropertyWebkitColumnCount')}}
155 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal')}} 155 {{apply_auto('CSSPropertyWebkitColumnGap', auto_getter='hasNormalColumnGap', aut o_setter='setHasNormalColumnGap', auto_identity='CSSValueNormal')}}
156 {{apply_auto('CSSPropertyWebkitColumnWidth')}} 156 {{apply_auto('CSSPropertyWebkitColumnWidth')}}
157 {{apply_auto('CSSPropertyWidows')}} 157 {{apply_auto('CSSPropertyWidows')}}
158 {{apply_auto('CSSPropertyZIndex')}} 158 {{apply_auto('CSSPropertyZIndex')}}
159 159
160 static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float value) 160 static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, const Length& le ngth)
Timothy Loh 2015/06/03 05:27:44 rename to lengthMatchesAllSides?
Sunil Ratnu 2015/06/03 05:42:25 Seems more appropriate. Done.
161 { 161 {
162 return length.type() == type && length.value() == value; 162 return (lengthBox.left() == length
163 && lengthBox.right() == length
164 && lengthBox.top() == length
165 && lengthBox.bottom() == length);
163 } 166 }
164 167
165 static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type, float value) 168 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, const BorderImageLength& borderImageLength)
Timothy Loh 2015/06/03 05:27:44 rename to borderImageLengthMatchesAllSides?
Sunil Ratnu 2015/06/03 05:42:26 Seems more appropriate. Done.
166 { 169 {
167 return (lengthTypeAndValueMatch(lengthBox.left(), type, value) 170 return (borderImageLengthBox.left() == borderImageLength
168 && lengthTypeAndValueMatch(lengthBox.right(), type, value) 171 && borderImageLengthBox.right() == borderImageLength
169 && lengthTypeAndValueMatch(lengthBox.top(), type, value) 172 && borderImageLengthBox.top() == borderImageLength
170 && lengthTypeAndValueMatch(lengthBox.bottom(), type, value)); 173 && borderImageLengthBox.bottom() == borderImageLength);
171 }
172
173 static bool lengthTypeAndValueMatch(const BorderImageLength& borderImageLength, LengthType type, float value)
174 {
175 return borderImageLength.isLength() && lengthTypeAndValueMatch(borderImageLe ngth.length(), type, value);
176 }
177
178 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, LengthType type, float value)
179 {
180 return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value)
181 && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value)
182 && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value)
183 && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value));
184 } 174 }
185 175
186 {% macro apply_border_image_modifier(property_id, modifier_type) %} 176 {% macro apply_border_image_modifier(property_id, modifier_type) %}
187 {% set is_mask_box = 'MaskBox' in property_id %} 177 {% set is_mask_box = 'MaskBox' in property_id %}
188 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %} 178 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %}
189 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %} 179 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %}
190 {{ declare_initial_function(property_id) }} 180 {{ declare_initial_function(property_id) }}
191 { 181 {
192 const NinePieceImage& currentImage = state.style()->{{getter}}(); 182 const NinePieceImage& currentImage = state.style()->{{getter}}();
193 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #} 183 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #}
194 {% if modifier_type == 'Outset' %} 184 {% if modifier_type == 'Outset' %}
195 if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0)) 185 if (lengthTypeAndValueMatch(currentImage.outset(), BorderImageLength(Length( 0, Fixed))))
196 return; 186 return;
197 {% elif modifier_type == 'Repeat' %} 187 {% elif modifier_type == 'Repeat' %}
198 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule) 188 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule)
199 return; 189 return;
200 {% elif modifier_type == 'Slice' and is_mask_box %} 190 {% elif modifier_type == 'Slice' and is_mask_box %}
201 // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility. 191 // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
202 if (currentImage.fill() == true && lengthTypeAndValueMatch(currentImage.imag eSlices(), Fixed, 0)) 192 if (currentImage.fill() == true && lengthTypeAndValueMatch(currentImage.imag eSlices(), Length(0, Fixed)))
203 return; 193 return;
204 {% elif modifier_type == 'Slice' and not is_mask_box %} 194 {% elif modifier_type == 'Slice' and not is_mask_box %}
205 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Percent, 100)) 195 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Length(100, Percent)))
206 return; 196 return;
207 {% elif modifier_type == 'Width' and is_mask_box %} 197 {% elif modifier_type == 'Width' and is_mask_box %}
208 // Masks have a different initial value for widths. Preserve the value of 'a uto' for backwards compatibility. 198 // Masks have a different initial value for widths. Preserve the value of 'a uto' for backwards compatibility.
209 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Auto, 0)) 199 if (lengthTypeAndValueMatch(currentImage.borderSlices(), BorderImageLength(L ength(Auto))))
210 return; 200 return;
211 {% elif modifier_type == 'Width' and not is_mask_box %} 201 {% elif modifier_type == 'Width' and not is_mask_box %}
212 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1)) 202 if (lengthTypeAndValueMatch(currentImage.borderSlices(), BorderImageLength(1 .0)))
213 return; 203 return;
214 {% endif %} 204 {% endif %}
215 205
216 NinePieceImage image(currentImage); 206 NinePieceImage image(currentImage);
217 {% if modifier_type == 'Outset' %} 207 {% if modifier_type == 'Outset' %}
218 image.setOutset(Length(0, Fixed)); 208 image.setOutset(Length(0, Fixed));
219 {% elif modifier_type == 'Repeat' %} 209 {% elif modifier_type == 'Repeat' %}
220 image.setHorizontalRule(StretchImageRule); 210 image.setHorizontalRule(StretchImageRule);
221 image.setVerticalRule(StretchImageRule); 211 image.setVerticalRule(StretchImageRule);
222 {% elif modifier_type == 'Slice' and is_mask_box %} 212 {% elif modifier_type == 'Slice' and is_mask_box %}
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 547 }
558 {{set_value(property)}}(ptype, c, url, 548 {{set_value(property)}}(ptype, c, url,
559 state.applyPropertyToRegularStyle(), 549 state.applyPropertyToRegularStyle(),
560 state.applyPropertyToVisitedLinkStyle()); 550 state.applyPropertyToVisitedLinkStyle());
561 } 551 }
562 } 552 }
563 {% endmacro %} 553 {% endmacro %}
564 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} 554 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}}
565 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} 555 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}}
566 } // namespace blink 556 } // namespace blink
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