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

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: . 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 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 auto& curr : clients()) {
haraken 2016/04/12 00:44:20 for (LayoutObject* client : clients().keys())
ikilpatrick 2016/04/12 03:08:09 Done.
55 LayoutObject* client = const_cast<LayoutObject*>(curr.key);
56 client->imageChanged(static_cast<WrappedImagePtr>(this));
57 }
41 } 58 }
42 59
43 bool CSSPaintValue::equals(const CSSPaintValue& other) const 60 bool CSSPaintValue::equals(const CSSPaintValue& other) const
44 { 61 {
45 return name() == other.name(); 62 return name() == other.name();
46 } 63 }
47 64
48 DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue) 65 DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue)
49 { 66 {
50 visitor->trace(m_name); 67 visitor->trace(m_name);
68 visitor->trace(m_generator);
69 visitor->trace(m_paintImageGeneratorObserver);
51 CSSImageGeneratorValue::traceAfterDispatch(visitor); 70 CSSImageGeneratorValue::traceAfterDispatch(visitor);
52 } 71 }
53 72
54 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698