Source/WebCore/ChangeLog

 12013-03-21 Peter Beverloo <peter@chromium.org>
 2
 3 Implement the DeviceAcceleration and DeviceRotationRate IDL objects
 4 https://bugs.webkit.org/show_bug.cgi?id=112910
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Remove the custom bindings --except for the event initialization
 9 methods-- in favor of implementing the IDL objects as defined by
 10 the specification. This patch adds the DeviceAcceleration and
 11 DeviceRotationRate objects.
 12
 13 There should be no observable change in behavior. This is being
 14 excersized by the existing layout tests.
 15
 16 * CMakeLists.txt:
 17 * DerivedSources.make:
 18 * DerivedSources.pri:
 19 * GNUmakefile.list.am:
 20 * Target.pri:
 21 * WebCore.gypi:
 22 * bindings/js/JSDeviceMotionEventCustom.cpp:
 23 * bindings/js/JSDeviceOrientationEventCustom.cpp:
 24 * bindings/v8/custom/V8DeviceMotionEventCustom.cpp:
 25 * bindings/v8/custom/V8DeviceOrientationEventCustom.cpp:
 26 * dom/DOMAllInOne.cpp:
 27 * dom/DeviceAcceleration.cpp: Added.
 28 (WebCore):
 29 (WebCore::DeviceAcceleration::DeviceAcceleration):
 30 (WebCore::DeviceAcceleration::x):
 31 (WebCore::DeviceAcceleration::y):
 32 (WebCore::DeviceAcceleration::z):
 33 * dom/DeviceAcceleration.h: Added.
 34 (WebCore):
 35 (DeviceAcceleration):
 36 (WebCore::DeviceAcceleration::create):
 37 * dom/DeviceAcceleration.idl: Added.
 38 * dom/DeviceMotionEvent.cpp:
 39 (WebCore::DeviceMotionEvent::initDeviceMotionEvent):
 40 (WebCore):
 41 (WebCore::DeviceMotionEvent::acceleration):
 42 (WebCore::DeviceMotionEvent::accelerationIncludingGravity):
 43 (WebCore::DeviceMotionEvent::rotationRate):
 44 (WebCore::DeviceMotionEvent::interval):
 45 * dom/DeviceMotionEvent.h:
 46 (WebCore):
 47 (DeviceMotionEvent):
 48 * dom/DeviceMotionEvent.idl:
 49 * dom/DeviceOrientationEvent.cpp:
 50 (WebCore::DeviceOrientationEvent::alpha):
 51 (WebCore):
 52 (WebCore::DeviceOrientationEvent::beta):
 53 (WebCore::DeviceOrientationEvent::gamma):
 54 (WebCore::DeviceOrientationEvent::absolute):
 55 * dom/DeviceOrientationEvent.h:
 56 (DeviceOrientationEvent):
 57 * dom/DeviceOrientationEvent.idl:
 58 * dom/DeviceRotationRate.cpp: Added.
 59 (WebCore):
 60 (WebCore::DeviceRotationRate::DeviceRotationRate):
 61 (WebCore::DeviceRotationRate::alpha):
 62 (WebCore::DeviceRotationRate::beta):
 63 (WebCore::DeviceRotationRate::gamma):
 64 * dom/DeviceRotationRate.h: Added.
 65 (WebCore):
 66 (DeviceRotationRate):
 67 (WebCore::DeviceRotationRate::create):
 68 * dom/DeviceRotationRate.idl: Added.
 69
1702013-03-20 Allan Sandfeld Jensen <allan.jensen@digia.com>
271
372 [Qt] New fast/text/word-space-with-kerning-3.html fails on Qt

Source/WebCore/CMakeLists.txt

