2010-07-12 Steve Block <steveblock@google.com>
authorsteveblock@google.com <steveblock@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jul 2010 11:35:13 +0000 (11:35 +0000)
committersteveblock@google.com <steveblock@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jul 2010 11:35:13 +0000 (11:35 +0000)
        Reviewed by Jeremy Orlow.

        DeviceOrientationEvent should use optional properties
        https://bugs.webkit.org/show_bug.cgi?id=41607

        This change adds a new DeviceOrientation class which takes care of which of the
        optional properties are present. DeviceOrientationEvent owns an instance of
        DeviceOrientation, rather than owning the properties directly.
        DeviceOrientationEvent now requires custom bindings.

        Test: fast/dom/DeviceOrientation/optional-event-properties.html

        * Android.mk:
        * Android.jscbindings.mk:
        * Android.v8bindings.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSBindingsAllInOne.cpp:
        * bindings/js/JSDeviceOrientationEventCustom.cpp: Added.
        (WebCore::JSDeviceOrientationEvent::alpha):
        (WebCore::JSDeviceOrientationEvent::beta):
        (WebCore::JSDeviceOrientationEvent::gamma):
        (WebCore::JSDeviceOrientationEvent::initDeviceOrientationEvent):
        * bindings/v8/custom/V8DeviceOrientationEventCustom.cpp: Added.
        (WebCore::V8DeviceOrientationEvent::alphaAccessorGetter):
        (WebCore::V8DeviceOrientationEvent::betaAccessorGetter):
        (WebCore::V8DeviceOrientationEvent::gammaAccessorGetter):
        (WebCore::V8DeviceOrientationEvent::initDeviceOrientationEventCallback):
        * dom/DeviceOrientation.cpp: Added.
        * dom/DeviceOrientation.h: Added.
        (WebCore::DeviceOrientation::create):
        (WebCore::DeviceOrientation::canProvideAlpha):
        (WebCore::DeviceOrientation::alpha):
        (WebCore::DeviceOrientation::canProvideBeta):
        (WebCore::DeviceOrientation::beta):
        (WebCore::DeviceOrientation::canProvideGamma):
        (WebCore::DeviceOrientation::gamma):
        (WebCore::DeviceOrientation::DeviceOrientation):
        * dom/DeviceOrientationEvent.cpp:
        (WebCore::DeviceOrientationEvent::DeviceOrientationEvent):
        (WebCore::DeviceOrientationEvent::initDeviceOrientationEvent):
        * dom/DeviceOrientationEvent.h:
        (WebCore::DeviceOrientationEvent::create):
        (WebCore::DeviceOrientationEvent::orientation):
        * dom/DeviceOrientationEvent.idl:
2010-07-12  Steve Block  <steveblock@google.com>

        Reviewed by Jeremy Orlow.

        DeviceOrientationEvent should use optional properties
        https://bugs.webkit.org/show_bug.cgi?id=41607

        * fast/dom/DeviceOrientation/optional-event-properties-expected.txt: Added.
        * fast/dom/DeviceOrientation/optional-event-properties.html: Added.
        * fast/dom/DeviceOrientation/script-tests/optional-event-properties.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63193 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/DeviceOrientation/optional-event-properties-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/DeviceOrientation/optional-event-properties.html [new file with mode: 0644]
LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js [new file with mode: 0644]
WebCore/Android.jscbindings.mk
WebCore/Android.mk
WebCore/Android.v8bindings.mk
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSBindingsAllInOne.cpp
WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp [new file with mode: 0644]
WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp [new file with mode: 0644]
WebCore/dom/DeviceOrientation.cpp [new file with mode: 0644]
WebCore/dom/DeviceOrientation.h [new file with mode: 0644]
WebCore/dom/DeviceOrientationEvent.cpp
WebCore/dom/DeviceOrientationEvent.h
WebCore/dom/DeviceOrientationEvent.idl

index 6ccfdb0..c96a375 100644 (file)
@@ -1,3 +1,14 @@
+2010-07-12  Steve Block  <steveblock@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        DeviceOrientationEvent should use optional properties
+        https://bugs.webkit.org/show_bug.cgi?id=41607
+
+        * fast/dom/DeviceOrientation/optional-event-properties-expected.txt: Added.
+        * fast/dom/DeviceOrientation/optional-event-properties.html: Added.
+        * fast/dom/DeviceOrientation/script-tests/optional-event-properties.js: Added.
+
 2010-07-07  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/dom/DeviceOrientation/optional-event-properties-expected.txt b/LayoutTests/fast/dom/DeviceOrientation/optional-event-properties-expected.txt
