Skip to content

Commit bc30450

Browse files
author
agoloman
committed
Revert (Bug 1962598, Bug 1992124): for causing wpt failures.
This reverts commit 13f5267. Revert "Bug 1962598 - Implement full @position-try fallback for anchor positioning. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin" This reverts commit 9903a17. Revert "Bug 1992124 - Ignore invalid @position-try rules. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin" This reverts commit bf0542d. Revert "Bug 1962598 - Add some missing expectations that I forgot to git add." This reverts commit c7e03c9.
1 parent 927298a commit bc30450

File tree

44 files changed

+179
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+179
-424
lines changed

layout/generic/AbsoluteContainingBlock.cpp

Lines changed: 27 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -835,25 +835,6 @@ void AbsoluteContainingBlock::ResolveAutoMarginsAfterLayout(
835835
}
836836
}
837837

838-
struct MOZ_STACK_CLASS MOZ_RAII AutoFallbackStyleSetter {
839-
AutoFallbackStyleSetter(nsIFrame* aFrame, ComputedStyle* aFallbackStyle)
840-
: mFrame(aFrame) {
841-
if (aFallbackStyle) {
842-
mOldStyle = aFrame->SetComputedStyleWithoutNotification(aFallbackStyle);
843-
}
844-
}
845-
846-
~AutoFallbackStyleSetter() {
847-
if (mOldStyle) {
848-
mFrame->SetComputedStyleWithoutNotification(std::move(mOldStyle));
849-
}
850-
}
851-
852-
private:
853-
nsIFrame* const mFrame;
854-
RefPtr<ComputedStyle> mOldStyle;
855-
};
856-
857838
// XXX Optimize the case where it's a resize reflow and the absolutely
858839
// positioned child has the exact same size and position and skip the
859840
// reflow...
@@ -891,9 +872,9 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
891872
#endif // DEBUG
892873

