Commit e6e56a6f authored by morrita@google.com's avatar morrita@google.com
Browse files

.: Spell-checking doesn't recognize word boundaries on contests inserted by...

.: Spell-checking doesn't recognize word boundaries on contests inserted by execCommand('insertHTML')
https://bugs.webkit.org/show_bug.cgi?id=65902

Reviewed by Ryosuke Niwa.

Add export for window.internals object.

* Source/autotools/symbols.filter:

Source/WebCore: Spell-checking doesn't recognize word boundaries on contests inserted by execCommand('insertHTML')
https://bugs.webkit.org/show_bug.cgi?id=65902

Reviewed by Ryosuke Niwa.

markMisspellingsAndBadGrammar() was using markSpelling() and markBadGrammar().
But these are low-level API and caller should take care of word boundary.
This change replaced these call with overloaded version of markMisspellingsAndBadGrammar(),
which handles word boundary correctly.

Test: editing/spelling/spelling-insert-html.html

* WebCore.exp.in:
* editing/Editor.cpp:
(WebCore::Editor::markMisspellingsAndBadGrammar):
* testing/Internals.cpp:
(WebCore::Internals::markerCountOf): Added.
(WebCore::Internals::markedRangeAt): Added.
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2: Spell-checking against execCommand() inserted HTML doesn't care word boundary.
https://bugs.webkit.org/show_bug.cgi?id=65902

Reviewed by Ryosuke Niwa.

Add exports for window.internals object.

* win/WebKit2.def:
* win/WebKit2CFLite.def:

LayoutTests: Spell-checking doesn't recognize word boundaries on contests inserted by execCommand('insertHTML')
https://bugs.webkit.org/show_bug.cgi?id=65902

Reviewed by Ryosuke Niwa.

Existing expectation was wrong because of some markers on substrings of words.
With this fix, Editor now rejects such markers.

* editing/spelling/spelling-insert-html-expected.txt: Added.
* editing/spelling/spelling-insert-html.html: Added.
* platform/mac/editing/pasteboard/merge-after-delete-1-expected.png:
* platform/mac/editing/pasteboard/merge-after-delete-2-expected.png:
* platform/mac/editing/pasteboard/merge-after-delete-expected.png:
* platform/mac/editing/pasteboard/merge-end-blockquote-expected.png:
* platform/mac/editing/pasteboard/merge-end-list-expected.png:
* platform/mac/editing/pasteboard/merge-end-table-expected.png:
* platform/mac/editing/pasteboard/paste-text-008-expected.png:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@93392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8f951cd0
2011-08-19 MORITA Hajime <morrita@google.com>
Spell-checking doesn't recognize word boundaries on contests inserted by execCommand('insertHTML')
https://bugs.webkit.org/show_bug.cgi?id=65902
Reviewed by Ryosuke Niwa.
Add export for window.internals object.
* Source/autotools/symbols.filter:
2011-08-16 Andras Becsi <abecsi@webkit.org>
 
Reviewed by Csaba Osztrogonác.
......
2011-08-19 MORITA Hajime <morrita@google.com>
Spell-checking doesn't recognize word boundaries on contests inserted by execCommand('insertHTML')
https://bugs.webkit.org/show_bug.cgi?id=65902
Reviewed by Ryosuke Niwa.
Existing expectation was wrong because of some markers on substrings of words.
With this fix, Editor now rejects such markers.
* editing/spelling/spelling-insert-html-expected.txt: Added.
* editing/spelling/spelling-insert-html.html: Added.
* platform/mac/editing/pasteboard/merge-after-delete-1-expected.png:
* platform/mac/editing/pasteboard/merge-after-delete-2-expected.png:
* platform/mac/editing/pasteboard/merge-after-delete-expected.png:
* platform/mac/editing/pasteboard/merge-end-blockquote-expected.png:
* platform/mac/editing/pasteboard/merge-end-list-expected.png:
* platform/mac/editing/pasteboard/merge-end-table-expected.png:
* platform/mac/editing/pasteboard/paste-text-008-expected.png:
2011-08-19 Shinya Kawanaka <shinyak@google.com>
 
