JavaScriptCore:
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Oct 2008 20:10:40 +0000 (20:10 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Oct 2008 20:10:40 +0000 (20:10 +0000)
2008-10-24  Greg Bolsinga  <bolsinga@apple.com>

        Reviewed by Sam Weinig.

        https://bugs.webkit.org/show_bug.cgi?id=21475

        Provide support for the Geolocation API

        http://dev.w3.org/geo/api/spec-source.html

        * wtf/Platform.h: ENABLE_GEOLOCATION defaults to 0

WebCore:

2008-10-24  Greg Bolsinga  <bolsinga@apple.com>

        Reviewed by Sam Weinig.

        https://bugs.webkit.org/show_bug.cgi?id=21475

        Provide support for the Geolocation API

        http://dev.w3.org/geo/api/spec-source.html

        Test: geolocation/geolocation-not-implemented.html

        * DerivedSources.make:
        * GNUmakefile.am: Added Geolocation support
        * WebCore.pro: Added Geolocation support
        * WebCore.vcproj/WebCore.vcproj: Added Geolocation support
        * WebCore.xcodeproj/project.pbxproj: Added Geolocation support
        * WebCoreSources.bkl: Added Geolocation support
        * bindings/js/JSCustomPositionCallback.cpp: Added.
        (WebCore::JSCustomPositionCallback::JSCustomPositionCallback):
        (WebCore::JSCustomPositionCallback::handleEvent):
        * bindings/js/JSCustomPositionCallback.h: Added.
        (WebCore::JSCustomPositionCallback::create):
        * bindings/js/JSCustomPositionErrorCallback.cpp: Added.
        (WebCore::JSCustomPositionErrorCallback::JSCustomPositionErrorCallback):
        (WebCore::JSCustomPositionErrorCallback::handleEvent):
        * bindings/js/JSCustomPositionErrorCallback.h: Added.
        (WebCore::JSCustomPositionErrorCallback::create):
        * bindings/js/JSDOMBinding.cpp: move markDOMObjectWrapper here from JSDOMWindowCustom
        (WebCore::markDOMObjectWrapper):
        * bindings/js/JSDOMBinding.h: move markDOMObjectWrapper here from JSDOMWindowCustom
        * bindings/js/JSDOMWindowCustom.cpp: move markDOMObjectWrapper to JSDOMBinding
        * bindings/js/JSGeolocationCustom.cpp: Added.
        (WebCore::JSGeolocation::getCurrentPosition):
        (WebCore::JSGeolocation::watchPosition):
        * bindings/js/JSNavigatorCustom.cpp: handle marking Geolocation
        (WebCore::JSNavigator::mark):
        * dom/Document.cpp:
        (WebCore::Document::Document):
        * dom/Document.h:
        (WebCore::Document::setUsingGeolocation):
        (WebCore::Document::usingGeolocation):
        * loader/FrameLoader.cpp: don't add to back forward cache if using Geolocation
        (WebCore::FrameLoader::canCachePage):
        * page/Geolocation.cpp: Added.
        (WebCore::Geolocation::GeoNotifier::GeoNotifier):
        (WebCore::Geolocation::GeoNotifier::timerFired):
        (WebCore::Geolocation::Geolocation):
        (WebCore::Geolocation::disconnectFrame):
        (WebCore::Geolocation::getCurrentPosition):
        (WebCore::Geolocation::watchPosition):
        (WebCore::Geolocation::clearWatch):
        (WebCore::Geolocation::stopUpdatingIfEmpty):
        (WebCore::Geolocation::sendErrorToOneShots):
        (WebCore::Geolocation::sendErrorToWatchers):
        (WebCore::Geolocation::sendPositionToOneShots):
        (WebCore::Geolocation::sendPositionToWatchers):
        (WebCore::Geolocation::handleError):
        (WebCore::Geolocation::geolocationServicePositionChanged):
        (WebCore::Geolocation::geolocationServiceErrorOccurred):
        * page/Geolocation.h: Added.
        (WebCore::Geolocation::create):
        (WebCore::Geolocation::~Geolocation):
        (WebCore::Geolocation::lastPosition):
        (WebCore::Geolocation::GeoNotifier::create):
        * page/Geolocation.idl: Added.
        * page/Geoposition.cpp: Added.
        (WebCore::Geoposition::toString):
        * page/Geoposition.h: Added.
        (WebCore::Geoposition::create):
        (WebCore::Geoposition::latitude):
        (WebCore::Geoposition::longitude):
        (WebCore::Geoposition::altitude):
        (WebCore::Geoposition::accuracy):
        (WebCore::Geoposition::altitudeAccuracy):
        (WebCore::Geoposition::heading):
        (WebCore::Geoposition::velocity):
        (WebCore::Geoposition::timestamp):
        (WebCore::Geoposition::Geoposition):
        * page/Geoposition.idl: Added.
        * page/Navigator.cpp:
        (WebCore::Navigator::disconnectFrame): disconnect Geolocation
        (WebCore::Navigator::geolocation): accessor for Geolocation
        * page/Navigator.h:
        (WebCore::Navigator::optionalGeolocation): accessor for Geolocation
        * page/Navigator.idl: accessor for Geolocation
        * page/PositionCallback.h: Added.
        (WebCore::PositionCallback::~PositionCallback):
        * page/PositionCallback.idl: Added.
        * page/PositionError.h: Added.
        (WebCore::PositionError::):
        (WebCore::PositionError::create):
        (WebCore::PositionError::code):
        (WebCore::PositionError::message):
        (WebCore::PositionError::PositionError):
        * page/PositionError.idl: Added.
        * page/PositionErrorCallback.h: Added.
        (WebCore::PositionErrorCallback::~PositionErrorCallback):
        * page/PositionErrorCallback.idl: Added.
        * page/PositionOptions.h: Added.
        (WebCore::PositionOptions::create):
        (WebCore::PositionOptions::enableHighAccuracy):
        (WebCore::PositionOptions::setEnableHighAccuracy):
        (WebCore::PositionOptions::timeout):
        (WebCore::PositionOptions::setTimeout):
        (WebCore::PositionOptions::PositionOptions):
        * page/PositionOptions.idl: Added.
        * platform/GeolocationService.cpp: Added.
        (WebCore::GeolocationService::GeolocationService):
        (WebCore::GeolocationService::positionChanged):
        (WebCore::GeolocationService::errorOccurred):
        * platform/GeolocationService.h: Added.
        (WebCore::GeolocationServiceClient::~GeolocationServiceClient):
        (WebCore::GeolocationServiceClient::geolocationServicePositionChanged):
        (WebCore::GeolocationServiceClient::geolocationServiceErrorOccurred):
        (WebCore::GeolocationService::~GeolocationService):

LayoutTests:

2008-10-24  Greg Bolsinga  <bolsinga@apple.com>

        Reviewed by Sam Weinig.

        https://bugs.webkit.org/show_bug.cgi?id=21475

        Provide support for the Geolocation API

        http://dev.w3.org/geo/api/spec-source.html

        Tests to verify Geolocation isn't implemented (so that it didn't leak into
        WebCore for platforms that do not support it).

        * geolocation: Added.
        * geolocation/geolocation-not-implemented-expected.txt: Added.
        * geolocation/geolocation-not-implemented.html: Added.
        * geolocation/geolocation-test.js: Copied from LayoutTests/media/video-test.js.
        (reset):
        (hanged):
        (watchPositionAndEnd):
        (watchPosition._positionCallback):
        (watchPosition):
        (watchPositionTestAndEnd):
        (watchPositionAndFail):
        (watchPositionAndTest._positionCallback):
        (watchPositionAndTest):
        (getCurrentPositionAndEnd):
        (getCurrentPosition._positionCallback):
        (getCurrentPosition):
        (getCurrentPositionTestAndEnd):
        (getCurrentPositionAndFail):
        (getCurrentPositionAndTest._positionCallback):
        (getCurrentPositionAndTest):
        (endTest):
        (relativeURL):

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

44 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/wtf/Platform.h
LayoutTests/ChangeLog
LayoutTests/geolocation/geolocation-not-implemented-expected.txt [new file with mode: 0644]
LayoutTests/geolocation/geolocation-not-implemented.html [new file with mode: 0644]
LayoutTests/geolocation/geolocation-test.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/bindings/js/JSCustomPositionCallback.cpp [new file with mode: 0644]
WebCore/bindings/js/JSCustomPositionCallback.h [new file with mode: 0644]
WebCore/bindings/js/JSCustomPositionErrorCallback.cpp [new file with mode: 0644]
WebCore/bindings/js/JSCustomPositionErrorCallback.h [new file with mode: 0644]
WebCore/bindings/js/JSDOMBinding.cpp
WebCore/bindings/js/JSDOMBinding.h
WebCore/bindings/js/JSDOMWindowCustom.cpp
WebCore/bindings/js/JSGeolocationCustom.cpp [new file with mode: 0644]
WebCore/bindings/js/JSNavigatorCustom.cpp
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/loader/FrameLoader.cpp
WebCore/page/Geolocation.cpp [new file with mode: 0644]
WebCore/page/Geolocation.h [new file with mode: 0644]
WebCore/page/Geolocation.idl [new file with mode: 0644]
WebCore/page/Geoposition.cpp [new file with mode: 0644]
WebCore/page/Geoposition.h [new file with mode: 0644]
WebCore/page/Geoposition.idl [new file with mode: 0644]
WebCore/page/Navigator.cpp
WebCore/page/Navigator.h
WebCore/page/Navigator.idl
WebCore/page/PositionCallback.h [new file with mode: 0644]
WebCore/page/PositionCallback.idl [new file with mode: 0644]
WebCore/page/PositionError.h [new file with mode: 0644]
WebCore/page/PositionError.idl [new file with mode: 0644]
WebCore/page/PositionErrorCallback.h [new file with mode: 0644]
WebCore/page/PositionErrorCallback.idl [new file with mode: 0644]
WebCore/page/PositionOptions.h [new file with mode: 0644]
WebCore/page/PositionOptions.idl [new file with mode: 0644]
WebCore/platform/GeolocationService.cpp [new file with mode: 0644]
WebCore/platform/GeolocationService.h [new file with mode: 0644]

index 1d4d72b..d843fc6 100644 (file)
@@ -1,3 +1,15 @@
+2008-10-24  Greg Bolsinga  <bolsinga@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=21475
+        
+        Provide support for the Geolocation API
+        
+        http://dev.w3.org/geo/api/spec-source.html
+
+        * wtf/Platform.h: ENABLE_GEOLOCATION defaults to 0
+
 2008-10-24  Darin Adler  <darin@apple.com>
 
         - finish rolling out https://bugs.webkit.org/show_bug.cgi?id=21732
index 884db0b..115019b 100644 (file)
 #define ENABLE_SAMPLING_TOOL 0
 #endif
 
