Browse files

Inline flow not learning height of all text descendants

https://bugs.webkit.org/show_bug.cgi?id=75305

Reviewed by Dan Bernstein.

Source/WebCore:

Tests: fast/inline/nested-text-descendants-expected.html
       fast/inline/nested-text-descendants.html

The root inline box would only learn it had text descendants if its first grandchild
was text. It wasn't informed of subsequent text grandchildren so could not factor them
into its calculation of the line height.
To fix this, propagate the existence of a text descendant to the root inline box
by walking up through the text child's ancestors.

* rendering/InlineFlowBox.cpp:
(WebCore::setHasTextDescendantsOnAncestors):
(WebCore::InlineFlowBox::addToLine):
* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::setHasTextDescendants):

LayoutTests:

* fast/inline/nested-text-descendants-expected.html: Added.
* fast/inline/nested-text-descendants.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information...
1 parent 07abbf2 commit 1170cfef2504a028c0f2339014b25b653bb9b0ba Robert Hogan committed Dec 28, 2011
View
10 LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-28 Robert Hogan <robert@webkit.org>
+
+ Inline flow not learning height of all text descendants
+ https://bugs.webkit.org/show_bug.cgi?id=75305
+
+ Reviewed by Dan Bernstein.
+
+ * fast/inline/nested-text-descendants-expected.html: Added.
+ * fast/inline/nested-text-descendants.html: Added.
+
2011-12-28 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r103620.
View
5 LayoutTests/fast/inline/nested-text-descendants-expected.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<span style="outline: 1px dotted blue;">&#x200b;<span style="margin: 0 10px;"></span>text</span>
+</body>
+</html>
View
5 LayoutTests/fast/inline/nested-text-descendants.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<span style="outline: 1px dotted blue;"> <span style="margin: 0 10px;"></span> text</span>
+</body>
+</html>
View
22 Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2011-12-28 Robert Hogan <robert@webkit.org>
+
+ Inline flow not learning height of all text descendants
+ https://bugs.webkit.org/show_bug.cgi?id=75305
+
+ Reviewed by Dan Bernstein.
+
+ Tests: fast/inline/nested-text-descendants-expected.html
+ fast/inline/nested-text-descendants.html
+
+ The root inline box would only learn it had text descendants if its first grandchild
+ was text. It wasn't informed of subsequent text grandchildren so could not factor them
+ into its calculation of the line height.
+ To fix this, propagate the existence of a text descendant to the root inline box
+ by walking up through the text child's ancestors.
+
+ * rendering/InlineFlowBox.cpp:
+ (WebCore::setHasTextDescendantsOnAncestors):
+ (WebCore::InlineFlowBox::addToLine):
+ * rendering/InlineFlowBox.h:
+ (WebCore::InlineFlowBox::setHasTextDescendants):
+
2011-12-28 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r103620.
View
12 Source/WebCore/rendering/InlineFlowBox.cpp
@@ -78,6 +78,14 @@ IntRect InlineFlowBox::roundedFrameRect() const
return IntRect(snappedX, snappedY, snappedMaxX - snappedX, snappedMaxY - snappedY);
}
+static void setHasTextDescendantsOnAncestors(InlineFlowBox* box)
+{
+ while (box && !box->hasTextDescendants()) {
+ box->setHasTextDescendants();
+ box = box->parent();
+ }
+}
+
void InlineFlowBox::addToLine(InlineBox* child)
{
ASSERT(!child->parent());
@@ -99,10 +107,10 @@ void InlineFlowBox::addToLine(InlineBox* child)
if (child->isText()) {
if (child->renderer()->parent() == renderer())
m_hasTextChildren = true;
- m_hasTextDescendants = true;
+ setHasTextDescendantsOnAncestors(this);
} else if (child->isInlineFlowBox()) {
if (toInlineFlowBox(child)->hasTextDescendants())
- m_hasTextDescendants = true;
+ setHasTextDescendantsOnAncestors(this);
}
if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer()->isPositioned()) {
View
1 Source/WebCore/rendering/InlineFlowBox.h
@@ -192,6 +192,7 @@ class InlineFlowBox : public InlineBox {
bool hasTextChildren() const { return m_hasTextChildren; }
bool hasTextDescendants() const { return m_hasTextDescendants; }
+ void setHasTextDescendants() { m_hasTextDescendants = true; }
void checkConsistency() const;
void setHasBadChildList();

0 comments on commit 1170cfe

Please sign in to comment.