Skip to content

Commit

Permalink
[StyleBuilder] Mark more extra fields (column,display,etc) readonly.
Browse files Browse the repository at this point in the history
As above. There should be no behaviour change.

Bug: 1377295
Change-Id: I0428ee5895c1d449060b482e6b31f5a7c4b7aa4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4000091
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1067928}
  • Loading branch information
bfgeek authored and Chromium LUCI CQ committed Nov 6, 2022
1 parent 198463a commit 5219463
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ TEST_F(MatchedPropertiesCacheTest, EnsuredOutsideFlatTree) {

auto style = CreateStyle();
auto parent = CreateStyle();
auto ensured_style = CreateStyle();
ensured_style->SetIsEnsuredOutsideFlatTree();
auto builder = CreateStyleBuilder();
builder.SetIsEnsuredOutsideFlatTree();
auto ensured_style = builder.TakeStyle();

TestKey key1("display:block", 1, GetDocument());

Expand All @@ -188,11 +189,15 @@ TEST_F(MatchedPropertiesCacheTest, EnsuredOutsideFlatTreeAndDisplayNone) {
TestCache cache(GetDocument());

auto parent = CreateStyle();
auto parent_none = CreateStyle();
auto style = CreateStyle();
auto style_flat = CreateStyle();
parent_none->SetIsEnsuredInDisplayNone();
style_flat->SetIsEnsuredOutsideFlatTree();

auto builder = CreateStyleBuilder();
builder.SetIsEnsuredInDisplayNone();
auto parent_none = builder.TakeStyle();

builder = CreateStyleBuilder();
builder.SetIsEnsuredOutsideFlatTree();
auto style_flat = builder.TakeStyle();

TestKey key1("display:block", 1, GetDocument());

Expand Down
29 changes: 15 additions & 14 deletions third_party/blink/renderer/core/css/resolver/style_adjuster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ static void AdjustStyleForHTMLElement(ComputedStyle& style,
}

if (IsA<HTMLUListElement>(element) || IsA<HTMLOListElement>(element)) {
style.SetIsInsideListElement();
builder.SetIsInsideListElement();
return;
}

Expand All @@ -551,7 +551,7 @@ static void AdjustStyleForHTMLElement(ComputedStyle& style,

if (IsA<HTMLBodyElement>(element) &&
element.GetDocument().FirstBodyElement() != element) {
style.SetIsSecondaryBodyElement();
builder.SetIsSecondaryBodyElement();
}
}

Expand Down Expand Up @@ -612,14 +612,14 @@ static void AdjustStyleForDisplay(ComputedStyle& style,
Document* document) {
// Blockify the children of flex, grid or LayoutCustom containers.
if (layout_parent_style.BlockifiesChildren() && !HostIsInputFile(element)) {
style.SetIsInBlockifyingDisplay();
builder.SetIsInBlockifyingDisplay();
if (style.Display() != EDisplay::kContents) {
builder.SetDisplay(EquivalentBlockDisplay(style.Display()));
if (!style.HasOutOfFlowPosition())
style.SetIsFlexOrGridOrCustomItem();
builder.SetIsFlexOrGridOrCustomItem();
}
if (layout_parent_style.IsDisplayFlexibleOrGridBox())
style.SetIsFlexOrGridItem();
builder.SetIsFlexOrGridItem();
}

if (style.Display() == EDisplay::kBlock)
Expand Down Expand Up @@ -773,13 +773,14 @@ void StyleAdjuster::AdjustEffectiveTouchAction(
}
}

static void AdjustStyleForInert(ComputedStyle& style, Element* element) {
static void AdjustStyleForInert(ComputedStyleBuilder& builder,
Element* element) {
if (!element)
return;

if (element->IsInertRoot()) {
style.SetIsInert(true);
style.SetIsInertIsInherited(false);
builder.SetIsInert(true);
builder.SetIsInertIsInherited(false);
return;
}

Expand All @@ -788,13 +789,13 @@ static void AdjustStyleForInert(ComputedStyle& style, Element* element) {
if (!modal_element)
modal_element = Fullscreen::FullscreenElementFrom(document);
if (modal_element == element) {
style.SetIsInert(false);
style.SetIsInertIsInherited(false);
builder.SetIsInert(false);
builder.SetIsInertIsInherited(false);
return;
}
if (modal_element && element == document.documentElement()) {
style.SetIsInert(true);
style.SetIsInertIsInherited(false);
builder.SetIsInert(true);
builder.SetIsInertIsInherited(false);
return;
}
}
Expand Down Expand Up @@ -928,7 +929,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
layout_parent_style)) {
style.SetIsStackingContextWithoutContainment(false);
if (!style.HasAutoZIndex())
style.SetEffectiveZIndexZero(true);
builder.SetEffectiveZIndexZero(true);
} else if (!style.HasAutoZIndex()) {
style.SetIsStackingContextWithoutContainment(true);
}
Expand Down Expand Up @@ -977,7 +978,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
// Let the theme also have a crack at adjusting the style.
LayoutTheme::GetTheme().AdjustStyle(element, style, builder);

AdjustStyleForInert(style, element);
AdjustStyleForInert(builder, element);

AdjustStyleForEditing(builder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ void StyleResolver::InitStyleAndApplyInheritance(
DCHECK((IsShadowHost(element.parentNode()) ||
IsA<HTMLSlotElement>(element.parentNode())) &&
!LayoutTreeBuilderTraversal::ParentElement(element));
state.Style()->SetIsEnsuredOutsideFlatTree();
state.StyleBuilder().SetIsEnsuredOutsideFlatTree();
}
}
state.StyleBuilder().SetStyleType(style_request.pseudo_id);
Expand Down Expand Up @@ -1391,7 +1391,7 @@ void StyleResolver::ApplyBaseStyle(
#endif

state.SetStyle(ComputedStyle::Clone(*animation_base_computed_style));
state.StyleRef().SetBaseData(
state.StyleBuilder().SetBaseData(
scoped_refptr<StyleBaseData>(GetBaseData(state)));
state.StyleBuilder().SetStyleType(style_request.pseudo_id);
if (!state.ParentStyle()) {
Expand Down Expand Up @@ -1749,7 +1749,7 @@ bool StyleResolver::ApplyAnimatedStyle(StyleResolverState& state,

if (!IsAnimationStyleChange(*animating_element) ||
!state.StyleRef().BaseData()) {
state.StyleRef().SetBaseData(StyleBaseData::Create(
state.StyleBuilder().SetBaseData(StyleBaseData::Create(
ComputedStyle::Clone(state.StyleRef()), cascade.GetImportantSet()));
}

Expand Down Expand Up @@ -2165,7 +2165,7 @@ void StyleResolver::CascadeAndApplyMatchedProperties(StyleResolverState& state,

// NOTE: This flag needs to be set before the entry is added to the
// matched properties cache, or it will be wrong on cache hits.
state.Style()->SetInlineStyleLostCascade(cascade.InlineStyleLost());
state.StyleBuilder().SetInlineStyleLostCascade(cascade.InlineStyleLost());

MaybeAddToMatchedPropertiesCache(state, cache_success, result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ TextControlInnerEditorElement::CustomStyleForLayoutObject(
: EUserModify::kReadWritePlaintextOnly);
text_block_style_builder.SetDisplay(EDisplay::kBlock);
text_block_style_builder.SetHasLineIfEmpty(true);
text_block_style->SetShouldIgnoreOverflowPropertyForInlineBlockBaseline();
text_block_style_builder
.SetShouldIgnoreOverflowPropertyForInlineBlockBaseline();

if (!IsA<HTMLTextAreaElement>(host)) {
text_block_style_builder.SetWhiteSpace(EWhiteSpace::kPre);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@
field_group: "*",
default_value: "true",
computed_style_custom_functions: ["setter"],
readonly: true,
},
{
name: "HasAutoColumnCount",
Expand All @@ -907,6 +908,7 @@
field_group: "*",
default_value: "true",
computed_style_custom_functions: ["setter"],
readonly: true,
},
{
name: "ImplicitNamedGridColumnLines",
Expand Down Expand Up @@ -966,13 +968,15 @@
field_group: "surround",
default_value: "false",
custom_compare: true,
readonly: true,
},
{
name: "MayHavePadding",
field_template: "monotonic_flag",
field_group: "surround",
default_value: "false",
custom_compare: true,
readonly: true,
},
{
name: "DarkColorScheme",
Expand All @@ -995,32 +999,37 @@
field_template: "monotonic_flag",
default_value: "false",
custom_compare: true,
readonly: true,
},
{
name: "IsFlexOrGridOrCustomItem",
field_template: "monotonic_flag",
default_value: "false",
custom_compare: true,
readonly: true,
},
{
name: "IsFlexOrGridItem",
field_template: "monotonic_flag",
default_value: "false",
custom_compare: true,
readonly: true,
},
{
name: "IsEnsuredOutsideFlatTree",
field_template: "monotonic_flag",
default_value: "false",
custom_compare: true,
inherited: true,
readonly: true,
},
{
name: "IsInsideListElement",
field_template: "monotonic_flag",
default_value: "false",
custom_compare: true,
inherited: true,
readonly: true,
},

// This field disables the 'overflow' check in |LayoutBlock::
Expand All @@ -1032,6 +1041,7 @@
field_template: "monotonic_flag",
default_value: "false",
inherited: false,
readonly: true,
},
{
name: "MathBaseline",
Expand Down Expand Up @@ -1119,6 +1129,7 @@
type_name: "bool",
field_group: "*",
default_value: "false",
readonly: true,
},
{
name: "BaselineShiftType",
Expand Down Expand Up @@ -1178,6 +1189,7 @@
wrapper_pointer_name: "scoped_refptr",
custom_compare: true,
custom_copy: true,
readonly: true,
},
{
// https://drafts.csswg.org/css-contain-2/#skips-its-contents
Expand All @@ -1193,6 +1205,7 @@
field_template: "primitive",
type_name: "bool",
default_value: "false",
readonly: true,
},
{
// We need to go through LayoutObject::SetStyle with
Expand All @@ -1205,6 +1218,7 @@
field_template: "monotonic_flag",
default_value: "false",
field_group: "*",
readonly: true,
},
{
name: "InlineStyleLostCascade",
Expand All @@ -1213,20 +1227,23 @@
field_group: "*",
default_value: "false",
custom_compare: true,
readonly: true,
},
{
name: "HasExplicitOverflowXVisible",
field_template: "monotonic_flag",
type_name: "bool",
field_group: "*",
default_value: "false",
readonly: true,
},
{
name: "HasExplicitOverflowYVisible",
field_template: "monotonic_flag",
type_name: "bool",
field_group: "*",
default_value: "false",
readonly: true,
}
],
}

0 comments on commit 5219463

Please sign in to comment.