+#if !defined(ENABLE_GEOLOCATION)
+#define ENABLE_GEOLOCATION 0
+#endif
+
 // CTI only supports x86 at the moment, and has only been tested on Mac and Windows.
 #if !defined(ENABLE_CTI) && PLATFORM(X86) && (PLATFORM(MAC) || PLATFORM(WIN))
 #define ENABLE_CTI 1
index 07834f6..7c9fd1a 100644 (file)
@@ -1,3 +1,39 @@
+2008-10-24  Greg Bolsinga  <bolsinga@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=21475
+        
+        Provide support for the Geolocation API
+        
+        http://dev.w3.org/geo/api/spec-source.html
+
+        Tests to verify Geolocation isn't implemented (so that it didn't leak into 
+        WebCore for platforms that do not support it).
+
+        * geolocation: Added.
+        * geolocation/geolocation-not-implemented-expected.txt: Added.
+        * geolocation/geolocation-not-implemented.html: Added.
+        * geolocation/geolocation-test.js: Copied from LayoutTests/media/video-test.js.
+        (reset):
+        (hanged):
+        (watchPositionAndEnd):
+        (watchPosition._positionCallback):
+        (watchPosition):
+        (watchPositionTestAndEnd):
+        (watchPositionAndFail):
+        (watchPositionAndTest._positionCallback):
+        (watchPositionAndTest):
+        (getCurrentPositionAndEnd):
+        (getCurrentPosition._positionCallback):
+        (getCurrentPosition):
+        (getCurrentPositionTestAndEnd):
+        (getCurrentPositionAndFail):
+        (getCurrentPositionAndTest._positionCallback):
+        (getCurrentPositionAndTest):
+        (endTest):
+        (relativeURL):
+
 2008-10-24  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Darin Adler
diff --git a/LayoutTests/geolocation/geolocation-not-implemented-expected.txt b/LayoutTests/geolocation/geolocation-not-implemented-expected.txt
new file mode 100644 (file)
index 0000000..8096eac
--- /dev/null
@@ -0,0 +1,7 @@
+TEST(navigator.geolocation === undefined) OK
+TEST(navigator.geolocation == null) OK
+TEST(hasGeolocationProperty == false) OK
+TEST('geolocation' in navigator == false) OK
+TEST(navigator.hasOwnProperty('geolocation') == false) OK
+END OF TEST
+
diff --git a/LayoutTests/geolocation/geolocation-not-implemented.html b/LayoutTests/geolocation/geolocation-not-implemented.html
new file mode 100644 (file)
index 0000000..f007070
--- /dev/null
@@ -0,0 +1,16 @@
+<body></body>
+<script src=geolocation-test.js></script>
+<script>
+test("navigator.geolocation === undefined");
+test("navigator.geolocation == null");
+var hasGeolocationProperty = false;
+for (var property in navigator) {
+    hasGeolocationProperty = (property == "geolocation");
+    if (hasGeolocationProperty)
+        break;
+}
+test("hasGeolocationProperty == false");
+test("'geolocation' in navigator == false");
+test("navigator.hasOwnProperty('geolocation') == false");
+endTest();
+</script>
diff --git a/LayoutTests/geolocation/geolocation-test.js b/LayoutTests/geolocation/geolocation-test.js
new file mode 100644 (file)
index 0000000..09c152d
--- /dev/null
@@ -0,0 +1,218 @@
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+var watchID = -1;
+var passedPosition = null;
+var console = document.createElement('div');
+document.body.appendChild(console);
+
+function reset()
+{
+    if (window.layoutTestController) {
+        layoutTestController.notifyDone();  
+        watchID = -1;
+        passedPosition = null;
+    }
+}
+
+function hanged()
+{
+    consoleWrite("FAIL: timed out");
+    reset();
+}
+setTimeout(hanged, 10000);
+
+function testAndEnd(testFuncString)
+{
+    test(testFuncString, true);
+}
+
+function test(testFuncString, endit)
+{
+    if (eval(testFuncString))
+        consoleWrite("TEST(" + testFuncString + ") <span style='color:green'>OK</span>");
+    else
+        consoleWrite("TEST(" + testFuncString + ") <span style='color:red'>FAIL</span>");    
+
+    if (endit)
+        endTest();  
+}
+
+function testExpected(testFuncString, expected)
+{
+    try {
+        var observed = eval(testFuncString);
+    } catch (ex) {
+        consoleWrite(ex);
+        return;
+    }
+    
+    var msg = "expected " + testFuncString + "=='" + expected + "', observed '" + observed + "'";
+
+    if (observed == expected)
+        consoleWrite(msg + " - <span style='color:green'>OK</span>");
+    else
+        consoleWrite(msg + " - <span style='color:red'>FAIL</span>");
+}
+
+function run(testFuncString)
+{
+    consoleWrite("RUN(" + testFuncString + ")");
+    try {
+        eval(testFuncString);
+    } catch (ex) {
+        consoleWrite(ex);
+    }
+}
+
+function watchPositionAndEnd(funcString)
+{
+    watchPosition(funcString, true)
+}
+
+function watchPosition(func, endit)
+{
+    function _positionCallback(position)
+    {        
+        passedPosition = position;
+        test("passedPosition == navigator.geolocation.lastPosition");
+        
+        consoleWrite("POSITION(" + position + ")");
+        
+        if (func)
+            func();
+        
+        if (endit)
+            endTest();    
+    }
+    
+    watchID = navigator.geolocation.watchPosition(_positionCallback);
+    test("watchID > 0");
+}
+
+function watchPositionTestAndEnd(testFuncString)
+{
+    watchPositionAndTest(testFuncString, true);
+}
+
+function watchPositionAndFail()
+{
+    watchPositionAndTest("false", true);
+}
+
+function watchPositionAndTest(testFuncString, endit)
+{
+    function _positionCallback(position)
+    {
+        passedPosition = position;
+        
+        if (eval(testFuncString))
+            consoleWrite("POSITION(" + position + ") TEST(" + testFuncString + ") <span style='color:green'>OK</span>");
+        else
+            consoleWrite("POSITION(" + position + ") TEST(" + testFuncString + ") <span style='color:red'>FAIL</span>");
+
+        if (endit)
+            endTest();    
+    }
+    
+    watchID = navigator.geolocation.watchPosition(_positionCallback);
+    test("watchID > 0");
+}
+
+function getCurrentPositionAndEnd(funcString)
+{
+    getCurrentPosition(funcString, true)
+}
+
+function getCurrentPosition(func, endit)
+{
+    function _positionCallback(position)
+    {        
+        passedPosition = position;
+        
+        consoleWrite("POSITION(" + position + ")");
+        
+        if (func)
+            func();
+        
+        if (endit)
+            endTest();    
+    }
+    
+    navigator.geolocation.getCurrentPosition(_positionCallback);
+}
+
+function getCurrentPositionTestAndEnd(testFuncString)
+{
+    getCurrentPositionAndTest(testFuncString, true);
+}
+
+function getCurrentPositionAndFail()
+{
+    getCurrentPositionAndTest("false", true);
+}
+
+function getCurrentPositionAndTest(testFuncString, endit)
+{
+    function _positionCallback(position)
+    {
+        passedPosition = position;
+        
+        if (eval(testFuncString))
+            consoleWrite("POSITION(" + position + ") TEST(" + testFuncString + ") <span style='color:green'>OK</span>");
+        else
+            consoleWrite("POSITION(" + position + ") TEST(" + testFuncString + ") <span style='color:red'>FAIL</span>");
+        
+        if (endit)
+            endTest();    
+    }
+    
+    navigator.geolocation.getCurrentPosition(_positionCallback);
+}
+
+function testException(testString, exceptionString)
+{
+    try {
+        eval(testString);
+    } catch (ex) { 
+        if (ex.code == eval(exceptionString))
+            consoleWrite("TEST(" + testString + ") THROWS("+exceptionString+") <span style='color:green'>OK</span>");
+        else
+            consoleWrite("TEST(" + testString + ") THROWS("+exceptionString+") <span style='color:red'>FAIL</span>");    
+    }
+}
+
+var testEnded = false;
+
+function endTest()
+{
+    consoleWrite("END OF TEST");
+    testEnded = true;
+    reset();
+}
+
+function endTestLater()
+{
+    setTimeout(endTest, 250);
+}
+
+function failTestIn(ms)
+{
+    setTimeout(function () {
+        consoleWrite("FAIL: did not end fast enough");
+        endTest();
+    }, ms);
+}
+
+function consoleWrite(text)
+{
+    if (testEnded)
+        return;
+    console.innerHTML += text + "<br>";
+}
+
+function relativeURL(url)
+{
+    return url.substr(url.indexOf('/geolocation/')+13);
+}
\ No newline at end of file
index 38692e2..13d8f62 100644 (file)
@@ -1,3 +1,120 @@
+2008-10-24  Greg Bolsinga  <bolsinga@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=21475
+        
+        Provide support for the Geolocation API
+        
+        http://dev.w3.org/geo/api/spec-source.html
+
+        Test: geolocation/geolocation-not-implemented.html
+
+        * DerivedSources.make:
+        * GNUmakefile.am: Added Geolocation support
+        * WebCore.pro: Added Geolocation support
+        * WebCore.vcproj/WebCore.vcproj: Added Geolocation support
+        * WebCore.xcodeproj/project.pbxproj: Added Geolocation support
+        * WebCoreSources.bkl: Added Geolocation support
+        * bindings/js/JSCustomPositionCallback.cpp: Added.
+        (WebCore::JSCustomPositionCallback::JSCustomPositionCallback):
+        (WebCore::JSCustomPositionCallback::handleEvent):
+        * bindings/js/JSCustomPositionCallback.h: Added.
+        (WebCore::JSCustomPositionCallback::create):
+        * bindings/js/JSCustomPositionErrorCallback.cpp: Added.
+        (WebCore::JSCustomPositionErrorCallback::JSCustomPositionErrorCallback):
+        (WebCore::JSCustomPositionErrorCallback::handleEvent):
+        * bindings/js/JSCustomPositionErrorCallback.h: Added.
+        (WebCore::JSCustomPositionErrorCallback::create):
+        * bindings/js/JSDOMBinding.cpp: move markDOMObjectWrapper here from JSDOMWindowCustom
+        (WebCore::markDOMObjectWrapper):
+        * bindings/js/JSDOMBinding.h: move markDOMObjectWrapper here from JSDOMWindowCustom
+        * bindings/js/JSDOMWindowCustom.cpp: move markDOMObjectWrapper to JSDOMBinding
+        * bindings/js/JSGeolocationCustom.cpp: Added.
+        (WebCore::JSGeolocation::getCurrentPosition):
+        (WebCore::JSGeolocation::watchPosition):
+        * bindings/js/JSNavigatorCustom.cpp: handle marking Geolocation
+        (WebCore::JSNavigator::mark):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        * dom/Document.h:
+        (WebCore::Document::setUsingGeolocation):
+        (WebCore::Document::usingGeolocation):
+        * loader/FrameLoader.cpp: don't add to back forward cache if using Geolocation
+        (WebCore::FrameLoader::canCachePage):
+        * page/Geolocation.cpp: Added.
+        (WebCore::Geolocation::GeoNotifier::GeoNotifier):
+        (WebCore::Geolocation::GeoNotifier::timerFired):
+        (WebCore::Geolocation::Geolocation):
+        (WebCore::Geolocation::disconnectFrame):
+        (WebCore::Geolocation::getCurrentPosition):
+        (WebCore::Geolocation::watchPosition):
+        (WebCore::Geolocation::clearWatch):
+        (WebCore::Geolocation::stopUpdatingIfEmpty):
+        (WebCore::Geolocation::sendErrorToOneShots):
+        (WebCore::Geolocation::sendErrorToWatchers):
+        (WebCore::Geolocation::sendPositionToOneShots):
+        (WebCore::Geolocation::sendPositionToWatchers):
+        (WebCore::Geolocation::handleError):
+        (WebCore::Geolocation::geolocationServicePositionChanged):
+        (WebCore::Geolocation::geolocationServiceErrorOccurred):
+        * page/Geolocation.h: Added.
+        (WebCore::Geolocation::create):
+        (WebCore::Geolocation::~Geolocation):
+        (WebCore::Geolocation::lastPosition):
+        (WebCore::Geolocation::GeoNotifier::create):
+        * page/Geolocation.idl: Added.
+        * page/Geoposition.cpp: Added.
+        (WebCore::Geoposition::toString):
+        * page/Geoposition.h: Added.
+        (WebCore::Geoposition::create):
+        (WebCore::Geoposition::latitude):
+        (WebCore::Geoposition::longitude):
+        (WebCore::Geoposition::altitude):
+        (WebCore::Geoposition::accuracy):
+        (WebCore::Geoposition::altitudeAccuracy):
+        (WebCore::Geoposition::heading):
+        (WebCore::Geoposition::velocity):
+        (WebCore::Geoposition::timestamp):
+        (WebCore::Geoposition::Geoposition):
+        * page/Geoposition.idl: Added.
+        * page/Navigator.cpp:
+        (WebCore::Navigator::disconnectFrame): disconnect Geolocation
+        (WebCore::Navigator::geolocation): accessor for Geolocation
+        * page/Navigator.h:
+        (WebCore::Navigator::optionalGeolocation): accessor for Geolocation
+        * page/Navigator.idl: accessor for Geolocation
+        * page/PositionCallback.h: Added.
+        (WebCore::PositionCallback::~PositionCallback):
+        * page/PositionCallback.idl: Added.
+        * page/PositionError.h: Added.
+        (WebCore::PositionError::):
+        (WebCore::PositionError::create):
+        (WebCore::PositionError::code):
+        (WebCore::PositionError::message):
+        (WebCore::PositionError::PositionError):
+        * page/PositionError.idl: Added.
+        * page/PositionErrorCallback.h: Added.
+        (WebCore::PositionErrorCallback::~PositionErrorCallback):
+        * page/PositionErrorCallback.idl: Added.
+        * page/PositionOptions.h: Added.
+        (WebCore::PositionOptions::create):
+        (WebCore::PositionOptions::enableHighAccuracy):
+        (WebCore::PositionOptions::setEnableHighAccuracy):
+        (WebCore::PositionOptions::timeout):
+        (WebCore::PositionOptions::setTimeout):
+        (WebCore::PositionOptions::PositionOptions):
+        * page/PositionOptions.idl: Added.
+        * platform/GeolocationService.cpp: Added.
+        (WebCore::GeolocationService::GeolocationService):
+        (WebCore::GeolocationService::positionChanged):
+        (WebCore::GeolocationService::errorOccurred):
+        * platform/GeolocationService.h: Added.
+        (WebCore::GeolocationServiceClient::~GeolocationServiceClient):
+        (WebCore::GeolocationServiceClient::geolocationServicePositionChanged):
+        (WebCore::GeolocationServiceClient::geolocationServiceErrorOccurred):
+        (WebCore::GeolocationService::~GeolocationService):
+
 2008-10-24  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Darin Adler
