[Squad] Unnecessary use of mutable style in vp propagation.
Also a couple of other places where ComputedStyle could be made
immutable.
Bug: 813068
Change-Id: I7cebac7951adbf65dbb057ef7b75d4ddab62e90c
Reviewed-on: https://chromium-review.googlesource.com/924145
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537340}
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
index 4a33b40..ade931f86 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
@@ -623,8 +623,10 @@
// be propagated from shadow host to distributed node.
if (state.DistributedToV0InsertionPoint() || element->AssignedSlot()) {
if (Element* parent = element->parentElement()) {
- if (ComputedStyle* style_of_shadow_host = parent->MutableComputedStyle())
+ if (const ComputedStyle* style_of_shadow_host =
+ parent->GetComputedStyle()) {
state.Style()->SetUserModify(style_of_shadow_host->UserModify());
+ }
}
}
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index c437dcf8..5884994e 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -2042,27 +2042,27 @@
Length scroll_padding_bottom = overflow_style->ScrollPaddingBottom();
Length scroll_padding_left = overflow_style->ScrollPaddingLeft();
- scoped_refptr<ComputedStyle> viewport_style = GetLayoutView()->MutableStyle();
- if (viewport_style->GetWritingMode() != root_writing_mode ||
- viewport_style->Direction() != root_direction ||
- viewport_style->VisitedDependentColor(GetCSSPropertyBackgroundColor()) !=
+ const ComputedStyle& viewport_style = GetLayoutView()->StyleRef();
+ if (viewport_style.GetWritingMode() != root_writing_mode ||
+ viewport_style.Direction() != root_direction ||
+ viewport_style.VisitedDependentColor(GetCSSPropertyBackgroundColor()) !=
background_color ||
- viewport_style->BackgroundLayers() != background_layers ||
- viewport_style->ImageRendering() != image_rendering ||
- viewport_style->OverflowAnchor() != overflow_anchor ||
- viewport_style->OverflowX() != overflow_x ||
- viewport_style->OverflowY() != overflow_y ||
- viewport_style->ColumnGap() != column_gap ||
- viewport_style->GetScrollSnapType() != snap_type ||
- viewport_style->GetScrollBehavior() != scroll_behavior ||
- viewport_style->OverscrollBehaviorX() != overscroll_behavior_x ||
- viewport_style->OverscrollBehaviorY() != overscroll_behavior_y ||
- viewport_style->ScrollPaddingTop() != scroll_padding_top ||
- viewport_style->ScrollPaddingRight() != scroll_padding_right ||
- viewport_style->ScrollPaddingBottom() != scroll_padding_bottom ||
- viewport_style->ScrollPaddingLeft() != scroll_padding_left) {
+ viewport_style.BackgroundLayers() != background_layers ||
+ viewport_style.ImageRendering() != image_rendering ||
+ viewport_style.OverflowAnchor() != overflow_anchor ||
+ viewport_style.OverflowX() != overflow_x ||
+ viewport_style.OverflowY() != overflow_y ||
+ viewport_style.ColumnGap() != column_gap ||
+ viewport_style.GetScrollSnapType() != snap_type ||
+ viewport_style.GetScrollBehavior() != scroll_behavior ||
+ viewport_style.OverscrollBehaviorX() != overscroll_behavior_x ||
+ viewport_style.OverscrollBehaviorY() != overscroll_behavior_y ||
+ viewport_style.ScrollPaddingTop() != scroll_padding_top ||
+ viewport_style.ScrollPaddingRight() != scroll_padding_right ||
+ viewport_style.ScrollPaddingBottom() != scroll_padding_bottom ||
+ viewport_style.ScrollPaddingLeft() != scroll_padding_left) {
scoped_refptr<ComputedStyle> new_style =
- ComputedStyle::Clone(*viewport_style);
+ ComputedStyle::Clone(viewport_style);
new_style->SetWritingMode(root_writing_mode);
new_style->SetDirection(root_direction);
new_style->SetBackgroundColor(background_color);
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index 9d59498..39b1fb4 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -1465,17 +1465,17 @@
child->SetPreferredLogicalWidthsDirty();
}
- scoped_refptr<ComputedStyle> child_style = child->MutableStyle();
+ const ComputedStyle& child_style = child->StyleRef();
if (child->IsFloating() ||
(child->IsBox() && ToLayoutBox(child)->AvoidsFloats())) {
LayoutUnit float_total_width = float_left_width + float_right_width;
- if (child_style->Clear() == EClear::kBoth ||
- child_style->Clear() == EClear::kLeft) {
+ if (child_style.Clear() == EClear::kBoth ||
+ child_style.Clear() == EClear::kLeft) {
max_logical_width = std::max(float_total_width, max_logical_width);
float_left_width = LayoutUnit();
}
- if (child_style->Clear() == EClear::kBoth ||
- child_style->Clear() == EClear::kRight) {
+ if (child_style.Clear() == EClear::kBoth ||
+ child_style.Clear() == EClear::kRight) {
max_logical_width = std::max(float_total_width, max_logical_width);
float_right_width = LayoutUnit();
}
@@ -1485,8 +1485,8 @@
// (variable).
// Auto and percentage margins simply become 0 when computing min/max width.
// Fixed margins can be added in as is.
- Length start_margin_length = child_style->MarginStartUsing(style_to_use);
- Length end_margin_length = child_style->MarginEndUsing(style_to_use);
+ Length start_margin_length = child_style.MarginStartUsing(style_to_use);
+ Length end_margin_length = child_style.MarginEndUsing(style_to_use);
LayoutUnit margin;
LayoutUnit margin_start;
LayoutUnit margin_end;
@@ -1540,7 +1540,7 @@
}
if (child->IsFloating()) {
- if (child_style->Floating() == EFloat::kLeft)
+ if (child_style.Floating() == EFloat::kLeft)
float_left_width += w;
else
float_right_width += w;