Skip to content
Permalink
Browse files
[Geolocation] Expose Coordinates.floorLevel
https://bugs.webkit.org/show_bug.cgi?id=178173
<rdar://problem/34918936>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Expose Coordinates.floorLevel via the Geolocation API. This is currently
a WebKit-specific extension and it is only populated on iOS / WKTR / DRT.
It is null on other platforms.

Test: fast/dom/Geolocation/floorLevel.html

* Modules/geolocation/Coordinates.h:
(WebCore::Coordinates::floorLevel const):
* Modules/geolocation/Coordinates.idl:
* Modules/geolocation/GeolocationPosition.h:
(WebCore::GeolocationPosition::encode const):
(WebCore::GeolocationPosition::decode):
* Modules/geolocation/ios/GeolocationPositionIOS.mm:
(WebCore::GeolocationPosition::GeolocationPosition):
* page/Settings.in:

Source/WebKit:

* UIProcess/API/C/WKGeolocationPosition.cpp:
(WKGeolocationPositionCreate):
(WKGeolocationPositionCreate_b):
(WKGeolocationPositionCreate_c):
* UIProcess/API/C/WKGeolocationPosition.h:

Tools:

Add test infrastructure for testing Coordinates.floorLevel.

* DumpRenderTree/TestRunner.cpp:
(setMockGeolocationPositionCallback):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/GeolocationProviderMock.cpp:
(WTR::GeolocationProviderMock::setPosition):
* WebKitTestRunner/GeolocationProviderMock.h:
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setMockGeolocationPosition):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

Add layout test coverage.

* fast/dom/Geolocation/floorLevel-expected.txt: Added.
* fast/dom/Geolocation/floorLevel.html: Added.

Canonical link: https://commits.webkit.org/194440@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223211 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Oct 11, 2017
1 parent 77bd764 commit da1e84f8604cb1719985fc446d1761eca2d2b133
Showing 27 changed files with 208 additions and 18 deletions.
@@ -1,3 +1,16 @@
2017-10-11 Chris Dumez <cdumez@apple.com>

[Geolocation] Expose Coordinates.floorLevel
https://bugs.webkit.org/show_bug.cgi?id=178173
<rdar://problem/34918936>

Reviewed by Ryosuke Niwa.

Add layout test coverage.

* fast/dom/Geolocation/floorLevel-expected.txt: Added.
* fast/dom/Geolocation/floorLevel.html: Added.

2017-10-11 Simon Fraser <simon.fraser@apple.com>

Avoid triggering layout from style change
@@ -0,0 +1,17 @@
Tests support for Geolocation's floorLevel

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS coords.latitude is mockLatitude
PASS coords.longitude is mockLongitude
PASS coords.accuracy is mockAccuracy
PASS coords.altitude is mockAltitude
PASS coords.altitudeAccuracy is mockAltitudeAccuracy
PASS coords.heading is mockHeading
PASS coords.speed is mockSpeed
PASS coords.floorLevel is mockFloorLevel
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<body>
<script src="../../../resources/js-test.js"></script>
<script>
description("Tests support for Geolocation's floorLevel");
jsTestIsAsync = true;

const mockLatitude = 51.478;
const mockLongitude = -0.166;
const mockAccuracy = 100.0;
const mockAltitude = 10.1;
const mockAltitudeAccuracy = 0.1;
const mockHeading = 223.3;
const mockSpeed = 123.4;
const mockFloorLevel = 3;

if (window.testRunner) {
testRunner.setGeolocationPermission(true);
testRunner.setMockGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy, mockAltitude, mockAltitudeAccuracy, mockHeading, mockSpeed, mockFloorLevel);
}

function checkPosition(position) {
coords = position.coords;
shouldBe("coords.latitude", "mockLatitude");
shouldBe("coords.longitude", "mockLongitude");
shouldBe("coords.accuracy", "mockAccuracy");
shouldBe("coords.altitude", "mockAltitude");
shouldBe("coords.altitudeAccuracy", "mockAltitudeAccuracy");
shouldBe("coords.heading", "mockHeading");
shouldBe("coords.speed", "mockSpeed");
shouldBe("coords.floorLevel", "mockFloorLevel");
finishJSTest();
}

navigator.geolocation.getCurrentPosition(checkPosition);
</script>
</body>
</html>
@@ -1,3 +1,27 @@
2017-10-11 Chris Dumez <cdumez@apple.com>

[Geolocation] Expose Coordinates.floorLevel
https://bugs.webkit.org/show_bug.cgi?id=178173
<rdar://problem/34918936>

Reviewed by Ryosuke Niwa.

Expose Coordinates.floorLevel via the Geolocation API. This is currently
a WebKit-specific extension and it is only populated on iOS / WKTR / DRT.
It is null on other platforms.

Test: fast/dom/Geolocation/floorLevel.html

