Commit aeb741cb authored by darin's avatar darin

LayoutTests:

        Reviewed by Adele.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8111
          REGRESSION (NativeTextField): first click in form field on weather.com leaves focus
          but no caret

        - updated results for improved dumping of selection location in DumpRenderTree

        * fast/forms/input-text-self-emptying-click-expected.checksum: Added.
        * fast/forms/input-text-self-emptying-click-expected.png: Added.
        * fast/forms/input-text-self-emptying-click-expected.txt: Added.
        * fast/forms/input-text-self-emptying-click.html: Added.

        * editing/selection/3690703-2-expected.txt: Updated.
        * fast/forms/input-appearance-focus-expected.txt: Updated.
        * fast/forms/input-appearance-readonly-expected.txt: Updated.
        * fast/forms/input-appearance-selection-expected.txt: Updated.
        * fast/forms/input-paste-undo-expected.txt: Updated.
        * fast/forms/input-text-double-click-expected.txt: Updated.
        * fast/forms/input-text-option-delete-expected.txt: Updated.
        * fast/forms/input-text-scroll-left-on-blur-expected.txt: Updated.
        * fast/forms/plaintext-mode-2-expected.txt: Updated.

WebCore:

        Reviewed by Adele.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8111
          REGRESSION (NativeTextField): first click in form field on weather.com leaves focus
          but no caret

        Test: fast/forms/input-text-self-emptying-click.html

        * page/MouseEventWithHitTestResults.h: Removed url, target, m_url and m_target,
        replacing them with isOverLink and m_isOverLink. Replaced innerNode with targetNode,
        and added logic to handle the case where the target node is removed from the document
        but the element the target node was in is still inside the document.
        * page/MouseEventWithHitTestResults.cpp: Added.

        * WebCore.xcodeproj/project.pbxproj: Added MouseEventWithHitTestResults.cpp.
        * WebCore.vcproj/WebCore/WebCore.vcproj: Ditto.

        * kwq/RenderTreeAsText.cpp: (nodePosition): Added a call to shadowParentNode so we
        correctly dump positions within shadow trees. This was needed to give a good result
        from my new test for this bug.

        * dom/Document.cpp:
        (WebCore::Document::prepareMouseEvent): Update to pass fewer parameters to the
        constructor for MouseEventWithHitTestResults. Now takes isOverLink boolean, and no
        longer takes href and target parameters.

        * page/Frame.cpp:
        (WebCore::Frame::handleMousePressEventDoubleClick): Use new name targetNode, instead
        of old name innerNode.
        (WebCore::Frame::handleMousePressEventTripleClick): Ditto.
        (WebCore::Frame::handleMousePressEventSingleClick): Ditto. Also change code to check
        if over a link to use !isOverLink instead of url.isNull.
        (WebCore::Frame::handleMousePressEvent): Ditto. Also remove unused "url" local variable.
        (WebCore::Frame::handleMouseMoveEvent): Ditto.
        (WebCore::Frame::handleMouseReleaseEvent): Ditto.
        (WebCore::Frame::passWidgetMouseDownEventToWidget): Ditto.

        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::handleMousePressEvent): Use new name targetNode, instead of old
        name innerNode.
        (WebCore::FrameMac::handleMouseMoveEvent): Ditto.
        (WebCore::FrameMac::passSubframeEventToSubframe): Ditto.
        (WebCore::FrameMac::sendContextMenuEvent): Ditto.

        * page/FrameView.cpp:
        (WebCore::subframeForEvent): Use new name targetNode, instead of old name innerNode.
        (WebCore::FrameView::handleMousePressEvent): Ditto.
        (WebCore::FrameView::handleMouseDoubleClickEvent): Ditto.
        (WebCore::selectCursor): Ditto. Also change code to check if over a link to use
        isOverLink instead of !url.isNull.
        (WebCore::FrameView::handleMouseMoveEvent): Ditto.
        (WebCore::FrameView::handleMouseReleaseEvent): Ditto.
        (WebCore::FrameView::updateDragAndDrop): Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@13715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 98f00f91