@@set(WebCore_IDL_FILES
343343 dom/CustomEvent.idl
344344 dom/DataTransferItem.idl
345345 dom/DataTransferItemList.idl
 346 dom/DeviceAcceleration.idl
346347 dom/DeviceMotionEvent.idl
347348 dom/DeviceOrientationEvent.idl
 349 dom/DeviceRotationRate.idl
348350 dom/DOMCoreException.idl
349351 dom/DOMError.idl
350352 dom/DOMImplementation.idl

@@set(WebCore_SOURCES
11401142 dom/DatasetDOMStringMap.cpp
11411143 dom/DataTransferItem.cpp
11421144 dom/DecodedDataDocumentParser.cpp
 1145 dom/DeviceAcceleration.cpp
11431146 dom/DeviceMotionController.cpp
11441147 dom/DeviceMotionData.cpp
11451148 dom/DeviceMotionEvent.cpp
11461149 dom/DeviceOrientationController.cpp
11471150 dom/DeviceOrientationData.cpp
11481151 dom/DeviceOrientationEvent.cpp
 1152 dom/DeviceRotationRate.cpp
11491153 dom/DOMCoreException.cpp
11501154 dom/DOMError.cpp
11511155 dom/DOMImplementation.cpp

Source/WebCore/DerivedSources.make

@@BINDING_IDLS = \
233233 $(WebCore)/dom/DOMStringMap.idl \
234234 $(WebCore)/dom/DataTransferItem.idl \
235235 $(WebCore)/dom/DataTransferItemList.idl \
 236 $(WebCore)/dom/DeviceAcceleration.idl \
236237 $(WebCore)/dom/DeviceMotionEvent.idl \
237238 $(WebCore)/dom/DeviceOrientationEvent.idl \
 239 $(WebCore)/dom/DeviceRotationRate.idl \
238240 $(WebCore)/dom/Document.idl \
239241 $(WebCore)/dom/DocumentFragment.idl \
240242 $(WebCore)/dom/DocumentType.idl \

Source/WebCore/DerivedSources.pri

@@IDL_BINDINGS += \
235235 $$PWD/dom/CustomEvent.idl \
236236 $$PWD/dom/DataTransferItem.idl \
237237 $$PWD/dom/DataTransferItemList.idl \
 238 $$PWD/dom/DeviceAcceleration.idl \
238239 $$PWD/dom/DeviceMotionEvent.idl \
239240 $$PWD/dom/DeviceOrientationEvent.idl \
 241 $$PWD/dom/DeviceRotationRate.idl \
240242 $$PWD/dom/DocumentFragment.idl \
241243 $$PWD/dom/Document.idl \
242244 $$PWD/dom/DocumentType.idl \

Source/WebCore/GNUmakefile.list.am

@@webcore_built_sources += \
161161 DerivedSources/WebCore/JSDedicatedWorkerContext.h \
162162 DerivedSources/WebCore/JSDelayNode.cpp \
163163 DerivedSources/WebCore/JSDelayNode.h \
 164 DerivedSources/WebCore/JSDeviceAcceleration.cpp \
 165 DerivedSources/WebCore/JSDeviceAcceleration.h \
164166 DerivedSources/WebCore/JSDeviceMotionEvent.cpp \
165167 DerivedSources/WebCore/JSDeviceMotionEvent.h \
166168 DerivedSources/WebCore/JSDeviceOrientationEvent.cpp \
167169 DerivedSources/WebCore/JSDeviceOrientationEvent.h \
 170 DerivedSources/WebCore/JSDeviceRotationRate.cpp \
 171 DerivedSources/WebCore/JSDeviceRotationRate.h \
168172 DerivedSources/WebCore/JSDirectoryEntry.cpp \
169173 DerivedSources/WebCore/JSDirectoryEntry.h \
170174 DerivedSources/WebCore/JSDirectoryEntrySync.cpp \

@@dom_binding_idls += \
13901394 $(WebCore)/dom/DOMStringMap.idl \
13911395 $(WebCore)/dom/DataTransferItem.idl \
13921396 $(WebCore)/dom/DataTransferItemList.idl \
 1397 $(WebCore)/dom/DeviceAcceleration.idl \
13931398 $(WebCore)/dom/DeviceMotionEvent.idl \
13941399 $(WebCore)/dom/DeviceOrientationEvent.idl \
 1400 $(WebCore)/dom/DeviceRotationRate.idl \
13951401 $(WebCore)/dom/Document.idl \
13961402 $(WebCore)/dom/DocumentFragment.idl \
13971403 $(WebCore)/dom/DocumentType.idl \

@@webcore_sources += \
28292835 Source/WebCore/dom/DecodedDataDocumentParser.h \
28302836 Source/WebCore/dom/default/PlatformMessagePortChannel.cpp \
28312837 Source/WebCore/dom/default/PlatformMessagePortChannel.h \
 2838 Source/WebCore/dom/DeviceAcceleration.cpp \
 2839 Source/WebCore/dom/DeviceAcceleration.h \
28322840 Source/WebCore/dom/DeviceMotionClient.h \
28332841 Source/WebCore/dom/DeviceMotionController.cpp \
28342842 Source/WebCore/dom/DeviceMotionController.h \

@@webcore_sources += \
28432851 Source/WebCore/dom/DeviceOrientationData.h \
28442852 Source/WebCore/dom/DeviceOrientationEvent.cpp \
28452853 Source/WebCore/dom/DeviceOrientationEvent.h \
 2854 Source/WebCore/dom/DeviceRotationRate.cpp \
 2855 Source/WebCore/dom/DeviceRotationRate.h \
28462856 Source/WebCore/dom/Document.cpp \
28472857 Source/WebCore/dom/DocumentFragment.cpp \
28482858 Source/WebCore/dom/DocumentFragment.h \

Source/WebCore/Target.pri

@@SOURCES += \
377377 dom/ContextFeatures.cpp \
378378 dom/CustomEvent.cpp \
379379 dom/DecodedDataDocumentParser.cpp \
 380 dom/DeviceAcceleration.cpp \
380381 dom/DeviceMotionController.cpp \
381382 dom/DeviceMotionData.cpp \
382383 dom/DeviceMotionEvent.cpp \
383384 dom/DeviceOrientationController.cpp \
384385 dom/DeviceOrientationData.cpp \
385386 dom/DeviceOrientationEvent.cpp \
 387 dom/DeviceRotationRate.cpp \
386388 dom/Document.cpp \
387389 dom/DocumentEventQueue.cpp \
388390 dom/DocumentFragment.cpp \

@@HEADERS += \
16201622 dom/ContextFeatures.h \
16211623 dom/CustomEvent.h \
16221624 dom/default/PlatformMessagePortChannel.h \
 1625 dom/DeviceAcceleration.h \
16231626 dom/DeviceMotionClient.h \
16241627 dom/DeviceMotionController.h \
16251628 dom/DeviceMotionData.h \

@@HEADERS += \
16281631 dom/DeviceOrientationController.h \
16291632 dom/DeviceOrientationData.h \
16301633 dom/DeviceOrientationEvent.h \
 1634 dom/DeviceRotationRate.h \
16311635 dom/Document.h \
16321636 dom/DocumentFragment.h \
16331637 dom/DocumentMarker.h \

Source/WebCore/WebCore.gypi

299299 'dom/DOMStringMap.idl',
300300 'dom/DataTransferItem.idl',
301301 'dom/DataTransferItemList.idl',
 302 'dom/DeviceAcceleration.idl',
302303 'dom/DeviceMotionEvent.idl',
303304 'dom/DeviceOrientationEvent.idl',
 305 'dom/DeviceRotationRate.idl',
304306 'dom/Document.idl',
305307 'dom/DocumentFragment.idl',
306308 'dom/DocumentType.idl',

29182920 'dom/DatasetDOMStringMap.h',
29192921 'dom/DecodedDataDocumentParser.cpp',
29202922 'dom/DecodedDataDocumentParser.h',
 2923 'dom/DeviceAcceleration.cpp',
 2924 'dom/DeviceAcceleration.h',
29212925 'dom/DeviceMotionClient.h',
29222926 'dom/DeviceMotionController.cpp',
29232927 'dom/DeviceMotionController.h',

29302934 'dom/DeviceOrientationData.cpp',
29312935 'dom/DeviceOrientationEvent.cpp',
29322936 'dom/DeviceOrientationEvent.h',
 2937 'dom/DeviceRotationRate.cpp',
 2938 'dom/DeviceRotationRate.h',
29332939 'dom/Document.cpp',
29342940 'dom/DocumentEventQueue.cpp',
29352941 'dom/DocumentEventQueue.h',

64886494 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDedicatedWorkerContext.h',
64896495 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDelayNode.cpp',
64906496 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDelayNode.h',
 6497 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceAcceleration.cpp',
 6498 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceAcceleration.h',
64916499 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceMotionEvent.cpp',
64926500 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceMotionEvent.h',
64936501 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceOrientationEvent.cpp',
64946502 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceOrientationEvent.h',
 6503 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceRotationRate.cpp',
 6504 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDeviceRotationRate.h',
64956505 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDirectoryEntry.cpp',
64966506 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDirectoryEntry.h',
64976507 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDirectoryEntrySync.cpp',

Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp

@@static PassRefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(JSVal
113113 return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
114114}
115115
116 static JSObject* createAccelerationObject(const DeviceMotionData::Acceleration* acceleration, ExecState* exec)
117 {
118  JSObject* object = constructEmptyObject(exec);
119  object->putDirect(exec->globalData(), Identifier(exec, "x"), acceleration->canProvideX() ? jsNumber(acceleration->x()) : jsNull());
120  object->putDirect(exec->globalData(), Identifier(exec, "y"), acceleration->canProvideY() ? jsNumber(acceleration->y()) : jsNull());
121  object->putDirect(exec->globalData(), Identifier(exec, "z"), acceleration->canProvideZ() ? jsNumber(acceleration->z()) : jsNull());
122  return object;
123 }
124 
125 static JSObject* createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate, ExecState* exec)
126 {
127  JSObject* object = constructEmptyObject(exec);
128  object->putDirect(exec->globalData(), Identifier(exec, "alpha"), rotationRate->canProvideAlpha() ? jsNumber(rotationRate->alpha()) : jsNull());
129  object->putDirect(exec->globalData(), Identifier(exec, "beta"), rotationRate->canProvideBeta() ? jsNumber(rotationRate->beta()) : jsNull());
130  object->putDirect(exec->globalData(), Identifier(exec, "gamma"), rotationRate->canProvideGamma() ? jsNumber(rotationRate->gamma()) : jsNull());
131  return object;
132 }
133 
134 JSValue JSDeviceMotionEvent::acceleration(ExecState* exec) const
135 {
136  DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
137  if (!imp->deviceMotionData()->acceleration())
138  return jsNull();
139  return createAccelerationObject(imp->deviceMotionData()->acceleration(), exec);
140 }
141 
142 JSValue JSDeviceMotionEvent::accelerationIncludingGravity(ExecState* exec) const
143 {
144  DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
145  if (!imp->deviceMotionData()->accelerationIncludingGravity())
146  return jsNull();
147  return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity(), exec);
148 }
149 
150 JSValue JSDeviceMotionEvent::rotationRate(ExecState* exec) const
151 {
152  DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
153  if (!imp->deviceMotionData()->rotationRate())
154  return jsNull();
155  return createRotationRateObject(imp->deviceMotionData()->rotationRate(), exec);
156 }
157 
158 JSValue JSDeviceMotionEvent::interval(ExecState*) const
159 {
160  DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
161  if (!imp->deviceMotionData()->canProvideInterval())
162  return jsNull();
163  return jsNumber(imp->deviceMotionData()->interval());
164 }
165 
166116JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState* exec)
167117{
168118 const String type = exec->argument(0).toString(exec)->value(exec);

Source/WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp

@@using namespace JSC;
3636
3737namespace WebCore {
3838
39 JSValue JSDeviceOrientationEvent::alpha(ExecState*) const
40 {
41  DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
42  if (!imp->orientation()->canProvideAlpha())
43  return jsNull();
44  return jsNumber(imp->orientation()->alpha());
45 }
46 
47 JSValue JSDeviceOrientationEvent::beta(ExecState*) const
48 {
49  DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
50  if (!imp->orientation()->canProvideBeta())
51  return jsNull();
52  return jsNumber(imp->orientation()->beta());
53 }
54 
55 JSValue JSDeviceOrientationEvent::gamma(ExecState*) const
56 {
57  DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
58  if (!imp->orientation()->canProvideGamma())
59  return jsNull();
60  return jsNumber(imp->orientation()->gamma());
61 }
62 
63 JSValue JSDeviceOrientationEvent::absolute(ExecState*) const
64 {
65  DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
66  if (!imp->orientation()->canProvideAbsolute())
67  return jsNull();
68  return jsBoolean(imp->orientation()->absolute());
69 }
70 
7139JSValue JSDeviceOrientationEvent::initDeviceOrientationEvent(ExecState* exec)
7240{
7341 const String type = exec->argument(0).toString(exec)->value(exec);

Source/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp

@@namespace WebCore {
3737
3838namespace {
3939
40 static v8::Handle<v8::Value> createAccelerationObject(const DeviceMotionData::Acceleration* acceleration, v8::Isolate* isolate)
41 {
42  v8::Local<v8::Object> object = v8::Object::New();
43  object->Set(v8::String::NewSymbol("x"), acceleration->canProvideX() ? v8::Number::New(acceleration->x()) : v8Null(isolate));
44  object->Set(v8::String::NewSymbol("y"), acceleration->canProvideY() ? v8::Number::New(acceleration->y()) : v8Null(isolate));
45  object->Set(v8::String::NewSymbol("z"), acceleration->canProvideZ() ? v8::Number::New(acceleration->z()) : v8Null(isolate));
46  return object;
47 }
48 
49 static v8::Handle<v8::Value> createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate, v8::Isolate* isolate)
50 {
51  v8::Local<v8::Object> object = v8::Object::New();
52  object->Set(v8::String::NewSymbol("alpha"), rotationRate->canProvideAlpha() ? v8::Number::New(rotationRate->alpha()) : v8Null(isolate));
53  object->Set(v8::String::NewSymbol("beta"), rotationRate->canProvideBeta() ? v8::Number::New(rotationRate->beta()) : v8Null(isolate));
54  object->Set(v8::String::NewSymbol("gamma"), rotationRate->canProvideGamma() ? v8::Number::New(rotationRate->gamma()) : v8Null(isolate));
55  return object;
56 }
57 
5840RefPtr<DeviceMotionData::Acceleration> readAccelerationArgument(v8::Local<v8::Value> value)
5941{
6042 if (isUndefinedOrNull(value))

@@RefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(v8::Local<v8::Va
121103
122104} // namespace
123105
124 v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
125 {
126  v8::Handle<v8::Object> holder = info.Holder();
127  DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
128  if (!imp->deviceMotionData()->acceleration())
129  return v8Null(info.GetIsolate());
130  return createAccelerationObject(imp->deviceMotionData()->acceleration(), info.GetIsolate());
131 }
132 
133 v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationIncludingGravityAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
134 {
135  v8::Handle<v8::Object> holder = info.Holder();
136  DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
137  if (!imp->deviceMotionData()->accelerationIncludingGravity())
138  return v8Null(info.GetIsolate());
139  return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity(), info.GetIsolate());
140 }
141 
142 v8::Handle<v8::Value> V8DeviceMotionEvent::rotationRateAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
143 {
144  v8::Handle<v8::Object> holder = info.Holder();
145  DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
146  if (!imp->deviceMotionData()->rotationRate())
147  return v8Null(info.GetIsolate());
148  return createRotationRateObject(imp->deviceMotionData()->rotationRate(), info.GetIsolate());
149 }
150 
151 v8::Handle<v8::Value> V8DeviceMotionEvent::intervalAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
152 {
153  v8::Handle<v8::Object> holder = info.Holder();
154  DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
155  if (!imp->deviceMotionData()->canProvideInterval())
156  return v8Null(info.GetIsolate());
157  return v8::Number::New(imp->deviceMotionData()->interval());
158 }
159 
160106v8::Handle<v8::Value> V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(const v8::Arguments& args)
161107{
162108 DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(args.Holder());

Source/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp

3535
3636namespace WebCore {
3737
38 v8::Handle<v8::Value> V8DeviceOrientationEvent::alphaAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
39 {
40  v8::Handle<v8::Object> holder = info.Holder();
41  DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
42  if (!imp->orientation()->canProvideAlpha())
43  return v8Null(info.GetIsolate());
44  return v8::Number::New(imp->orientation()->alpha());
45 }
46 
47 v8::Handle<v8::Value> V8DeviceOrientationEvent::betaAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
48 {
49  v8::Handle<v8::Object> holder = info.Holder();
50  DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
51  if (!imp->orientation()->canProvideBeta())
52  return v8Null(info.GetIsolate());
53  return v8::Number::New(imp->orientation()->beta());
54 }
55 
56 v8::Handle<v8::Value> V8DeviceOrientationEvent::gammaAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
57 {
58  v8::Handle<v8::Object> holder = info.Holder();
59  DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
60  if (!imp->orientation()->canProvideGamma())
61  return v8Null(info.GetIsolate());
62  return v8::Number::New(imp->orientation()->gamma());
63 }
64 
65 v8::Handle<v8::Value> V8DeviceOrientationEvent::absoluteAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
66 {
67  v8::Handle<v8::Object> holder = info.Holder();
68  DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
69  if (!imp->orientation()->canProvideAbsolute())
70  return v8Null(info.GetIsolate());
71  return v8::Boolean::New(imp->orientation()->absolute());
72 }
73 
7438v8::Handle<v8::Value> V8DeviceOrientationEvent::initDeviceOrientationEventMethodCustom(const v8::Arguments& args)
7539{
7640 DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(args.Holder());

Source/WebCore/dom/DOMAllInOne.cpp

5353#include "DOMStringMap.cpp"
5454#include "DatasetDOMStringMap.cpp"
5555#include "DecodedDataDocumentParser.cpp"
 56#include "DeviceAcceleration.cpp"
5657#include "DeviceMotionController.cpp"
5758#include "DeviceMotionData.cpp"
5859#include "DeviceMotionEvent.cpp"
5960#include "DeviceOrientationController.cpp"
6061#include "DeviceOrientationData.cpp"
6162#include "DeviceOrientationEvent.cpp"
 63#include "DeviceRotationRate.cpp"
6264#include "Document.cpp"
6365#include "DocumentEventQueue.cpp"
6466#include "DocumentFragment.cpp"

Source/WebCore/dom/DeviceAcceleration.cpp

 1/*
 2 * Copyright (C) 2013 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceAcceleration.h"
 28
 29namespace WebCore {
 30
 31DeviceAcceleration::DeviceAcceleration(const DeviceMotionData::Acceleration* acceleration)
 32 : m_acceleration(acceleration)
 33{
 34}
 35
 36double DeviceAcceleration::x(bool& isNull) const
 37{
 38 if (m_acceleration->canProvideX())
 39 return m_acceleration->x();
 40
 41 isNull = true;
 42 return 0;
 43}
 44
 45double DeviceAcceleration::y(bool& isNull) const
 46{
 47 if (m_acceleration->canProvideY())
 48 return m_acceleration->y();
 49
 50 isNull = true;
 51 return 0;
 52}
 53
 54double DeviceAcceleration::z(bool& isNull) const
 55{
 56 if (m_acceleration->canProvideZ())
 57 return m_acceleration->z();
 58
 59 isNull = true;
 60 return 0;
 61}
 62
 63} // namespace WebCore

Source/WebCore/dom/DeviceAcceleration.h

 1/*
 2 * Copyright (C) 2013 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceAcceleration_h
 27#define DeviceAcceleration_h
 28
 29#if ENABLE(DEVICE_ORIENTATION)
 30
 31#include "DeviceMotionData.h"
 32#include <wtf/RefCounted.h>
 33
 34namespace WebCore {
 35
 36class DeviceAcceleration : public RefCounted<DeviceAcceleration> {
 37public:
 38 static PassRefPtr<DeviceAcceleration> create(const DeviceMotionData::Acceleration* acceleration)
 39 {
 40 return adoptRef(new DeviceAcceleration(acceleration));
 41 }
 42
 43 double x(bool& isNull) const;
 44 double y(bool& isNull) const;
 45 double z(bool& isNull) const;
 46
 47private:
 48 DeviceAcceleration(const DeviceMotionData::Acceleration*);
 49
 50 const DeviceMotionData::Acceleration* m_acceleration;
 51};
 52
 53} // namespace WebCore
 54
 55#endif // ENABLE(DEVICE_ORIENTATION)
 56
 57#endif // DeviceAcceleration_h

Source/WebCore/dom/DeviceAcceleration.idl

 1/*
 2 * Copyright (C) 2013 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26[
 27 Conditional=DEVICE_ORIENTATION,
 28 ImplementationLacksVTable
 29] interface DeviceAcceleration {
 30 readonly attribute double? x;
 31 readonly attribute double? y;
 32 readonly attribute double? z;
 33};

Source/WebCore/dom/DeviceMotionEvent.cpp

2626#include "config.h"
2727#include "DeviceMotionEvent.h"
2828
 29#include "DeviceAcceleration.h"
2930#include "DeviceMotionData.h"
 31#include "DeviceRotationRate.h"
3032#include "EventNames.h"
3133
3234namespace WebCore {

@@void DeviceMotionEvent::initDeviceMotionEvent(const AtomicString& type, bool bub
5355
5456 initEvent(type, bubbles, cancelable);
5557 m_deviceMotionData = deviceMotionData;
 58
 59 m_acceleration.clear();
 60 m_accelerationIncludingGravity.clear();
 61 m_rotationRate.clear();
 62}
 63
 64DeviceAcceleration* DeviceMotionEvent::acceleration()
 65{
 66 if (!m_deviceMotionData->acceleration())
 67 return 0;
 68
 69 if (!m_acceleration.get())
 70 m_acceleration = DeviceAcceleration::create(m_deviceMotionData->acceleration());
 71
 72 return m_acceleration.get();
 73}
 74
 75DeviceAcceleration* DeviceMotionEvent::accelerationIncludingGravity()
 76{
 77 if (!m_deviceMotionData->accelerationIncludingGravity())
 78 return 0;
 79
 80 if (!m_accelerationIncludingGravity.get())
 81 m_accelerationIncludingGravity = DeviceAcceleration::create(m_deviceMotionData->accelerationIncludingGravity());
 82
 83 return m_accelerationIncludingGravity.get();
 84}
 85
 86DeviceRotationRate* DeviceMotionEvent::rotationRate()
 87{
 88 if (!m_deviceMotionData->rotationRate())
 89 return 0;
 90
 91 if (!m_rotationRate.get())
 92 m_rotationRate = DeviceRotationRate::create(m_deviceMotionData->rotationRate());
 93
 94 return m_rotationRate.get();
 95}
 96
 97double DeviceMotionEvent::interval(bool& isNull) const
 98{
 99 if (m_deviceMotionData->canProvideInterval())
 100 return m_deviceMotionData->interval();
 101
 102 isNull = true;
 103 return 0;
56104}
57105
58106const AtomicString& DeviceMotionEvent::interfaceName() const

Source/WebCore/dom/DeviceMotionEvent.h

3030
3131namespace WebCore {
3232
 33class DeviceAcceleration;
3334class DeviceMotionData;
 35class DeviceRotationRate;
3436
3537class DeviceMotionEvent : public Event {
3638public:

@@public:
4850
4951 DeviceMotionData* deviceMotionData() const { return m_deviceMotionData.get(); }
5052
 53 DeviceAcceleration* acceleration();
 54 DeviceAcceleration* accelerationIncludingGravity();
 55 DeviceRotationRate* rotationRate();
 56 double interval(bool& isNull) const;
 57
5158 virtual const AtomicString& interfaceName() const;
5259
5360private:

@@private:
5562 DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*);
5663
5764 RefPtr<DeviceMotionData> m_deviceMotionData;
 65
 66 RefPtr<DeviceAcceleration> m_acceleration;
 67 RefPtr<DeviceAcceleration> m_accelerationIncludingGravity;
 68 RefPtr<DeviceRotationRate> m_rotationRate;
5869};
5970
6071} // namespace WebCore

Source/WebCore/dom/DeviceMotionEvent.idl

2626[
2727 Conditional=DEVICE_ORIENTATION,
2828] interface DeviceMotionEvent : Event {
29  [Custom] readonly attribute Acceleration acceleration;
30  [Custom] readonly attribute Acceleration accelerationIncludingGravity;
31  [Custom] readonly attribute RotationRate rotationRate;
32  [Custom] readonly attribute double interval;
 29 readonly attribute DeviceAcceleration acceleration;
 30 readonly attribute DeviceAcceleration accelerationIncludingGravity;
 31 readonly attribute DeviceRotationRate rotationRate;
 32 readonly attribute double? interval;
3333 [Custom] void initDeviceMotionEvent(in [Optional=DefaultIsUndefined] DOMString type,
3434 in [Optional=DefaultIsUndefined] boolean bubbles,
3535 in [Optional=DefaultIsUndefined] boolean cancelable,

Source/WebCore/dom/DeviceOrientationEvent.cpp

@@void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type
5555 m_orientation = orientation;
5656}
5757
 58double DeviceOrientationEvent::alpha(bool& isNull) const
 59{
 60 if (m_orientation->canProvideAlpha())
 61 return m_orientation->alpha();
 62
 63 isNull = true;
 64 return 0;
 65}
 66
 67double DeviceOrientationEvent::beta(bool& isNull) const
 68{
 69 if (m_orientation->canProvideBeta())
 70 return m_orientation->beta();
 71
 72 isNull = true;
 73 return 0;
 74}
 75
 76double DeviceOrientationEvent::gamma(bool& isNull) const
 77{
 78 if (m_orientation->canProvideGamma())
 79 return m_orientation->gamma();
 80
 81 isNull = true;
 82 return 0;
 83}
 84
 85bool DeviceOrientationEvent::absolute(bool& isNull) const
 86{
 87 if (m_orientation->canProvideAbsolute())
 88 return m_orientation->absolute();
 89
 90 isNull = true;
 91 return 0;
 92}
 93
5894const AtomicString& DeviceOrientationEvent::interfaceName() const
5995{
6096#if ENABLE(DEVICE_ORIENTATION)

Source/WebCore/dom/DeviceOrientationEvent.h

@@public:
4848
4949 DeviceOrientationData* orientation() const { return m_orientation.get(); }
5050
 51 double alpha(bool& isNull) const;
 52 double beta(bool& isNull) const;
 53 double gamma(bool& isNull) const;
 54 bool absolute(bool& isNull) const;
 55
5156 virtual const AtomicString& interfaceName() const;
5257
5358private:

Source/WebCore/dom/DeviceOrientationEvent.idl

2626[
2727 Conditional=DEVICE_ORIENTATION,
2828] interface DeviceOrientationEvent : Event {
29  [Custom] readonly attribute double alpha;
30  [Custom] readonly attribute double beta;
31  [Custom] readonly attribute double gamma;
32  [Custom] readonly attribute boolean absolute;
 29 readonly attribute double? alpha;
 30 readonly attribute double? beta;
 31 readonly attribute double? gamma;
 32 readonly attribute boolean? absolute;
3333 [Custom] void initDeviceOrientationEvent(in [Optional=DefaultIsUndefined] DOMString type,
3434 in [Optional=DefaultIsUndefined] boolean bubbles,
3535 in [Optional=DefaultIsUndefined] boolean cancelable,

Source/WebCore/dom/DeviceRotationRate.cpp

 1/*
 2 * Copyright (C) 2013 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceRotationRate.h"
 28
 29namespace WebCore {
 30
 31DeviceRotationRate::DeviceRotationRate(const DeviceMotionData::RotationRate* rotationRate)
 32 : m_rotationRate(rotationRate)
 33{
 34}
 35
 36double DeviceRotationRate::alpha(bool& isNull) const
 37{
 38 if (m_rotationRate->canProvideAlpha())
 39 return m_rotationRate->alpha();
 40
 41 isNull = true;
 42 return 0;
 43}
 44
 45double DeviceRotationRate::beta(bool& isNull) const
 46{
 47 if (m_rotationRate->canProvideBeta())
 48 return m_rotationRate->beta();
 49
 50 isNull = true;
 51 return 0;
 52}
 53
 54double DeviceRotationRate::gamma(bool& isNull) const
 55{
 56 if (m_rotationRate->canProvideGamma())
 57 return m_rotationRate->gamma();
 58
 59 isNull = true;
 60 return 0;
 61}
 62
 63} // namespace WebCore

Source/WebCore/dom/DeviceRotationRate.h

 1/*
 2 * Copyright (C) 2013 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceRotationRate_h
 27#define DeviceRotationRate_h
 28
 29#if ENABLE(DEVICE_ORIENTATION)
 30
 31#include "DeviceMotionData.h"
 32#include <wtf/RefCounted.h>
 33
 34namespace WebCore {
 35
 36class DeviceRotationRate : public RefCounted<DeviceRotationRate> {
 37public:
 38 static PassRefPtr<DeviceRotationRate> create(const DeviceMotionData::RotationRate* rotationRate)
 39 {
 40 return adoptRef(new DeviceRotationRate(rotationRate));
 41 }
 42
 43 double alpha(bool& isNull) const;
 44 double beta(bool& isNull) const;
 45 double gamma(bool& isNull) const;
 46
 47private:
 48 DeviceRotationRate(const DeviceMotionData::RotationRate*);
 49
 50 const DeviceMotionData::RotationRate* m_rotationRate;
 51};
 52
 53} // namespace WebCore
 54
 55#endif // ENABLE(DEVICE_ORIENTATION)
 56
 57#endif // DeviceRotationRate_h

Source/WebCore/dom/DeviceRotationRate.idl

 1/*
 2 * Copyright (C) 2013 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26[
 27 Conditional=DEVICE_ORIENTATION,
 28 ImplementationLacksVTable
 29] interface DeviceRotationRate {
 30 readonly attribute double? alpha;
 31 readonly attribute double? beta;
 32 readonly attribute double? gamma;
 33};