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