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

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

Issue 893093002: Delete remaining masks dead code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | sky/engine/core/css/SVGCSSValueKeywords.in » ('j') | 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, LengthType type, float value) 168 static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt hBox, LengthType type, float value)
169 { 169 {
170 return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value) 170 return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value)
171 && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value) 171 && lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value)
172 && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value) 172 && lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value)
173 && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value)); 173 && lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value));
174 } 174 }
175 175
176 {% macro apply_border_image_modifier(property_id, modifier_type) %} 176 {% macro apply_border_image_modifier(property_id, modifier_type) %}
177 {% set is_mask_box = 'MaskBox' in property_id %}
178 {% set getter = 'maskBoxImage' if is_mask_box else 'borderImage' %}
179 {% set setter = 'setMaskBoxImage' if is_mask_box else 'setBorderImage' %}
180 {{ declare_initial_function(property_id) }} 177 {{ declare_initial_function(property_id) }}
181 { 178 {
182 const NinePieceImage& currentImage = state.style()->{{getter}}(); 179 const NinePieceImage& currentImage = state.style()->borderImage();
183 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #} 180 {# Check for equality in case we can bail out before creating a new NinePiec eImage. #}
184 {% if modifier_type == 'Outset' %} 181 {% if modifier_type == 'Outset' %}
185 if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0)) 182 if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0))
186 return; 183 return;
187 {% elif modifier_type == 'Repeat' %} 184 {% elif modifier_type == 'Repeat' %}
188 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule) 185 if (currentImage.horizontalRule() == StretchImageRule && currentImage.vertic alRule() == StretchImageRule)
189 return; 186 return;
190 {% elif modifier_type == 'Slice' and is_mask_box %} 187 {% elif modifier_type == 'Slice' %}
191 // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
192 if (currentImage.fill() == true && lengthTypeAndValueMatch(currentImage.imag eSlices(), Fixed, 0))
193 return;
194 {% elif modifier_type == 'Slice' and not is_mask_box %}
195 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Percent, 100)) 188 if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.ima geSlices(), Percent, 100))
196 return; 189 return;
197 {% elif modifier_type == 'Width' and is_mask_box %} 190 {% elif modifier_type == 'Width' %}
198 // Masks have a different initial value for widths. Preserve the value of 'a uto' for backwards compatibility.
199 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Auto, 0))
200 return;
201 {% elif modifier_type == 'Width' and not is_mask_box %}
202 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1)) 191 if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1))
203 return; 192 return;
204 {% endif %} 193 {% endif %}
205 194
206 NinePieceImage image(currentImage); 195 NinePieceImage image(currentImage);
207 {% if modifier_type == 'Outset' %} 196 {% if modifier_type == 'Outset' %}
208 image.setOutset(Length(0, Fixed)); 197 image.setOutset(Length(0, Fixed));
209 {% elif modifier_type == 'Repeat' %} 198 {% elif modifier_type == 'Repeat' %}
210 image.setHorizontalRule(StretchImageRule); 199 image.setHorizontalRule(StretchImageRule);
211 image.setVerticalRule(StretchImageRule); 200 image.setVerticalRule(StretchImageRule);
212 {% elif modifier_type == 'Slice' and is_mask_box %} 201 {% elif modifier_type == 'Slice' %}
213 image.setImageSlices(LengthBox({{ (['Length(0, Fixed)']*4) | join(', ') }})) ;
214 image.setFill(true);
215 {% elif modifier_type == 'Slice' and not is_mask_box %}
216 image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }})); 202 image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }}));
217 image.setFill(false); 203 image.setFill(false);
218 {% elif modifier_type == 'Width' %} 204 {% elif modifier_type == 'Width' %}
219 image.setBorderSlices({{ 'Length(Auto)' if is_mask_box else '1.0' }}); 205 image.setBorderSlices(1.0);
220 {% endif %} 206 {% endif %}
221 state.style()->{{setter}}(image); 207 state.style()->setBorderImage(image);
222 } 208 }
223 209
224 {{declare_inherit_function(property_id)}} 210 {{declare_inherit_function(property_id)}}
225 { 211 {
226 NinePieceImage image(state.style()->{{getter}}()); 212 NinePieceImage image(state.style()->borderImage());
227 {% if modifier_type == 'Outset' %} 213 {% if modifier_type == 'Outset' %}
228 image.copyOutsetFrom(state.parentStyle()->{{getter}}()); 214 image.copyOutsetFrom(state.parentStyle()->borderImage());
229 {% elif modifier_type == 'Repeat' %} 215 {% elif modifier_type == 'Repeat' %}
230 image.copyRepeatFrom(state.parentStyle()->{{getter}}()); 216 image.copyRepeatFrom(state.parentStyle()->borderImage());
231 {% elif modifier_type == 'Slice' %} 217 {% elif modifier_type == 'Slice' %}
232 image.copyImageSlicesFrom(state.parentStyle()->{{getter}}()); 218 image.copyImageSlicesFrom(state.parentStyle()->borderImage());
233 {% elif modifier_type == 'Width' %} 219 {% elif modifier_type == 'Width' %}
234 image.copyBorderSlicesFrom(state.parentStyle()->{{getter}}()); 220 image.copyBorderSlicesFrom(state.parentStyle()->borderImage());
235 {% endif %} 221 {% endif %}
236 state.style()->{{setter}}(image); 222 state.style()->setBorderImage(image);
237 } 223 }
238 224
239 {{declare_value_function(property_id)}} 225 {{declare_value_function(property_id)}}
240 { 226 {
241 NinePieceImage image(state.style()->{{getter}}()); 227 NinePieceImage image(state.style()->borderImage());
242 {% if modifier_type == 'Outset' %} 228 {% if modifier_type == 'Outset' %}
243 image.setOutset(state.styleMap().mapNinePieceImageQuad(value)); 229 image.setOutset(state.styleMap().mapNinePieceImageQuad(value));
244 {% elif modifier_type == 'Repeat' %} 230 {% elif modifier_type == 'Repeat' %}
245 state.styleMap().mapNinePieceImageRepeat(value, image); 231 state.styleMap().mapNinePieceImageRepeat(value, image);
246 {% elif modifier_type == 'Slice' %} 232 {% elif modifier_type == 'Slice' %}
247 state.styleMap().mapNinePieceImageSlice(value, image); 233 state.styleMap().mapNinePieceImageSlice(value, image);
248 {% elif modifier_type == 'Width' %} 234 {% elif modifier_type == 'Width' %}
249 image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value)); 235 image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value));
250 {% endif %} 236 {% endif %}
251 state.style()->{{setter}}(image); 237 state.style()->setBorderImage(image);
252 } 238 }
253 {% endmacro %} 239 {% endmacro %}
254 {{apply_border_image_modifier('CSSPropertyBorderImageOutset', 'Outset')}} 240 {{apply_border_image_modifier('CSSPropertyBorderImageOutset', 'Outset')}}
255 {{apply_border_image_modifier('CSSPropertyBorderImageRepeat', 'Repeat')}} 241 {{apply_border_image_modifier('CSSPropertyBorderImageRepeat', 'Repeat')}}
256 {{apply_border_image_modifier('CSSPropertyBorderImageSlice', 'Slice')}} 242 {{apply_border_image_modifier('CSSPropertyBorderImageSlice', 'Slice')}}
257 {{apply_border_image_modifier('CSSPropertyBorderImageWidth', 'Width')}} 243 {{apply_border_image_modifier('CSSPropertyBorderImageWidth', 'Width')}}
258 244
259 {% macro apply_value_border_image_source(property_id) %} 245 {% macro apply_value_border_image_source(property_id) %}
260 {{declare_value_function(property_id)}} 246 {{declare_value_function(property_id)}}
261 { 247 {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 {% if action == 'Reset' %} 331 {% if action == 'Reset' %}
346 directives.setResetValue(value); 332 directives.setResetValue(value);
347 {% else %} 333 {% else %}
348 directives.addIncrementValue(value); 334 directives.addIncrementValue(value);
349 {% endif %} 335 {% endif %}
350 } 336 }
351 } 337 }
352 {% endmacro %} 338 {% endmacro %}
353 339
354 {% macro apply_fill_layer(property_id, fill_type) %} 340 {% macro apply_fill_layer(property_id, fill_type) %}
355 {% set layer_type = 'Background' if 'Background' in property_id else 'Mask' %} 341 {% set access_layers = 'accessBackgroundLayers' %}
356 {% set fill_layer_type = layer_type + 'FillLayer' %}
357 {% set access_layers = 'access' + layer_type + 'Layers' %}
358 {% set map_fill = 'mapFill' + fill_type %} 342 {% set map_fill = 'mapFill' + fill_type %}
359 {{declare_initial_function(property_id)}} 343 {{declare_initial_function(property_id)}}
360 { 344 {
361 FillLayer* currChild = &state.style()->{{access_layers}}(); 345 FillLayer* currChild = &state.style()->{{access_layers}}();
362 currChild->set{{fill_type}}(FillLayer::initialFill{{fill_type}}({{fill_layer _type}})); 346 currChild->set{{fill_type}}(FillLayer::initialFill{{fill_type}}(BackgroundFi llLayer));
363 for (currChild = currChild->next(); currChild; currChild = currChild->next() ) 347 for (currChild = currChild->next(); currChild; currChild = currChild->next() )
364 currChild->clear{{fill_type}}(); 348 currChild->clear{{fill_type}}();
365 } 349 }
366 350
367 {{declare_inherit_function(property_id)}} 351 {{declare_inherit_function(property_id)}}
368 { 352 {
369 FillLayer* currChild = &state.style()->{{access_layers}}(); 353 FillLayer* currChild = &state.style()->{{access_layers}}();
370 FillLayer* prevChild = 0; 354 FillLayer* prevChild = 0;
371 const FillLayer* currParent = &state.parentStyle()->{{layer_type|lower}}Laye rs(); 355 const FillLayer* currParent = &state.parentStyle()->backgroundLayers();
372 while (currParent && currParent->is{{fill_type}}Set()) { 356 while (currParent && currParent->is{{fill_type}}Set()) {
373 if (!currChild) 357 if (!currChild)
374 currChild = prevChild->ensureNext(); 358 currChild = prevChild->ensureNext();
375 currChild->set{{fill_type}}(currParent->{{fill_type|lower_first}}()); 359 currChild->set{{fill_type}}(currParent->{{fill_type|lower_first}}());
376 prevChild = currChild; 360 prevChild = currChild;
377 currChild = prevChild->next(); 361 currChild = prevChild->next();
378 currParent = currParent->next(); 362 currParent = currParent->next();
379 } 363 }
380 364
381 while (currChild) { 365 while (currChild) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second ()); 442 state.style()->set{{alignment_type}}OverflowAlignment(*pairValue->second ());
459 } else { 443 } else {
460 state.style()->set{{alignment_type}}(*primitiveValue); 444 state.style()->set{{alignment_type}}(*primitiveValue);
461 } 445 }
462 } 446 }
463 {% endmacro %} 447 {% endmacro %}
464 {{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}} 448 {{apply_alignment('CSSPropertyAlignItems', 'AlignItems')}}
465 {{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}} 449 {{apply_alignment('CSSPropertyAlignSelf', 'AlignSelf')}}
466 450
467 } // namespace blink 451 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/css/SVGCSSValueKeywords.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698