index a7febfd..cd9accd 100644 (file)
@@ -93,6 +93,8 @@ DOM_CLASSES = \
     EventTargetNode \
     File \
     FileList \
+    Geolocation \
+    Geoposition \
     HTMLAnchorElement \
     HTMLAppletElement \
     HTMLAreaElement \
@@ -180,6 +182,10 @@ DOM_CLASSES = \
     OverflowEvent \
     Plugin \
     PluginArray \
+    PositionCallback \
+    PositionError \
+    PositionErrorCallback \
+    PositionOptions \
     ProcessingInstruction \
     ProgressEvent \
     RGBColor \
index 989e7be..d71834c 100644 (file)
@@ -209,9 +209,15 @@ IDL_BINDINGS += \
        WebCore/page/Console.idl \
        WebCore/page/DOMSelection.idl \
        WebCore/page/DOMWindow.idl \
+       WebCore/page/Geolocation.idl \
+       WebCore/page/Geoposition.idl \
        WebCore/page/History.idl \
        WebCore/page/Location.idl \
        WebCore/page/Navigator.idl \
+       WebCore/page/PositionCallback.idl \
+       WebCore/page/PositionError.idl \
+       WebCore/page/PositionErrorCallback.idl \
+       WebCore/page/PositionOptions.idl \
        WebCore/page/Screen.idl \
        WebCore/plugins/MimeType.idl \
        WebCore/plugins/MimeTypeArray.idl \
@@ -325,6 +331,10 @@ webcore_sources += \
        WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp \
        WebCore/bindings/js/JSClipboardCustom.cpp \
        WebCore/bindings/js/JSConsoleCustom.cpp \
+       WebCore/bindings/js/JSCustomPositionCallback.cpp \
+       WebCore/bindings/js/JSCustomPositionCallback.h \
+       WebCore/bindings/js/JSCustomPositionErrorCallback.cpp \
+       WebCore/bindings/js/JSCustomPositionErrorCallback.h \
        WebCore/bindings/js/JSCustomVoidCallback.cpp \
        WebCore/bindings/js/JSCustomVoidCallback.h \
        WebCore/bindings/js/JSCustomXPathNSResolver.cpp \
@@ -349,6 +359,7 @@ webcore_sources += \
        WebCore/bindings/js/JSEventTarget.h \
        WebCore/bindings/js/JSEventTargetBase.h \
        WebCore/bindings/js/JSEventTargetNodeCustom.cpp \
+       WebCore/bindings/js/JSGeolocationCustom.cpp \
        WebCore/bindings/js/JSHTMLAllCollection.cpp \
        WebCore/bindings/js/JSHTMLAllCollection.h \
        WebCore/bindings/js/JSHTMLAppletElementCustom.cpp \
@@ -1190,6 +1201,10 @@ webcore_sources += \
        WebCore/page/FrameTree.h \
        WebCore/page/FrameView.cpp \
        WebCore/page/FrameView.h \
+       WebCore/page/Geolocation.cpp \
+       WebCore/page/Geolocation.h \
+       WebCore/page/Geoposition.cpp \
+       WebCore/page/Geoposition.h \
        WebCore/page/History.cpp \
        WebCore/page/History.h \
        WebCore/page/Location.cpp \
@@ -1202,6 +1217,10 @@ webcore_sources += \
        WebCore/page/Page.h \
        WebCore/page/PageGroup.cpp \
        WebCore/page/PageGroup.h \
+       WebCore/page/PositionCallback.h \
+       WebCore/page/PositionError.h \
+       WebCore/page/PositionErrorCallback.h \
+       WebCore/page/PositionOptions.h \
        WebCore/page/PrintContext.cpp \
        WebCore/page/PrintContext.h \
        WebCore/page/Screen.cpp \
@@ -1247,6 +1266,8 @@ webcore_sources += \
        WebCore/platform/FileChooser.h \
        WebCore/platform/FileSystem.h \
        WebCore/platform/FloatConversion.h \
+       WebCore/platform/GeolocationService.cpp \
+       WebCore/platform/GeolocationService.h \
        WebCore/platform/HostWindow.h \
        WebCore/platform/KURL.cpp \
        WebCore/platform/KURL.h \
index d4d84ad..bccfadf 100644 (file)
@@ -369,6 +369,8 @@ SOURCES += \
     bindings/js/JSCSSRuleCustom.cpp \
     bindings/js/JSCSSStyleDeclarationCustom.cpp \
     bindings/js/JSCSSValueCustom.cpp \
+    bindings/js/JSCustomPositionCallback.cpp \
+    bindings/js/JSCustomPositionErrorCallback.cpp \
     bindings/js/JSCustomVoidCallback.cpp \
     bindings/js/JSCustomXPathNSResolver.cpp \
     bindings/js/JSDocumentCustom.cpp \
@@ -381,6 +383,7 @@ SOURCES += \
     bindings/js/JSEventCustom.cpp \
     bindings/js/JSEventTarget.cpp \
     bindings/js/JSEventTargetNodeCustom.cpp \
+    bindings/js/JSGeolocationCustom.cpp \
     bindings/js/JSHTMLAllCollection.cpp \
     bindings/js/JSHistoryCustom.cpp \
     bindings/js/JSJavaScriptCallFrameCustom.cpp \
@@ -777,6 +780,8 @@ SOURCES += \
     page/Frame.cpp \
     page/FrameTree.cpp \
     page/FrameView.cpp \
+    page/Geolocation.cpp \
+    page/Geoposition.cpp \
     page/History.cpp \
     page/Location.cpp \
     page/MouseEventWithHitTestResults.cpp \
@@ -804,6 +809,7 @@ SOURCES += \
     platform/DragData.cpp \
     platform/DragImage.cpp \
     platform/FileChooser.cpp \
+    platform/GeolocationService.cpp \
     platform/graphics/FontDescription.cpp \
     platform/graphics/FontFamily.cpp \
     platform/graphics/AffineTransform.cpp \
index 7b718db..4814807 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSGeolocation.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSGeoposition.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSEvent.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSPositionError.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSPositionOptions.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSOverflowEvent.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\page\Geolocation.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release_PGO|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               WholeProgramOptimization="true"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\page\Geolocation.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\page\Geoposition.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release_PGO|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               WholeProgramOptimization="true"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\page\Geoposition.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\page\History.cpp"\r
                                >\r
                                <FileConfiguration\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\page\PositionCallback.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\page\PositionError.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\page\PositionErrorCallback.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\page\PositionOptions.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\page\Screen.cpp"\r
                                >\r
                                <FileConfiguration\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\platform\GeolocationService.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\platform\GeolocationService.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\platform\HostWindow.h"\r
                                >\r
                        </File>\r
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath="..\bindings\js\JSCustomPositionCallback.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\bindings\js\JSCustomPositionErrorCallback.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath="..\bindings\js\JSCustomSQLStatementCallback.cpp"\r
                                        >\r
                                </File>\r
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath="..\bindings\js\JSGeolocationCustom.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath="..\bindings\js\JSHistoryCustom.cpp"\r
                                        >\r
                                </File>\r
