OLD | NEW |
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 "modules/csspaint/CSSPaintDefinition.h" | 5 #include "modules/csspaint/CSSPaintDefinition.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "bindings/core/v8/V8BindingMacros.h" | 9 #include "bindings/core/v8/V8BindingMacros.h" |
10 #include "bindings/core/v8/V8ObjectConstructor.h" | 10 #include "bindings/core/v8/V8ObjectConstructor.h" |
11 #include "core/css/CSSComputedStyleDeclaration.h" | 11 #include "core/css/CSSComputedStyleDeclaration.h" |
12 #include "core/css/cssom/FilteredComputedStylePropertyMap.h" | 12 #include "core/css/cssom/FilteredComputedStylePropertyMap.h" |
13 #include "core/dom/ExecutionContext.h" | 13 #include "core/dom/ExecutionContext.h" |
14 #include "core/layout/LayoutObject.h" | 14 #include "core/layout/LayoutObject.h" |
15 #include "modules/csspaint/Geometry.h" | |
16 #include "modules/csspaint/PaintRenderingContext2D.h" | 15 #include "modules/csspaint/PaintRenderingContext2D.h" |
| 16 #include "modules/csspaint/PaintSize.h" |
17 #include "platform/graphics/ImageBuffer.h" | 17 #include "platform/graphics/ImageBuffer.h" |
18 #include "platform/graphics/PaintGeneratedImage.h" | 18 #include "platform/graphics/PaintGeneratedImage.h" |
19 #include "platform/graphics/RecordingImageBufferSurface.h" | 19 #include "platform/graphics/RecordingImageBufferSurface.h" |
20 #include "wtf/PtrUtil.h" | 20 #include "wtf/PtrUtil.h" |
21 | 21 |
22 namespace blink { | 22 namespace blink { |
23 | 23 |
24 CSSPaintDefinition* CSSPaintDefinition::create(ScriptState* scriptState, v8::Loc
al<v8::Function> constructor, v8::Local<v8::Function> paint, Vector<CSSPropertyI
D>& nativeInvalidationProperties, Vector<AtomicString>& customInvalidationProper
ties) | 24 CSSPaintDefinition* CSSPaintDefinition::create(ScriptState* scriptState, v8::Loc
al<v8::Function> constructor, v8::Local<v8::Function> paint, Vector<CSSPropertyI
D>& nativeInvalidationProperties, Vector<AtomicString>& customInvalidationProper
ties) |
25 { | 25 { |
26 return new CSSPaintDefinition(scriptState, constructor, paint, nativeInvalid
ationProperties, customInvalidationProperties); | 26 return new CSSPaintDefinition(scriptState, constructor, paint, nativeInvalid
ationProperties, customInvalidationProperties); |
(...skipping 23 matching lines...) Expand all Loading... |
50 | 50 |
51 // We may have failed to create an instance class, in which case produce an | 51 // We may have failed to create an instance class, in which case produce an |
52 // invalid image. | 52 // invalid image. |
53 if (isUndefinedOrNull(instance)) | 53 if (isUndefinedOrNull(instance)) |
54 return nullptr; | 54 return nullptr; |
55 | 55 |
56 DCHECK(layoutObject.node()); | 56 DCHECK(layoutObject.node()); |
57 | 57 |
58 PaintRenderingContext2D* renderingContext = PaintRenderingContext2D::create( | 58 PaintRenderingContext2D* renderingContext = PaintRenderingContext2D::create( |
59 ImageBuffer::create(wrapUnique(new RecordingImageBufferSurface(size)))); | 59 ImageBuffer::create(wrapUnique(new RecordingImageBufferSurface(size)))); |
60 Geometry* geometry = Geometry::create(size); | 60 PaintSize* paintSize = PaintSize::create(size); |
61 StylePropertyMap* styleMap = FilteredComputedStylePropertyMap::create( | 61 StylePropertyMap* styleMap = FilteredComputedStylePropertyMap::create( |
62 CSSComputedStyleDeclaration::create(layoutObject.node()), | 62 CSSComputedStyleDeclaration::create(layoutObject.node()), |
63 m_nativeInvalidationProperties, m_customInvalidationProperties); | 63 m_nativeInvalidationProperties, m_customInvalidationProperties); |
64 | 64 |
65 v8::Local<v8::Value> argv[] = { | 65 v8::Local<v8::Value> argv[] = { |
66 toV8(renderingContext, m_scriptState->context()->Global(), isolate), | 66 toV8(renderingContext, m_scriptState->context()->Global(), isolate), |
67 toV8(geometry, m_scriptState->context()->Global(), isolate), | 67 toV8(paintSize, m_scriptState->context()->Global(), isolate), |
68 toV8(styleMap, m_scriptState->context()->Global(), isolate) | 68 toV8(styleMap, m_scriptState->context()->Global(), isolate) |
69 }; | 69 }; |
70 | 70 |
71 v8::Local<v8::Function> paint = m_paint.newLocal(isolate); | 71 v8::Local<v8::Function> paint = m_paint.newLocal(isolate); |
72 | 72 |
73 v8::TryCatch block(isolate); | 73 v8::TryCatch block(isolate); |
74 block.SetVerbose(true); | 74 block.SetVerbose(true); |
75 | 75 |
76 V8ScriptRunner::callFunction(paint, m_scriptState->getExecutionContext(), in
stance, 3, argv, isolate); | 76 V8ScriptRunner::callFunction(paint, m_scriptState->getExecutionContext(), in
stance, 3, argv, isolate); |
77 | 77 |
(...skipping 19 matching lines...) Expand all Loading... |
97 | 97 |
98 v8::Local<v8::Object> paintInstance; | 98 v8::Local<v8::Object> paintInstance; |
99 if (V8ObjectConstructor::newInstance(isolate, constructor).ToLocal(&paintIns
tance)) { | 99 if (V8ObjectConstructor::newInstance(isolate, constructor).ToLocal(&paintIns
tance)) { |
100 m_instance.set(isolate, paintInstance); | 100 m_instance.set(isolate, paintInstance); |
101 } | 101 } |
102 | 102 |
103 m_didCallConstructor = true; | 103 m_didCallConstructor = true; |
104 } | 104 } |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
OLD | NEW |