Changeset 176593 in webkit
- Timestamp:
- Dec 1, 2014, 10:42:52 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
css/StyleBuilderCustom.h (modified) (36 diffs)
-
css/makeprop.pl (modified) (1 diff)
-
rendering/style/RenderStyle.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r176592 r176593 1 2014-12-01 Chris Dumez <cdumez@apple.com> 2 3 Transform StyleBuilderCustom into a class and mark it as a friend of RenderStyle 4 https://bugs.webkit.org/show_bug.cgi?id=138999 5 6 Reviewed by Sam Weinig. 7 8 Transform StyleBuilderCustom into a class and mark it as a friend of 9 RenderStyle. This is needed because some of the StyleBuilderCustom 10 functions need to access RenderStyle's private API. 11 12 No new tests, no behavior change. 13 14 * css/StyleBuilderCustom.h: 15 Move functions from StyleBuilderFunctions namespace to 16 StyleBuilderCustom class. 17 18 * css/makeprop.pl: 19 Use StyleBuilderCustom scope instead of StyleBuilderFunctions for 20 custom implementation. 21 22 * rendering/style/RenderStyle.h: 23 Mark StyleBuilderCustom class as a friend, similarly to what was 24 already done for DeprecatedStyleBuilder and StyleResolver. 25 1 26 2014-11-17 Oliver Hunt <oliver@apple.com> 2 27 -
trunk/Source/WebCore/css/StyleBuilderCustom.h
r176584 r176593 40 40 41 41 // Note that we assume the CSS parser only allows valid CSSValue types. 42 namespace StyleBuilderFunctions { 43 44 inline void applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value) 42 class StyleBuilderCustom { 43 public: 44 static void applyValueWebkitMarqueeIncrement(StyleResolver&, CSSValue&); 45 46 static void applyValueDirection(StyleResolver&, CSSValue&); 47 48 static void applyInitialZoom(StyleResolver&); 49 static void applyInheritZoom(StyleResolver&); 50 static void applyValueZoom(StyleResolver&, CSSValue&); 51 52 #if ENABLE(CSS_SHAPES) 53 static void applyValueWebkitShapeOutside(StyleResolver&, CSSValue&); 54 #endif // ENABLE(CSS_SHAPES) 55 56 static void applyValueVerticalAlign(StyleResolver&, CSSValue&); 57 58 #if ENABLE(CSS_IMAGE_RESOLUTION) 59 static void applyInheritImageResolution(StyleResolver&); 60 static void applyInitialImageResolution(StyleResolver&); 61 static void applyValueImageResolution(StyleResolver&, CSSValue&); 62 #endif // ENABLE(CSS_IMAGE_RESOLUTION) 63 64 static void applyInheritSize(StyleResolver&); 65 static void applyInitialSize(StyleResolver&); 66 static void applyValueSize(StyleResolver&, CSSValue&); 67 68 static void applyInheritTextIndent(StyleResolver&); 69 static void applyInitialTextIndent(StyleResolver&); 70 static void applyValueTextIndent(StyleResolver&, CSSValue&); 71 72 #define DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(type, modifier) \ 73 static void applyInherit##type##modifier(StyleResolver&); \ 74 static void applyInitial##type##modifier(StyleResolver&); \ 75 static void applyValue##type##modifier(StyleResolver&, CSSValue&) 76 77 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Outset); 78 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Repeat); 79 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Slice); 80 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Width); 81 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Outset); 82 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Repeat); 83 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Slice); 84 DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width); 85 86 static void applyValueWordSpacing(StyleResolver&, CSSValue&); 87 88 #if ENABLE(IOS_TEXT_AUTOSIZING) 89 static void applyInheritLineHeight(StyleResolver&); 90 static void applyInitialLineHeight(StyleResolver&); 91 #endif // ENABLE(IOS_TEXT_AUTOSIZING) 92 static void applyValueLineHeight(StyleResolver&, CSSValue&); 93 94 static void applyInheritOutlineStyle(StyleResolver&); 95 static void applyInitialOutlineStyle(StyleResolver&); 96 static void applyValueOutlineStyle(StyleResolver&, CSSValue&); 97 98 static void applyInitialClip(StyleResolver&); 99 static void applyInheritClip(StyleResolver&); 100 static void applyValueClip(StyleResolver&, CSSValue&); 101 102 static void applyValueWebkitLocale(StyleResolver&, CSSValue&); 103 static void applyValueWebkitWritingMode(StyleResolver&, CSSValue&); 104 static void applyValueWebkitTextOrientation(StyleResolver&, CSSValue&); 105 static void applyValueWebkitJustifySelf(StyleResolver&, CSSValue&); 106 static void applyValueWebkitPerspective(StyleResolver&, CSSValue&); 107 108 private: 109 static void resetEffectiveZoom(StyleResolver&); 110 static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&); 111 static bool convertLineHeight(StyleResolver&, const CSSValue&, Length&, float multiplier = 1.f); 112 113 static Length mmLength(double mm); 114 static Length inchLength(double inch); 115 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height); 116 }; 117 118 inline void StyleBuilderCustom::applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value) 45 119 { 46 120 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 66 140 } 67 141 68 inline void applyValueDirection(StyleResolver& styleResolver, CSSValue& value)142 inline void StyleBuilderCustom::applyValueDirection(StyleResolver& styleResolver, CSSValue& value) 69 143 { 70 144 styleResolver.style()->setDirection(downcast<CSSPrimitiveValue>(value)); … … 75 149 } 76 150 77 inline void resetEffectiveZoom(StyleResolver& styleResolver)151 inline void StyleBuilderCustom::resetEffectiveZoom(StyleResolver& styleResolver) 78 152 { 79 153 // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect. … … 81 155 } 82 156 83 inline void applyInitialZoom(StyleResolver& styleResolver)157 inline void StyleBuilderCustom::applyInitialZoom(StyleResolver& styleResolver) 84 158 { 85 159 resetEffectiveZoom(styleResolver); … … 87 161 } 88 162 89 inline void applyInheritZoom(StyleResolver& styleResolver)163 inline void StyleBuilderCustom::applyInheritZoom(StyleResolver& styleResolver) 90 164 { 91 165 resetEffectiveZoom(styleResolver); … … 93 167 } 94 168 95 inline void applyValueZoom(StyleResolver& styleResolver, CSSValue& value)169 inline void StyleBuilderCustom::applyValueZoom(StyleResolver& styleResolver, CSSValue& value) 96 170 { 97 171 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 119 193 120 194 #if ENABLE(CSS_SHAPES) 121 inline void applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue& value)195 inline void StyleBuilderCustom::applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue& value) 122 196 { 123 197 if (is<CSSPrimitiveValue>(value)) { … … 153 227 #endif // ENABLE(CSS_SHAPES) 154 228 155 inline Length mmLength(double mm)229 inline Length StyleBuilderCustom::mmLength(double mm) 156 230 { 157 231 Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)); 158 232 return value.get().computeLength<Length>(CSSToLengthConversionData()); 159 233 } 160 inline Length inchLength(double inch)234 inline Length StyleBuilderCustom::inchLength(double inch) 161 235 { 162 236 Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN)); 163 237 return value.get().computeLength<Length>(CSSToLengthConversionData()); 164 238 } 165 static boolgetPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)239 bool StyleBuilderCustom::getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height) 166 240 { 167 241 static NeverDestroyed<Length> a5Width(mmLength(148)); … … 237 311 } 238 312 239 inline void applyValueVerticalAlign(StyleResolver& styleResolver, CSSValue& value)313 inline void StyleBuilderCustom::applyValueVerticalAlign(StyleResolver& styleResolver, CSSValue& value) 240 314 { 241 315 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 247 321 248 322 #if ENABLE(CSS_IMAGE_RESOLUTION) 249 inline void applyInheritImageResolution(StyleResolver& styleResolver)323 inline void StyleBuilderCustom::applyInheritImageResolution(StyleResolver& styleResolver) 250 324 { 251 325 styleResolver.style()->setImageResolutionSource(styleResolver.parentStyle()->imageResolutionSource()); … … 254 328 } 255 329 256 inline void applyInitialImageResolution(StyleResolver& styleResolver)330 inline void StyleBuilderCustom::applyInitialImageResolution(StyleResolver& styleResolver) 257 331 { 258 332 styleResolver.style()->setImageResolutionSource(RenderStyle::initialImageResolutionSource()); … … 261 335 } 262 336 263 inline void applyValueImageResolution(StyleResolver& styleResolver, CSSValue& value)337 inline void StyleBuilderCustom::applyValueImageResolution(StyleResolver& styleResolver, CSSValue& value) 264 338 { 265 339 ImageResolutionSource source = RenderStyle::initialImageResolutionSource(); … … 281 355 #endif // ENABLE(CSS_IMAGE_RESOLUTION) 282 356 283 inline void applyInheritSize(StyleResolver&) { }284 inline void applyInitialSize(StyleResolver&) { }285 inline void applyValueSize(StyleResolver& styleResolver, CSSValue& value)357 inline void StyleBuilderCustom::applyInheritSize(StyleResolver&) { } 358 inline void StyleBuilderCustom::applyInitialSize(StyleResolver&) { } 359 inline void StyleBuilderCustom::applyValueSize(StyleResolver& styleResolver, CSSValue& value) 286 360 { 287 361 styleResolver.style()->resetPageSizeType(); … … 357 431 } 358 432 359 inline void applyInheritTextIndent(StyleResolver& styleResolver)433 inline void StyleBuilderCustom::applyInheritTextIndent(StyleResolver& styleResolver) 360 434 { 361 435 styleResolver.style()->setTextIndent(styleResolver.parentStyle()->textIndent()); … … 366 440 } 367 441 368 inline void applyInitialTextIndent(StyleResolver& styleResolver)442 inline void StyleBuilderCustom::applyInitialTextIndent(StyleResolver& styleResolver) 369 443 { 370 444 styleResolver.style()->setTextIndent(RenderStyle::initialTextIndent()); … … 375 449 } 376 450 377 inline void applyValueTextIndent(StyleResolver& styleResolver, CSSValue& value)451 inline void StyleBuilderCustom::applyValueTextIndent(StyleResolver& styleResolver, CSSValue& value) 378 452 { 379 453 Length lengthOrPercentageValue; … … 472 546 473 547 private: 474 static inlineconst NinePieceImage& getValue(RenderStyle* style)548 static const NinePieceImage& getValue(RenderStyle* style) 475 549 { 476 550 return type == BorderImage ? style->borderImage() : style->maskBoxImage(); 477 551 } 478 552 479 static inlinevoid setValue(RenderStyle* style, const NinePieceImage& value)553 static void setValue(RenderStyle* style, const NinePieceImage& value) 480 554 { 481 555 return type == BorderImage ? style->setBorderImage(value) : style->setMaskBoxImage(value); … … 484 558 485 559 #define DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(type, modifier) \ 486 inline void applyInherit##type##modifier(StyleResolver& styleResolver) \560 inline void StyleBuilderCustom::applyInherit##type##modifier(StyleResolver& styleResolver) \ 487 561 { \ 488 562 ApplyPropertyBorderImageModifier<type, modifier>::applyInheritValue(styleResolver); \ 489 563 } \ 490 inline void applyInitial##type##modifier(StyleResolver& styleResolver) \564 inline void StyleBuilderCustom::applyInitial##type##modifier(StyleResolver& styleResolver) \ 491 565 { \ 492 566 ApplyPropertyBorderImageModifier<type, modifier>::applyInitialValue(styleResolver); \ 493 567 } \ 494 inline void applyValue##type##modifier(StyleResolver& styleResolver, CSSValue& value) \568 inline void StyleBuilderCustom::applyValue##type##modifier(StyleResolver& styleResolver, CSSValue& value) \ 495 569 { \ 496 570 ApplyPropertyBorderImageModifier<type, modifier>::applyValue(styleResolver, value); \ … … 506 580 DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width) 507 581 508 inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)582 inline CSSToLengthConversionData StyleBuilderCustom::csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver) 509 583 { 510 584 if (Frame* frame = styleResolver.document().frame()) … … 514 588 } 515 589 516 inline bool convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier = 1.f)590 inline bool StyleBuilderCustom::convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier) 517 591 { 518 592 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 540 614 } 541 615 542 inline void applyValueWordSpacing(StyleResolver& styleResolver, CSSValue& value)616 inline void StyleBuilderCustom::applyValueWordSpacing(StyleResolver& styleResolver, CSSValue& value) 543 617 { 544 618 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 560 634 #if ENABLE(IOS_TEXT_AUTOSIZING) 561 635 562 inline void applyInheritLineHeight(StyleResolver& styleResolver)636 inline void StyleBuilderCustom::applyInheritLineHeight(StyleResolver& styleResolver) 563 637 { 564 638 styleResolver.style()->setLineHeight(styleResolver.parentStyle()->lineHeight()); … … 566 640 } 567 641 568 inline void applyInitialLineHeight(StyleResolver& styleResolver)642 inline void StyleBuilderCustom::applyInitialLineHeight(StyleResolver& styleResolver) 569 643 { 570 644 styleResolver.style()->setLineHeight(RenderStyle::initialLineHeight()); … … 572 646 } 573 647 574 inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)648 inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value) 575 649 { 576 650 Length lineHeight; … … 585 659 #else 586 660 587 inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)661 inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value) 588 662 { 589 663 Length lineHeight; … … 596 670 #endif 597 671 598 inline void applyInheritOutlineStyle(StyleResolver& styleResolver)672 inline void StyleBuilderCustom::applyInheritOutlineStyle(StyleResolver& styleResolver) 599 673 { 600 674 styleResolver.style()->setOutlineStyleIsAuto(styleResolver.parentStyle()->outlineStyleIsAuto()); … … 602 676 } 603 677 604 inline void applyInitialOutlineStyle(StyleResolver& styleResolver)678 inline void StyleBuilderCustom::applyInitialOutlineStyle(StyleResolver& styleResolver) 605 679 { 606 680 styleResolver.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto()); … … 608 682 } 609 683 610 inline void applyValueOutlineStyle(StyleResolver& styleResolver, CSSValue& value)684 inline void StyleBuilderCustom::applyValueOutlineStyle(StyleResolver& styleResolver, CSSValue& value) 611 685 { 612 686 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 616 690 } 617 691 618 inline void applyInitialClip(StyleResolver& styleResolver)692 inline void StyleBuilderCustom::applyInitialClip(StyleResolver& styleResolver) 619 693 { 620 694 styleResolver.style()->setClip(Length(), Length(), Length(), Length()); … … 622 696 } 623 697 624 inline void applyInheritClip(StyleResolver& styleResolver)698 inline void StyleBuilderCustom::applyInheritClip(StyleResolver& styleResolver) 625 699 { 626 700 RenderStyle* parentStyle = styleResolver.parentStyle(); … … 631 705 } 632 706 633 inline void applyValueClip(StyleResolver& styleResolver, CSSValue& value)707 inline void StyleBuilderCustom::applyValueClip(StyleResolver& styleResolver, CSSValue& value) 634 708 { 635 709 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 649 723 } 650 724 651 inline void applyValueWebkitLocale(StyleResolver& styleResolver, CSSValue& value)725 inline void StyleBuilderCustom::applyValueWebkitLocale(StyleResolver& styleResolver, CSSValue& value) 652 726 { 653 727 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 663 737 } 664 738 665 inline void applyValueWebkitWritingMode(StyleResolver& styleResolver, CSSValue& value)739 inline void StyleBuilderCustom::applyValueWebkitWritingMode(StyleResolver& styleResolver, CSSValue& value) 666 740 { 667 741 styleResolver.setWritingMode(downcast<CSSPrimitiveValue>(value)); … … 673 747 } 674 748 675 inline void applyValueWebkitTextOrientation(StyleResolver& styleResolver, CSSValue& value)749 inline void StyleBuilderCustom::applyValueWebkitTextOrientation(StyleResolver& styleResolver, CSSValue& value) 676 750 { 677 751 styleResolver.setTextOrientation(downcast<CSSPrimitiveValue>(value)); 678 752 } 679 753 680 inline void applyValueWebkitJustifySelf(StyleResolver& styleResolver, CSSValue& value)754 inline void StyleBuilderCustom::applyValueWebkitJustifySelf(StyleResolver& styleResolver, CSSValue& value) 681 755 { 682 756 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 689 763 } 690 764 691 inline void applyValueWebkitPerspective(StyleResolver& styleResolver, CSSValue& value)765 inline void StyleBuilderCustom::applyValueWebkitPerspective(StyleResolver& styleResolver, CSSValue& value) 692 766 { 693 767 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); … … 714 788 } 715 789 716 } // namespace StyleBuilderFunctions717 718 790 } // namespace WebCore 719 791 -
trunk/Source/WebCore/css/makeprop.pl
r176491 r176593 418 418 next unless exists($propertiesWithStyleBuilderOptions{$name}); 419 419 420 my $scope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All" ? "StyleBuilderCustom" : "StyleBuilderFunctions"; 421 my $valueScope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "Value" ? "StyleBuilderCustom" : $scope; 422 420 423 print STYLEBUILDER " case CSSProperty" . $nameToId{$name} . ":\n"; 421 424 print STYLEBUILDER " if (isInitial)\n"; 422 print STYLEBUILDER " StyleBuilderFunctions::applyInitial" . $nameToId{$name} . "(styleResolver);\n";425 print STYLEBUILDER " " . $scope . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n"; 423 426 print STYLEBUILDER " else if (isInherit)\n"; 424 print STYLEBUILDER " StyleBuilderFunctions::applyInherit" . $nameToId{$name} . "(styleResolver);\n";427 print STYLEBUILDER " " . $scope . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n"; 425 428 print STYLEBUILDER " else\n"; 426 print STYLEBUILDER " StyleBuilderFunctions::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";429 print STYLEBUILDER " " . $valueScope . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n"; 427 430 print STYLEBUILDER " return true;\n"; 428 431 } -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r176369 r176593 129 129 friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps. 130 130 friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors. Rebaselining would allow this to be yanked. 131 friend class StyleBuilderCustom; // Sets members directly. 131 132 friend class StyleResolver; // Sets members directly. 132 133
Note:
See TracChangeset
for help on using the changeset viewer.