input[maxlength=0] should ignore text input.
The spellchecker shouldn't mark substrings of words after pasting.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS markedText is "zz"
PASS successfullyParsed is true
TEST COMPLETE
foo zz
food.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<pre id="description"></pre>
<pre id="console"></pre>
<div id="container">
<div id="destination" contentEditable>food.</div>
</div>
<script>
description("The spellchecker shouldn't mark substrings of words after pasting.");
var sel = window.getSelection();
var destination = document.getElementById("destination");
var destinationText = destination.firstChild;
sel.setBaseAndExtent(destinationText, 2, destinationText, 2);
document.execCommand("InsertHTML", false, "<div>o zz</div><div>fo</div>");
if (window.internals) {
// The destination node has multiple text nodes,
// so we need concatenate the marked text.
var texts = destination.childNodes;
var markedText = "";
for (var i = 0; i < texts.length; ++i) {
var marked = internals.markerRangeForNode(texts[i], 0);
if (marked)
markedText += marked.toString()
}
// The first "foo" isn't checked because it crosses the pasted and base html.
// See http://webkit.org/b/66450.
shouldBeEqualToString("markedText", "zz");
}
if (window.layoutTestController)
layoutTestController.dumpAsText();
var successfullyParsed = true;
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2011-08-19 MORITA Hajime <morrita@google.com>
Spell-checking doesn't recognize word boundaries on contests inserted by execCommand('insertHTML')
https://bugs.webkit.org/show_bug.cgi?id=65902
Reviewed by Ryosuke Niwa.
markMisspellingsAndBadGrammar() was using markSpelling() and markBadGrammar().
But these are low-level API and caller should take care of word boundary.
This change replaced these call with overloaded version of markMisspellingsAndBadGrammar(),
which handles word boundary correctly.
Test: editing/spelling/spelling-insert-html.html
* WebCore.exp.in:
* editing/Editor.cpp:
(WebCore::Editor::markMisspellingsAndBadGrammar):
* testing/Internals.cpp:
(WebCore::Internals::markerCountOf): Added.
(WebCore::Internals::markedRangeAt): Added.
* testing/Internals.h:
* testing/Internals.idl:
2011-08-19 Nayan Kumar K <nayankk@motorola.com>
 
