Commit bb707344 authored by mitz@apple.com's avatar mitz@apple.com

Reviewed by Darin Adler.

        - fix <rdar://problem/5450655> Control-clicking text in a link can surprisingly select only part of the link, should select entire link

        No test because context menu events cannot be tested in DumpRenderTree.

        * page/EventHandler.cpp:
        (WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent): Added.
        If the click occurred in an active link, selects the entire link
        element. Otherwise selects the closest word.
        (WebCore::EventHandler::sendContextMenuEvent): Call
        selectClosestWordOrLinkFromMouseEvent().
        * page/EventHandler.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4b5a82dc
2007-11-10 Dan Bernstein <mitz@apple.com>
Reviewed by Darin Adler.
- fix <rdar://problem/5450655> Control-clicking text in a link can surprisingly select only part of the link, should select entire link
No test because context menu events cannot be tested in DumpRenderTree.
* page/EventHandler.cpp:
(WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent): Added.
If the click occurred in an active link, selects the entire link
element. Otherwise selects the closest word.
(WebCore::EventHandler::sendContextMenuEvent): Call
selectClosestWordOrLinkFromMouseEvent().
* page/EventHandler.h:
2007-11-10 John Sullivan <sullivan@apple.com>
Reviewed by Tim Hatcher
......
......@@ -169,6 +169,30 @@ void EventHandler::selectClosestWordFromMouseEvent(const MouseEventWithHitTestRe
}
}
void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults& result)
{
if (!result.hitTestResult().isLiveLink())
return selectClosestWordFromMouseEvent(result);
Node* innerNode = result.targetNode();
if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) {
Selection newSelection;
Element* URLElement = result.hitTestResult().URLElement();
VisiblePosition pos(innerNode->renderer()->positionForPoint(result.localPoint()));
if (pos.isNotNull() && pos.deepEquivalent().node()->isDescendantOf(URLElement))
newSelection = Selection::selectionFromContentsOfNode(URLElement);
if (newSelection.isRange()) {
m_frame->setSelectionGranularity(WordGranularity);
m_beganSelectingText = true;
}
if (m_frame->shouldChangeSelection(newSelection))
m_frame->selectionController()->setSelection(newSelection);
}
}
bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestResults& event)
{
if (event.event().button() != LeftButton)
......@@ -1348,7 +1372,7 @@ bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
// available for text selections. But only if we're above text.
(m_frame->selectionController()->isContentEditable() || mev.targetNode() && mev.targetNode()->isTextNode())) {
m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection
selectClosestWordFromMouseEvent(mev);
selectClosestWordOrLinkFromMouseEvent(mev);
}
swallowEvent = dispatchMouseEvent(contextmenuEvent, mev.targetNode(), true, 0, event, true);
......
......@@ -182,6 +182,7 @@ private:
bool eventActivatedView(const PlatformMouseEvent&) const;
void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults& event);
void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults& event);
bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment