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

Unified Diff: third_party/WebKit/Source/core/css/CSSPaintValue.cpp

Issue 2661323002: Implement CSSPaintValue and add a layout test. (Closed)
Patch Set: rebase Created 3 years, 10 months 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/CSSPaintValue.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSPaintValue.cpp b/third_party/WebKit/Source/core/css/CSSPaintValue.cpp
index d93ed2427d3ac01d91fb5ad2df69035ae8745ae8..82ccd3fdaa5cb396662826d137c7670a0c4b80a2 100644
--- a/third_party/WebKit/Source/core/css/CSSPaintValue.cpp
+++ b/third_party/WebKit/Source/core/css/CSSPaintValue.cpp
@@ -5,6 +5,8 @@
#include "core/css/CSSPaintValue.h"
#include "core/css/CSSCustomIdentValue.h"
+#include "core/css/CSSSyntaxDescriptor.h"
+#include "core/css/cssom/StyleValueFactory.h"
#include "core/layout/LayoutObject.h"
#include "platform/graphics/Image.h"
#include "wtf/text/StringBuilder.h"
@@ -47,7 +49,44 @@ PassRefPtr<Image> CSSPaintValue::image(const LayoutObject& layoutObject,
m_generator = CSSPaintImageGenerator::create(
name(), layoutObject.document(), m_paintImageGeneratorObserver);
- return m_generator->paint(layoutObject, size, zoom);
+ if (!parseInputArguments())
+ return nullptr;
+
+ return m_generator->paint(layoutObject, size, zoom, m_parsedInputArguments);
+}
+
+bool CSSPaintValue::parseInputArguments() {
+ if (m_inputArgumentsInvalid)
+ return false;
+
+ if (m_parsedInputArguments ||
+ !RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled())
+ return true;
+
+ if (!m_generator->isImageGeneratorReady())
+ return false;
+
+ const Vector<CSSSyntaxDescriptor>& inputArgumentTypes =
+ m_generator->inputArgumentTypes();
+ if (m_argumentVariableData.size() != inputArgumentTypes.size()) {
+ m_inputArgumentsInvalid = true;
+ return false;
+ }
+
+ m_parsedInputArguments = new CSSStyleValueVector();
+
+ for (size_t i = 0; i < m_argumentVariableData.size(); ++i) {
+ const CSSValue* parsedValue =
+ m_argumentVariableData[i]->parseForSyntax(inputArgumentTypes[i]);
+ if (!parsedValue) {
+ m_inputArgumentsInvalid = true;
+ m_parsedInputArguments = nullptr;
+ return false;
+ }
+ m_parsedInputArguments->appendVector(
+ StyleValueFactory::cssValueToStyleValueVector(*parsedValue));
+ }
+ return true;
}
void CSSPaintValue::Observer::paintImageGeneratorReady() {
@@ -73,6 +112,7 @@ DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue) {
visitor->trace(m_name);
visitor->trace(m_generator);
visitor->trace(m_paintImageGeneratorObserver);
+ visitor->trace(m_parsedInputArguments);
CSSImageGeneratorValue::traceAfterDispatch(visitor);
}
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSPaintValue.h ('k') | third_party/WebKit/Source/core/css/CSSVariableData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698