[css-anchor-position] Remove old broken getComputedStyle code
getComputedStyle should not rely on box dimensions when using
position-try. This was leftovers from back when the position fallback
was applied at used value time.
Fixes CHECK failure for getComputedStyle on inset properties.
Bug: 40286059
Change-Id: I8e73f28f8fc468a80ba968a0d9fe7b2d7465341e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5419444
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1282343}
diff --git a/third_party/blink/renderer/core/css/properties/computed_style_utils.cc b/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
index 6647d5f..36072a6 100644
--- a/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
+++ b/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
@@ -798,7 +798,7 @@
const auto* box = DynamicTo<LayoutBox>(layout_object);
// In this case, the used value is the computed value, so we resolve directly.
- if (offset.IsFixed() && !style.MayHavePositionFallbackList()) {
+ if (offset.IsFixed()) {
return ZoomAdjustedPixelValueForLength(offset, style);
}
diff --git a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
index f44a803..96aebef 100644
--- a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
+++ b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
@@ -5521,9 +5521,7 @@
bool MarginBottom::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
- return layout_object && layout_object->IsBox() &&
- (!style || !style->MarginBottom().IsFixed() ||
- style->MayHavePositionFallbackList());
+ return layout_object && layout_object->IsBox();
}
const CSSValue* MarginBottom::CSSValueFromComputedStyleInternal(
@@ -5532,8 +5530,7 @@
bool allow_visited_style,
CSSValuePhase value_phase) const {
if (const LayoutBox* box = DynamicTo<LayoutBox>(layout_object)) {
- if (!style.MarginBottom().IsFixed() ||
- style.MayHavePositionFallbackList()) {
+ if (!style.MarginBottom().IsFixed()) {
return ZoomAdjustedPixelValue(box->MarginBottom(), style);
}
}
@@ -5578,8 +5575,7 @@
bool MarginLeft::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
- (!style || !style->MarginLeft().IsFixed() ||
- style->MayHavePositionFallbackList());
+ (!style || !style->MarginLeft().IsFixed());
}
const CSSValue* MarginLeft::CSSValueFromComputedStyleInternal(
@@ -5588,7 +5584,7 @@
bool allow_visited_style,
CSSValuePhase value_phase) const {
if (const LayoutBox* box = DynamicTo<LayoutBox>(layout_object)) {
- if (!style.MarginLeft().IsFixed() || style.MayHavePositionFallbackList()) {
+ if (!style.MarginLeft().IsFixed()) {
return ZoomAdjustedPixelValue(box->MarginLeft(), style);
}
}
@@ -5607,8 +5603,7 @@
bool MarginRight::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
- (!style || !style->MarginRight().IsFixed() ||
- style->MayHavePositionFallbackList());
+ (!style || !style->MarginRight().IsFixed());
}
const CSSValue* MarginRight::CSSValueFromComputedStyleInternal(
@@ -5617,7 +5612,7 @@
bool allow_visited_style,
CSSValuePhase value_phase) const {
if (const LayoutBox* box = DynamicTo<LayoutBox>(layout_object)) {
- if (!style.MarginRight().IsFixed() || style.MayHavePositionFallbackList()) {
+ if (!style.MarginRight().IsFixed()) {
return ZoomAdjustedPixelValue(box->MarginRight(), style);
}
}
@@ -5636,8 +5631,7 @@
bool MarginTop::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
- (!style || !style->MarginTop().IsFixed() ||
- style->MayHavePositionFallbackList());
+ (!style || !style->MarginTop().IsFixed());
}
const CSSValue* MarginTop::CSSValueFromComputedStyleInternal(
@@ -5646,7 +5640,7 @@
bool allow_visited_style,
CSSValuePhase value_phase) const {
if (const LayoutBox* box = DynamicTo<LayoutBox>(layout_object)) {
- if (!style.MarginTop().IsFixed() || style.MayHavePositionFallbackList()) {
+ if (!style.MarginTop().IsFixed()) {
return ZoomAdjustedPixelValue(box->MarginTop(), style);
}
}
diff --git a/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc b/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc
index 3963f1e..ef3ab97 100644
--- a/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc
+++ b/third_party/blink/renderer/core/css/properties/shorthands/shorthands_custom.cc
@@ -2505,8 +2505,7 @@
return layout_object && layout_object->IsBox() &&
(!style || !style->MarginBottom().IsFixed() ||
!style->MarginTop().IsFixed() || !style->MarginLeft().IsFixed() ||
- !style->MarginRight().IsFixed() ||
- style->MayHavePositionFallbackList());
+ !style->MarginRight().IsFixed());
}
const CSSValue* Margin::CSSValueFromComputedStyleInternal(
diff --git a/third_party/blink/renderer/core/style/computed_style.h b/third_party/blink/renderer/core/style/computed_style.h
index d396778..3484ec9 100644
--- a/third_party/blink/renderer/core/style/computed_style.h
+++ b/third_party/blink/renderer/core/style/computed_style.h
@@ -664,13 +664,6 @@
: OutlineType::kDontIncludeBlockInkOverflow;
}
- // position-fallback
-
- // https://drafts.csswg.org/css-anchor-position-1/#position-fallback-list
- bool MayHavePositionFallbackList() const {
- return HasOutOfFlowPosition() && GetPositionTryOptions();
- }
-
// Scroll properties.
PhysicalToLogicalGetter<const Length&, ComputedStyle>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-anchor-position/chrome-40286059-crash.html b/third_party/blink/web_tests/external/wpt/css/css-anchor-position/chrome-40286059-crash.html
new file mode 100644
index 0000000..dbbeb5a
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/css/css-anchor-position/chrome-40286059-crash.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<link rel="help" href="https://crbug.com/40286059">
+<p>Pass if no crash</p>
+<div id="pop" style="position-try-options: --foo" popover></div>
+<script>
+ getComputedStyle(pop).left;
+</script>