LayoutTests:
authorlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 23:47:09 +0000 (23:47 +0000)
committerlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 23:47:09 +0000 (23:47 +0000)
        Reviewed by justin

        * editing/execCommand/format-block-with-trailing-br-expected.checksum: Added.
        * editing/execCommand/format-block-with-trailing-br-expected.png: Added.
        * editing/execCommand/format-block-with-trailing-br-expected.txt: Added.
        * editing/execCommand/format-block-with-trailing-br.html: Added.

WebCore:

        Reviewed by justin

        * editing/VisiblePosition.cpp: Removed is[Not]EqualIgnoringAffinity and made operator== use the logic that ignores affinity.
        * editing/VisiblePosition.h: Ditto.
        (WebCore::operator==):
        * editing/visible_units.cpp:
        (WebCore::isStartOfParagraph): Changed to compare VisiblePositions using ==.
        (WebCore::isEndOfParagraph): Ditto.
        (WebCore::isStartOfBlock): Ditto.
        (WebCore::isEndOfBlock): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15117 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-trailing-br.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/VisiblePosition.cpp
WebCore/editing/VisiblePosition.h
WebCore/editing/visible_units.cpp

index b9eaa8f7202111250557f4b34a9f45b08eeadfd9..45b14d1dfc9b7a2e6ae3580d514b87a88fdf3b90 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-30  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        * editing/execCommand/format-block-with-trailing-br-expected.checksum: Added.
+        * editing/execCommand/format-block-with-trailing-br-expected.png: Added.
+        * editing/execCommand/format-block-with-trailing-br-expected.txt: Added.
+        * editing/execCommand/format-block-with-trailing-br.html: Added.
+
 2006-06-30  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
