- Revision
- 176721
- Author
- [email protected]
- Date
- 2014-12-03 06:46:15 -0800 (Wed, 03 Dec 2014)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (176720 => 176721)
--- trunk/Source/WebCore/ChangeLog 2014-12-03 14:39:25 UTC (rev 176720)
+++ trunk/Source/WebCore/ChangeLog 2014-12-03 14:46:15 UTC (rev 176721)
@@ -1,5 +1,33 @@
2014-12-03 Chris Dumez <[email protected]>
+ 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.
+
+2014-12-03 Chris Dumez <[email protected]>
+
Modernize the CSSParser code
https://bugs.webkit.org/show_bug.cgi?id=139209
Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (176720 => 176721)
--- trunk/Source/WebCore/css/CSSPropertyNames.in 2014-12-03 14:39:25 UTC (rev 176720)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in 2014-12-03 14:46:15 UTC (rev 176721)
@@ -44,20 +44,25 @@
// can indicate that a Converter helper function in
// css/StyleBuilderConverter.h should be used.
//
-// * Custom=[Value|All]:
+// * Custom=[Initial|Value|Inherit|All]:
+// Custom=Initial option is used to indicate that the CSS property requires
+// special handling to set its initial value.
+// Custom=Inherit option is used to indicate that the CSS property requires
+// special handling to set its inherit value.
// Custom=Value option is used to indicate that the CSS property requires special
// handling to set its value, and a regular Converter helper cannot be
// used. The Custom code for the property should be located in
// css/StyleBuilderCustom.h and named applyValue[CSSPropertyName]().
// If special handling is also needed to apply inherit or initial value, use
-// Custom=All.
+// Custom=All. Alternatively, several '|'-separated options can be passed:
+// e.g. 'Custom=Inherit|Value".
// high-priority property names have to be listed first, to simplify the check
// for applying them first.
color [Inherited, LegacyStyleBuilder]
direction [Inherited, Custom=Value]
-display [LegacyStyleBuilder]
+display [Custom=Inherit|Value]
font [Inherited, LegacyStyleBuilder]
font-family [Inherited, Custom=All]
font-size [Inherited, LegacyStyleBuilder]
Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (176720 => 176721)
--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2014-12-03 14:39:25 UTC (rev 176720)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2014-12-03 14:46:15 UTC (rev 176721)
@@ -967,47 +967,6 @@
}
};
-class ApplyPropertyDisplay {
-private:
- static inline bool isValidDisplayValue(StyleResolver* styleResolver, EDisplay displayPropertyValue)
- {
- if (styleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO)
- return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
- return true;
- }
-public:
- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
- {
- EDisplay display = styleResolver->parentStyle()->display();
- if (!isValidDisplayValue(styleResolver, display))
- return;
- styleResolver->style()->setDisplay(display);
- }
-
- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
- {
- styleResolver->style()->setDisplay(RenderStyle::initialDisplay());
- }
-
- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
- {
- if (!is<CSSPrimitiveValue>(*value))
- return;
-
- EDisplay display = downcast<CSSPrimitiveValue>(*value);
-
- if (!isValidDisplayValue(styleResolver, display))
- return;
-
- styleResolver->style()->setDisplay(display);
- }
-
- static PropertyHandler createHandler()
- {
- return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
- }
-};
-
const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
{
static NeverDestroyed<DeprecatedStyleBuilder> styleBuilderInstance;
@@ -1039,7 +998,6 @@
setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter<Increment>::createHandler());
setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter<Reset>::createHandler());
setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
- setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (176720 => 176721)
--- trunk/Source/WebCore/css/StyleBuilderCustom.h 2014-12-03 14:39:25 UTC (rev 176720)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h 2014-12-03 14:46:15 UTC (rev 176721)
@@ -35,6 +35,7 @@
#include "Frame.h"
#include "LocaleToScriptMapping.h"
#include "Rect.h"
+#include "SVGElement.h"
#include "StyleFontSizeFunctions.h"
#include "StyleResolver.h"
@@ -121,6 +122,9 @@
static void applyInheritFontFamily(StyleResolver&);
static void applyValueFontFamily(StyleResolver&, CSSValue&);
+ static void applyInheritDisplay(StyleResolver&);
+ static void applyValueDisplay(StyleResolver&, CSSValue&);
+
private:
static void resetEffectiveZoom(StyleResolver&);
static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
@@ -132,6 +136,7 @@
template <CSSPropertyID id>
static void applyTextOrBoxShadowValue(StyleResolver&, CSSValue&);
+ static bool isValidDisplayValue(StyleResolver&, EDisplay);
};
inline void StyleBuilderCustom::applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
@@ -980,6 +985,27 @@
styleResolver.setFontDescription(fontDescription);
}
+inline bool StyleBuilderCustom::isValidDisplayValue(StyleResolver& styleResolver, EDisplay display)
+{
+ if (is<SVGElement>(styleResolver.element()) && styleResolver.style()->styleType() == NOPSEUDO)
+ return display == INLINE || display == BLOCK || display == NONE;
+ return true;
+}
+
+inline void StyleBuilderCustom::applyInheritDisplay(StyleResolver& styleResolver)
+{
+ EDisplay display = styleResolver.parentStyle()->display();
+ if (isValidDisplayValue(styleResolver, display))
+ styleResolver.style()->setDisplay(display);
+}
+
+inline void StyleBuilderCustom::applyValueDisplay(StyleResolver& styleResolver, CSSValue& value)
+{
+ EDisplay display = downcast<CSSPrimitiveValue>(value);
+ if (isValidDisplayValue(styleResolver, display))
+ styleResolver.style()->setDisplay(display);
+}
+
} // namespace WebCore
#endif // StyleBuilderCustom_h
Modified: trunk/Source/WebCore/css/makeprop.pl (176720 => 176721)
--- trunk/Source/WebCore/css/makeprop.pl 2014-12-03 14:39:25 UTC (rev 176720)
+++ trunk/Source/WebCore/css/makeprop.pl 2014-12-03 14:46:15 UTC (rev 176721)
@@ -330,6 +330,13 @@
# StyleBuilder.cpp generator.
#
+sub getScopeForFunction {
+ my $name = shift;
+ my $builderFunction = shift;
+
+ return $propertiesWithStyleBuilderOptions{$name}{"Custom"}{$builderFunction} ? "StyleBuilderCustom" : "StyleBuilderFunctions";
+}
+
foreach my $name (@names) {
# Skip properties still using the legacy style builder.
next unless exists($propertiesWithStyleBuilderOptions{$name});
@@ -353,8 +360,12 @@
$propertiesWithStyleBuilderOptions{$name}{"Initial"} = "initial" . $nameForMethods;
}
if (!exists($propertiesWithStyleBuilderOptions{$name}{"Custom"})) {
- $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "None";
+ $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "";
+ } elsif ($propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All") {
+ $propertiesWithStyleBuilderOptions{$name}{"Custom"} = "Initial|Inherit|Value";
}
+ my %customValues = map { $_ => 1 } split(/\|/, $propertiesWithStyleBuilderOptions{$name}{"Custom"});
+ $propertiesWithStyleBuilderOptions{$name}{"Custom"} = \%customValues;
}
open STYLEBUILDER, ">StyleBuilder.cpp" || die "Could not open StyleBuilder.cpp for writing";
@@ -380,18 +391,20 @@
# Skip properties still using the legacy style builder.
next unless exists($propertiesWithStyleBuilderOptions{$name});
- next if $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All";
-
my $setValue = "styleResolver.style()->" . $propertiesWithStyleBuilderOptions{$name}{"Setter"};
- print STYLEBUILDER " inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
- print STYLEBUILDER " {\n";
- print STYLEBUILDER " " . $setValue . "(RenderStyle::" . $propertiesWithStyleBuilderOptions{$name}{"Initial"} . "());\n";
- print STYLEBUILDER " }\n";
- print STYLEBUILDER " inline void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
- print STYLEBUILDER " {\n";
- print STYLEBUILDER " " . $setValue . "(styleResolver.parentStyle()->" . $propertiesWithStyleBuilderOptions{$name}{"Getter"} . "());\n";
- print STYLEBUILDER " }\n";
- if ($propertiesWithStyleBuilderOptions{$name}{"Custom"} ne "Value") {
+ if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Initial"}) {
+ print STYLEBUILDER " inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
+ print STYLEBUILDER " {\n";
+ print STYLEBUILDER " " . $setValue . "(RenderStyle::" . $propertiesWithStyleBuilderOptions{$name}{"Initial"} . "());\n";
+ print STYLEBUILDER " }\n";
+ }
+ if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Inherit"}) {
+ print STYLEBUILDER " inline void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
+ print STYLEBUILDER " {\n";
+ print STYLEBUILDER " " . $setValue . "(styleResolver.parentStyle()->" . $propertiesWithStyleBuilderOptions{$name}{"Getter"} . "());\n";
+ print STYLEBUILDER " }\n";
+ }
+ if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Value"}) {
print STYLEBUILDER " inline void applyValue" . $nameToId{$name} . "(StyleResolver& styleResolver, CSSValue& value)\n";
print STYLEBUILDER " {\n";
my $convertedValue;
@@ -417,16 +430,13 @@
# Skip properties still using the legacy style builder.
next unless exists($propertiesWithStyleBuilderOptions{$name});
- my $scope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All" ? "StyleBuilderCustom" : "StyleBuilderFunctions";
- my $valueScope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "Value" ? "StyleBuilderCustom" : $scope;
-
print STYLEBUILDER " case CSSProperty" . $nameToId{$name} . ":\n";
print STYLEBUILDER " if (isInitial)\n";
- print STYLEBUILDER " " . $scope . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
+ print STYLEBUILDER " " . getScopeForFunction($name, "Initial") . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
print STYLEBUILDER " else if (isInherit)\n";
- print STYLEBUILDER " " . $scope . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
+ print STYLEBUILDER " " . getScopeForFunction($name, "Inherit") . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
print STYLEBUILDER " else\n";
- print STYLEBUILDER " " . $valueScope . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
+ print STYLEBUILDER " " . getScopeForFunction($name, "Value") . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
print STYLEBUILDER " return true;\n";
}