Commit 503f473
committed
dragend event has incorrect coordinates in a nested <iframe>
https://bugs.webkit.org/show_bug.cgi?id=308617
rdar://170750013
Reviewed by Aditya Keerthi.
The dragEnd event coordinates are off by a substantial amount while the
dragStart event coordinates are correct. This is because when WebKit
receives the end point in WebViewImpl::sendDragEndToPage from AppKit,
all WebKit does is convert this point from screen to window coordinates.
The coordinates of clientX/clientY are supposed to be in respect to
the content space of the frame that the events are on. Previously, a
frame (content space) was not specified, so after receiving screen to
window coordinates, WebKit just converts to main frame content coordinates.
To fix this issue, first do an additional step and convert from window coordinates
to WKWebView coordinates. Since AppKit gives us the end point, the drag offset does
not need to be applied in WebPage::dragEnded.
In EventHandler::dispatchEventToDragSourceElement, use the dragged element's frame
to call dispatchDragEvent. This is the frame that has the dragStart and dragEnd event.
Now, dispatchDragEvent will be on the correct frame's EventHandler.
From here, it is then converted from WKWebView
coordinates to the correct frame's content coordinates, yielding the
correct clientX/clientY.
Add an API test that checks for dragEnd coordinates when dragging within the nested iframe
as well as dragging to outside the iframe.
Update DragAndDropTests.DragSourceEndedAtCoordinateTransformation as the expected coordinates
were previously incorrect.
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::dispatchEventToDragSourceElement):
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::sendDragEndToPage):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dragEnded):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::(SiteIsolation, DragSourceEndedAtCoordinateTransformation)):
* Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
(TEST(DragAndDropTests, DragEndEventCoordinatesWithNestedIframes)):
Canonical link: https://commits.webkit.org/308216@main1 parent e869783 commit 503f473
File tree
5 files changed
+127
-16
lines changed- Source
- WebCore/page
- WebKit
- UIProcess/mac
- WebProcess/WebPage
- Tools/TestWebKitAPI/Tests
- WebKitCocoa
- mac
5 files changed
+127
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4649 | 4649 | | |
4650 | 4650 | | |
4651 | 4651 | | |
4652 | | - | |
4653 | | - | |
| 4652 | + | |
| 4653 | + | |
4654 | 4654 | | |
4655 | 4655 | | |
4656 | 4656 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4319 | 4319 | | |
4320 | 4320 | | |
4321 | 4321 | | |
4322 | | - | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
4323 | 4326 | | |
4324 | 4327 | | |
4325 | 4328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5598 | 5598 | | |
5599 | 5599 | | |
5600 | 5600 | | |
5601 | | - | |
5602 | 5601 | | |
5603 | 5602 | | |
5604 | 5603 | | |
| |||
5615 | 5614 | | |
5616 | 5615 | | |
5617 | 5616 | | |
5618 | | - | |
| 5617 | + | |
5619 | 5618 | | |
5620 | 5619 | | |
5621 | 5620 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7169 | 7169 | | |
7170 | 7170 | | |
7171 | 7171 | | |
7172 | | - | |
| 7172 | + | |
7173 | 7173 | | |
7174 | | - | |
| 7174 | + | |
7175 | 7175 | | |
7176 | | - | |
| 7176 | + | |
7177 | 7177 | | |
7178 | 7178 | | |
7179 | 7179 | | |
7180 | 7180 | | |
7181 | 7181 | | |
7182 | 7182 | | |
7183 | | - | |
7184 | | - | |
| 7183 | + | |
| 7184 | + | |
7185 | 7185 | | |
7186 | 7186 | | |
7187 | 7187 | | |
7188 | 7188 | | |
7189 | 7189 | | |
7190 | | - | |
| 7190 | + | |
7191 | 7191 | | |
7192 | 7192 | | |
7193 | 7193 | | |
| |||
7200 | 7200 | | |
7201 | 7201 | | |
7202 | 7202 | | |
7203 | | - | |
7204 | | - | |
7205 | | - | |
| 7203 | + | |
| 7204 | + | |
| 7205 | + | |
7206 | 7206 | | |
7207 | 7207 | | |
7208 | | - | |
7209 | | - | |
| 7208 | + | |
| 7209 | + | |
7210 | 7210 | | |
7211 | 7211 | | |
7212 | 7212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
63 | 172 | | |
64 | 173 | | |
65 | 174 | | |
| |||
0 commit comments