| OLD | NEW |
| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return ScrollByPixel; | 187 return ScrollByPixel; |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Refetch the event target node if it is removed or currently is the shadow nod
e inside an <input> element. | 191 // Refetch the event target node if it is removed or currently is the shadow nod
e inside an <input> element. |
| 192 // If a mouse event handler changes the input element type to one that has a wid
get associated, | 192 // If a mouse event handler changes the input element type to one that has a wid
get associated, |
| 193 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid
get and thus the | 193 // we'd like to EventHandler::handleMousePressEvent to pass the event to the wid
get and thus the |
| 194 // event target node can't still be the shadow node. | 194 // event target node can't still be the shadow node. |
| 195 static inline bool shouldRefetchEventTarget(const MouseEventWithHitTestResults&
mev) | 195 static inline bool shouldRefetchEventTarget(const MouseEventWithHitTestResults&
mev) |
| 196 { | 196 { |
| 197 Node* targetNode = mev.targetNode(); | 197 Node* targetNode = mev.innerNode(); |
| 198 if (!targetNode || !targetNode->parentNode()) | 198 if (!targetNode || !targetNode->parentNode()) |
| 199 return true; | 199 return true; |
| 200 return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(target
Node)->host()); | 200 return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(target
Node)->host()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 EventHandler::EventHandler(LocalFrame* frame) | 203 EventHandler::EventHandler(LocalFrame* frame) |
| 204 : m_frame(frame) | 204 : m_frame(frame) |
| 205 , m_mousePressed(false) | 205 , m_mousePressed(false) |
| 206 , m_capturesDragging(false) | 206 , m_capturesDragging(false) |
| 207 , m_mouseDownMayStartSelect(false) | 207 , m_mouseDownMayStartSelect(false) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 m_selectionInitiationState = PlacedCaret; | 360 m_selectionInitiationState = PlacedCaret; |
| 361 } | 361 } |
| 362 | 362 |
| 363 m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granulari
ty); | 363 m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granulari
ty); |
| 364 | 364 |
| 365 return true; | 365 return true; |
| 366 } | 366 } |
| 367 | 367 |
| 368 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul
t, AppendTrailingWhitespace appendTrailingWhitespace) | 368 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul
t, AppendTrailingWhitespace appendTrailingWhitespace) |
| 369 { | 369 { |
| 370 Node* innerNode = result.targetNode(); | 370 Node* innerNode = result.innerNode(); |
| 371 VisibleSelection newSelection; | 371 VisibleSelection newSelection; |
| 372 | 372 |
| 373 if (innerNode && innerNode->renderer()) { | 373 if (innerNode && innerNode->renderer()) { |
| 374 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); | 374 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); |
| 375 if (pos.isNotNull()) { | 375 if (pos.isNotNull()) { |
| 376 newSelection = VisibleSelection(pos); | 376 newSelection = VisibleSelection(pos); |
| 377 newSelection.expandUsingGranularity(WordGranularity); | 377 newSelection.expandUsingGranularity(WordGranularity); |
| 378 } | 378 } |
| 379 | 379 |
| 380 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel
ection.isRange()) | 380 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel
ection.isRange()) |
| 381 newSelection.appendTrailingWhitespace(); | 381 newSelection.appendTrailingWhitespace(); |
| 382 | 382 |
| 383 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec
tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); | 383 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec
tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult
& result, AppendTrailingWhitespace appendTrailingWhitespace) | 387 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult
& result, AppendTrailingWhitespace appendTrailingWhitespace) |
| 388 { | 388 { |
| 389 Node* innerNode = result.targetNode(); | 389 Node* innerNode = result.innerNode(); |
| 390 VisibleSelection newSelection; | 390 VisibleSelection newSelection; |
| 391 | 391 |
| 392 if (innerNode && innerNode->renderer()) { | 392 if (innerNode && innerNode->renderer()) { |
| 393 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); | 393 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); |
| 394 Position start = pos.deepEquivalent(); | 394 Position start = pos.deepEquivalent(); |
| 395 Position end = pos.deepEquivalent(); | 395 Position end = pos.deepEquivalent(); |
| 396 if (pos.isNotNull()) { | 396 if (pos.isNotNull()) { |
| 397 DocumentMarkerVector markers = innerNode->document().markers().marke
rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()); | 397 DocumentMarkerVector markers = innerNode->document().markers().marke
rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()); |
| 398 if (markers.size() == 1) { | 398 if (markers.size() == 1) { |
| 399 start.moveToOffset(markers[0]->startOffset()); | 399 start.moveToOffset(markers[0]->startOffset()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 423 selectClosestMisspellingFromHitTestResult(result.hitTestResult(), | 423 selectClosestMisspellingFromHitTestResult(result.hitTestResult(), |
| 424 (result.event().clickCount() == 2 && m_frame->editor().isSelectTrail
ingWhitespaceEnabled()) ? ShouldAppendTrailingWhitespace : DontAppendTrailingWhi
tespace); | 424 (result.event().clickCount() == 2 && m_frame->editor().isSelectTrail
ingWhitespaceEnabled()) ? ShouldAppendTrailingWhitespace : DontAppendTrailingWhi
tespace); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit
TestResults& result) | 428 void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit
TestResults& result) |
| 429 { | 429 { |
| 430 if (!result.hitTestResult().isLiveLink()) | 430 if (!result.hitTestResult().isLiveLink()) |
| 431 return selectClosestWordFromMouseEvent(result); | 431 return selectClosestWordFromMouseEvent(result); |
| 432 | 432 |
| 433 Node* innerNode = result.targetNode(); | 433 Node* innerNode = result.innerNode(); |
| 434 | 434 |
| 435 if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) { | 435 if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) { |
| 436 VisibleSelection newSelection; | 436 VisibleSelection newSelection; |
| 437 Element* URLElement = result.hitTestResult().URLElement(); | 437 Element* URLElement = result.hitTestResult().URLElement(); |
| 438 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); | 438 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); |
| 439 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda
ntOf(URLElement)) | 439 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda
ntOf(URLElement)) |
| 440 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem
ent); | 440 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem
ent); |
| 441 | 441 |
| 442 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec
tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); | 442 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec
tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); |
| 443 } | 443 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 463 return true; | 463 return true; |
| 464 } | 464 } |
| 465 | 465 |
| 466 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR
esults& event) | 466 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR
esults& event) |
| 467 { | 467 { |
| 468 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventTripleClick"); | 468 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventTripleClick"); |
| 469 | 469 |
| 470 if (event.event().button() != LeftButton) | 470 if (event.event().button() != LeftButton) |
| 471 return false; | 471 return false; |
| 472 | 472 |
| 473 Node* innerNode = event.targetNode(); | 473 Node* innerNode = event.innerNode(); |
| 474 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) | 474 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) |
| 475 return false; | 475 return false; |
| 476 | 476 |
| 477 VisibleSelection newSelection; | 477 VisibleSelection newSelection; |
| 478 VisiblePosition pos(innerNode->renderer()->positionForPoint(event.localPoint
())); | 478 VisiblePosition pos(innerNode->renderer()->positionForPoint(event.localPoint
())); |
| 479 if (pos.isNotNull()) { | 479 if (pos.isNotNull()) { |
| 480 newSelection = VisibleSelection(pos); | 480 newSelection = VisibleSelection(pos); |
| 481 newSelection.expandUsingGranularity(ParagraphGranularity); | 481 newSelection.expandUsingGranularity(ParagraphGranularity); |
| 482 } | 482 } |
| 483 | 483 |
| 484 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe
lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); | 484 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe
lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); |
| 485 } | 485 } |
| 486 | 486 |
| 487 static int textDistance(const Position& start, const Position& end) | 487 static int textDistance(const Position& start, const Position& end) |
| 488 { | 488 { |
| 489 RefPtrWillBeRawPtr<Range> range = Range::create(*start.document(), start, en
d); | 489 RefPtrWillBeRawPtr<Range> range = Range::create(*start.document(), start, en
d); |
| 490 return TextIterator::rangeLength(range.get(), true); | 490 return TextIterator::rangeLength(range.get(), true); |
| 491 } | 491 } |
| 492 | 492 |
| 493 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
esults& event) | 493 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
esults& event) |
| 494 { | 494 { |
| 495 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventSingleClick"); | 495 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventSingleClick"); |
| 496 | 496 |
| 497 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 497 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 498 Node* innerNode = event.targetNode(); | 498 Node* innerNode = event.innerNode(); |
| 499 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) | 499 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) |
| 500 return false; | 500 return false; |
| 501 | 501 |
| 502 // Extend the selection if the Shift key is down, unless the click is in a l
ink. | 502 // Extend the selection if the Shift key is down, unless the click is in a l
ink. |
| 503 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); | 503 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); |
| 504 | 504 |
| 505 // Don't restart the selection when the mouse is pressed on an | 505 // Don't restart the selection when the mouse is pressed on an |
| 506 // existing selection so we can allow for text dragging. | 506 // existing selection so we can allow for text dragging. |
| 507 if (FrameView* view = m_frame->view()) { | 507 if (FrameView* view = m_frame->view()) { |
| 508 LayoutPoint vPoint = view->windowToContents(event.event().position()); | 508 LayoutPoint vPoint = view->windowToContents(event.event().position()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 582 |
| 583 if (ScrollView* scrollView = m_frame->view()) { | 583 if (ScrollView* scrollView = m_frame->view()) { |
| 584 if (scrollView->isPointInScrollbarCorner(event.event().position())) | 584 if (scrollView->isPointInScrollbarCorner(event.event().position())) |
| 585 return false; | 585 return false; |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool singleClick = event.event().clickCount() <= 1; | 588 bool singleClick = event.event().clickCount() <= 1; |
| 589 | 589 |
| 590 // If we got the event back, that must mean it wasn't prevented, | 590 // If we got the event back, that must mean it wasn't prevented, |
| 591 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. | 591 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. |
| 592 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.targetNode()) && !
event.scrollbar(); | 592 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.innerNode()) && !e
vent.scrollbar(); |
| 593 | 593 |
| 594 m_mouseDownMayStartDrag = singleClick; | 594 m_mouseDownMayStartDrag = singleClick; |
| 595 | 595 |
| 596 m_mouseDownWasSingleClickInSelection = false; | 596 m_mouseDownWasSingleClickInSelection = false; |
| 597 | 597 |
| 598 m_mouseDown = event.event(); | 598 m_mouseDown = event.event(); |
| 599 | 599 |
| 600 if (event.isOverWidget() && passWidgetMouseDownEventToWidget(event)) | 600 if (event.isOverWidget() && passWidgetMouseDownEventToWidget(event)) |
| 601 return true; | 601 return true; |
| 602 | 602 |
| 603 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx
tensions().zoomAndPanEnabled()) { | 603 if (m_frame->document()->isSVGDocument() && m_frame->document()->accessSVGEx
tensions().zoomAndPanEnabled()) { |
| 604 if (event.event().shiftKey() && singleClick) { | 604 if (event.event().shiftKey() && singleClick) { |
| 605 m_svgPan = true; | 605 m_svgPan = true; |
| 606 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()-
>windowToContents(event.event().position())); | 606 m_frame->document()->accessSVGExtensions().startPan(m_frame->view()-
>windowToContents(event.event().position())); |
| 607 return true; | 607 return true; |
| 608 } | 608 } |
| 609 } | 609 } |
| 610 | 610 |
| 611 // We don't do this at the start of mouse down handling, | 611 // We don't do this at the start of mouse down handling, |
| 612 // because we don't want to do it until we know we didn't hit a widget. | 612 // because we don't want to do it until we know we didn't hit a widget. |
| 613 if (singleClick) | 613 if (singleClick) |
| 614 focusDocumentView(); | 614 focusDocumentView(); |
| 615 | 615 |
| 616 Node* innerNode = event.targetNode(); | 616 Node* innerNode = event.innerNode(); |
| 617 | 617 |
| 618 m_mousePressNode = innerNode; | 618 m_mousePressNode = innerNode; |
| 619 m_dragStartPos = event.event().position(); | 619 m_dragStartPos = event.event().position(); |
| 620 | 620 |
| 621 bool swallowEvent = false; | 621 bool swallowEvent = false; |
| 622 m_mousePressed = true; | 622 m_mousePressed = true; |
| 623 m_selectionInitiationState = HaveNotStartedSelection; | 623 m_selectionInitiationState = HaveNotStartedSelection; |
| 624 | 624 |
| 625 if (event.event().clickCount() == 2) | 625 if (event.event().clickCount() == 2) |
| 626 swallowEvent = handleMousePressEventDoubleClick(event); | 626 swallowEvent = handleMousePressEventDoubleClick(event); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 638 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
vent) | 638 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
vent) |
| 639 { | 639 { |
| 640 TRACE_EVENT0("blink", "EventHandler::handleMouseDraggedEvent"); | 640 TRACE_EVENT0("blink", "EventHandler::handleMouseDraggedEvent"); |
| 641 | 641 |
| 642 if (!m_mousePressed) | 642 if (!m_mousePressed) |
| 643 return false; | 643 return false; |
| 644 | 644 |
| 645 if (handleDrag(event, ShouldCheckDragHysteresis)) | 645 if (handleDrag(event, ShouldCheckDragHysteresis)) |
| 646 return true; | 646 return true; |
| 647 | 647 |
| 648 Node* targetNode = event.targetNode(); | 648 Node* targetNode = event.innerNode(); |
| 649 if (event.event().button() != LeftButton || !targetNode) | 649 if (event.event().button() != LeftButton || !targetNode) |
| 650 return false; | 650 return false; |
| 651 | 651 |
| 652 RenderObject* renderer = targetNode->renderer(); | 652 RenderObject* renderer = targetNode->renderer(); |
| 653 if (!renderer) { | 653 if (!renderer) { |
| 654 Node* parent = NodeRenderingTraversal::parent(targetNode); | 654 Node* parent = NodeRenderingTraversal::parent(targetNode); |
| 655 if (!parent) | 655 if (!parent) |
| 656 return false; | 656 return false; |
| 657 | 657 |
| 658 renderer = parent->renderer(); | 658 renderer = parent->renderer(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); | 693 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); |
| 694 renderer->hitTest(request, result); | 694 renderer->hitTest(request, result); |
| 695 updateSelectionForMouseDrag(result); | 695 updateSelectionForMouseDrag(result); |
| 696 } | 696 } |
| 697 | 697 |
| 698 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) | 698 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
t) |
| 699 { | 699 { |
| 700 if (!m_mouseDownMayStartSelect) | 700 if (!m_mouseDownMayStartSelect) |
| 701 return; | 701 return; |
| 702 | 702 |
| 703 Node* target = hitTestResult.targetNode(); | 703 Node* target = hitTestResult.innerNode(); |
| 704 if (!target) | 704 if (!target) |
| 705 return; | 705 return; |
| 706 | 706 |
| 707 VisiblePosition targetPosition = m_frame->selection().selection().visiblePos
itionRespectingEditingBoundary(hitTestResult.localPoint(), target); | 707 VisiblePosition targetPosition = m_frame->selection().selection().visiblePos
itionRespectingEditingBoundary(hitTestResult.localPoint(), target); |
| 708 // Don't modify the selection if we're not on a node. | 708 // Don't modify the selection if we're not on a node. |
| 709 if (targetPosition.isNull()) | 709 if (targetPosition.isNull()) |
| 710 return; | 710 return; |
| 711 | 711 |
| 712 // Restart the selection if this is the first mouse move. This work is usual
ly | 712 // Restart the selection if this is the first mouse move. This work is usual
ly |
| 713 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. | 713 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 778 |
| 779 // Clear the selection if the mouse didn't move after the last mouse | 779 // Clear the selection if the mouse didn't move after the last mouse |
| 780 // press and it's not a context menu click. We do this so when clicking | 780 // press and it's not a context menu click. We do this so when clicking |
| 781 // on the selection, the selection goes away. However, if we are | 781 // on the selection, the selection goes away. However, if we are |
| 782 // editing, place the caret. | 782 // editing, place the caret. |
| 783 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex
tendedSelection | 783 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex
tendedSelection |
| 784 && m_dragStartPos == event.event().position() | 784 && m_dragStartPos == event.event().position() |
| 785 && m_frame->selection().isRange() | 785 && m_frame->selection().isRange() |
| 786 && event.event().button() != RightButton) { | 786 && event.event().button() != RightButton) { |
| 787 VisibleSelection newSelection; | 787 VisibleSelection newSelection; |
| 788 Node* node = event.targetNode(); | 788 Node* node = event.innerNode(); |
| 789 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr
owsingEnabled(); | 789 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr
owsingEnabled(); |
| 790 if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle
())) { | 790 if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle
())) { |
| 791 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP
oint(event.localPoint())); | 791 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP
oint(event.localPoint())); |
| 792 newSelection = VisibleSelection(pos); | 792 newSelection = VisibleSelection(pos); |
| 793 } | 793 } |
| 794 | 794 |
| 795 setSelectionIfNeeded(m_frame->selection(), newSelection); | 795 setSelectionIfNeeded(m_frame->selection(), newSelection); |
| 796 | 796 |
| 797 handled = true; | 797 handled = true; |
| 798 } | 798 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 if (!widget || !widget->isFrameView()) | 964 if (!widget || !widget->isFrameView()) |
| 965 return 0; | 965 return 0; |
| 966 | 966 |
| 967 return &toFrameView(widget)->frame(); | 967 return &toFrameView(widget)->frame(); |
| 968 } | 968 } |
| 969 | 969 |
| 970 static LocalFrame* subframeForHitTestResult(const MouseEventWithHitTestResults&
hitTestResult) | 970 static LocalFrame* subframeForHitTestResult(const MouseEventWithHitTestResults&
hitTestResult) |
| 971 { | 971 { |
| 972 if (!hitTestResult.isOverWidget()) | 972 if (!hitTestResult.isOverWidget()) |
| 973 return 0; | 973 return 0; |
| 974 return subframeForTargetNode(hitTestResult.targetNode()); | 974 return subframeForTargetNode(hitTestResult.innerNode()); |
| 975 } | 975 } |
| 976 | 976 |
| 977 static bool isSubmitImage(Node* node) | 977 static bool isSubmitImage(Node* node) |
| 978 { | 978 { |
| 979 return isHTMLInputElement(node) && toHTMLInputElement(node)->type() == Input
TypeNames::image; | 979 return isHTMLInputElement(node) && toHTMLInputElement(node)->type() == Input
TypeNames::image; |
| 980 } | 980 } |
| 981 | 981 |
| 982 bool EventHandler::useHandCursor(Node* node, bool isOverLink) | 982 bool EventHandler::useHandCursor(Node* node, bool isOverLink) |
| 983 { | 983 { |
| 984 if (!node) | 984 if (!node) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 | 1228 |
| 1229 // Mouse events simulated from touch should not hit-test again. | 1229 // Mouse events simulated from touch should not hit-test again. |
| 1230 ASSERT(!mouseEvent.fromTouch()); | 1230 ASSERT(!mouseEvent.fromTouch()); |
| 1231 | 1231 |
| 1232 HitTestRequest request(HitTestRequest::Active); | 1232 HitTestRequest request(HitTestRequest::Active); |
| 1233 // Save the document point we generate in case the window coordinate is inva
lidated by what happens | 1233 // Save the document point we generate in case the window coordinate is inva
lidated by what happens |
| 1234 // when we dispatch the event. | 1234 // when we dispatch the event. |
| 1235 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); | 1235 LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.
position()); |
| 1236 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); | 1236 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re
quest, documentPoint, mouseEvent); |
| 1237 | 1237 |
| 1238 if (!mev.targetNode()) { | 1238 if (!mev.innerNode()) { |
| 1239 invalidateClick(); | 1239 invalidateClick(); |
| 1240 return false; | 1240 return false; |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 m_mousePressNode = mev.targetNode(); | 1243 m_mousePressNode = mev.innerNode(); |
| 1244 | 1244 |
| 1245 RefPtr<LocalFrame> subframe = subframeForHitTestResult(mev); | 1245 RefPtr<LocalFrame> subframe = subframeForHitTestResult(mev); |
| 1246 if (subframe && passMousePressEventToSubframe(mev, subframe.get())) { | 1246 if (subframe && passMousePressEventToSubframe(mev, subframe.get())) { |
| 1247 // Start capturing future events for this frame. We only do this if we
didn't clear | 1247 // Start capturing future events for this frame. We only do this if we
didn't clear |
| 1248 // the m_mousePressed flag, which may happen if an AppKit widget entered
a modal event loop. | 1248 // the m_mousePressed flag, which may happen if an AppKit widget entered
a modal event loop. |
| 1249 m_capturesDragging = subframe->eventHandler().capturesDragging(); | 1249 m_capturesDragging = subframe->eventHandler().capturesDragging(); |
| 1250 if (m_mousePressed && m_capturesDragging) { | 1250 if (m_mousePressed && m_capturesDragging) { |
| 1251 m_capturingMouseEventsNode = mev.targetNode(); | 1251 m_capturingMouseEventsNode = mev.innerNode(); |
| 1252 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 1252 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
| 1253 } | 1253 } |
| 1254 invalidateClick(); | 1254 invalidateClick(); |
| 1255 return true; | 1255 return true; |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 #if OS(WIN) | 1258 #if OS(WIN) |
| 1259 // We store whether pan scrolling is in progress before calling stopAutoscro
ll() | 1259 // We store whether pan scrolling is in progress before calling stopAutoscro
ll() |
| 1260 // because it will set m_autoscrollType to NoAutoscroll on return. | 1260 // because it will set m_autoscrollType to NoAutoscroll on return. |
| 1261 bool isPanScrollInProgress = panScrollInProgress(); | 1261 bool isPanScrollInProgress = panScrollInProgress(); |
| 1262 stopAutoscroll(); | 1262 stopAutoscroll(); |
| 1263 if (isPanScrollInProgress) { | 1263 if (isPanScrollInProgress) { |
| 1264 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate | 1264 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate |
| 1265 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. | 1265 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. |
| 1266 invalidateClick(); | 1266 invalidateClick(); |
| 1267 return true; | 1267 return true; |
| 1268 } | 1268 } |
| 1269 #endif | 1269 #endif |
| 1270 | 1270 |
| 1271 m_clickCount = mouseEvent.clickCount(); | 1271 m_clickCount = mouseEvent.clickCount(); |
| 1272 m_clickNode = mev.targetNode()->isTextNode() ? NodeRenderingTraversal::pare
nt(mev.targetNode()) : mev.targetNode(); | 1272 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren
t(mev.innerNode()) : mev.innerNode(); |
| 1273 | 1273 |
| 1274 if (FrameView* view = m_frame->view()) { | 1274 if (FrameView* view = m_frame->view()) { |
| 1275 RenderLayer* layer = mev.targetNode()->renderer() ? mev.targetNode()->re
nderer()->enclosingLayer() : 0; | 1275 RenderLayer* layer = mev.innerNode()->renderer() ? mev.innerNode()->rend
erer()->enclosingLayer() : 0; |
| 1276 IntPoint p = view->windowToContents(mouseEvent.position()); | 1276 IntPoint p = view->windowToContents(mouseEvent.position()); |
| 1277 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { | 1277 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint
InResizeControl(p, ResizerForPointer)) { |
| 1278 m_resizeScrollableArea = layer->scrollableArea(); | 1278 m_resizeScrollableArea = layer->scrollableArea(); |
| 1279 m_resizeScrollableArea->setInResizeMode(true); | 1279 m_resizeScrollableArea->setInResizeMode(true); |
| 1280 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC
orner(p); | 1280 m_offsetFromResizeCorner = m_resizeScrollableArea->offsetFromResizeC
orner(p); |
| 1281 invalidateClick(); | 1281 invalidateClick(); |
| 1282 return true; | 1282 return true; |
| 1283 } | 1283 } |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 m_frame->selection().setCaretBlinkingSuspended(true); | 1286 m_frame->selection().setCaretBlinkingSuspended(true); |
| 1287 | 1287 |
| 1288 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targe
tNode(), m_clickCount, mouseEvent, true); | 1288 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner
Node(), m_clickCount, mouseEvent, true); |
| 1289 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); | 1289 swallowEvent = swallowEvent || handleMouseFocus(mouseEvent); |
| 1290 m_capturesDragging = !swallowEvent || mev.scrollbar(); | 1290 m_capturesDragging = !swallowEvent || mev.scrollbar(); |
| 1291 | 1291 |
| 1292 // If the hit testing originally determined the event was in a scrollbar, re
fetch the MouseEventWithHitTestResults | 1292 // If the hit testing originally determined the event was in a scrollbar, re
fetch the MouseEventWithHitTestResults |
| 1293 // in case the scrollbar widget was destroyed when the mouse event was handl
ed. | 1293 // in case the scrollbar widget was destroyed when the mouse event was handl
ed. |
| 1294 if (mev.scrollbar()) { | 1294 if (mev.scrollbar()) { |
| 1295 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou
se.get(); | 1295 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou
se.get(); |
| 1296 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
); | 1296 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
); |
| 1297 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou
seEvent); | 1297 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou
seEvent); |
| 1298 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get
()) | 1298 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get
()) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 | 1448 |
| 1449 bool swallowEvent = false; | 1449 bool swallowEvent = false; |
| 1450 RefPtr<LocalFrame> newSubframe = m_capturingMouseEventsNode.get() ? subframe
ForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1450 RefPtr<LocalFrame> newSubframe = m_capturingMouseEventsNode.get() ? subframe
ForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
| 1451 | 1451 |
| 1452 // We want mouseouts to happen first, from the inside out. First send a mov
e event to the last subframe so that it will fire mouseouts. | 1452 // We want mouseouts to happen first, from the inside out. First send a mov
e event to the last subframe so that it will fire mouseouts. |
| 1453 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isD
escendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) | 1453 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isD
escendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) |
| 1454 passMouseMoveEventToSubframe(mev, m_lastMouseMoveEventSubframe.get()); | 1454 passMouseMoveEventToSubframe(mev, m_lastMouseMoveEventSubframe.get()); |
| 1455 | 1455 |
| 1456 if (newSubframe) { | 1456 if (newSubframe) { |
| 1457 // Update over/out state before passing the event to the subframe. | 1457 // Update over/out state before passing the event to the subframe. |
| 1458 updateMouseEventTargetNode(mev.targetNode(), mouseEvent, true); | 1458 updateMouseEventTargetNode(mev.innerNode(), mouseEvent, true); |
| 1459 | 1459 |
| 1460 // Event dispatch in updateMouseEventTargetNode may have caused the subf
rame of the target | 1460 // Event dispatch in updateMouseEventTargetNode may have caused the subf
rame of the target |
| 1461 // node to be detached from its FrameView, in which case the event shoul
d not be passed. | 1461 // node to be detached from its FrameView, in which case the event shoul
d not be passed. |
| 1462 if (newSubframe->view()) | 1462 if (newSubframe->view()) |
| 1463 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(),
hoveredNode); | 1463 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(),
hoveredNode); |
| 1464 } else { | 1464 } else { |
| 1465 if (scrollbar && !m_mousePressed) | 1465 if (scrollbar && !m_mousePressed) |
| 1466 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo
rms that support visual feedback on scrollbar hovering. | 1466 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo
rms that support visual feedback on scrollbar hovering. |
| 1467 if (FrameView* view = m_frame->view()) { | 1467 if (FrameView* view = m_frame->view()) { |
| 1468 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult()); | 1468 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult()); |
| 1469 if (optionalCursor.isCursorChange()) { | 1469 if (optionalCursor.isCursorChange()) { |
| 1470 m_currentMouseCursor = optionalCursor.cursor(); | 1470 m_currentMouseCursor = optionalCursor.cursor(); |
| 1471 view->setCursor(m_currentMouseCursor); | 1471 view->setCursor(m_currentMouseCursor); |
| 1472 } | 1472 } |
| 1473 } | 1473 } |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 m_lastMouseMoveEventSubframe = newSubframe; | 1476 m_lastMouseMoveEventSubframe = newSubframe; |
| 1477 | 1477 |
| 1478 if (swallowEvent) | 1478 if (swallowEvent) |
| 1479 return true; | 1479 return true; |
| 1480 | 1480 |
| 1481 swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.targetNode
(), 0, mouseEvent, true); | 1481 swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.innerNode(
), 0, mouseEvent, true); |
| 1482 if (!swallowEvent) | 1482 if (!swallowEvent) |
| 1483 swallowEvent = handleMouseDraggedEvent(mev); | 1483 swallowEvent = handleMouseDraggedEvent(mev); |
| 1484 | 1484 |
| 1485 return swallowEvent; | 1485 return swallowEvent; |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 void EventHandler::invalidateClick() | 1488 void EventHandler::invalidateClick() |
| 1489 { | 1489 { |
| 1490 m_clickCount = 0; | 1490 m_clickCount = 0; |
| 1491 m_clickNode = nullptr; | 1491 m_clickNode = nullptr; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 | 1544 |
| 1545 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; | 1545 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; |
| 1546 HitTestRequest request(hitType); | 1546 HitTestRequest request(hitType); |
| 1547 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); | 1547 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); |
| 1548 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN
ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1548 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN
ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
| 1549 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1549 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 1550 m_capturingMouseEventsNode = nullptr; | 1550 m_capturingMouseEventsNode = nullptr; |
| 1551 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) | 1551 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) |
| 1552 return true; | 1552 return true; |
| 1553 | 1553 |
| 1554 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
targetNode(), m_clickCount, mouseEvent, false); | 1554 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
innerNode(), m_clickCount, mouseEvent, false); |
| 1555 | 1555 |
| 1556 bool contextMenuEvent = mouseEvent.button() == RightButton; | 1556 bool contextMenuEvent = mouseEvent.button() == RightButton; |
| 1557 #if OS(MACOSX) | 1557 #if OS(MACOSX) |
| 1558 // FIXME: The Mac port achieves the same behavior by checking whether the co
ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl
ementations. | 1558 // FIXME: The Mac port achieves the same behavior by checking whether the co
ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl
ementations. |
| 1559 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv
ent::CtrlKey) | 1559 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv
ent::CtrlKey) |
| 1560 contextMenuEvent = true; | 1560 contextMenuEvent = true; |
| 1561 #endif | 1561 #endif |
| 1562 | 1562 |
| 1563 bool swallowClickEvent = false; | 1563 bool swallowClickEvent = false; |
| 1564 if (m_clickCount > 0 && !contextMenuEvent && mev.targetNode() && m_clickNode
) { | 1564 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode)
{ |
| 1565 if (Node* clickTargetNode = mev.targetNode()->commonAncestor(*m_clickNod
e, parentForClickEvent)) | 1565 if (Node* clickTargetNode = mev.innerNode()->commonAncestor(*m_clickNode
, parentForClickEvent)) |
| 1566 swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, click
TargetNode, m_clickCount, mouseEvent, true); | 1566 swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, click
TargetNode, m_clickCount, mouseEvent, true); |
| 1567 } | 1567 } |
| 1568 | 1568 |
| 1569 if (m_resizeScrollableArea) { | 1569 if (m_resizeScrollableArea) { |
| 1570 m_resizeScrollableArea->setInResizeMode(false); | 1570 m_resizeScrollableArea->setInResizeMode(false); |
| 1571 m_resizeScrollableArea = 0; | 1571 m_resizeScrollableArea = 0; |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 bool swallowMouseReleaseEvent = false; | 1574 bool swallowMouseReleaseEvent = false; |
| 1575 if (!swallowMouseUpEvent) | 1575 if (!swallowMouseUpEvent) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 { | 1687 { |
| 1688 bool accept = false; | 1688 bool accept = false; |
| 1689 | 1689 |
| 1690 if (!m_frame->view()) | 1690 if (!m_frame->view()) |
| 1691 return false; | 1691 return false; |
| 1692 | 1692 |
| 1693 HitTestRequest request(HitTestRequest::ReadOnly); | 1693 HitTestRequest request(HitTestRequest::ReadOnly); |
| 1694 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); | 1694 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); |
| 1695 | 1695 |
| 1696 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) | 1696 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) |
| 1697 RefPtrWillBeRawPtr<Node> newTarget = mev.targetNode(); | 1697 RefPtrWillBeRawPtr<Node> newTarget = mev.innerNode(); |
| 1698 if (newTarget && newTarget->isTextNode()) | 1698 if (newTarget && newTarget->isTextNode()) |
| 1699 newTarget = NodeRenderingTraversal::parent(newTarget.get()); | 1699 newTarget = NodeRenderingTraversal::parent(newTarget.get()); |
| 1700 | 1700 |
| 1701 if (AutoscrollController* controller = autoscrollController()) | 1701 if (AutoscrollController* controller = autoscrollController()) |
| 1702 controller->updateDragAndDrop(newTarget.get(), event.position(), event.t
imestamp()); | 1702 controller->updateDragAndDrop(newTarget.get(), event.position(), event.t
imestamp()); |
| 1703 | 1703 |
| 1704 if (m_dragTarget != newTarget) { | 1704 if (m_dragTarget != newTarget) { |
| 1705 // FIXME: this ordering was explicitly chosen to match WinIE. However, | 1705 // FIXME: this ordering was explicitly chosen to match WinIE. However, |
| 1706 // it is sometimes incorrect when dragging within subframes, as seen wit
h | 1706 // it is sometimes incorrect when dragging within subframes, as seen wit
h |
| 1707 // LayoutTests/fast/events/drag-in-frames.html. | 1707 // LayoutTests/fast/events/drag-in-frames.html. |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven
t); | 2087 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven
t); |
| 2088 | 2088 |
| 2089 // No hit test result, handle in root instance. Perhaps we should just retur
n false instead? | 2089 // No hit test result, handle in root instance. Perhaps we should just retur
n false instead? |
| 2090 return handleGestureEventInFrame(targetedEvent); | 2090 return handleGestureEventInFrame(targetedEvent); |
| 2091 } | 2091 } |
| 2092 | 2092 |
| 2093 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult
s& targetedEvent) | 2093 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult
s& targetedEvent) |
| 2094 { | 2094 { |
| 2095 ASSERT(!targetedEvent.event().isScrollEvent()); | 2095 ASSERT(!targetedEvent.event().isScrollEvent()); |
| 2096 | 2096 |
| 2097 RefPtrWillBeRawPtr<Node> eventTarget = targetedEvent.hitTestResult().targetN
ode(); | 2097 RefPtrWillBeRawPtr<Node> eventTarget = targetedEvent.hitTestResult().innerNo
de(); |
| 2098 RefPtr<Scrollbar> scrollbar = targetedEvent.hitTestResult().scrollbar(); | 2098 RefPtr<Scrollbar> scrollbar = targetedEvent.hitTestResult().scrollbar(); |
| 2099 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 2099 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
| 2100 | 2100 |
| 2101 if (scrollbar) { | 2101 if (scrollbar) { |
| 2102 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); | 2102 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); |
| 2103 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow
ed) | 2103 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow
ed) |
| 2104 m_scrollbarHandlingScrollGesture = scrollbar; | 2104 m_scrollbarHandlingScrollGesture = scrollbar; |
| 2105 if (eventSwallowed) | 2105 if (eventSwallowed) |
| 2106 return true; | 2106 return true; |
| 2107 } | 2107 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2307 } | 2307 } |
| 2308 } | 2308 } |
| 2309 #if OS(ANDROID) | 2309 #if OS(ANDROID) |
| 2310 bool shouldLongPressSelectWord = true; | 2310 bool shouldLongPressSelectWord = true; |
| 2311 #else | 2311 #else |
| 2312 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); | 2312 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()-
>touchEditingEnabled(); |
| 2313 #endif | 2313 #endif |
| 2314 if (shouldLongPressSelectWord) { | 2314 if (shouldLongPressSelectWord) { |
| 2315 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.p
osition()); | 2315 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.p
osition()); |
| 2316 HitTestResult result = hitTestResultAtPoint(hitTestPoint); | 2316 HitTestResult result = hitTestResultAtPoint(hitTestPoint); |
| 2317 Node* innerNode = result.targetNode(); | 2317 Node* innerNode = result.innerNode(); |
| 2318 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode())) { | 2318 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable()
|| innerNode->isTextNode())) { |
| 2319 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); | 2319 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitesp
ace); |
| 2320 if (m_frame->selection().isRange()) { | 2320 if (m_frame->selection().isRange()) { |
| 2321 focusDocumentView(); | 2321 focusDocumentView(); |
| 2322 return true; | 2322 return true; |
| 2323 } | 2323 } |
| 2324 } | 2324 } |
| 2325 } | 2325 } |
| 2326 return sendContextMenuEventForGesture(targetedEvent); | 2326 return sendContextMenuEventForGesture(targetedEvent); |
| 2327 } | 2327 } |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 m_mousePressed = false; | 2701 m_mousePressed = false; |
| 2702 LayoutPoint viewportPos = v->windowToContents(event.position()); | 2702 LayoutPoint viewportPos = v->windowToContents(event.position()); |
| 2703 HitTestRequest request(HitTestRequest::Active); | 2703 HitTestRequest request(HitTestRequest::Active); |
| 2704 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); | 2704 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); |
| 2705 | 2705 |
| 2706 if (!m_frame->selection().contains(viewportPos) | 2706 if (!m_frame->selection().contains(viewportPos) |
| 2707 && !mev.scrollbar() | 2707 && !mev.scrollbar() |
| 2708 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. | 2708 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. |
| 2709 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items | 2709 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items |
| 2710 // available for text selections. But only if we're above text. | 2710 // available for text selections. But only if we're above text. |
| 2711 && (m_frame->selection().isContentEditable() || (mev.targetNode() && mev
.targetNode()->isTextNode()))) { | 2711 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { |
| 2712 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection | 2712 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection |
| 2713 | 2713 |
| 2714 if (mev.hitTestResult().isMisspelled()) | 2714 if (mev.hitTestResult().isMisspelled()) |
| 2715 selectClosestMisspellingFromMouseEvent(mev); | 2715 selectClosestMisspellingFromMouseEvent(mev); |
| 2716 else if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick(
)) | 2716 else if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick(
)) |
| 2717 selectClosestWordOrLinkFromMouseEvent(mev); | 2717 selectClosestWordOrLinkFromMouseEvent(mev); |
| 2718 } | 2718 } |
| 2719 | 2719 |
| 2720 return !dispatchMouseEvent(EventTypeNames::contextmenu, mev.targetNode(), 0,
event, false); | 2720 return !dispatchMouseEvent(EventTypeNames::contextmenu, mev.innerNode(), 0,
event, false); |
| 2721 } | 2721 } |
| 2722 | 2722 |
| 2723 bool EventHandler::sendContextMenuEventForKey() | 2723 bool EventHandler::sendContextMenuEventForKey() |
| 2724 { | 2724 { |
| 2725 FrameView* view = m_frame->view(); | 2725 FrameView* view = m_frame->view(); |
| 2726 if (!view) | 2726 if (!view) |
| 2727 return false; | 2727 return false; |
| 2728 | 2728 |
| 2729 Document* doc = m_frame->document(); | 2729 Document* doc = m_frame->document(); |
| 2730 if (!doc) | 2730 if (!doc) |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3813 | 3813 |
| 3814 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) | 3814 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) |
| 3815 { | 3815 { |
| 3816 // If we're clicking into a frame that is selected, the frame will appear | 3816 // If we're clicking into a frame that is selected, the frame will appear |
| 3817 // greyed out even though we're clicking on the selection. This looks | 3817 // greyed out even though we're clicking on the selection. This looks |
| 3818 // really strange (having the whole frame be greyed out), so we deselect the | 3818 // really strange (having the whole frame be greyed out), so we deselect the |
| 3819 // selection. | 3819 // selection. |
| 3820 IntPoint p = m_frame->view()->windowToContents(mev.event().position()); | 3820 IntPoint p = m_frame->view()->windowToContents(mev.event().position()); |
| 3821 if (m_frame->selection().contains(p)) { | 3821 if (m_frame->selection().contains(p)) { |
| 3822 VisiblePosition visiblePos( | 3822 VisiblePosition visiblePos( |
| 3823 mev.targetNode()->renderer()->positionForPoint(mev.localPoint())); | 3823 mev.innerNode()->renderer()->positionForPoint(mev.localPoint())); |
| 3824 VisibleSelection newSelection(visiblePos); | 3824 VisibleSelection newSelection(visiblePos); |
| 3825 m_frame->selection().setSelection(newSelection); | 3825 m_frame->selection().setSelection(newSelection); |
| 3826 } | 3826 } |
| 3827 | 3827 |
| 3828 subframe->eventHandler().handleMousePressEvent(mev.event()); | 3828 subframe->eventHandler().handleMousePressEvent(mev.event()); |
| 3829 return true; | 3829 return true; |
| 3830 } | 3830 } |
| 3831 | 3831 |
| 3832 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me
v, LocalFrame* subframe, HitTestResult* hoveredNode) | 3832 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me
v, LocalFrame* subframe, HitTestResult* hoveredNode) |
| 3833 { | 3833 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3854 // the event via an EventTargetNode dispatch when this returns false. | 3854 // the event via an EventTargetNode dispatch when this returns false. |
| 3855 if (!widget->isFrameView()) | 3855 if (!widget->isFrameView()) |
| 3856 return false; | 3856 return false; |
| 3857 | 3857 |
| 3858 return toFrameView(widget)->frame().eventHandler().handleWheelEvent(wheelEve
nt); | 3858 return toFrameView(widget)->frame().eventHandler().handleWheelEvent(wheelEve
nt); |
| 3859 } | 3859 } |
| 3860 | 3860 |
| 3861 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
esults& event) | 3861 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
esults& event) |
| 3862 { | 3862 { |
| 3863 // Figure out which view to send the event to. | 3863 // Figure out which view to send the event to. |
| 3864 if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetN
ode()->renderer()->isWidget()) | 3864 if (!event.innerNode() || !event.innerNode()->renderer() || !event.innerNode
()->renderer()->isWidget()) |
| 3865 return false; | 3865 return false; |
| 3866 return false; | 3866 return false; |
| 3867 } | 3867 } |
| 3868 | 3868 |
| 3869 PassRefPtrWillBeRawPtr<DataTransfer> EventHandler::createDraggingDataTransfer()
const | 3869 PassRefPtrWillBeRawPtr<DataTransfer> EventHandler::createDraggingDataTransfer()
const |
| 3870 { | 3870 { |
| 3871 return DataTransfer::create(DataTransfer::DragAndDrop, DataTransferWritable,
DataObject::create()); | 3871 return DataTransfer::create(DataTransfer::DragAndDrop, DataTransferWritable,
DataObject::create()); |
| 3872 } | 3872 } |
| 3873 | 3873 |
| 3874 void EventHandler::focusDocumentView() | 3874 void EventHandler::focusDocumentView() |
| 3875 { | 3875 { |
| 3876 Page* page = m_frame->page(); | 3876 Page* page = m_frame->page(); |
| 3877 if (!page) | 3877 if (!page) |
| 3878 return; | 3878 return; |
| 3879 page->focusController().focusDocumentView(m_frame); | 3879 page->focusController().focusDocumentView(m_frame); |
| 3880 } | 3880 } |
| 3881 | 3881 |
| 3882 unsigned EventHandler::accessKeyModifiers() | 3882 unsigned EventHandler::accessKeyModifiers() |
| 3883 { | 3883 { |
| 3884 #if OS(MACOSX) | 3884 #if OS(MACOSX) |
| 3885 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3885 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 3886 #else | 3886 #else |
| 3887 return PlatformEvent::AltKey; | 3887 return PlatformEvent::AltKey; |
| 3888 #endif | 3888 #endif |
| 3889 } | 3889 } |
| 3890 | 3890 |
| 3891 } // namespace blink | 3891 } // namespace blink |
| OLD | NEW |