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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult
& result, AppendTrailingWhitespace appendTrailingWhitespace) | 437 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult
& result, AppendTrailingWhitespace appendTrailingWhitespace) |
438 { | 438 { |
439 Node* innerNode = result.targetNode(); | 439 Node* innerNode = result.targetNode(); |
440 VisibleSelection newSelection; | 440 VisibleSelection newSelection; |
441 | 441 |
442 if (innerNode && innerNode->renderer()) { | 442 if (innerNode && innerNode->renderer()) { |
443 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); | 443 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); |
444 Position start = pos.deepEquivalent(); | 444 Position start = pos.deepEquivalent(); |
445 Position end = pos.deepEquivalent(); | 445 Position end = pos.deepEquivalent(); |
446 if (pos.isNotNull()) { | 446 if (pos.isNotNull()) { |
447 Vector<DocumentMarker*> markers = innerNode->document()->markers()->
markersInRange( | 447 Vector<DocumentMarker*> markers = innerNode->document().markers()->m
arkersInRange( |
448 makeRange(pos, pos).get(), DocumentMarker::Spelling | DocumentMa
rker::Grammar); | 448 makeRange(pos, pos).get(), DocumentMarker::Spelling | DocumentMa
rker::Grammar); |
449 if (markers.size() == 1) { | 449 if (markers.size() == 1) { |
450 start.moveToOffset(markers[0]->startOffset()); | 450 start.moveToOffset(markers[0]->startOffset()); |
451 end.moveToOffset(markers[0]->endOffset()); | 451 end.moveToOffset(markers[0]->endOffset()); |
452 newSelection = VisibleSelection(start, end); | 452 newSelection = VisibleSelection(start, end); |
453 } | 453 } |
454 } | 454 } |
455 | 455 |
456 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel
ection.isRange()) | 456 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel
ection.isRange()) |
457 newSelection.appendTrailingWhitespace(); | 457 newSelection.appendTrailingWhitespace(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 if (pos.isNotNull()) { | 526 if (pos.isNotNull()) { |
527 newSelection = VisibleSelection(pos); | 527 newSelection = VisibleSelection(pos); |
528 newSelection.expandUsingGranularity(ParagraphGranularity); | 528 newSelection.expandUsingGranularity(ParagraphGranularity); |
529 } | 529 } |
530 | 530 |
531 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe
lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); | 531 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe
lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); |
532 } | 532 } |
533 | 533 |
534 static int textDistance(const Position& start, const Position& end) | 534 static int textDistance(const Position& start, const Position& end) |
535 { | 535 { |
536 RefPtr<Range> range = Range::create(start.anchorNode()->document(), start,
end); | 536 RefPtr<Range> range = Range::create(&start.anchorNode()->document(), start,
end); |
537 return TextIterator::rangeLength(range.get(), true); | 537 return TextIterator::rangeLength(range.get(), true); |
538 } | 538 } |
539 | 539 |
540 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
esults& event) | 540 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
esults& event) |
541 { | 541 { |
542 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 542 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
543 Node* innerNode = event.targetNode(); | 543 Node* innerNode = event.targetNode(); |
544 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) | 544 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) |
545 return false; | 545 return false; |
546 | 546 |
547 // Extend the selection if the Shift key is down, unless the click is in a l
ink. | 547 // Extend the selection if the Shift key is down, unless the click is in a l
ink. |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 } | 1958 } |
1959 } | 1959 } |
1960 } | 1960 } |
1961 | 1961 |
1962 // Fire mouseout/mouseover if the mouse has shifted to a different node. | 1962 // Fire mouseout/mouseover if the mouse has shifted to a different node. |
1963 if (fireMouseOverOut) { | 1963 if (fireMouseOverOut) { |
1964 RenderLayer* layerForLastNode = layerForNode(m_lastNodeUnderMouse.get())
; | 1964 RenderLayer* layerForLastNode = layerForNode(m_lastNodeUnderMouse.get())
; |
1965 RenderLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get(
)); | 1965 RenderLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get(
)); |
1966 Page* page = m_frame->page(); | 1966 Page* page = m_frame->page(); |
1967 | 1967 |
1968 if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->docu
ment() != m_frame->document())) { | 1968 if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || &m_nodeUnderMouse->doc
ument() != m_frame->document())) { |
1969 // The mouse has moved between frames. | 1969 // The mouse has moved between frames. |
1970 if (Frame* frame = m_lastNodeUnderMouse->document()->frame()) { | 1970 if (Frame* frame = m_lastNodeUnderMouse->document().frame()) { |
1971 if (FrameView* frameView = frame->view()) | 1971 if (FrameView* frameView = frame->view()) |
1972 frameView->mouseExitedContentArea(); | 1972 frameView->mouseExitedContentArea(); |
1973 } | 1973 } |
1974 } else if (page && (layerForLastNode && (!layerForNodeUnderMouse || laye
rForNodeUnderMouse != layerForLastNode))) { | 1974 } else if (page && (layerForLastNode && (!layerForNodeUnderMouse || laye
rForNodeUnderMouse != layerForLastNode))) { |
1975 // The mouse has moved between layers. | 1975 // The mouse has moved between layers. |
1976 if (ScrollableArea* scrollableAreaForLastNode = associatedScrollable
Area(layerForLastNode)) | 1976 if (ScrollableArea* scrollableAreaForLastNode = associatedScrollable
Area(layerForLastNode)) |
1977 scrollableAreaForLastNode->mouseExitedContentArea(); | 1977 scrollableAreaForLastNode->mouseExitedContentArea(); |
1978 } | 1978 } |
1979 | 1979 |
1980 if (m_nodeUnderMouse && (!m_lastNodeUnderMouse || m_lastNodeUnderMouse->
document() != m_frame->document())) { | 1980 if (m_nodeUnderMouse && (!m_lastNodeUnderMouse || &m_lastNodeUnderMouse-
>document() != m_frame->document())) { |
1981 // The mouse has moved between frames. | 1981 // The mouse has moved between frames. |
1982 if (Frame* frame = m_nodeUnderMouse->document()->frame()) { | 1982 if (Frame* frame = m_nodeUnderMouse->document().frame()) { |
1983 if (FrameView* frameView = frame->view()) | 1983 if (FrameView* frameView = frame->view()) |
1984 frameView->mouseEnteredContentArea(); | 1984 frameView->mouseEnteredContentArea(); |
1985 } | 1985 } |
1986 } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || laye
rForNodeUnderMouse != layerForLastNode))) { | 1986 } else if (page && (layerForNodeUnderMouse && (!layerForLastNode || laye
rForNodeUnderMouse != layerForLastNode))) { |
1987 // The mouse has moved between layers. | 1987 // The mouse has moved between layers. |
1988 if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScro
llableArea(layerForNodeUnderMouse)) | 1988 if (ScrollableArea* scrollableAreaForNodeUnderMouse = associatedScro
llableArea(layerForNodeUnderMouse)) |
1989 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); | 1989 scrollableAreaForNodeUnderMouse->mouseEnteredContentArea(); |
1990 } | 1990 } |
1991 | 1991 |
1992 if (m_lastNodeUnderMouse && m_lastNodeUnderMouse->document() != m_frame-
>document()) { | 1992 if (m_lastNodeUnderMouse && &m_lastNodeUnderMouse->document() != m_frame
->document()) { |
1993 m_lastNodeUnderMouse = 0; | 1993 m_lastNodeUnderMouse = 0; |
1994 m_lastScrollbarUnderMouse = 0; | 1994 m_lastScrollbarUnderMouse = 0; |
1995 m_lastInstanceUnderMouse = 0; | 1995 m_lastInstanceUnderMouse = 0; |
1996 } | 1996 } |
1997 | 1997 |
1998 if (m_lastNodeUnderMouse != m_nodeUnderMouse) { | 1998 if (m_lastNodeUnderMouse != m_nodeUnderMouse) { |
1999 // send mouseout event to the old node | 1999 // send mouseout event to the old node |
2000 if (m_lastNodeUnderMouse) | 2000 if (m_lastNodeUnderMouse) |
2001 m_lastNodeUnderMouse->dispatchMouseEvent(mouseEvent, eventNames(
).mouseoutEvent, 0, m_nodeUnderMouse.get()); | 2001 m_lastNodeUnderMouse->dispatchMouseEvent(mouseEvent, eventNames(
).mouseoutEvent, 0, m_nodeUnderMouse.get()); |
2002 // send mouseover event to the new node | 2002 // send mouseover event to the new node |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3629 continue; | 3629 continue; |
3630 | 3630 |
3631 Node* node = result.innerNode(); | 3631 Node* node = result.innerNode(); |
3632 if (!node) | 3632 if (!node) |
3633 continue; | 3633 continue; |
3634 | 3634 |
3635 // Touch events should not go to text nodes | 3635 // Touch events should not go to text nodes |
3636 if (node->isTextNode()) | 3636 if (node->isTextNode()) |
3637 node = EventPathWalker::parent(node); | 3637 node = EventPathWalker::parent(node); |
3638 | 3638 |
3639 Document* doc = node->document(); | 3639 Document& doc = node->document(); |
3640 // Record the originating touch document even if it does not have a
touch listener. | 3640 // Record the originating touch document even if it does not have a
touch listener. |
3641 if (freshTouchEvents) { | 3641 if (freshTouchEvents) { |
3642 m_originatingTouchPointDocument = doc; | 3642 m_originatingTouchPointDocument = &doc; |
3643 freshTouchEvents = false; | 3643 freshTouchEvents = false; |
3644 } | 3644 } |
3645 if (!doc->hasTouchEventHandlers()) | 3645 if (!doc.hasTouchEventHandlers()) |
3646 continue; | 3646 continue; |
3647 m_originatingTouchPointTargets.set(touchPointTargetKey, node); | 3647 m_originatingTouchPointTargets.set(touchPointTargetKey, node); |
3648 touchTarget = node; | 3648 touchTarget = node; |
3649 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState
== PlatformTouchPoint::TouchCancelled) { | 3649 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState
== PlatformTouchPoint::TouchCancelled) { |
3650 // We only perform a hittest on release or cancel to unset :active o
r :hover state. | 3650 // We only perform a hittest on release or cancel to unset :active o
r :hover state. |
3651 if (touchPointTargetKey == m_originatingTouchPointTargetKey) { | 3651 if (touchPointTargetKey == m_originatingTouchPointTargetKey) { |
3652 hitTestResultAtPoint(pagePoint, hitType); | 3652 hitTestResultAtPoint(pagePoint, hitType); |
3653 m_originatingTouchPointTargetKey = 0; | 3653 m_originatingTouchPointTargetKey = 0; |
3654 } else if (m_originatingTouchPointDocument.get() && m_originatingTou
chPointDocument->frame()) { | 3654 } else if (m_originatingTouchPointDocument.get() && m_originatingTou
chPointDocument->frame()) { |
3655 LayoutPoint pagePointInOriginatingDocument = documentPointForWin
dowPoint(m_originatingTouchPointDocument->frame(), point.pos()); | 3655 LayoutPoint pagePointInOriginatingDocument = documentPointForWin
dowPoint(m_originatingTouchPointDocument->frame(), point.pos()); |
3656 hitTestResultInFrame(m_originatingTouchPointDocument->frame(), p
agePointInOriginatingDocument, hitType); | 3656 hitTestResultInFrame(m_originatingTouchPointDocument->frame(), p
agePointInOriginatingDocument, hitType); |
3657 } | 3657 } |
3658 // The target should be the original target for this touch, so get i
t from the hashmap. As it's a release or cancel | 3658 // The target should be the original target for this touch, so get i
t from the hashmap. As it's a release or cancel |
3659 // we also remove it from the map. | 3659 // we also remove it from the map. |
3660 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe
y); | 3660 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe
y); |
3661 } else | 3661 } else |
3662 // No hittest is performed on move or stationary, since the target i
s not allowed to change anyway. | 3662 // No hittest is performed on move or stationary, since the target i
s not allowed to change anyway. |
3663 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey
); | 3663 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey
); |
3664 | 3664 |
3665 if (!touchTarget.get()) | 3665 if (!touchTarget.get()) |
3666 continue; | 3666 continue; |
3667 Document* doc = touchTarget->toNode()->document(); | 3667 Document& doc = touchTarget->toNode()->document(); |
3668 if (!doc->hasTouchEventHandlers()) | 3668 if (!doc.hasTouchEventHandlers()) |
3669 continue; | 3669 continue; |
3670 Frame* targetFrame = doc->frame(); | 3670 Frame* targetFrame = doc.frame(); |
3671 if (!targetFrame) | 3671 if (!targetFrame) |
3672 continue; | 3672 continue; |
3673 | 3673 |
3674 if (m_frame != targetFrame) { | 3674 if (m_frame != targetFrame) { |
3675 // pagePoint should always be relative to the target elements contai
ning frame. | 3675 // pagePoint should always be relative to the target elements contai
ning frame. |
3676 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); | 3676 pagePoint = documentPointForWindowPoint(targetFrame, point.pos()); |
3677 } | 3677 } |
3678 | 3678 |
3679 float scaleFactor = targetFrame->pageZoomFactor(); | 3679 float scaleFactor = targetFrame->pageZoomFactor(); |
3680 | 3680 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3729 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); | 3729 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); |
3730 const EventTargetSet& targetsForState = changedTouches[state].m_targets; | 3730 const EventTargetSet& targetsForState = changedTouches[state].m_targets; |
3731 | 3731 |
3732 for (EventTargetSet::const_iterator it = targetsForState.begin(); it !=
targetsForState.end(); ++it) { | 3732 for (EventTargetSet::const_iterator it = targetsForState.begin(); it !=
targetsForState.end(); ++it) { |
3733 EventTarget* touchEventTarget = it->get(); | 3733 EventTarget* touchEventTarget = it->get(); |
3734 RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : tou
chesByTarget.get(touchEventTarget)); | 3734 RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : tou
chesByTarget.get(touchEventTarget)); |
3735 ASSERT(targetTouches); | 3735 ASSERT(targetTouches); |
3736 | 3736 |
3737 RefPtr<TouchEvent> touchEvent = | 3737 RefPtr<TouchEvent> touchEvent = |
3738 TouchEvent::create(effectiveTouches.get(), targetTouches.get(),
changedTouches[state].m_touches.get(), | 3738 TouchEvent::create(effectiveTouches.get(), targetTouches.get(),
changedTouches[state].m_touches.get(), |
3739 stateName, touchEventTarget->toNode()->docume
nt()->defaultView(), | 3739 stateName, touchEventTarget->toNode()->docume
nt().defaultView(), |
3740 0, 0, 0, 0, event.ctrlKey(), event.altKey(),
event.shiftKey(), event.metaKey()); | 3740 0, 0, 0, 0, event.ctrlKey(), event.altKey(),
event.shiftKey(), event.metaKey()); |
3741 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); | 3741 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); |
3742 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); | 3742 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); |
3743 } | 3743 } |
3744 } | 3744 } |
3745 | 3745 |
3746 return swallowedEvent; | 3746 return swallowedEvent; |
3747 } | 3747 } |
3748 | 3748 |
3749 bool EventHandler::dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent
& event) | 3749 bool EventHandler::dispatchSyntheticTouchEventIfEnabled(const PlatformMouseEvent
& event) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3848 unsigned EventHandler::accessKeyModifiers() | 3848 unsigned EventHandler::accessKeyModifiers() |
3849 { | 3849 { |
3850 #if OS(DARWIN) | 3850 #if OS(DARWIN) |
3851 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3851 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3852 #else | 3852 #else |
3853 return PlatformEvent::AltKey; | 3853 return PlatformEvent::AltKey; |
3854 #endif | 3854 #endif |
3855 } | 3855 } |
3856 | 3856 |
3857 } // namespace WebCore | 3857 } // namespace WebCore |
OLD | NEW |