Commit 3dbd1155 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Don't load pending resources for @page descriptors.

We incorrectly parse properties like background-image as page
descriptors. This CL makes sure we at least don't trigger fetches for
such urls.

Bug: 1086264
Change-Id: I32f2262fae46cafdd57f1cf2baa825d6bef32389
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215323Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771718}
parent 7bf63c20
...@@ -1270,8 +1270,6 @@ scoped_refptr<const ComputedStyle> StyleResolver::StyleForPage( ...@@ -1270,8 +1270,6 @@ scoped_refptr<const ComputedStyle> StyleResolver::StyleForPage(
state, result.AllRules(), false, inherited_only, needs_apply_pass); state, result.AllRules(), false, inherited_only, needs_apply_pass);
} }
state.LoadPendingResources();
// Now return the style. // Now return the style.
return state.TakeStyle(); return state.TakeStyle();
} }
......
...@@ -326,7 +326,7 @@ const CSSImageValue& GetBackgroundImageValue(Element* element) { ...@@ -326,7 +326,7 @@ const CSSImageValue& GetBackgroundImageValue(Element* element) {
TEST_F(StyleResolverTest, BackgroundImageFetch) { TEST_F(StyleResolverTest, BackgroundImageFetch) {
GetDocument().documentElement()->setInnerHTML(R"HTML( GetDocument().documentElement()->setInnerHTML(R"HTML(
<style id="sheet"> <style>
#none { #none {
display: none; display: none;
background-image: url(img-none.png); background-image: url(img-none.png);
...@@ -389,4 +389,28 @@ TEST_F(StyleResolverTest, BackgroundImageFetch) { ...@@ -389,4 +389,28 @@ TEST_F(StyleResolverTest, BackgroundImageFetch) {
<< "No fetch for element outside the flat tree"; << "No fetch for element outside the flat tree";
} }
TEST_F(StyleResolverTest, NoFetchForAtPage) {
// Strictly, we should drop descriptors from @page rules which are not valid
// descriptors, but as long as we apply them to ComputedStyle we should at
// least not trigger fetches. The display:contents is here to make sure we
// don't hit a DCHECK in StylePendingImage::ComputedCSSValue().
GetDocument().body()->setInnerHTML(R"HTML(
<style>
@page {
display: contents;
background-image: url(bg-img.png);
}
</style>
)HTML");
scoped_refptr<const ComputedStyle> page_style =
GetDocument().EnsureStyleResolver().StyleForPage(0, "");
ASSERT_TRUE(page_style);
const CSSValue* computed_value = ComputedStyleUtils::ComputedPropertyValue(
GetCSSPropertyBackgroundImage(), *page_style);
const CSSValueList* bg_img_list = To<CSSValueList>(computed_value);
EXPECT_TRUE(To<CSSImageValue>(bg_img_list->Item(0)).IsCachePending());
}
} // namespace blink } // namespace blink
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