Remove DCHECK(Style()) calls and use StyleRef() instead.
This patch removes the DCHECKs added in [1], and replaces them with
StyleRef() calls which already perform the DCHECK. This makes the code
look cleaner.
[1] https://chromium-review.googlesource.com/c/551116/
Bug: 628043
Change-Id: I125890524d09abb35e0e1b224b6e2518d88894cb
Reviewed-on: https://chromium-review.googlesource.com/553797
Reviewed-by: Rune Lillesveen <rune@opera.com>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#483255}
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index a16e5d49..5bdb5e9 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -728,10 +728,8 @@
// A margin has three types: fixed, percentage, and auto (variable).
// Auto and percentage margins become 0 when computing min/max width.
// Fixed margins can be added in as is.
- DCHECK(child.Style());
- DCHECK(Style());
- Length margin_left = child.Style()->MarginStartUsing(*Style());
- Length margin_right = child.Style()->MarginEndUsing(*Style());
+ Length margin_left = child.StyleRef().MarginStartUsing(StyleRef());
+ Length margin_right = child.StyleRef().MarginEndUsing(StyleRef());
LayoutUnit margin;
if (margin_left.IsFixed())
margin += margin_left.Value();
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
index 43b4fb7..bcd7d16 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -638,9 +638,8 @@
// edge or any positive margin push it out.
// If the child is being centred then the margin calculated to do that has
// factored in any offset required to avoid floats, so use it if necessary.
- DCHECK(Style());
- if (Style()->GetTextAlign() == ETextAlign::kWebkitCenter ||
- child.Style()->MarginStartUsing(*Style()).IsAuto())
+ if (StyleRef().GetTextAlign() == ETextAlign::kWebkitCenter ||
+ child.Style()->MarginStartUsing(StyleRef()).IsAuto())
new_position =
std::max(new_position, position_to_avoid_floats + child_margin_start);
else if (position_to_avoid_floats > initial_start_position)
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 8a7030df..d20e35d 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -3791,14 +3791,12 @@
const LayoutBlock* containing_block) {
LayoutUnit margin_before;
LayoutUnit margin_after;
- DCHECK(Style());
DCHECK(containing_block);
- DCHECK(containing_block->Style());
ComputeMarginsForDirection(
kBlockDirection, containing_block,
ContainingBlockLogicalWidthForContent(), LogicalHeight(), margin_before,
- margin_after, Style()->MarginBeforeUsing(*containing_block->Style()),
- Style()->MarginAfterUsing(*containing_block->Style()));
+ margin_after, StyleRef().MarginBeforeUsing(containing_block->StyleRef()),
+ StyleRef().MarginAfterUsing(containing_block->StyleRef()));
// Note that in this 'positioning phase' of the layout we are using the
// containing block's writing mode rather than our own when calculating
// margins.
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
index 06f59cc..8436b88 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -1636,10 +1636,8 @@
if (available_alignment_space <= 0)
return;
- DCHECK(child.Style());
- DCHECK(Style());
- Length margin_start = child.Style()->MarginStartUsing(*Style());
- Length margin_end = child.Style()->MarginEndUsing(*Style());
+ Length margin_start = child.StyleRef().MarginStartUsing(StyleRef());
+ Length margin_end = child.StyleRef().MarginEndUsing(StyleRef());
if (margin_start.IsAuto() && margin_end.IsAuto()) {
child.SetMarginStart(available_alignment_space / 2, Style());
child.SetMarginEnd(available_alignment_space / 2, Style());
@@ -1662,10 +1660,8 @@
if (available_alignment_space <= 0)
return;
- DCHECK(child.Style());
- DCHECK(Style());
- Length margin_before = child.Style()->MarginBeforeUsing(*Style());
- Length margin_after = child.Style()->MarginAfterUsing(*Style());
+ Length margin_before = child.StyleRef().MarginBeforeUsing(StyleRef());
+ Length margin_after = child.StyleRef().MarginAfterUsing(StyleRef());
if (margin_before.IsAuto() && margin_after.IsAuto()) {
child.SetMarginBefore(available_alignment_space / 2, Style());
child.SetMarginAfter(available_alignment_space / 2, Style());
diff --git a/third_party/WebKit/Source/core/layout/LayoutInline.cpp b/third_party/WebKit/Source/core/layout/LayoutInline.cpp
index 7b5cd93..e053cf9 100644
--- a/third_party/WebKit/Source/core/layout/LayoutInline.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutInline.cpp
@@ -844,27 +844,23 @@
}
LayoutUnit LayoutInline::MarginStart(const ComputedStyle* other_style) const {
- DCHECK(Style());
- return ComputeMargin(
- this, Style()->MarginStartUsing(other_style ? *other_style : *Style()));
+ return ComputeMargin(this, StyleRef().MarginStartUsing(
+ other_style ? *other_style : StyleRef()));
}
LayoutUnit LayoutInline::MarginEnd(const ComputedStyle* other_style) const {
- DCHECK(Style());
return ComputeMargin(
- this, Style()->MarginEndUsing(other_style ? *other_style : *Style()));
+ this, StyleRef().MarginEndUsing(other_style ? *other_style : StyleRef()));
}
LayoutUnit LayoutInline::MarginBefore(const ComputedStyle* other_style) const {
- DCHECK(Style());
- return ComputeMargin(
- this, Style()->MarginBeforeUsing(other_style ? *other_style : *Style()));
+ return ComputeMargin(this, StyleRef().MarginBeforeUsing(
+ other_style ? *other_style : StyleRef()));
}
LayoutUnit LayoutInline::MarginAfter(const ComputedStyle* other_style) const {
- DCHECK(Style());
- return ComputeMargin(
- this, Style()->MarginAfterUsing(other_style ? *other_style : *Style()));
+ return ComputeMargin(this, StyleRef().MarginAfterUsing(
+ other_style ? *other_style : StyleRef()));
}
LayoutUnit LayoutInline::MarginOver() const {
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h
index e30873d..9bfc60b 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.h
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -2810,36 +2810,31 @@
inline int AdjustForAbsoluteZoom(int value, LayoutObject* layout_object) {
DCHECK(layout_object);
- DCHECK(layout_object->Style());
- return AdjustForAbsoluteZoom(value, *layout_object->Style());
+ return AdjustForAbsoluteZoom(value, layout_object->StyleRef());
}
inline LayoutUnit AdjustLayoutUnitForAbsoluteZoom(LayoutUnit value,
LayoutObject& layout_object) {
- DCHECK(layout_object.Style());
- return AdjustLayoutUnitForAbsoluteZoom(value, *layout_object.Style());
+ return AdjustLayoutUnitForAbsoluteZoom(value, layout_object.StyleRef());
}
inline void AdjustFloatQuadForAbsoluteZoom(FloatQuad& quad,
LayoutObject& layout_object) {
- DCHECK(layout_object.Style());
- float zoom = layout_object.Style()->EffectiveZoom();
+ float zoom = layout_object.StyleRef().EffectiveZoom();
if (zoom != 1)
quad.Scale(1 / zoom, 1 / zoom);
}
inline void AdjustFloatRectForAbsoluteZoom(FloatRect& rect,
LayoutObject& layout_object) {
- DCHECK(layout_object.Style());
- float zoom = layout_object.Style()->EffectiveZoom();
+ float zoom = layout_object.StyleRef().EffectiveZoom();
if (zoom != 1)
rect.Scale(1 / zoom, 1 / zoom);
}
inline double AdjustScrollForAbsoluteZoom(double value,
LayoutObject& layout_object) {
- DCHECK(layout_object.Style());
- return AdjustScrollForAbsoluteZoom(value, *layout_object.Style());
+ return AdjustScrollForAbsoluteZoom(value, layout_object.StyleRef());
}
#define DEFINE_LAYOUT_OBJECT_TYPE_CASTS(thisType, predicate) \