Index: third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp |
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp b/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp |
index 948350c998f4ff70305c9224f4153925fb82d539..16a2d9d10eb4c2e2898046b7f3bc71e7604dbbaf 100644 |
--- a/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp |
+++ b/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp |
@@ -28,6 +28,7 @@ |
#include "core/css/BasicShapeFunctions.h" |
#include "core/css/CSSBasicShapeValues.h" |
+#include "core/css/CSSColorValue.h" |
#include "core/css/CSSContentDistributionValue.h" |
#include "core/css/CSSCustomIdentValue.h" |
#include "core/css/CSSFontFamilyValue.h" |
@@ -156,6 +157,11 @@ FilterOperations StyleBuilderConverter::convertFilterOperations( |
return FilterOperationResolver::createFilterOperations(state, value); |
} |
+FilterOperations StyleBuilderConverter::convertOffscreenFilterOperations( |
+ const CSSValue& value) { |
+ return FilterOperationResolver::createOffscreenFilterOperations(value); |
+} |
+ |
static FontDescription::GenericFamilyType convertGenericFamily( |
CSSValueID valueID) { |
switch (valueID) { |
@@ -328,6 +334,36 @@ float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, |
return primitiveValue.getFloatValue(); |
} |
+double StyleBuilderConverter::convertValueToNumber( |
+ const CSSFunctionValue* filter, |
+ const CSSPrimitiveValue* value) { |
+ switch (filter->functionType()) { |
+ case CSSValueGrayscale: |
+ case CSSValueSepia: |
+ case CSSValueSaturate: |
+ case CSSValueInvert: |
+ case CSSValueBrightness: |
+ case CSSValueContrast: |
+ case CSSValueOpacity: { |
+ double amount = (filter->functionType() == CSSValueBrightness) ? 0 : 1; |
+ if (filter->length() == 1) { |
+ amount = value->getDoubleValue(); |
+ if (value->isPercentage()) |
+ amount /= 100; |
+ } |
+ return amount; |
+ } |
+ case CSSValueHueRotate: { |
+ double angle = 0; |
+ if (filter->length() == 1) |
+ angle = value->computeDegrees(); |
+ return angle; |
+ } |
+ default: |
+ return 0; |
+ } |
+} |
+ |
FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, |
const CSSValue& value) { |
const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
@@ -1000,25 +1036,48 @@ LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, |
return LengthSize(radiusWidth, radiusHeight); |
} |
-ShadowData StyleBuilderConverter::convertShadow(StyleResolverState& state, |
- const CSSValue& value) { |
+ShadowData StyleBuilderConverter::convertShadow( |
+ const CSSToLengthConversionData& conversionData, |
+ StyleResolverState* state, |
+ const CSSValue& value) { |
const CSSShadowValue& shadow = toCSSShadowValue(value); |
- float x = shadow.x->computeLength<float>(state.cssToLengthConversionData()); |
- float y = shadow.y->computeLength<float>(state.cssToLengthConversionData()); |
+ float x = shadow.x->computeLength<float>(conversionData); |
+ float y = shadow.y->computeLength<float>(conversionData); |
float blur = |
- shadow.blur |
- ? shadow.blur->computeLength<float>(state.cssToLengthConversionData()) |
- : 0; |
- float spread = shadow.spread |
- ? shadow.spread->computeLength<float>( |
- state.cssToLengthConversionData()) |
- : 0; |
+ shadow.blur ? shadow.blur->computeLength<float>(conversionData) : 0; |
+ float spread = |
+ shadow.spread ? shadow.spread->computeLength<float>(conversionData) : 0; |
ShadowStyle shadowStyle = |
shadow.style && shadow.style->getValueID() == CSSValueInset ? Inset |
: Normal; |
StyleColor color = StyleColor::currentColor(); |
- if (shadow.color) |
- color = convertStyleColor(state, *shadow.color); |
+ if (shadow.color) { |
+ if (state) { |
+ color = convertStyleColor(*state, *shadow.color); |
+ } else { |
+ // For OffScreen canvas, we default to black and only parse non |
+ // Document dependent CSS colors. |
+ color = StyleColor(Color::black); |
+ if (shadow.color->isColorValue()) { |
+ color = toCSSColorValue(*shadow.color).value(); |
+ } else { |
+ CSSValueID valueID = toCSSIdentifierValue(*shadow.color).getValueID(); |
+ switch (valueID) { |
+ case CSSValueInvalid: |
+ NOTREACHED(); |
+ case CSSValueInternalQuirkInherit: |
+ case CSSValueWebkitLink: |
+ case CSSValueWebkitActivelink: |
+ case CSSValueWebkitFocusRingColor: |
+ case CSSValueCurrentcolor: |
+ break; |
+ default: |
+ color = StyleColor::colorFromKeyword(valueID); |
+ } |
+ } |
+ } |
+ } |
+ |
return ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, color); |
} |
@@ -1031,8 +1090,10 @@ PassRefPtr<ShadowList> StyleBuilderConverter::convertShadowList( |
} |
ShadowDataVector shadows; |
- for (const auto& item : toCSSValueList(value)) |
- shadows.push_back(convertShadow(state, *item)); |
+ for (const auto& item : toCSSValueList(value)) { |
+ shadows.push_back( |
+ convertShadow(state.cssToLengthConversionData(), &state, *item)); |
+ } |
return ShadowList::adopt(shadows); |
} |