Commit 00bbbf00 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Fix pre-order traversal in LayoutBoxModelObject::HasNonEmptyLayoutSize

Passing 'this' (which |object| will be in this case) to
LayoutObject::NextInPreOrder, will turn it into a non-obvious way of
saying FirstChild.
Pass |root| instead of |object| to make the traversal actually pre-
order.

Bug: 769459
Change-Id: I6bc4c487faab053d02bc16826862234f15e2376e
Reviewed-on: https://chromium-review.googlesource.com/690254Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#505099}
parent da738897
...@@ -65,6 +65,12 @@ static const char kBlockWithEmptyInlines[] = ...@@ -65,6 +65,12 @@ static const char kBlockWithEmptyInlines[] =
" <span></span> " " <span></span> "
"</div>"; "</div>";
static const char kBlockWithEmptyFirstChild[] =
"<div id='testElement'>"
" <div style='position: absolute'></div> "
" <div style='position: absolute'>Hello</div> "
"</div>";
class WebElementTest : public ::testing::Test { class WebElementTest : public ::testing::Test {
protected: protected:
Document& GetDocument() { return page_holder_->GetDocument(); } Document& GetDocument() { return page_holder_->GetDocument(); }
...@@ -124,6 +130,9 @@ TEST_F(WebElementTest, HasNonEmptyLayoutSize) { ...@@ -124,6 +130,9 @@ TEST_F(WebElementTest, HasNonEmptyLayoutSize) {
GetDocument().getElementById("testElement")->CreateShadowRootInternal(); GetDocument().getElementById("testElement")->CreateShadowRootInternal();
root.SetInnerHTMLFromString("<div>Hello World</div>"); root.SetInnerHTMLFromString("<div>Hello World</div>");
EXPECT_TRUE(TestElement().HasNonEmptyLayoutSize()); EXPECT_TRUE(TestElement().HasNonEmptyLayoutSize());
InsertHTML(kBlockWithEmptyFirstChild);
EXPECT_TRUE(TestElement().HasNonEmptyLayoutSize());
} }
TEST_F(WebElementTest, IsEditable) { TEST_F(WebElementTest, IsEditable) {
......
...@@ -593,7 +593,7 @@ bool LayoutBoxModelObject::HasNonEmptyLayoutSize() const { ...@@ -593,7 +593,7 @@ bool LayoutBoxModelObject::HasNonEmptyLayoutSize() const {
for (const LayoutBoxModelObject* root = this; root; for (const LayoutBoxModelObject* root = this; root;
root = root->Continuation()) { root = root->Continuation()) {
for (const LayoutObject* object = root; object; for (const LayoutObject* object = root; object;
object = object->NextInPreOrder(object)) { object = object->NextInPreOrder(root)) {
if (object->IsBox()) { if (object->IsBox()) {
const LayoutBox& box = ToLayoutBox(*object); const LayoutBox& box = ToLayoutBox(*object);
if (box.LogicalHeight() && box.LogicalWidth()) if (box.LogicalHeight() && box.LogicalWidth())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment