[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 15:22:19 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 33f5aa4f0418e7b035b4a2cdd7cfc15e67fc01e4
Author: morrita at google.com <morrita at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 2 05:30:42 2010 +0000

    2010-11-01  MORITA Hajime  <morrita at google.com>
    
            Reviewed by Kent Tamura.
    
            @spellcheck attribute at the child of contentEditable node is ignored.
            https://bugs.webkit.org/show_bug.cgi?id=48418
    
            * editing/spelling/script-tests/spelling-attribute-at-child.js: Added.
            * editing/spelling/spelling-attribute-at-child-expected.txt: Added.
            * editing/spelling/spelling-attribute-at-child.html: Added.
    2010-11-01  MORITA Hajime  <morrita at google.com>
    
            Reviewed by Kent Tamura.
    
            @spellcheck attribute at the child of contentEditable node is ignored.
            https://bugs.webkit.org/show_bug.cgi?id=48418
    
            Changed to check spellcheck availability against a node under the
            selection (caret) instead of the focus. For shadow elements, the
            check now refers its host node.  Note that the original code didn't
            care shadows because focus is never set on them.
    
            Test: editing/spelling/spelling-attribute-at-child.html
    
            * dom/Element.h:
            * editing/Editor.cpp:
            (WebCore::Editor::markMisspellingsOrBadGrammar):
            (WebCore::Editor::isSpellCheckingEnabledFor):
            (WebCore::Editor::isSpellCheckingEnabledInFocusedNode): Now just calling isSpellCheckingEnabledFor()
            (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
            * editing/Editor.h:
            * platform/ContextMenu.cpp:
            (WebCore::ContextMenu::populate):
            * rendering/TextControlInnerElements.cpp:
            (WebCore::TextControlInnerElement::isSpellCheckingEnabled): Added.
            * rendering/TextControlInnerElements.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71101 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 36cd3a0..e478372 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-01  MORITA Hajime  <morrita at google.com>
+
+        Reviewed by Kent Tamura.
+
+        @spellcheck attribute at the child of contentEditable node is ignored.
+        https://bugs.webkit.org/show_bug.cgi?id=48418
+
+        * editing/spelling/script-tests/spelling-attribute-at-child.js: Added.
+        * editing/spelling/spelling-attribute-at-child-expected.txt: Added.
+        * editing/spelling/spelling-attribute-at-child.html: Added.
+
 2010-11-01  Adam Barth  <abarth at webkit.org>
 
         Update expected results for PNG ICC profile.
diff --git a/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js b/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js
new file mode 100644
index 0000000..0028672
--- /dev/null
+++ b/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js
@@ -0,0 +1,29 @@
+description('Tests if the spellchecker behavior change after the spellcheck attribute changed by the script.');
+
+var root = document.createElement("div");
+document.body.appendChild(root);
+
+function childHasSpellingMarker(markup)
+{
+    root.innerHTML = markup;
+    var text = document.getElementById("child").firstChild;
+    document.getSelection().setPosition(text, 1);
+    document.execCommand("InsertText", false, 'z');
+    document.execCommand("InsertText", false, 'z');
+    document.execCommand("InsertText", false, ' ');
+    var marked = layoutTestController.hasSpellingMarker(1, 2);
+    root.innerHTML = "";
+    return marked;
+}
+
+shouldBeFalse("childHasSpellingMarker(\"<div contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")");
+shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span id='child'>[]</span> Baz</div>\")");
+shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>\")");
+shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")");
+shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>Foo <span id='child'>[]</span> Baz</div>\")");
+shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>\")");
+shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")");
+shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Foo <span id='child'>[]</span> Baz</div>\")");
+shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>\")");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/editing/spelling/spelling-attribute-at-child-expected.txt b/LayoutTests/editing/spelling/spelling-attribute-at-child-expected.txt
new file mode 100644
index 0000000..54b4ef8
--- /dev/null
+++ b/LayoutTests/editing/spelling/spelling-attribute-at-child-expected.txt
@@ -0,0 +1,18 @@
+Tests if the spellchecker behavior change after the spellcheck attribute changed by the script.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS childHasSpellingMarker("<div contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>") is false
+PASS childHasSpellingMarker("<div contentEditable>Foo <span id='child'>[]</span> Baz</div>") is true
+PASS childHasSpellingMarker("<div contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>") is true
+PASS childHasSpellingMarker("<div spellcheck='false' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>") is false
+PASS childHasSpellingMarker("<div spellcheck='false' contentEditable>Foo <span id='child'>[]</span> Baz</div>") is false
+PASS childHasSpellingMarker("<div spellcheck='false' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>") is true
+PASS childHasSpellingMarker("<div spellcheck='true' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>") is false
+PASS childHasSpellingMarker("<div spellcheck='true' contentEditable>Foo <span id='child'>[]</span> Baz</div>") is true
+PASS childHasSpellingMarker("<div spellcheck='true' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>") is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/spelling/spelling-attribute-at-child.html b/LayoutTests/editing/spelling/spelling-attribute-at-child.html
new file mode 100644
index 0000000..78957a9
--- /dev/null
+++ b/LayoutTests/editing/spelling/spelling-attribute-at-child.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-attribute-at-child.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 27cbfb0..966fd27 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-11-01  MORITA Hajime  <morrita at google.com>
+
+        Reviewed by Kent Tamura.
+
+        @spellcheck attribute at the child of contentEditable node is ignored.
+        https://bugs.webkit.org/show_bug.cgi?id=48418
+
+        Changed to check spellcheck availability against a node under the
+        selection (caret) instead of the focus. For shadow elements, the
+        check now refers its host node.  Note that the original code didn't
+        care shadows because focus is never set on them.
+        
+        Test: editing/spelling/spelling-attribute-at-child.html
+
+        * dom/Element.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::markMisspellingsOrBadGrammar):
+        (WebCore::Editor::isSpellCheckingEnabledFor): 
+        (WebCore::Editor::isSpellCheckingEnabledInFocusedNode): Now just calling isSpellCheckingEnabledFor()
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+        * editing/Editor.h:
+        * platform/ContextMenu.cpp:
+        (WebCore::ContextMenu::populate):
+        * rendering/TextControlInnerElements.cpp:
+        (WebCore::TextControlInnerElement::isSpellCheckingEnabled): Added.
+        * rendering/TextControlInnerElements.h:
+
 2010-11-01  Martin Robinson  <mrobinson at igalia.com>
 
         Reviewed by Daniel Bates.
diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h
index 67887cc..1a85650 100644
--- a/WebCore/dom/Element.h
+++ b/WebCore/dom/Element.h
@@ -326,7 +326,7 @@ public:
     void webkitRequestFullScreen(unsigned short flags);
 #endif
 
-    bool isSpellCheckingEnabled() const;
+    virtual bool isSpellCheckingEnabled() const;
 
 protected:
     Element(const QualifiedName& tagName, Document* document, ConstructionType type)
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 8a4ef59..22cb7b1 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -2095,7 +2095,7 @@ void Editor::markMisspellingsOrBadGrammar(const VisibleSelection& selection, boo
     if (!editableNode || !editableNode->isContentEditable())
         return;
 
-    if (!isSpellCheckingEnabledInFocusedNode())
+    if (!isSpellCheckingEnabledFor(editableNode))
         return;
 
     // Get the spell checker if it is available
@@ -2115,11 +2115,8 @@ void Editor::markMisspellingsOrBadGrammar(const VisibleSelection& selection, boo
     }    
 }
 
-bool Editor::isSpellCheckingEnabledInFocusedNode() const
+bool Editor::isSpellCheckingEnabledFor(Node* node) const
 {
-    // Ascend the DOM tree to find a "spellcheck" attribute.
-    // When we find a "spellcheck" attribute, retrieve its value and return false if its value is "false".
-    const Node* node = frame()->document()->focusedNode();
     if (!node)
         return false;
     const Element* focusedElement = node->isElementNode() ? toElement(node) : node->parentElement();
@@ -2128,6 +2125,11 @@ bool Editor::isSpellCheckingEnabledInFocusedNode() const
     return focusedElement->isSpellCheckingEnabled();
 }
 
