[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

justin.garcia at apple.com justin.garcia at apple.com
Wed Apr 7 23:23:11 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 619526afe8fce604cdfac9a27887e61708420c17
Author: justin.garcia at apple.com <justin.garcia at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 5 05:25:24 2009 +0000

    WebCore:
    
    2009-11-02  Justin Garcia  <justin.garcia at apple.com>
    
            Reviewed by Adele Peterson.
    
            https://bugs.webkit.org/show_bug.cgi?id=25439
            Deleting when in front of a block image removes character from previous paragraph
    
            Added editing/deleting/25439-{1,2,3}.html
    
            * editing/DeleteSelectionCommand.cpp:
            (WebCore::DeleteSelectionCommand::mergeParagraphs): Block images, tables and HRs cannot
            be made inline with other content.  Instead of merging, just move the caret to just before
            the selection we deleted.
            * editing/htmlediting.cpp:
            (WebCore::firstInSpecialElement): Added a FIXME.  This function begins iterating up from pos.node(), which
            doesn't necessarily contain pos (suppose pos was [img, 0]).
            (WebCore::lastInSpecialElement): Ditto.
            (WebCore::isRenderedAsNonInlineTableImageOrHR): Moved from visible_units.cpp.  Added a check for non-inline images.
            * editing/htmlediting.h:
            * editing/visible_units.cpp:
            (WebCore::startOfParagraph): Use moved/renamed function.  Removed FIXME.  The problem causing
            5027702 is now squarely in first/lastInSpecialElement
            (WebCore::endOfParagraph): Ditto.
    
    LayoutTests:
    
    2009-11-03  Justin Garcia  <justin.garcia at apple.com>
    
            Reviewed by Adele Peterson.
    
            https://bugs.webkit.org/show_bug.cgi?id=25439
            Deleting when in front of a block image removes character from previous paragraph
    
            * editing/deleting/delete-before-block-image-1-expected.txt: Added.
            * editing/deleting/delete-before-block-image-1.html: Added.
            * editing/deleting/delete-before-block-image-2-expected.txt: Added.
            * editing/deleting/delete-before-block-image-2.html: Added.
            * editing/deleting/delete-before-block-table-expected.txt: Added.
            * editing/deleting/delete-before-block-table.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50542 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 62bd0bb..69b1332 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2009-11-03  Justin Garcia  <justin.garcia at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        https://bugs.webkit.org/show_bug.cgi?id=25439
+        Deleting when in front of a block image removes character from previous paragraph
+
+        * editing/deleting/delete-before-block-image-1-expected.txt: Added.
+        * editing/deleting/delete-before-block-image-1.html: Added.
+        * editing/deleting/delete-before-block-image-2-expected.txt: Added.
+        * editing/deleting/delete-before-block-image-2.html: Added.
+        * editing/deleting/delete-before-block-table-expected.txt: Added.
+        * editing/deleting/delete-before-block-table.html: Added.
+
 2009-11-04  Enrica Casucci  <enrica at apple.com>
 
         Reviewed by Adele Peterson.
diff --git a/LayoutTests/editing/deleting/delete-before-block-image-1-expected.txt b/LayoutTests/editing/deleting/delete-before-block-image-1-expected.txt
new file mode 100644
index 0000000..933e900
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-before-block-image-1-expected.txt
@@ -0,0 +1,3 @@
+This tests placing the caret just before a block image and pressing delete. The image should not be deleted. The caret should just move back to the previous paragraph.<img id="img" style="display:block;" src="../resources/abe.png">
+
+Selection: [[object Text], 167]
diff --git a/LayoutTests/editing/deleting/delete-before-block-image-1.html b/LayoutTests/editing/deleting/delete-before-block-image-1.html
new file mode 100644
index 0000000..aecf18b
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-before-block-image-1.html
@@ -0,0 +1,18 @@
+<head>
+<script>
+function runTest() {
+    if (window.layoutTestController)
+        window.layoutTestController.dumpAsText();
+    img = document.getElementById("img");
+    s = window.getSelection();
+    s.setPosition(img, 0);
+    document.execCommand("Delete");
+    if (window.layoutTestController)
+        document.body.innerText = document.getElementById("div").innerHTML + "\n\nSelection: [" + s.anchorNode + ", " + s.anchorOffset + "]";
+}
+</script>    
+</head>
+<body onLoad="runTest();">
+<div>This is a test for <a href="https://bugs.webkit.org/show_bug.cgi?id=25439">https://bugs.webkit.org/show_bug.cgi?id=25439</a>.</div>
+<div id="div" contentEditable="true">This tests placing the caret just before a block image and pressing delete. The image should not be deleted. The caret should just move back to the previous paragraph.<img id="img" style="display:block;" src="../resources/abe.png"></div>
+</body>
diff --git a/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt b/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt
new file mode 100644
index 0000000..c65abd4
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt
@@ -0,0 +1,3 @@
+<img id="img" style="display:block;" src="../resources/abe.png">
+
+Selection: [[object HTMLDivElement], 0]
diff --git a/LayoutTests/editing/deleting/delete-before-block-image-2.html b/LayoutTests/editing/deleting/delete-before-block-image-2.html
new file mode 100644
index 0000000..0c81dfe
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-before-block-image-2.html
@@ -0,0 +1,19 @@
+<head>
+<script>
+function runTest() {
+    if (window.layoutTestController)
+        window.layoutTestController.dumpAsText();
+    img = document.getElementById("img");
+    s = window.getSelection();
+    s.setPosition(img, 0);
+    document.execCommand("Delete");
+    if (window.layoutTestController)
+        document.body.innerText = document.getElementById("div").innerHTML + "\n\nSelection: [" + s.anchorNode + ", " + s.anchorOffset + "]";
+}
+</script>    
+</head>
+<body onLoad="runTest();">
+<div>This is a test for <a href="https://bugs.webkit.org/show_bug.cgi?id=25439">https://bugs.webkit.org/show_bug.cgi?id=25439</a>.</div>
+<div>This tests placing the caret just before a block image and pressing delete. The image should move up one line.</div>
+<div id="div" contentEditable="true"><br><img id="img" style="display:block;" src="../resources/abe.png"></div>
+</body>
diff --git a/LayoutTests/editing/deleting/delete-before-block-table-expected.txt b/LayoutTests/editing/deleting/delete-before-block-table-expected.txt
new file mode 100644
index 0000000..6e2e51c
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-before-block-table-expected.txt
@@ -0,0 +1,3 @@
+This tests placing the caret just before a block table and pressing delete. The caret should just move back to the previous paragraph.<table border="1" id="table"><tbody><tr><td>1</td><td>2</td></tr></tbody></table>
+
+Selection: [[object Text], 134]
diff --git a/LayoutTests/editing/deleting/delete-before-block-table.html b/LayoutTests/editing/deleting/delete-before-block-table.html
new file mode 100644
index 0000000..07ee4ec
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-before-block-table.html
@@ -0,0 +1,18 @@
+<head>
+<script>
+function runTest() {
+    if (window.layoutTestController)
+        window.layoutTestController.dumpAsText();
+    table = document.getElementById("table");
+    s = window.getSelection();
+    s.setPosition(table, 0);
+    document.execCommand("Delete");
+    if (window.layoutTestController)
+        document.body.innerText = document.getElementById("div").innerHTML + "\n\nSelection: [" + s.anchorNode + ", " + s.anchorOffset + "]";
+}
+</script>    
+</head>
+<body onLoad="runTest();">
+<div>This is a test for <a href="https://bugs.webkit.org/show_bug.cgi?id=25439">https://bugs.webkit.org/show_bug.cgi?id=25439</a>.</div>
+<div id="div" contentEditable="true">This tests placing the caret just before a block table and pressing delete. The caret should just move back to the previous paragraph.<table border="1" id="table"><tr><td>1</td><td>2</td></tr></table></div>
+</body>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 244c045..4f4be4b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2009-11-02  Justin Garcia  <justin.garcia at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        https://bugs.webkit.org/show_bug.cgi?id=25439
+        Deleting when in front of a block image removes character from previous paragraph
+
+        Added editing/deleting/25439-{1,2,3}.html
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::mergeParagraphs): Block images, tables and HRs cannot 
+        be made inline with other content.  Instead of merging, just move the caret to just before 
+        the selection we deleted.
+        * editing/htmlediting.cpp:
+        (WebCore::firstInSpecialElement): Added a FIXME.  This function begins iterating up from pos.node(), which 
+        doesn't necessarily contain pos (suppose pos was [img, 0]).
+        (WebCore::lastInSpecialElement): Ditto.
+        (WebCore::isRenderedAsNonInlineTableImageOrHR): Moved from visible_units.cpp.  Added a check for non-inline images.
+        * editing/htmlediting.h:
+        * editing/visible_units.cpp:
+        (WebCore::startOfParagraph): Use moved/renamed function.  Removed FIXME.  The problem causing 
+        5027702 is now squarely in first/lastInSpecialElement
+        (WebCore::endOfParagraph): Ditto.
 2009-11-04  Enrica Casucci  <enrica at apple.com>
 
         Reviewed by Adele Peterson.
