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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/CSSPaintValue.h" 5 #include "core/css/CSSPaintValue.h"
6 6
7 #include "core/css/CSSCustomIdentValue.h" 7 #include "core/css/CSSCustomIdentValue.h"
8 #include "core/layout/LayoutObject.h"
8 #include "platform/graphics/Image.h" 9 #include "platform/graphics/Image.h"
9 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 CSSPaintValue::CSSPaintValue(CSSCustomIdentValue* name) 14 CSSPaintValue::CSSPaintValue(CSSCustomIdentValue* name)
14 : CSSImageGeneratorValue(PaintClass) 15 : CSSImageGeneratorValue(PaintClass)
15 , m_name(name) 16 , m_name(name)
17 , m_paintImageGeneratorObserver(new Observer(this))
16 { 18 {
17 } 19 }
18 20
19 CSSPaintValue::~CSSPaintValue() 21 CSSPaintValue::~CSSPaintValue()
20 { 22 {
21 } 23 }
22 24
23 String CSSPaintValue::customCSSText() const 25 String CSSPaintValue::customCSSText() const
24 { 26 {
25 StringBuilder result; 27 StringBuilder result;
26 result.appendLiteral("paint("); 28 result.appendLiteral("paint(");
27 result.append(m_name->customCSSText()); 29 result.append(m_name->customCSSText());
28 result.append(')'); 30 result.append(')');
29 return result.toString(); 31 return result.toString();
30 } 32 }
31 33
32 String CSSPaintValue::name() const 34 String CSSPaintValue::name() const
33 { 35 {
34 return m_name->value(); 36 return m_name->value();
35 } 37 }
36 38
37 PassRefPtr<Image> CSSPaintValue::image(const LayoutObject&, const IntSize&) 39 PassRefPtr<Image> CSSPaintValue::image(const LayoutObject& layoutObject, const I ntSize& size)
38 { 40 {
39 // TODO(ikilpatrick): implement. 41 if (!m_generator)
40 return nullptr; 42 m_generator = CSSPaintImageGenerator::create(name(), layoutObject.docume nt(), m_paintImageGeneratorObserver);
43
44 return m_generator->paint(size);
45 }
46
47 void CSSPaintValue::Observer::paintImageGeneratorReady()
48 {
49 m_ownerValue->paintImageGeneratorReady();
50 }
51
52 void CSSPaintValue::paintImageGeneratorReady()
53 {
54 for (const LayoutObject* client : clients().keys()) {
55 const_cast<LayoutObject*>(client)->imageChanged(static_cast<WrappedImage Ptr>(this));
56 }
41 } 57 }
42 58
43 bool CSSPaintValue::equals(const CSSPaintValue& other) const 59 bool CSSPaintValue::equals(const CSSPaintValue& other) const
44 { 60 {
45 return name() == other.name(); 61 return name() == other.name();
46 } 62 }
47 63
48 DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue) 64 DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue)
49 { 65 {
50 visitor->trace(m_name); 66 visitor->trace(m_name);
67 visitor->trace(m_generator);
68 visitor->trace(m_paintImageGeneratorObserver);
51 CSSImageGeneratorValue::traceAfterDispatch(visitor); 69 CSSImageGeneratorValue::traceAfterDispatch(visitor);
52 } 70 }
53 71
54 } // namespace blink 72 } // namespace blink
OLDNEW
« 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