Commit 5a003d5c authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Use InitialStyleForElement for invisible elements

We previously used ComputedStyle::Create when creating ComputedStyle for
invisible elements, but the ComputedStyle made with that lacks some
setup needed for it to actually be usable correctly. Example case is
the style's font fallback list is not set, leading to some crashes.

Bug: 904791
Change-Id: I512082af6dcf7a5076eb033a2f9a78b83020e47e
Reviewed-on: https://chromium-review.googlesource.com/c/1345952
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610322}
parent 91cd44f5
...@@ -75,6 +75,8 @@ class CORE_EXPORT StyleResolver final ...@@ -75,6 +75,8 @@ class CORE_EXPORT StyleResolver final
const ComputedStyle* layout_parent_style = nullptr, const ComputedStyle* layout_parent_style = nullptr,
RuleMatchingBehavior = kMatchAllRules); RuleMatchingBehavior = kMatchAllRules);
static scoped_refptr<ComputedStyle> InitialStyleForElement(Document&);
static AnimatableValue* CreateAnimatableValueSnapshot( static AnimatableValue* CreateAnimatableValueSnapshot(
Element&, Element&,
const ComputedStyle& base_style, const ComputedStyle& base_style,
...@@ -138,8 +140,6 @@ class CORE_EXPORT StyleResolver final ...@@ -138,8 +140,6 @@ class CORE_EXPORT StyleResolver final
private: private:
explicit StyleResolver(Document&); explicit StyleResolver(Document&);
static scoped_refptr<ComputedStyle> InitialStyleForElement(Document&);
// FIXME: This should probably go away, folded into FontBuilder. // FIXME: This should probably go away, folded into FontBuilder.
void UpdateFont(StyleResolverState&); void UpdateFont(StyleResolverState&);
......
...@@ -2145,7 +2145,8 @@ scoped_refptr<ComputedStyle> Element::StyleForLayoutObject() { ...@@ -2145,7 +2145,8 @@ scoped_refptr<ComputedStyle> Element::StyleForLayoutObject() {
if (RuntimeEnabledFeatures::InvisibleDOMEnabled() && if (RuntimeEnabledFeatures::InvisibleDOMEnabled() &&
hasAttribute(html_names::kInvisibleAttr)) { hasAttribute(html_names::kInvisibleAttr)) {
auto style = ComputedStyle::Create(); auto style =
GetDocument().GetStyleResolver()->InitialStyleForElement(GetDocument());
style->SetDisplay(EDisplay::kNone); style->SetDisplay(EDisplay::kNone);
return style; return 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