@@ -8,9 +31,9 @@
 
         The hang was caused by an infinite loop inside outdentRegion.
         The code did not account for the fact that, when a list item
-        cointains multiple paragraphs, outdent moves all paragraphs at
-        once, invalidating some of the position we keep track of in the loop.
-        Some code refactoring has also been done to minimize duplicate code.
+        contains multiple paragraphs, outdent moves all paragraphs at
+        once, invalidating some of the positions we keep track of in the loop.
+        Some code refactoring has also been done to minimize duplicated code.
         
         Test: editing/execCommand/outdent-multiparagraph-list.html
 
diff --git a/WebCore/editing/DeleteSelectionCommand.cpp b/WebCore/editing/DeleteSelectionCommand.cpp
index fbb5aea..9e4ba29 100644
--- a/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/WebCore/editing/DeleteSelectionCommand.cpp
@@ -595,6 +595,14 @@ void DeleteSelectionCommand::mergeParagraphs()
         return;
     }
     
+    // Block images, tables and horizontal rules cannot be made inline with content at mergeDestination.  If there is 
+    // any (!isStartOfParagraph(mergeDestination)), don't merge, just move the caret to just before the selection we deleted.
+    // See https://bugs.webkit.org/show_bug.cgi?id=25439
+    if (isRenderedAsNonInlineTableImageOrHR(startOfParagraphToMove.deepEquivalent().node()) && !isStartOfParagraph(mergeDestination)) {
+        m_endingPosition = m_upstreamStart;
+        return;
+    }
+    
     RefPtr<Range> range = Range::create(document(), rangeCompliantEquivalent(startOfParagraphToMove.deepEquivalent()), rangeCompliantEquivalent(endOfParagraphToMove.deepEquivalent()));
     RefPtr<Range> rangeToBeReplaced = Range::create(document(), rangeCompliantEquivalent(mergeDestination.deepEquivalent()), rangeCompliantEquivalent(mergeDestination.deepEquivalent()));
     if (!document()->frame()->editor()->client()->shouldMoveRangeAfterDelete(range.get(), rangeToBeReplaced.get()))