new file mode 100644 (file)
index 0000000..cd0e933
--- /dev/null
@@ -0,0 +1,37 @@
+Tests the optional properties of DeviceOrientationEvent. Each property should be null if not set, or set to null or undefined.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+event = document.createEvent('DeviceOrientationEvent')
+PASS event.alpha == null is true
+PASS event.beta == null is true
+PASS event.gamma == null is true
+event.initDeviceOrientationEvent('', false, false, 0, 1, 2)
+PASS event.alpha == 0 is true
+PASS event.beta == 1 is true
+PASS event.gamma == 2 is true
+event.initDeviceOrientationEvent()
+PASS event.alpha == null is true
+PASS event.beta == null is true
+PASS event.gamma == null is true
+event.initDeviceOrientationEvent('', false, false, [], [], [])
+PASS event.alpha == 0 is true
+PASS event.beta == 0 is true
+PASS event.gamma == 0 is true
+event.initDeviceOrientationEvent('', false, false, undefined, undefined, undefined)
+PASS event.alpha == null is true
+PASS event.beta == null is true
+PASS event.gamma == null is true
+event.initDeviceOrientationEvent('', false, false, '', '', '')
+PASS event.alpha == 0 is true
+PASS event.beta == 0 is true
+PASS event.gamma == 0 is true
+event.initDeviceOrientationEvent('', false, false, null, null, null)
+PASS event.alpha == null is true
+PASS event.beta == null is true
+PASS event.gamma == null is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/DeviceOrientation/optional-event-properties.html b/LayoutTests/fast/dom/DeviceOrientation/optional-event-properties.html
new file mode 100644 (file)
index 0000000..212669f
--- /dev/null
@@ -0,0 +1,12 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/optional-event-properties.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js
new file mode 100644 (file)
index 0000000..2936e72
--- /dev/null
@@ -0,0 +1,40 @@
+description("Tests the optional properties of DeviceOrientationEvent. Each property should be null if not set, or set to null or undefined.");
+
+var event;
+
+evalAndLog("event = document.createEvent('DeviceOrientationEvent')");
+shouldBeTrue("event.alpha == null");
+shouldBeTrue("event.beta == null");
+shouldBeTrue("event.gamma == null");
+
+evalAndLog("event.initDeviceOrientationEvent('', false, false, 0, 1, 2)");
+shouldBeTrue("event.alpha == 0");
+shouldBeTrue("event.beta == 1");
+shouldBeTrue("event.gamma == 2");
+
+evalAndLog("event.initDeviceOrientationEvent()");
+shouldBeTrue("event.alpha == null");
+shouldBeTrue("event.beta == null");
+shouldBeTrue("event.gamma == null");
+
+evalAndLog("event.initDeviceOrientationEvent('', false, false, [], [], [])");
+shouldBeTrue("event.alpha == 0");
+shouldBeTrue("event.beta == 0");
+shouldBeTrue("event.gamma == 0");
+
+evalAndLog("event.initDeviceOrientationEvent('', false, false, undefined, undefined, undefined)");
+shouldBeTrue("event.alpha == null");
+shouldBeTrue("event.beta == null");
+shouldBeTrue("event.gamma == null");
+
+evalAndLog("event.initDeviceOrientationEvent('', false, false, '', '', '')");
+shouldBeTrue("event.alpha == 0");
+shouldBeTrue("event.beta == 0");
+shouldBeTrue("event.gamma == 0");
+
+evalAndLog("event.initDeviceOrientationEvent('', false, false, null, null, null)");
+shouldBeTrue("event.alpha == null");
+shouldBeTrue("event.beta == null");
+shouldBeTrue("event.gamma == null");
+
+window.successfullyParsed = true;
index 5a82c3b..2ee4276 100644 (file)
@@ -80,19 +80,20 @@ LOCAL_SRC_FILES += \
        bindings/js/JSCustomSQLTransactionCallback.cpp \
        bindings/js/JSCustomSQLTransactionErrorCallback.cpp \
        bindings/js/JSCustomVoidCallback.cpp \
-       bindings/js/JSDatabaseCallback.cpp \
-       bindings/js/JSDesktopNotificationsCustom.cpp \
        bindings/js/JSDOMApplicationCacheCustom.cpp \
        bindings/js/JSDOMBinding.cpp \
