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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 210823007: Add TRACE_EVENT for common events in EventHandler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/events/EventDispatcher.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 /* 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 495 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point()));
496 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda ntOf(URLElement)) 496 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda ntOf(URLElement))
497 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem ent); 497 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem ent);
498 498
499 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); 499 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
500 } 500 }
501 } 501 }
502 502
503 bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR esults& event) 503 bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR esults& event)
504 { 504 {
505 TRACE_EVENT0("webkit", "EventHandler::handleMousePressEventDoubleClick");
506
505 if (event.event().button() != LeftButton) 507 if (event.event().button() != LeftButton)
506 return false; 508 return false;
507 509
508 if (m_frame->selection().isRange()) { 510 if (m_frame->selection().isRange()) {
509 // A double-click when range is already selected 511 // A double-click when range is already selected
510 // should not change the selection. So, do not call 512 // should not change the selection. So, do not call
511 // selectClosestWordFromMouseEvent, but do set 513 // selectClosestWordFromMouseEvent, but do set
512 // m_beganSelectingText to prevent handleMouseReleaseEvent 514 // m_beganSelectingText to prevent handleMouseReleaseEvent
513 // from setting caret selection. 515 // from setting caret selection.
514 m_selectionInitiationState = ExtendedSelection; 516 m_selectionInitiationState = ExtendedSelection;
515 } else { 517 } else {
516 selectClosestWordFromMouseEvent(event); 518 selectClosestWordFromMouseEvent(event);
517 } 519 }
518 return true; 520 return true;
519 } 521 }
520 522
521 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR esults& event) 523 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR esults& event)
522 { 524 {
525 TRACE_EVENT0("webkit", "EventHandler::handleMousePressEventTripleClick");
526
523 if (event.event().button() != LeftButton) 527 if (event.event().button() != LeftButton)
524 return false; 528 return false;
525 529
526 Node* innerNode = event.targetNode(); 530 Node* innerNode = event.targetNode();
527 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 531 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect))
528 return false; 532 return false;
529 533
530 VisibleSelection newSelection; 534 VisibleSelection newSelection;
531 VisiblePosition pos(innerNode->renderer()->positionForPoint(event.localPoint ())); 535 VisiblePosition pos(innerNode->renderer()->positionForPoint(event.localPoint ()));
532 if (pos.isNotNull()) { 536 if (pos.isNotNull()) {
533 newSelection = VisibleSelection(pos); 537 newSelection = VisibleSelection(pos);
534 newSelection.expandUsingGranularity(ParagraphGranularity); 538 newSelection.expandUsingGranularity(ParagraphGranularity);
535 } 539 }
536 540
537 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); 541 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity);
538 } 542 }
539 543
540 static int textDistance(const Position& start, const Position& end) 544 static int textDistance(const Position& start, const Position& end)
541 { 545 {
542 RefPtr<Range> range = Range::create(*start.document(), start, end); 546 RefPtr<Range> range = Range::create(*start.document(), start, end);
543 return TextIterator::rangeLength(range.get(), true); 547 return TextIterator::rangeLength(range.get(), true);
544 } 548 }
545 549
546 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR esults& event) 550 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR esults& event)
547 { 551 {
552 TRACE_EVENT0("webkit", "EventHandler::handleMousePressEventSingleClick");
553
548 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 554 m_frame->document()->updateLayoutIgnorePendingStylesheets();
549 Node* innerNode = event.targetNode(); 555 Node* innerNode = event.targetNode();
550 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 556 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect))
551 return false; 557 return false;
552 558
553 // Extend the selection if the Shift key is down, unless the click is in a l ink. 559 // Extend the selection if the Shift key is down, unless the click is in a l ink.
554 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); 560 bool extendSelection = event.event().shiftKey() && !event.isOverLink();
555 561
556 // Don't restart the selection when the mouse is pressed on an 562 // Don't restart the selection when the mouse is pressed on an
557 // existing selection so we can allow for text dragging. 563 // existing selection so we can allow for text dragging.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 return true; 620 return true;
615 621
616 if (!node->canStartSelection()) 622 if (!node->canStartSelection())
617 return false; 623 return false;
618 624
619 return true; 625 return true;
620 } 626 }
621 627
622 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve nt) 628 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve nt)
623 { 629 {
630 TRACE_EVENT0("webkit", "EventHandler::handleMousePressEvent");
631
624 // Reset drag state. 632 // Reset drag state.
625 dragState().m_dragSrc = nullptr; 633 dragState().m_dragSrc = nullptr;
626 634
627 cancelFakeMouseMoveEvent(); 635 cancelFakeMouseMoveEvent();
628 636
629 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 637 m_frame->document()->updateLayoutIgnorePendingStylesheets();
630 638
631 if (ScrollView* scrollView = m_frame->view()) { 639 if (ScrollView* scrollView = m_frame->view()) {
632 if (scrollView->isPointInScrollbarCorner(event.event().position())) 640 if (scrollView->isPointInScrollbarCorner(event.event().position()))
633 return false; 641 return false;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 swallowEvent = handleMousePressEventSingleClick(event); 687 swallowEvent = handleMousePressEventSingleClick(event);
680 688
681 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect 689 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect
682 || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNod e->renderBox()->canBeProgramaticallyScrolled()); 690 || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNod e->renderBox()->canBeProgramaticallyScrolled());
683 691
684 return swallowEvent; 692 return swallowEvent;
685 } 693 }
686 694
687 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e vent) 695 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e vent)
688 { 696 {
697 TRACE_EVENT0("webkit", "EventHandler::handleMouseDraggedEvent");
698
689 if (!m_mousePressed) 699 if (!m_mousePressed)
690 return false; 700 return false;
691 701
692 if (handleDrag(event, ShouldCheckDragHysteresis)) 702 if (handleDrag(event, ShouldCheckDragHysteresis))
693 return true; 703 return true;
694 704
695 Node* targetNode = event.targetNode(); 705 Node* targetNode = event.targetNode();
696 if (event.event().button() != LeftButton || !targetNode) 706 if (event.event().button() != LeftButton || !targetNode)
697 return false; 707 return false;
698 708
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 return 0; 888 return 0;
879 } 889 }
880 890
881 bool EventHandler::panScrollInProgress() const 891 bool EventHandler::panScrollInProgress() const
882 { 892 {
883 return autoscrollController() && autoscrollController()->panScrollInProgress (); 893 return autoscrollController() && autoscrollController()->panScrollInProgress ();
884 } 894 }
885 895
886 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) 896 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding)
887 { 897 {
898 TRACE_EVENT0("webkit", "EventHandler::hitTestResultAtPoint");
899
888 // We always send hitTestResultAtPoint to the main frame if we have one, 900 // We always send hitTestResultAtPoint to the main frame if we have one,
889 // otherwise we might hit areas that are obscured by higher frames. 901 // otherwise we might hit areas that are obscured by higher frames.
890 if (Page* page = m_frame->page()) { 902 if (Page* page = m_frame->page()) {
891 LocalFrame* mainFrame = page->mainFrame(); 903 LocalFrame* mainFrame = page->mainFrame();
892 if (m_frame != mainFrame) { 904 if (m_frame != mainFrame) {
893 FrameView* frameView = m_frame->view(); 905 FrameView* frameView = m_frame->view();
894 FrameView* mainView = mainFrame->view(); 906 FrameView* mainView = mainFrame->view();
895 if (frameView && mainView) { 907 if (frameView && mainView) {
896 IntPoint mainFramePoint = mainView->rootViewToContents(frameView ->contentsToRootView(roundedIntPoint(point))); 908 IntPoint mainFramePoint = mainView->rootViewToContents(frameView ->contentsToRootView(roundedIntPoint(point)));
897 return mainFrame->eventHandler().hitTestResultAtPoint(mainFrameP oint, hitType, padding); 909 return mainFrame->eventHandler().hitTestResultAtPoint(mainFrameP oint, hitType, padding);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint & windowPoint) 1290 static LayoutPoint documentPointForWindowPoint(LocalFrame* frame, const IntPoint & windowPoint)
1279 { 1291 {
1280 FrameView* view = frame->view(); 1292 FrameView* view = frame->view();
1281 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? 1293 // FIXME: Is it really OK to use the wrong coordinates here when view is 0?
1282 // Historically the code would just crash; this is clearly no worse than tha t. 1294 // Historically the code would just crash; this is clearly no worse than tha t.
1283 return view ? view->windowToContents(windowPoint) : windowPoint; 1295 return view ? view->windowToContents(windowPoint) : windowPoint;
1284 } 1296 }
1285 1297
1286 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) 1298 bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
1287 { 1299 {
1300 TRACE_EVENT0("webkit", "EventHandler::handleMousePressEvent");
1301
1288 RefPtr<FrameView> protector(m_frame->view()); 1302 RefPtr<FrameView> protector(m_frame->view());
1289 1303
1290 bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent); 1304 bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent);
1291 if (defaultPrevented) 1305 if (defaultPrevented)
1292 return true; 1306 return true;
1293 1307
1294 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); 1308 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
1295 m_frame->tree().top()->eventHandler().m_lastMouseDownUserGestureToken = gest ureIndicator.currentToken(); 1309 m_frame->tree().top()->eventHandler().m_lastMouseDownUserGestureToken = gest ureIndicator.currentToken();
1296 1310
1297 cancelFakeMouseMoveEvent(); 1311 cancelFakeMouseMoveEvent();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (FrameView* frameView = m_frame->view()) { 1453 if (FrameView* frameView = m_frame->view()) {
1440 if (frameView->containsScrollableArea(layerScrollableArea)) 1454 if (frameView->containsScrollableArea(layerScrollableArea))
1441 return layerScrollableArea; 1455 return layerScrollableArea;
1442 } 1456 }
1443 1457
1444 return 0; 1458 return 0;
1445 } 1459 }
1446 1460
1447 bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event) 1461 bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event)
1448 { 1462 {
1463 TRACE_EVENT0("webkit", "EventHandler::handleMouseMoveEvent");
1464
1449 RefPtr<FrameView> protector(m_frame->view()); 1465 RefPtr<FrameView> protector(m_frame->view());
1450 MaximumDurationTracker maxDurationTracker(&m_maxMouseMovedDuration); 1466 MaximumDurationTracker maxDurationTracker(&m_maxMouseMovedDuration);
1451 1467
1452 HitTestResult hoveredNode = HitTestResult(LayoutPoint()); 1468 HitTestResult hoveredNode = HitTestResult(LayoutPoint());
1453 bool result = handleMouseMoveOrLeaveEvent(event, &hoveredNode); 1469 bool result = handleMouseMoveOrLeaveEvent(event, &hoveredNode);
1454 1470
1455 Page* page = m_frame->page(); 1471 Page* page = m_frame->page();
1456 if (!page) 1472 if (!page)
1457 return result; 1473 return result;
1458 1474
1459 if (RenderLayer* layer = layerForNode(hoveredNode.innerNode())) { 1475 if (RenderLayer* layer = layerForNode(hoveredNode.innerNode())) {
1460 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer )) 1476 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer ))
1461 layerScrollableArea->mouseMovedInContentArea(); 1477 layerScrollableArea->mouseMovedInContentArea();
1462 } 1478 }
1463 1479
1464 if (FrameView* frameView = m_frame->view()) 1480 if (FrameView* frameView = m_frame->view())
1465 frameView->mouseMovedInContentArea(); 1481 frameView->mouseMovedInContentArea();
1466 1482
1467 hoveredNode.setToShadowHostIfInUserAgentShadowRoot(); 1483 hoveredNode.setToShadowHostIfInUserAgentShadowRoot();
1468 page->chrome().mouseDidMoveOverElement(hoveredNode, event.modifierFlags()); 1484 page->chrome().mouseDidMoveOverElement(hoveredNode, event.modifierFlags());
1469 page->chrome().setToolTip(hoveredNode); 1485 page->chrome().setToolTip(hoveredNode);
1470 1486
1471 return result; 1487 return result;
1472 } 1488 }
1473 1489
1474 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) 1490 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event)
1475 { 1491 {
1492 TRACE_EVENT0("webkit", "EventHandler::handleMouseLeaveEvent");
1493
1476 RefPtr<FrameView> protector(m_frame->view()); 1494 RefPtr<FrameView> protector(m_frame->view());
1477 handleMouseMoveOrLeaveEvent(event); 1495 handleMouseMoveOrLeaveEvent(event);
1478 } 1496 }
1479 1497
1480 static Cursor& syntheticTouchCursor() 1498 static Cursor& syntheticTouchCursor()
1481 { 1499 {
1482 DEFINE_STATIC_LOCAL(Cursor, c, (Image::loadPlatformResource("syntheticTouchC ursor").get(), IntPoint(10, 10))); 1500 DEFINE_STATIC_LOCAL(Cursor, c, (Image::loadPlatformResource("syntheticTouchC ursor").get(), IntPoint(10, 10)));
1483 return c; 1501 return c;
1484 } 1502 }
1485 1503
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 { 1622 {
1605 // IE doesn't dispatch click events for mousedown/mouseup events across form 1623 // IE doesn't dispatch click events for mousedown/mouseup events across form
1606 // controls. 1624 // controls.
1607 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) 1625 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent())
1608 return 0; 1626 return 0;
1609 return node.parentOrShadowHostNode(); 1627 return node.parentOrShadowHostNode();
1610 } 1628 }
1611 1629
1612 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent) 1630 bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
1613 { 1631 {
1632 TRACE_EVENT0("webkit", "EventHandler::handleMouseReleaseEvent");
1633
1614 RefPtr<FrameView> protector(m_frame->view()); 1634 RefPtr<FrameView> protector(m_frame->view());
1615 1635
1616 m_frame->selection().setCaretBlinkingSuspended(false); 1636 m_frame->selection().setCaretBlinkingSuspended(false);
1617 1637
1618 bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent); 1638 bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent);
1619 if (defaultPrevented) 1639 if (defaultPrevented)
1620 return true; 1640 return true;
1621 1641
1622 OwnPtr<UserGestureIndicator> gestureIndicator; 1642 OwnPtr<UserGestureIndicator> gestureIndicator;
1623 1643
(...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after
3570 IntRect rect = frame->view()->visibleContentRect(); 3590 IntRect rect = frame->view()->visibleContentRect();
3571 if (!rect.contains(roundedIntPoint(point))) 3591 if (!rect.contains(roundedIntPoint(point)))
3572 return result; 3592 return result;
3573 } 3593 }
3574 frame->contentRenderer()->hitTest(HitTestRequest(hitType), result); 3594 frame->contentRenderer()->hitTest(HitTestRequest(hitType), result);
3575 return result; 3595 return result;
3576 } 3596 }
3577 3597
3578 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) 3598 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
3579 { 3599 {
3600 TRACE_EVENT0("webkit", "EventHandler::handleTouchEvent");
3601
3580 // First build up the lists to use for the 'touches', 'targetTouches' and 'c hangedTouches' attributes 3602 // First build up the lists to use for the 'touches', 'targetTouches' and 'c hangedTouches' attributes
3581 // in the JS event. See http://www.sitepen.com/blog/2008/07/10/touching-and- gesturing-on-the-iphone/ 3603 // in the JS event. See http://www.sitepen.com/blog/2008/07/10/touching-and- gesturing-on-the-iphone/
3582 // for an overview of how these lists fit together. 3604 // for an overview of how these lists fit together.
3583 3605
3584 // Holds the complete set of touches on the screen and will be used as the ' touches' list in the JS event. 3606 // Holds the complete set of touches on the screen and will be used as the ' touches' list in the JS event.
3585 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create(); 3607 RefPtrWillBeRawPtr<TouchList> touches = TouchList::create();
3586 3608
3587 // A different view on the 'touches' list above, filtered and grouped by eve nt target. Used for the 3609 // A different view on the 'touches' list above, filtered and grouped by eve nt target. Used for the
3588 // 'targetTouches' list in the JS event. 3610 // 'targetTouches' list in the JS event.
3589 typedef WillBeHeapHashMap<EventTarget*, RefPtrWillBeMember<TouchList> > Targ etTouchesHeapMap; 3611 typedef WillBeHeapHashMap<EventTarget*, RefPtrWillBeMember<TouchList> > Targ etTouchesHeapMap;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 unsigned EventHandler::accessKeyModifiers() 4047 unsigned EventHandler::accessKeyModifiers()
4026 { 4048 {
4027 #if OS(MACOSX) 4049 #if OS(MACOSX)
4028 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4050 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4029 #else 4051 #else
4030 return PlatformEvent::AltKey; 4052 return PlatformEvent::AltKey;
4031 #endif 4053 #endif
4032 } 4054 }
4033 4055
4034 } // namespace WebCore 4056 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/events/EventDispatcher.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698