OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "core/dom/Element.h" | 41 #include "core/dom/Element.h" |
42 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
43 #include "platform/RuntimeEnabledFeatures.h" | 43 #include "platform/RuntimeEnabledFeatures.h" |
44 #include "wtf/GetPtr.h" | 44 #include "wtf/GetPtr.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 void V8Element::scrollLeftAttributeSetterCustom(v8::Local<v8::Value> value, cons
t v8::PropertyCallbackInfo<void>& info) | 48 void V8Element::scrollLeftAttributeSetterCustom(v8::Local<v8::Value> value, cons
t v8::PropertyCallbackInfo<void>& info) |
49 { | 49 { |
50 ExceptionState exceptionState(ExceptionState::SetterContext, "scrollLeft", "
Element", info.Holder(), info.GetIsolate()); | 50 ExceptionState exceptionState(ExceptionState::SetterContext, "scrollLeft", "
Element", info.Holder(), info.GetIsolate()); |
51 Element* impl = V8Element::toNative(info.Holder()); | 51 Element* impl = V8Element::toImpl(info.Holder()); |
52 | 52 |
53 if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject())
{ | 53 if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject())
{ |
54 TONATIVE_VOID(Dictionary, scrollOptionsHorizontal, Dictionary(value, inf
o.GetIsolate())); | 54 TONATIVE_VOID(Dictionary, scrollOptionsHorizontal, Dictionary(value, inf
o.GetIsolate())); |
55 impl->setScrollLeft(scrollOptionsHorizontal, exceptionState); | 55 impl->setScrollLeft(scrollOptionsHorizontal, exceptionState); |
56 exceptionState.throwIfNeeded(); | 56 exceptionState.throwIfNeeded(); |
57 return; | 57 return; |
58 } | 58 } |
59 | 59 |
60 TONATIVE_VOID_EXCEPTIONSTATE(float, position, toInt32(value, exceptionState)
, exceptionState); | 60 TONATIVE_VOID_EXCEPTIONSTATE(float, position, toInt32(value, exceptionState)
, exceptionState); |
61 impl->setScrollLeft(position); | 61 impl->setScrollLeft(position); |
62 } | 62 } |
63 | 63 |
64 void V8Element::scrollTopAttributeSetterCustom(v8::Local<v8::Value> value, const
v8::PropertyCallbackInfo<void>& info) | 64 void V8Element::scrollTopAttributeSetterCustom(v8::Local<v8::Value> value, const
v8::PropertyCallbackInfo<void>& info) |
65 { | 65 { |
66 ExceptionState exceptionState(ExceptionState::SetterContext, "scrollTop", "E
lement", info.Holder(), info.GetIsolate()); | 66 ExceptionState exceptionState(ExceptionState::SetterContext, "scrollTop", "E
lement", info.Holder(), info.GetIsolate()); |
67 Element* impl = V8Element::toNative(info.Holder()); | 67 Element* impl = V8Element::toImpl(info.Holder()); |
68 | 68 |
69 if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject())
{ | 69 if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject())
{ |
70 TONATIVE_VOID(Dictionary, scrollOptionsVertical, Dictionary(value, info.
GetIsolate())); | 70 TONATIVE_VOID(Dictionary, scrollOptionsVertical, Dictionary(value, info.
GetIsolate())); |
71 impl->setScrollTop(scrollOptionsVertical, exceptionState); | 71 impl->setScrollTop(scrollOptionsVertical, exceptionState); |
72 exceptionState.throwIfNeeded(); | 72 exceptionState.throwIfNeeded(); |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
76 TONATIVE_VOID_EXCEPTIONSTATE(float, position, toInt32(value, exceptionState)
, exceptionState); | 76 TONATIVE_VOID_EXCEPTIONSTATE(float, position, toInt32(value, exceptionState)
, exceptionState); |
77 impl->setScrollTop(position); | 77 impl->setScrollTop(position); |
78 } | 78 } |
79 | 79 |
80 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
81 // Overload resolution for animate() | 81 // Overload resolution for animate() |
82 // FIXME: needs support for union types http://crbug.com/240176 | 82 // FIXME: needs support for union types http://crbug.com/240176 |
83 //////////////////////////////////////////////////////////////////////////////// | 83 //////////////////////////////////////////////////////////////////////////////// |
84 | 84 |
85 // AnimationPlayer animate(AnimationEffect? effect); | 85 // AnimationPlayer animate(AnimationEffect? effect); |
86 void animate1Method(const v8::FunctionCallbackInfo<v8::Value>& info) | 86 void animate1Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
87 { | 87 { |
88 Element* impl = V8Element::toNative(info.Holder()); | 88 Element* impl = V8Element::toImpl(info.Holder()); |
89 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toNativeWithTypeC
heck(info.GetIsolate(), info[0])); | 89 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toImplWithTypeChe
ck(info.GetIsolate(), info[0])); |
90 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe
ct)), impl); | 90 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe
ct)), impl); |
91 } | 91 } |
92 | 92 |
93 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect); | 93 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect); |
94 void animate2Method(const v8::FunctionCallbackInfo<v8::Value>& info) | 94 void animate2Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
95 { | 95 { |
96 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", "
Element", info.Holder(), info.GetIsolate()); | 96 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", "
Element", info.Holder(), info.GetIsolate()); |
97 Element* impl = V8Element::toNative(info.Holder()); | 97 Element* impl = V8Element::toImpl(info.Holder()); |
98 TONATIVE_VOID(Vector<Dictionary>, keyframes, toNativeArray<Dictionary>(info[
0], 1, info.GetIsolate())); | 98 TONATIVE_VOID(Vector<Dictionary>, keyframes, toImplArray<Dictionary>(info[0]
, 1, info.GetIsolate())); |
99 RefPtrWillBeRawPtr<AnimationPlayer> result = ElementAnimation::animate(*impl
, keyframes, exceptionState); | 99 RefPtrWillBeRawPtr<AnimationPlayer> result = ElementAnimation::animate(*impl
, keyframes, exceptionState); |
100 if (exceptionState.throwIfNeeded()) | 100 if (exceptionState.throwIfNeeded()) |
101 return; | 101 return; |
102 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | 102 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); |
103 } | 103 } |
104 | 104 |
105 // AnimationPlayer animate(AnimationEffect? effect, double timing); | 105 // AnimationPlayer animate(AnimationEffect? effect, double timing); |
106 void animate3Method(const v8::FunctionCallbackInfo<v8::Value>& info) | 106 void animate3Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
107 { | 107 { |
108 Element* impl = V8Element::toNative(info.Holder()); | 108 Element* impl = V8Element::toImpl(info.Holder()); |
109 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toNativeWithTypeC
heck(info.GetIsolate(), info[0])); | 109 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toImplWithTypeChe
ck(info.GetIsolate(), info[0])); |
110 TONATIVE_VOID(double, duration, static_cast<double>(info[1]->NumberValue()))
; | 110 TONATIVE_VOID(double, duration, static_cast<double>(info[1]->NumberValue()))
; |
111 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe
ct, duration)), impl); | 111 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe
ct, duration)), impl); |
112 } | 112 } |
113 | 113 |
114 // AnimationPlayer animate(AnimationEffect? effect, Dictionary timing); | 114 // AnimationPlayer animate(AnimationEffect? effect, Dictionary timing); |
115 void animate4Method(const v8::FunctionCallbackInfo<v8::Value>& info) | 115 void animate4Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
116 { | 116 { |
117 Element* impl = V8Element::toNative(info.Holder()); | 117 Element* impl = V8Element::toImpl(info.Holder()); |
118 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toNativeWithTypeC
heck(info.GetIsolate(), info[0])); | 118 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toImplWithTypeChe
ck(info.GetIsolate(), info[0])); |
119 TONATIVE_VOID(Dictionary, timingInput, Dictionary(info[1], info.GetIsolate()
)); | 119 TONATIVE_VOID(Dictionary, timingInput, Dictionary(info[1], info.GetIsolate()
)); |
120 if (!timingInput.isUndefinedOrNull() && !timingInput.isObject()) { | 120 if (!timingInput.isUndefinedOrNull() && !timingInput.isObject()) { |
121 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute("ani
mate", "Element", "parameter 2 ('timingInput') is not an object."), info.GetIsol
ate()); | 121 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute("ani
mate", "Element", "parameter 2 ('timingInput') is not an object."), info.GetIsol
ate()); |
122 return; | 122 return; |
123 } | 123 } |
124 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe
ct, timingInput)), impl); | 124 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe
ct, timingInput)), impl); |
125 } | 125 } |
126 | 126 |
127 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect, double
timing); | 127 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect, double
timing); |
128 void animate5Method(const v8::FunctionCallbackInfo<v8::Value>& info) | 128 void animate5Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
129 { | 129 { |
130 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", "
Element", info.Holder(), info.GetIsolate()); | 130 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", "
Element", info.Holder(), info.GetIsolate()); |
131 Element* impl = V8Element::toNative(info.Holder()); | 131 Element* impl = V8Element::toImpl(info.Holder()); |
132 TONATIVE_VOID(Vector<Dictionary>, keyframes, toNativeArray<Dictionary>(info[
0], 1, info.GetIsolate())); | 132 TONATIVE_VOID(Vector<Dictionary>, keyframes, toImplArray<Dictionary>(info[0]
, 1, info.GetIsolate())); |
133 TONATIVE_VOID(double, duration, static_cast<double>(info[1]->NumberValue()))
; | 133 TONATIVE_VOID(double, duration, static_cast<double>(info[1]->NumberValue()))
; |
134 RefPtrWillBeRawPtr<AnimationPlayer> result = ElementAnimation::animate(*impl
, keyframes, duration, exceptionState); | 134 RefPtrWillBeRawPtr<AnimationPlayer> result = ElementAnimation::animate(*impl
, keyframes, duration, exceptionState); |
135 if (exceptionState.throwIfNeeded()) | 135 if (exceptionState.throwIfNeeded()) |
136 return; | 136 return; |
137 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | 137 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); |
138 } | 138 } |
139 | 139 |
140 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect, Dictio
nary timing); | 140 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect, Dictio
nary timing); |
141 void animate6Method(const v8::FunctionCallbackInfo<v8::Value>& info) | 141 void animate6Method(const v8::FunctionCallbackInfo<v8::Value>& info) |
142 { | 142 { |
143 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", "
Element", info.Holder(), info.GetIsolate()); | 143 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", "
Element", info.Holder(), info.GetIsolate()); |
144 Element* impl = V8Element::toNative(info.Holder()); | 144 Element* impl = V8Element::toImpl(info.Holder()); |
145 TONATIVE_VOID(Vector<Dictionary>, keyframes, toNativeArray<Dictionary>(info[
0], 1, info.GetIsolate())); | 145 TONATIVE_VOID(Vector<Dictionary>, keyframes, toImplArray<Dictionary>(info[0]
, 1, info.GetIsolate())); |
146 TONATIVE_VOID(Dictionary, timingInput, Dictionary(info[1], info.GetIsolate()
)); | 146 TONATIVE_VOID(Dictionary, timingInput, Dictionary(info[1], info.GetIsolate()
)); |
147 if (!timingInput.isUndefinedOrNull() && !timingInput.isObject()) { | 147 if (!timingInput.isUndefinedOrNull() && !timingInput.isObject()) { |
148 exceptionState.throwTypeError("parameter 2 ('timingInput') is not an obj
ect."); | 148 exceptionState.throwTypeError("parameter 2 ('timingInput') is not an obj
ect."); |
149 exceptionState.throwIfNeeded(); | 149 exceptionState.throwIfNeeded(); |
150 return; | 150 return; |
151 } | 151 } |
152 RefPtrWillBeRawPtr<AnimationPlayer> result = ElementAnimation::animate(*impl
, keyframes, timingInput, exceptionState); | 152 RefPtrWillBeRawPtr<AnimationPlayer> result = ElementAnimation::animate(*impl
, keyframes, timingInput, exceptionState); |
153 if (exceptionState.throwIfNeeded()) | 153 if (exceptionState.throwIfNeeded()) |
154 return; | 154 return; |
155 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | 155 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 setArityTypeError(exceptionState, "[1]", info.Length()); | 228 setArityTypeError(exceptionState, "[1]", info.Length()); |
229 exceptionState.throwIfNeeded(); | 229 exceptionState.throwIfNeeded(); |
230 return; | 230 return; |
231 break; | 231 break; |
232 } | 232 } |
233 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 233 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
234 exceptionState.throwIfNeeded(); | 234 exceptionState.throwIfNeeded(); |
235 } | 235 } |
236 | 236 |
237 } // namespace blink | 237 } // namespace blink |
OLD | NEW |