Title: [135764] branches/safari-536.28-branch

Diff

Modified: branches/safari-536.28-branch/LayoutTests/ChangeLog (135763 => 135764)


--- branches/safari-536.28-branch/LayoutTests/ChangeLog	2012-11-26 22:11:42 UTC (rev 135763)
+++ branches/safari-536.28-branch/LayoutTests/ChangeLog	2012-11-26 22:15:06 UTC (rev 135764)
@@ -1,5 +1,19 @@
 2012-11-26  Lucas Forschler  <[email protected]>
 
+        Merge r132924
+
+    2012-10-30  Dan Bernstein  <[email protected]>
+
+            <rdar://problem/12395187> REGRESSION (r121299): OS X Text Replacement forces cursor out of text fields
+            https://bugs.webkit.org/show_bug.cgi?id=100768
+
+            Reviewed by Anders Carlsson.
+
+            * platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt: Added.
+            * platform/mac/editing/spelling/autocorrection-in-textarea.html: Added.
+
+2012-11-26  Lucas Forschler  <[email protected]>
+
         Merge r132713
 
     2012-10-26  Anders Carlsson  <[email protected]> 

Copied: branches/safari-536.28-branch/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt (from rev 132924, trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt) (0 => 135764)


--- branches/safari-536.28-branch/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt	                        (rev 0)
+++ branches/safari-536.28-branch/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea-expected.txt	2012-11-26 22:15:06 UTC (rev 135764)
@@ -0,0 +1,3 @@
+0123456789
+
+PASS

Copied: branches/safari-536.28-branch/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea.html (from rev 132924, trunk/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea.html) (0 => 135764)


--- branches/safari-536.28-branch/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea.html	                        (rev 0)
+++ branches/safari-536.28-branch/LayoutTests/platform/mac/editing/spelling/autocorrection-in-textarea.html	2012-11-26 22:15:06 UTC (rev 135764)
@@ -0,0 +1,27 @@
+<div contenteditable>
+    0123456789
+</div>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    _onload_ = function() {
+        var textarea = document.getElementById("textarea");
+        textarea.focus();
+        var hasBeenBlurred = false;
+        textarea._onblur_ = function() {
+            hasBeenBlurred = true;
+        }
+
+        document.execCommand("InsertText", false, "te");
+        document.execCommand("InsertText", false, "h");
+        document.execCommand("InsertText", false, " ");
+
+        document.execCommand("InsertText", false, "test result is");
+
+        var result = textarea.value === "the test result is" ? "PASS" : "FAIL";
+        document.getElementById("result").appendChild(document.createTextNode(result));
+    }
+</script>
+<textarea id="textarea"></textarea>
+<p id="result"></p>

Modified: branches/safari-536.28-branch/Source/WebCore/ChangeLog (135763 => 135764)


--- branches/safari-536.28-branch/Source/WebCore/ChangeLog	2012-11-26 22:11:42 UTC (rev 135763)
+++ branches/safari-536.28-branch/Source/WebCore/ChangeLog	2012-11-26 22:15:06 UTC (rev 135764)
@@ -1,3 +1,28 @@
+2012-11-26  Lucas Forschler  <[email protected]>
+
+        Merge r132924
+
+    2012-10-30  Dan Bernstein  <[email protected]>
+
+            <rdar://problem/12395187> REGRESSION (r121299): OS X Text Replacement forces cursor out of text fields
+            https://bugs.webkit.org/show_bug.cgi?id=100768
+
+            Reviewed by Anders Carlsson.
+
+            r121299 introduced code to restore the paragraph range by saving its length and start offset
+            relative to the document. The latter was obtained by iterating over the range starting at
+            the beginning of the document and ending at the beginning of the paragraph range. However,
+            such a range could not be constructed if the paragraph range was contained in a shadow DOM,
+            since a range must have both its endpoints within the same shadow tree (or not in a shadow
+            tree).
+
+            Test: platform/mac/editing/spelling/autocorrection-in-textarea.html
+
+            * editing/Editor.cpp:
+            (WebCore::Editor::markAndReplaceFor): Changed paragraphStartIndex to be relative to the
+            root container of paragraphRange, using the same logic used by
+            checkForDifferentRootContainer() in Range.cpp.
+
 2012-11-18  Simon Fraser  <[email protected]>
 
         <rdar://problem/12726004> Chopin: Don't say there are dirty overlay scrollbars when they are clipped out (102609)

Modified: branches/safari-536.28-branch/Source/WebCore/WebCore.exp.in (135763 => 135764)


