⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176721 in webkit


Ignore:
Timestamp:
Dec 3, 2014, 6:46:15 AM (12 years ago)
Author:
Chris Dumez
Message:

Move 'display' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=139218

Reviewed by Antti Koivisto.

Move 'display' CSS property to the new StyleBuilder.

No new tests, no behavior change.

  • css/CSSPropertyNames.in:
  • css/DeprecatedStyleBuilder.cpp:

(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyDisplay::isValidDisplayValue): Deleted.
(WebCore::ApplyPropertyDisplay::applyInheritValue): Deleted.
(WebCore::ApplyPropertyDisplay::applyInitialValue): Deleted.
(WebCore::ApplyPropertyDisplay::applyValue): Deleted.
(WebCore::ApplyPropertyDisplay::createHandler): Deleted.

  • css/StyleBuilderCustom.h:

(WebCore::StyleBuilderCustom::isValidDisplayValue):
(WebCore::StyleBuilderCustom::applyInheritDisplay):
(WebCore::StyleBuilderCustom::applyValueDisplay):

  • css/makeprop.pl:

Add support for passing multiple values for Custom option, e.g.:
'Custom=Inherit|Value'. This was useful as we did not need custom
code for display's initial value.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176719 r176721  
     12014-12-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Move 'display' CSS property to the new StyleBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=139218
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move 'display' CSS property to the new StyleBuilder.
     9
     10        No new tests, no behavior change.
     11
     12        * css/CSSPropertyNames.in:
     13        * css/DeprecatedStyleBuilder.cpp:
     14        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
     15        (WebCore::ApplyPropertyDisplay::isValidDisplayValue): Deleted.
     16        (WebCore::ApplyPropertyDisplay::applyInheritValue): Deleted.
     17        (WebCore::ApplyPropertyDisplay::applyInitialValue): Deleted.
     18        (WebCore::ApplyPropertyDisplay::applyValue): Deleted.
     19        (WebCore::ApplyPropertyDisplay::createHandler): Deleted.
     20        * css/StyleBuilderCustom.h:
     21        (WebCore::StyleBuilderCustom::isValidDisplayValue):
     22        (WebCore::StyleBuilderCustom::applyInheritDisplay):
     23        (WebCore::StyleBuilderCustom::applyValueDisplay):
     24        * css/makeprop.pl:
     25        Add support for passing multiple values for Custom option, e.g.:
     26        'Custom=Inherit|Value'. This was useful as we did not need custom
     27        code for display's initial value.
     28
    1292014-12-03  Chris Dumez  <cdumez@apple.com>
    230
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r176657 r176721  
    4545// css/StyleBuilderConverter.h should be used.
    4646//
    47 // * Custom=[Value|All]:
     47// * Custom=[Initial|Value|Inherit|All]:
     48// Custom=Initial option is used to indicate that the CSS property requires
     49// special handling to set its initial value.
     50// Custom=Inherit option is used to indicate that the CSS property requires
     51// special handling to set its inherit value.
    4852// Custom=Value option is used to indicate that the CSS property requires special
    4953// handling to set its value, and a regular Converter helper cannot be
     
    5155// css/StyleBuilderCustom.h and named applyValue[CSSPropertyName]().
    5256// If special handling is also needed to apply inherit or initial value, use
    53 // Custom=All.
     57// Custom=All. Alternatively, several '|'-separated options can be passed:
     58// e.g. 'Custom=Inherit|Value".
    5459
    5560
     
    5863color [Inherited, LegacyStyleBuilder]
    5964direction [Inherited, Custom=Value]
    60 display [LegacyStyleBuilder]
     65display [Custom=Inherit|Value]
    6166font [Inherited, LegacyStyleBuilder]
    6267font-family [Inherited, Custom=All]
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r176657 r176721  
    968968};
    969969
    970 class ApplyPropertyDisplay {
    971 private:
    972     static inline bool isValidDisplayValue(StyleResolver* styleResolver, EDisplay displayPropertyValue)
    973     {
    974         if (styleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO)
    975             return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
    976         return true;
    977     }
    978 public:
    979     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
    980     {
    981         EDisplay display = styleResolver->parentStyle()->display();
    982         if (!isValidDisplayValue(styleResolver, display))
    983             return;
    984         styleResolver->style()->setDisplay(display);
    985     }
    986 
    987     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
    988     {
    989         styleResolver->style()->setDisplay(RenderStyle::initialDisplay());
    990     }
    991 
    992     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    993     {
    994         if (!is<CSSPrimitiveValue>(*value))
    995             return;
    996 
    997         EDisplay display = downcast<CSSPrimitiveValue>(*value);
    998 
    999         if (!isValidDisplayValue(styleResolver, display))
    1000             return;
    1001 
    1002         styleResolver->style()->setDisplay(display);
    1003     }
    1004 
    1005     static PropertyHandler createHandler()
    1006     {
    1007         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
    1008     }
    1009 };
    1010 
    1011970const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
    1012971{
     
    1040999    setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter<Reset>::createHandler());
    10411000    setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
    1042     setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
    10431001    setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
    10441002    setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r176657 r176721  
    3636#include "LocaleToScriptMapping.h"
    3737#include "Rect.h"
     38#include "SVGElement.h"
    3839#include "StyleFontSizeFunctions.h"
    3940#include "StyleResolver.h"
     
    122123    static void applyValueFontFamily(StyleResolver&, CSSValue&);
    123124
     125    static void applyInheritDisplay(StyleResolver&);
     126    static void applyValueDisplay(StyleResolver&, CSSValue&);
     127
    124128private:
    125129    static void resetEffectiveZoom(StyleResolver&);
     
    133137    template <CSSPropertyID id>
    134138    static void applyTextOrBoxShadowValue(StyleResolver&, CSSValue&);
     139    static bool isValidDisplayValue(StyleResolver&, EDisplay);
    135140};
    136141
     
    981986}
    982987
     988inline bool StyleBuilderCustom::isValidDisplayValue(StyleResolver& styleResolver, EDisplay display)
     989{
     990    if (is<SVGElement>(styleResolver.element()) && styleResolver.style()->styleType() == NOPSEUDO)
     991        return display == INLINE || display == BLOCK || display == NONE;
     992    return true;
     993}
     994
     995inline void StyleBuilderCustom::applyInheritDisplay(StyleResolver& styleResolver)
     996{
     997    EDisplay display = styleResolver.parentStyle()->display();
     998    if (isValidDisplayValue(styleResolver, display))
     999        styleResolver.style()->setDisplay(display);
     1000}
     1001
     1002inline void StyleBuilderCustom::applyValueDisplay(StyleResolver& styleResolver, CSSValue& value)
     1003{
     1004    EDisplay display = downcast<CSSPrimitiveValue>(value);
     1005    if (isValidDisplayValue(styleResolver, display))
     1006        styleResolver.style()->setDisplay(display);
     1007}
     1008
    9831009} // namespace WebCore
    9841010
  • trunk/Source/WebCore/css/makeprop.pl

    r176593 r176721  
    331331#
    332332
     333sub getScopeForFunction {
     334  my $name = shift;
     335  my $builderFunction = shift;
     336
     337  return $propertiesWithStyleBuilderOptions{$name}{"Custom"}{$builderFunction} ? "StyleBuilderCustom" : "StyleBuilderFunctions";
     338}
     339
    333340foreach my $name (@names) {
    334341  # Skip properties still using the legacy style builder.
     
    354361  }
    355362  if (!exists($propertiesWithStyleBuilderOptions{$name}{"Custom"})) {
    356     $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "None";
    357   }
     363    $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "";
     364  } elsif ($propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All") {
     365    $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "Initial|Inherit|Value";
     366  }
     367  my %customValues = map { $_ => 1 } split(/\|/, $propertiesWithStyleBuilderOptions{$name}{"Custom"});
     368  $propertiesWithStyleBuilderOptions{$name}{"Custom"} = \%customValues;
    358369}
    359370
     
    381392  next unless exists($propertiesWithStyleBuilderOptions{$name});
    382393
    383   next if $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All";
    384 
    385394  my $setValue = "styleResolver.style()->" . $propertiesWithStyleBuilderOptions{$name}{"Setter"};
    386   print STYLEBUILDER "    inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
    387   print STYLEBUILDER "    {\n";
    388   print STYLEBUILDER "        " . $setValue . "(RenderStyle::" . $propertiesWithStyleBuilderOptions{$name}{"Initial"} . "());\n";
    389   print STYLEBUILDER "    }\n";
    390   print STYLEBUILDER "    inline void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
    391   print STYLEBUILDER "    {\n";
    392   print STYLEBUILDER "        " . $setValue . "(styleResolver.parentStyle()->" .  $propertiesWithStyleBuilderOptions{$name}{"Getter"} . "());\n";
    393   print STYLEBUILDER "    }\n";
    394   if ($propertiesWithStyleBuilderOptions{$name}{"Custom"} ne "Value") {
     395  if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Initial"}) {
     396    print STYLEBUILDER "    inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
     397    print STYLEBUILDER "    {\n";
     398    print STYLEBUILDER "        " . $setValue . "(RenderStyle::" . $propertiesWithStyleBuilderOptions{$name}{"Initial"} . "());\n";
     399    print STYLEBUILDER "    }\n";
     400  }
     401  if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Inherit"}) {
     402    print STYLEBUILDER "    inline void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
     403    print STYLEBUILDER "    {\n";
     404    print STYLEBUILDER "        " . $setValue . "(styleResolver.parentStyle()->" .  $propertiesWithStyleBuilderOptions{$name}{"Getter"} . "());\n";
     405    print STYLEBUILDER "    }\n";
     406  }
     407  if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Value"}) {
    395408    print STYLEBUILDER "    inline void applyValue" . $nameToId{$name} . "(StyleResolver& styleResolver, CSSValue& value)\n";
    396409    print STYLEBUILDER "    {\n";
     
    418431  next unless exists($propertiesWithStyleBuilderOptions{$name});
    419432
    420   my $scope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All" ? "StyleBuilderCustom" : "StyleBuilderFunctions";
    421   my $valueScope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "Value" ? "StyleBuilderCustom" : $scope;
    422 
    423433  print STYLEBUILDER "    case CSSProperty" . $nameToId{$name} . ":\n";
    424434  print STYLEBUILDER "        if (isInitial)\n";
    425   print STYLEBUILDER "            " . $scope . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
     435  print STYLEBUILDER "            " . getScopeForFunction($name, "Initial") . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
    426436  print STYLEBUILDER "        else if (isInherit)\n";
    427   print STYLEBUILDER "            " . $scope . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
     437  print STYLEBUILDER "            " . getScopeForFunction($name, "Inherit") . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
    428438  print STYLEBUILDER "        else\n";
    429   print STYLEBUILDER "            " . $valueScope . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
     439  print STYLEBUILDER "            " . getScopeForFunction($name, "Value") . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
    430440  print STYLEBUILDER "        return true;\n";
    431441}
Note: See TracChangeset for help on using the changeset viewer.