- Revision
- 176621
- Author
- [email protected]
- Date
- 2014-12-01 18:16:55 -0800 (Mon, 01 Dec 2014)
Log Message
Move 'text-shadow' / 'box-shadow' / '-webkit-box-shadow' to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138938
Reviewed by Sam Weinig.
Move 'text-shadow' / 'box-shadow' / '-webkit-box-shadow' CSS properties
from StyleResolver to the new StyleBuilder by using custom code.
No new tests, no behavior change.
* css/CSSPropertyNames.in:
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
(WebCore::StyleBuilderCustom::applyInitialTextShadow):
(WebCore::StyleBuilderCustom::applyInheritTextShadow):
(WebCore::StyleBuilderCustom::applyValueTextShadow):
(WebCore::StyleBuilderCustom::applyInitialBoxShadow):
(WebCore::StyleBuilderCustom::applyInheritBoxShadow):
(WebCore::StyleBuilderCustom::applyValueBoxShadow):
(WebCore::StyleBuilderCustom::applyInitialWebkitBoxShadow):
(WebCore::StyleBuilderCustom::applyInheritWebkitBoxShadow):
(WebCore::StyleBuilderCustom::applyValueWebkitBoxShadow):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (176620 => 176621)
--- trunk/Source/WebCore/ChangeLog 2014-12-02 02:02:52 UTC (rev 176620)
+++ trunk/Source/WebCore/ChangeLog 2014-12-02 02:16:55 UTC (rev 176621)
@@ -1,3 +1,30 @@
+2014-12-01 Chris Dumez <[email protected]>
+
+ Move 'text-shadow' / 'box-shadow' / '-webkit-box-shadow' to the new StyleBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=138938
+
+ Reviewed by Sam Weinig.
+
+ Move 'text-shadow' / 'box-shadow' / '-webkit-box-shadow' CSS properties
+ from StyleResolver to the new StyleBuilder by using custom code.
+
+ No new tests, no behavior change.
+
+ * css/CSSPropertyNames.in:
+ * css/StyleBuilderCustom.h:
+ (WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
+ (WebCore::StyleBuilderCustom::applyInitialTextShadow):
+ (WebCore::StyleBuilderCustom::applyInheritTextShadow):
+ (WebCore::StyleBuilderCustom::applyValueTextShadow):
+ (WebCore::StyleBuilderCustom::applyInitialBoxShadow):
+ (WebCore::StyleBuilderCustom::applyInheritBoxShadow):
+ (WebCore::StyleBuilderCustom::applyValueBoxShadow):
+ (WebCore::StyleBuilderCustom::applyInitialWebkitBoxShadow):
+ (WebCore::StyleBuilderCustom::applyInheritWebkitBoxShadow):
+ (WebCore::StyleBuilderCustom::applyValueWebkitBoxShadow):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::applyProperty):
+
2014-12-01 Gyuyoung Kim <[email protected]>
[EFL] Add a ENABLE_CSS_SCROLL_SNAP macro to CMake build system
Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (176620 => 176621)
--- trunk/Source/WebCore/css/CSSPropertyNames.in 2014-12-02 02:02:52 UTC (rev 176620)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in 2014-12-02 02:16:55 UTC (rev 176621)
@@ -151,7 +151,7 @@
border-top-width [Initial=initialBorderWidth, Converter=LineWidth<float>]
border-width [LegacyStyleBuilder]
bottom [Initial=initialOffset, Converter=LengthOrAuto]
-box-shadow [LegacyStyleBuilder]
+box-shadow [Custom=All]
box-sizing
// -webkit-box-sizing worked in Safari 4 and earlier.
-webkit-box-sizing = box-sizing
@@ -242,7 +242,7 @@
text-overline-mode [LegacyStyleBuilder]
text-overline-style [LegacyStyleBuilder]
text-overline-width [LegacyStyleBuilder]
-text-shadow [Inherited, LegacyStyleBuilder]
+text-shadow [Inherited, Custom=All]
text-transform [Inherited]
-epub-text-transform = text-transform
text-underline [LegacyStyleBuilder]
@@ -326,7 +326,7 @@
// -webkit-box-shadow differs from box-shadow in its treatement of blur radii > 8px.
// Let -webkit-box-shadow blur radius be w_r and box-shadow blur radius be b_r. For
// w_r > 8px, b_r = 8 + 4 * sqrt((w_r - 8) / 2).
--webkit-box-shadow [LegacyStyleBuilder]
+-webkit-box-shadow [Custom=All]
-webkit-color-correction [Inherited, TypeName=ColorSpace, NameForMethods=ColorSpace]
-webkit-column-axis [TypeName=ColumnAxis]
-webkit-column-break-after [TypeName=EPageBreak, Initial=initialPageBreak]
Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (176620 => 176621)
--- trunk/Source/WebCore/css/StyleBuilderCustom.h 2014-12-02 02:02:52 UTC (rev 176620)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h 2014-12-02 02:16:55 UTC (rev 176621)
@@ -31,6 +31,7 @@
#include "CSSImageGeneratorValue.h"
#include "CSSImageSetValue.h"
#include "CSSImageValue.h"
+#include "CSSShadowValue.h"
#include "Frame.h"
#include "LocaleToScriptMapping.h"
#include "Rect.h"
@@ -105,6 +106,16 @@
static void applyValueWebkitJustifySelf(StyleResolver&, CSSValue&);
static void applyValueWebkitPerspective(StyleResolver&, CSSValue&);
+ static void applyInitialTextShadow(StyleResolver&);
+ static void applyInheritTextShadow(StyleResolver&);
+ static void applyValueTextShadow(StyleResolver&, CSSValue&);
+ static void applyInitialBoxShadow(StyleResolver&);
+ static void applyInheritBoxShadow(StyleResolver&);
+ static void applyValueBoxShadow(StyleResolver&, CSSValue&);
+ static void applyInitialWebkitBoxShadow(StyleResolver&);
+ static void applyInheritWebkitBoxShadow(StyleResolver&);
+ static void applyValueWebkitBoxShadow(StyleResolver&, CSSValue&);
+
private:
static void resetEffectiveZoom(StyleResolver&);
static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
@@ -113,6 +124,9 @@
static Length mmLength(double mm);
static Length inchLength(double inch);
static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height);
+
+ template <CSSPropertyID id>
+ static void applyTextOrBoxShadowValue(StyleResolver&, CSSValue&);
};
inline void StyleBuilderCustom::applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
@@ -787,6 +801,86 @@
styleResolver.style()->setPerspective(perspectiveValue);
}
+template <CSSPropertyID id>
+inline void StyleBuilderCustom::applyTextOrBoxShadowValue(StyleResolver& styleResolver, CSSValue& value)
+{
+ if (is<CSSPrimitiveValue>(value)) {
+ ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
+ if (id == CSSPropertyTextShadow)
+ styleResolver.style()->setTextShadow(nullptr);
+ else
+ styleResolver.style()->setBoxShadow(nullptr);
+ return;
+ }
+
+ bool isFirstEntry = true;
+ for (auto& item : downcast<CSSValueList>(value)) {
+ auto& shadowValue = downcast<CSSShadowValue>(item.get());
+ auto conversionData = styleResolver.state().cssToLengthConversionData();
+ int x = shadowValue.x->computeLength<int>(conversionData);
+ int y = shadowValue.y->computeLength<int>(conversionData);
+ int blur = shadowValue.blur ? shadowValue.blur->computeLength<int>(conversionData) : 0;
+ int spread = shadowValue.spread ? shadowValue.spread->computeLength<int>(conversionData) : 0;
+ ShadowStyle shadowStyle = shadowValue.style && shadowValue.style->getValueID() == CSSValueInset ? Inset : Normal;
+ Color color;
+ if (shadowValue.color)
+ color = styleResolver.colorFromPrimitiveValue(shadowValue.color.get());
+ else
+ color = styleResolver.style()->color();
+ auto shadowData = std::make_unique<ShadowData>(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent);
+ if (id == CSSPropertyTextShadow)
+ styleResolver.style()->setTextShadow(WTF::move(shadowData), !isFirstEntry); // add to the list if this is not the first entry
+ else
+ styleResolver.style()->setBoxShadow(WTF::move(shadowData), !isFirstEntry); // add to the list if this is not the first entry
+ isFirstEntry = false;
+ }
+}
+
+inline void StyleBuilderCustom::applyInitialTextShadow(StyleResolver& styleResolver)
+{
+ styleResolver.style()->setTextShadow(nullptr);
+}
+
+inline void StyleBuilderCustom::applyInheritTextShadow(StyleResolver& styleResolver)
+{
+ styleResolver.style()->setTextShadow(styleResolver.parentStyle()->textShadow() ? std::make_unique<ShadowData>(*styleResolver.parentStyle()->textShadow()) : nullptr);
+}
+
+inline void StyleBuilderCustom::applyValueTextShadow(StyleResolver& styleResolver, CSSValue& value)
+{
+ applyTextOrBoxShadowValue<CSSPropertyTextShadow>(styleResolver, value);
+}
+
+inline void StyleBuilderCustom::applyInitialBoxShadow(StyleResolver& styleResolver)
+{
+ styleResolver.style()->setBoxShadow(nullptr);
+}
+
+inline void StyleBuilderCustom::applyInheritBoxShadow(StyleResolver& styleResolver)
+{
+ styleResolver.style()->setBoxShadow(styleResolver.parentStyle()->boxShadow() ? std::make_unique<ShadowData>(*styleResolver.parentStyle()->boxShadow()) : nullptr);
+}
+
+inline void StyleBuilderCustom::applyValueBoxShadow(StyleResolver& styleResolver, CSSValue& value)
+{
+ applyTextOrBoxShadowValue<CSSPropertyBoxShadow>(styleResolver, value);
+}
+
+inline void StyleBuilderCustom::applyInitialWebkitBoxShadow(StyleResolver& styleResolver)
+{
+ applyInitialBoxShadow(styleResolver);
+}
+
+inline void StyleBuilderCustom::applyInheritWebkitBoxShadow(StyleResolver& styleResolver)
+{
+ applyInheritBoxShadow(styleResolver);
+}
+
+inline void StyleBuilderCustom::applyValueWebkitBoxShadow(StyleResolver& styleResolver, CSSValue& value)
+{
+ applyTextOrBoxShadowValue<CSSPropertyWebkitBoxShadow>(styleResolver, value);
+}
+
} // namespace WebCore
#endif // StyleBuilderCustom_h
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (176620 => 176621)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-12-02 02:02:52 UTC (rev 176620)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-12-02 02:16:55 UTC (rev 176621)
@@ -2371,46 +2371,6 @@
break;
// CSS3 Properties
- case CSSPropertyTextShadow:
- case CSSPropertyBoxShadow:
- case CSSPropertyWebkitBoxShadow: {
- if (isInherit) {
- if (id == CSSPropertyTextShadow)
- return state.style()->setTextShadow(state.parentStyle()->textShadow() ? std::make_unique<ShadowData>(*state.parentStyle()->textShadow()) : nullptr);
- return state.style()->setBoxShadow(state.parentStyle()->boxShadow() ? std::make_unique<ShadowData>(*state.parentStyle()->boxShadow()) : nullptr);
- }
- if (isInitial || primitiveValue) // initial | none
- return id == CSSPropertyTextShadow ? state.style()->setTextShadow(nullptr) : state.style()->setBoxShadow(nullptr);
-
- if (!is<CSSValueList>(*value))
- return;
-
- bool isFirstEntry = true;
- for (auto& currentValue : downcast<CSSValueList>(*value)) {
- if (!is<CSSShadowValue>(currentValue.get()))
- continue;
- auto& item = downcast<CSSShadowValue>(currentValue.get());
- int x = item.x->computeLength<int>(state.cssToLengthConversionData());
- int y = item.y->computeLength<int>(state.cssToLengthConversionData());
- int blur = item.blur ? item.blur->computeLength<int>(state.cssToLengthConversionData()) : 0;
- int spread = item.spread ? item.spread->computeLength<int>(state.cssToLengthConversionData()) : 0;
- ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSValueInset ? Inset : Normal;
- Color color;
- if (item.color)
- color = colorFromPrimitiveValue(item.color.get());
- else if (state.style())
- color = state.style()->color();
-
- auto shadowData = std::make_unique<ShadowData>(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent);
- if (id == CSSPropertyTextShadow)
- state.style()->setTextShadow(WTF::move(shadowData), !isFirstEntry); // add to the list if this is not the first entry
- else
- state.style()->setBoxShadow(WTF::move(shadowData), !isFirstEntry); // add to the list if this is not the first entry
-
- isFirstEntry = false;
- }
- return;
- }
case CSSPropertySrc: // Only used in @font-face rules.
return;
case CSSPropertyUnicodeRange: // Only used in @font-face rules.
@@ -2829,6 +2789,7 @@
case CSSPropertyBorderTopStyle:
case CSSPropertyBorderTopWidth:
case CSSPropertyBottom:
+ case CSSPropertyBoxShadow:
case CSSPropertyBoxSizing:
case CSSPropertyCaptionSide:
case CSSPropertyClear:
@@ -2898,6 +2859,7 @@
case CSSPropertyTextIndent:
case CSSPropertyTextOverflow:
case CSSPropertyTextRendering:
+ case CSSPropertyTextShadow:
case CSSPropertyTextTransform:
case CSSPropertyTop:
case CSSPropertyUnicodeBidi:
@@ -2933,6 +2895,7 @@
case CSSPropertyWebkitBoxOrdinalGroup:
case CSSPropertyWebkitBoxOrient:
case CSSPropertyWebkitBoxPack:
+ case CSSPropertyWebkitBoxShadow:
case CSSPropertyWebkitBoxReflect:
case CSSPropertyWebkitColorCorrection:
case CSSPropertyWebkitColumnAxis: