Skip to content

Commit 1912fbf

Browse files
authored
browser(webkit): simulate device orientation events (#1851)
* Enable orientation events * browser(webkit): simulate device orientation events
1 parent cf415bb commit 1912fbf

File tree

3 files changed

+92
-22
lines changed

3 files changed

+92
-22
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1197
1+
1198

browser_patches/webkit/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ build_gtk() {
99
if ! [[ -d ./WebKitBuild/GTK/DependenciesGTK ]]; then
1010
yes | WEBKIT_JHBUILD=1 WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/GTK DEBIAN_FRONTEND=noninteractive ./Tools/Scripts/update-webkitgtk-libs
1111
fi
12-
WEBKIT_JHBUILD=1 WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/GTK ./Tools/Scripts/build-webkit --gtk --release --touch-events MiniBrowser
12+
WEBKIT_JHBUILD=1 WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/GTK ./Tools/Scripts/build-webkit --gtk --release --touch-events --orientation-events MiniBrowser
1313
}
1414

1515
build_wpe() {
1616
if ! [[ -d ./WebKitBuild/WPE/DependenciesWPE ]]; then
1717
yes | WEBKIT_JHBUILD=1 WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/WPE DEBIAN_FRONTEND=noninteractive ./Tools/Scripts/update-webkitwpe-libs
1818
fi
19-
WEBKIT_JHBUILD=1 WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/WPE ./Tools/Scripts/build-webkit --wpe --release --touch-events MiniBrowser
19+
WEBKIT_JHBUILD=1 WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/WPE ./Tools/Scripts/build-webkit --wpe --release --touch-events --orientation-events MiniBrowser
2020
}
2121

2222
if [[ "$(uname)" == "Darwin" ]]; then
2323
cd "checkout"
24-
./Tools/Scripts/build-webkit --release --touch-events
24+
./Tools/Scripts/build-webkit --release --touch-events --orientation-events
2525
elif [[ "$(uname)" == "Linux" ]]; then
2626
cd "checkout"
2727
if [[ $# == 0 ]]; then

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 88 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ index 777a54166ed6664561b3f8249a6abb4ac59d0480..e738f34f65fa8137a16bf7b66bc237b8
836836
"name": "webSocketWillSendHandshakeRequest",
837837
"description": "Fired when WebSocket is about to initiate handshake.",
838838
diff --git a/Source/JavaScriptCore/inspector/protocol/Page.json b/Source/JavaScriptCore/inspector/protocol/Page.json
839-
index 78980810141a9e9b65b93e6cebe80daff9a52dc1..4b25429daecf6743e2a52966e64a23e0257d505a 100644
839+
index 78980810141a9e9b65b93e6cebe80daff9a52dc1..4818c82fff8b19e060e129275ef5f95f1db2fcb0 100644
840840
--- a/Source/JavaScriptCore/inspector/protocol/Page.json
841841
+++ b/Source/JavaScriptCore/inspector/protocol/Page.json
842842
@@ -109,6 +109,41 @@
@@ -925,7 +925,7 @@ index 78980810141a9e9b65b93e6cebe80daff9a52dc1..4b25429daecf6743e2a52966e64a23e0
925925
{
926926
"name": "snapshotNode",
927927
"description": "Capture a snapshot of the specified node that does not include unrelated layers.",
928-
@@ -282,19 +341,78 @@
928+
@@ -282,19 +341,85 @@
929929
"returns": [
930930
{ "name": "data", "type": "string", "description": "Base64-encoded web archive." }
931931
]
@@ -985,6 +985,13 @@ index 78980810141a9e9b65b93e6cebe80daff9a52dc1..4b25429daecf6743e2a52966e64a23e0
985985
+ "parameters": [
986986
+ { "name": "width", "type": "integer" },
987987
+ { "name": "height", "type": "integer" }
988+
+ ]
989+
+ },
990+
+ {
991+
+ "name": "setOrientationOverride",
992+
+ "description": "Overrides window.orientation with provided value.",
993+
+ "parameters": [
994+
+ { "name": "angle", "type": "integer", "optional": true }
988995
+ ]
989996
}
990997
],
@@ -1006,7 +1013,7 @@ index 78980810141a9e9b65b93e6cebe80daff9a52dc1..4b25429daecf6743e2a52966e64a23e0
10061013
]
10071014
},
10081015
{
1009-
@@ -304,6 +422,14 @@
1016+
@@ -304,6 +429,14 @@
10101017
{ "name": "frame", "$ref": "Frame", "description": "Frame object." }
10111018
]
10121019
},
@@ -1021,7 +1028,7 @@ index 78980810141a9e9b65b93e6cebe80daff9a52dc1..4b25429daecf6743e2a52966e64a23e0
10211028
{
10221029
"name": "frameDetached",
10231030
"description": "Fired when frame has been detached from its parent.",
1024-
@@ -340,12 +466,50 @@
1031+
@@ -340,12 +473,50 @@
10251032
{ "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }
10261033
]
10271034
},
@@ -3052,7 +3059,7 @@ index b038a1879c043aa17dae97425693f29be42e3258..d60716b837663004675ffd90bceede4c
30523059