diff --git a/WebCore/editing/htmlediting.cpp b/WebCore/editing/htmlediting.cpp
index d19ef6b..eb73cdd 100644
--- a/WebCore/editing/htmlediting.cpp
+++ b/WebCore/editing/htmlediting.cpp
@@ -494,6 +494,7 @@ bool validBlockTag(const AtomicString& blockTag)
 
 static Node* firstInSpecialElement(const Position& pos)
 {
+    // FIXME: This begins at pos.node(), which doesn't necessarily contain pos (suppose pos was [img, 0]).  See <rdar://problem/5027702>.
     Node* rootEditableElement = pos.node()->rootEditableElement();
     for (Node* n = pos.node(); n && n->rootEditableElement() == rootEditableElement; n = n->parentNode())
         if (isSpecialElement(n)) {
@@ -509,6 +510,7 @@ static Node* firstInSpecialElement(const Position& pos)
 
 static Node* lastInSpecialElement(const Position& pos)
 {
+    // FIXME: This begins at pos.node(), which doesn't necessarily contain pos (suppose pos was [img, 0]).  See <rdar://problem/5027702>.
     Node* rootEditableElement = pos.node()->rootEditableElement();
     for (Node* n = pos.node(); n && n->rootEditableElement() == rootEditableElement; n = n->parentNode())
         if (isSpecialElement(n)) {
@@ -1077,6 +1079,14 @@ bool isNodeVisiblyContainedWithin(Node* node, const Range* selectedRange)
         && visiblePositionAfterNode(node) == selectedRange->endPosition();
 }
 
+bool isRenderedAsNonInlineTableImageOrHR(const Node* node)
+{
+    if (!node)
+        return false;
+    RenderObject* renderer = node->renderer();
+    return renderer && ((renderer->isTable() && !renderer->isInline()) || renderer->isImage() && !renderer->isInline() || renderer->isHR());
+}
+
 PassRefPtr<Range> avoidIntersectionWithNode(const Range* range, Node* node)
 {
     if (!range)
diff --git a/WebCore/editing/htmlediting.h b/WebCore/editing/htmlediting.h
index f44181c..43048e0 100644
--- a/WebCore/editing/htmlediting.h
+++ b/WebCore/editing/htmlediting.h
@@ -91,6 +91,7 @@ bool isTableStructureNode(const Node*);
 bool isListElement(Node*);
 bool isNodeRendered(const Node*);
 bool isNodeVisiblyContainedWithin(Node*, const Range*);
+bool isRenderedAsNonInlineTableImageOrHR(const Node*);
     
     
 // -------------------------------------------------------------------------
diff --git a/WebCore/editing/visible_units.cpp b/WebCore/editing/visible_units.cpp
index c96fdfd..84ace83 100644
--- a/WebCore/editing/visible_units.cpp
+++ b/WebCore/editing/visible_units.cpp
@@ -776,12 +776,6 @@ VisiblePosition nextSentencePosition(const VisiblePosition &c)
     return c.honorEditableBoundaryAtOrBefore(next);
 }
 
-static bool renderedAsNonInlineTableOrHR(RenderObject* renderer)
-{
-    return renderer && ((renderer->isTable() && !renderer->isInline()) || renderer->isHR());
-}
-
-// FIXME: Broken for positions before/after images that aren't inline (5027702)
 VisiblePosition startOfParagraph(const VisiblePosition& c)
 {
     Position p = c.deepEquivalent();
@@ -790,7 +784,7 @@ VisiblePosition startOfParagraph(const VisiblePosition& c)
     if (!startNode)
         return VisiblePosition();
     
-    if (renderedAsNonInlineTableOrHR(startNode->renderer()) && p.atLastEditingPositionForNode())
+    if (isRenderedAsNonInlineTableImageOrHR(startNode))
         return firstDeepEditingPositionForNode(startNode);
 
     Node* startBlock = enclosingBlock(startNode);
@@ -841,7 +835,6 @@ VisiblePosition startOfParagraph(const VisiblePosition& c)
     return VisiblePosition(node, offset, DOWNSTREAM);
 }
 
-// FIXME: Broken for positions before/after images that aren't inline (5027702)
 VisiblePosition endOfParagraph(const VisiblePosition &c)
 {    
     if (c.isNull())
@@ -850,7 +843,7 @@ VisiblePosition endOfParagraph(const VisiblePosition &c)
     Position p = c.deepEquivalent();
     Node* startNode = p.node();
 
-    if (renderedAsNonInlineTableOrHR(startNode->renderer()) && p.atFirstEditingPositionForNode())
+    if (isRenderedAsNonInlineTableImageOrHR(startNode))
         return lastDeepEditingPositionForNode(startNode);
     
     Node* startBlock = enclosingBlock(startNode);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list