index 4ed8b2e..a21b835 100644 (file)
                F916C48D0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F916C48B0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp */; };
                F916C48E0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F916C48C0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h */; };
                F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */; };
+               FE80D7A70E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */; };
+               FE80D7A80E9C1ED2000D6F75 /* JSCustomPositionCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */; };
+               FE80D7A90E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */; };
+               FE80D7AA0E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */; };
+               FE80D7AB0E9C1ED2000D6F75 /* JSGeolocationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */; };
+               FE80D7C50E9C1F25000D6F75 /* Geolocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80D7B70E9C1F25000D6F75 /* Geolocation.cpp */; };
+               FE80D7C60E9C1F25000D6F75 /* Geolocation.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7B80E9C1F25000D6F75 /* Geolocation.h */; settings = {ATTRIBUTES = (); }; };
+               FE80D7C80E9C1F25000D6F75 /* Geoposition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80D7BA0E9C1F25000D6F75 /* Geoposition.cpp */; };
+               FE80D7C90E9C1F25000D6F75 /* Geoposition.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */; };
+               FE80D7CB0E9C1F25000D6F75 /* PositionCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7BD0E9C1F25000D6F75 /* PositionCallback.h */; };
+               FE80D7CD0E9C1F25000D6F75 /* PositionError.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7BF0E9C1F25000D6F75 /* PositionError.h */; };
+               FE80D7CF0E9C1F25000D6F75 /* PositionErrorCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7C10E9C1F25000D6F75 /* PositionErrorCallback.h */; };
+               FE80D7D10E9C1F25000D6F75 /* PositionOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80D7C30E9C1F25000D6F75 /* PositionOptions.h */; };
+               FE80DA630E9C4703000D6F75 /* JSGeolocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80DA5F0E9C4703000D6F75 /* JSGeolocation.cpp */; };
+               FE80DA640E9C4703000D6F75 /* JSGeolocation.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80DA600E9C4703000D6F75 /* JSGeolocation.h */; };
+               FE80DA650E9C4703000D6F75 /* JSGeoposition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80DA610E9C4703000D6F75 /* JSGeoposition.cpp */; };
+               FE80DA660E9C4703000D6F75 /* JSGeoposition.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80DA620E9C4703000D6F75 /* JSGeoposition.h */; };
+               FE80DA710E9C472F000D6F75 /* JSPositionError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80DA6D0E9C472F000D6F75 /* JSPositionError.cpp */; };
+               FE80DA720E9C472F000D6F75 /* JSPositionError.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80DA6E0E9C472F000D6F75 /* JSPositionError.h */; };
+               FE80DA730E9C472F000D6F75 /* JSPositionOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80DA6F0E9C472F000D6F75 /* JSPositionOptions.cpp */; };
+               FE80DA740E9C472F000D6F75 /* JSPositionOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80DA700E9C472F000D6F75 /* JSPositionOptions.h */; };
+               FEAB90120EA51B9C006348C3 /* GeolocationService.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEAB90100EA51B9C006348C3 /* GeolocationService.cpp */; };
+               FEAB90130EA51B9C006348C3 /* GeolocationService.h in Headers */ = {isa = PBXBuildFile; fileRef = FEAB90110EA51B9C006348C3 /* GeolocationService.h */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
                F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEvent.h; sourceTree = "<group>"; };
                F9F0ED780DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = XMLHttpRequestProgressEvent.idl; sourceTree = "<group>"; };
                FE49EF970DC51462004266E1 /* DashboardSupportCSSPropertyNames.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DashboardSupportCSSPropertyNames.in; sourceTree = "<group>"; };
+               FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomPositionCallback.cpp; sourceTree = "<group>"; };
+               FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomPositionCallback.h; sourceTree = "<group>"; };
+               FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomPositionErrorCallback.cpp; sourceTree = "<group>"; };
+               FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomPositionErrorCallback.h; sourceTree = "<group>"; };
+               FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGeolocationCustom.cpp; sourceTree = "<group>"; };
+               FE80D7B70E9C1F25000D6F75 /* Geolocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Geolocation.cpp; sourceTree = "<group>"; };
+               FE80D7B80E9C1F25000D6F75 /* Geolocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Geolocation.h; sourceTree = "<group>"; };
+               FE80D7B90E9C1F25000D6F75 /* Geolocation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Geolocation.idl; sourceTree = "<group>"; };
+               FE80D7BA0E9C1F25000D6F75 /* Geoposition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Geoposition.cpp; sourceTree = "<group>"; };
+               FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Geoposition.h; sourceTree = "<group>"; };
+               FE80D7BC0E9C1F25000D6F75 /* Geoposition.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Geoposition.idl; sourceTree = "<group>"; };
+               FE80D7BD0E9C1F25000D6F75 /* PositionCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PositionCallback.h; sourceTree = "<group>"; };
+               FE80D7BE0E9C1F25000D6F75 /* PositionCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PositionCallback.idl; sourceTree = "<group>"; };
+               FE80D7BF0E9C1F25000D6F75 /* PositionError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PositionError.h; sourceTree = "<group>"; };
+               FE80D7C00E9C1F25000D6F75 /* PositionError.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PositionError.idl; sourceTree = "<group>"; };
+               FE80D7C10E9C1F25000D6F75 /* PositionErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PositionErrorCallback.h; sourceTree = "<group>"; };
+               FE80D7C20E9C1F25000D6F75 /* PositionErrorCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PositionErrorCallback.idl; sourceTree = "<group>"; };
+               FE80D7C30E9C1F25000D6F75 /* PositionOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PositionOptions.h; sourceTree = "<group>"; };
+               FE80D7C40E9C1F25000D6F75 /* PositionOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PositionOptions.idl; sourceTree = "<group>"; };
+               FE80DA5F0E9C4703000D6F75 /* JSGeolocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGeolocation.cpp; sourceTree = "<group>"; };
+               FE80DA600E9C4703000D6F75 /* JSGeolocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGeolocation.h; sourceTree = "<group>"; };
+               FE80DA610E9C4703000D6F75 /* JSGeoposition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGeoposition.cpp; sourceTree = "<group>"; };
+               FE80DA620E9C4703000D6F75 /* JSGeoposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGeoposition.h; sourceTree = "<group>"; };
+               FE80DA6D0E9C472F000D6F75 /* JSPositionError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPositionError.cpp; sourceTree = "<group>"; };
+               FE80DA6E0E9C472F000D6F75 /* JSPositionError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPositionError.h; sourceTree = "<group>"; };
+               FE80DA6F0E9C472F000D6F75 /* JSPositionOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPositionOptions.cpp; sourceTree = "<group>"; };
+               FE80DA700E9C472F000D6F75 /* JSPositionOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPositionOptions.h; sourceTree = "<group>"; };
+               FEAB90100EA51B9C006348C3 /* GeolocationService.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationService.cpp; sourceTree = "<group>"; };
+               FEAB90110EA51B9C006348C3 /* GeolocationService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationService.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                65A21483097A3F5300B9050A /* FrameTree.h */,
                                65CBFEF70974F607001DAC25 /* FrameView.cpp */,
                                65CBFEF80974F607001DAC25 /* FrameView.h */,
+                               FE80D7B70E9C1F25000D6F75 /* Geolocation.cpp */,
+                               FE80D7B80E9C1F25000D6F75 /* Geolocation.h */,
+                               FE80D7B90E9C1F25000D6F75 /* Geolocation.idl */,
+                               FE80D7BA0E9C1F25000D6F75 /* Geoposition.cpp */,
+                               FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */,
+                               FE80D7BC0E9C1F25000D6F75 /* Geoposition.idl */,
                                BC94D1500C275C8B006BC617 /* History.cpp */,
                                BC94D1510C275C8B006BC617 /* History.h */,
                                BC94D1520C275C8B006BC617 /* History.idl */,
                                65A21467097A329100B9050A /* Page.h */,
                                9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */,
                                9302B0BE0D79F82C00C7EE83 /* PageGroup.h */,
+                               FE80D7BD0E9C1F25000D6F75 /* PositionCallback.h */,
+                               FE80D7BE0E9C1F25000D6F75 /* PositionCallback.idl */,
+                               FE80D7BF0E9C1F25000D6F75 /* PositionError.h */,
+                               FE80D7C00E9C1F25000D6F75 /* PositionError.idl */,
+                               FE80D7C10E9C1F25000D6F75 /* PositionErrorCallback.h */,
+                               FE80D7C20E9C1F25000D6F75 /* PositionErrorCallback.idl */,
+                               FE80D7C30E9C1F25000D6F75 /* PositionOptions.h */,
+                               FE80D7C40E9C1F25000D6F75 /* PositionOptions.idl */,
                                BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
                                BCEC01BB0C274DAC009F4EC9 /* Screen.h */,
                                BCEC01BC0C274DAC009F4EC9 /* Screen.idl */,
                                65DF322E09D1DDBC000BE325 /* JSEntity.h */,
                                93F9B7720BA5FDDC00854064 /* JSEntityReference.cpp */,
                                93F9B7730BA5FDDC00854064 /* JSEntityReference.h */,
+                               FE80DA5F0E9C4703000D6F75 /* JSGeolocation.cpp */,
+                               FE80DA600E9C4703000D6F75 /* JSGeolocation.h */,
+                               FE80DA610E9C4703000D6F75 /* JSGeoposition.cpp */,
+                               FE80DA620E9C4703000D6F75 /* JSGeoposition.h */,
                                BCD9C2BC0C17B69E005C90A2 /* JSNamedNodeMap.cpp */,
                                BCD9C2BD0C17B69E005C90A2 /* JSNamedNodeMap.h */,
                                14DC0D3509FED073007B0235 /* JSNode.cpp */,
                                BCD9C2BF0C17B69E005C90A2 /* JSNodeList.h */,
                                65DF31E909D1CC60000BE325 /* JSNotation.cpp */,
                                65DF31EA09D1CC60000BE325 /* JSNotation.h */,
+                               FE80DA6D0E9C472F000D6F75 /* JSPositionError.cpp */,
+                               FE80DA6E0E9C472F000D6F75 /* JSPositionError.h */,
+                               FE80DA6F0E9C472F000D6F75 /* JSPositionOptions.cpp */,
+                               FE80DA700E9C472F000D6F75 /* JSPositionOptions.h */,
                                65DF31EB09D1CC60000BE325 /* JSProcessingInstruction.cpp */,
                                65DF31EC09D1CC60000BE325 /* JSProcessingInstruction.h */,
                                E4B423850CBFB73C00AF2ECE /* JSProgressEvent.cpp */,
                                BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
                                BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
                                BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
