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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/CSSPaintImageGeneratorImpl.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h"
6
7 #include "core/dom/Document.h"
8 #include "core/frame/LocalDOMWindow.h"
9 #include "modules/csspaint/CSSPaintDefinition.h"
10 #include "modules/csspaint/PaintWorklet.h"
11 #include "modules/csspaint/WindowPaintWorklet.h"
12 #include "platform/graphics/Image.h"
13
14 namespace blink {
15
16 CSSPaintImageGenerator* CSSPaintImageGeneratorImpl::create(const String& name, D ocument& document, Observer* observer)
17 {
18 LocalDOMWindow* domWindow = document.domWindow();
19 PaintWorklet* paintWorklet = WindowPaintWorklet::from(*domWindow).paintWorkl et(&document);
20
21 CSSPaintDefinition* paintDefinition = paintWorklet->findDefinition(name);
22 CSSPaintImageGeneratorImpl* generator;
23 if (!paintDefinition) {
24 generator = new CSSPaintImageGeneratorImpl(observer);
25 paintWorklet->addPendingGenerator(name, generator);
26 } else {
27 generator = new CSSPaintImageGeneratorImpl(paintDefinition);
28 }
29
30 return generator;
31 }
32
33 CSSPaintImageGeneratorImpl::CSSPaintImageGeneratorImpl(CSSPaintDefinition* defin ition)
34 : m_definition(definition)
35 {
36 }
37
38 CSSPaintImageGeneratorImpl::CSSPaintImageGeneratorImpl(Observer* observer)
39 : m_observer(observer)
40 {
41 }
42
43 CSSPaintImageGeneratorImpl::~CSSPaintImageGeneratorImpl()
44 {
45 }
46
47 void CSSPaintImageGeneratorImpl::setDefinition(CSSPaintDefinition* definition)
48 {
49 ASSERT(!m_definition);
50 m_definition = definition;
51
52 ASSERT(m_observer);
53 m_observer->paintImageGeneratorReady();
54 }
55
56 PassRefPtr<Image> CSSPaintImageGeneratorImpl::paint(const IntSize& size)
57 {
58 return m_definition ? m_definition->paint(size) : nullptr;
59 }
60
61 DEFINE_TRACE(CSSPaintImageGeneratorImpl)
62 {
63 visitor->trace(m_definition);
64 visitor->trace(m_observer);
65 CSSPaintImageGenerator::trace(visitor);
66 }
67
68 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698