* Modules/geolocation/Coordinates.h:
(WebCore::Coordinates::floorLevel const):
* Modules/geolocation/Coordinates.idl:
* Modules/geolocation/GeolocationPosition.h:
(WebCore::GeolocationPosition::encode const):
(WebCore::GeolocationPosition::decode):
* Modules/geolocation/ios/GeolocationPositionIOS.mm:
(WebCore::GeolocationPosition::GeolocationPosition):
* page/Settings.in:

2017-10-11 Simon Fraser <simon.fraser@apple.com>

Avoid triggering layout from style change
@@ -51,6 +51,7 @@ class Coordinates : public RefCounted<Coordinates> {
std::optional<double> altitudeAccuracy() const { return m_position.altitudeAccuracy; }
std::optional<double> heading() const { return m_position.heading; }
std::optional<double> speed() const { return m_position.speed; }
std::optional<double> floorLevel() const { return m_position.floorLevel; }

private:
explicit Coordinates(GeolocationPosition&&);
@@ -35,4 +35,5 @@
readonly attribute unrestricted double? altitudeAccuracy;
readonly attribute unrestricted double? heading;
readonly attribute unrestricted double? speed;
[EnabledBySetting=GeolocationFloorLevel] readonly attribute unrestricted double? floorLevel;
};
@@ -62,6 +62,7 @@ class GeolocationPosition {
std::optional<double> altitudeAccuracy;
std::optional<double> heading;
std::optional<double> speed;
std::optional<double> floorLevel;

bool isValid() const;

@@ -80,6 +81,7 @@ void GeolocationPosition::encode(Encoder& encoder) const
encoder << altitudeAccuracy;
encoder << heading;
encoder << speed;
encoder << floorLevel;
}

template<class Decoder>
@@ -101,6 +103,8 @@ bool GeolocationPosition::decode(Decoder& decoder, GeolocationPosition& position
return false;
if (!decoder.decode(position.speed))
return false;
if (!decoder.decode(position.floorLevel))
return false;

return true;
}
@@ -46,6 +46,8 @@
speed = location.speed;
if (location.course >= 0.0)
heading = location.course;
if (location.floor)
floorLevel = location.floor.level;
}

}
@@ -295,6 +295,8 @@ linkPreconnectEnabled initial=false

beaconAPIEnabled initial=false

geolocationFloorLevelEnabled initial=true

constantPropertiesEnabled initial=false

viewportFitEnabled initial=false
@@ -1,3 +1,17 @@
2017-10-11 Chris Dumez <cdumez@apple.com>

[Geolocation] Expose Coordinates.floorLevel
https://bugs.webkit.org/show_bug.cgi?id=178173
<rdar://problem/34918936>

Reviewed by Ryosuke Niwa.

* UIProcess/API/C/WKGeolocationPosition.cpp:
(WKGeolocationPositionCreate):
(WKGeolocationPositionCreate_b):
(WKGeolocationPositionCreate_c):
* UIProcess/API/C/WKGeolocationPosition.h:

2017-10-11 Youenn Fablet <youenn@apple.com>

Bump default cache storage quota to 20MB
@@ -38,10 +38,15 @@ WKTypeID WKGeolocationPositionGetTypeID()

WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy)
{
return WKGeolocationPositionCreate_b(timestamp, latitude, longitude, accuracy, false, 0., false, 0., false, 0., false, 0.);
return WKGeolocationPositionCreate_c(timestamp, latitude, longitude, accuracy, false, 0., false, 0., false, 0., false, 0., false, 0.);
}

WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
{
return WKGeolocationPositionCreate_c(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed, false, 0.);
}

WKGeolocationPositionRef WKGeolocationPositionCreate_c(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel)
{
WebCore::GeolocationPosition corePosition { timestamp, latitude, longitude, accuracy };
if (providesAltitude)
@@ -52,6 +57,8 @@ WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double
corePosition.heading = heading;
if (providesSpeed)
corePosition.speed = speed;
if (providesFloorLevel)
corePosition.floorLevel = floorLevel;

auto position = WebGeolocationPosition::create(WTFMove(corePosition));
return toAPI(&position.leakRef());
@@ -36,6 +36,7 @@ WK_EXPORT WKTypeID WKGeolocationPositionGetTypeID();

WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy);
WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate_c(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel);

#ifdef __cplusplus
}
@@ -1,3 +1,36 @@
2017-10-11 Chris Dumez <cdumez@apple.com>

[Geolocation] Expose Coordinates.floorLevel
https://bugs.webkit.org/show_bug.cgi?id=178173
<rdar://problem/34918936>

Reviewed by Ryosuke Niwa.

Add test infrastructure for testing Coordinates.floorLevel.

* DumpRenderTree/TestRunner.cpp:
(setMockGeolocationPositionCallback):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setMockGeolocationPosition):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/GeolocationProviderMock.cpp:
(WTR::GeolocationProviderMock::setPosition):
* WebKitTestRunner/GeolocationProviderMock.h:
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setMockGeolocationPosition):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setMockGeolocationPosition):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

2017-10-11 Youenn Fablet <youenn@apple.com>