+                               FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */,
+                               FE80D7A30E9C1ED2000D6F75 /* JSCustomPositionCallback.h */,
+                               FE80D7A40E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp */,
+                               FE80D7A50E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h */,
                                51EC925B0CE90DD400F90308 /* JSCustomSQLStatementCallback.cpp */,
                                51EC925C0CE90DD400F90308 /* JSCustomSQLStatementCallback.h */,
                                51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */,
                                BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */,
                                BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */,
                                BC3B7B200E91AAF400D54065 /* JSEventTargetNodeCustom.cpp */,
+                               FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */,
                                BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
                                BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
                                BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
                                066C772A0AB603B700238CC4 /* FileChooser.h */,
                                514B3F720C722047000530DF /* FileSystem.h */,
                                BC073BA90C399B1F000F5979 /* FloatConversion.h */,
+                               FEAB90100EA51B9C006348C3 /* GeolocationService.cpp */,
+                               FEAB90110EA51B9C006348C3 /* GeolocationService.h */,
                                BC3BC29B0E91AB0F00835588 /* HostWindow.h */,
                                6593923509AE4346002C531F /* KURL.cpp */,
                                6593923609AE4346002C531F /* KURL.h */,
                                1C81BA0C0E97348300266E07 /* JavaScriptDebugListener.h in Headers */,
                                1C81BA0E0E97348300266E07 /* JavaScriptDebugServer.h in Headers */,
                                BC3BE12B0E98092F00835588 /* PopupMenuStyle.h in Headers */,
+                               FE80D7A80E9C1ED2000D6F75 /* JSCustomPositionCallback.h in Headers */,
+                               FE80D7AA0E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.h in Headers */,
+                               FE80D7C60E9C1F25000D6F75 /* Geolocation.h in Headers */,
+                               FE80D7C90E9C1F25000D6F75 /* Geoposition.h in Headers */,
+                               FE80D7CB0E9C1F25000D6F75 /* PositionCallback.h in Headers */,
+                               FE80D7CD0E9C1F25000D6F75 /* PositionError.h in Headers */,
+                               FE80D7CF0E9C1F25000D6F75 /* PositionErrorCallback.h in Headers */,
+                               FE80D7D10E9C1F25000D6F75 /* PositionOptions.h in Headers */,
+                               FE80DA640E9C4703000D6F75 /* JSGeolocation.h in Headers */,
+                               FE80DA660E9C4703000D6F75 /* JSGeoposition.h in Headers */,
+                               FE80DA720E9C472F000D6F75 /* JSPositionError.h in Headers */,
+                               FE80DA740E9C472F000D6F75 /* JSPositionOptions.h in Headers */,
                                BC3BE9940E9C1C7C00835588 /* RenderScrollbar.h in Headers */,
                                BC3BE9950E9C1C7C00835588 /* RenderScrollbarPart.h in Headers */,
                                BC3BE9990E9C1E5D00835588 /* RenderScrollbarTheme.h in Headers */,
                                BCE659A90EA927B9007E4533 /* ThemeTypes.h in Headers */,
                                BCE659E60EA92FB2007E4533 /* ThemeMac.h in Headers */,
                                E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */,
+                               FEAB90130EA51B9C006348C3 /* GeolocationService.h in Headers */,
                                BCE65BEB0EACDF16007E4533 /* Length.h in Headers */,
                                BCFF64910EAD15C200C1D6F7 /* LengthBox.h in Headers */,
                                BCFF64920EAD15C200C1D6F7 /* LengthSize.h in Headers */,
                                1C81BA020E9733CB00266E07 /* JavaScriptProfile.cpp in Sources */,
                                1C81BA090E97348300266E07 /* JavaScriptCallFrame.cpp in Sources */,
                                1C81BA0D0E97348300266E07 /* JavaScriptDebugServer.cpp in Sources */,
+                               FE80D7A70E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp in Sources */,
+                               FE80D7A90E9C1ED2000D6F75 /* JSCustomPositionErrorCallback.cpp in Sources */,
+                               FE80D7AB0E9C1ED2000D6F75 /* JSGeolocationCustom.cpp in Sources */,
+                               FE80D7C50E9C1F25000D6F75 /* Geolocation.cpp in Sources */,
+                               FE80D7C80E9C1F25000D6F75 /* Geoposition.cpp in Sources */,
+                               FE80DA630E9C4703000D6F75 /* JSGeolocation.cpp in Sources */,
+                               FE80DA650E9C4703000D6F75 /* JSGeoposition.cpp in Sources */,
+                               FE80DA710E9C472F000D6F75 /* JSPositionError.cpp in Sources */,
+                               FE80DA730E9C472F000D6F75 /* JSPositionOptions.cpp in Sources */,
                                BC3BE9930E9C1C7C00835588 /* RenderScrollbar.cpp in Sources */,
                                BC3BE9A50E9C239600835588 /* RenderScrollbarTheme.cpp in Sources */,
                                BC3BE9AB0E9C242000835588 /* RenderScrollbarPart.cpp in Sources */,
                                939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
                                BCE659E90EA92FFA007E4533 /* ThemeMac.mm in Sources */,
                                E1C4DE6E0EA75C650023CCD6 /* ActiveDOMObject.cpp in Sources */,
+                               FEAB90120EA51B9C006348C3 /* GeolocationService.cpp in Sources */,
                                BCE65BEA0EACDF16007E4533 /* Length.cpp in Sources */,
                                BCE65D320EAD1211007E4533 /* Theme.cpp in Sources */,
                                E1C36CBD0EB08062007410BC /* JSDOMGlobalObject.cpp in Sources */,
index 986289d..7614716 100644 (file)
@@ -42,6 +42,8 @@ This file contains the list of files needed to build WebCore.
         bindings/js/JSCSSRuleCustom.cpp
         bindings/js/JSCSSStyleDeclarationCustom.cpp
         bindings/js/JSCSSValueCustom.cpp
+        bindings/js/JSCustomPositionCallback.cpp
+        bindings/js/JSCustomPositionErrorCallback.cpp
         bindings/js/JSCustomSQLStatementCallback.cpp
         bindings/js/JSCustomSQLStatementErrorCallback.cpp
         bindings/js/JSCustomSQLTransactionCallback.cpp
@@ -60,6 +62,7 @@ This file contains the list of files needed to build WebCore.
         bindings/js/JSEventCustom.cpp
         bindings/js/JSEventTarget.cpp
         bindings/js/JSEventTargetNodeCustom.cpp
+        bindings/js/JSGeolocationCustom.cpp
         bindings/js/JSHTMLAllCollection.cpp
         bindings/js/JSHistoryCustom.cpp
         bindings/js/JSHTMLAppletElementCustom.cpp
@@ -239,6 +242,8 @@ This file contains the list of files needed to build WebCore.
         DerivedSources/WebCore/JSEventTargetNode.cpp
         DerivedSources/WebCore/JSFile.cpp
         DerivedSources/WebCore/JSFileList.cpp
+        DerivedSources/WebCore/JSGeolocation.cpp
+        DerivedSources/WebCore/JSGeoposition.cpp
         DerivedSources/WebCore/JSHTMLAnchorElement.cpp
         DerivedSources/WebCore/JSHTMLAppletElement.cpp
         DerivedSources/WebCore/JSHTMLAreaElement.cpp
@@ -323,6 +328,8 @@ This file contains the list of files needed to build WebCore.
         DerivedSources/WebCore/JSOverflowEvent.cpp
         DerivedSources/WebCore/JSPlugin.cpp
         DerivedSources/WebCore/JSPluginArray.cpp
+        DerivedSources/WebCore/JSPositionError.cpp
+        DerivedSources/WebCore/JSPositionOptions.cpp
         DerivedSources/WebCore/JSProcessingInstruction.cpp
         DerivedSources/WebCore/JSProgressEvent.cpp
         DerivedSources/WebCore/JSRange.cpp
@@ -670,6 +677,8 @@ This file contains the list of files needed to build WebCore.
         page/Frame.cpp
         page/FrameTree.cpp
         page/FrameView.cpp
+        page/Geolocation.cpp
+        page/Geoposition.cpp
         page/History.cpp
         page/Location.cpp
         page/MouseEventWithHitTestResults.cpp
@@ -693,6 +702,7 @@ This file contains the list of files needed to build WebCore.
         platform/DeprecatedValueListImpl.cpp
         platform/DragImage.cpp
         platform/FileChooser.cpp
+        platform/GeolocationService.cpp
         platform/graphics/Font.cpp
         platform/graphics/FontCache.cpp
         platform/graphics/FontData.cpp
