Skip to content

Commit e096cef

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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@223211 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fd30e0e commit e096cef

27 files changed

+208
-18
lines changed

LayoutTests/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2017-10-11 Chris Dumez <[email protected]>
2+
3+
[Geolocation] Expose Coordinates.floorLevel
4+
https://bugs.webkit.org/show_bug.cgi?id=178173
5+
<rdar://problem/34918936>
6+
7+
Reviewed by Ryosuke Niwa.
8+
9+
Add layout test coverage.
10+
11+
* fast/dom/Geolocation/floorLevel-expected.txt: Added.
12+
* fast/dom/Geolocation/floorLevel.html: Added.
13+
114
2017-10-11 Simon Fraser <[email protected]>
215

316
Avoid triggering layout from style change
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Tests support for Geolocation's floorLevel
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
PASS coords.latitude is mockLatitude
7+
PASS coords.longitude is mockLongitude
8+
PASS coords.accuracy is mockAccuracy
9+
PASS coords.altitude is mockAltitude
10+
PASS coords.altitudeAccuracy is mockAltitudeAccuracy
11+
PASS coords.heading is mockHeading
12+
PASS coords.speed is mockSpeed
13+
PASS coords.floorLevel is mockFloorLevel
14+
PASS successfullyParsed is true
15+
16+
TEST COMPLETE
17+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<script src="../../../resources/js-test.js"></script>
5+
<script>
6+
description("Tests support for Geolocation's floorLevel");
7+
jsTestIsAsync = true;
8+
9+
const mockLatitude = 51.478;
10+
const mockLongitude = -0.166;
11+
const mockAccuracy = 100.0;
12+
const mockAltitude = 10.1;
13+
const mockAltitudeAccuracy = 0.1;
14+
const mockHeading = 223.3;
15+
const mockSpeed = 123.4;
16+
const mockFloorLevel = 3;
17+
18+
if (window.testRunner) {
19+
testRunner.setGeolocationPermission(true);
20+
testRunner.setMockGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy, mockAltitude, mockAltitudeAccuracy, mockHeading, mockSpeed, mockFloorLevel);
21+
}
22+
23+
function checkPosition(position) {
24+
coords = position.coords;
25+
shouldBe("coords.latitude", "mockLatitude");
26+
shouldBe("coords.longitude", "mockLongitude");
27+
shouldBe("coords.accuracy", "mockAccuracy");
28+
shouldBe("coords.altitude", "mockAltitude");
29+
shouldBe("coords.altitudeAccuracy", "mockAltitudeAccuracy");
30+
shouldBe("coords.heading", "mockHeading");
31+
shouldBe("coords.speed", "mockSpeed");
32+
shouldBe("coords.floorLevel", "mockFloorLevel");
33+
finishJSTest();
34+
}
35+
36+
navigator.geolocation.getCurrentPosition(checkPosition);
37+
</script>
38+
</body>
39+
</html>

Source/WebCore/ChangeLog

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2017-10-11 Chris Dumez <[email protected]>
2+
3+
[Geolocation] Expose Coordinates.floorLevel
4+
https://bugs.webkit.org/show_bug.cgi?id=178173
5+
<rdar://problem/34918936>
6+
7+
Reviewed by Ryosuke Niwa.
8+
9+
Expose Coordinates.floorLevel via the Geolocation API. This is currently
10+
a WebKit-specific extension and it is only populated on iOS / WKTR / DRT.
11+
It is null on other platforms.
12+
13+
Test: fast/dom/Geolocation/floorLevel.html
14+
15+
* Modules/geolocation/Coordinates.h:
16+
(WebCore::Coordinates::floorLevel const):
17+
* Modules/geolocation/Coordinates.idl:
18+
* Modules/geolocation/GeolocationPosition.h:
19+
(WebCore::GeolocationPosition::encode const):
20+
(WebCore::GeolocationPosition::decode):
21+
* Modules/geolocation/ios/GeolocationPositionIOS.mm:
22+
(WebCore::GeolocationPosition::GeolocationPosition):
23+
* page/Settings.in:
24+
125
2017-10-11 Simon Fraser <[email protected]>
226

327
Avoid triggering layout from style change

Source/WebCore/Modules/geolocation/Coordinates.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Coordinates : public RefCounted<Coordinates> {
5151
std::optional<double> altitudeAccuracy() const { return m_position.altitudeAccuracy; }
5252
std::optional<double> heading() const { return m_position.heading; }
5353
std::optional<double> speed() const { return m_position.speed; }
54+
std::optional<double> floorLevel() const { return m_position.floorLevel; }
5455

5556
private:
5657
explicit Coordinates(GeolocationPosition&&);

Source/WebCore/Modules/geolocation/Coordinates.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
readonly attribute unrestricted double? altitudeAccuracy;
3636
readonly attribute unrestricted double? heading;
3737
readonly attribute unrestricted double? speed;
38+
[EnabledBySetting=GeolocationFloorLevel] readonly attribute unrestricted double? floorLevel;
3839
};

Source/WebCore/Modules/geolocation/GeolocationPosition.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class GeolocationPosition {
6262
std::optional<double> altitudeAccuracy;
6363
std::optional<double> heading;
6464
std::optional<double> speed;
65+
std::optional<double> floorLevel;
6566

6667
bool isValid() const;
6768

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

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

105109
return true;
106110
}

Source/WebCore/Modules/geolocation/ios/GeolocationPositionIOS.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
speed = location.speed;
4747
if (location.course >= 0.0)
4848
heading = location.course;
49+
if (location.floor)
50+
floorLevel = location.floor.level;
4951
}
5052

5153
}

Source/WebCore/page/Settings.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ linkPreconnectEnabled initial=false
295295

296296
beaconAPIEnabled initial=false
297297

298+
geolocationFloorLevelEnabled initial=true
299+
298300
constantPropertiesEnabled initial=false
299301

300302
viewportFitEnabled initial=false

Source/WebKit/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2017-10-11 Chris Dumez <[email protected]>
2+
3+
[Geolocation] Expose Coordinates.floorLevel
4+
https://bugs.webkit.org/show_bug.cgi?id=178173
5+
<rdar://problem/34918936>
6+
7+
Reviewed by Ryosuke Niwa.
8+
9+
* UIProcess/API/C/WKGeolocationPosition.cpp:
10+
(WKGeolocationPositionCreate):
11+
(WKGeolocationPositionCreate_b):
12+
(WKGeolocationPositionCreate_c):
13+
* UIProcess/API/C/WKGeolocationPosition.h:
14+
115
2017-10-11 Youenn Fablet <[email protected]>
216

317
Bump default cache storage quota to 20MB

0 commit comments

Comments
 (0)