Modernize Geolocation code
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 17:41:59 +0000 (17:41 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 17:41:59 +0000 (17:41 +0000)
commit80bb9af80c2e0ccb3c6575b92ff4dce7c43ff1fa
treeb52782c11a89761116c068fa98b6bfd14c5f83b0
parent152248f5578aa99148300f50897298dd43a5c0b4
Modernize Geolocation code
https://bugs.webkit.org/show_bug.cgi?id=178148

Reviewed by Ryosuke Niwa.

Source/WebCore:

Modernize Geolocation code:
- Use std::optional<> instead of separate boolean members
- Make GeolocationPosition a simple struct that can be passed via IPC
- Replace WebGeolocationPosition::Data with GeolocationPosition
- Move logic to construct a GeolocationPosition from a CLLocation on iOS
  in one place to avoid code duplication.

* Modules/geolocation/Coordinates.cpp:
(WebCore::Coordinates::Coordinates):
* Modules/geolocation/Coordinates.h:
(WebCore::Coordinates::create):
(WebCore::Coordinates::isolatedCopy const):
(WebCore::Coordinates::latitude const):
(WebCore::Coordinates::longitude const):
(WebCore::Coordinates::altitude const):
(WebCore::Coordinates::accuracy const):
(WebCore::Coordinates::altitudeAccuracy const):
(WebCore::Coordinates::heading const):
(WebCore::Coordinates::speed const):
* Modules/geolocation/Geolocation.cpp:
(WebCore::createGeoposition):
(WebCore::Geolocation::lastPosition):
* Modules/geolocation/GeolocationClient.h:
* Modules/geolocation/GeolocationController.cpp:
(WebCore::GeolocationController::positionChanged):
(WebCore::GeolocationController::lastPosition):
* Modules/geolocation/GeolocationController.h:
* Modules/geolocation/GeolocationPosition.h:
(WebCore::GeolocationPosition::GeolocationPosition):
The default constructor is only needed by our IPC decoding code.

(WebCore::GeolocationPosition::encode const):
(WebCore::GeolocationPosition::decode):
* Modules/geolocation/ios/GeolocationPositionIOS.mm: Copied from Source/WebCore/Modules/geolocation/Coordinates.cpp.
(WebCore::GeolocationPosition::GeolocationPosition):
* WebCore.xcodeproj/project.pbxproj:
* platform/mock/GeolocationClientMock.cpp:
(WebCore::GeolocationClientMock::lastPosition):
(WebCore::GeolocationClientMock::controllerTimerFired):
* platform/mock/GeolocationClientMock.h:

Source/WebKit:

* Shared/WebGeolocationPosition.cpp:
(WebKit::WebGeolocationPosition::create):
(WebKit::WebGeolocationPosition::~WebGeolocationPosition):
* Shared/WebGeolocationPosition.h:
(WebKit::WebGeolocationPosition::timestamp const):
(WebKit::WebGeolocationPosition::latitude const):
(WebKit::WebGeolocationPosition::longitude const):
(WebKit::WebGeolocationPosition::accuracy const):
(WebKit::WebGeolocationPosition::altitude const):
(WebKit::WebGeolocationPosition::altitudeAccuracy const):
(WebKit::WebGeolocationPosition::heading const):
(WebKit::WebGeolocationPosition::speed const):
(WebKit::WebGeolocationPosition::corePosition const):
(WebKit::WebGeolocationPosition::WebGeolocationPosition):
* UIProcess/API/C/WKGeolocationPosition.cpp:
(WKGeolocationPositionCreate_b):
* UIProcess/API/Cocoa/_WKGeolocationPosition.mm:
(WebKit::wrapper):
* UIProcess/API/glib/WebKitGeolocationProvider.cpp:
(WebKit::WebKitGeolocationProvider::notifyPositionChanged):
* UIProcess/WebGeolocationManagerProxy.cpp:
(WebKit::WebGeolocationManagerProxy::providerDidChangePosition):
* UIProcess/ios/WKGeolocationProviderIOS.mm:
(-[WKLegacyCoreLocationProvider positionChanged:]):
* WebProcess/Geolocation/WebGeolocationManager.cpp:
(WebKit::WebGeolocationManager::didChangePosition):
* WebProcess/Geolocation/WebGeolocationManager.h:
* WebProcess/Geolocation/WebGeolocationManager.messages.in:
* WebProcess/WebCoreSupport/WebGeolocationClient.cpp:
(WebKit::WebGeolocationClient::lastPosition):
* WebProcess/WebCoreSupport/WebGeolocationClient.h:

Source/WebKitLegacy/ios:

* Misc/WebGeolocationCoreLocationProvider.h:
* Misc/WebGeolocationCoreLocationProvider.mm:
(-[WebGeolocationCoreLocationProvider sendLocation:]):
* Misc/WebGeolocationProviderIOS.mm:
(-[_WebCoreLocationUpdateThreadingProxy positionChanged:]):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebGeolocationClient.h:
* WebCoreSupport/WebGeolocationClient.mm:
(WebGeolocationClient::lastPosition):
* WebView/WebGeolocationPosition.mm:
(-[WebGeolocationPositionInternal initWithCoreGeolocationPosition:]):
(core):
(-[WebGeolocationPosition initWithTimestamp:latitude:longitude:accuracy:]):
(-[WebGeolocationPosition initWithGeolocationPosition:]):
* WebView/WebGeolocationPositionInternal.h:

Source/WebKitLegacy/win:

* WebCoreSupport/WebGeolocationClient.cpp:
(WebGeolocationClient::lastPosition):
* WebCoreSupport/WebGeolocationClient.h:
* WebGeolocationPosition.cpp:
(WebGeolocationPosition::initWithTimestamp):
(core):
* WebGeolocationPosition.h:
(WebGeolocationPosition::impl const):

Tools:

* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setMockGeolocationPosition):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/geolocation/Coordinates.cpp
Source/WebCore/Modules/geolocation/Coordinates.h
Source/WebCore/Modules/geolocation/Geolocation.cpp
Source/WebCore/Modules/geolocation/GeolocationClient.h
Source/WebCore/Modules/geolocation/GeolocationController.cpp
Source/WebCore/Modules/geolocation/GeolocationController.h
Source/WebCore/Modules/geolocation/GeolocationPosition.h
Source/WebCore/Modules/geolocation/ios/GeolocationPositionIOS.mm [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mock/GeolocationClientMock.cpp
Source/WebCore/platform/mock/GeolocationClientMock.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebGeolocationPosition.cpp
Source/WebKit/Shared/WebGeolocationPosition.h
Source/WebKit/UIProcess/API/C/WKGeolocationPosition.cpp
Source/WebKit/UIProcess/API/Cocoa/_WKGeolocationPosition.mm
Source/WebKit/UIProcess/API/glib/WebKitGeolocationProvider.cpp
Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp
Source/WebKit/UIProcess/ios/WKGeolocationProviderIOS.mm
Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp
Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.h
Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.messages.in
Source/WebKit/WebProcess/WebCoreSupport/WebGeolocationClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebGeolocationClient.h
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/Misc/WebGeolocationCoreLocationProvider.h
Source/WebKitLegacy/ios/Misc/WebGeolocationCoreLocationProvider.mm
Source/WebKitLegacy/ios/Misc/WebGeolocationProviderIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebGeolocationClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebGeolocationClient.mm
Source/WebKitLegacy/mac/WebView/WebGeolocationPosition.mm
Source/WebKitLegacy/mac/WebView/WebGeolocationPositionInternal.h
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebGeolocationClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebGeolocationClient.h
Source/WebKitLegacy/win/WebGeolocationPosition.cpp
Source/WebKitLegacy/win/WebGeolocationPosition.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/TestRunnerMac.mm