WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-73511-20111206180921.patch (text/plain), 12.34 KB, created by
Shinya Kawanaka
on 2011-12-06 01:09:22 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Shinya Kawanaka
Created:
2011-12-06 01:09:22 PST
Size:
12.34 KB
patch
obsolete
>Subversion Revision: 102096 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f28cec1850ea8184c82db0f115688d8ee6b7dd75..1f3703e37b80fca2de8d52b70a1de33379c56cd5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,29 @@ >+2011-12-06 Shinya Kawanaka <shinyak@google.com> >+ >+ Internals should have a method to reutrn the max sequence number of spellcheck reqeust. >+ https://bugs.webkit.org/show_bug.cgi?id=73511 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Internal state of SpellChecker should be able to be exposed for testing SpellChecker. >+ This patch will enable us to know asynchronous spellcheck has finished or not. >+ >+ Test: editing/spelling/spellcheck-sequencenum.html >+ >+ * editing/SpellChecker.cpp: >+ (WebCore::SpellChecker::SpellChecker): >+ (WebCore::SpellChecker::createRequest): >+ (WebCore::SpellChecker::didCheck): >+ * editing/SpellChecker.h: >+ (WebCore::SpellChecker::lastRequestSequence): >+ Interface to take SpellCheck sequence numbers. >+ (WebCore::SpellChecker::lastProcessedSequence): ditto. >+ * testing/Internals.cpp: >+ (WebCore::Internals::lastSpellCheckRequestSequence): ditto for Internals. >+ (WebCore::Internals::lastSpellCheckProcessedSequence): ditto. >+ * testing/Internals.h: >+ * testing/Internals.idl: >+ > 2011-12-05 Noel Gordon <noel.gordon@gmail.com> > > [GTK] GIF image test crashes on 32- and 64-bit Release >diff --git a/Source/WebCore/editing/SpellChecker.cpp b/Source/WebCore/editing/SpellChecker.cpp >index 8ff5742174226b4f22079ba31079534e1b6a14f4..aac69a029bda865fca14967ae14238182e9a184f 100644 >--- a/Source/WebCore/editing/SpellChecker.cpp >+++ b/Source/WebCore/editing/SpellChecker.cpp >@@ -72,7 +72,8 @@ private: > > SpellChecker::SpellChecker(Frame* frame) > : m_frame(frame) >- , m_lastRequestedSequence(0) >+ , m_lastRequestSequence(0) >+ , m_lastProcessedSequence(0) > , m_timerToProcessQueuedRequest(this, &SpellChecker::timerFiredToProcessQueuedRequest) > { > } >@@ -97,7 +98,7 @@ PassRefPtr<SpellChecker::SpellCheckRequest> SpellChecker::createRequest(TextChec > if (!text.length()) > return PassRefPtr<SpellCheckRequest>(); > >- return adoptRef(new SpellCheckRequest(++m_lastRequestedSequence, range, text, mask)); >+ return adoptRef(new SpellCheckRequest(++m_lastRequestSequence, range, text, mask)); > } > > void SpellChecker::timerFiredToProcessQueuedRequest(Timer<SpellChecker>*) >@@ -198,7 +199,6 @@ static DocumentMarker::MarkerType toMarkerType(TextCheckingType type) > void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& results) > { > ASSERT(m_processingRequest); >- > ASSERT(m_processingRequest->sequence() == sequence); > if (m_processingRequest->sequence() != sequence) { > m_requestQueue.clear(); >@@ -234,6 +234,9 @@ void SpellChecker::didCheck(int sequence, const Vector<TextCheckingResult>& resu > startOffset = results[i].location; > } > >+ if (m_lastProcessedSequence < sequence) >+ m_lastProcessedSequence = sequence; >+ > m_processingRequest.clear(); > if (!m_requestQueue.isEmpty()) > m_timerToProcessQueuedRequest.startOneShot(0); >diff --git a/Source/WebCore/editing/SpellChecker.h b/Source/WebCore/editing/SpellChecker.h >index 702f369d5657aebc459b5113f6e216a5dc28f1ff..b45e4bcfddcf6908d9c61a58a7b94a4a0f7f06d4 100644 >--- a/Source/WebCore/editing/SpellChecker.h >+++ b/Source/WebCore/editing/SpellChecker.h >@@ -53,6 +53,16 @@ public: > void requestCheckingFor(TextCheckingTypeMask, PassRefPtr<Range>); > void didCheck(int sequence, const Vector<TextCheckingResult>&); > >+ int lastRequestSequence() const >+ { >+ return m_lastRequestSequence; >+ } >+ >+ int lastProcessedSequence() const >+ { >+ return m_lastProcessedSequence; >+ } >+ > private: > class SpellCheckRequest; > typedef Deque<RefPtr<SpellCheckRequest> > RequestQueue; >@@ -65,7 +75,8 @@ private: > void enqueueRequest(PassRefPtr<SpellCheckRequest>); > > Frame* m_frame; >- int m_lastRequestedSequence; >+ int m_lastRequestSequence; >+ int m_lastProcessedSequence; > > Timer<SpellChecker> m_timerToProcessQueuedRequest; > >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index ae97243d02f7ccdd6c1097fcbf826da5d6d3d585..a9e79b030eed44ef3376c107c928cc3e922f4f61 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -48,6 +48,7 @@ > #include "Settings.h" > #include "ShadowContentElement.h" > #include "ShadowRoot.h" >+#include "SpellChecker.h" > #include "TextIterator.h" > > #if ENABLE(GESTURE_EVENTS) >@@ -618,4 +619,26 @@ bool Internals::unifiedTextCheckingEnabled(Document* document, ExceptionCode& ec > return document->frame()->settings()->unifiedTextCheckerEnabled(); > } > >+int Internals::lastSpellCheckRequestSequence(Document* document, ExceptionCode& ec) >+{ >+ if (!document || !document->frame() || !document->frame()->editor() || !document->frame()->editor()->spellChecker()) { >+ ec = INVALID_ACCESS_ERR; >+ return -1; >+ } >+ >+ SpellChecker* checker = document->frame()->editor()->spellChecker(); >+ return checker->lastRequestSequence(); >+} >+ >+int Internals::lastSpellCheckProcessedSequence(Document* document, ExceptionCode& ec) >+{ >+ if (!document || !document->frame() || !document->frame()->editor() || !document->frame()->editor()->spellChecker()) { >+ ec = INVALID_ACCESS_ERR; >+ return -1; >+ } >+ >+ SpellChecker* checker = document->frame()->editor()->spellChecker(); >+ return checker->lastProcessedSequence(); >+} >+ > } >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index a68fe9423269706f00103af20097855f6449521d..14d9dfdf3b1d8d4a417fd2ffe8b3a5753b48c732 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -110,6 +110,9 @@ public: > void setUnifiedTextCheckingEnabled(Document*, bool, ExceptionCode&); > bool unifiedTextCheckingEnabled(Document*, ExceptionCode&); > >+ int lastSpellCheckRequestSequence(Document*, ExceptionCode&); >+ int lastSpellCheckProcessedSequence(Document*, ExceptionCode&); >+ > static const char* internalsId; > > private: >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index 889cda2899088a05eb1338453c26d3ca1c42a840..d622260430a7169c4c6a351e60619050f692a231 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -81,6 +81,9 @@ module window { > void setShouldLayoutFixedElementsRelativeToFrame(in Document document, in boolean enabled) raises(DOMException); > void setUnifiedTextCheckingEnabled(in Document document, in boolean enabled) raises (DOMException); > boolean unifiedTextCheckingEnabled(in Document document) raises (DOMException); >+ >+ long lastSpellCheckRequestSequence(in Document document) raises (DOMException); >+ long lastSpellCheckProcessedSequence(in Document document) raises (DOMException); > }; > } > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 196ed4ecaaa44a961b0162c3cc70b2502894dae1..99ce97f29156bc8ee873c3fc2a4856ad452f4d8f 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2011-12-06 Shinya Kawanaka <shinyak@google.com> >+ >+ Internals should have a method to reutrn the max sequence number of spellcheck reqeust. >+ https://bugs.webkit.org/show_bug.cgi?id=73511 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests to check internals.lastSpellCheckRequestSequence and internals.lastSpellCheckProcessedSequence. >+ >+ * editing/spelling/spellcheck-sequencenum-expected.txt: Added. >+ * editing/spelling/spellcheck-sequencenum.html: Added. >+ > 2011-12-05 Florin Malita <fmalita@google.com> > > Heap-buffer-overflow in WebCore::HTMLTreeBuilder::processEndTag >diff --git a/LayoutTests/editing/spelling/spellcheck-sequencenum-expected.txt b/LayoutTests/editing/spelling/spellcheck-sequencenum-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..5f0a3a817199dd0bb9e9803bc71dfaa129559903 >--- /dev/null >+++ b/LayoutTests/editing/spelling/spellcheck-sequencenum-expected.txt >@@ -0,0 +1,12 @@ >+For Bug 73511: Internals should have a method to return the max sequence number of spellcheck request. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+PASS SpellCheck sequence seems work correctly. >+PASS SpellCheck sequence seems work correctly. >+PASS SpellCheck sequence seems work correctly. >+ >diff --git a/LayoutTests/editing/spelling/spellcheck-sequencenum.html b/LayoutTests/editing/spelling/spellcheck-sequencenum.html >new file mode 100644 >index 0000000000000000000000000000000000000000..44468c73263e0fa6f86b21c01ecc8d30eb59ef95 >--- /dev/null >+++ b/LayoutTests/editing/spelling/spellcheck-sequencenum.html >@@ -0,0 +1,136 @@ >+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> >+<html> >+<head> >+<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> >+description('For Bug 73511: Internals should have a method to return the max sequence number of spellcheck request.'); >+ >+if (window.layoutTestController) { >+ layoutTestController.waitUntilDone(); >+ layoutTestController.setAsynchronousSpellCheckingEnabled(true); >+} >+ >+var testRoot = document.createElement("div"); >+document.body.insertBefore(testRoot, document.body.firstChild); >+ >+var source = document.createElement("div"); >+source.innerHTML = "foo bar"; >+testRoot.appendChild(source); >+ >+function createInput(testRoot) { >+ var e = document.createElement('input'); >+ e.setAttribute("type", "text"); >+ testRoot.appendChild(e); >+ >+ return e; >+} >+ >+function createTextArea(testRoot) { >+ var e = document.createElement("textarea"); >+ testRoot.appendChild(e); >+ >+ return e; >+} >+ >+function createContentEditable(testRoot) { >+ var e = document.createElement("div"); >+ e.setAttribute("contentEditable", "true"); >+ testRoot.appendChild(e); >+ >+ return e; >+} >+ >+var destinations = [ >+ createInput(testRoot), >+ createTextArea(testRoot), >+ createContentEditable(testRoot), >+]; >+ >+var sel = window.getSelection(); >+ >+var tests = []; >+for (var i = 0; i < destinations.length; ++i) { >+ var t = function(i) { >+ return function() { >+ if (!window.internals) >+ return; >+ var sequence = internals.lastSpellCheckRequestSequence(document); >+ var processed = internals.lastSpellCheckProcessedSequence(document); >+ copyAndPaste(source, destinations[i]); >+ verify(sequence, processed); >+ } >+ }(i); >+ tests.push(t); >+} >+ >+function verifyIfAny() >+{ >+ var next = tests.shift(); >+ if (next) { >+ next(); >+ return; >+ } >+ >+ testRoot.style.display = "none"; >+ if (window.layoutTestController) { >+ layoutTestController.setAsynchronousSpellCheckingEnabled(false); >+ layoutTestController.notifyDone(); >+ } >+} >+ >+function copyAndPaste(source, dest) >+{ >+ sel.selectAllChildren(source); >+ document.execCommand("Copy"); >+ >+ if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement) { >+ dest.value = ""; >+ dest.focus(); >+ } else { >+ dest.innerHTML = ""; >+ sel.selectAllChildren(dest); >+ } >+ document.execCommand("Paste"); >+} >+ >+function verify(sequence, processed) >+{ >+ var nretry = 10; >+ var nsleep = 1; >+ function trial() { >+ var newSequence = internals.lastSpellCheckRequestSequence(document); >+ var newProcessed = internals.lastSpellCheckProcessedSequence(document); >+ >+ var verified = newSequence >= sequence && newProcessed >= processed && newSequence == newProcessed; >+ if (verified) { >+ testPassed("SpellCheck sequence seems work correctly."); >+ verifyIfAny(); >+ return; >+ } >+ >+ nretry--; >+ if (0 == nretry) { >+ testFailed("SpellCheck sequence didn't increase."); >+ verifyIfAny(); >+ return; >+ } >+ >+ nsleep *= 2; >+ window.setTimeout(trial, nsleep); >+ }; >+ trial(); >+} >+ >+verifyIfAny(); >+ >+var successfullyParsed = true; >+ >+</script> >+<script src="../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 73511
:
117333
|
117570
|
118005
|
118151
|
118155
|
118197