Skip to content
Permalink
Browse files
2010-10-22 MORITA Hajime <morrita@google.com>
        Reviewed by Tony Chang.

        spellcheck='' should be the same as spellcheck="true"
        https://bugs.webkit.org/show_bug.cgi?id=25539

        * editing/spelling/spellcheck-attribute-expected.txt:
        * editing/spelling/spellcheck-attribute.html:
2010-10-24  MORITA Hajime  <morrita@google.com>

        Reviewed by Tony Chang.

        spellcheck='' should be the same as spellcheck="true"
        https://bugs.webkit.org/show_bug.cgi?id=25539

        - Added a check for empty string and missing attribute.
        - Extracted the check to Element::spellCheckingEnabled()
        - Introduced SpellcheckAttributeState enum to represent the
          states for spellcheck attributes.

        * dom/Element.cpp:
        (WebCore::Element::spellcheckAttributeState): Added.
        (WebCore::Element::isSpellCheckingEnabled): Added.
        * dom/Element.h:
        * editing/Editor.cpp:
        (WebCore::markMisspellingsOrBadGrammar):
        (WebCore::Editor::isSpellCheckingEnabledInFocusedNode): Renamed, partly extracted to Element::isSpellCheckingEnabled()
        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
        * editing/Editor.h:
        * platform/ContextMenu.cpp:
        (WebCore::ContextMenu::populate):
2010-10-25  MORITA Hajime  <morrita@google.com>

        Reviewed by Tony Chang.

        spellcheck='' should be the same as spellcheck="true"
        https://bugs.webkit.org/show_bug.cgi?id=25539

        Followed API rename in WebCore.

        * src/ContextMenuClientImpl.cpp:
        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::shouldSpellcheckByDefault):

Canonical link: https://commits.webkit.org/61046@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
omo committed Oct 26, 2010
1 parent cf01852 commit 37249d1937ec3b7b563c8a4c71fc2b052cd28bd2
Showing 12 changed files with 121 additions and 19 deletions.
@@ -1,3 +1,13 @@
2010-10-22 MORITA Hajime <morrita@google.com>

Reviewed by Tony Chang.

spellcheck='' should be the same as spellcheck="true"
https://bugs.webkit.org/show_bug.cgi?id=25539

* editing/spelling/spellcheck-attribute-expected.txt:
* editing/spelling/spellcheck-attribute.html:

2010-10-25 Simon Fraser <simon.fraser@apple.com>

Reviewed by Dan Bernstein.
@@ -3,7 +3,13 @@ This tests if the "spellcheck" attribute is implemented as written in its specif
PASS:test1_1
PASS:test1_2
PASS:test1_3
PASS:test1_4
PASS:test1_5
PASS:test1_6
PASS:test2_1
PASS:test2_2
PASS:test2_3
PASS:test2_4
PASS:test2_5
PASS:test2_6

@@ -10,11 +10,17 @@
<label>1.1.</label><input id="test1_1" type="text"></input><br/>
<label>1.2.</label><input id="test1_2" type="text" spellcheck="true"></input><br/>
<label>1.3.</label><input id="test1_3" type="text" spellcheck="false"></input><br/>
<label>1.4.</label><input id="test1_4" type="text" spellcheck="InvalidValue"></input><br/>
<label>1.5.</label><input id="test1_5" type="text" spellcheck></input><br/>
<label>1.6.</label><input id="test1_6" type="text"></input><br/>
</div>
<div spellcheck="false">
<label>2.1.</label><input id="test2_1" type="text"></input><br/>
<label>2.2.</label><input id="test2_2" type="text" spellcheck="true"></input><br/>
<label>2.3.</label><input id="test2_3" type="text" spellcheck="false"></input><br/>
<label>2.4.</label><input id="test2_4" type="text" spellcheck="InvalidValue"></input><br/>
<label>2.5.</label><input id="test2_5" type="text" spellcheck></input><br/>
<label>2.6.</label><input id="test2_6" type="text"></input><br/>
</div>
</div>
<pre id="console"></pre>
@@ -37,9 +43,15 @@
testTypingInvalidWord('test1_1', true);
testTypingInvalidWord('test1_2', true);
testTypingInvalidWord('test1_3', false);
testTypingInvalidWord('test1_4', true);
testTypingInvalidWord('test1_5', true);
testTypingInvalidWord('test1_6', true);
testTypingInvalidWord('test2_1', false);
testTypingInvalidWord('test2_2', true);
testTypingInvalidWord('test2_3', false);
testTypingInvalidWord('test2_4', false);
testTypingInvalidWord('test2_5', true);
testTypingInvalidWord('test2_6', false);