diff --git a/WebCore/bindings/js/JSCustomPositionCallback.cpp b/WebCore/bindings/js/JSCustomPositionCallback.cpp
new file mode 100644 (file)
index 0000000..b25a3fa
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 "JSCustomPositionCallback.h"
+
+#include "Console.h"
+#include "CString.h"
+#include "Frame.h"
+#include "JSGeoposition.h"
+#include "Page.h"
+#include "ScriptController.h"
+#include <kjs/JSLock.h>
+
+namespace WebCore {
+
+using namespace JSC;
+
+JSCustomPositionCallback::JSCustomPositionCallback(JSObject* callback, Frame* frame)
+    : m_callback(callback)
+    , m_frame(frame)
+{
+}
+
+void JSCustomPositionCallback::handleEvent(Geoposition* geoposition, bool& raisedException)
+{
+    ASSERT(m_callback);
+    ASSERT(m_frame);
+    
+    if (!m_frame->script()->isEnabled())
+        return;
+    
+    JSGlobalObject* globalObject = m_frame->script()->globalObject();
+    ExecState* exec = globalObject->globalExec();
+    
+    JSC::JSLock lock(false);
+    
+    JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent"));
+    CallData callData;
+    CallType callType = function->getCallData(callData);
+    if (callType == CallTypeNone) {
+        callType = m_callback->getCallData(callData);
+        if (callType == CallTypeNone) {
+            // FIXME: Should an exception be thrown here?
+            return;
+        }
+        function = m_callback;
+    }
+    
+    RefPtr<JSCustomPositionCallback> protect(this);
+    
+    ArgList args;
+    args.append(toJS(exec, geoposition));
+    
+    globalObject->startTimeoutCheck();
+    call(exec, function, callType, callData, m_callback, args);
+    globalObject->stopTimeoutCheck();
+    
+    if (exec->hadException()) {
+        m_frame->domWindow()->console()->reportCurrentException(exec);
+        raisedException = true;
+    }
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/js/JSCustomPositionCallback.h b/WebCore/bindings/js/JSCustomPositionCallback.h
new file mode 100644 (file)
index 0000000..f10695e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 JSCustomPositionCallback_h
+#define JSCustomPositionCallback_h
+
+#include "PositionCallback.h"
+#include <kjs/JSObject.h>
+#include <kjs/protect.h>
+#include <wtf/Forward.h>
+
+namespace JSC {
+    class JSObject;
+}
+
+namespace WebCore {
+
+class Frame;
+class Geoposition;
+
+class JSCustomPositionCallback : public PositionCallback {
+public:
+    static PassRefPtr<JSCustomPositionCallback> create(JSC::JSObject* callback, Frame* frame) { return adoptRef(new JSCustomPositionCallback(callback, frame)); }
+    
+    virtual void handleEvent(Geoposition*, bool& raisedException);
+
+private:
+    JSCustomPositionCallback(JSC::JSObject* callback, Frame*);
+
+    JSC::ProtectedPtr<JSC::JSObject> m_callback;
+    RefPtr<Frame> m_frame;
+};
+    
+} // namespace WebCore
+
+#endif // JSCustomPositionCallback_h
diff --git a/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp b/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp
new file mode 100644 (file)
index 0000000..f51b25d
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 "JSCustomPositionErrorCallback.h"
+
+#include "Console.h"
+#include "CString.h"
+#include "Frame.h"
+#include "JSPositionError.h"
+#include "Page.h"
+#include "ScriptController.h"
+#include <kjs/JSLock.h>
+
+namespace WebCore {
+    
+using namespace JSC;
+
+JSCustomPositionErrorCallback::JSCustomPositionErrorCallback(JSObject* callback, Frame* frame)
+    : m_callback(callback)
+    , m_frame(frame)
+{
+}
+
+void JSCustomPositionErrorCallback::handleEvent(PositionError* positionError)
+{
+    ASSERT(m_callback);
+    ASSERT(m_frame);
+    
+    if (!m_frame->script()->isEnabled())
+        return;
+    
+    JSGlobalObject* globalObject = m_frame->script()->globalObject();
+    ExecState* exec = globalObject->globalExec();
+    
+    JSC::JSLock lock(false);
+    
+    JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent"));
+    CallData callData;
+    CallType callType = function->getCallData(callData);
+    if (callType == CallTypeNone) {
+        callType = m_callback->getCallData(callData);
+        if (callType == CallTypeNone) {
+            // FIXME: Should an exception be thrown here?
+            return;
+        }
+        function = m_callback;
+    }
+    
+    RefPtr<JSCustomPositionErrorCallback> protect(this);
+    
+    ArgList args;
+    args.append(toJS(exec, positionError));
+    
+    globalObject->startTimeoutCheck();
+    call(exec, function, callType, callData, m_callback, args);
+    globalObject->stopTimeoutCheck();
+    
+    if (exec->hadException())
+        m_frame->domWindow()->console()->reportCurrentException(exec);
+}
+    
+} // namespace WebCore
diff --git a/WebCore/bindings/js/JSCustomPositionErrorCallback.h b/WebCore/bindings/js/JSCustomPositionErrorCallback.h
new file mode 100644 (file)
index 0000000..fa9e550
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 JSCustomPositionErrorCallback_h
+#define JSCustomPositionErrorCallback_h
+
+#include "PositionErrorCallback.h"
+#include <kjs/JSObject.h>
+#include <kjs/protect.h>
+#include <wtf/Forward.h>
+
+namespace JSC {
+    class JSObject;
+}
+
+namespace WebCore {
+    
+class Frame;
+class PositionError;
+
+class JSCustomPositionErrorCallback : public PositionErrorCallback {
+public:
+    static PassRefPtr<JSCustomPositionErrorCallback> create(JSC::JSObject* callback, Frame* frame) { return adoptRef(new JSCustomPositionErrorCallback(callback, frame)); }
+    
+    virtual void handleEvent(PositionError*);
+
+private:
+    JSCustomPositionErrorCallback(JSC::JSObject* callback, Frame*);
+
+    JSC::ProtectedPtr<JSC::JSObject> m_callback;
+    RefPtr<Frame> m_frame;
+};
+    
+} // namespace WebCore
+
+#endif // JSCustomPositionErrorCallback_h
index ad69949..874945f 100644 (file)
@@ -353,6 +353,16 @@ void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocum
     addWrapper(wrapper);
 }
 
+void markDOMObjectWrapper(JSGlobalData& globalData, void* object)
+{
+    if (!object)
+        return;
+    DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, object);
+    if (!wrapper || wrapper->marked())
+        return;
+    wrapper->mark();
+}
+
 JSValue* jsStringOrNull(ExecState* exec, const String& s)
 {
     if (s.isNull())
index a017799..b753d86 100644 (file)
@@ -69,6 +69,7 @@ namespace WebCore {
     void updateDOMNodeDocument(Node*, Document* oldDocument, Document* newDocument);
     void markDOMNodesForDocument(Document*);
     void markActiveObjectsForDocument(JSC::JSGlobalData&, Document*);
+    void markDOMObjectWrapper(JSC::JSGlobalData& globalData, void* object);
     void markCrossHeapDependentObjectsForDocument(JSC::JSGlobalData&, Document*);
 
     JSC::StructureID* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*);
index 928f37c..c181355 100644 (file)
@@ -41,16 +41,6 @@ using namespace JSC;
 
 namespace WebCore {
 
-static void markDOMObjectWrapper(JSGlobalData& globalData, void* object)
-{
-    if (!object)
-        return;
-    DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, object);
-    if (!wrapper || wrapper->marked())
-        return;
-    wrapper->mark();
-}
-
 void JSDOMWindow::mark()
 {
     Base::mark();
diff --git a/WebCore/bindings/js/JSGeolocationCustom.cpp b/WebCore/bindings/js/JSGeolocationCustom.cpp
new file mode 100644 (file)
index 0000000..9c11172
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 "JSGeolocation.h"
+
+#include "DOMWindow.h"
+#include "ExceptionCode.h"
+#include "Geolocation.h"
+#include "GeolocationService.h"
+#include "JSCustomPositionCallback.h"
+#include "JSCustomPositionErrorCallback.h"
+#include "JSDOMWindow.h"
+#include "JSPositionOptions.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue* JSGeolocation::getCurrentPosition(ExecState* exec, const ArgList& args)
+{
+    // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions
+    RefPtr<PositionCallback> positionCallback;
+    JSObject* object = args.at(exec, 0)->getObject();
+    if (exec->hadException())
+        return jsUndefined();
+    if (!object) {
+        setDOMException(exec, TYPE_MISMATCH_ERR);
+        return jsUndefined();
+    }
+
+    if (Frame* frame = toJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame())
+        positionCallback = JSCustomPositionCallback::create(object, frame);
+    
+    RefPtr<PositionErrorCallback> positionErrorCallback;
+    if (!args.at(exec, 1)->isUndefinedOrNull()) {
+        JSObject* object = args.at(exec, 1)->getObject();
+        if (!object) {
+            setDOMException(exec, TYPE_MISMATCH_ERR);
+            return jsUndefined();
+        }
+
+        if (Frame* frame = toJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame())
+            positionErrorCallback = JSCustomPositionErrorCallback::create(object, frame);
+    }
+    
+    RefPtr<PositionOptions> positionOptions;
+    if (!args.at(exec, 2)->isUndefinedOrNull())
+        positionOptions = toPositionOptions(args.at(exec, 2));
+    
+    m_impl->getCurrentPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.get());
+    
+    return jsUndefined();
+}
+
+JSValue* JSGeolocation::watchPosition(ExecState* exec, const ArgList& args)
+{
+    // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions
+    RefPtr<PositionCallback> positionCallback;
+    JSObject* object = args.at(exec, 0)->getObject();
+    if (exec->hadException())
+        return jsUndefined();
+    if (!object) {
+        setDOMException(exec, TYPE_MISMATCH_ERR);
+        return jsUndefined();
+    }
+    
+    if (Frame* frame = toJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame())
+        positionCallback = JSCustomPositionCallback::create(object, frame);
+    
+    RefPtr<PositionErrorCallback> positionErrorCallback;
+    if (!args.at(exec, 1)->isUndefinedOrNull()) {
+        JSObject* object = args.at(exec, 1)->getObject();
+        if (!object) {
+            setDOMException(exec, TYPE_MISMATCH_ERR);
+            return jsUndefined();
+        }
+        
+        if (Frame* frame = toJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame())
+            positionErrorCallback = JSCustomPositionErrorCallback::create(object, frame);
+    }
+    
+    RefPtr<PositionOptions> positionOptions;
+    if (!args.at(exec, 2)->isUndefinedOrNull())
+        positionOptions = toPositionOptions(args.at(exec, 2));
+    
+    int watchID = m_impl->watchPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.get());
+    return jsNumber(exec, watchID);
+}
+
+} // namespace WebCore
index 8522d6a..a85eb93 100644 (file)
@@ -113,4 +113,13 @@ JSValue* JSNavigator::appVersion(ExecState* exec) const
     return jsString(exec, imp->appVersion());
 }
 
+void JSNavigator::mark()
+{
+    Base::mark();
+
+    JSGlobalData& globalData = *Heap::heap(this)->globalData();
+
+    markDOMObjectWrapper(globalData, impl()->optionalGeolocation());
+}
+
 }
index f43eda1..4bd55c6 100644 (file)
@@ -316,6 +316,7 @@ Document::Document(Frame* frame, bool isXHTML)
 #if ENABLE(DATABASE)
     , m_hasOpenDatabases(false)
 #endif
+    , m_usingGeolocation(false)
 #if USE(LOW_BANDWIDTH_DISPLAY)
     , m_inLowBandwidthDisplay(false)
 #endif
index d4146eb..c8b0b88 100644 (file)
@@ -998,6 +998,10 @@ public:
     bool hasOpenDatabases() { return m_hasOpenDatabases; }
     void stopDatabases();
 #endif
+    
+    void setUsingGeolocation(bool f) { m_usingGeolocation = f; }
+    bool usingGeolocation() const { return m_usingGeolocation; };
+    
 protected:
     void clearXMLVersion() { m_xmlVersion = String(); }
 
@@ -1074,6 +1078,8 @@ private:
     typedef HashSet<Database*> DatabaseSet;
     OwnPtr<DatabaseSet> m_openDatabaseSet;
 #endif
+    
+    bool m_usingGeolocation;
 
 #if USE(LOW_BANDWIDTH_DISPLAY)
     bool m_inLowBandwidthDisplay;
index 4ec4760..5295019 100644 (file)
@@ -1915,6 +1915,7 @@ bool FrameLoader::canCachePage()
 #if ENABLE(DATABASE)
         && !m_frame->document()->hasOpenDatabases()
 #endif