-  bindings/js/JSDOMFormDataCustom.cpp \
+       bindings/js/JSDOMFormDataCustom.cpp \
        bindings/js/JSDOMGlobalObject.cpp \
        bindings/js/JSDOMWindowBase.cpp \
        bindings/js/JSDOMWindowCustom.cpp \
        bindings/js/JSDOMWindowShell.cpp \
+       bindings/js/JSDatabaseCallback.cpp \
        bindings/js/JSDataGridColumnListCustom.cpp \
        bindings/js/JSDataGridDataSource.cpp \
        bindings/js/JSDatabaseCustom.cpp \
        bindings/js/JSDedicatedWorkerContextCustom.cpp \
+       bindings/js/JSDesktopNotificationsCustom.cpp \
+       bindings/js/JSDeviceOrientationEventCustom.cpp \
        bindings/js/JSDocumentCustom.cpp \
        bindings/js/JSElementCustom.cpp \
        bindings/js/JSEventCustom.cpp \
index 2c86993..b68f30f 100644 (file)
@@ -148,6 +148,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
        dom/Notation.cpp \
        dom/OptionElement.cpp \
        dom/OptionGroupElement.cpp \
+       dom/DeviceOrientation.cpp \
        dom/DeviceOrientationController.cpp \
        dom/DeviceOrientationEvent.cpp \
        dom/OverflowEvent.cpp \
index e8424ee..b36beab 100644 (file)
@@ -108,6 +108,7 @@ LOCAL_SRC_FILES += \
        bindings/v8/custom/V8DatabaseCallback.cpp \
        bindings/v8/custom/V8DatabaseCustom.cpp \
        bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp \
+       bindings/v8/custom/V8DeviceOrientationEventCustom.cpp \
        bindings/v8/custom/V8DocumentCustom.cpp \
        bindings/v8/custom/V8DocumentLocationCustom.cpp \
        bindings/v8/custom/V8ElementCustom.cpp \