if (window.layoutTestController) {
layoutTestController.dumpAsText();
@@ -1,3 +1,27 @@
2010-10-24 MORITA Hajime <morrita@google.com>

Reviewed by Tony Chang.

spellcheck='' should be the same as spellcheck="true"
https://bugs.webkit.org/show_bug.cgi?id=25539

- Added a check for empty string and missing attribute.
- Extracted the check to Element::spellCheckingEnabled()
- Introduced SpellcheckAttributeState enum to represent the
states for spellcheck attributes.

* dom/Element.cpp:
(WebCore::Element::spellcheckAttributeState): Added.
(WebCore::Element::isSpellCheckingEnabled): Added.
* dom/Element.h:
* editing/Editor.cpp:
(WebCore::markMisspellingsOrBadGrammar):
(WebCore::Editor::isSpellCheckingEnabledInFocusedNode): Renamed, partly extracted to Element::isSpellCheckingEnabled()
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
* editing/Editor.h:
* platform/ContextMenu.cpp:
(WebCore::ContextMenu::populate):

2010-10-25 Kent Tamura <tkent@chromium.org>

Reviewed by Darin Adler.
@@ -1708,4 +1708,37 @@ void Element::webkitRequestFullScreen(unsigned short flags)
}
#endif

SpellcheckAttributeState Element::spellcheckAttributeState() const
{
if (!hasAttribute(HTMLNames::spellcheckAttr))
return SpellcheckAttributeDefault;

const AtomicString& value = getAttribute(HTMLNames::spellcheckAttr);
if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, ""))
return SpellcheckAttributeTrue;
if (equalIgnoringCase(value, "false"))
return SpellcheckAttributeFalse;

return SpellcheckAttributeDefault;
}

bool Element::isSpellCheckingEnabled() const
{
const Element* element = this;
while (element) {
switch (element->spellcheckAttributeState()) {
case SpellcheckAttributeTrue:
return true;
case SpellcheckAttributeFalse:
return false;
case SpellcheckAttributeDefault:
break;
}

element = element->parentElement();
}

return true;
}

} // namespace WebCore
@@ -40,6 +40,12 @@ class DOMTokenList;
class ElementRareData;
class IntSize;

enum SpellcheckAttributeState {
SpellcheckAttributeTrue,
SpellcheckAttributeFalse,
SpellcheckAttributeDefault
};