+        && !m_frame->document()->usingGeolocation()
         && m_frame->page()
         && m_frame->page()->backForwardList()->enabled()
         && m_frame->page()->backForwardList()->capacity() > 0
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
new file mode 100644 (file)
index 0000000..9973a95
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 "Geolocation.h"
+
+#include "Document.h"
+#include "Frame.h"
+#include "PositionError.h"
+
+namespace WebCore {
+
+Geolocation::GeoNotifier::GeoNotifier(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PositionOptions* options)
+    : m_successCallback(successCallback)
+    , m_errorCallback(errorCallback)
+    , m_timer(this, &Geolocation::GeoNotifier::timerFired)
+{
+    if (m_errorCallback && options && options->timeout() != -1)
+        m_timer.startOneShot(options->timeout() / 1000.0);
+}
+
+void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*)
+{
+    ASSERT(m_errorCallback);
+    
+    m_timer.stop();
+
+    RefPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT_ERROR, "Timed out");
+    m_errorCallback->handleEvent(error.get());
+}
+
+Geolocation::Geolocation(Frame* frame)
+    : m_frame(frame)
+    , m_service(GeolocationService::create(this))
+{
+    ASSERT(m_frame->document());
+    m_frame->document()->setUsingGeolocation(true);
+}
+
+void Geolocation::disconnectFrame()
+{
+    m_service->stopUpdating();
+    if (m_frame->document())
+        m_frame->document()->setUsingGeolocation(false);
+    m_frame = 0;
+}
+
+void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PositionOptions* options)
+{
+    RefPtr<GeoNotifier> notifier = GeoNotifier::create(successCallback, errorCallback, options);
+
+    if (!m_service->startUpdating(options)) {
+        if (notifier->m_errorCallback) {
+            RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_ERROR, "Unable to Start");
+            notifier->m_errorCallback->handleEvent(error.get());
+        }
+        return;
+    }
+
+    m_oneShots.add(notifier);
+}
+
+int Geolocation::watchPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PositionOptions* options)
+{
+    RefPtr<GeoNotifier> notifier = GeoNotifier::create(successCallback, errorCallback, options);
+
+    if (!m_service->startUpdating(options)) {
+        if (notifier->m_errorCallback) {
+            RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_ERROR, "Unable to Start");
+            notifier->m_errorCallback->handleEvent(error.get());
+        }
+        return 0;
+    }
+    
+    static int sIdentifier = 0;
+    
+    m_watchers.set(++sIdentifier, notifier);
+
+    return sIdentifier;
+}
+
+void Geolocation::clearWatch(int watchId)
+{
+    m_watchers.remove(watchId);
+    
+    stopUpdatingIfEmpty();
+}
+
+void Geolocation::stopUpdatingIfEmpty()
+{
+    if (m_watchers.isEmpty() && m_oneShots.isEmpty())
+        m_service->stopUpdating();
+}
+
+void Geolocation::sendErrorToOneShots(PositionError* error)
+{
+    Vector<RefPtr<GeoNotifier> > copy;
+    copyToVector(m_oneShots, copy);
+
+    Vector<RefPtr<GeoNotifier> >::const_iterator end = copy.end();
+    for (Vector<RefPtr<GeoNotifier> >::const_iterator it = copy.begin(); it != end; ++it) {
+        RefPtr<GeoNotifier> notifier = *it;
+        
+        if (notifier->m_errorCallback)
+            notifier->m_errorCallback->handleEvent(error);
+    }
+}
+
+void Geolocation::sendErrorToWatchers(PositionError* error)
+{
+    Vector<RefPtr<GeoNotifier> > copy;
+    copyValuesToVector(m_watchers, copy);
+
+    Vector<RefPtr<GeoNotifier> >::const_iterator end = copy.end();
+    for (Vector<RefPtr<GeoNotifier> >::const_iterator it = copy.begin(); it != end; ++it) {
+        RefPtr<GeoNotifier> notifier = *it;
+        
+        if (notifier->m_errorCallback)
+            notifier->m_errorCallback->handleEvent(error);
+    }
+}
+
+void Geolocation::sendPositionToOneShots(Geoposition* position)
+{
+    Vector<RefPtr<GeoNotifier> > copy;
+    copyToVector(m_oneShots, copy);
+    
+    Vector<RefPtr<GeoNotifier> >::const_iterator end = copy.end();
+    for (Vector<RefPtr<GeoNotifier> >::const_iterator it = copy.begin(); it != end; ++it) {
+        RefPtr<GeoNotifier> notifier = *it;
+        ASSERT(notifier->m_successCallback);
+        
+        notifier->m_timer.stop();
+        bool shouldCallErrorCallback = false;
+        notifier->m_successCallback->handleEvent(position, shouldCallErrorCallback);
+        if (shouldCallErrorCallback) {
+            RefPtr<PositionError> error = PositionError::create(PositionError::UNKNOWN_ERROR, "An exception was thrown");
+            handleError(error.get());
+        }
+    }
+}
+
+void Geolocation::sendPositionToWatchers(Geoposition* position)
+{
+    Vector<RefPtr<GeoNotifier> > copy;
+    copyValuesToVector(m_watchers, copy);
+    
+    Vector<RefPtr<GeoNotifier> >::const_iterator end = copy.end();
+    for (Vector<RefPtr<GeoNotifier> >::const_iterator it = copy.begin(); it != end; ++it) {
+        RefPtr<GeoNotifier> notifier = *it;
+        ASSERT(notifier->m_successCallback);
+        
+        notifier->m_timer.stop();
+        bool shouldCallErrorCallback = false;
+        notifier->m_successCallback->handleEvent(position, shouldCallErrorCallback);
+        if (shouldCallErrorCallback) {
+            RefPtr<PositionError> error = PositionError::create(PositionError::UNKNOWN_ERROR, "An exception was thrown");
+            handleError(error.get());
+        }
+    }
+}
+
+void Geolocation::handleError(PositionError* error)
+{
+    ASSERT(error);
+    
+    sendErrorToOneShots(error);    
+    sendErrorToWatchers(error);
+
+    m_oneShots.clear();
+}
+
+void Geolocation::geolocationServicePositionChanged(GeolocationService* service)
+{
+    ASSERT(service->lastPosition());
+    
+    sendPositionToOneShots(service->lastPosition());
+    sendPositionToWatchers(service->lastPosition());
+        
+    m_oneShots.clear();
+    stopUpdatingIfEmpty();
+}
+
+void Geolocation::geolocationServiceErrorOccurred(GeolocationService* service)
+{
+    ASSERT(service->lastError());
+    
+    handleError(service->lastError());
+}
+
+} // namespace WebCore
diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h
new file mode 100644 (file)
index 0000000..d67793a
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 Geolocation_h
+#define Geolocation_h
+
+#include "GeolocationService.h"
+#include "PositionCallback.h"
+#include "PositionErrorCallback.h"
+#include "PositionOptions.h"
+#include "Timer.h"
+#include <wtf/Platform.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+class Geoposition;
+
+class Geolocation : public RefCounted<Geolocation>, public GeolocationServiceClient {
+public:
+    static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); }
+
+    virtual ~Geolocation() {}
+
+    void disconnectFrame();
+    
+    Geoposition* lastPosition() const { return m_service->lastPosition(); }
+
+    void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PositionOptions*);
+    int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PositionOptions*);
+    void clearWatch(int watchId);
+
+private:
+    Geolocation(Frame*);
+
+    class GeoNotifier : public RefCounted<GeoNotifier> {
+    public:
+        static PassRefPtr<GeoNotifier> create(PassRefPtr<PositionCallback> positionCallback, PassRefPtr<PositionErrorCallback> positionErrorCallback, PositionOptions* options) { return adoptRef(new GeoNotifier(positionCallback, positionErrorCallback, options)); }
+        
+        void timerFired(Timer<GeoNotifier>*);
+        
+        RefPtr<PositionCallback> m_successCallback;
+        RefPtr<PositionErrorCallback> m_errorCallback;
+        Timer<GeoNotifier> m_timer;
+
+    private:
+        GeoNotifier(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PositionOptions*);
+    };
+    
+    void stopUpdatingIfEmpty();
+
+    void sendErrorToOneShots(PositionError*);
+    void sendErrorToWatchers(PositionError*);
+    void sendPositionToOneShots(Geoposition*);
+    void sendPositionToWatchers(Geoposition*);
+    
+    void handleError(PositionError*);
+    
+    virtual void geolocationServicePositionChanged(GeolocationService*);
+    virtual void geolocationServiceErrorOccurred(GeolocationService*);
+            
+    typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet;
+    typedef HashMap<int, RefPtr<GeoNotifier> > GeoNotifierMap;
+    
+    GeoNotifierSet m_oneShots;
+    GeoNotifierMap m_watchers;
+    Frame* m_frame;
+    OwnPtr<GeolocationService> m_service;
+};
+    
+} // namespace WebCore
+
+#endif // Geolocation_h
diff --git a/WebCore/page/Geolocation.idl b/WebCore/page/Geolocation.idl
new file mode 100644 (file)
index 0000000..e125118
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+module core {
+
+    interface Geolocation {
+        readonly attribute Geoposition lastPosition;
+
+        [Custom] void getCurrentPosition(in PositionCallback successCallback, in PositionErrorCallback errorCallback, in PositionOptions options);
+
+        [Custom] long watchPosition(in PositionCallback successCallback, in PositionErrorCallback errorCallback, in PositionOptions options);
+
+        void clearWatch(in long watchId);
+    };
+
+}
diff --git a/WebCore/page/Geoposition.cpp b/WebCore/page/Geoposition.cpp
new file mode 100644 (file)
index 0000000..4592ebe
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 "Geoposition.h"
+
+namespace WebCore {
+
+String Geoposition::toString() const
+{
+    return String::format("position(%.6lg, %.6lg, %.6lg, %.6lg, %.6lg, %.6lg, %.6lg, %.lld)",
+                          m_latitude, m_longitude, m_altitude, m_accuracy, 
+                          m_altitudeAccuracy, m_heading, m_velocity, m_timestamp);
+}
+
+} // namespace WebCore
diff --git a/WebCore/page/Geoposition.h b/WebCore/page/Geoposition.h
new file mode 100644 (file)
index 0000000..1cf43e1
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 Geoposition_h
+#define Geoposition_h
+
+#include "Event.h"
+#include "PlatformString.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+typedef int ExceptionCode;
+
+class Geoposition : public RefCounted<Geoposition> {
+public:
+    static PassRefPtr<Geoposition> create(double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy, double heading, double velocity, DOMTimeStamp timestamp) { return adoptRef(new Geoposition(latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, velocity, timestamp)); }
+    
+    double latitude() const { return m_latitude; }
+    double longitude() const { return m_longitude; }
+    double altitude() const { return m_altitude; }
+    double accuracy() const { return m_accuracy; }
+    double altitudeAccuracy() const { return m_altitudeAccuracy; }
+    double heading() const { return m_heading; }
+    double velocity() const { return m_velocity; }
+    DOMTimeStamp timestamp() const { return m_timestamp; }
+
+    String toString() const;
+
+private:
+    Geoposition(double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy, double heading, double velocity, DOMTimeStamp timestamp)
+        : m_latitude(latitude)
+        , m_longitude(longitude)
+        , m_altitude(altitude)
+        , m_accuracy(accuracy)
+        , m_altitudeAccuracy(altitudeAccuracy)
+        , m_heading(heading)
+        , m_velocity(velocity)
+        , m_timestamp(timestamp)
+    {
+    }
+
+    double m_latitude;
+    double m_longitude;
+    double m_altitude;
+    double m_accuracy;
+    double m_altitudeAccuracy;
+    double m_heading;
+    double m_velocity;
+    DOMTimeStamp m_timestamp;
+};
+    
+} // namespace WebCore
+
+#endif // Geoposition_h
diff --git a/WebCore/page/Geoposition.idl b/WebCore/page/Geoposition.idl
new file mode 100644 (file)
index 0000000..14cc6ac
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+module core {
+
+    interface Geoposition {
+        readonly attribute double latitude;
+        readonly attribute double longitude;
+        readonly attribute double altitude;
+        readonly attribute double accuracy;
+        readonly attribute double altitudeAccuracy;
+        readonly attribute double heading
+        readonly attribute double velocity
+        readonly attribute DOMTimeStamp timestamp;
+
+#if defined(LANGUAGE_JAVASCRIPT)
+        [DontEnum] DOMString toString();
+#endif
+    };
+}
index df30523..6eb7c3e 100644 (file)
@@ -27,6 +27,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
+#include "Geolocation.h"
 #include "Language.h"
 #include "MimeTypeArray.h"
 #include "NetworkStateNotifier.h"