893874
const bool isGrid = aFlags.contains(AbsPosReflowFlag::IsGridContainerCB);
875+
const auto* stylePos = aKidFrame->StylePosition();
894876
// TODO(bug 1989059): position-try-order.
895-
auto fallbacks =
896-
aKidFrame->StylePosition()->mPositionTryFallbacks._0.AsSpan();
877+
auto fallbacks = stylePos->mPositionTryFallbacks._0.AsSpan();
897878
Maybe<uint32_t> currentFallbackIndex;
898879
// TODO(emilio): Right now fallback only applies to position-area, which only
899880
// makes a difference with a default anchor... Generalize it?
@@ -912,59 +893,33 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
912893
}
913894
}
914895
}
915-
const StylePositionTryFallbacksItem* currentFallback = nullptr;
916-
RefPtr<ComputedStyle> currentFallbackStyle;
917-
918-
auto TryAdvanceFallback = [&]() -> bool {
919-
if (fallbacks.IsEmpty()) {
920-
return false;
921-
}
922-
uint32_t nextFallbackIndex =
923-
currentFallbackIndex ? *currentFallbackIndex + 1 : 0;
924-
if (nextFallbackIndex >= fallbacks.Length()) {
925-
return false;
926-
}
927-
const StylePositionTryFallbacksItem* nextFallback;
928-
RefPtr<ComputedStyle> nextFallbackStyle;
929-
while (true) {
930-
nextFallback = &fallbacks[nextFallbackIndex];
931-
if (nextFallback->IsIdentAndOrTactic()) {
932-
auto* ident = nextFallback->AsIdentAndOrTactic().ident.AsAtom();
933-
if (!ident->IsEmpty()) {
934-
nextFallbackStyle = aPresContext->StyleSet()->ResolvePositionTry(
935-
*aKidFrame->GetContent()->AsElement(), *aKidFrame->Style(),
936-
ident);
937-
if (!nextFallbackStyle) {
938-
// No @position-try rule for this name was found, per spec we should
939-
// skip it.
940-
nextFallbackIndex++;
941-
if (nextFallbackIndex >= fallbacks.Length()) {
942-
return false;
943-
}
944-
}
945-
}
946-
}
947-
break;
896+
do {
897+
const StylePositionTryFallbacksItem* currentFallback = nullptr;
898+
RefPtr<ComputedStyle> currentFallbackStyle;
899+
if (currentFallbackIndex) {
900+
currentFallback = &fallbacks[*currentFallbackIndex];
948901
}
949-
currentFallbackIndex = Some(nextFallbackIndex);
950-
currentFallback = nextFallback;
951-
currentFallbackStyle = std::move(nextFallbackStyle);
952-
return true;
953-
};
954902

955-
do {
956-
AutoFallbackStyleSetter fallback(aKidFrame, currentFallbackStyle);
957903
const nsRect usedCb = [&] {
958904
if (isGrid) {
959905
// TODO(emilio): how does position-area interact with grid?
960906
return nsGridContainerFrame::GridItemCB(aKidFrame);
961907
}
962908

963-
auto positionArea = aKidFrame->StylePosition()->mPositionArea;
909+
auto positionArea = stylePos->mPositionArea;
964910
const StylePositionTryFallbacksTryTactic* tactic = nullptr;
965911
if (currentFallback) {
966912
if (currentFallback->IsIdentAndOrTactic()) {
967913
const auto& item = currentFallback->AsIdentAndOrTactic();
914+
if (!item.ident.AsAtom()->IsEmpty()) {
915+
currentFallbackStyle = aPresContext->StyleSet()->ResolvePositionTry(
916+
*aKidFrame->GetContent()->AsElement(), *aKidFrame->Style(),
917+
item.ident.AsAtom());
918+
if (currentFallbackStyle) {
919+
positionArea =
920+
currentFallbackStyle->StylePosition()->mPositionArea;
921+
}
922+
}
968923
tactic = &item.try_tactic;
969924
} else {
970925
MOZ_ASSERT(currentFallback->IsPositionArea());
@@ -1204,18 +1159,21 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
12041159

12051160
aKidFrame->DidReflow(aPresContext, &kidReflowInput);
12061161

1207-
if (usedCb.Contains(aKidFrame->GetRect()) && aStatus.IsComplete()) {
1208-
// We don't overflow our CB, no further fallback needed.
1209-
break;
1210-
}
1211-
1212-
if (!TryAdvanceFallback()) {
1213-
// If there are no further fallbacks, we're done.
1162+
if (fallbacks.IsEmpty() ||
1163+
(currentFallbackIndex &&
1164+
*currentFallbackIndex >= fallbacks.Length() - 1) ||
1165+
(usedCb.Contains(aKidFrame->GetRect()) && aStatus.IsComplete())) {
1166+
// If there are no further fallbacks, or we don't overflow, we're done.
12141167
break;
12151168
}
12161169

12171170
// Try with the next fallback.
12181171
aKidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
1172+
if (currentFallbackIndex) {
1173+
(*currentFallbackIndex)++;
1174+
} else {
1175+
currentFallbackIndex.emplace(0);
1176+
}
12191177
aStatus.Reset();
12201178
} while (true);
12211179

layout/generic/nsIFrame.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -957,16 +957,15 @@ class nsIFrame : public nsQueryFrame {
957957
}
958958

959959
/**
960-
* SetComputedStyleWithoutNotification is for changes to the style that should
961-
* suppress style change processing, in other words, those that aren't really
962-
* changes. This generally means only changes that happen during frame
963-
* construction, or those that get handled out of band, like @position-try
964-
* fallback.
965-
* @return the old style.
966-
*/
967-
RefPtr<ComputedStyle> SetComputedStyleWithoutNotification(
968-
RefPtr<ComputedStyle> aStyle) {
969-
return std::exchange(mComputedStyle, std::move(aStyle));
960+
* SetComputedStyleWithoutNotification is for changes to the style
961+
* context that should suppress style change processing, in other
962+
* words, those that aren't really changes. This generally means only
963+
* changes that happen during frame construction.
964+
*/
965+
void SetComputedStyleWithoutNotification(ComputedStyle* aStyle) {
966+
if (aStyle != mComputedStyle) {
967+
mComputedStyle = aStyle;
968+
}
970969
}
971970

972971
protected:

testing/web-platform/meta/css/css-anchor-position/anchor-center-fallback-transition-behavior.html.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[anchor-invalid-fallback.html]
2+
[Flip to invalid anchor()]
3+
expected: FAIL
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[anchor-scroll-chained-fallback.html]
2+
expected: FAIL

testing/web-platform/meta/css/css-anchor-position/anchor-scroll-position-try-001.html.ini

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
[anchor-scroll-position-try-001.html]
22
[Scroll down until the top edge of #anchor touches container but not overflowing]
3-
expected: [PASS, FAIL]
3+
expected:
4+
[PASS, FAIL]
45

56
[Scroll further up, where the second option no longer fits]
6-
expected: [PASS, FAIL]
7+
expected:
8+
[PASS, FAIL]
9+
10+
[Scroll further down, making the first fallback position overflow by 1px]
11+
expected: FAIL
712

813
[Scroll back up so that both the first and second options fit.]
914
expected: FAIL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[anchor-scroll-position-try-002.html]
2+
[Should use the second fallback position after scrolling left]
3+
expected: FAIL

testing/web-platform/meta/css/css-anchor-position/anchor-scroll-position-try-004.html.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[anchor-scroll-position-try-004.html]
2+
[Should use the second fallback position after scrolling viewport down]
3+
expected: FAIL
4+
25
[Should use the third fallback position after scrolling the vrl scroller left]
36
expected:
47
if os == "android": [PASS, FAIL]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[anchor-scroll-position-try-005.html]
2+
[Should use the second fallback position after scrolling left]
3+
expected: FAIL

testing/web-platform/meta/css/css-anchor-position/anchor-scroll-position-try-006.html.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[anchor-scroll-position-try-006.html]
2+
[Should use the last (fourth) position option initially]
3+
expected: FAIL
4+
25
[Should still use the last position option as long as it fits.]
36
expected: FAIL
47

0 commit comments

Comments
 (0)