--- branches/safari-536.28-branch/Source/WebCore/WebCore.exp.in	2012-11-26 22:11:42 UTC (rev 135763)
+++ branches/safari-536.28-branch/Source/WebCore/WebCore.exp.in	2012-11-26 22:15:06 UTC (rev 135764)
@@ -283,7 +283,7 @@
 __ZN7WebCore12SpellChecker17didCheckSucceededEiRKN3WTF6VectorINS_18TextCheckingResultELm0EEE
 __ZN7WebCore12TextEncodingC1ERKN3WTF6StringE
 __ZN7WebCore12TextIterator11rangeLengthEPKNS_5RangeEb
-__ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_7ElementEiib
+__ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_13ContainerNodeEiib
 __ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_7ElementEPKNS_5RangeERmS6_
 __ZN7WebCore12TextIterator7advanceEv
 __ZN7WebCore12TextIterator8subrangeEPNS_5RangeEii

Modified: branches/safari-536.28-branch/Source/WebCore/editing/Editor.cpp (135763 => 135764)


--- branches/safari-536.28-branch/Source/WebCore/editing/Editor.cpp	2012-11-26 22:11:42 UTC (rev 135763)
+++ branches/safari-536.28-branch/Source/WebCore/editing/Editor.cpp	2012-11-26 22:15:06 UTC (rev 135764)
@@ -2110,11 +2110,15 @@
                 if (canEditRichly())
                     applyCommand(CreateLinkCommand::create(m_frame->document(), result->replacement));
             } else if (canEdit() && shouldInsertText(result->replacement, rangeToReplace.get(), EditorInsertActionTyped)) {
-                int paragraphStartIndex = TextIterator::rangeLength(Range::create(m_frame->document(), m_frame->document(), 0, paragraph.paragraphRange()->startContainer(), paragraph.paragraphRange()->startOffset()).get());
+                Node* root = paragraph.paragraphRange()->startContainer();
+                while (ContainerNode* parent = root->parentNode())
+                    root = parent;
+
+                int paragraphStartIndex = TextIterator::rangeLength(Range::create(m_frame->document(), root, 0, paragraph.paragraphRange()->startContainer(), paragraph.paragraphRange()->startOffset()).get());
                 int paragraphLength = TextIterator::rangeLength(paragraph.paragraphRange().get());
                 applyCommand(SpellingCorrectionCommand::create(rangeToReplace, result->replacement));
                 // Recalculate newParagraphRange, since SpellingCorrectionCommand modifies the DOM, such that the original paragraph range is no longer valid. Radar: 10305315 Bugzilla: 89526
-                RefPtr<Range> newParagraphRange = TextIterator::rangeFromLocationAndLength(m_frame->document()->documentElement(), paragraphStartIndex, paragraphLength+replacementLength-resultLength);
+                RefPtr<Range> newParagraphRange = TextIterator::rangeFromLocationAndLength(toContainerNode(root), paragraphStartIndex, paragraphLength + replacementLength - resultLength);
                 paragraph = TextCheckingParagraph(TextIterator::subrange(newParagraphRange.get(), resultLocation, replacementLength), newParagraphRange);
                 
                 if (AXObjectCache::accessibilityEnabled()) {

Modified: branches/safari-536.28-branch/Source/WebCore/editing/TextIterator.cpp (135763 => 135764)


--- branches/safari-536.28-branch/Source/WebCore/editing/TextIterator.cpp	2012-11-26 22:11:42 UTC (rev 135763)
+++ branches/safari-536.28-branch/Source/WebCore/editing/TextIterator.cpp	2012-11-26 22:15:06 UTC (rev 135764)
@@ -2402,7 +2402,7 @@
     return characterSubrange(entireRangeIterator, characterOffset, characterCount);
 }
 
-PassRefPtr<Range> TextIterator::rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, bool forSelectionPreservation)
+PassRefPtr<Range> TextIterator::rangeFromLocationAndLength(ContainerNode* scope, int rangeLocation, int rangeLength, bool forSelectionPreservation)
 {
     RefPtr<Range> resultRange = scope->document()->createRange();
 

Modified: branches/safari-536.28-branch/Source/WebCore/editing/TextIterator.h (135763 => 135764)


--- branches/safari-536.28-branch/Source/WebCore/editing/TextIterator.h	2012-11-26 22:11:42 UTC (rev 135763)
+++ branches/safari-536.28-branch/Source/WebCore/editing/TextIterator.h	2012-11-26 22:15:06 UTC (rev 135764)
@@ -100,7 +100,7 @@
     Node* node() const;
      
     static int rangeLength(const Range*, bool spacesForReplacedElements = false);
-    static PassRefPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, bool spacesForReplacedElements = false);
+    static PassRefPtr<Range> rangeFromLocationAndLength(ContainerNode* scope, int rangeLocation, int rangeLength, bool spacesForReplacedElements = false);
     static bool getLocationAndLengthFromRange(Element* scope, const Range*, size_t& location, size_t& length);
     static PassRefPtr<Range> subrange(Range* entireRange, int characterOffset, int characterCount);
     
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to