@@ -87,6 +88,10 @@ void Navigator::disconnectFrame()
         m_mimeTypes->disconnectFrame();
         m_mimeTypes = 0;
     }
+    if (m_geolocation) {
+        m_geolocation->disconnectFrame();
+        m_geolocation = 0;
+    }
     m_frame = 0;
 }
 
@@ -197,4 +202,11 @@ bool Navigator::onLine() const
     return networkStateNotifier().onLine();
 }
 
+Geolocation* Navigator::geolocation() const
+{
+    if (!m_geolocation)
+        m_geolocation = Geolocation::create(m_frame);
+    return m_geolocation.get();
+}
+    
 } // namespace WebCore
index 83c9880..ea5d780 100644 (file)
@@ -27,6 +27,7 @@
 namespace WebCore {
 
     class Frame;
+    class Geolocation;
     class MimeTypeArray;
     class PluginData;
     class PluginArray;
@@ -56,11 +57,16 @@ namespace WebCore {
         bool javaEnabled() const;
 
         bool onLine() const;
+        Geolocation* geolocation() const;
+        // This is used for GC marking.
+        Geolocation* optionalGeolocation() const { return m_geolocation.get(); }
+
     private:
         Navigator(Frame*);
         Frame* m_frame;
         mutable RefPtr<PluginArray> m_plugins;
         mutable RefPtr<MimeTypeArray> m_mimeTypes;
+        mutable RefPtr<Geolocation> m_geolocation;
     };
 
 }
index 53cec55..905159c 100644 (file)
@@ -19,7 +19,9 @@
 
 module window {
 
-    interface Navigator {
+    interface [
+        CustomMarkFunction
+    ] Navigator {
         readonly attribute DOMString appCodeName;
         readonly attribute DOMString appName;
         readonly attribute [CustomGetter] DOMString appVersion;
@@ -36,6 +38,9 @@ module window {
         boolean javaEnabled();
         
         readonly attribute boolean onLine;
+#if ENABLE_GEOLOCATION
+        readonly attribute Geolocation geolocation;
+#endif
     };
 
 }
diff --git a/WebCore/page/PositionCallback.h b/WebCore/page/PositionCallback.h
new file mode 100644 (file)
index 0000000..5f32c75
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 PositionCallback_h
+#define PositionCallback_h
+
+#include <wtf/Platform.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+    
+    class Geoposition;
+    
+    class PositionCallback : public RefCounted<PositionCallback> {
+    public:
+        virtual ~PositionCallback() { }
+        virtual void handleEvent(Geoposition* position, bool& raisedException) = 0;
+    };
+    
+} // namespace WebCore
+
+#endif // PositionCallback_h
diff --git a/WebCore/page/PositionCallback.idl b/WebCore/page/PositionCallback.idl
new file mode 100644 (file)
index 0000000..e862538
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+module core {
+
+    interface [
+        GenerateConstructor
+    ] PositionCallback {
+        void handleEvent(in Geoposition position);
+    };
+
+}
diff --git a/WebCore/page/PositionError.h b/WebCore/page/PositionError.h
new file mode 100644 (file)
index 0000000..1d68bde
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 PositionError_h
+#define PositionError_h
+
+#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+    
+class PositionError : public RefCounted<PositionError> {
+public:
+    enum ErrorCode {
+        PERMISSION_ERROR = 1,
+        LOCATION_PROVIDER_ERROR,
+        POSITION_NOT_FOUND_ERROR,
+        TIMEOUT_ERROR,
+        UNKNOWN_ERROR
+    };
+    
+    static PassRefPtr<PositionError> create(ErrorCode code, const String& message) { return adoptRef(new PositionError(code, message)); }
+
+    ErrorCode code() const { return m_code; }
+    const String& message() const { return m_message; }
+    
+private:
+    PositionError(ErrorCode code, const String& message) 
+        : m_code(code)
+        , m_message(message)
+    {
+    }
+    
+    ErrorCode m_code;
+    String m_message;
+};
+    
+} // namespace WebCore
+
+#endif // PositionError_h
diff --git a/WebCore/page/PositionError.idl b/WebCore/page/PositionError.idl
new file mode 100644 (file)
index 0000000..8c8c335
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+module core {
+
+    interface [
+        GenerateConstructor
+    ] PositionError {
+        readonly attribute long code;
+        readonly attribute DOMString message;
+    };
+
+}
diff --git a/WebCore/page/PositionErrorCallback.h b/WebCore/page/PositionErrorCallback.h
new file mode 100644 (file)
index 0000000..c23e883
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 PositionErrorCallback_h
+#define PositionErrorCallback_h
+
+#include <wtf/Platform.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+    class PositionError;
+
+    class PositionErrorCallback : public RefCounted<PositionErrorCallback> {
+    public:
+        virtual ~PositionErrorCallback() { }
+        virtual void handleEvent(PositionError*) = 0;
+    };
+    
+} // namespace WebCore
+
+#endif // PositionErrorCallback_h
diff --git a/WebCore/page/PositionErrorCallback.idl b/WebCore/page/PositionErrorCallback.idl
new file mode 100644 (file)
index 0000000..07edfa6
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+module core {
+
+    interface [
+        GenerateConstructor
+    ] PositionErrorCallback {
+        void handleEvent(in PositionError error);
+    };
+
+}
diff --git a/WebCore/page/PositionOptions.h b/WebCore/page/PositionOptions.h
new file mode 100644 (file)
index 0000000..5251cd7
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 PositionOptions_h
+#define PositionOptions_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+    
+class PositionOptions : public RefCounted<PositionOptions> {
+public:
+    static PassRefPtr<PositionOptions> create(bool highAccuracy, int timeout) { return adoptRef(new PositionOptions(highAccuracy, timeout)); }
+
+    bool enableHighAccuracy() const { return m_highAccuracy; }
+    void setEnableHighAccuracy(bool enable) { m_highAccuracy = enable; }
+    int timeout() const { return m_timeout; }
+    void setTimeout(int t) { m_timeout = t; }
+    
+private:
+    PositionOptions(bool highAccuracy, int timeout)
+        : m_highAccuracy(highAccuracy)
+        , m_timeout(timeout)
+    {
+    }
+    
+    bool m_highAccuracy;
+    int m_timeout;
+};
+    
+} // namespace WebCore
+
+#endif // PositionOptions_h
diff --git a/WebCore/page/PositionOptions.idl b/WebCore/page/PositionOptions.idl
new file mode 100644 (file)
index 0000000..60e6863
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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. 
+ */
+
+module core {
+
+    interface [
+        GenerateConstructor
+    ] PositionOptions {
+        attribute boolean enableHighAccuracy;
+        attribute long timeout;
+    };
+
+}
diff --git a/WebCore/platform/GeolocationService.cpp b/WebCore/platform/GeolocationService.cpp
new file mode 100644 (file)
index 0000000..dfd5a5c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 "GeolocationService.h"
+
+#include "Geoposition.h"
+#include "PositionError.h"
+#include "PositionOptions.h"
+
+namespace WebCore {
+
+#if !ENABLE(GEOLOCATION)
+GeolocationService* GeolocationService::create(GeolocationServiceClient*)
+{
+    return 0;
+}
+#endif
+
+GeolocationService::GeolocationService(GeolocationServiceClient* client)
+    : m_geolocationServiceClient(client)
+{
+    ASSERT(m_geolocationServiceClient);
+}
+
+void GeolocationService::positionChanged()
+{
+    m_geolocationServiceClient->geolocationServicePositionChanged(this);
+}
+
+void GeolocationService::errorOccurred()
+{
+    m_geolocationServiceClient->geolocationServiceErrorOccurred(this);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/GeolocationService.h b/WebCore/platform/GeolocationService.h
new file mode 100644 (file)
index 0000000..4356c90
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 GeolocationService_h
+#define GeolocationService_h
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class GeolocationService;
+class Geoposition;
+class PositionError;
+class PositionOptions;
+
+class GeolocationServiceClient {
+public:
+    virtual ~GeolocationServiceClient() { }
+    virtual void geolocationServicePositionChanged(GeolocationService*) { }
+    virtual void geolocationServiceErrorOccurred(GeolocationService*) { }
+};
+
+class GeolocationService : public Noncopyable {
+public:
+    static GeolocationService* create(GeolocationServiceClient*);
+    virtual ~GeolocationService() {}
+    
+    virtual bool startUpdating(PositionOptions*) { return false; }
+    virtual void stopUpdating() {}
+    
+    virtual Geoposition* lastPosition() const { return 0; }
+    virtual PositionError* lastError() const { return 0; }
+
+    void positionChanged();
+    void errorOccurred();
+
+protected:
+    GeolocationService(GeolocationServiceClient*);
+
+private:
+    GeolocationServiceClient* m_geolocationServiceClient;
+};
+    
+} // namespace WebCore
+
+#endif // GeolocationService_h