Commit 406daf8b authored by ojan@chromium.org's avatar ojan@chromium.org

2010-03-12 Ojan Vafai <ojan@chromium.org>

        Reviewed by David Levin.

        smartdelete should only occur after double-click
        https://bugs.webkit.org/show_bug.cgi?id=35314

        * editing/deleting/non-smart-delete.html:
        * editing/pasteboard/drag-drop-modifies-page.html:
        * editing/pasteboard/page-zoom-expected.txt:
        Space is removed because we used to incorrectly smartpaste here.
        New behavior matches NSTextView.
        * editing/style/apply-through-end-of-document-expected.txt:
        The change here is that selectall + smartpaste doesn't put a BR,
        but selectall + normal-paste does. Not sure if that's a bug or not,
        but it's not a side effect of this change.
        * editing/style/style-boundary-005.html:
        * platform/mac/editing/deleting/non-smart-delete-expected.checksum:
        * platform/mac/editing/deleting/non-smart-delete-expected.png:
        * platform/mac/editing/deleting/non-smart-delete-expected.txt:
        * platform/mac/editing/execCommand/paste-1-expected.txt:
        * platform/mac/editing/execCommand/paste-2-expected.txt:
        * platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.checksum:
        * platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.png:
        * platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.txt:

        * platform/mac/editing/selection/expanding-selections-expected.txt:
        * platform/mac/editing/selection/expanding-selections2-expected.txt:
        * platform/mac/editing/selection/triple-click-in-pre-expected.txt:
        The above three results change because granularity is no longer part of the seleciton,
        so changes in granularity don't fire selection change notifications.

        * platform/mac/editing/style/style-boundary-005-expected.checksum:
        * platform/mac/editing/style/style-boundary-005-expected.png:
        * platform/mac/editing/style/style-boundary-005-expected.txt:
2010-03-12  Ojan Vafai  <ojan@chromium.org>

        Reviewed by David Levin.

        smartdelete should only occur after double-click
        https://bugs.webkit.org/show_bug.cgi?id=35314

        1. Consolidate all notions of selection-granularity into SelectionController.
        2. Now only mouse-based selections store a selection-granularity. This matches NSTextView.

        New tests were added in http://trac.webkit.org/changeset/55913.

        * WebCore.base.exp:
        * editing/MoveSelectionCommand.cpp:
        (WebCore::MoveSelectionCommand::MoveSelectionCommand):
        (WebCore::MoveSelectionCommand::doApply):
        * editing/MoveSelectionCommand.h:
        (WebCore::MoveSelectionCommand::create):
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::SelectionController):
        (WebCore::SelectionController::setSelection):
        (WebCore::SelectionController::modify):
        (WebCore::SelectionController::clear):
        * editing/SelectionController.h:
        (WebCore::SelectionController::setSelection):
        (WebCore::SelectionController::granularity):
        * editing/VisibleSelection.cpp:
        (WebCore::VisibleSelection::VisibleSelection):
        (WebCore::VisibleSelection::expandUsingGranularity):
        (WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
        (WebCore::VisibleSelection::validate):
        * editing/VisibleSelection.h:
        (WebCore::operator==):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::clear):
        * page/DOMSelection.cpp:
        (WebCore::DOMSelection::extend):
        * page/DragController.cpp:
        (WebCore::DragController::concludeEditDrag):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::selectClosestWordFromMouseEvent):
        (WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent):
        (WebCore::EventHandler::handleMousePressEventTripleClick):
        (WebCore::EventHandler::handleMousePressEventSingleClick):
        (WebCore::EventHandler::updateSelectionForMouseDrag):
        * page/Frame.cpp:
        (WebCore::Frame::Frame):
        (WebCore::Frame::selectionGranularity):
        * page/Frame.h:
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::setSelectionRange):
2010-03-12  Ojan Vafai  <ojan@chromium.org>

        Reviewed by David Levin.

        smartdelete should only occur after double-click
        https://bugs.webkit.org/show_bug.cgi?id=35314

        * src/WebFrameImpl.cpp:
        (WebKit::WebFrameImpl::selectWordAroundPosition):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@56175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1d9039f5