30533060
} // namespace WebCore
30543061
diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
3055-
index 0e2e3c2bcc2fe167c246a5f55c4de3b52282a516..2e7900ccbb92566b4c5e33e0e7ec7c0c8e440832 100644
3062+
index 0e2e3c2bcc2fe167c246a5f55c4de3b52282a516..848df344e9a3b4b00883db8010be0de39844f3cc 100644
30563063
--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
30573064
+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
30583065
@@ -32,6 +32,8 @@
@@ -3375,7 +3382,7 @@ index 0e2e3c2bcc2fe167c246a5f55c4de3b52282a516..2e7900ccbb92566b4c5e33e0e7ec7c0c
33753382
void InspectorPageAgent::archive(ErrorString& errorString, String* data)
33763383
{
33773384
#if ENABLE(WEB_ARCHIVE) && USE(CF)
3378-
@@ -1047,4 +1167,531 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)
3385+
@@ -1047,4 +1167,538 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)
33793386
#endif
33803387
}
33813388

@@ -3905,10 +3912,17 @@ index 0e2e3c2bcc2fe167c246a5f55c4de3b52282a516..2e7900ccbb92566b4c5e33e0e7ec7c0c
39053912
+ m_inspectedPage.setOverrideScreenSize(size);
39063913
+}
39073914
+
3915+
+void InspectorPageAgent::setOrientationOverride(Inspector::ErrorString&, const int* angle)
3916+
+{
3917+
+ Optional<int> orientation;
3918+
+ if (angle)
3919+
+ orientation = *angle;
3920+
+ m_inspectedPage.setOverrideOrientation(orientation);
3921+
+}
39083922
+
39093923
} // namespace WebCore
39103924
diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h
3911-
index 6c75829502336b0806db2531e78186d2c559e44c..b2965f34e7ec1297b855ce0304adc2481baf2dc7 100644
3925+
index 6c75829502336b0806db2531e78186d2c559e44c..7b3c952fb5c8e60620d605bd2b9b4989554ae91c 100644
39123926
--- a/Source/WebCore/inspector/agents/InspectorPageAgent.h
39133927
+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h
39143928
@@ -40,11 +40,16 @@
@@ -3939,7 +3953,7 @@ index 6c75829502336b0806db2531e78186d2c559e44c..b2965f34e7ec1297b855ce0304adc248
39393953
void overrideUserAgent(ErrorString&, const String* value) override;
39403954
void overrideSetting(ErrorString&, const String& setting, const bool* value) override;
39413955
void getCookies(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::Cookie>>& cookies) override;
3942-
@@ -112,20 +119,30 @@ public:
3956+
@@ -112,20 +119,31 @@ public:
39433957
void setShowPaintRects(ErrorString&, bool show) override;
39443958
void setEmulatedMedia(ErrorString&, const String&) override;
39453959
void setForcedAppearance(ErrorString&, const String&) override;
@@ -3957,6 +3971,7 @@ index 6c75829502336b0806db2531e78186d2c559e44c..b2965f34e7ec1297b855ce0304adc248
39573971
+ void setBypassCSP(ErrorString&, bool) override;
39583972
+ void crash(ErrorString&) override;
39593973
+ void setScreenSizeOverride(ErrorString&, int width, int height) override;
3974+
+ void setOrientationOverride(Inspector::ErrorString&, const int* angle) override;
39603975

39613976
// InspectorInstrumentation
39623977
- void domContentEventFired();
@@ -3974,7 +3989,7 @@ index 6c75829502336b0806db2531e78186d2c559e44c..b2965f34e7ec1297b855ce0304adc248
39743989
void defaultAppearanceDidChange(bool useDarkAppearance);
39753990
void applyUserAgentOverride(String&);
39763991
void applyEmulatedMedia(String&);
3977-
@@ -134,6 +151,12 @@ public:
3992+
@@ -134,6 +152,12 @@ public:
39783993
void didLayout();
39793994
void didScroll();
39803995
void didRecalculateStyle();
@@ -3987,15 +4002,15 @@ index 6c75829502336b0806db2531e78186d2c559e44c..b2965f34e7ec1297b855ce0304adc248
39874002

39884003
Frame* frameForId(const String& frameId);
39894004
WEBCORE_EXPORT String frameId(Frame*);
3990-
@@ -142,6 +165,7 @@ public:
4005+
@@ -142,6 +166,7 @@ public:
39914006

39924007
private:
39934008
double timestamp();
39944009
+ void ensureUserWorldsExistInAllFrames(const Vector<DOMWrapperWorld*>&);
39954010

39964011
static bool mainResourceContent(Frame*, bool withBase64Encode, String* result);
39974012
static bool dataContent(const char* data, unsigned size, const String& textEncodingName, bool withBase64Encode, String* result);
3998-
@@ -153,18 +177,20 @@ private:
4013+
@@ -153,18 +178,20 @@ private:
39994014
RefPtr<Inspector::PageBackendDispatcher> m_backendDispatcher;
40004015

40014016
Page& m_inspectedPage;
@@ -4512,7 +4527,7 @@ index adb15dbb4c53f8d1c4957a646eff30fe8c9cc659..a596843b0779b912688c2c029cc073e6
45124527
Timer m_cursorUpdateTimer;
45134528

45144529
diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
4515-
index e6271d7e86023bce03193752805f21ee96d235fa..675ed534b6a692cd34563cac00a4e5e3d431d245 100644
4530+
index e6271d7e86023bce03193752805f21ee96d235fa..37841e631f6837bb49dc82cc4213598cb2a862c2 100644
45164531
--- a/Source/WebCore/page/Frame.cpp
45174532
+++ b/Source/WebCore/page/Frame.cpp
45184533
@@ -184,6 +184,7 @@ Frame::Frame(Page& page, HTMLFrameOwnerElement* ownerElement, UniqueRef<FrameLoa
@@ -4523,6 +4538,15 @@ index e6271d7e86023bce03193752805f21ee96d235fa..675ed534b6a692cd34563cac00a4e5e3
45234538
}
45244539

