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

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: Created 4 years, 10 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
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 "</style>"
180 "<div style='width: 300px; height: 100px;'>"
181 "<span style='background: blue; width: 50px; height: 50px; margin-left: 250px; font-size: 50px;' draggable='true'>abcd</span>"
182 "</div>");
183 PlatformMouseEvent mouseDownEvent1(
184 IntPoint(262, 29),
185 IntPoint(329, 167),
186 LeftButton,
187 PlatformEvent::MousePressed,
188 1,
189 PlatformEvent::Modifiers::LeftButtonDown,
190 WTF::monotonicallyIncreasingTime());
191 document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent1);
192
193 PlatformMouseEvent mouseMoveEvent(
194 IntPoint(618, 298),
195 IntPoint(685, 436),
196 LeftButton,
197 PlatformEvent::MouseMoved,
198 1,
199 PlatformEvent::Modifiers::LeftButtonDown,
200 WTF::monotonicallyIncreasingTime());
201 document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
202
203 EXPECT_EQ(IntPoint(12, 29), document().frame()->eventHandler().dragDataTrans ferLocationForTesting());
204 }
205
206 TEST_F(EventHandlerTest, draggedSVGImagePositionTest)
207 {
208 setHtmlInnerHTML(
209 "<style>"
210 "body { margin: 0px; }"
211 "[draggable] {"
212 "-webkit-user-select: none; user-select: none; -webkit-user-drag: elemen t; }"
213 "</style>"
214 "<div style='width: 300px; height: 100px;'>"
215 "<svg width='500' height='500'>"
216 "<rect x='100' y='100' width='100px' height='100px' fill='blue' draggabl e='true'/>"
217 "</svg>"
218 "</div>");
219 PlatformMouseEvent mouseDownEvent1(
220 IntPoint(145, 144),
221 IntPoint(212, 282),
222 LeftButton,
223 PlatformEvent::MousePressed,
224 1,
225 PlatformEvent::Modifiers::LeftButtonDown,
226 WTF::monotonicallyIncreasingTime());
227 document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent1);
228
229 PlatformMouseEvent mouseMoveEvent(
230 IntPoint(618, 298),
231 IntPoint(685, 436),
232 LeftButton,
233 PlatformEvent::MouseMoved,
234 1,
235 PlatformEvent::Modifiers::LeftButtonDown,
236 WTF::monotonicallyIncreasingTime());
237 document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent);
238
239 EXPECT_EQ(IntPoint(45, 44), document().frame()->eventHandler().dragDataTrans ferLocationForTesting());
240 }
241
174 } // namespace blink 242 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698