[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

morrita at google.com morrita at google.com
Wed Dec 22 13:13:25 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7b51c895153695bedeba7b4c2bd312533428279b
Author: morrita at google.com <morrita at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 9 02:05:26 2010 +0000

    2010-09-08  MORITA Hajime  <morrita at google.com>
    
            Reviewed by Tony Chang.
    
            spelling underline gets lost on backspace
            https://bugs.webkit.org/show_bug.cgi?id=41423
    
            * editing/spelling/script-tests/TEMPLATE.html: Copied from LayoutTests/editing/selection/script-tests/TEMPLATE.html.
            * editing/spelling/script-tests/spelling-backspace-between-lines.js: Added.
            * editing/spelling/spelling-backspace-between-lines-expected.txt: Added.
            * editing/spelling/spelling-backspace-between-lines.html: Added.
    2010-09-08  MORITA Hajime  <morrita at google.com>
    
            Reviewed by Tony Chang.
    
            spelling underline gets lost on backspace
            https://bugs.webkit.org/show_bug.cgi?id=41423
    
            moveParagraphs() did make a DOM range by serializing source range
            and deserializing it back, and markers are gone during the process.
            This change marks that DOM range again.
    
            Test: editing/spelling/spelling-backspace-between-lines.html
    
            * editing/CompositeEditCommand.cpp:
            (WebCore::CompositeEditCommand::moveParagraphs):
            * editing/Editor.cpp:
            (WebCore::Editor::clearMisspellingsAndBadGrammar): Added.
            (WebCore::Editor::markMisspellingsAndBadGrammar): Added.
            * editing/Editor.h:
    2010-09-08  MORITA Hajime  <morrita at google.com>
    
            Reviewed by Tony Chang.
    
            spelling underline gets lost on backspace
            https://bugs.webkit.org/show_bug.cgi?id=41423
    
            Switched to use a anchorNode of the selection instead of a focused
            node for finer control of node selection in spellingNode():
            With the focused node, we cannot select other nodes but the first
            child of that node. In some case, we need to inspect these.
    
            The API is only for LayoutTests, and the change is compatible for
            existing test cases.
    
            * WebView/WebFrame.mm:
            (spellingNode):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67049 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5b7eb40..4c097a4 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-08  MORITA Hajime  <morrita at google.com>
+
+        Reviewed by Tony Chang.
+
+        spelling underline gets lost on backspace
+        https://bugs.webkit.org/show_bug.cgi?id=41423
+
+        * editing/spelling/script-tests/TEMPLATE.html: Copied from LayoutTests/editing/selection/script-tests/TEMPLATE.html.
+        * editing/spelling/script-tests/spelling-backspace-between-lines.js: Added.
+        * editing/spelling/spelling-backspace-between-lines-expected.txt: Added.
+        * editing/spelling/spelling-backspace-between-lines.html: Added.
+
 2010-09-08  Fumitoshi Ukai  <ukai at chromium.org>
 
         Unreviewed.
diff --git a/LayoutTests/editing/selection/script-tests/TEMPLATE.html b/LayoutTests/editing/spelling/script-tests/TEMPLATE.html
similarity index 100%
copy from LayoutTests/editing/selection/script-tests/TEMPLATE.html
copy to LayoutTests/editing/spelling/script-tests/TEMPLATE.html
diff --git a/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js b/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js
new file mode 100644
index 0000000..d3663d2
--- /dev/null
+++ b/LayoutTests/editing/spelling/script-tests/spelling-backspace-between-lines.js
@@ -0,0 +1,65 @@
+
+description('For Bug 41423: Spelling marker should remain after hitting a backspace key.');
+
+var testRoot = document.createElement("div");
+document.body.insertBefore(testRoot, document.body.firstChild);
+
+function setup(targetName)
+{
+    testRoot.innerHTML = "<div id='" + targetName + "' contentEditable><div>OK</div><div>OK zz OK</div></div>";
+    document.getElementById(targetName).focus();
+    return document.getSelection();
+}
+
+function firstLineText()
+{
+    return testRoot.firstChild.firstChild.innerText.trim();
+}
+
+function testWithDelete()
+{
+    window.sel = setup("target1");
+
+    sel.modify("move", "forward", "line");
+    for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length
+        sel.modify("move", "forward", "word");
+
+    shouldBe("firstLineText()", "'OK'");
+    shouldBe("sel.anchorNode.data", "'OK zz OK'");
+    shouldBe("textInputController.hasSpellingMarker(3, 2)", "1");
+
+    sel.modify("move", "left", "lineboundary");
+    document.execCommand("Delete", false);
+    sel.modify("move", "right", "line"); // Moves to the line ending to focus the "OK zz OK" text.
+
+    shouldBe("sel.anchorNode.data", "'OK zz OK'");
+    shouldBe("firstLineText()", "'OKOK zz OK'");
+    shouldBe("textInputController.hasSpellingMarker(3, 2)", "1");
+}
+
+function testWithForwardDelete()
+{
+    window.sel = setup("target1");
+
+    sel.modify("move", "forward", "line");
+    for (var i = 0; i < 3; i++) // 3 for ["OK, "zz", "OK"].length
+        sel.modify("move", "forward", "word");
+
+    shouldBe("firstLineText()", "'OK'");
+    shouldBe("sel.anchorNode.data", "'OK zz OK'");
+    shouldBe("textInputController.hasSpellingMarker(3, 2)", "1");
+
+    sel.modify("move", "left", "line");
+    document.execCommand("ForwardDelete", false);
+    sel.modify("move", "right", "line"); // Moves to the line ending to focus the "OK zz OK" text.
+
+    shouldBe("firstLineText()", "'OKOK zz OK'");
+    shouldBe("sel.anchorNode.data", "'OK zz OK'");
+    shouldBe("textInputController.hasSpellingMarker(3, 2)", "1");
+}
+
+testWithDelete();
+testWithForwardDelete();
+testRoot.style.display = "none";
+
+var successfullyParsed = true;
diff --git a/LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt b/LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt
new file mode 100644
index 0000000..03841f3
--- /dev/null
+++ b/LayoutTests/editing/spelling/spelling-backspace-between-lines-expected.txt
@@ -0,0 +1,21 @@
+For Bug 41423: Spelling marker should remain after hitting a backspace key.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS firstLineText() is 'OK'
+PASS sel.anchorNode.data is 'OK zz OK'
+PASS textInputController.hasSpellingMarker(3, 2) is 1
+PASS sel.anchorNode.data is 'OK zz OK'
+PASS firstLineText() is 'OKOK zz OK'
+PASS textInputController.hasSpellingMarker(3, 2) is 1
+PASS firstLineText() is 'OK'
+PASS sel.anchorNode.data is 'OK zz OK'
+PASS textInputController.hasSpellingMarker(3, 2) is 1
+PASS firstLineText() is 'OKOK zz OK'
+PASS sel.anchorNode.data is 'OK zz OK'
+PASS textInputController.hasSpellingMarker(3, 2) is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/spelling/spelling-backspace-between-lines.html b/LayoutTests/editing/spelling/spelling-backspace-between-lines.html
new file mode 100644
index 0000000..bd20e96
--- /dev/null
+++ b/LayoutTests/editing/spelling/spelling-backspace-between-lines.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/js-test-selection-shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/spelling-backspace-between-lines.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d6e657e..76aea1f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-08  MORITA Hajime  <morrita at google.com>
+
+        Reviewed by Tony Chang.
+
+        spelling underline gets lost on backspace
+        https://bugs.webkit.org/show_bug.cgi?id=41423
+
+        moveParagraphs() did make a DOM range by serializing source range
+        and deserializing it back, and markers are gone during the process.
+        This change marks that DOM range again.
+
+        Test: editing/spelling/spelling-backspace-between-lines.html
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::moveParagraphs):
+        * editing/Editor.cpp:
+        (WebCore::Editor::clearMisspellingsAndBadGrammar): Added.
+        (WebCore::Editor::markMisspellingsAndBadGrammar): Added.
+        * editing/Editor.h:
+
 2010-09-08  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp
