- Revision
- 121303
- Author
- [email protected]
- Date
- 2012-06-26 17:00:52 -0700 (Tue, 26 Jun 2012)
Log Message
Stop calling node() and deprecatedEditingOffset() in comparePositions
https://bugs.webkit.org/show_bug.cgi?id=54535
Reviewed by Enrica Casucci.
Source/WebCore:
Replaced deprecatedNode() and deprecatedEditingOffset() by containerNode() and computeOffsetInContainerNode()
in comparePositions().
In addition, fixed a bunch of bugs in DeleteSelectionCommand::handleSpecialCaseBRDelete revealed by this change:
- Use node after position instead of deprecated node in determinig whether start and end positions at a br.
- Don't set m_startsAtEmptyLine true when BR is wrapped in a block element. The only reason this code had worked
was positions like (div, offset, 0) and (br, before) in <div><br> were treated differently, which we no longer do.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
* editing/htmlediting.cpp:
(WebCore::comparePositions):
LayoutTests:
Rebaselined existing tests. There are no user-visible changes.
* editing/inseting/font-size-clears-from-typing-style-expected.txt: No longer keeps div's around
when merging paragraphs.
* platform/mac/editing/deleting/delete-br-002-expected.txt:
* platform/mac/editing/deleting/delete-br-004-expected.txt:
* platform/mac/editing/deleting/delete-br-005-expected.txt:
* platform/mac/editing/deleting/delete-br-006-expected.txt:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (121302 => 121303)
--- trunk/LayoutTests/ChangeLog 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/LayoutTests/ChangeLog 2012-06-27 00:00:52 UTC (rev 121303)
@@ -1,3 +1,19 @@
+2012-06-26 Ryosuke Niwa <[email protected]>
+
+ Stop calling node() and deprecatedEditingOffset() in comparePositions
+ https://bugs.webkit.org/show_bug.cgi?id=54535
+
+ Reviewed by Enrica Casucci.
+
+ Rebaselined existing tests. There are no user-visible changes.
+
+ * editing/inseting/font-size-clears-from-typing-style-expected.txt: No longer keeps div's around
+ when merging paragraphs.
+ * platform/mac/editing/deleting/delete-br-002-expected.txt:
+ * platform/mac/editing/deleting/delete-br-004-expected.txt:
+ * platform/mac/editing/deleting/delete-br-005-expected.txt:
+ * platform/mac/editing/deleting/delete-br-006-expected.txt:
+
2012-06-26 Alice Cheng <[email protected]>
Crash at WebCore::TextIterator::handleTextBox
Modified: trunk/LayoutTests/editing/inserting/font-size-clears-from-typing-style-expected.txt (121302 => 121303)
--- trunk/LayoutTests/editing/inserting/font-size-clears-from-typing-style-expected.txt 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/LayoutTests/editing/inserting/font-size-clears-from-typing-style-expected.txt 2012-06-27 00:00:52 UTC (rev 121303)
@@ -1,4 +1,3 @@
Tests that we don't serialize redundant font-size in typingStyle. There should be no span or style attribute around A or B below.See https://bugs.webkit.org/show_bug.cgi?id=26279.
-| <div>
-| id="wrapper"
-| "B<#selection-caret>A"
+| "B<#selection-caret>A"
+| <br>
Modified: trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt (121302 => 121303)
--- trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt 2012-06-27 00:00:52 UTC (rev 121303)
@@ -24,6 +24,7 @@
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
Modified: trunk/LayoutTests/platform/mac/editing/deleting/delete-br-004-expected.txt (121302 => 121303)
--- trunk/LayoutTests/platform/mac/editing/deleting/delete-br-004-expected.txt 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/LayoutTests/platform/mac/editing/deleting/delete-br-004-expected.txt 2012-06-27 00:00:52 UTC (rev 121303)
@@ -25,6 +25,7 @@
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
@@ -42,5 +43,4 @@
RenderBR {BR} at (14,42) size 0x28
RenderText {#text} at (14,70) size 92x28
text run at (14,70) width 92: "years ago"
- RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 3 {#text} of child 1 {SPAN} of child 1 {DIV} of body
Modified: trunk/LayoutTests/platform/mac/editing/deleting/delete-br-005-expected.txt (121302 => 121303)
--- trunk/LayoutTests/platform/mac/editing/deleting/delete-br-005-expected.txt 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/LayoutTests/platform/mac/editing/deleting/delete-br-005-expected.txt 2012-06-27 00:00:52 UTC (rev 121303)
@@ -25,9 +25,11 @@
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
@@ -44,5 +46,4 @@
RenderBR {BR} at (218,36) size 0x0
RenderText {#text} at (14,42) size 92x28
text run at (14,42) width 92: "years ago"
- RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 2 {#text} of child 1 {SPAN} of child 1 {DIV} of body
Modified: trunk/LayoutTests/platform/mac/editing/deleting/delete-br-006-expected.txt (121302 => 121303)
--- trunk/LayoutTests/platform/mac/editing/deleting/delete-br-006-expected.txt 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/LayoutTests/platform/mac/editing/deleting/delete-br-006-expected.txt 2012-06-27 00:00:52 UTC (rev 121303)
@@ -25,9 +25,11 @@
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document
@@ -47,5 +49,4 @@
text run at (157,14) width 61: "seven "
RenderText {#text} at (218,14) size 92x28
text run at (218,14) width 92: "years ago"
- RenderText {#text} at (0,0) size 0x0
caret: position 23 of child 0 {#text} of child 1 {SPAN} of child 1 {DIV} of body
Modified: trunk/Source/WebCore/ChangeLog (121302 => 121303)
--- trunk/Source/WebCore/ChangeLog 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/Source/WebCore/ChangeLog 2012-06-27 00:00:52 UTC (rev 121303)
@@ -1,3 +1,23 @@
+2012-06-26 Ryosuke Niwa <[email protected]>
+
+ Stop calling node() and deprecatedEditingOffset() in comparePositions
+ https://bugs.webkit.org/show_bug.cgi?id=54535
+
+ Reviewed by Enrica Casucci.
+
+ Replaced deprecatedNode() and deprecatedEditingOffset() by containerNode() and computeOffsetInContainerNode()
+ in comparePositions().
+
+ In addition, fixed a bunch of bugs in DeleteSelectionCommand::handleSpecialCaseBRDelete revealed by this change:
+ - Use node after position instead of deprecated node in determinig whether start and end positions at a br.
+ - Don't set m_startsAtEmptyLine true when BR is wrapped in a block element. The only reason this code had worked
+ was positions like (div, offset, 0) and (br, before) in <div><br> were treated differently, which we no longer do.
+
+ * editing/DeleteSelectionCommand.cpp:
+ (WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
+ * editing/htmlediting.cpp:
+ (WebCore::comparePositions):
+
2012-06-26 Christophe Dumez <[email protected]>
[EFL] Use eina_file_ls() in EFL implementation of FileSystem listDirectory()
Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (121302 => 121303)
--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2012-06-27 00:00:52 UTC (rev 121303)
@@ -297,18 +297,26 @@
bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
{
+ Node* nodeAfterUpstreamStart = m_upstreamStart.computeNodeAfterPosition();
+ Node* nodeAfterDownstreamStart = m_downstreamStart.computeNodeAfterPosition();
+ // Upstream end will appear before BR due to canonicalization
+ Node* nodeAfterUpstreamEnd = m_upstreamEnd.computeNodeAfterPosition();
+
+ if (!nodeAfterUpstreamStart || !nodeAfterDownstreamStart)
+ return false;
+
// Check for special-case where the selection contains only a BR on a line by itself after another BR.
- bool upstreamStartIsBR = m_upstreamStart.deprecatedNode()->hasTagName(brTag);
- bool downstreamStartIsBR = m_downstreamStart.deprecatedNode()->hasTagName(brTag);
- bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && m_downstreamStart.deprecatedNode() == m_upstreamEnd.deprecatedNode();
+ bool upstreamStartIsBR = nodeAfterUpstreamStart->hasTagName(brTag);
+ bool downstreamStartIsBR = nodeAfterDownstreamStart->hasTagName(brTag);
+ bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && nodeAfterDownstreamStart == nodeAfterUpstreamEnd;
if (isBROnLineByItself) {
- removeNode(m_downstreamStart.deprecatedNode());
+ removeNode(nodeAfterDownstreamStart);
return true;
}
- // Not a special-case delete per se, but we can detect that the merging of content between blocks
- // should not be done.
- if (upstreamStartIsBR && downstreamStartIsBR) {
+ // FIXME: This code doesn't belong in here.
+ // We detect the case where the start is an empty line consisting of BR not wrapped in a block element.
+ if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterUpstreamStart)))) {
m_startsAtEmptyLine = true;
m_endingPosition = m_downstreamEnd;
}
Modified: trunk/Source/WebCore/editing/htmlediting.cpp (121302 => 121303)
--- trunk/Source/WebCore/editing/htmlediting.cpp 2012-06-26 23:54:46 UTC (rev 121302)
+++ trunk/Source/WebCore/editing/htmlediting.cpp 2012-06-27 00:00:52 UTC (rev 121303)
@@ -78,15 +78,15 @@
if (!commonScope)
return 0;
- Node* nodeA = commonScope->ancestorInThisScope(a.deprecatedNode());
+ Node* nodeA = commonScope->ancestorInThisScope(a.containerNode());
ASSERT(nodeA);
- bool hasDescendentA = nodeA != a.deprecatedNode();
- int offsetA = hasDescendentA ? 0 : a.deprecatedEditingOffset();
+ bool hasDescendentA = nodeA != a.containerNode();
+ int offsetA = hasDescendentA ? 0 : a.computeOffsetInContainerNode();
- Node* nodeB = commonScope->ancestorInThisScope(b.deprecatedNode());
+ Node* nodeB = commonScope->ancestorInThisScope(b.containerNode());
ASSERT(nodeB);
- bool hasDescendentB = nodeB != b.deprecatedNode();
- int offsetB = hasDescendentB ? 0 : b.deprecatedEditingOffset();
+ bool hasDescendentB = nodeB != b.containerNode();
+ int offsetB = hasDescendentB ? 0 : b.computeOffsetInContainerNode();
int bias = 0;
if (nodeA == nodeB) {