Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 } | 176 } |
| 177 | 177 |
| 178 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, LengthType type, float value) | 178 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, LengthType type, float value) |
| 179 { | 179 { |
| 180 return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value) | 180 return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value) |
| 181 && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value) | 181 && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value) |
| 182 && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value) | 182 && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value) |
| 183 && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value)); | 183 && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 static bool numberTypeAndValueMatch(const BorderImageLength& borderImageLength, float value) | |
| 187 { | |
| 188 return borderImageLength.isNumber() && (borderImageLength.number() == value) ; | |
| 189 } | |
| 190 | |
| 191 static bool numberTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, float value) | |
|
Timothy Loh
2015/05/29 02:10:15
Naming is weird, lengthTypeAndValueMatch is checki
Sunil Ratnu
2015/05/29 13:56:01
Made the changes. Now passing BorderImageLength as
| |
| 192 { | |
| 193 return (numberTypeAndValueMatch(borderImageLengthBox.left(), value) | |
| 194 && numberTypeAndValueMatch(borderImageLengthBox.right(), value) | |
| 195 && numberTypeAndValueMatch(borderImageLengthBox.top(), value) | |
| 196 && numberTypeAndValueMatch(borderImageLengthBox.bottom(), value)); | |
| 197 } | |
| 198 | |
| 186 {% macro apply_border_image_modifier(property_id, modifier_type) %} | 199 {% macro apply_border_image_modifier(property_id, modifier_type) %} |
| 187 {% set is_mask_box = 'MaskBox' in property_id %} | 200 {% set is_mask_box = 'MaskBox' in property_id %} |
| 188 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %} | 201 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %} |
| 189 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %} | 202 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %} |
| 190 {{ declare_initial_function(property_id) }} | 203 {{ declare_initial_function(property_id) }} |
| 191 { | 204 { |
| 192 const NinePieceImage& currentImage = state.style()->{{getter}}(); | 205 const NinePieceImage& currentImage = state.style()->{{getter}}(); |
| 193 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #} | 206 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #} |
| 194 {% if modifier_type == 'Outset' %} | 207 {% if modifier_type == 'Outset' %} |
| 195 if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0)) | 208 if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0)) |
| 196 return; | 209 return; |
| 197 {% elif modifier_type == 'Repeat' %} | 210 {% elif modifier_type == 'Repeat' %} |
| 198 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule) | 211 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule) |
| 199 return; | 212 return; |
| 200 {% elif modifier_type == 'Slice' and is_mask_box %} | 213 {% 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. | 214 // 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)) | 215 if (currentImage.fill() == true && lengthTypeAndValueMatch(currentImage.imag eSlices(), Fixed, 0)) |
| 203 return; | 216 return; |
| 204 {% elif modifier_type == 'Slice' and not is_mask_box %} | 217 {% elif modifier_type == 'Slice' and not is_mask_box %} |
| 205 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Percent, 100)) | 218 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Percent, 100)) |
| 206 return; | 219 return; |
| 207 {% elif modifier_type == 'Width' and is_mask_box %} | 220 {% 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. | 221 // Masks have a different initial value for widths. Preserve the value of 'a uto' for backwards compatibility. |
| 209 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Auto, 0)) | 222 if (numberTypeAndValueMatch(currentImage.borderSlices(), 0)) |
|
Timothy Loh
2015/05/29 02:10:15
I think this is wrong. The default for -webkit-mas
Sunil Ratnu
2015/05/29 13:56:01
Done.
| |
| 210 return; | 223 return; |
| 211 {% elif modifier_type == 'Width' and not is_mask_box %} | 224 {% elif modifier_type == 'Width' and not is_mask_box %} |
| 212 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1)) | 225 if (numberTypeAndValueMatch(currentImage.borderSlices(), 1.0)) |
|
Timothy Loh
2015/05/29 02:10:15
This is fixing a bug, right? We could add a test h
Sunil Ratnu
2015/05/29 13:56:01
Not sure if its fixing a bug for which we can have
| |
| 213 return; | 226 return; |
| 214 {% endif %} | 227 {% endif %} |
| 215 | 228 |
| 216 NinePieceImage image(currentImage); | 229 NinePieceImage image(currentImage); |
| 217 {% if modifier_type == 'Outset' %} | 230 {% if modifier_type == 'Outset' %} |
| 218 image.setOutset(Length(0, Fixed)); | 231 image.setOutset(Length(0, Fixed)); |
| 219 {% elif modifier_type == 'Repeat' %} | 232 {% elif modifier_type == 'Repeat' %} |
| 220 image.setHorizontalRule(StretchImageRule); | 233 image.setHorizontalRule(StretchImageRule); |
| 221 image.setVerticalRule(StretchImageRule); | 234 image.setVerticalRule(StretchImageRule); |
| 222 {% elif modifier_type == 'Slice' and is_mask_box %} | 235 {% elif modifier_type == 'Slice' and is_mask_box %} |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 } | 570 } |
| 558 {{set_value(property)}}(ptype, c, url, | 571 {{set_value(property)}}(ptype, c, url, |
| 559 state.applyPropertyToRegularStyle(), | 572 state.applyPropertyToRegularStyle(), |
| 560 state.applyPropertyToVisitedLinkStyle()); | 573 state.applyPropertyToVisitedLinkStyle()); |
| 561 } | 574 } |
| 562 } | 575 } |
| 563 {% endmacro %} | 576 {% endmacro %} |
| 564 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} | 577 {{apply_svg_paint('CSSPropertyFill', 'FillPaint')}} |
| 565 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} | 578 {{apply_svg_paint('CSSPropertyStroke', 'StrokePaint')}} |
| 566 } // namespace blink | 579 } // namespace blink |
| OLD | NEW |