Run-time error fix in WebKit-GTK with video support disabled.
......@@ -597,6 +597,7 @@ __ZN7WebCore23getHostnamesWithCookiesERN3WTF7HashSetINS0_6StringENS0_10StringHas
__ZN7WebCore23overrideDefaultLanguageERKN3WTF6StringE
__ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv
__ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
__ZN7WebCore24DocumentMarkerController10markersForEPNS_4NodeE
__ZN7WebCore24DocumentMarkerController13removeMarkersENS_14DocumentMarker11MarkerTypesE
__ZN7WebCore24DocumentMarkerController23renderedRectsForMarkersENS_14DocumentMarker10MarkerTypeE
__ZN7WebCore24contextMenuItemTagItalicEv
......
......@@ -1941,16 +1941,7 @@ void Editor::clearMisspellingsAndBadGrammar(const VisibleSelection &movingSelect
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);
markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled(), movingSelection);
}
void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping, bool doReplacement)
......
......@@ -29,12 +29,14 @@
#include "CachedResourceLoader.h"
#include "ClientRect.h"
#include "Document.h"
#include "DocumentMarkerController.h"
#include "Element.h"
#include "ExceptionCode.h"
#include "InspectorController.h"
#include "MemoryCache.h"
#include "NodeRenderingContext.h"
#include "Page.h"
#include "Range.h"
#include "RenderObject.h"
#include "RenderTreeAsText.h"
#include "Settings.h"
......@@ -183,6 +185,29 @@ PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionCode& e
return ClientRect::create(renderer->absoluteBoundingBoxRect());
}
unsigned Internals::markerCountForNode(Node* node, ExceptionCode& ec)
{
if (!node) {
ec = INVALID_ACCESS_ERR;
return 0;
}
return node->document()->markers()->markersFor(node).size();
}
PassRefPtr<Range> Internals::markerRangeForNode(Node* node, unsigned index, ExceptionCode& ec)
{
if (!node) {
ec = INVALID_ACCESS_ERR;
return 0;
}
Vector<DocumentMarker*> markers = node->document()->markers()->markersFor(node);
if (markers.size() <= index)
return 0;
return Range::create(node->document(), node, markers[index]->startOffset(), node, markers[index]->endOffset());
}
void Internals::setForceCompositingMode(Document* document, bool enabled, ExceptionCode& ec)
{
if (!document || !document->settings()) {
......@@ -233,4 +258,5 @@ void Internals::reset(Document* document)
document->settings()->setPasswordEchoDurationInSeconds(passwordEchoEnabledBackup);
}
}
......@@ -38,6 +38,7 @@ class ClientRect;
class Document;
class Element;
class Node;
class Range;
class Internals : public RefCounted<Internals> {
public:
......@@ -67,6 +68,9 @@ public:
PassRefPtr<ClientRect> boundingBox(Element*, ExceptionCode&);
unsigned markerCountForNode(Node*, ExceptionCode&);
PassRefPtr<Range> markerRangeForNode(Node*, unsigned, ExceptionCode&);
void setForceCompositingMode(Document*, bool enabled, ExceptionCode&);
void setPasswordEchoEnabled(Document*, bool enabled, ExceptionCode&);
......
......@@ -42,6 +42,8 @@ module window {
void setInspectorResourcesDataSizeLimits(in Document document, in long maximumResourcesContentSize, in long maximumSingleResourceContentSize) raises(DOMException);
ClientRect boundingBox(in Element element) raises(DOMException);
unsigned long markerCountForNode(in Node node) raises(DOMException);
Range markerRangeForNode(in Node node, in unsigned long index) raises(DOMException);
void setForceCompositingMode(in Document document, in boolean enabled) raises(DOMException);
......
2011-08-19 MORITA Hajime <morrita@google.com>
Spell-checking against execCommand() inserted HTML doesn't care word boundary.
https://bugs.webkit.org/show_bug.cgi?id=65902
Reviewed by Ryosuke Niwa.
Add exports for window.internals object.
* win/WebKit2.def:
* win/WebKit2CFLite.def:
2011-08-18 Beth Dakin <bdakin@apple.com>
Reviewed by Sam Weinig.
......
......@@ -137,6 +137,7 @@ EXPORTS
; Re-exports from WebCore for test harnesses
??0NodeRenderingContext@WebCore@@QAE@PAVNode@1@@Z
??1NodeRenderingContext@WebCore@@QAE@XZ
??1Range@WebCore@@QAE@XZ
?toNode@WebCore@@YAPAVNode@1@VJSValue@JSC@@@Z
??0ClientRect@WebCore@@AAE@ABVIntRect@1@@Z
??0ClientRect@WebCore@@AAE@XZ
......@@ -146,6 +147,7 @@ EXPORTS
?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBD@Z
?addSlowCase@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PAVStringImpl@2@@Z
?cacheDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PAV23@PBUClassInfo@3@@Z
?create@Range@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@V?$PassRefPtr@VDocument@WebCore@@@4@V?$PassRefPtr@VNode@WebCore@@@4@H1H@Z
?create@ShadowContentElement@WebCore@@SA?AV?$PassRefPtr@VShadowContentElement@WebCore@@@WTF@@PAVDocument@2@@Z
?createWrapper@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVNode@1@@Z
?ensureShadowRoot@Element@WebCore@@QAEPAVShadowRoot@2@XZ
......@@ -154,6 +156,7 @@ EXPORTS
?getElementById@TreeScope@WebCore@@QBEPAVElement@2@ABVAtomicString@WTF@@@Z
?isPreloaded@CachedResourceLoader@WebCore@@QBE_NABVString@WTF@@@Z
?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@UStringHash@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z
?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@@WTF@@PAVNode@2@@Z
?memoryCache@WebCore@@YAPAVMemoryCache@1@XZ
?page@Document@WebCore@@QBEPAVPage@2@XZ
?removeShadowRoot@Element@WebCore@@QAEXXZ
......@@ -166,5 +169,6 @@ EXPORTS
?toElement@WebCore@@YAPAVElement@1@VJSValue@JSC@@@Z
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVClientRect@1@@Z
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVNode@1@@Z
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVRange@1@@Z
?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
?virtualFunctionToPreventWeakVtable@JSDOMWrapper@WebCore@@MAEXXZ
......@@ -134,10 +134,12 @@ EXPORTS
??0String@WTF@@QAE@PBD@Z
??0String@WTF@@QAE@PB_W@Z
??1NodeRenderingContext@WebCore@@QAE@XZ
??1Range@WebCore@@QAE@XZ
?absoluteBoundingBoxRect@RenderObject@WebCore@@QAE?AVIntRect@2@_N@Z
?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBD@Z
?addSlowCase@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PAVStringImpl@2@@Z
?cacheDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PAV23@PBUClassInfo@3@@Z
?create@Range@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@V?$PassRefPtr@VDocument@WebCore@@@4@V?$PassRefPtr@VNode@WebCore@@@4@H1H@Z
?create@ShadowContentElement@WebCore@@SA?AV?$PassRefPtr@VShadowContentElement@WebCore@@@WTF@@PAVDocument@2@@Z
?createWrapper@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVNode@1@@Z
?ensureShadowRoot@Element@WebCore@@QAEPAVShadowRoot@2@XZ
......@@ -148,6 +150,7 @@ EXPORTS
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVClientRect@1@@Z
?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
?jsStringSlowCase@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@AAV?$HashMap@PAVStringImpl@WTF@@V?$Weak@VJSString@JSC@@@JSC@@UStringHash@2@U?$HashTraits@PAVStringImpl@WTF@@@2@U?$HashTraits@V?$Weak@VJSString@JSC@@@JSC@@@2@@WTF@@PAVStringImpl@6@@Z
?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@@WTF@@PAVNode@2@@Z
?memoryCache@WebCore@@YAPAVMemoryCache@1@XZ
?page@Document@WebCore@@QBEPAVPage@2@XZ
?removeShadowRoot@Element@WebCore@@QAEXXZ
......@@ -159,5 +162,6 @@ EXPORTS
?toDocument@WebCore@@YAPAVDocument@1@VJSValue@JSC@@@Z
?toElement@WebCore@@YAPAVElement@1@VJSValue@JSC@@@Z
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVNode@1@@Z
?toJS@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@PAVRange@1@@Z
?toNode@WebCore@@YAPAVNode@1@VJSValue@JSC@@@Z
?virtualFunctionToPreventWeakVtable@JSDOMWrapper@WebCore@@MAEXXZ
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment