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

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

Issue 1866623002: Hook up CSSPaintValue::image to CSS Paint API callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments + rebase. Created 4 years, 8 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 c4348e10b2d63435296889d760f0049cd268812b..c9f24f2d5e24f40515337a1844fa8070308301da 100644
--- a/third_party/WebKit/Source/core/css/CSSPaintValue.cpp
+++ b/third_party/WebKit/Source/core/css/CSSPaintValue.cpp
@@ -5,6 +5,7 @@
#include "core/css/CSSPaintValue.h"
#include "core/css/CSSCustomIdentValue.h"
+#include "core/layout/LayoutObject.h"
#include "platform/graphics/Image.h"
#include "wtf/text/StringBuilder.h"
@@ -13,6 +14,7 @@ namespace blink {
CSSPaintValue::CSSPaintValue(CSSCustomIdentValue* name)
: CSSImageGeneratorValue(PaintClass)
, m_name(name)
+ , m_paintImageGeneratorObserver(new Observer(this))
{
}
@@ -34,10 +36,24 @@ String CSSPaintValue::name() const
return m_name->value();
}
-PassRefPtr<Image> CSSPaintValue::image(const LayoutObject&, const IntSize&)
+PassRefPtr<Image> CSSPaintValue::image(const LayoutObject& layoutObject, const IntSize& size)
{
- // TODO(ikilpatrick): implement.
- return nullptr;
+ if (!m_generator)
+ m_generator = CSSPaintImageGenerator::create(name(), layoutObject.document(), m_paintImageGeneratorObserver);
+
+ return m_generator->paint(size);
+}
+
+void CSSPaintValue::Observer::paintImageGeneratorReady()
+{
+ m_ownerValue->paintImageGeneratorReady();
+}
+
+void CSSPaintValue::paintImageGeneratorReady()
+{
+ for (const LayoutObject* client : clients().keys()) {
+ const_cast<LayoutObject*>(client)->imageChanged(static_cast<WrappedImagePtr>(this));
+ }
}
bool CSSPaintValue::equals(const CSSPaintValue& other) const
@@ -48,6 +64,8 @@ bool CSSPaintValue::equals(const CSSPaintValue& other) const
DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue)
{
visitor->trace(m_name);
+ visitor->trace(m_generator);
+ visitor->trace(m_paintImageGeneratorObserver);
CSSImageGeneratorValue::traceAfterDispatch(visitor);
}
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSPaintValue.h ('k') | third_party/WebKit/Source/modules/ModulesInitializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698