Commit 369b6fca authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Don't update style for focusability when render-blocking.

WebNode::IsFocusable() updated style and layout tree, without ignoring
pending stylesheets, which meant generating a display:none placeholder
style for the root node. Instead, early return from IsFocusable() when
we are blocking rendering.

Bug: 521692

Change-Id: Idd6cfcf800e4173cfc1bdcb916728c7a0186edf9
Reviewed-on: https://chromium-review.googlesource.com/c/1245787Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599181}
parent b7590d68
...@@ -133,6 +133,8 @@ bool WebNode::IsCommentNode() const { ...@@ -133,6 +133,8 @@ bool WebNode::IsCommentNode() const {
bool WebNode::IsFocusable() const { bool WebNode::IsFocusable() const {
if (!private_->IsElementNode()) if (!private_->IsElementNode())
return false; return false;
if (!private_->GetDocument().IsRenderingReady())
return false;
private_->GetDocument().UpdateStyleAndLayoutTreeForNode(private_.Get()); private_->GetDocument().UpdateStyleAndLayoutTreeForNode(private_.Get());
return ToElement(private_.Get())->IsFocusable(); return ToElement(private_.Get())->IsFocusable();
} }
......
...@@ -67,7 +67,8 @@ TEST_F(WebNodeSimTest, IsFocused) { ...@@ -67,7 +67,8 @@ TEST_F(WebNodeSimTest, IsFocused) {
LoadURL("https://example.com/test.html"); LoadURL("https://example.com/test.html");
WebView().Resize(WebSize(800, 600)); WebView().Resize(WebSize(800, 600));
main_resource.Complete(R"HTML( main_resource.Start();
main_resource.Write(R"HTML(
<!DOCTYPE html> <!DOCTYPE html>
<link rel=stylesheet href=style.css> <link rel=stylesheet href=style.css>
<input id=focusable> <input id=focusable>
...@@ -79,7 +80,9 @@ TEST_F(WebNodeSimTest, IsFocused) { ...@@ -79,7 +80,9 @@ TEST_F(WebNodeSimTest, IsFocused) {
WebNode input_node(GetDocument().getElementById("focusable")); WebNode input_node(GetDocument().getElementById("focusable"));
EXPECT_FALSE(input_node.IsFocusable()); EXPECT_FALSE(input_node.IsFocusable());
EXPECT_FALSE(GetDocument().HasNodesWithPlaceholderStyle());
main_resource.Finish();
css_resource.Complete("dummy {}"); css_resource.Complete("dummy {}");
EXPECT_TRUE(input_node.IsFocusable()); EXPECT_TRUE(input_node.IsFocusable());
} }
......
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