class Element : public ContainerNode {
public:
static PassRefPtr<Element> create(const QualifiedName&, Document*);
@@ -320,6 +326,8 @@ class Element : public ContainerNode {
void webkitRequestFullScreen(unsigned short flags);
#endif

bool isSpellCheckingEnabled() const;

protected:
Element(const QualifiedName& tagName, Document* document, ConstructionType type)
: ContainerNode(document, type)
@@ -375,7 +383,9 @@ class Element : public ContainerNode {

ElementRareData* rareData() const;
ElementRareData* ensureRareData();


SpellcheckAttributeState spellcheckAttributeState() const;

private:
mutable RefPtr<NamedNodeMap> m_attributeMap;
};
@@ -2524,7 +2524,7 @@ static void markMisspellingsOrBadGrammar(Editor* editor, const VisibleSelection&
if (!editableNode || !editableNode->isContentEditable())
return;

if (!editor->spellCheckingEnabledInFocusedNode())
if (!editor->isSpellCheckingEnabledInFocusedNode())
return;

// Get the spell checker if it is available
@@ -2543,22 +2543,15 @@ static void markMisspellingsOrBadGrammar(Editor* editor, const VisibleSelection&
}
}

bool Editor::spellCheckingEnabledInFocusedNode() const
bool Editor::isSpellCheckingEnabledInFocusedNode() 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();
while (node) {
if (node->isElementNode()) {
const WTF::AtomicString& value = static_cast<const Element*>(node)->getAttribute(spellcheckAttr);
if (equalIgnoringCase(value, "true"))
return true;
if (equalIgnoringCase(value, "false"))
return false;
}
node = node->parent();
}
return true;
const Element* focusedElement = node->isElementNode() ? toElement(node) : node->parentElement();
if (!focusedElement)
return false;
return focusedElement->isSpellCheckingEnabled();
}

void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange)
@@ -2603,7 +2596,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
if (!editableNode || !editableNode->isContentEditable())
return;

if (!spellCheckingEnabledInFocusedNode())
if (!isSpellCheckingEnabledInFocusedNode())
return;

// Expand the range to encompass entire paragraphs, since text checking needs that much context.
@@ -207,7 +207,7 @@ class Editor {
Vector<String> guessesForMisspelledSelection();
Vector<String> guessesForUngrammaticalSelection();
Vector<String> guessesForMisspelledOrUngrammaticalSelection(bool& misspelled, bool& ungrammatical);
bool spellCheckingEnabledInFocusedNode() const;
bool isSpellCheckingEnabledInFocusedNode() const;
void markMisspellingsAfterTypingToPosition(const VisiblePosition&);
void markMisspellings(const VisibleSelection&, RefPtr<Range>& firstMisspellingRange);
void markBadGrammar(const VisibleSelection&);
@@ -428,7 +428,7 @@ void ContextMenu::populate()
} else { // Make an editing context menu
SelectionController* selection = frame->selection();
bool inPasswordField = selection->isInPasswordField();
bool spellCheckingEnabled = frame->editor()->spellCheckingEnabledInFocusedNode();
bool spellCheckingEnabled = frame->editor()->isSpellCheckingEnabledInFocusedNode();

if (!inPasswordField && spellCheckingEnabled) {
// Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range
@@ -1,3 +1,17 @@
2010-10-25 MORITA Hajime <morrita@google.com>

Reviewed by Tony Chang.

spellcheck='' should be the same as spellcheck="true"
https://bugs.webkit.org/show_bug.cgi?id=25539

Followed API rename in WebCore.

* src/ContextMenuClientImpl.cpp:
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::shouldSpellcheckByDefault):

2010-10-25 Satish Sampath <satish@chromium.org>

Unreviewed, fix for a build break caused by my earlier patch.
@@ -241,7 +241,7 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {
data.isSpellCheckingEnabled = true;
// Spellchecking might be enabled for the field, but could be disabled on the node.
if (m_webView->focusedWebCoreFrame()->editor()->spellCheckingEnabledInFocusedNode())
if (m_webView->focusedWebCoreFrame()->editor()->isSpellCheckingEnabledInFocusedNode())
data.misspelledWord = selectMisspelledWord(defaultMenu, selectedFrame);
}
}
@@ -124,7 +124,7 @@ bool EditorClientImpl::shouldSpellcheckByDefault()
const Editor* editor = frame->editor();
if (!editor)
return false;
if (editor->spellCheckingEnabledInFocusedNode())
if (editor->isSpellCheckingEnabledInFocusedNode())
return true;
const Document* document = frame->document();
if (!document)

0 comments on commit 37249d1

Please sign in to comment.