Skip to content

Commit 37cbcfe

Browse files
author
Norisz Fay
committed
Backed out changeset 6e5782df6da1 (bug 1668136) for causing wpt failures on content-visibility-vs-scrollIntoView-003.html CLOSED TREE
1 parent 3a02200 commit 37cbcfe

18 files changed

+30
-427
lines changed

dom/base/DOMIntersectionObserver.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -803,16 +803,8 @@ void DOMIntersectionObserver::Update(Document& aDocument,
803803
}
804804
}
805805

806-
// If descendantScrolledIntoView, it means the target is with c-v: auto, and
807-
// the content relevancy value has been set to visible before
808-
// scrollIntoView. Here, we need to generate entries for them, so that the
809-
// content relevancy value could be checked in the callback.
810-
const bool temporarilyVisibleForScrolledIntoView =
811-
isContentVisibilityObserver == IsContentVisibilityObserver::Yes &&
812-
target->TemporarilyVisibleForScrolledIntoViewDescendant();
813806
// Steps 2.10 - 2.15.
814-
if (target->UpdateIntersectionObservation(this, thresholdIndex) ||
815-
temporarilyVisibleForScrolledIntoView) {
807+
if (target->UpdateIntersectionObservation(this, thresholdIndex)) {
816808
// See https://github.com/w3c/IntersectionObserver/issues/432 about
817809
// why we use thresholdIndex > 0 rather than isIntersecting for the
818810
// entry's isIntersecting value.
@@ -821,10 +813,6 @@ void DOMIntersectionObserver::Update(Document& aDocument,
821813
output.mIsSimilarOrigin ? Some(output.mRootBounds) : Nothing(),
822814
output.mTargetRect, output.mIntersectionRect, thresholdIndex > 0,
823815
intersectionRatio);
824-
825-
if (temporarilyVisibleForScrolledIntoView) {
826-
target->SetTemporarilyVisibleForScrolledIntoViewDescendant(false);
827-
}
828816
}
829817
}
830818
}

dom/base/Element.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,20 +1373,9 @@ class Element : public FragmentOrElement {
13731373
if (auto* slots = GetExistingExtendedDOMSlots()) {
13741374
slots->mContentRelevancy.reset();
13751375
slots->mVisibleForContentVisibility.reset();
1376-
slots->mTemporarilyVisibleForScrolledIntoViewDescendant = false;
13771376
}
13781377
}
13791378

1380-
bool TemporarilyVisibleForScrolledIntoViewDescendant() const {
1381-
const auto* slots = GetExistingExtendedDOMSlots();
1382-
return slots && slots->mTemporarilyVisibleForScrolledIntoViewDescendant;
1383-
}
1384-
1385-
void SetTemporarilyVisibleForScrolledIntoViewDescendant(bool aVisible) {
1386-
ExtendedDOMSlots()->mTemporarilyVisibleForScrolledIntoViewDescendant =
1387-
aVisible;
1388-
}
1389-
13901379
// https://drafts.csswg.org/cssom-view-1/#dom-element-checkvisibility
13911380
MOZ_CAN_RUN_SCRIPT bool CheckVisibility(const CheckVisibilityOptions&);
13921381