Bump default cache storage quota to 20MB
@@ -1019,8 +1019,15 @@ static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObj
speed = JSValueToNumber(context, arguments[6], 0);
}

bool canProvideFloorLevel = false;
double floorLevel = 0.;
if (argumentCount > 7 && !JSValueIsUndefined(context, arguments[7])) {
canProvideFloorLevel = true;
floorLevel = JSValueToNumber(context, arguments[7], 0);
}

TestRunner* controller = reinterpret_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
controller->setMockGeolocationPosition(latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed);
controller->setMockGeolocationPosition(latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed, canProvideFloorLevel, floorLevel);

return JSValueMakeUndefined(context);
}
@@ -110,7 +110,7 @@ class TestRunner : public WTR::UIScriptContextDelegate, public RefCounted<TestRu
void setAutomaticLinkDetectionEnabled(bool flag);
void setMainFrameIsFirstResponder(bool flag);
void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel);
void setMockGeolocationPositionUnavailableError(JSStringRef message);
void setPersistentUserStyleSheetLocation(JSStringRef path);
void setPluginsEnabled(bool);
@@ -442,7 +442,7 @@ static inline size_t indexOfSeparatorAfterDirectoryName(const std::string& direc
[orientation release];
}

void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel)
{
WebGeolocationPosition *position = nil;
if (!providesAltitude && !providesAltitudeAccuracy && !providesHeading && !providesSpeed) {
@@ -458,6 +458,8 @@ static inline size_t indexOfSeparatorAfterDirectoryName(const std::string& direc
geolocationPosition.heading = heading;
if (providesSpeed)
geolocationPosition.speed = speed;
if (providesFloorLevel)
geolocationPosition.floorLevel = floorLevel;
position = [[WebGeolocationPosition alloc] initWithGeolocationPosition:(WTFMove(geolocationPosition))];
}
[[MockGeolocationProvider shared] setPosition:position];
@@ -473,7 +473,7 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo
fprintf(testResult, "ERROR: TestRunner::setMockDeviceOrientation() not implemented\n");
}

void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel)
{
// FIXME: Implement for Geolocation layout tests.
// See https://bugs.webkit.org/show_bug.cgi?id=28264.
@@ -63,9 +63,9 @@ GeolocationProviderMock::~GeolocationProviderMock()
WKGeolocationManagerSetProvider(m_geolocationManager, 0);
}

void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel)
{
m_position.adopt(WKGeolocationPositionCreate_b(currentTime(), latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed));
m_position.adopt(WKGeolocationPositionCreate_c(currentTime(), latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed, providesFloorLevel, floorLevel));

m_hasError = false;
m_errorMessage.clear();
@@ -35,7 +35,7 @@ class GeolocationProviderMock {
GeolocationProviderMock(WKContextRef);
~GeolocationProviderMock();

void setPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
void setPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel);
void setPositionUnavailableError(WKStringRef errorMessage);

void startUpdating(WKGeolocationManagerRef);
@@ -189,7 +189,7 @@ interface TestRunner {

// Geolocation
void setGeolocationPermission(boolean value);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, optional object altitude, optional object altitudeAccuracy, optional object heading, optional object speed);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, optional object altitude, optional object altitudeAccuracy, optional object heading, optional object speed, optional object floorLevel);
void setMockGeolocationPositionUnavailableError(DOMString errorMessage);
boolean isGeolocationProviderActive();

@@ -538,7 +538,7 @@ void InjectedBundle::setGeolocationPermission(bool enabled)
WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
}

void InjectedBundle::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
void InjectedBundle::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel)
{
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGeolocationPosition"));

@@ -588,6 +588,14 @@ void InjectedBundle::setMockGeolocationPosition(double latitude, double longitud
WKRetainPtr<WKDoubleRef> speedWK(AdoptWK, WKDoubleCreate(speed));
WKDictionarySetItem(messageBody.get(), speedKeyWK.get(), speedWK.get());

WKRetainPtr<WKStringRef> providesFloorLevelKeyWK(AdoptWK, WKStringCreateWithUTF8CString("providesFloorLevel"));
WKRetainPtr<WKBooleanRef> providesFloorLevelWK(AdoptWK, WKBooleanCreate(providesFloorLevel));
WKDictionarySetItem(messageBody.get(), providesFloorLevelKeyWK.get(), providesFloorLevelWK.get());

WKRetainPtr<WKStringRef> floorLevelKeyWK(AdoptWK, WKStringCreateWithUTF8CString("floorLevel"));
WKRetainPtr<WKDoubleRef> floorLevelWK(AdoptWK, WKDoubleCreate(floorLevel));
WKDictionarySetItem(messageBody.get(), floorLevelKeyWK.get(), floorLevelWK.get());

WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
}

@@ -97,7 +97,7 @@ class InjectedBundle {

// Geolocation.
void setGeolocationPermission(bool);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel);
void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
bool isGeolocationProviderActive() const;

0 comments on commit da1e84f

Please sign in to comment.