2010-03-12 Ojan Vafai <ojan@chromium.org>
Reviewed by David Levin.
smartdelete should only occur after double-click
https://bugs.webkit.org/show_bug.cgi?id=35314
* editing/deleting/non-smart-delete.html:
* editing/pasteboard/drag-drop-modifies-page.html:
* editing/pasteboard/page-zoom-expected.txt:
Space is removed because we used to incorrectly smartpaste here.
New behavior matches NSTextView.
* editing/style/apply-through-end-of-document-expected.txt:
The change here is that selectall + smartpaste doesn't put a BR,
but selectall + normal-paste does. Not sure if that's a bug or not,
but it's not a side effect of this change.
* editing/style/style-boundary-005.html:
* platform/mac/editing/deleting/non-smart-delete-expected.checksum:
* platform/mac/editing/deleting/non-smart-delete-expected.png:
* platform/mac/editing/deleting/non-smart-delete-expected.txt:
* platform/mac/editing/execCommand/paste-1-expected.txt:
* platform/mac/editing/execCommand/paste-2-expected.txt:
* platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.checksum:
* platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.png:
* platform/mac/editing/pasteboard/drag-drop-modifies-page-expected.txt:
* platform/mac/editing/selection/expanding-selections-expected.txt:
* platform/mac/editing/selection/expanding-selections2-expected.txt:
* platform/mac/editing/selection/triple-click-in-pre-expected.txt:
The above three results change because granularity is no longer part of the seleciton,
so changes in granularity don't fire selection change notifications.
* platform/mac/editing/style/style-boundary-005-expected.checksum:
* platform/mac/editing/style/style-boundary-005-expected.png:
* platform/mac/editing/style/style-boundary-005-expected.txt:
2010-03-18 Alexey Proskuryakov <ap@apple.com>
Reviewed by Adam Roben and Anders Carlsson.
......
......@@ -40,7 +40,7 @@ Non-smart delete when deleting a word selected via the keyboard.
<div class="expected-results">
Expected Results:
<br>
The first word should be deleted. The space following it should remain. It should look like this (currently this is broken and the space is deleted https://bugs.webkit.org/show_bug.cgi?id=35314):
The first word should be deleted. The space following it should remain. It should look like this:
<BR>
" bar baz"
</div>
......
......@@ -29,8 +29,7 @@ function editingTest() {
</head>
<body>
<p>This tests non-smartmove drag/drop. The space should be deleted on move,
but not reinserted on drop, resulting in "worldhello". Currently there's a bug
(https://bugs.webkit.org/show_bug.cgi?id=35314) where the space is reinserted on drop.</p>
but not reinserted on drop, resulting in "worldhello".</p>
<div contenteditable="true" id="test"><span id="dragme">hello</span> world</div>
<script>runEditingTest();</script>
</body>
......
Copy this 16px text.
Paste Copy this 16px text it here.
PasteCopy this 16px text it here.
The pasted text should have a font size of 16px.
Copy this x-small text.
Paste Copy this x-small it here.
PasteCopy this x-small it here.
The pasted text should have a font size of x-small.
......
......@@ -24,4 +24,5 @@ layer at (0,0) size 800x600
RenderBlock {PRE} at (0,140) size 784x15
RenderText {#text} at (0,0) size 24x15
text run at (0,0) width 24: "the"
RenderBR {BR} at (24,12) size 0x0
caret: position 3 of child 0 {#text} of child 7 {PRE} of child 1 {BODY} of child 0 {HTML} of document
......@@ -51,8 +51,7 @@ Pasting at style boundary does not crash or produce empty style span(s).
<div class="expected-results">
Expected Results:
<br>
Should see this content in the red box below (currently there's a bug where
there is an extra space after the bold element https://bugs.webkit.org/show_bug.cgi?id=35314):
Should see this content in the red box below:
<br><div>one two three <b>four</b>one</div>
</div>
</div>
......
25614efd3493758eb76da8f4748cdd48
\ No newline at end of file
d3f2f03e7a6b3460b751bb500f812b0d
\ No newline at end of file
......@@ -11,26 +11,25 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 784x240 [border: (2px solid #0000FF)]
RenderBlock {DIV} at (0,0) size 784x212 [border: (2px solid #0000FF)]
RenderBlock {DIV} at (14,14) size 756x56
RenderText {#text} at (0,0) size 67x28
text run at (0,0) width 67: "Tests: "
RenderBR {BR} at (0,0) size 0x0
RenderText {#text} at (0,28) size 642x28
text run at (0,28) width 642: "Non-smart delete when deleting a word selected via the keyboard."
RenderBlock {DIV} at (14,86) size 756x140
RenderBlock {DIV} at (14,86) size 756x112
RenderText {#text} at (0,0) size 189x28
text run at (0,0) width 189: "Expected Results: "
RenderBR {BR} at (189,22) size 0x0
RenderText {#text} at (0,28) size 715x84
RenderText {#text} at (0,28) size 715x56
text run at (0,28) width 715: "The first word should be deleted. The space following it should remain. It"
text run at (0,56) width 671: "should look like this (currently this is broken and the space is deleted"
text run at (0,84) width 489: "https://bugs.webkit.org/show_bug.cgi?id=35314): "
RenderBR {BR} at (489,106) size 0x0
RenderText {#text} at (0,112) size 97x28
text run at (0,112) width 97: "\" bar baz\""
RenderBlock {DIV} at (0,264) size 784x32
text run at (0,56) width 210: "should look like this: "
RenderBR {BR} at (210,78) size 0x0
RenderText {#text} at (0,84) size 97x28
text run at (0,84) width 97: "\" bar baz\""
RenderBlock {DIV} at (0,236) size 784x32
RenderBlock {DIV} at (0,0) size 784x32 [border: (2px solid #FF0000)]
RenderText {#text} at (2,2) size 71x28
text run at (2,2) width 71: "bar baz"
RenderText {#text} at (2,2) size 77x28
text run at (2,2) width 77: " bar baz"
caret: position 0 of child 0 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
......@@ -4,11 +4,11 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 8 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 4 of #text > BODY > HTML > #document to 4 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 3 of #text > BODY > HTML > #document to 3 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -27,8 +27,8 @@ layer at (0,0) size 800x600
layer at (0,0) size 300x150
RenderBlock {HTML} at (0,0) size 300x150
RenderBody {BODY} at (8,8) size 284x134 [bgcolor=#FFFFE0]
RenderText {#text} at (0,0) size 45x18
text run at (0,0) width 45: "foo bar"
RenderText {#text} at (45,0) size 26x18
text run at (45,0) width 26: " baz"
RenderText {#text} at (0,0) size 49x18
text run at (0,0) width 49: "foo bar "
RenderText {#text} at (49,0) size 22x18
text run at (49,0) width 22: "baz"
RenderText {#text} at (0,0) size 0x0
......@@ -4,11 +4,11 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 8 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document toDOMRange:range from 4 of #text > BODY > HTML > #document to 4 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > BODY > HTML > #document to 8 of #text > BODY > HTML > #document toDOMRange:range from 3 of #text > BODY > HTML > #document to 3 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -27,8 +27,8 @@ layer at (0,0) size 800x600
layer at (0,0) size 300x150
RenderBlock {HTML} at (0,0) size 300x150
RenderBody {BODY} at (8,8) size 284x134 [bgcolor=#FFFFE0]
RenderText {#text} at (0,0) size 45x18
text run at (0,0) width 45: "foo bar"
RenderText {#text} at (45,0) size 26x18
text run at (45,0) width 26: " baz"
RenderText {#text} at (0,0) size 49x18
text run at (0,0) width 49: "foo bar "
RenderText {#text} at (49,0) size 22x18
text run at (49,0) width 22: "baz"
RenderText {#text} at (0,0) size 0x0
3d3191296d52f9a79e4d6cc041582b91
\ No newline at end of file
935cba8b736643ed7cbb0133e973c810
\ No newline at end of file
......@@ -4,7 +4,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionDropped
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -12,15 +12,14 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x54
RenderText {#text} at (0,0) size 756x54
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 719x36
text run at (0,0) width 719: "This tests non-smartmove drag/drop. The space should be deleted on move, but not reinserted on drop, resulting in"
text run at (0,18) width 756: "\"worldhello\". Currently there's a bug (https://bugs.webkit.org/show_bug.cgi?id=35314) where the space is reinserted on"
text run at (0,36) width 33: "drop."
RenderBlock {DIV} at (0,70) size 784x18
text run at (0,18) width 86: "\"worldhello\"."
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 37x18
text run at (0,0) width 37: "world"
RenderText {#text} at (37,0) size 35x18
text run at (37,0) width 35: " hello"
RenderText {#text} at (37,0) size 31x18
text run at (37,0) width 31: "hello"
selection start: position 0 of child 1 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 6 of child 1 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 5 of child 1 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
......@@ -3,7 +3,6 @@ EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
......
......@@ -3,7 +3,6 @@ EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
......
......@@ -5,7 +5,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 30 of #text > PRE > DIV > DIV > BODY > HTML > #document to 30 of #text > PRE > DIV > DIV > BODY > HTML > #document toDOMRange:range from 16 of #text > PRE > DIV > DIV > BODY > HTML > #document to 30 of #text > PRE > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 16 of #text > PRE > DIV > DIV > BODY > HTML > #document to 30 of #text > PRE > DIV > DIV > BODY > HTML > #document toDOMRange:range from 16 of #text > PRE > DIV > DIV > BODY > HTML > #document to 30 of #text > PRE > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
......
28d32961a9388737065e99d4c3cb04a2
\ No newline at end of file
1c5a6f9e02365f6d0d5c5c13c592c2a3
\ No newline at end of file
......@@ -24,7 +24,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 5 of #text > B > DIV > DIV > BODY > HTML > #document to 5 of #text > B > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > B > DIV > DIV > BODY > HTML > #document to 5 of #text > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > DIV > BODY > HTML > #document to 4 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > B > DIV > DIV > BODY > HTML > #document to 5 of #text > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -32,24 +32,22 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 784x240 [border: (2px solid #0000FF)]
RenderBlock {DIV} at (0,0) size 784x184 [border: (2px solid #0000FF)]
RenderBlock {DIV} at (14,14) size 756x56
RenderText {#text} at (0,0) size 67x28
text run at (0,0) width 67: "Tests: "
RenderBR {BR} at (0,0) size 0x0
RenderText {#text} at (0,28) size 698x28
text run at (0,28) width 698: "Pasting at style boundary does not crash or produce empty style span(s)."
RenderBlock {DIV} at (14,86) size 756x140
RenderBlock (anonymous) at (0,0) size 756x112
RenderBlock {DIV} at (14,86) size 756x84
RenderBlock (anonymous) at (0,0) size 756x56
RenderText {#text} at (0,0) size 189x28
text run at (0,0) width 189: "Expected Results: "
RenderBR {BR} at (189,22) size 0x0
RenderText {#text} at (0,28) size 723x84
text run at (0,28) width 723: "Should see this content in the red box below (currently there's a bug where"
text run at (0,56) width 435: "there is an extra space after the bold element"
text run at (0,84) width 489: "https://bugs.webkit.org/show_bug.cgi?id=35314): "
RenderBR {BR} at (489,106) size 0x0
RenderBlock {DIV} at (0,112) size 756x28
RenderText {#text} at (0,28) size 442x28
text run at (0,28) width 442: "Should see this content in the red box below: "
RenderBR {BR} at (442,50) size 0x0
RenderBlock {DIV} at (0,56) size 756x28
RenderText {#text} at (0,0) size 138x28
text run at (0,0) width 138: "one two three "
RenderInline {B} at (0,0) size 44x28
......@@ -57,15 +55,15 @@ layer at (0,0) size 800x600
text run at (138,0) width 44: "four"
RenderText {#text} at (182,0) size 35x28
text run at (182,0) width 35: "one"
RenderBlock {DIV} at (0,264) size 784x22
RenderBlock {DIV} at (0,208) size 784x22
RenderBlock {DIV} at (0,0) size 784x22 [border: (2px solid #FF0000)]
RenderText {#text} at (2,2) size 86x18
text run at (2,2) width 86: "one two three"
RenderInline {B} at (0,0) size 33x18
RenderText {#text} at (88,2) size 33x18
text run at (88,2) width 33: " four"
RenderText {#text} at (121,2) size 27x18
text run at (121,2) width 27: " one"
RenderText {#text} at (121,2) size 23x18
text run at (121,2) width 23: "one"
RenderBlock (anonymous) at (0,22) size 784x0
RenderText {#text} at (0,0) size 0x0
caret: position 4 of child 2 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
caret: position 3 of child 2 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
2010-03-12 Ojan Vafai <ojan@chromium.org>
Reviewed by David Levin.
smartdelete should only occur after double-click
https://bugs.webkit.org/show_bug.cgi?id=35314
1. Consolidate all notions of selection-granularity into SelectionController.
2. Now only mouse-based selections store a selection-granularity. This matches NSTextView.
New tests were added in http://trac.webkit.org/changeset/55913.
* WebCore.base.exp:
* editing/MoveSelectionCommand.cpp:
(WebCore::MoveSelectionCommand::MoveSelectionCommand):
(WebCore::MoveSelectionCommand::doApply):
* editing/MoveSelectionCommand.h:
(WebCore::MoveSelectionCommand::create):
* editing/SelectionController.cpp:
(WebCore::SelectionController::SelectionController):
(WebCore::SelectionController::setSelection):
(WebCore::SelectionController::modify):
(WebCore::SelectionController::clear):
* editing/SelectionController.h:
(WebCore::SelectionController::setSelection):
(WebCore::SelectionController::granularity):
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::VisibleSelection):
(WebCore::VisibleSelection::expandUsingGranularity):
(WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
(WebCore::VisibleSelection::validate):
* editing/VisibleSelection.h:
(WebCore::operator==):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::clear):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::extend):
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::selectClosestWordFromMouseEvent):
(WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent):
(WebCore::EventHandler::handleMousePressEventTripleClick):
(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::EventHandler::updateSelectionForMouseDrag):
* page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::selectionGranularity):
* page/Frame.h:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::setSelectionRange):
2010-03-18 Dimitri Glazkov <dglazkov@chromium.org>
Unreviewed, build fix.
......
......@@ -407,7 +407,7 @@ __ZN7WebCore19AnimationController21pauseTransitionAtTimeEPNS_12RenderObjectERKNS
__ZN7WebCore19CSSStyleDeclaration11setPropertyERKNS_6StringES3_Ri
__ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv
__ZN7WebCore19SelectionController10setFocusedEb
__ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionEbbb
__ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionEbbbNS_15TextGranularityE
__ZN7WebCore19SelectionController16setSelectedRangeEPNS_5RangeENS_9EAffinityEb
__ZN7WebCore19SelectionController5clearEv
__ZN7WebCore19SelectionController6modifyENS0_11EAlterationENS0_10EDirectionENS_15TextGranularityEb
......
......@@ -31,8 +31,8 @@
namespace WebCore {
MoveSelectionCommand::MoveSelectionCommand(PassRefPtr<DocumentFragment> fragment, const Position& position, bool smartMove)
: CompositeEditCommand(position.node()->document()), m_fragment(fragment), m_position(position), m_smartMove(smartMove)
MoveSelectionCommand::MoveSelectionCommand(PassRefPtr<DocumentFragment> fragment, const Position& position, bool smartInsert, bool smartDelete)
: CompositeEditCommand(position.node()->document()), m_fragment(fragment), m_position(position), m_smartInsert(smartInsert), m_smartDelete(smartDelete)
{
ASSERT(m_fragment);
}
......@@ -60,7 +60,7 @@ void MoveSelectionCommand::doApply()
pos = Position(positionNode, positionOffset);
}
deleteSelection(m_smartMove);
deleteSelection(m_smartDelete);
// If the node for the destination has been removed as a result of the deletion,
// set the destination to the ending point after the deletion.
......@@ -74,7 +74,7 @@ void MoveSelectionCommand::doApply()
// Document was modified out from under us.
return;
}
applyCommandToComposite(ReplaceSelectionCommand::create(positionNode->document(), m_fragment, true, m_smartMove));
applyCommandToComposite(ReplaceSelectionCommand::create(positionNode->document(), m_fragment, true, m_smartInsert));
}
EditAction MoveSelectionCommand::editingAction() const
......
......@@ -34,20 +34,21 @@ class DocumentFragment;
class MoveSelectionCommand : public CompositeEditCommand {
public:
static PassRefPtr<MoveSelectionCommand> create(PassRefPtr<DocumentFragment> fragment, const Position& position, bool smartMove = false)
static PassRefPtr<MoveSelectionCommand> create(PassRefPtr<DocumentFragment> fragment, const Position& position, bool smartInsert = false, bool smartDelete = false)
{
return adoptRef(new MoveSelectionCommand(fragment, position, smartMove));
return adoptRef(new MoveSelectionCommand(fragment, position, smartInsert, smartDelete));
}
private:
MoveSelectionCommand(PassRefPtr<DocumentFragment>, const Position&, bool smartMove);
MoveSelectionCommand(PassRefPtr<DocumentFragment>, const Position&, bool smartInsert, bool smartDelete);
virtual void doApply();
virtual EditAction editingAction() const;
RefPtr<DocumentFragment> m_fragment;
Position m_position;
bool m_smartMove;
bool m_smartInsert;
bool m_smartDelete;
};
} // namespace WebCore
......
......@@ -66,6 +66,7 @@ const int NoXPosForVerticalArrowNavigation = INT_MIN;
SelectionController::SelectionController(Frame* frame, bool isDragCaretController)
: m_frame(frame)
, m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation)
, m_granularity(CharacterGranularity)
, m_caretBlinkTimer(this, &SelectionController::caretBlinkTimerFired)
, m_needsLayout(true)
, m_absCaretBoundsDirty(true)
......@@ -104,8 +105,10 @@ void SelectionController::moveTo(const Position &base, const Position &extent, E
setSelection(VisibleSelection(base, extent, affinity), true, true, userTriggered);
}
void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered)
void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered, TextGranularity granularity)
{
m_granularity = granularity;
m_lastChangeWasHorizontalExtension = false;
if (m_isDragCaretController) {
......@@ -602,9 +605,6 @@ bool SelectionController::modify(EAlteration alter, EDirection dir, TextGranular
return false;
}
if (m_frame)
m_frame->setSelectionGranularity(granularity);
willBeModified(alter, dir);
VisiblePosition pos;
......@@ -637,7 +637,7 @@ bool SelectionController::modify(EAlteration alter, EDirection dir, TextGranular
if (pos.isNull())
return false;
// Some of the above operations set an xPosForVerticalArrowNavigation.
// Setting a selection will clear it, so save it to possibly restore later.
// Note: the START position type is arbitrary because it is unused, it would be
......@@ -656,14 +656,9 @@ bool SelectionController::modify(EAlteration alter, EDirection dir, TextGranular
if (granularity == LineGranularity || granularity == ParagraphGranularity)
m_xPosForVerticalArrowNavigation = x;
if (userTriggered) {
// User modified selection change also sets the granularity back to character.
// NOTE: The one exception is that we need to keep word granularity to
// preserve smart delete behavior when extending by word (e.g. double-click),
// then shift-option-right arrow, then delete needs to smart delete, per TextEdit.
if (!(alter == EXTEND && granularity == WordGranularity && m_frame->selectionGranularity() == WordGranularity))
m_frame->setSelectionGranularity(CharacterGranularity);
}
if (userTriggered)
m_granularity = CharacterGranularity;
setNeedsLayout();
......@@ -758,23 +753,13 @@ bool SelectionController::modify(EAlteration alter, int verticalDistance, bool u
}
if (userTriggered)
m_frame->setSelectionGranularity(CharacterGranularity);
m_granularity = CharacterGranularity;
m_lastChangeWasHorizontalExtension = alter == EXTEND;
return true;
}
bool SelectionController::expandUsingGranularity(TextGranularity granularity)
{
if (isNone())
return false;
m_selection.expandUsingGranularity(granularity);
m_needsLayout = true;
return true;
}
int SelectionController::xPosForVerticalArrowNavigation(EPositionType type)
{
int x = 0;
......@@ -817,6 +802,7 @@ int SelectionController::xPosForVerticalArrowNavigation(EPositionType type)
void SelectionController::clear()
{
m_granularity = CharacterGranularity;
setSelection(VisibleSelection());
}
......
......@@ -59,7 +59,8 @@ public:
void moveTo(const Position&, const Position&, EAffinity, bool userTriggered = false);
const VisibleSelection& selection() const { return m_selection; }
void setSelection(const VisibleSelection&, bool closeTyping = true, bool clearTypingStyle = true, bool userTriggered = false);
void setSelection(const VisibleSelection&, bool closeTyping = true, bool clearTypingStyle = true, bool userTriggered = false, TextGranularity = CharacterGranularity);
void setSelection(const VisibleSelection& selection, TextGranularity granularity) { setSelection(selection, true, true, false, granularity); }
bool setSelectedRange(Range*, EAffinity, bool closeTyping);
void selectAll();
void clear();
......@@ -75,7 +76,7 @@ public:
bool modify(EAlteration, EDirection, TextGranularity, bool userTriggered = false);
bool modify(EAlteration, int verticalDistance, bool userTriggered = false);
bool expandUsingGranularity(TextGranularity);
TextGranularity granularity() const { return m_granularity; }
void setBase(const VisiblePosition&, bool userTriggered = false);
void setBase(const Position&, EAffinity, bool userTriggered = false);
......@@ -178,6 +179,7 @@ private:
int m_xPosForVerticalArrowNavigation;
VisibleSelection m_selection;
TextGranularity m_granularity;
Timer<SelectionController> m_caretBlinkTimer;
......
......@@ -43,7 +43,6 @@ namespace WebCore {
VisibleSelection::VisibleSelection()
: m_affinity(DOWNSTREAM)
, m_granularity(CharacterGranularity)
, m_selectionType(NoSelection)
, m_baseIsFirst(true)
{
......@@ -53,7 +52,6 @@ VisibleSelection::VisibleSelection(const Position& pos, EAffinity affinity)
: m_base(pos)
, m_extent(pos)
, m_affinity(affinity)
, m_granularity(CharacterGranularity)
{
validate();
}
......@@ -62,7 +60,6 @@ VisibleSelection::VisibleSelection(const Position& base, const Position& extent,
: m_base(base)
, m_extent(extent)
, m_affinity(affinity)
, m_granularity(CharacterGranularity)
{
validate();
}
......@@ -71,7 +68,6 @@ VisibleSelection::VisibleSelection(const VisiblePosition& pos)
: m_base(pos.deepEquivalent())
, m_extent(pos.deepEquivalent())
, m_affinity(pos.affinity())
, m_granularity(CharacterGranularity)
{
validate();
}
......@@ -80,7 +76,6 @@ VisibleSelection::VisibleSelection(const VisiblePosition& base, const VisiblePos
: m_base(base.deepEquivalent())
, m_extent(extent.deepEquivalent())
, m_affinity(base.affinity())
, m_granularity(CharacterGranularity)
{
validate();
}
......@@ -89,7 +84,6 @@ VisibleSelection::VisibleSelection(const Range* range, EAffinity affinity)
: m_base(range->startPosition())
, m_extent(range->endPosition())
, m_affinity(affinity)
, m_granularity(CharacterGranularity)
{
validate();
}
......@@ -190,8 +184,7 @@ bool VisibleSelection::expandUsingGranularity(TextGranularity granularity)
if (isNone())
return false;
m_granularity = granularity;
validate();
validate(granularity);
return true;
}
......@@ -268,7 +261,7 @@ void VisibleSelection::setBaseAndExtentToDeepEquivalents()
m_baseIsFirst = comparePositions(m_base, m_extent) <= 0;
}
void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity()
void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(TextGranularity granularity)
{
if (m_baseIsFirst) {
m_start = m_base;
......@@ -278,7 +271,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity()
m_end = m_base;
}
switch (m_granularity) {
switch (granularity) {
case CharacterGranularity:
// Don't do any expansion.
break;
......@@ -408,10 +401,10 @@ void VisibleSelection::updateSelectionType()
m_affinity = DOWNSTREAM;
}
void VisibleSelection::validate()
void VisibleSelection::validate(TextGranularity granularity)
{
setBaseAndExtentToDeepEquivalents();
setStartAndEndFromBaseAndExtentRespectingGranularity();
setStartAndEndFromBaseAndExtentRespectingGranularity(granularity);
adjustSelectionToAvoidCrossingEditingBoundaries();
updateSelectionType();
......
......@@ -81,8 +81,7 @@ public:
void appendTrailingWhitespace();
bool expandUsingGranularity(TextGranularity granularity);
TextGranularity granularity() const { return m_granularity; }
// We don't yet support multi-range selections, so we only ever have one range to return.
PassRefPtr<Range> firstRange() const;
......@@ -106,11 +105,11 @@ public:
void setWithoutValidation(const Position&, const Position&);