dom/base/FragmentOrElement.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,6 @@ class FragmentOrElement : public nsIContent {
242242
*/
243243
Maybe<bool> mVisibleForContentVisibility;
244244

245-
/**
246-
* Whether content-visibility: auto is temporarily visible for
247-
* the purposes of the descendant of scrollIntoView.
248-
*/
249-
bool mTemporarilyVisibleForScrolledIntoViewDescendant = false;
250-
251245
/**
252246
* Explicitly set attr-elements, see
253247
* https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#explicitly-set-attr-element

layout/base/PresShell.cpp

Lines changed: 17 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,49 +3533,23 @@ nsresult PresShell::ScrollContentIntoView(nsIContent* aContent,
35333533
mContentToScrollTo = nullptr;
35343534
}
35353535

3536-
// If the target frame has an ancestor of a `content-visibility: auto`
3536+
// If the target frame is an ancestor of a `content-visibility: auto`
35373537
// element ensure that it is laid out, so that the boundary rectangle is
35383538
// correct.
3539-
// Additionally, ensure that all ancestor elements with 'content-visibility:
3540-
// auto' are set to 'visible'. so that they are laid out as visible before
3541-
// scrolling, improving the accuracy of the scroll position, especially when
3542-
// the scroll target is within the overflow area. And here invoking
3543-
// 'SetTemporarilyVisibleForScrolledIntoViewDescendant' would make the
3544-
// intersection observer knows that it should generate entries for these
3545-
// c-v:auto ancestors, so that the content relevancy could be checked again
3546-
// after scrolling. https://drafts.csswg.org/css-contain-2/#cv-notes
3547-
bool reflowedForHiddenContent = false;
35483539
if (mContentToScrollTo) {
35493540
if (nsIFrame* frame = mContentToScrollTo->GetPrimaryFrame()) {
3550-
bool hasContentVisibilityAutoAncestor = false;
3551-
auto* ancestor = frame->GetClosestContentVisibilityAncestor(
3552-
nsIFrame::IncludeContentVisibility::Auto);
3553-
while (ancestor) {
3554-
if (auto* element = Element::FromNodeOrNull(ancestor->GetContent())) {
3555-
hasContentVisibilityAutoAncestor = true;
3556-
element->SetTemporarilyVisibleForScrolledIntoViewDescendant(true);
3557-
element->SetVisibleForContentVisibility(true);
3558-
}
3559-
ancestor = ancestor->GetClosestContentVisibilityAncestor(
3560-
nsIFrame::IncludeContentVisibility::Auto);
3561-
}
3562-
if (hasContentVisibilityAutoAncestor) {
3563-
UpdateHiddenContentInForcedLayout(frame);
3564-
// TODO: There might be the other already scheduled relevancy updates,
3565-
// other than caused be scrollIntoView.
3566-
UpdateContentRelevancyImmediately(ContentRelevancyReason::Visible);
3567-
reflowedForHiddenContent = ReflowForHiddenContentIfNeeded();
3541+
if (frame->IsHiddenByContentVisibilityOnAnyAncestor(
3542+
nsIFrame::IncludeContentVisibility::Auto)) {
3543+
frame->PresShell()->EnsureReflowIfFrameHasHiddenContent(frame);
35683544
}
35693545
}
35703546
}
35713547

3572-
if (!reflowedForHiddenContent) {
3573-
// Flush layout and attempt to scroll in the process.
3574-
if (PresShell* presShell = composedDoc->GetPresShell()) {
3575-
presShell->SetNeedLayoutFlush();
3576-
}
3577-
composedDoc->FlushPendingNotifications(FlushType::InterruptibleLayout);
3548+
// Flush layout and attempt to scroll in the process.
3549+
if (PresShell* presShell = composedDoc->GetPresShell()) {
3550+
presShell->SetNeedLayoutFlush();
35783551
}
3552+
composedDoc->FlushPendingNotifications(FlushType::InterruptibleLayout);
35793553

35803554
// If mContentToScrollTo is non-null, that means we interrupted the reflow
35813555
// (or suppressed it altogether because we're suppressing interruptible
@@ -11876,21 +11850,18 @@ bool PresShell::GetZoomableByAPZ() const {
1187611850
return mZoomConstraintsClient && mZoomConstraintsClient->GetAllowZoom();
1187711851
}
1187811852

11879-
bool PresShell::ReflowForHiddenContentIfNeeded() {
11880-
if (mHiddenContentInForcedLayout.IsEmpty()) {
11881-
return false;
11882-
}
11883-
mDocument->FlushPendingNotifications(FlushType::Layout);
11884-
mHiddenContentInForcedLayout.Clear();
11885-
return true;
11886-
}
11887-
11888-
void PresShell::UpdateHiddenContentInForcedLayout(nsIFrame* aFrame) {
11853+
void PresShell::EnsureReflowIfFrameHasHiddenContent(nsIFrame* aFrame) {
1188911854
if (!aFrame || !aFrame->IsSubtreeDirty() ||
1189011855
!StaticPrefs::layout_css_content_visibility_enabled()) {
1189111856
return;
1189211857
}
1189311858

11859+
// Flushing notifications below might trigger more layouts, which might,
11860+
// in turn, trigger layout of other hidden content. We keep a local set
11861+
// of hidden content we are laying out to handle recursive calls.
11862+
nsTHashSet<nsIContent*> hiddenContentInForcedLayout;
11863+
11864+
MOZ_ASSERT(mHiddenContentInForcedLayout.IsEmpty());
1189411865
nsIFrame* topmostFrameWithContentHidden = nullptr;
1189511866
for (nsIFrame* cur = aFrame->GetInFlowParent(); cur;
1189611867
cur = cur->GetInFlowParent()) {
@@ -11908,13 +11879,9 @@ void PresShell::UpdateHiddenContentInForcedLayout(nsIFrame* aFrame) {
1190811879
MOZ_ASSERT(topmostFrameWithContentHidden);
1190911880
FrameNeedsReflow(topmostFrameWithContentHidden, IntrinsicDirty::None,
1191011881
NS_FRAME_IS_DIRTY);
11911-
}
11912-
11913-
void PresShell::EnsureReflowIfFrameHasHiddenContent(nsIFrame* aFrame) {
11914-
MOZ_ASSERT(mHiddenContentInForcedLayout.IsEmpty());
11882+
mDocument->FlushPendingNotifications(FlushType::Layout);
1191511883

11916-
UpdateHiddenContentInForcedLayout(aFrame);
11917-
ReflowForHiddenContentIfNeeded();
11884+
mHiddenContentInForcedLayout.Clear();
1191811885
}
1191911886

1192011887
bool PresShell::IsForcingLayoutForHiddenContent(const nsIFrame* aFrame) const {
@@ -11945,15 +11912,3 @@ void PresShell::ScheduleContentRelevancyUpdate(ContentRelevancyReason aReason) {
1194511912
presContext->RefreshDriver()->EnsureContentRelevancyUpdateHappens();
1194611913
}
1194711914
}
11948-
11949-
void PresShell::UpdateContentRelevancyImmediately(
11950-
ContentRelevancyReason aReason) {
11951-
if (MOZ_UNLIKELY(mIsDestroying)) {
11952-
return;
11953-
}
11954-
11955-
mContentVisibilityRelevancyToUpdate += aReason;
11956-
11957-
SetNeedLayoutFlush();
11958-
UpdateRelevancyOfContentVisibilityAutoFrames();
11959-
}

layout/base/PresShell.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,8 +1729,6 @@ class PresShell final : public nsStubDocumentObserver,
17291729

17301730
bool GetZoomableByAPZ() const;
17311731

1732-
bool ReflowForHiddenContentIfNeeded();
1733-
void UpdateHiddenContentInForcedLayout(nsIFrame*);
17341732
/**
17351733
* If this frame has content hidden via `content-visibilty` that has a pending
17361734
* reflow, force the content to reflow immediately.
@@ -1749,7 +1747,6 @@ class PresShell final : public nsStubDocumentObserver,
17491747

17501748
void UpdateRelevancyOfContentVisibilityAutoFrames();
17511749
void ScheduleContentRelevancyUpdate(ContentRelevancyReason aReason);
1752-
void UpdateContentRelevancyImmediately(ContentRelevancyReason aReason);
17531750

17541751
private:
17551752
~PresShell();

layout/generic/nsIFrame.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6924,18 +6924,18 @@ bool nsIFrame::IsHiddenByContentVisibilityOfInFlowParentForLayout() const {
69246924
Style()->IsAnonBox());
69256925
}
69266926

6927-
nsIFrame* nsIFrame::GetClosestContentVisibilityAncestor(
6927+
bool nsIFrame::IsHiddenByContentVisibilityOnAnyAncestor(
69286928
const EnumSet<IncludeContentVisibility>& aInclude) const {
69296929
if (!StaticPrefs::layout_css_content_visibility_enabled()) {
6930-
return nullptr;
6930+
return false;
69316931
}
69326932

69336933
auto* parent = GetInFlowParent();
69346934
bool isAnonymousBlock = Style()->IsAnonBox() && parent &&
69356935
parent->HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES);
69366936
for (nsIFrame* cur = parent; cur; cur = cur->GetInFlowParent()) {
69376937
if (!isAnonymousBlock && cur->HidesContent(aInclude)) {
6938-
return cur;
6938+
return true;
69396939
}
69406940

69416941
// Anonymous boxes are not hidden by the content-visibility of their first
@@ -6944,12 +6944,7 @@ nsIFrame* nsIFrame::GetClosestContentVisibilityAncestor(
69446944
isAnonymousBlock = false;
69456945
}
69466946

6947-
return nullptr;
6948-
}
6949-
6950-
bool nsIFrame::IsHiddenByContentVisibilityOnAnyAncestor(
6951-
const EnumSet<IncludeContentVisibility>& aInclude) const {
6952-
return !!GetClosestContentVisibilityAncestor(aInclude);
6947+
return false;
69536948
}
69546949

69556950
bool nsIFrame::HasSelectionInSubtree() {

layout/generic/nsIFrame.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,14 +3220,6 @@ class nsIFrame : public nsQueryFrame {
32203220
*/
32213221
bool HidesContentForLayout() const;
32223222

3223-
/**
3224-
* returns the closest ancestor with `content-visibility` property.
3225-
* @param aInclude specifies what kind of `content-visibility` to include.
3226-
*/
3227-
nsIFrame* GetClosestContentVisibilityAncestor(
3228-
const mozilla::EnumSet<IncludeContentVisibility>& =
3229-
IncludeAllContentVisibility()) const;
3230-
32313223
/**
32323224
* Returns true if this frame is entirely hidden due the `content-visibility`
32333225
* property on an ancestor.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[content-visibility-058.html]
2+
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1797467
3+
expected: FAIL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[content-visibility-064.html]
2+
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1800868
3+
expected: FAIL
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[content-visibility-075.html]
2-
fuzzy: # Tiny pixels differ around the scrollbar thumb.
3-
if (os == "mac"): maxDifference=19;totalPixels=26
2+
expected: FAIL
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[content-visibility-076.html]
2-
fuzzy: # Tiny pixels differ around the scrollbar thumb.
3-
if (os == "mac"): maxDifference=19;totalPixels=26
2+
expected: [FAIL, PASS]

testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-vs-scrollIntoView-001.html.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

testing/web-platform/meta/css/css-contain/content-visibility/content-visibility-vs-scrollIntoView-003.html.ini

Lines changed: 0 additions & 6 deletions
This file was deleted.

testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-vs-scrollIntoView-001-ref.html

Lines changed: 0 additions & 41 deletions
This file was deleted.

testing/web-platform/tests/css/css-contain/content-visibility/content-visibility-vs-scrollIntoView-001.html

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)