index 957b770..aa94d1e 100644 (file)
@@ -584,6 +584,7 @@ SET(WebCore_SOURCES
     bindings/js/JSDataGridDataSource.cpp
     bindings/js/JSDebugWrapperSet.cpp
     bindings/js/JSDedicatedWorkerContextCustom.cpp
+    bindings/js/JSDeviceOrientationEventCustom.cpp
     bindings/js/JSDocumentCustom.cpp
     bindings/js/JSDOMApplicationCacheCustom.cpp
     bindings/js/JSDOMBinding.cpp
@@ -778,6 +779,7 @@ SET(WebCore_SOURCES
     dom/CustomEvent.cpp
     dom/DatasetDOMStringMap.cpp
     dom/DecodedDataDocumentParser.cpp
+    dom/DeviceOrientation.cpp
     dom/DeviceOrientationController.cpp
     dom/DeviceOrientationEvent.cpp
     dom/Document.cpp
index 8c71d93..b0eff9e 100644 (file)
@@ -1,3 +1,55 @@
+2010-07-12  Steve Block  <steveblock@google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        DeviceOrientationEvent should use optional properties
+        https://bugs.webkit.org/show_bug.cgi?id=41607
+
+        This change adds a new DeviceOrientation class which takes care of which of the
+        optional properties are present. DeviceOrientationEvent owns an instance of
+        DeviceOrientation, rather than owning the properties directly.
+        DeviceOrientationEvent now requires custom bindings.
+
+        Test: fast/dom/DeviceOrientation/optional-event-properties.html
+
+        * Android.mk:
+        * Android.jscbindings.mk:
+        * Android.v8bindings.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        * bindings/js/JSDeviceOrientationEventCustom.cpp: Added.
+        (WebCore::JSDeviceOrientationEvent::alpha):
+        (WebCore::JSDeviceOrientationEvent::beta):
+        (WebCore::JSDeviceOrientationEvent::gamma):
+        (WebCore::JSDeviceOrientationEvent::initDeviceOrientationEvent):
+        * bindings/v8/custom/V8DeviceOrientationEventCustom.cpp: Added.
+        (WebCore::V8DeviceOrientationEvent::alphaAccessorGetter):
+        (WebCore::V8DeviceOrientationEvent::betaAccessorGetter):
+        (WebCore::V8DeviceOrientationEvent::gammaAccessorGetter):
+        (WebCore::V8DeviceOrientationEvent::initDeviceOrientationEventCallback):
+        * dom/DeviceOrientation.cpp: Added.
+        * dom/DeviceOrientation.h: Added.
+        (WebCore::DeviceOrientation::create):
+        (WebCore::DeviceOrientation::canProvideAlpha):
+        (WebCore::DeviceOrientation::alpha):
+        (WebCore::DeviceOrientation::canProvideBeta):
+        (WebCore::DeviceOrientation::beta):
+        (WebCore::DeviceOrientation::canProvideGamma):
+        (WebCore::DeviceOrientation::gamma):
+        (WebCore::DeviceOrientation::DeviceOrientation):
+        * dom/DeviceOrientationEvent.cpp:
+        (WebCore::DeviceOrientationEvent::DeviceOrientationEvent):
+        (WebCore::DeviceOrientationEvent::initDeviceOrientationEvent):
+        * dom/DeviceOrientationEvent.h:
+        (WebCore::DeviceOrientationEvent::create):
+        (WebCore::DeviceOrientationEvent::orientation):
+        * dom/DeviceOrientationEvent.idl:
+
 2010-07-13  Andreas Kling  <andreas.kling@nokia.com>
 
         Reviewed by Antti Koivisto.
index 278aa9b..8823ad8 100644 (file)
@@ -452,6 +452,7 @@ webcore_sources += \
        WebCore/bindings/js/JSDOMWindowShell.h \
        WebCore/bindings/js/JSDOMWrapper.cpp \
        WebCore/bindings/js/JSDOMWrapper.h \
+       WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp \
        WebCore/bindings/js/JSDocumentCustom.cpp \
        WebCore/bindings/js/JSElementCustom.cpp \
        WebCore/bindings/js/JSEventCustom.cpp \
@@ -800,6 +801,8 @@ webcore_sources += \
        WebCore/dom/DatasetDOMStringMap.h \
        WebCore/dom/DecodedDataDocumentParser.cpp \
        WebCore/dom/DecodedDataDocumentParser.h \
+       WebCore/dom/DeviceOrientation.cpp \
+       WebCore/dom/DeviceOrientation.h \
        WebCore/dom/DeviceOrientationClient.h \
        WebCore/dom/DeviceOrientationController.cpp \
        WebCore/dom/DeviceOrientationController.h \
index 1ccbc3f..32c2f75 100644 (file)
             'bindings/js/JSDedicatedWorkerContextCustom.cpp',
             'bindings/js/JSDebugWrapperSet.cpp',
             'bindings/js/JSDebugWrapperSet.h',
+            'bindings/js/JSDeviceOrientationEventCustom.cpp',
             'bindings/js/JSDocumentCustom.cpp',
             'bindings/js/JSDOMApplicationCacheCustom.cpp',
             'bindings/js/JSDOMBinding.cpp',
             'bindings/v8/custom/V8DatabaseSyncCustom.cpp',
             'bindings/v8/custom/V8DataGridColumnListCustom.cpp',
             'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp',
+            'bindings/v8/custom/V8DeviceOrientationEventCustom.cpp',
             'bindings/v8/custom/V8DocumentLocationCustom.cpp',
             'bindings/v8/custom/V8DOMFormDataCustom.cpp',
             'bindings/v8/custom/V8DOMWindowCustom.cpp',
             'dom/DatasetDOMStringMap.h',
             'dom/DecodedDataDocumentParser.cpp',
             'dom/DecodedDataDocumentParser.h',
+            'dom/DeviceOrientation.cpp',
+            'dom/DeviceOrientation.h',
             'dom/DeviceOrientationClient.h',
             'dom/DeviceOrientationController.cpp',
             'dom/DeviceOrientationController.h',
index 49149dc..16e2e39 100644 (file)
@@ -286,6 +286,7 @@ SOURCES += \
     bindings/js/JSDataGridDataSource.cpp \
     bindings/js/JSDebugWrapperSet.cpp \
     bindings/js/JSDesktopNotificationsCustom.cpp \
+    bindings/js/JSDeviceOrientationEventCustom.cpp \
     bindings/js/JSDocumentCustom.cpp \
     bindings/js/JSDOMFormDataCustom.cpp \
     bindings/js/JSDOMGlobalObject.cpp \
@@ -462,6 +463,7 @@ SOURCES += \
     dom/CSSMappedAttributeDeclaration.cpp \
     dom/CustomEvent.cpp \
     dom/DecodedDataDocumentParser.cpp \
+    dom/DeviceOrientation.cpp \
     dom/DeviceOrientationController.cpp \
     dom/DeviceOrientationEvent.cpp \
     dom/Document.cpp \
@@ -1219,6 +1221,7 @@ HEADERS += \
     dom/CSSMappedAttributeDeclaration.h \
     dom/CustomEvent.h \
     dom/default/PlatformMessagePortChannel.h \
+    dom/DeviceOrientation.h \
     dom/DeviceOrientationClient.h \
     dom/DeviceOrientationController.h \
     dom/DeviceOrientationEvent.h \
index 9106a57..e08d46e 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\dom\DeviceOrientation.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\dom\DeviceOrientation.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\dom\DeviceOrientationClient.h"\r
                                >\r
                        </File>\r
                                        </FileConfiguration>\r
                                </File>\r
                                <File\r
+                                       RelativePath="..\bindings\js\JSDeviceOrientationEventCustom.cpp"\r
+                                       >\r
+                                       <FileConfiguration\r
+                                               Name="Debug|Win32"\r
+                                               ExcludedFromBuild="true"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release|Win32"\r
+                                               ExcludedFromBuild="true"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Debug_Internal|Win32"\r
+                                               ExcludedFromBuild="true"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Debug_Cairo|Win32"\r
+                                               ExcludedFromBuild="true"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Release_Cairo|Win32"\r
+                                               ExcludedFromBuild="true"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                               />\r
+                                       </FileConfiguration>\r
+                                       <FileConfiguration\r
+                                               Name="Debug_All|Win32"\r
+                                               ExcludedFromBuild="true"\r
+                                               >\r
+                                               <Tool\r
+                                                       Name="VCCLCompilerTool"\r
+                                               />\r
+                                       </FileConfiguration>\r
+                               </File>\r
+                               <File\r
                                        RelativePath="..\bindings\js\JSEventCustom.cpp"\r
                                        >\r
                                        <FileConfiguration\r
index 1cd25ec..a978e4e 100644 (file)
                54C50F7B0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54C50F7A0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp */; };
                550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
                550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               590E1B4911E4EF4B0069F784 /* DeviceOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = 590E1B4811E4EF4B0069F784 /* DeviceOrientation.h */; };
