Commit bc74a9f3 authored by Balazs Kelemen's avatar Balazs Kelemen Committed by Commit Bot

Recheck for display:none in StyleAdjuster after calling AdjustStyleForHTMLElement

AdjustStyleForHTMLElement might set display:none. This can happen for a HTMLImageElement
that returns true for IsCollapsed(). Therefore the condition should be checked again.

Bug: 768546
Change-Id: I77b441a19f713018b89afa4f460501f9ca96275a
Reviewed-on: https://chromium-review.googlesource.com/683006Reviewed-by: default avatarnainar <nainar@chromium.org>
Commit-Queue: Balazs Kelemen <b.kelemen@samsung.com>
Cr-Commit-Position: refs/heads/master@{#505436}
parent b1ce939b
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<script type="text/javascript">
// Tests that style resolution of an an out-of-flow image that is disallowed thus collapsed doesn't crash.
if (window.testRunner) {
// Inject a subresource filter to disallow 'beta.png'.
testRunner.setDisallowedSubresourcePathSuffixes(["beta.png"]);
}
async_test(t => {
let i = document.createElement("img");
i.style.position = 'absolute';
i.onload = t.unreached_func();
i.onerror = t.step_func_done(_ => {
let style = window.getComputedStyle(i);
assert_equals(style.display, "none", "Images that are disallowed should be set to display:none");
});
i.src = "resources/beta.png";
document.body.append(i);
}, "Style resolution does not crash with disallowed out-of-flow images.");
</script>
......@@ -481,10 +481,11 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
const ComputedStyle& parent_style = *state.ParentStyle();
const ComputedStyle& layout_parent_style = *state.LayoutParentStyle();
if (style.Display() != EDisplay::kNone && element &&
element->IsHTMLElement()) {
AdjustStyleForHTMLElement(style, ToHTMLElement(*element));
}
if (style.Display() != EDisplay::kNone) {
if (element && element->IsHTMLElement())
AdjustStyleForHTMLElement(style, ToHTMLElement(*element));
// Per the spec, position 'static' and 'relative' in the top layer compute
// to 'absolute'.
if (IsInTopLayer(element, style) &&
......
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