Chromium Code Reviews| Index: third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp |
| diff --git a/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp b/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp |
| index 5a37f56c481afe7ba76b546e4f2899b80fb06166..9170cfb9cce96f964f9289407e4380ddd1f2d339 100644 |
| --- a/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp |
| +++ b/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp |
| @@ -9,7 +9,9 @@ |
| #include "bindings/core/v8/V8BindingMacros.h" |
| #include "bindings/core/v8/V8ObjectConstructor.h" |
| #include "core/css/CSSComputedStyleDeclaration.h" |
| +#include "core/css/CSSVariableData.h" |
| #include "core/css/cssom/FilteredComputedStylePropertyMap.h" |
| +#include "core/css/cssom/StyleValueFactory.h" |
| #include "core/dom/ExecutionContext.h" |
| #include "core/layout/LayoutObject.h" |
| #include "modules/csspaint/PaintRenderingContext2D.h" |
| @@ -66,9 +68,11 @@ CSSPaintDefinition::CSSPaintDefinition( |
| CSSPaintDefinition::~CSSPaintDefinition() {} |
| -PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, |
| - const IntSize& size, |
| - float zoom) { |
| +PassRefPtr<Image> CSSPaintDefinition::paint( |
| + const LayoutObject& layoutObject, |
| + const IntSize& size, |
| + float zoom, |
| + const Vector<RefPtr<CSSVariableData>>& variableData) { |
| const IntSize specifiedSize = getSpecifiedSize(size, zoom); |
| ScriptState::Scope scope(m_scriptState.get()); |
| @@ -96,10 +100,26 @@ PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, |
| m_nativeInvalidationProperties, m_customInvalidationProperties, |
| layoutObject.node()); |
| + // Parse arguments. |
| + CSSStyleValueVector paintArguments; |
| + if (RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) { |
| + if (variableData.size() != m_inputArgumentTypes.size()) { |
| + return nullptr; |
| + } |
| + for (size_t i = 0; i < variableData.size(); ++i) { |
| + const CSSValue* parsedValue = |
| + variableData[i].get()->parseForSyntax(m_inputArgumentTypes[i]); |
|
ikilpatrick
2017/02/16 03:19:36
this feels too late to parse the data? I think you
renjieliu1
2017/02/16 04:11:14
good suggestion! however parse the CSSVariableData
|
| + if (!parsedValue) |
| + return nullptr; |
| + paintArguments.appendVector( |
| + StyleValueFactory::cssValueToStyleValueVector(*parsedValue)); |
| + } |
| + } |
| v8::Local<v8::Value> argv[] = { |
| ToV8(renderingContext, m_scriptState->context()->Global(), isolate), |
| ToV8(paintSize, m_scriptState->context()->Global(), isolate), |
| - ToV8(styleMap, m_scriptState->context()->Global(), isolate)}; |
| + ToV8(styleMap, m_scriptState->context()->Global(), isolate), |
| + ToV8(paintArguments, m_scriptState->context()->Global(), isolate)}; |
| v8::Local<v8::Function> paint = m_paint.newLocal(isolate); |
| @@ -107,7 +127,7 @@ PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, |
| block.SetVerbose(true); |
| V8ScriptRunner::callFunction(paint, m_scriptState->getExecutionContext(), |
| - instance, 3, argv, isolate); |
| + instance, 4, argv, isolate); |
| // The paint function may have produced an error, in which case produce an |
| // invalid image. |