Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandlerTest.cpp

Issue 1716023002: Fix draggable elements are painted at incorrect position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove comment. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/EventHandler.h" 5 #include "core/input/EventHandler.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Range.h" 8 #include "core/dom/Range.h"
9 #include "core/editing/Editor.h" 9 #include "core/editing/Editor.h"
10 #include "core/editing/FrameSelection.h" 10 #include "core/editing/FrameSelection.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 document().frame()->eventHandler().handleGestureEvent(doubleTapEvent); 164 document().frame()->eventHandler().handleGestureEvent(doubleTapEvent);
165 ASSERT_TRUE(selection.isCaret()); 165 ASSERT_TRUE(selection.isCaret());
166 EXPECT_EQ(Position(line, 0), selection.start()); 166 EXPECT_EQ(Position(line, 0), selection.start());
167 167
168 TapEventBuilder tripleTapEvent(IntPoint(0, 0), 3); 168 TapEventBuilder tripleTapEvent(IntPoint(0, 0), 3);
169 document().frame()->eventHandler().handleGestureEvent(tripleTapEvent); 169 document().frame()->eventHandler().handleGestureEvent(tripleTapEvent);
170 ASSERT_TRUE(selection.isCaret()); 170 ASSERT_TRUE(selection.isCaret());
171 EXPECT_EQ(Position(line, 0), selection.start()); 171 EXPECT_EQ(Position(line, 0), selection.start());
172 } 172 }
173 173
174 TEST_F(EventHandlerTest, draggedInlinePositionTest)
175 {
176 setHtmlInnerHTML(
177 "<style>"
178 "body { margin: 0px; }"
179 ".line { font-family: sans-serif; background: blue; width: 300px; height : 30px; font-size: 40px; margin-left: 250px; }"
180 "</style>"
181 "<div style='width: 300px; height: 100px;'>"
182 "<span class='line' draggable='true'>abcd</span>"
183 "</div>");
184 PlatformMouseEvent mouseDownEvent1(
185 IntPoint(262, 29),
186 IntPoint(329, 67),
187 LeftButton,
188 PlatformEvent::MousePressed,
189 1,
190 PlatformEvent::Modifiers::LeftButtonDown,
191 WTF::monotonicallyIncreasingTime());
192 document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent1);
193
194 PlatformMouseEvent mouseMoveEvent(
195 IntPoint(618, 298),
196 IntPoint(685, 436),
197 LeftButton,
198 PlatformEvent::MouseMoved,
199 1,
200 PlatformEvent::Modifiers::LeftButtonDown,
201 WTF::monotonicallyIncreasingTime());
202 document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
203
204 EXPECT_EQ(IntPoint(12, 29), document().frame()->eventHandler().dragDataTrans ferLocationForTesting());
205 }
206
207 TEST_F(EventHandlerTest, draggedSVGImagePositionTest)
208 {
209 setHtmlInnerHTML(
210 "<style>"
211 "body { margin: 0px; }"
212 "[draggable] {"
213 "-webkit-user-select: none; user-select: none; -webkit-user-drag: elemen t; }"
214 "</style>"
215 "<div style='width: 300px; height: 100px;'>"
216 "<svg width='500' height='500'>"
217 "<rect x='100' y='100' width='100px' height='100px' fill='blue' draggabl e='true'/>"
218 "</svg>"
219 "</div>");
220 PlatformMouseEvent mouseDownEvent1(
221 IntPoint(145, 144),
222 IntPoint(212, 282),
223 LeftButton,
224 PlatformEvent::MousePressed,
225 1,
226 PlatformEvent::Modifiers::LeftButtonDown,
227 WTF::monotonicallyIncreasingTime());
228 document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent1);
229
230 PlatformMouseEvent mouseMoveEvent(
231 IntPoint(618, 298),
232 IntPoint(685, 436),
233 LeftButton,
234 PlatformEvent::MouseMoved,
235 1,
236 PlatformEvent::Modifiers::LeftButtonDown,
237 WTF::monotonicallyIncreasingTime());
238 document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
239
240 EXPECT_EQ(IntPoint(45, 44), document().frame()->eventHandler().dragDataTrans ferLocationForTesting());
241 }
242
174 } // namespace blink 243 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698