+               590E1B4B11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 590E1B4A11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp */; };
                5913953B110758450083EC55 /* JNIBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 5913953A110758450083EC55 /* JNIBridge.h */; };
                5913953D1107584E0083EC55 /* JNIBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5913953C1107584E0083EC55 /* JNIBridge.cpp */; };
                596229781133EFD700DC4CBB /* GeolocationPositionCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */; };
                59B597731108656B007159E8 /* BridgeJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59B597721108656B007159E8 /* BridgeJSC.cpp */; };
                59B5977511086579007159E8 /* BridgeJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59B5977411086579007159E8 /* BridgeJSC.h */; settings = {ATTRIBUTES = (Private, ); }; };
                59BC393F11054A1300FD85DB /* JavaStringJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59BC393E11054A1300FD85DB /* JavaStringJSC.h */; };
+               59D1C10411EB5DCF00B638C8 /* DeviceOrientation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59D1C10311EB5DCF00B638C8 /* DeviceOrientation.cpp */; };
                59E560A71105336600AA1258 /* JavaClassJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59E560A61105336600AA1258 /* JavaClassJSC.h */; };
                59E560A91105336F00AA1258 /* JavaClassJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59E560A81105336F00AA1258 /* JavaClassJSC.cpp */; };
                59E842661109E5A2000305AD /* JNIBridgeJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59E842651109E5A2000305AD /* JNIBridgeJSC.h */; };
                54C50F7A0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLDocumentParserLibxml2.cpp; sourceTree = "<group>"; };
                550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               590E1B4811E4EF4B0069F784 /* DeviceOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientation.h; sourceTree = "<group>"; };
+               590E1B4A11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDeviceOrientationEventCustom.cpp; sourceTree = "<group>"; };
                5913953A110758450083EC55 /* JNIBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JNIBridge.h; sourceTree = "<group>"; };
                5913953C1107584E0083EC55 /* JNIBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JNIBridge.cpp; sourceTree = "<group>"; };
                596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationPositionCache.cpp; sourceTree = "<group>"; };
                59B597721108656B007159E8 /* BridgeJSC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BridgeJSC.cpp; path = bridge/jsc/BridgeJSC.cpp; sourceTree = "<group>"; };
                59B5977411086579007159E8 /* BridgeJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BridgeJSC.h; path = bridge/jsc/BridgeJSC.h; sourceTree = "<group>"; };
                59BC393E11054A1300FD85DB /* JavaStringJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaStringJSC.h; path = jsc/JavaStringJSC.h; sourceTree = "<group>"; };
+               59D1C10311EB5DCF00B638C8 /* DeviceOrientation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceOrientation.cpp; sourceTree = "<group>"; };
                59E560A61105336600AA1258 /* JavaClassJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaClassJSC.h; path = jsc/JavaClassJSC.h; sourceTree = "<group>"; };
                59E560A81105336F00AA1258 /* JavaClassJSC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaClassJSC.cpp; path = jsc/JavaClassJSC.cpp; sourceTree = "<group>"; };
                59E842651109E5A2000305AD /* JNIBridgeJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JNIBridgeJSC.h; path = jsc/JNIBridgeJSC.h; sourceTree = "<group>"; };
                BC4EDEF70C08F414007EDD49 /* Custom */ = {
                        isa = PBXGroup;
                        children = (
+                               590E1B4A11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp */,
                                BC275CB211C5E85C00C9206C /* JSArrayBufferCustom.cpp */,
                                492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */,
                                86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */,
                F523D32402DE4478018635CA /* dom */ = {
                        isa = PBXGroup;
                        children = (
+                               59D1C10311EB5DCF00B638C8 /* DeviceOrientation.cpp */,
+                               590E1B4811E4EF4B0069F784 /* DeviceOrientation.h */,
                                E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */,
                                E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */,
                                A8C4A7FC09D563270003AC8D /* Attr.cpp */,
                                C585A6FA11D4FB3D004C3E4B /* IndexedDatabase.h in Headers */,
                                C585A6FC11D4FB3D004C3E4B /* IndexedDatabaseImpl.h in Headers */,
                                C585A6FE11D4FB3D004C3E4B /* IndexedDatabaseRequest.h in Headers */,
+                               590E1B4911E4EF4B0069F784 /* DeviceOrientation.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                C585A6F911D4FB3D004C3E4B /* IndexedDatabase.cpp in Sources */,
                                C585A6FB11D4FB3D004C3E4B /* IndexedDatabaseImpl.cpp in Sources */,
                                C585A6FD11D4FB3D004C3E4B /* IndexedDatabaseRequest.cpp in Sources */,
+                               590E1B4B11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp in Sources */,
+                               59D1C10411EB5DCF00B638C8 /* DeviceOrientation.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 373c0e0..b517496 100644 (file)
@@ -62,6 +62,7 @@
 #include "JSDebugWrapperSet.cpp"
 #include "JSDedicatedWorkerContextCustom.cpp"
 #include "JSDesktopNotificationsCustom.cpp"
+#include "JSDeviceOrientationEventCustom.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSElementCustom.cpp"
 #include "JSEventCustom.cpp"
diff --git a/WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp b/WebCore/bindings/js/JSDeviceOrientationEventCustom.cpp
new file mode 100644 (file)
index 0000000..05f8755
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDeviceOrientationEvent.h"
+
+#if ENABLE(DEVICE_ORIENTATION)
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationEvent.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSDeviceOrientationEvent::alpha(ExecState* exec) const
+{
+    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
+    if (!imp->orientation()->canProvideAlpha())
+        return jsNull();
+    return jsNumber(exec, imp->orientation()->alpha());
+}
+
+JSValue JSDeviceOrientationEvent::beta(ExecState* exec) const
+{
+    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
+    if (!imp->orientation()->canProvideBeta())
+        return jsNull();
+    return jsNumber(exec, imp->orientation()->beta());
+}
+
+JSValue JSDeviceOrientationEvent::gamma(ExecState* exec) const
+{
+    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
+    if (!imp->orientation()->canProvideGamma())
+        return jsNull();
+    return jsNumber(exec, imp->orientation()->gamma());
+}
+
+JSValue JSDeviceOrientationEvent::initDeviceOrientationEvent(ExecState* exec)
+{
+    const String& type = ustringToString(exec->argument(0).toString(exec));
+    bool bubbles = exec->argument(1).toBoolean(exec);
+    bool cancelable = exec->argument(2).toBoolean(exec);
+    // If alpha, beta or gamma are null or undefined, mark them as not provided.
+    // Otherwise, use the standard JavaScript conversion.
+    bool alphaProvided = !exec->argument(3).isUndefinedOrNull();
+    double alpha = exec->argument(3).toNumber(exec);
+    bool betaProvided = !exec->argument(4).isUndefinedOrNull();
+    double beta = exec->argument(4).toNumber(exec);
+    bool gammaProvided = !exec->argument(5).isUndefinedOrNull();
+    double gamma = exec->argument(5).toNumber(exec);
+    RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma);
+    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
+    imp->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
+    return jsUndefined();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DEVICE_ORIENTATION)
diff --git a/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp b/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp
new file mode 100644 (file)
index 0000000..26cc6cc
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8DeviceOrientationEvent.h"
+
+#if ENABLE(DEVICE_ORIENTATION)
+
+#include "DeviceOrientation.h"
+#include "V8Binding.h"
+#include "V8Proxy.h"
+
+#include <v8.h>
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8DeviceOrientationEvent::alphaAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+    INC_STATS("DOM.DeviceOrientationEvent.alpha._get");
+    v8::Handle<v8::Object> holder = info.Holder();
+    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
+    if (!imp->orientation()->canProvideAlpha())
+        return v8::Null();
+    return v8::Number::New(imp->orientation()->alpha());
+}
+
+v8::Handle<v8::Value> V8DeviceOrientationEvent::betaAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+    INC_STATS("DOM.DeviceOrientationEvent.beta._get");
+    v8::Handle<v8::Object> holder = info.Holder();
+    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
+    if (!imp->orientation()->canProvideBeta())
+        return v8::Null();
+    return v8::Number::New(imp->orientation()->beta());
+}
+
+v8::Handle<v8::Value> V8DeviceOrientationEvent::gammaAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+    INC_STATS("DOM.DeviceOrientationEvent.gamma._get");
+    v8::Handle<v8::Object> holder = info.Holder();
+    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
+    if (!imp->orientation()->canProvideGamma())
+        return v8::Null();
+    return v8::Number::New(imp->orientation()->gamma());
+}
+
+v8::Handle<v8::Value> V8DeviceOrientationEvent::initDeviceOrientationEventCallback(const v8::Arguments& args)
+{
+    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(args.Holder());
+    V8Parameter<> type = args[0];
+    bool bubbles = args[1]->BooleanValue();
+    bool cancelable = args[2]->BooleanValue();
+    // If alpha, beta or gamma are null or undefined, mark them as not provided.
+    // Otherwise, use the standard JavaScript conversion.
+    bool alphaProvided = !isUndefinedOrNull(args[3]);
+    double alpha = static_cast<double>(args[3]->NumberValue());
+    bool betaProvided = !isUndefinedOrNull(args[4]);
+    double beta = static_cast<double>(args[4]->NumberValue());
+    bool gammaProvided = !isUndefinedOrNull(args[5]);
+    double gamma = static_cast<double>(args[5]->NumberValue());
+    RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma);
+    imp->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
+    return v8::Handle<v8::Value>();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DEVICE_ORIENTATION)
diff --git a/WebCore/dom/DeviceOrientation.cpp b/WebCore/dom/DeviceOrientation.cpp
new file mode 100644 (file)
index 0000000..f1c28b1
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DeviceOrientation.h"
+
+namespace WebCore {
+
+PassRefPtr<DeviceOrientation> DeviceOrientation::create()
+{
+    return adoptRef(new DeviceOrientation);
+}
+
+PassRefPtr<DeviceOrientation> DeviceOrientation::create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
+{
+    return adoptRef(new DeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma));
+}
+
+
+DeviceOrientation::DeviceOrientation()
+    : m_canProvideAlpha(false)
+    , m_canProvideBeta(false)
+    , m_canProvideGamma(false)
+{
+}
+
+DeviceOrientation::DeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
+    : m_canProvideAlpha(canProvideAlpha)
+    , m_canProvideBeta(canProvideBeta)
+    , m_canProvideGamma(canProvideGamma)
+    , m_alpha(alpha)
+    , m_beta(beta)
+    , m_gamma(gamma)
+{
+}
+
+double DeviceOrientation::alpha() const
+{
+    return m_alpha;
+}
+
+double DeviceOrientation::beta() const
+{
+    return m_beta;
+}
+
+double DeviceOrientation::gamma() const
+{
+    return m_gamma;
+}
+
+bool DeviceOrientation::canProvideAlpha() const
+{
+    return m_canProvideAlpha;
+}
+
+bool DeviceOrientation::canProvideBeta() const
+{
+    return m_canProvideBeta;
+}
+
+bool DeviceOrientation::canProvideGamma() const
+{
+    return m_canProvideGamma;
+}
+
+} // namespace WebCore
diff --git a/WebCore/dom/DeviceOrientation.h b/WebCore/dom/DeviceOrientation.h
new file mode 100644 (file)
index 0000000..c652736
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DeviceOrientation_h
+#define DeviceOrientation_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class DeviceOrientation : public RefCounted<DeviceOrientation> {
+public:
+    static PassRefPtr<DeviceOrientation> create();
+    static PassRefPtr<DeviceOrientation> create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
+
+    double alpha() const;
+    double beta() const;
+    double gamma() const;
+    bool canProvideAlpha() const;
+    bool canProvideBeta() const;
+    bool canProvideGamma() const;
+
+private:
+    DeviceOrientation();
+    DeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
+
+    bool m_canProvideAlpha;
+    bool m_canProvideBeta;
+    bool m_canProvideGamma;
+    double m_alpha;
+    double m_beta;
+    double m_gamma;
+};
+
+} // namespace WebCore
+
+#endif // DeviceOrientation_h
index b1aae65..8a75226 100644 (file)
 #include "config.h"
 #include "DeviceOrientationEvent.h"
 
+#include "DeviceOrientation.h"
+
 #if ENABLE(DEVICE_ORIENTATION)
 
 namespace WebCore {
 
 DeviceOrientationEvent::DeviceOrientationEvent()
-    : m_alpha(0)
-    , m_beta(0)
-    , m_gamma(0)
+    : m_orientation(DeviceOrientation::create())
 {
 }
 
-DeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, double alpha, double beta, double gamma)
+DeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientation* orientation)
     : Event(eventType, false, false) // Can't bubble, not cancelable
-    , m_alpha(alpha)
-    , m_beta(beta)
-    , m_gamma(gamma)
+    , m_orientation(orientation)
 {
 }
 
-void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& eventType, bool canBubble, bool cancelable, double alpha, double beta, double gamma)
+void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientation* orientation)
 {
     if (dispatched())
         return;
 
-    initEvent(eventType, canBubble, cancelable);
-
-    m_alpha = alpha;
-    m_beta = beta;
-    m_gamma = gamma;
+    initEvent(type, bubbles, cancelable);
+    m_orientation = orientation;
 }
 
 } // namespace WebCore
index 33ff026..604b35f 100644 (file)
 
 namespace WebCore {
 
+class DeviceOrientation;
+
 class DeviceOrientationEvent : public Event {
 public:
     static PassRefPtr<DeviceOrientationEvent> create()
     {
         return adoptRef(new DeviceOrientationEvent);
     }
-    static PassRefPtr<DeviceOrientationEvent> create(const AtomicString& eventType, double alpha, double beta, double gamma)
+    static PassRefPtr<DeviceOrientationEvent> create(const AtomicString& eventType, DeviceOrientation* orientation)
     {
-        return adoptRef(new DeviceOrientationEvent(eventType, alpha, beta, gamma));
+        return adoptRef(new DeviceOrientationEvent(eventType, orientation));
     }
 
-    void initDeviceOrientationEvent(const AtomicString& eventType, bool canBubble, bool cancelable, double alpha, double beta, double gamma);
-    double alpha() const { return m_alpha; }
-    double beta() const { return m_beta; }
-    double gamma() const { return m_gamma; }
+    void initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientation*);
 
     virtual bool isDeviceOrientationEvent() const { return true; }
 
+    DeviceOrientation* orientation() const { return m_orientation.get(); }
+
 private:
     DeviceOrientationEvent();
-    DeviceOrientationEvent(const AtomicString& eventType, double alpha, double beta, double gamma);
+    DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientation*);
 
-    double m_alpha;
-    double m_beta;
-    double m_gamma;
+    RefPtr<DeviceOrientation> m_orientation;
 };
 
 } // namespace WebCore
index 95d96ec..5582f0d 100644 (file)
@@ -28,10 +28,10 @@ module core {
     interface [
         Conditional=DEVICE_ORIENTATION
     ] DeviceOrientationEvent : Event {
-        readonly attribute double alpha;
-        readonly attribute double beta;
-        readonly attribute double gamma;
-        void initDeviceOrientationEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in double alpha, in double beta, in double gamma);
+        readonly attribute [Custom] double alpha;
+        readonly attribute [Custom] double beta;
+        readonly attribute [Custom] double gamma;
+        [Custom] void initDeviceOrientationEvent(in DOMString type, in boolean bubbles, in boolean cancelable, in double alpha, in double beta, in double gamma);
     };
 
 }