45254540
Ref<Frame> Frame::create(Page* page, HTMLFrameOwnerElement* ownerElement, UniqueRef<FrameLoaderClient>&& client)
4541+
@@ -322,7 +323,7 @@ void Frame::orientationChanged()
4542+
int Frame::orientation() const
4543+
{
4544+
if (m_page)
4545+
- return m_page->chrome().client().deviceOrientation();
4546+
+ return m_page->orientation();
4547+
return 0;
4548+
}
4549+
#endif // ENABLE(ORIENTATION_EVENTS)
45264550
diff --git a/Source/WebCore/page/FrameSnapshotting.cpp b/Source/WebCore/page/FrameSnapshotting.cpp
45274551
index 73587787f88a6ad4e4baffb0beb0b87e7782916f..88492f501e6ec9e38455dbe6fd27537bf0ee6970 100644
45284552
--- a/Source/WebCore/page/FrameSnapshotting.cpp
@@ -4578,7 +4602,7 @@ index 9c58b06f4c471130ce4815f11d14cb78f81b49a0..3d624733c36f09518b12095d91e67a2a
45784602
if (stateObjectType == StateObjectType::Push) {
45794603
frame->loader().history().pushState(WTFMove(data), title, fullURL.string());
45804604
diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
4581-
index 232fd43079726422402ae646c4fa803eb5604568..21224e5e132b1f78c40d225db24426507b4b2819 100644
4605+
index 232fd43079726422402ae646c4fa803eb5604568..2d06753c2c85c245e6a3a38385ca2efdd1f6097f 100644
45824606
--- a/Source/WebCore/page/Page.cpp
45834607
+++ b/Source/WebCore/page/Page.cpp
45844608
@@ -87,6 +87,7 @@
@@ -4589,7 +4613,7 @@ index 232fd43079726422402ae646c4fa803eb5604568..21224e5e132b1f78c40d225db2442650
45894613
#include "PlatformStrategies.h"
45904614
#include "PlugInClient.h"
45914615
#include "PluginData.h"
4592-
@@ -428,6 +429,21 @@ void Page::setOverrideViewportArguments(const Optional<ViewportArguments>& viewp
4616+
@@ -428,6 +429,37 @@ void Page::setOverrideViewportArguments(const Optional<ViewportArguments>& viewp
45934617
document->updateViewportArguments();
45944618
}
45954619

@@ -4607,29 +4631,61 @@ index 232fd43079726422402ae646c4fa803eb5604568..21224e5e132b1f78c40d225db2442650
46074631
+ if (auto* document = mainFrame().document())
46084632
+ document->updateViewportArguments();
46094633
+}
4634+
+
4635+
+#if ENABLE(ORIENTATION_EVENTS)
4636+
+int Page::orientation() const
4637+
+{
4638+
+ return m_overrideOrientation.valueOr(chrome().client().deviceOrientation());
4639+
+}
4640+
+
4641+
+void Page::setOverrideOrientation(Optional<int> orientation)
4642+
+{
4643+
+ if (orientation == m_overrideOrientation)
4644+
+ return;
4645+
+
4646+
+ m_overrideOrientation = orientation;
4647+
+ mainFrame().orientationChanged();
4648+
+}
4649+
+#endif
46104650
+
46114651
ScrollingCoordinator* Page::scrollingCoordinator()
46124652
{
46134653
if (!m_scrollingCoordinator && m_settings->scrollingCoordinatorEnabled()) {
46144654
diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h
4615-
index 0c2244aa22e4742b1b57b9f47d1649519735226d..a51827796ee3272188617cefff1d426dd3fd9131 100644
4655+
index 0c2244aa22e4742b1b57b9f47d1649519735226d..5f090a00532862204dd1bb203965424807e292af 100644
46164656
--- a/Source/WebCore/page/Page.h
46174657
+++ b/Source/WebCore/page/Page.h
46184658
@@ -187,6 +187,9 @@ public:
46194659
const Optional<ViewportArguments>& overrideViewportArguments() const { return m_overrideViewportArguments; }
46204660
WEBCORE_EXPORT void setOverrideViewportArguments(const Optional<ViewportArguments>&);
46214661

46224662
+ WEBCORE_EXPORT FloatSize screenSize();
4623-
+ WEBCORE_EXPORT void setOverrideScreenSize(Optional<FloatSize> size);
4663+
+ void setOverrideScreenSize(Optional<FloatSize> size);
46244664
+
46254665
static void refreshPlugins(bool reload);
46264666
WEBCORE_EXPORT PluginData& pluginData();
46274667
void clearPluginData();
4628-
@@ -1010,6 +1013,7 @@ private:
4668+
@@ -720,6 +723,11 @@ public:
4669+
4670+
WEBCORE_EXPORT Vector<Ref<Element>> editableElementsInRect(const FloatRect&) const;
4671+
4672+
+#if ENABLE(ORIENTATION_EVENTS)
4673+
+ int orientation() const;
4674+
+ void setOverrideOrientation(Optional<int>);
4675+
+#endif
4676+
+
4677+
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
4678+
DeviceOrientationUpdateProvider* deviceOrientationUpdateProvider() const { return m_deviceOrientationUpdateProvider.get(); }
4679+
#endif
4680+
@@ -1010,6 +1018,11 @@ private:
46294681
#endif
46304682

46314683
Optional<ViewportArguments> m_overrideViewportArguments;
46324684
+ Optional<FloatSize> m_overrideScreenSize;
4685+
+
4686+
+#if ENABLE(ORIENTATION_EVENTS)
4687+
+ Optional<int> m_overrideOrientation;
4688+
+#endif
46334689

46344690
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
46354691
RefPtr<DeviceOrientationUpdateProvider> m_deviceOrientationUpdateProvider;
@@ -12736,7 +12792,7 @@ index 22f644fd7f450d32ea45f97e27488ef5f34c153a..9ac93959568cb4561c039cc0ce7b28c4
1273612792
};
1273712793

1273812794
diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
12739-
index 543de23da89e1b74dba97aa1a3953f2cf69a4d1c..1f3483bd5d466b7a776efa5b5e1e0d3675ad5638 100644
12795+
index 543de23da89e1b74dba97aa1a3953f2cf69a4d1c..25029c335bd13396b1bc6e14fbc4e6fbc9009fb3 100644
1274012796
--- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
1274112797
+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
1274212798
@@ -409,6 +409,8 @@ void WebChromeClient::setResizable(bool resizable)
@@ -12748,6 +12804,20 @@ index 543de23da89e1b74dba97aa1a3953f2cf69a4d1c..1f3483bd5d466b7a776efa5b5e1e0d36
1274812804
// Notify the bundle client.
1274912805
m_page.injectedBundleUIClient().willAddMessageToConsole(&m_page, source, level, message, lineNumber, columnNumber, sourceID);
1275012806
}
12807+
@@ -807,6 +809,13 @@ bool WebChromeClient::canShowDataListSuggestionLabels() const
12808+
12809+
#endif
12810+
12811+
+#if ENABLE(ORIENTATION_EVENTS) && !PLATFORM(IOS_FAMILY)
12812+
+int WebChromeClient::deviceOrientation() const {
12813+
+ // Only overrides are supported for non-iOS platforms.
12814+
+ return 0;
12815+
+}
12816+
+#endif
12817+
+
12818+
void WebChromeClient::runOpenPanel(Frame& frame, FileChooser& fileChooser)
12819+
{
12820+
if (m_page.activeOpenPanelResultListener())
1275112821
diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
1275212822
index ef1c8cdbbad2ef5ada3212c851c62a149f9fea0e..142e2ffdc95646eea469c3a51e3c329be10bd57c 100644
1275312823
--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp

0 commit comments

Comments
 (0)