Title: [136513] trunk
Revision
136513
Author
[email protected]
Date
2012-12-04 08:58:07 -0800 (Tue, 04 Dec 2012)

Log Message

Redrawing issue with inserting new inline element between existing inline elements
https://bugs.webkit.org/show_bug.cgi?id=50315

Reviewed by Levi Weintraub.

Source/WebCore:

When inserting an element such as '<span>text<br></span>' between two lineboxes, the second of which has leading space
collapsed away after a line-break, dirtyLinesFromChangeChild() needs to ensure that the linebox the fragment is inserted into (the second
of the two lineboxes) gets dirtied.

Since the element has been inserted before the first element in the linebox, but after the collapsed leading
space, the search for the new element's linebox will go past the leading space to the previous linebox and select that
one by mistake.

So in order to ensure the element's linebox is dirtied make sure its previous sibling is not the line-break object of the
linebox we selected when searching for a linebox to dirty. If the previous sibling is the linebox's line-break object then
the element is in the one after the one we selected and we should dirty that linebox too.

Test: fast/inline/layout-after-inserting-nested-br.html

* rendering/RenderLineBoxList.cpp:
(WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):

LayoutTests:

* fast/inline/layout-after-inserting-nested-br-expected.html: Added.
* fast/inline/layout-after-inserting-nested-br.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136512 => 136513)


--- trunk/LayoutTests/ChangeLog	2012-12-04 16:53:42 UTC (rev 136512)
+++ trunk/LayoutTests/ChangeLog	2012-12-04 16:58:07 UTC (rev 136513)
@@ -1,3 +1,13 @@
+2012-12-04  Robert Hogan  <[email protected]>
+
+        Redrawing issue with inserting new inline element between existing inline elements
+        https://bugs.webkit.org/show_bug.cgi?id=50315
+
+        Reviewed by Levi Weintraub.
+
+        * fast/inline/layout-after-inserting-nested-br-expected.html: Added.
+        * fast/inline/layout-after-inserting-nested-br.html: Added.
+
 2012-12-04  Mikhail Pozdnyakov  <[email protected]>
 
         IntSize::scale() should return rounded value

Added: trunk/LayoutTests/fast/inline/layout-after-inserting-nested-br-expected.html (0 => 136513)


--- trunk/LayoutTests/fast/inline/layout-after-inserting-nested-br-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/layout-after-inserting-nested-br-expected.html	2012-12-04 16:58:07 UTC (rev 136513)
@@ -0,0 +1,10 @@
+<!DOCTYPE html> 
+<html> 
+<body> 
+<!-- https://bugs.webkit.org/show_bug.cgi?id=50315 -->
+When you click on 'link', a second 'abc' should get inserted after the first.
+<span id="span">abc<br></span> 
+<span id="span">abc<br></span> 
+<span id="link">link</span> 
+</body>
+</html>

Added: trunk/LayoutTests/fast/inline/layout-after-inserting-nested-br.html (0 => 136513)


--- trunk/LayoutTests/fast/inline/layout-after-inserting-nested-br.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/layout-after-inserting-nested-br.html	2012-12-04 16:58:07 UTC (rev 136513)
@@ -0,0 +1,31 @@
+<!DOCTYPE html> 
+<html> 
+<body> 
+<!-- https://bugs.webkit.org/show_bug.cgi?id=50315 -->
+When you click on 'link', a second 'abc' should get inserted after the first.
+<span id="span">abc<br></span> 
+<span id="link">link</span> 
+<script> 
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+    }
+    window.addEventListener('load', function() {
+        setTimeout(function() {
+            document.getElementById('link')._onclick_ = function(){
+                var span = document.getElementById('span').cloneNode(true);
+                this.parentNode.insertBefore(span, this);
+            };
+        	var testEl = document.getElementById("link");
+            var x = testEl.offsetLeft;
+            var y = testEl.offsetTop + testEl.offsetHeight / 2;
+            if (window.eventSender) {
+                eventSender.mouseMoveTo(x,y);
+                eventSender.mouseDown();
+                eventSender.mouseUp();
+            }
+            setTimeout(testRunner.notifyDone(), 0);
+        }, 0);
+    }, false);
+</script> 
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (136512 => 136513)


--- trunk/Source/WebCore/ChangeLog	2012-12-04 16:53:42 UTC (rev 136512)
+++ trunk/Source/WebCore/ChangeLog	2012-12-04 16:58:07 UTC (rev 136513)
@@ -1,3 +1,27 @@
+2012-12-04  Robert Hogan  <[email protected]>
+
+        Redrawing issue with inserting new inline element between existing inline elements
+        https://bugs.webkit.org/show_bug.cgi?id=50315
+
+        Reviewed by Levi Weintraub.
+
+        When inserting an element such as '<span>text<br></span>' between two lineboxes, the second of which has leading space
+        collapsed away after a line-break, dirtyLinesFromChangeChild() needs to ensure that the linebox the fragment is inserted into (the second 
+        of the two lineboxes) gets dirtied. 
+        
+        Since the element has been inserted before the first element in the linebox, but after the collapsed leading
+        space, the search for the new element's linebox will go past the leading space to the previous linebox and select that
+        one by mistake.
+        
+        So in order to ensure the element's linebox is dirtied make sure its previous sibling is not the line-break object of the
+        linebox we selected when searching for a linebox to dirty. If the previous sibling is the linebox's line-break object then
+        the element is in the one after the one we selected and we should dirty that linebox too. 
+
+        Test: fast/inline/layout-after-inserting-nested-br.html
+
+        * rendering/RenderLineBoxList.cpp:
+        (WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
+
 2012-12-04  Mikhail Pozdnyakov  <[email protected]>
 
         IntSize::scale() should return rounded value

Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (136512 => 136513)


--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2012-12-04 16:53:42 UTC (rev 136512)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2012-12-04 16:58:07 UTC (rev 136513)
@@ -386,7 +386,11 @@
         if (adjacentBox)
             adjacentBox->markDirty();
         adjacentBox = box->nextRootBox();
-        if (adjacentBox && (adjacentBox->lineBreakObj() == child || child->isBR() || (curr && curr->isBR())))
+        // If |child| has been inserted before the first element in the linebox, but after collapsed leading
+        // space, the search for |child|'s linebox will go past the leading space to the previous linebox and select that
+        // one as |box|. If we hit that situation here, dirty the |box| actually containing the child too. 
+        bool insertedAfterLeadingSpace = box->lineBreakObj() == child->previousSibling();
+        if (adjacentBox && (adjacentBox->lineBreakObj() == child || child->isBR() || (curr && curr->isBR()) || insertedAfterLeadingSpace))
             adjacentBox->markDirty();
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to