+bool Editor::isSpellCheckingEnabledInFocusedNode() const
+{
+    return isSpellCheckingEnabledFor(m_frame->selection()->start().node());
+}
+
 void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange)
 {
     markMisspellingsOrBadGrammar(selection, true, firstMisspellingRange);
@@ -2170,7 +2172,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
     if (!editableNode || !editableNode->isContentEditable())
         return;
 
-    if (!isSpellCheckingEnabledInFocusedNode())
+    if (!isSpellCheckingEnabledFor(editableNode))
         return;
 
     // Expand the range to encompass entire paragraphs, since text checking needs that much context.
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 110e3f9..8bf1ea5 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -219,6 +219,7 @@ public:
     Vector<String> guessesForUngrammaticalSelection();
     Vector<String> guessesForMisspelledOrUngrammaticalSelection(bool& misspelled, bool& ungrammatical);
     bool isSpellCheckingEnabledInFocusedNode() const;
+    bool isSpellCheckingEnabledFor(Node*) const;
     void markMisspellingsAfterTypingToPosition(const VisiblePosition&);
     void markMisspellings(const VisibleSelection&, RefPtr<Range>& firstMisspellingRange);
     void markBadGrammar(const VisibleSelection&);
diff --git a/WebCore/platform/ContextMenu.cpp b/WebCore/platform/ContextMenu.cpp
index ecdf230..93cdfdf 100644
--- a/WebCore/platform/ContextMenu.cpp
+++ b/WebCore/platform/ContextMenu.cpp
@@ -429,7 +429,7 @@ void ContextMenu::populate()
     } else { // Make an editing context menu
         SelectionController* selection = frame->selection();
         bool inPasswordField = selection->isInPasswordField();
-        bool spellCheckingEnabled = frame->editor()->isSpellCheckingEnabledInFocusedNode();
+        bool spellCheckingEnabled = frame->editor()->isSpellCheckingEnabledFor(node);
         
         if (!inPasswordField && spellCheckingEnabled) {
             // Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range
diff --git a/WebCore/rendering/TextControlInnerElements.cpp b/WebCore/rendering/TextControlInnerElements.cpp
index f9641f4..d9a1a73 100644
--- a/WebCore/rendering/TextControlInnerElements.cpp
+++ b/WebCore/rendering/TextControlInnerElements.cpp
@@ -124,6 +124,11 @@ void TextControlInnerElement::attachInnerElement(Node* parent, PassRefPtr<Render
         parent->renderer()->addChild(renderer);
 }
 
+bool TextControlInnerElement::isSpellCheckingEnabled() const
+{
+    return m_shadowParent && m_shadowParent->isSpellCheckingEnabled();
+}
+
 // ----------------------------
 
 inline TextControlInnerTextElement::TextControlInnerTextElement(Document* document, HTMLElement* shadowParent)
diff --git a/WebCore/rendering/TextControlInnerElements.h b/WebCore/rendering/TextControlInnerElements.h
index 46c1c8e..61c9dba 100644
--- a/WebCore/rendering/TextControlInnerElements.h
+++ b/WebCore/rendering/TextControlInnerElements.h
@@ -49,6 +49,7 @@ private:
     virtual bool isMouseFocusable() const { return false; } 
     virtual bool isShadowNode() const { return m_shadowParent; }
     virtual ContainerNode* shadowParentNode() { return m_shadowParent; }
+    virtual bool isSpellCheckingEnabled() const;
     void setShadowParentNode(HTMLElement* shadowParent) { m_shadowParent = shadowParent; }
 
     HTMLElement* m_shadowParent;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list