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

Side by Side Diff: sky/engine/core/page/EventHandler.cpp

Issue 873963003: Remove more mouse-specific code (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Build fixes Created 5 years, 11 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 *m_maxDuration = max(*m_maxDuration, monotonicallyIncreasingTime() - m_s tart); 114 *m_maxDuration = max(*m_maxDuration, monotonicallyIncreasingTime() - m_s tart);
115 } 115 }
116 116
117 private: 117 private:
118 double* m_maxDuration; 118 double* m_maxDuration;
119 double m_start; 119 double m_start;
120 }; 120 };
121 121
122 EventHandler::EventHandler(LocalFrame* frame) 122 EventHandler::EventHandler(LocalFrame* frame)
123 : m_frame(frame) 123 : m_frame(frame)
124 , m_mousePressed(false)
125 , m_capturesDragging(false) 124 , m_capturesDragging(false)
126 , m_mouseDownMayStartSelect(false)
127 , m_mouseDownMayStartDrag(false)
128 , m_selectionInitiationState(HaveNotStartedSelection) 125 , m_selectionInitiationState(HaveNotStartedSelection)
129 , m_hoverTimer(this, &EventHandler::hoverTimerFired)
130 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) 126 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired)
131 , m_mouseDownMayStartAutoscroll(false)
132 , m_clickCount(0) 127 , m_clickCount(0)
133 , m_shouldOnlyFireDragOverEvent(false) 128 , m_shouldOnlyFireDragOverEvent(false)
134 , m_mousePositionIsUnknown(true)
135 , m_maxMouseMovedDuration(0)
136 , m_didStartDrag(false) 129 , m_didStartDrag(false)
137 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 130 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
138 , m_lastShowPressTimestamp(0) 131 , m_lastShowPressTimestamp(0)
139 { 132 {
140 } 133 }
141 134
142 EventHandler::~EventHandler() 135 EventHandler::~EventHandler()
143 { 136 {
144 } 137 }
145 138
146 void EventHandler::clear() 139 void EventHandler::clear()
147 { 140 {
148 m_hoverTimer.stop();
149 m_cursorUpdateTimer.stop(); 141 m_cursorUpdateTimer.stop();
150 m_activeIntervalTimer.stop(); 142 m_activeIntervalTimer.stop();
151 m_nodeUnderMouse = nullptr;
152 m_lastNodeUnderMouse = nullptr;
153 m_lastScrollbarUnderMouse = nullptr;
154 m_clickCount = 0; 143 m_clickCount = 0;
155 m_clickNode = nullptr; 144 m_clickNode = nullptr;
156 m_dragTarget = nullptr; 145 m_dragTarget = nullptr;
157 m_shouldOnlyFireDragOverEvent = false; 146 m_shouldOnlyFireDragOverEvent = false;
158 m_mousePositionIsUnknown = true;
159 m_lastKnownMousePosition = IntPoint();
160 m_lastKnownMouseGlobalPosition = IntPoint();
161 m_mousePressNode = nullptr;
162 m_mousePressed = false;
163 m_capturesDragging = false; 147 m_capturesDragging = false;
164 m_previousWheelScrolledNode = nullptr;
165 m_maxMouseMovedDuration = 0;
166 m_didStartDrag = false; 148 m_didStartDrag = false;
167 m_mouseDownMayStartSelect = false;
168 m_mouseDownMayStartDrag = false;
169 m_lastShowPressTimestamp = 0; 149 m_lastShowPressTimestamp = 0;
170 m_lastDeferredTapElement = nullptr; 150 m_lastDeferredTapElement = nullptr;
171 } 151 }
172 152
173 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) 153 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
174 { 154 {
175 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) 155 if (!nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get()))
176 return; 156 return;
177 if (nodeToBeRemoved.isInShadowTree()) { 157 if (nodeToBeRemoved.isInShadowTree()) {
178 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); 158 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode();
179 } else { 159 } else {
180 // We don't dispatch click events if the mousedown node is removed 160 // We don't dispatch click events if the mousedown node is removed
181 // before a mouseup event. It is compatible with IE and Firefox. 161 // before a mouseup event. It is compatible with IE and Firefox.
182 m_clickNode = nullptr; 162 m_clickNode = nullptr;
183 } 163 }
184 } 164 }
185 165
186 static inline bool dispatchSelectStart(Node* node)
187 {
188 if (!node || !node->renderer())
189 return true;
190
191 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel ectstart));
192 }
193
194 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection)
195 {
196 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode);
197 if (!rootUserSelectAll)
198 return selection;
199
200 VisibleSelection newSelection(selection);
201 newSelection.setBase(positionBeforeNode(rootUserSelectAll).upstream(CanCross EditingBoundary));
202 newSelection.setExtent(positionAfterNode(rootUserSelectAll).downstream(CanCr ossEditingBoundary));
203
204 return newSelection;
205 }
206
207 bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe tNode, const VisibleSelection& selection, TextGranularity granularity)
208 {
209 if (Position::nodeIsUserSelectNone(targetNode))
210 return false;
211
212 if (!dispatchSelectStart(targetNode))
213 return false;
214
215 if (selection.isRange())
216 m_selectionInitiationState = ExtendedSelection;
217 else {
218 granularity = CharacterGranularity;
219 m_selectionInitiationState = PlacedCaret;
220 }
221
222 m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granulari ty);
223
224 return true;
225 }
226
227 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul t, AppendTrailingWhitespace appendTrailingWhitespace) 166 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul t, AppendTrailingWhitespace appendTrailingWhitespace)
228 { 167 {
229 Node* innerNode = result.targetNode(); 168 Node* innerNode = result.targetNode();
230 VisibleSelection newSelection; 169 VisibleSelection newSelection;
231 170
232 if (innerNode && innerNode->renderer()) { 171 if (innerNode && innerNode->renderer()) {
233 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 172 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point()));
234 if (pos.isNotNull()) { 173 if (pos.isNotNull()) {
235 newSelection = VisibleSelection(pos); 174 newSelection = VisibleSelection(pos);
236 newSelection.expandUsingGranularity(WordGranularity); 175 newSelection.expandUsingGranularity(WordGranularity);
237 } 176 }
238 177
239 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange()) 178 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange())
240 newSelection.appendTrailingWhitespace(); 179 newSelection.appendTrailingWhitespace();
241
242 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
243 } 180 }
244 } 181 }
245 182
246 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace) 183 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace)
247 { 184 {
248 Node* innerNode = result.targetNode(); 185 Node* innerNode = result.targetNode();
249 VisibleSelection newSelection; 186 VisibleSelection newSelection;
250 187
251 if (innerNode && innerNode->renderer()) { 188 if (innerNode && innerNode->renderer()) {
252 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 189 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point()));
253 Position start = pos.deepEquivalent(); 190 Position start = pos.deepEquivalent();
254 Position end = pos.deepEquivalent(); 191 Position end = pos.deepEquivalent();
255 if (pos.isNotNull()) { 192 if (pos.isNotNull()) {
256 DocumentMarkerVector markers = innerNode->document().markers().marke rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()); 193 DocumentMarkerVector markers = innerNode->document().markers().marke rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers());
257 if (markers.size() == 1) { 194 if (markers.size() == 1) {
258 start.moveToOffset(markers[0]->startOffset()); 195 start.moveToOffset(markers[0]->startOffset());
259 end.moveToOffset(markers[0]->endOffset()); 196 end.moveToOffset(markers[0]->endOffset());
260 newSelection = VisibleSelection(start, end); 197 newSelection = VisibleSelection(start, end);
261 } 198 }
262 } 199 }
263 200
264 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange()) 201 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange())
265 newSelection.appendTrailingWhitespace(); 202 newSelection.appendTrailingWhitespace();
266
267 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
268 } 203 }
269 } 204 }
270 205
271 void EventHandler::updateSelectionForMouseDrag()
272 {
273 FrameView* view = m_frame->view();
274 if (!view)
275 return;
276 RenderView* renderer = m_frame->contentRenderer();
277 if (!renderer)
278 return;
279
280 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::Move);
281 HitTestResult result(m_lastKnownMousePosition);
282 renderer->hitTest(request, result);
283 updateSelectionForMouseDrag(result);
284 }
285
286 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul t)
287 {
288 if (!m_mouseDownMayStartSelect)
289 return;
290
291 Node* target = hitTestResult.targetNode();
292 if (!target)
293 return;
294
295 VisiblePosition targetPosition = m_frame->selection().selection().visiblePos itionRespectingEditingBoundary(hitTestResult.localPoint(), target);
296 // Don't modify the selection if we're not on a node.
297 if (targetPosition.isNull())
298 return;
299
300 // Restart the selection if this is the first mouse move. This work is usual ly
301 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection.
302 VisibleSelection newSelection = m_frame->selection().selection();
303
304 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target))
305 return;
306
307 if (m_selectionInitiationState != ExtendedSelection) {
308 // Always extend selection here because it's caused by a mouse drag
309 m_selectionInitiationState = ExtendedSelection;
310 newSelection = VisibleSelection(targetPosition);
311 }
312
313 if (RuntimeEnabledFeatures::userSelectAllEnabled()) {
314 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo rNode(m_mousePressNode.get());
315 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == Position::rootUserSelectAllForNode(target)) {
316 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePre ssNode).upstream(CanCrossEditingBoundary));
317 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePr essNode).downstream(CanCrossEditingBoundary));
318 } else {
319 // Reset base for user select all when base is inside user-select-al l area and extent < base.
320 if (rootUserSelectAllForMousePressNode && comparePositions(target->r enderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->rende rer()->positionForPoint(m_dragStartPos)) < 0)
321 newSelection.setBase(positionAfterNode(rootUserSelectAllForMouse PressNode).downstream(CanCrossEditingBoundary));
322
323 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod e(target);
324 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && co mparePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0)
325 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTa rget).upstream(CanCrossEditingBoundary));
326 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer())
327 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTar get).downstream(CanCrossEditingBoundary));
328 else
329 newSelection.setExtent(targetPosition);
330 }
331 } else {
332 newSelection.setExtent(targetPosition);
333 }
334
335 if (m_frame->selection().granularity() != CharacterGranularity)
336 newSelection.expandUsingGranularity(m_frame->selection().granularity());
337
338 m_frame->selection().setNonDirectionalSelectionIfNeeded(newSelection, m_fram e->selection().granularity(),
339 FrameSelection::AdjustEndpointsAtBidiBoundary);
340 }
341
342 AutoscrollController* EventHandler::autoscrollController() const 206 AutoscrollController* EventHandler::autoscrollController() const
343 { 207 {
344 if (Page* page = m_frame->page()) 208 if (Page* page = m_frame->page())
345 return &page->autoscrollController(); 209 return &page->autoscrollController();
346 return 0; 210 return 0;
347 } 211 }
348 212
349 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) 213 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding)
350 { 214 {
351 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); 215 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint");
(...skipping 15 matching lines...) Expand all
367 231
368 return result; 232 return result;
369 } 233 }
370 234
371 void EventHandler::stopAutoscroll() 235 void EventHandler::stopAutoscroll()
372 { 236 {
373 if (AutoscrollController* controller = autoscrollController()) 237 if (AutoscrollController* controller = autoscrollController())
374 controller->stopAutoscroll(); 238 controller->stopAutoscroll();
375 } 239 }
376 240
377 Node* EventHandler::mousePressNode() const
378 {
379 return m_mousePressNode.get();
380 }
381
382 bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari ty, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint) 241 bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari ty, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint)
383 { 242 {
384 if (!delta) 243 if (!delta)
385 return false; 244 return false;
386 245
387 Node* node = startNode; 246 Node* node = startNode;
388 247
389 if (!node) 248 if (!node)
390 node = m_frame->document()->focusedElement(); 249 node = m_frame->document()->focusedElement();
391 250
392 if (!node)
393 node = m_mousePressNode.get();
394
395 if (!node || !node->renderer()) 251 if (!node || !node->renderer())
396 return false; 252 return false;
397 253
398 RenderBox* curBox = node->renderer()->enclosingBox(); 254 RenderBox* curBox = node->renderer()->enclosingBox();
399 while (curBox && !curBox->isRenderView()) { 255 while (curBox && !curBox->isRenderView()) {
400 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it 256 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it
401 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode; 257 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode;
402 bool didScroll = curBox->scroll(direction, granularity, delta); 258 bool didScroll = curBox->scroll(direction, granularity, delta);
403 259
404 if (didScroll && stopNode) 260 if (didScroll && stopNode)
(...skipping 12 matching lines...) Expand all
417 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) 273 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode)
418 { 274 {
419 // The layout needs to be up to date to determine if we can scroll. We may b e 275 // The layout needs to be up to date to determine if we can scroll. We may b e
420 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. 276 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
421 m_frame->document()->updateLayout(); 277 m_frame->document()->updateLayout();
422 if (scroll(direction, granularity, startingNode)) 278 if (scroll(direction, granularity, startingNode))
423 return true; 279 return true;
424 return false; 280 return false;
425 } 281 }
426 282
427 IntPoint EventHandler::lastKnownMousePosition() const
428 {
429 return m_lastKnownMousePosition;
430 }
431
432 bool EventHandler::useHandCursor(Node* node, bool isOverLink) 283 bool EventHandler::useHandCursor(Node* node, bool isOverLink)
433 { 284 {
434 if (!node) 285 if (!node)
435 return false; 286 return false;
436 287
437 return isOverLink && !node->hasEditableStyle(); 288 return isOverLink && !node->hasEditableStyle();
438 } 289 }
439 290
440 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*) 291 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*)
441 { 292 {
442 ASSERT(m_frame); 293 ASSERT(m_frame);
443 ASSERT(m_frame->document()); 294 ASSERT(m_frame->document());
444 295
445 updateCursor(); 296 updateCursor();
446 } 297 }
447 298
448 void EventHandler::updateCursor() 299 void EventHandler::updateCursor()
449 { 300 {
450 if (m_mousePositionIsUnknown)
451 return;
452
453 FrameView* view = m_frame->view();
454 if (!view || !view->shouldSetCursor())
455 return;
456
457 RenderView* renderView = view->renderView();
458 if (!renderView)
459 return;
460
461 m_frame->document()->updateLayout();
462
463 HitTestRequest request(HitTestRequest::ReadOnly);
464 HitTestResult result(m_lastKnownMousePosition);
465 renderView->hitTest(request, result);
466
467 OptionalCursor optionalCursor = selectCursor(result);
468 if (optionalCursor.isCursorChange()) {
469 m_currentMouseCursor = optionalCursor.cursor();
470 view->setCursor(m_currentMouseCursor);
471 }
472 } 301 }
473 302
474 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) 303 OptionalCursor EventHandler::selectCursor(const HitTestResult& result)
475 { 304 {
476 Page* page = m_frame->page(); 305 Page* page = m_frame->page();
477 if (!page) 306 if (!page)
478 return NoCursorChange; 307 return NoCursorChange;
479 308
480 Node* node = result.innerPossiblyPseudoNode(); 309 Node* node = result.innerPossiblyPseudoNode();
481 if (!node) 310 if (!node)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 return pointerCursor(); 434 return pointerCursor();
606 } 435 }
607 436
608 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam) 437 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam)
609 { 438 {
610 bool editable = (node && node->hasEditableStyle()); 439 bool editable = (node && node->hasEditableStyle());
611 440
612 if (useHandCursor(node, result.isOverLink())) 441 if (useHandCursor(node, result.isOverLink()))
613 return handCursor(); 442 return handCursor();
614 443
615 // During selection, use an I-beam no matter what we're over.
616 // If a drag may be starting or we're capturing mouse events for a particula r node, don't treat this as a selection.
617 if (m_mousePressed && m_mouseDownMayStartSelect
618 && !m_mouseDownMayStartDrag
619 && m_frame->selection().isCaretOrRange()) {
620 return iBeam;
621 }
622
623 RenderObject* renderer = node ? node->renderer() : 0; 444 RenderObject* renderer = node ? node->renderer() : 0;
624 if ((editable || (renderer && renderer->isText() && node->canStartSelection( ))) && !result.scrollbar()) 445 if ((editable || (renderer && renderer->isText() && node->canStartSelection( ))) && !result.scrollbar())
625 return iBeam; 446 return iBeam;
626 return pointerCursor(); 447 return pointerCursor();
627 } 448 }
628 449
629 ScrollableArea* EventHandler::associatedScrollableArea(const RenderLayer* layer) const 450 ScrollableArea* EventHandler::associatedScrollableArea(const RenderLayer* layer) const
630 { 451 {
631 if (RenderLayerScrollableArea* scrollableArea = layer->scrollableArea()) { 452 if (RenderLayerScrollableArea* scrollableArea = layer->scrollableArea()) {
632 if (scrollableArea->scrollsOverflow()) 453 if (scrollableArea->scrollsOverflow())
(...skipping 14 matching lines...) Expand all
647 if (RenderView* renderView = m_frame->contentRenderer()) { 468 if (RenderView* renderView = m_frame->contentRenderer()) {
648 HitTestRequest request(HitTestRequest::ReadOnly); 469 HitTestRequest request(HitTestRequest::ReadOnly);
649 HitTestResult result(windowPoint); 470 HitTestResult result(windowPoint);
650 renderView->hitTest(request, result); 471 renderView->hitTest(request, result);
651 return result.scrollbar(); 472 return result.scrollbar();
652 } 473 }
653 474
654 return false; 475 return false;
655 } 476 }
656 477
657 void EventHandler::scheduleHoverStateUpdate()
658 {
659 if (!m_hoverTimer.isActive())
660 m_hoverTimer.startOneShot(0, FROM_HERE);
661 }
662
663 void EventHandler::scheduleCursorUpdate() 478 void EventHandler::scheduleCursorUpdate()
664 { 479 {
665 if (!m_cursorUpdateTimer.isActive()) 480 if (!m_cursorUpdateTimer.isActive())
666 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, FROM_HERE); 481 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, FROM_HERE);
667 } 482 }
668 483
669 bool EventHandler::isCursorVisible() const 484 bool EventHandler::isCursorVisible() const
670 { 485 {
671 return m_frame->page()->isCursorVisible(); 486 return m_frame->page()->isCursorVisible();
672 } 487 }
673 488
674 void EventHandler::hoverTimerFired(Timer<EventHandler>*)
675 {
676 m_hoverTimer.stop();
677
678 ASSERT(m_frame);
679 ASSERT(m_frame->document());
680
681 if (RenderView* renderer = m_frame->contentRenderer()) {
682 HitTestRequest request(HitTestRequest::Move);
683 HitTestResult result(m_lastKnownMousePosition);
684 renderer->hitTest(request, result);
685 }
686 }
687
688 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*) 489 void EventHandler::activeIntervalTimerFired(Timer<EventHandler>*)
689 { 490 {
690 m_activeIntervalTimer.stop(); 491 m_activeIntervalTimer.stop();
691 m_lastDeferredTapElement = nullptr; 492 m_lastDeferredTapElement = nullptr;
692 } 493 }
693 494
694 void EventHandler::notifyElementActivated() 495 void EventHandler::notifyElementActivated()
695 { 496 {
696 // Since another element has been set to active, stop current timer and clea r reference. 497 // Since another element has been set to active, stop current timer and clea r reference.
697 if (m_activeIntervalTimer.isActive()) 498 if (m_activeIntervalTimer.isActive())
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 578 }
778 } 579 }
779 580
780 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc ation) const 581 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc ation) const
781 { 582 {
782 return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation)); 583 return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation));
783 } 584 }
784 585
785 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation) const 586 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation) const
786 { 587 {
787 FrameView* view = m_frame->view(); 588 return false;
788 if (!view)
789 return false;
790 IntPoint dragLocation = dragViewportLocation;
791 IntSize delta = dragLocation - m_mouseDownPos;
792
793 int threshold = 3;
794
795 return abs(delta.width()) >= threshold || abs(delta.height()) >= threshold;
796 } 589 }
797 590
798 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve nt, TextEventInputType inputType) 591 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve nt, TextEventInputType inputType)
799 { 592 {
800 // Platforms should differentiate real commands like selectAll from text inp ut in disguise (like insertNewline), 593 // Platforms should differentiate real commands like selectAll from text inp ut in disguise (like insertNewline),
801 // and avoid dispatching text input events from keydown default handlers. 594 // and avoid dispatching text input events from keydown default handlers.
802 ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboard Event(underlyingEvent)->type() == EventTypeNames::keypress); 595 ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboard Event(underlyingEvent)->type() == EventTypeNames::keypress);
803 596
804 if (!m_frame) 597 if (!m_frame)
805 return false; 598 return false;
(...skipping 20 matching lines...) Expand all
826 } 619 }
827 620
828 void EventHandler::defaultTabEventHandler(KeyboardEvent* event) 621 void EventHandler::defaultTabEventHandler(KeyboardEvent* event)
829 { 622 {
830 } 623 }
831 624
832 void EventHandler::capsLockStateMayHaveChanged() 625 void EventHandler::capsLockStateMayHaveChanged()
833 { 626 {
834 } 627 }
835 628
836 // If scrollbar (under mouse) is different from last, send a mouse exited. Set
837 // last to scrollbar if setLast is true; else set last to 0.
838 void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL ast)
839 {
840 if (m_lastScrollbarUnderMouse != scrollbar) {
841 // Send mouse exited to the old scrollbar.
842 if (m_lastScrollbarUnderMouse)
843 m_lastScrollbarUnderMouse->mouseExited();
844
845 // Send mouse entered if we're setting a new scrollbar.
846 if (scrollbar && setLast)
847 scrollbar->mouseEntered();
848
849 m_lastScrollbarUnderMouse = setLast ? scrollbar : 0;
850 }
851 }
852
853 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType) 629 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType)
854 { 630 {
855 HitTestResult result(point); 631 HitTestResult result(point);
856 632
857 if (!frame || !frame->contentRenderer()) 633 if (!frame || !frame->contentRenderer())
858 return result; 634 return result;
859 if (frame->view()) { 635 if (frame->view()) {
860 IntRect rect = frame->view()->visibleContentRect(); 636 IntRect rect = frame->view()->visibleContentRect();
861 if (!rect.contains(roundedIntPoint(point))) 637 if (!rect.contains(roundedIntPoint(point)))
862 return result; 638 return result;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 679
904 void EventHandler::focusDocumentView() 680 void EventHandler::focusDocumentView()
905 { 681 {
906 Page* page = m_frame->page(); 682 Page* page = m_frame->page();
907 if (!page) 683 if (!page)
908 return; 684 return;
909 page->focusController().focusDocumentView(m_frame); 685 page->focusController().focusDocumentView(m_frame);
910 } 686 }
911 687
912 } // namespace blink 688 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/page/EventHandler.h ('k') | sky/engine/core/rendering/RenderLayerScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698