index aa37193..356a717 100644
--- a/WebCore/editing/CompositeEditCommand.cpp
+++ b/WebCore/editing/CompositeEditCommand.cpp
@@ -36,6 +36,7 @@
 #include "Document.h"
 #include "DocumentFragment.h"
 #include "EditorInsertAction.h"
+#include "Frame.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "InlineTextBox.h"
@@ -939,6 +940,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     // FIXME (5098931): We should add a new insert action "WebViewInsertActionMoved" and call shouldInsertFragment here.
     
     setEndingSelection(VisibleSelection(start, end, DOWNSTREAM));
+    document()->frame()->editor()->clearMisspellingsAndBadGrammar(endingSelection());
     deleteSelection(false, false, false, false);
 
     ASSERT(destination.deepEquivalent().node()->inDocument());
@@ -968,7 +970,9 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     setEndingSelection(destination);
     ASSERT(endingSelection().isCaretOrRange());
     applyCommandToComposite(ReplaceSelectionCommand::create(document(), fragment, true, false, !preserveStyle, false, true));
-    
+
+    document()->frame()->editor()->markMisspellingsAndBadGrammar(endingSelection());
+
     // If the selection is in an empty paragraph, restore styles from the old empty paragraph to the new empty paragraph.
     bool selectionIsEmptyParagraph = endingSelection().isCaret() && isStartOfParagraph(endingSelection().visibleStart()) && isEndOfParagraph(endingSelection().visibleStart());
     if (styleInEmptyParagraph && selectionIsEmptyParagraph)
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 9e41a62..d3b8376 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -2353,6 +2353,29 @@ bool Editor::spellingPanelIsShowing()
     return client()->spellingUIIsShowing();
 }
 
