Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp

Issue 2326633002: Adds filter support for offscreen canvas (Closed)
Patch Set: Code using ConversionData Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp b/third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp
index 6ac699796981b0e6edd8f111ba41b2c62cdfb1a5..4db7b30903145b9476952c60983a3302fc5ceebb 100644
--- a/third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/FilterOperationResolver.cpp
@@ -117,7 +117,7 @@ static void countFilterUse(FilterOperation::OperationType operationType,
}
FilterOperations FilterOperationResolver::createFilterOperations(
- StyleResolverState& state,
+ StyleResolverState* state,
const CSSValue& inValue) {
FilterOperations operations;
@@ -126,15 +126,28 @@ FilterOperations FilterOperationResolver::createFilterOperations(
return operations;
}
- const CSSToLengthConversionData& conversionData =
- state.cssToLengthConversionData();
+ const CSSToLengthConversionData* conversionData;
+ if (state) {
+ conversionData = &(state->cssToLengthConversionData());
+ } else {
+ FontDescription fontDescription;
+ Font font(fontDescription);
+ static CSSToLengthConversionData::FontSizes fontSizes(10, 16, &font);
Justin Novosad 2016/11/08 20:59:23 These hard-coded values should be in constants. A
fserb 2017/01/17 17:58:44 Couldn't find it anywhere. The default on CSS Font
+ static CSSToLengthConversionData::ViewportSize viewportSize(1024, 768);
+ static CSSToLengthConversionData baseData(&ComputedStyle::initialStyle(),
esprehn 2016/11/22 01:38:37 I don't think you can do this, any number of worke
fserb 2017/01/17 17:58:44 I've removed the statics.
+ fontSizes, viewportSize, 1);
+ conversionData = &baseData;
+ }
+
for (auto& currValue : toCSSValueList(inValue)) {
if (currValue->isURIValue()) {
- countFilterUse(FilterOperation::REFERENCE, state.document());
+ if (!state)
Justin Novosad 2016/11/08 20:59:23 Add a comment here to explain the the !state case
fserb 2017/01/17 17:58:44 done.
+ continue;
+ countFilterUse(FilterOperation::REFERENCE, state->document());
const CSSURIValue& urlValue = toCSSURIValue(*currValue);
SVGElementProxy& elementProxy =
- state.elementStyleResources().cachedOrPendingFromValue(urlValue);
+ state->elementStyleResources().cachedOrPendingFromValue(urlValue);
operations.operations().append(
ReferenceFilterOperation::create(urlValue.value(), elementProxy));
continue;
@@ -143,7 +156,8 @@ FilterOperations FilterOperationResolver::createFilterOperations(
const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get());
FilterOperation::OperationType operationType =
filterOperationForType(filterValue->functionType());
- countFilterUse(operationType, state.document());
+ if (state)
+ countFilterUse(operationType, state->document());
esprehn 2016/11/22 01:38:37 I think you actually want to take an ExecutionCont
fserb 2017/01/17 17:58:44 added TODO.
DCHECK_LE(filterValue->length(), 1u);
const CSSPrimitiveValue* firstValue =
@@ -193,22 +207,26 @@ FilterOperations FilterOperationResolver::createFilterOperations(
}
case CSSValueBlur: {
Length stdDeviation = Length(0, Fixed);
- if (filterValue->length() >= 1)
- stdDeviation = firstValue->convertToLength(conversionData);
+ if (filterValue->length() >= 1) {
+ stdDeviation = firstValue->convertToLength(*conversionData);
+ }
operations.operations().append(
BlurFilterOperation::create(stdDeviation));
break;
}
case CSSValueDropShadow: {
const CSSShadowValue& item = toCSSShadowValue(filterValue->item(0));
- IntPoint location(item.x->computeLength<int>(conversionData),
- item.y->computeLength<int>(conversionData));
- int blur =
- item.blur ? item.blur->computeLength<int>(conversionData) : 0;
+ IntPoint location;
+ int blur;
+
+ location = IntPoint(item.x->computeLength<int>(*conversionData),
+ item.y->computeLength<int>(*conversionData));
+ blur = item.blur ? item.blur->computeLength<int>(*conversionData) : 0;
Color shadowColor = Color::black;
esprehn 2016/11/22 01:38:37 This is going to force all shadows to be black, th
fserb 2017/01/17 17:58:44 yep. This code got refactored on StyleBuilderConve
- if (item.color)
- shadowColor = state.document().textLinkColors().colorFromCSSValue(
- *item.color, state.style()->color());
+ if (item.color && state) {
+ shadowColor = state->document().textLinkColors().colorFromCSSValue(
+ *item.color, state->style()->color());
+ }
operations.operations().append(
DropShadowFilterOperation::create(location, blur, shadowColor));

Powered by Google App Engine
This is Rietveld 408576698