diff --git a/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.checksum b/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.checksum
new file mode 100644 (file)
index 0000000..c9c06ab
--- /dev/null
@@ -0,0 +1 @@
+4152064e9e88f5f08799c3d9958a7651
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.png b/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.png
new file mode 100644 (file)
index 0000000..2de87db
Binary files /dev/null and b/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.png differ
diff --git a/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.txt b/LayoutTests/editing/execCommand/format-block-with-trailing-br-expected.txt
new file mode 100644 (file)
index 0000000..f4f568d
--- /dev/null
@@ -0,0 +1,16 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of PRE > DIV > BODY > HTML > #document to 0 of PRE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x43 [border: (1px solid #000000)]
+        RenderBlock {PRE} at (1,14) size 782x15
+          RenderText {#text} at (0,0) size 24x15
+            text run at (0,0) width 24: "Foo"
+caret: position 0 of child 0 {#text} of child 1 {PRE} of child 0 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/format-block-with-trailing-br.html b/LayoutTests/editing/execCommand/format-block-with-trailing-br.html
new file mode 100644 (file)
index 0000000..aa97267
--- /dev/null
@@ -0,0 +1,11 @@
+<div style="border:1px solid black" contenteditable="true">
+<div id="item1">Foo<br></div>
+</div>
+
+<script>
+var s = window.getSelection();
+var p1 = document.getElementById("item1");
+s.setPosition(p1, 0);
+document.execCommand("FormatBlock", false, "pre");
+
+</script>
\ No newline at end of file
index d54b99fe314992514c3e12ad0ceafe8a0ed8b3c5..90b851e7eb9e826f7e8aa69076b3ff1ae59e1e15 100644 (file)
@@ -1,3 +1,16 @@
+2006-06-30  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        * editing/VisiblePosition.cpp: Removed is[Not]EqualIgnoringAffinity and made operator== use the logic that ignores affinity.
+        * editing/VisiblePosition.h: Ditto.
+        (WebCore::operator==):
+        * editing/visible_units.cpp:
+        (WebCore::isStartOfParagraph): Changed to compare VisiblePositions using ==.
+        (WebCore::isEndOfParagraph): Ditto.
+        (WebCore::isStartOfBlock): Ditto.
+        (WebCore::isEndOfBlock): Ditto.
+
 === Safari-521.14 ===
 
 2006-06-30  Justin Garcia  <justin.garcia@apple.com>
index 4acd7b6631c7588f09afe4cb948b8967458ad6c3..4f2cb586370e1746fe981f8af62640aa0f2aac70 100644 (file)
@@ -256,26 +256,6 @@ UChar VisiblePosition::characterAfter() const
     return textNode->data()[offset];
 }
 
-bool isEqualIgnoringAffinity(const VisiblePosition &a, const VisiblePosition &b)
-{
-    bool result = a.deepEquivalent() == b.deepEquivalent() || 
-                  // FIXME (8622): This is a slow but temporary workaround. 
-                  a.deepEquivalent().downstream() == b.deepEquivalent().downstream();
-    if (result) {
-        // We want to catch cases where positions are equal, but affinities are not, since
-        // this is very likely a bug, given the places where this call is used. The difference
-        // is very likely due to code that set the affinity on a VisiblePosition "by hand" and 
-        // did so incorrectly.
-        ASSERT(a.affinity() == b.affinity());
-    }
-    return result;
-}
-
-bool isNotEqualIgnoringAffinity(const VisiblePosition &a, const VisiblePosition &b)
-{
-    return !isEqualIgnoringAffinity(a, b);
-}
-
 void VisiblePosition::debugPosition(const char *msg) const
 {
     if (isNull())
index 15f3feb58426f159095922530a7dda1cf445f3ea..ce0b75c5ef5e419bd986f1fe0c788bec5adde1ce 100644 (file)
@@ -93,7 +93,9 @@ private:
 
 inline bool operator==(const VisiblePosition &a, const VisiblePosition &b)
 {
-    return a.deepEquivalent() == b.deepEquivalent() && a.affinity() == b.affinity();
+    return a.deepEquivalent() == b.deepEquivalent() || 
+           // FIXME (8622): This is a slow but temporary workaround. 
+           a.deepEquivalent().downstream() == b.deepEquivalent().downstream();
 }
  
 inline bool operator!=(const VisiblePosition &a, const VisiblePosition &b)
@@ -101,9 +103,6 @@ inline bool operator!=(const VisiblePosition &a, const VisiblePosition &b)
     return !(a == b);
 }
 
-bool isEqualIgnoringAffinity(const VisiblePosition&, const VisiblePosition&);
-bool isNotEqualIgnoringAffinity(const VisiblePosition&, const VisiblePosition&);
-
 PassRefPtr<Range> makeRange(const VisiblePosition &, const VisiblePosition &);
 bool setStart(Range*, const VisiblePosition&);
 bool setEnd(Range*, const VisiblePosition&);
index 669ea0bb0bed5c4941d55a98229d3097ec470298..427d429545cfa3b94b9356467053d7702968714f 100644 (file)
@@ -655,12 +655,12 @@ bool inSameParagraph(const VisiblePosition &a, const VisiblePosition &b)
 
 bool isStartOfParagraph(const VisiblePosition &pos)
 {
-    return pos.isNotNull() && isEqualIgnoringAffinity(pos, startOfParagraph(pos));
+    return pos.isNotNull() && pos == startOfParagraph(pos);
 }
 
 bool isEndOfParagraph(const VisiblePosition &pos)
 {
-    return pos.isNotNull() && isEqualIgnoringAffinity(pos, endOfParagraph(pos));
+    return pos.isNotNull() && pos == endOfParagraph(pos);
 }
 
 VisiblePosition previousParagraphPosition(const VisiblePosition &p, int x)
@@ -718,12 +718,12 @@ bool inSameBlock(const VisiblePosition &a, const VisiblePosition &b)
 
 bool isStartOfBlock(const VisiblePosition &pos)
 {
-    return pos.isNotNull() && isEqualIgnoringAffinity(pos, startOfBlock(pos));
+    return pos.isNotNull() && pos == startOfBlock(pos);
 }
 
 bool isEndOfBlock(const VisiblePosition &pos)
 {
-    return pos.isNotNull() && isEqualIgnoringAffinity(pos, endOfBlock(pos));
+    return pos.isNotNull() && pos == endOfBlock(pos);
 }
 
 // ---------