+void Editor::clearMisspellingsAndBadGrammar(const VisibleSelection &movingSelection)
+{
+    RefPtr<Range> selectedRange = movingSelection.toNormalizedRange();
+    if (selectedRange) {
+        frame()->document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Spelling);
+        frame()->document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Grammar);
+    }
+}
+
+void Editor::markMisspellingsAndBadGrammar(const VisibleSelection &movingSelection)
+{
+    bool markSpelling = isContinuousSpellCheckingEnabled();
+    bool markGrammar = markSpelling && isGrammarCheckingEnabled();
+
+    if (markSpelling) {
+        RefPtr<Range> unusedFirstMisspellingRange;
+        markMisspellings(movingSelection, unusedFirstMisspellingRange);
+    }
+
+    if (markGrammar)
+        markBadGrammar(movingSelection);
+}
+
 void Editor::markMisspellingsAfterTypingToPosition(const VisiblePosition &p)
 {
 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 78e89b4..79552b4 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -314,6 +314,9 @@ public:
 
     // This is only called on the mac where paste is implemented primarily at the WebKit level.
     void pasteAsPlainTextBypassingDHTML();
+ 
+    void clearMisspellingsAndBadGrammar(const VisibleSelection&);
+    void markMisspellingsAndBadGrammar(const VisibleSelection&);
 
     Node* findEventTargetFrom(const VisibleSelection& selection) const;
 private:
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 09bfd69..80a6b31 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,21 @@
+2010-09-08  MORITA Hajime  <morrita at google.com>
+
+        Reviewed by Tony Chang.
+
+        spelling underline gets lost on backspace
+        https://bugs.webkit.org/show_bug.cgi?id=41423
+
+        Switched to use a anchorNode of the selection instead of a focused
+        node for finer control of node selection in spellingNode():
+        With the focused node, we cannot select other nodes but the first
+        child of that node. In some case, we need to inspect these.
+
+        The API is only for LayoutTests, and the change is compatible for
+        existing test cases.
+        
+        * WebView/WebFrame.mm:
+        (spellingNode):
+
 2010-09-08  Adam Barth  <abarth at webkit.org>
 
         Rubber-stamped by Eric Seidel.
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index a3b6f9e..5b28833 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -1368,7 +1368,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 static Node* spellingNode(Frame* coreFrame)
 {
-    Node* focusedNode = coreFrame->document()->focusedNode();
+    Node* focusedNode = coreFrame->selection()->start().node();
     if (!focusedNode || !focusedNode->renderer())
         return 0;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list