Skip to content

Commit

Permalink
Inline flow not learning height of all text descendants
Browse files Browse the repository at this point in the history
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
Robert Hogan committed Dec 28, 2011
1 parent 07abbf2 commit 1170cfe
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
10 changes: 10 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 5 additions & 0 deletions LayoutTests/fast/inline/nested-text-descendants-expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<span style="outline: 1px dotted blue;">&#x200b;<span style="margin: 0 10px;"></span>text</span>
</body>
</html>
5 changes: 5 additions & 0 deletions LayoutTests/fast/inline/nested-text-descendants.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<span style="outline: 1px dotted blue;"> <span style="margin: 0 10px;"></span> text</span>
</body>
</html>
22 changes: 22 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 10 additions & 2 deletions Source/WebCore/rendering/InlineFlowBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/InlineFlowBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1170cfe

Please sign in to comment.