<rdar://problem/9479926> REGRESSION (r82144): Icon overlaps text in Twitter message...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 May 2011 04:44:27 +0000 (04:44 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 May 2011 04:44:27 +0000 (04:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=61241

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/block/positioning/start-ignoring-before.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::TrailingObjects::updateMidpointsForTrailingBoxes): Added a boolean parameter saying
whether to merge the first trailing space with the line break.
(WebCore::RenderBlock::LineBreaker::nextLineBreak): When adding a midpoint behind the current
character, account for trailing positioned objects that occurred after the midpoint by calling
updateMidpointsForTrailingBoxes(), which adds midpoints for them.

LayoutTests:

* fast/block/positioning/start-ignoring-before-expected.png: Added.
* fast/block/positioning/start-ignoring-before-expected.txt: Added.
* fast/block/positioning/start-ignoring-before.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/positioning/start-ignoring-before-expected.png [new file with mode: 0644]
LayoutTests/fast/block/positioning/start-ignoring-before-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/positioning/start-ignoring-before.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index f830b90..3fa107e 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-21  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/9479926> REGRESSION (r82144): Icon overlaps text in Twitter message dialog
+        https://bugs.webkit.org/show_bug.cgi?id=61241
+
+        * fast/block/positioning/start-ignoring-before-expected.png: Added.
+        * fast/block/positioning/start-ignoring-before-expected.txt: Added.
+        * fast/block/positioning/start-ignoring-before.html: Added.
+
 2011-05-21  Justin Schuh  <jschuh@chromium.org>
 
         Unreviewed.
diff --git a/LayoutTests/fast/block/positioning/start-ignoring-before-expected.png b/LayoutTests/fast/block/positioning/start-ignoring-before-expected.png
new file mode 100644 (file)
index 0000000..04c4372
Binary files /dev/null and b/LayoutTests/fast/block/positioning/start-ignoring-before-expected.png differ
diff --git a/LayoutTests/fast/block/positioning/start-ignoring-before-expected.txt b/LayoutTests/fast/block/positioning/start-ignoring-before-expected.txt
new file mode 100644 (file)
index 0000000..e01f5cf
--- /dev/null
@@ -0,0 +1,15 @@
+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 784x50
+        RenderText {#text} at (0,0) size 100x50
+          text run at (0,0) width 100: "X "
+        RenderText {#text} at (0,0) size 0x0
+        RenderInline {SPAN} at (0,0) size 50x50 [color=#FF0000]
+          RenderText {#text} at (100,0) size 50x50
+            text run at (100,0) width 50: "Y"
+        RenderText {#text} at (0,0) size 0x0
+layer at (108,8) size 50x50
+  RenderImage {IMG} at (108,8) size 50x50 [bgcolor=#008000]
diff --git a/LayoutTests/fast/block/positioning/start-ignoring-before.html b/LayoutTests/fast/block/positioning/start-ignoring-before.html
new file mode 100644 (file)
index 0000000..78f692c
--- /dev/null
@@ -0,0 +1,3 @@
+<div style="font: 50px ahem; -webkit-font-smoothing: none;">
+    X <img style="position: absolute; width: 50px; height: 50px; background-color: green;"> <span style="color: red;">Y</span>
+</div>
index 35eb6b9..74c5a7e 100644 (file)
@@ -1,3 +1,19 @@
+2011-05-21  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/9479926> REGRESSION (r82144): Icon overlaps text in Twitter message dialog
+        https://bugs.webkit.org/show_bug.cgi?id=61241
+
+        Test: fast/block/positioning/start-ignoring-before.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::TrailingObjects::updateMidpointsForTrailingBoxes): Added a boolean parameter saying
+        whether to merge the first trailing space with the line break.
+        (WebCore::RenderBlock::LineBreaker::nextLineBreak): When adding a midpoint behind the current
+        character, account for trailing positioned objects that occurred after the midpoint by calling
+        updateMidpointsForTrailingBoxes(), which adds midpoints for them.
+
 2011-05-21  Jeremy Noble  <jer.noble@apple.com>
 
         Reviewed by Eric Carlson.
index 02d00ef..39479b2 100644 (file)
@@ -1744,7 +1744,10 @@ public:
     void setTrailingWhitespace(RenderText*);
     void clear();
     void appendBoxIfNeeded(RenderBox*);
-    void updateMidpointsForTrailingBoxes(LineMidpointState&, const InlineIterator& lBreak);
+
+    enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace };
+
+    void updateMidpointsForTrailingBoxes(LineMidpointState&, const InlineIterator& lBreak, CollapseFirstSpaceOrNot);
 
 private:
     RenderText* m_whitespace;
@@ -1774,7 +1777,7 @@ inline void TrailingObjects::appendBoxIfNeeded(RenderBox* box)
         m_boxes.append(box);
 }
 
-void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMidpointState, const InlineIterator& lBreak)
+void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMidpointState, const InlineIterator& lBreak, CollapseFirstSpaceOrNot collapseFirstSpace)
 {
     if (!m_whitespace)
         return;
@@ -1786,7 +1789,8 @@ void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMid
         int trailingSpaceMidpoint = lineMidpointState.numMidpoints - 1;
         for ( ; trailingSpaceMidpoint >= 0 && lineMidpointState.midpoints[trailingSpaceMidpoint].m_obj != m_whitespace; --trailingSpaceMidpoint) { }
         ASSERT(trailingSpaceMidpoint >= 0);
-        lineMidpointState.midpoints[trailingSpaceMidpoint].m_pos--;
+        if (collapseFirstSpace == CollapseFirstSpace)
+            lineMidpointState.midpoints[trailingSpaceMidpoint].m_pos--;
 
         // Now make sure every single trailingPositionedBox following the trailingSpaceMidpoint properly stops and starts
         // ignoring spaces.
@@ -1805,6 +1809,7 @@ void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMid
         }
     } else if (!lBreak.m_obj) {
         ASSERT(m_whitespace->isText());
+        ASSERT(collapseFirstSpace == CollapseFirstSpace);
         // Add a new end midpoint that stops right at the very end.
         unsigned length = m_whitespace->textLength();
         unsigned pos = length >= 2 ? length - 2 : UINT_MAX;
@@ -2212,6 +2217,7 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
                             // spaces. Create a midpoint to terminate the run
                             // before the second space.
                             addMidpoint(lineMidpointState, ignoreStart);
+                            trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace);
                         }
                     }
                 } else if (ignoringSpaces) {
@@ -2360,7 +2366,7 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
     // Sanity check our midpoints.
     checkMidpoints(lineMidpointState, lBreak);
 
-    trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, lBreak);
+    trailingObjects.updateMidpointsForTrailingBoxes(lineMidpointState, lBreak, TrailingObjects::CollapseFirstSpace);
 
     // We might have made lBreak an iterator that points past the end
     // of the object. Do this adjustment to make it point to the start