2006-04-05 Darin Adler <darin@apple.com>
Reviewed by Adele.
- test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8111
REGRESSION (NativeTextField): first click in form field on weather.com leaves focus
but no caret
- updated results for improved dumping of selection location in DumpRenderTree
* fast/forms/input-text-self-emptying-click-expected.checksum: Added.
* fast/forms/input-text-self-emptying-click-expected.png: Added.
* fast/forms/input-text-self-emptying-click-expected.txt: Added.
* fast/forms/input-text-self-emptying-click.html: Added.
* editing/selection/3690703-2-expected.txt: Updated.
* fast/forms/input-appearance-focus-expected.txt: Updated.
* fast/forms/input-appearance-readonly-expected.txt: Updated.
* fast/forms/input-appearance-selection-expected.txt: Updated.
* fast/forms/input-paste-undo-expected.txt: Updated.
* fast/forms/input-text-double-click-expected.txt: Updated.
* fast/forms/input-text-option-delete-expected.txt: Updated.
* fast/forms/input-text-scroll-left-on-blur-expected.txt: Updated.
* fast/forms/plaintext-mode-2-expected.txt: Updated.
2006-04-05 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed and landed by Maciej.
......
......@@ -145,4 +145,4 @@ layer at (0,0) size 800x600
text run at (362,0) width 60: "\x{A9}2005 Google"
layer at (205,85) size 387x13
RenderBlock {DIV} at (3,3) size 387x13
caret: position 0 of document
caret: position 0 of child 0 {DIV} of child 1 {INPUT} of child 1 {TD} of child 0 {TR} of child 0 {TBODY} of child 2 {TABLE} of child 4 {DIV} of child 0 {CENTER} of child 1 {BODY} of child 0 {HTML} of document
......@@ -34,5 +34,5 @@ layer at (169,47) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
RenderText {TEXT} at (1,0) size 82x13
text run at (1,0) width 82: "My Text Field 2"
selection start: position 0 of child 0 {TEXT} of document
selection end: position 15 of child 0 {TEXT} of document
selection start: position 0 of child 0 {TEXT} of child 0 {DIV} of child 3 {INPUT} of child 1 {P} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 15 of child 0 {TEXT} of child 0 {DIV} of child 3 {INPUT} of child 1 {P} of child 0 {BODY} of child 0 {HTML} of document
......@@ -14,5 +14,5 @@ layer at (13,31) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
RenderText {TEXT} at (1,0) size 63x13
text run at (1,0) width 63: "Test Passed"
selection start: position 0 of child 0 {TEXT} of document
selection end: position 11 of child 0 {TEXT} of document
selection start: position 0 of child 0 {TEXT} of child 0 {DIV} of child 2 {INPUT} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 11 of child 0 {TEXT} of child 0 {DIV} of child 2 {INPUT} of child 1 {BODY} of child 0 {HTML} of document
......@@ -87,5 +87,5 @@ layer at (13,47) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
RenderText {TEXT} at (1,0) size 131x13
text run at (1,0) width 131: "123456789 ABCDEFGHIJ"
selection start: position 3 of child 0 {TEXT} of document
selection end: position 12 of child 0 {TEXT} of document
selection start: position 3 of child 0 {TEXT} of child 0 {DIV} of child 1 {INPUT} of child 1 {P} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 12 of child 0 {TEXT} of child 0 {DIV} of child 1 {INPUT} of child 1 {P} of child 1 {BODY} of child 0 {HTML} of document
......@@ -32,4 +32,4 @@ layer at (0,0) size 800x600
RenderBlock {DIV} at (0,95) size 784x0
layer at (13,67) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
caret: position 0 of document
caret: position 0 of child 0 {DIV} of child 4 {INPUT} of child 1 {BODY} of child 0 {HTML} of document
......@@ -17,5 +17,5 @@ layer at (13,13) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
RenderText {TEXT} at (1,0) size 72x13
text run at (1,0) width 72: "word another"
selection start: position 0 of child 0 {TEXT} of document
selection end: position 4 of child 0 {TEXT} of document
selection start: position 0 of child 0 {TEXT} of child 0 {DIV} of child 0 {INPUT} of child 0 {BODY} of child 0 {HTML} of document
selection end: position 4 of child 0 {TEXT} of child 0 {DIV} of child 0 {INPUT} of child 0 {BODY} of child 0 {HTML} of document
......@@ -21,4 +21,4 @@ layer at (13,13) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
RenderText {TEXT} at (1,0) size 30x13
text run at (1,0) width 30: "word "
caret: position 5 of child 0 {TEXT} of document
caret: position 5 of child 0 {TEXT} of child 0 {DIV} of child 0 {INPUT} of child 0 {BODY} of child 0 {HTML} of document
......@@ -48,4 +48,4 @@ layer at (325,13) size 142x13 scrollX 179 scrollWidth 321
RenderBlock {DIV} at (3,3) size 142x13
RenderText {TEXT} at (1,0) size 319x13
text run at (1,0) width 319: "this text field has a lot of text in it so that it needs to scroll"
caret: position 66 of child 0 {TEXT} of document
caret: position 66 of child 0 {TEXT} of child 0 {DIV} of child 4 {INPUT} of child 0 {BODY} of child 0 {HTML} of document
7728295f47080a91a3e4168251882b47
\ No newline at end of file
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV to 0 of DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
layer at (0,0) size 800x600
RenderCanvas at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x576
RenderBlock (anonymous) at (0,0) size 784x23
RenderTextField {INPUT} at (2,2) size 148x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderText {TEXT} at (0,0) size 0x0
RenderBlock {P} at (0,39) size 784x36
RenderText {TEXT} at (0,0) size 776x36
text run at (0,0) width 776: "Tests clicking on an input element that has a value that self-destructs. If the test succeeds, there should be a blinking caret in"
text run at (0,18) width 82: "the text field."
layer at (13,13) size 142x13
RenderBlock {DIV} at (3,3) size 142x13
caret: position 0 of child 0 {DIV} of child 0 {INPUT} of child 0 {BODY} of child 0 {HTML} of document
<input type="text" onfocus="this.value=''" value="click to edit">
<p>Tests clicking on an input element that has a value that self-destructs. If the test succeeds, there should be a blinking caret in the text field.</p>
<script>
if (window.eventSender) {
eventSender.mouseMoveTo(15, 15);
eventSender.mouseDown();
eventSender.mouseUp();
}
</script>
......@@ -45,4 +45,4 @@ layer at (11,13) size 594x13
RenderBlock {DIV} at (3,3) size 594x13
RenderText {TEXT} at (1,0) size 480x13
text run at (1,0) width 480: "This styled text, and link will be pasted into the textfield. All richness should be stripped."
caret: position 94 of child 0 {TEXT} of document
caret: position 94 of child 0 {TEXT} of child 0 {DIV} of child 0 {INPUT} of child 1 {BODY} of child 0 {HTML} of document
2006-04-05 Darin Adler <darin@apple.com>
Reviewed by Adele.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8111
REGRESSION (NativeTextField): first click in form field on weather.com leaves focus
but no caret
Test: fast/forms/input-text-self-emptying-click.html
* page/MouseEventWithHitTestResults.h: Removed url, target, m_url and m_target,
replacing them with isOverLink and m_isOverLink. Replaced innerNode with targetNode,
and added logic to handle the case where the target node is removed from the document
but the element the target node was in is still inside the document.
* page/MouseEventWithHitTestResults.cpp: Added.
* WebCore.xcodeproj/project.pbxproj: Added MouseEventWithHitTestResults.cpp.
* WebCore.vcproj/WebCore/WebCore.vcproj: Ditto.
* kwq/RenderTreeAsText.cpp: (nodePosition): Added a call to shadowParentNode so we
correctly dump positions within shadow trees. This was needed to give a good result
from my new test for this bug.
* dom/Document.cpp:
(WebCore::Document::prepareMouseEvent): Update to pass fewer parameters to the
constructor for MouseEventWithHitTestResults. Now takes isOverLink boolean, and no
longer takes href and target parameters.
* page/Frame.cpp:
(WebCore::Frame::handleMousePressEventDoubleClick): Use new name targetNode, instead
of old name innerNode.
(WebCore::Frame::handleMousePressEventTripleClick): Ditto.
(WebCore::Frame::handleMousePressEventSingleClick): Ditto. Also change code to check
if over a link to use !isOverLink instead of url.isNull.
(WebCore::Frame::handleMousePressEvent): Ditto. Also remove unused "url" local variable.
(WebCore::Frame::handleMouseMoveEvent): Ditto.
(WebCore::Frame::handleMouseReleaseEvent): Ditto.
(WebCore::Frame::passWidgetMouseDownEventToWidget): Ditto.
* bridge/mac/FrameMac.mm:
(WebCore::FrameMac::handleMousePressEvent): Use new name targetNode, instead of old
name innerNode.
(WebCore::FrameMac::handleMouseMoveEvent): Ditto.
(WebCore::FrameMac::passSubframeEventToSubframe): Ditto.
(WebCore::FrameMac::sendContextMenuEvent): Ditto.
* page/FrameView.cpp:
(WebCore::subframeForEvent): Use new name targetNode, instead of old name innerNode.
(WebCore::FrameView::handleMousePressEvent): Ditto.
(WebCore::FrameView::handleMouseDoubleClickEvent): Ditto.
(WebCore::selectCursor): Ditto. Also change code to check if over a link to use
isOverLink instead of !url.isNull.
(WebCore::FrameView::handleMouseMoveEvent): Ditto.
(WebCore::FrameView::handleMouseReleaseEvent): Ditto.
(WebCore::FrameView::updateDragAndDrop): Ditto.
2006-04-05 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed and landed by Maciej.
......@@ -602,6 +602,10 @@
RelativePath="..\..\page\FrameView.h"
>
</File>
<File
RelativePath="..\..\page\MouseEventWithHitTestResults.cpp"
>
</File>
<File
RelativePath="..\..\page\MouseEventWithHitTestResults.h"
>
......
......@@ -298,6 +298,7 @@
93CD4FEC0995FD2A007ECC97 /* PlatformString.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CD4FEB0995FD2A007ECC97 /* PlatformString.h */; };
93E47C5C09BE2BBB0019C5C1 /* PageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93E47C5B09BE2BBB0019C5C1 /* PageMac.mm */; };
93E62D9B0985F41600E1B5E3 /* SystemTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E62D990985F41600E1B5E3 /* SystemTime.h */; };
93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */; };
93EEC1FA09C2877700C515D1 /* DocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1E709C2877700C515D1 /* DocPtr.h */; };
93EEC1FF09C2877700C515D1 /* CanvasRenderingContext2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EEC1ED09C2877700C515D1 /* CanvasRenderingContext2D.cpp */; };
93EEC20009C2877700C515D1 /* CanvasRenderingContext2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EEC1EE09C2877700C515D1 /* CanvasRenderingContext2D.h */; };
......@@ -1548,6 +1549,7 @@
93CD4FEB0995FD2A007ECC97 /* PlatformString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformString.h; path = platform/PlatformString.h; sourceTree = "<group>"; };
93E47C5B09BE2BBB0019C5C1 /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = "<group>"; };
93E62D990985F41600E1B5E3 /* SystemTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SystemTime.h; path = platform/SystemTime.h; sourceTree = "<group>"; };
93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; };
93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
93EEC1E609C2877700C515D1 /* CharacterData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CharacterData.idl; sourceTree = "<group>"; };
93EEC1E709C2877700C515D1 /* DocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocPtr.h; sourceTree = "<group>"; };
......@@ -2761,6 +2763,7 @@
65A21483097A3F5300B9050A /* FrameTree.h */,
65CBFEF70974F607001DAC25 /* FrameView.cpp */,
65CBFEF80974F607001DAC25 /* FrameView.h */,
93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */,
935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */,
65FEA86809833ADE00BED4AB /* Page.cpp */,
65A21467097A329100B9050A /* Page.h */,
......@@ -5492,6 +5495,7 @@
659DDC8209E198BA001BF3C6 /* JSDocument.cpp in Sources */,
930705D809E0C9B700B17FE4 /* JSCounter.cpp in Sources */,
930705E909E0C9F000B17FE4 /* JSCSSPrimitiveValue.cpp in Sources */,
93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -1352,12 +1352,12 @@ void FrameMac::handleMousePressEvent(const MouseEventWithHitTestResults& event)
// If we got the event back, that must mean it wasn't prevented,
// so it's allowed to start a drag or selection.
_mouseDownMayStartSelect = canMouseDownStartSelect(event.innerNode());
_mouseDownMayStartSelect = canMouseDownStartSelect(event.targetNode());
// Careful that the drag starting logic stays in sync with eventMayStartDrag()
_mouseDownMayStartDrag = singleClick;
d->m_mousePressNode = event.innerNode();
d->m_mousePressNode = event.targetNode();
if (!passWidgetMouseDownEventToWidget(event, false)) {
// We don't do this at the start of mouse down handling (before calling into WebCore),
......@@ -1696,7 +1696,7 @@ void FrameMac::handleMouseMoveEvent(const MouseEventWithHitTestResults& event)
_mouseDownMayStartDrag = false;
d->m_view->invalidateClick();
Node* node = event.innerNode();
Node* node = event.targetNode();
RenderLayer* layer = 0;
if (node && node->renderer())
layer = node->renderer()->enclosingLayer();
......@@ -1823,7 +1823,7 @@ bool FrameMac::passSubframeEventToSubframe(MouseEventWithHitTestResults& event,
}
case NSLeftMouseDown: {
Node *node = event.innerNode();
Node *node = event.targetNode();
if (!node) {
return false;
}
......@@ -2107,11 +2107,11 @@ bool FrameMac::sendContextMenuEvent(NSEvent *event)
IntPoint viewportPos = v->viewportToContents(mouseEvent.pos());
MouseEventWithHitTestResults mev = doc->prepareMouseEvent(false, true, false, viewportPos, mouseEvent);
swallowEvent = v->dispatchMouseEvent(contextmenuEvent, mev.innerNode(), true, 0, mouseEvent, true);
swallowEvent = v->dispatchMouseEvent(contextmenuEvent, mev.targetNode(), true, 0, mouseEvent, true);
if (!swallowEvent && !isPointInsideSelection(viewportPos) &&
([_bridge selectWordBeforeMenuEvent] || [_bridge isEditable] || mev.innerNode()->isContentEditable())) {
([_bridge selectWordBeforeMenuEvent] || [_bridge isEditable] || mev.targetNode()->isContentEditable())) {
_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection
selectClosestWordFromMouseEvent(mouseEvent, mev.innerNode());
selectClosestWordFromMouseEvent(mouseEvent, mev.targetNode());
}
ASSERT(_currentEvent == event);
......
......@@ -1664,25 +1664,17 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(bool readonly, bool act
const IntPoint& point, const PlatformMouseEvent& event)
{
if (!renderer())
return MouseEventWithHitTestResults(event, String(), String(), 0);
return MouseEventWithHitTestResults(event, 0, false);
assert(renderer()->isCanvas());
RenderObject::NodeInfo renderInfo(readonly, active, mouseMove);
renderer()->layer()->hitTest(renderInfo, point);
String href;
String target;
if (renderInfo.URLElement()) {
Element* e = renderInfo.URLElement();
href = parseURL(e->getAttribute(hrefAttr));
if (!href.isNull())
target = e->getAttribute(targetAttr);
}
if (!readonly)
updateRendering();
return MouseEventWithHitTestResults(event, href, target, renderInfo.innerNode());
bool isOverLink = renderInfo.URLElement() && !renderInfo.URLElement()->getAttribute(hrefAttr).isNull();
return MouseEventWithHitTestResults(event, renderInfo.innerNode(), isOverLink);
}
// DOM Section 1.1.1
......
......@@ -388,6 +388,8 @@ static DeprecatedString nodePosition(Node *node)
Node *p;
for (Node *n = node; n; n = p) {
p = n->parentNode();
if (!p)
p = n->shadowParentNode();
if (n != node)
result += " of ";
if (p)
......
......@@ -1723,13 +1723,13 @@ void Frame::handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&
// from setting caret selection.
d->m_beganSelectingText = true;
else
selectClosestWordFromMouseEvent(event.event(), event.innerNode());
selectClosestWordFromMouseEvent(event.event(), event.targetNode());
}
}
void Frame::handleMousePressEventTripleClick(const MouseEventWithHitTestResults& event)
{
Node *innerNode = event.innerNode();
Node *innerNode = event.targetNode();
if (event.event().button() == LeftButton && innerNode && innerNode->renderer() &&
mouseDownMayStartSelect() && innerNode->renderer()->shouldSelect()) {
......@@ -1752,7 +1752,7 @@ void Frame::handleMousePressEventTripleClick(const MouseEventWithHitTestResults&
void Frame::handleMousePressEventSingleClick(const MouseEventWithHitTestResults& event)
{
Node *innerNode = event.innerNode();
Node *innerNode = event.targetNode();
if (event.event().button() == LeftButton) {
if (innerNode && innerNode->renderer() &&
......@@ -1760,7 +1760,7 @@ void Frame::handleMousePressEventSingleClick(const MouseEventWithHitTestResults&
SelectionController sel;
// Extend the selection if the Shift key is down, unless the click is in a link.
bool extendSelection = event.event().shiftKey() && event.url().isNull();
bool extendSelection = event.event().shiftKey() && !event.isOverLink();
// Don't restart the selection when the mouse is pressed on an
// existing selection so we can allow for text dragging.
......@@ -1802,8 +1802,7 @@ void Frame::handleMousePressEventSingleClick(const MouseEventWithHitTestResults&
void Frame::handleMousePressEvent(const MouseEventWithHitTestResults& event)
{
String url = event.url();
Node *innerNode = event.innerNode();
Node *innerNode = event.targetNode();
d->m_mousePressNode = innerNode;
d->m_dragStartPos = event.event().pos();
......@@ -1830,7 +1829,7 @@ void Frame::handleMouseMoveEvent(const MouseEventWithHitTestResults& event)
if (!d->m_bMousePressed)
return;
Node *innerNode = event.innerNode();
Node *innerNode = event.targetNode();
if (event.event().button() != 0 || !innerNode || !innerNode->renderer() || !mouseDownMayStartSelect() || !innerNode->renderer()->shouldSelect())
return;
......@@ -1876,7 +1875,7 @@ void Frame::handleMouseReleaseEvent(const MouseEventWithHitTestResults& event)
&& d->m_dragStartPos == event.event().pos()
&& d->m_selection.isRange()) {
SelectionController selection;
Node *node = event.innerNode();
Node *node = event.targetNode();
if (node && node->isContentEditable() && node->renderer()) {
IntPoint vPoint = view()->viewportToContents(event.event().pos());
VisiblePosition pos = node->renderer()->positionForPoint(vPoint);
......@@ -3007,7 +3006,7 @@ void Frame::handleMouseReleaseDoubleClickEvent(const MouseEventWithHitTestResult
bool Frame::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event, bool isDoubleClick)
{
// Figure out which view to send the event to.
RenderObject *target = event.innerNode() ? event.innerNode()->renderer() : 0;
RenderObject *target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target)
return false;
......
......@@ -463,10 +463,10 @@ void FrameView::layout()
static Frame* subframeForEvent(const MouseEventWithHitTestResults& mev)
{
if (!mev.innerNode())
if (!mev.targetNode())
return 0;
RenderObject* renderer = mev.innerNode()->renderer();
RenderObject* renderer = mev.targetNode()->renderer();
if (!renderer || !renderer->isWidget())
return 0;
......@@ -494,9 +494,9 @@ void FrameView::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
}
d->clickCount = mouseEvent.clickCount();
d->clickNode = mev.innerNode();
d->clickNode = mev.targetNode();
bool swallowEvent = dispatchMouseEvent(mousedownEvent, mev.innerNode(), true, d->clickCount, mouseEvent, true);
bool swallowEvent = dispatchMouseEvent(mousedownEvent, mev.targetNode(), true, d->clickCount, mouseEvent, true);
if (!swallowEvent) {
m_frame->handleMousePressEvent(mev);
......@@ -526,10 +526,10 @@ void FrameView::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEvent
return;
d->clickCount = mouseEvent.clickCount();
bool swallowEvent = dispatchMouseEvent(mouseupEvent, mev.innerNode(), true, d->clickCount, mouseEvent, false);
bool swallowEvent = dispatchMouseEvent(mouseupEvent, mev.targetNode(), true, d->clickCount, mouseEvent, false);
if (mev.innerNode() == d->clickNode)
dispatchMouseEvent(clickEvent, mev.innerNode(), true, d->clickCount, mouseEvent, true);
if (mev.targetNode() == d->clickNode)
dispatchMouseEvent(clickEvent, mev.targetNode(), true, d->clickCount, mouseEvent, true);
// Qt delivers a release event AND a double click event.
if (!swallowEvent) {
......@@ -551,7 +551,7 @@ static Cursor selectCursor(const MouseEventWithHitTestResults& event, Frame* fra
if (mousePressed && frame->hasSelection())
return iBeamCursor();
Node* node = event.innerNode();
Node* node = event.targetNode();
RenderObject* renderer = node ? node->renderer() : 0;
RenderStyle* style = renderer ? renderer->style() : 0;
......@@ -560,7 +560,7 @@ static Cursor selectCursor(const MouseEventWithHitTestResults& event, Frame* fra
switch (style ? style->cursor() : CURSOR_AUTO) {
case CURSOR_AUTO:
if (!event.url().isNull() || isSubmitImage(node))
if (event.isOverLink() || isSubmitImage(node))
return handCursor();
if ((node && node->isContentEditable()) || (renderer && renderer->isText() && renderer->canSelect()))
return iBeamCursor();
......@@ -629,7 +629,7 @@ void FrameView::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent)
if (d->oldSubframe)
m_frame->passSubframeEventToSubframe(mev, d->oldSubframe.get());
bool swallowEvent = dispatchMouseEvent(mousemoveEvent, mev.innerNode(), false, 0, mouseEvent, true);
bool swallowEvent = dispatchMouseEvent(mousemoveEvent, mev.targetNode(), false, 0, mouseEvent, true);
if (!swallowEvent)
m_frame->handleMouseMoveEvent(mev);
......@@ -668,10 +668,10 @@ void FrameView::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
if (m_frame->passSubframeEventToSubframe(mev))
return;
bool swallowEvent = dispatchMouseEvent(mouseupEvent, mev.innerNode(), true, d->clickCount, mouseEvent, false);
bool swallowEvent = dispatchMouseEvent(mouseupEvent, mev.targetNode(), true, d->clickCount, mouseEvent, false);
if (d->clickCount > 0 && mev.innerNode() == d->clickNode)
dispatchMouseEvent(clickEvent, mev.innerNode(), true, d->clickCount, mouseEvent, true);
if (d->clickCount > 0 && mev.targetNode() == d->clickNode)
dispatchMouseEvent(clickEvent, mev.targetNode(), true, d->clickCount, mouseEvent, true);
if (!swallowEvent)
m_frame->handleMouseReleaseEvent(mev);
......@@ -701,7 +701,7 @@ bool FrameView::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard* cl
MouseEventWithHitTestResults mev = prepareMouseEvent(true, false, false, PlatformMouseEvent());
// Drag events should never go to text nodes (following IE, and proper mouseover/out dispatch)
Node* newTarget = mev.innerNode();
Node* newTarget = mev.targetNode();
if (newTarget && newTarget->isTextNode())
newTarget = newTarget->parentNode();
if (newTarget)
......
/*
Copyright (C) 2006 Apple Computer, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "MouseEventWithHitTestResults.h"
// Would TargetedMouseEvent be a better name?
namespace WebCore {
static inline Element* targetElement(Node* node)
{
if (!node)
return 0;
Node* parent = node->parent();
if (!parent || !parent->isElementNode())
return 0;
return static_cast<Element*>(parent);
}
MouseEventWithHitTestResults::MouseEventWithHitTestResults(const PlatformMouseEvent& event,
PassRefPtr<Node> node, bool isOverLink)
: m_event(event)
, m_targetNode(node)
, m_targetElement(targetElement(m_targetNode.get()))
, m_isOverLink(isOverLink)
{
}
Node* MouseEventWithHitTestResults::targetNode() const
{
if (m_targetElement && !m_targetNode->inDocument() && m_targetElement->inDocument())
return m_targetElement.get();
return m_targetNode.get();
}
}
......@@ -21,26 +21,24 @@
#ifndef MouseEventWithHitTestResults_h
#define MouseEventWithHitTestResults_h
#include "Node.h"
#include "Element.h"
#include "PlatformMouseEvent.h"
namespace WebCore {
class MouseEventWithHitTestResults {
public:
MouseEventWithHitTestResults(const PlatformMouseEvent& e, const String& u, const String& t, PassRefPtr<Node> n)
: m_event(e), m_url(u), m_target(t), m_innerNode(n) { }
MouseEventWithHitTestResults(const PlatformMouseEvent&, PassRefPtr<Node>, bool isOverLink);
const PlatformMouseEvent& event() const { return m_event; }
String url() const { return m_url; }
String target() const { return m_target; }
Node* innerNode() const { return m_innerNode.get(); }
Node* targetNode() const;
bool isOverLink() const { return m_isOverLink; }
private:
PlatformMouseEvent m_event;
String m_url;
String m_target;
RefPtr<Node> m_innerNode;
RefPtr<Node> m_targetNode;
RefPtr<Element> m_targetElement;
bool m_isOverLink;
};
}
......
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