2018-11-28 00:18:03 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "ScrollAnchorContainer.h"
|
|
|
|
|
2019-01-11 21:21:09 +03:00
|
|
|
#include "mozilla/dom/Text.h"
|
2019-04-06 09:02:28 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
Bug 1691589 - Reduce reliance on GeckoProfiler.h when only labels (and maybe markers) are needed - r=necko-reviewers,geckoview-reviewers,sg,agi,florian
There are no code changes, only #include changes.
It was a fairly mechanical process: Search for all "AUTO_PROFILER_LABEL", and in each file, if only labels are used, convert "GeckoProfiler.h" into "ProfilerLabels.h" (or just add that last one where needed).
In some files, there were also some marker calls but no other profiler-related calls, in these cases "GeckoProfiler.h" was replaced with both "ProfilerLabels.h" and "ProfilerMarkers.h", which still helps in reducing the use of the all-encompassing "GeckoProfiler.h".
Differential Revision: https://phabricator.services.mozilla.com/D104588
2021-02-16 07:44:19 +03:00
|
|
|
#include "mozilla/ProfilerLabels.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_layout.h"
|
2019-01-22 22:37:16 +03:00
|
|
|
#include "mozilla/ToString.h"
|
2019-04-02 23:06:52 +03:00
|
|
|
#include "nsBlockFrame.h"
|
2018-11-28 00:18:03 +03:00
|
|
|
#include "nsGfxScrollFrame.h"
|
2019-04-02 23:06:52 +03:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIFrameInlines.h"
|
2018-11-28 00:18:03 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2019-04-02 23:06:52 +03:00
|
|
|
#include "nsPlaceholderFrame.h"
|
|
|
|
|
|
|
|
using namespace mozilla::dom;
|
2018-11-28 00:18:03 +03:00
|
|
|
|
2020-06-15 15:38:27 +03:00
|
|
|
static mozilla::LazyLogModule sAnchorLog("scrollanchor");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
# define ANCHOR_LOG(fmt, ...) \
|
|
|
|
MOZ_LOG(sAnchorLog, LogLevel::Debug, \
|
|
|
|
("ANCHOR(%p, %s, root: %d): " fmt, this, \
|
|
|
|
Frame() \
|
|
|
|
->PresContext() \
|
|
|
|
->Document() \
|
|
|
|
->GetDocumentURI() \
|
|
|
|
->GetSpecOrDefault() \
|
|
|
|
.get(), \
|
|
|
|
mScrollFrame->mIsRoot, ##__VA_ARGS__));
|
|
|
|
#else
|
|
|
|
# define ANCHOR_LOG(...)
|
|
|
|
#endif
|
2018-11-28 00:18:03 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layout {
|
|
|
|
|
|
|
|
ScrollAnchorContainer::ScrollAnchorContainer(ScrollFrameHelper* aScrollFrame)
|
2018-11-28 00:45:16 +03:00
|
|
|
: mScrollFrame(aScrollFrame),
|
|
|
|
mAnchorNode(nullptr),
|
2019-01-17 00:13:12 +03:00
|
|
|
mLastAnchorOffset(0),
|
2019-10-31 12:25:08 +03:00
|
|
|
mDisabled(false),
|
2018-12-21 19:26:10 +03:00
|
|
|
mAnchorNodeIsDirty(true),
|
2018-11-28 00:38:43 +03:00
|
|
|
mApplyingAnchorAdjustment(false),
|
|
|
|
mSuppressAnchorAdjustment(false) {}
|
2018-11-28 00:18:03 +03:00
|
|
|
|
2020-03-17 12:38:32 +03:00
|
|
|
ScrollAnchorContainer::~ScrollAnchorContainer() = default;
|
2018-11-28 00:18:03 +03:00
|
|
|
|
|
|
|
ScrollAnchorContainer* ScrollAnchorContainer::FindFor(nsIFrame* aFrame) {
|
|
|
|
aFrame = aFrame->GetParent();
|
|
|
|
if (!aFrame) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsIScrollableFrame* nearest = nsLayoutUtils::GetNearestScrollableFrame(
|
|
|
|
aFrame, nsLayoutUtils::SCROLLABLE_SAME_DOC |
|
|
|
|
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
|
|
|
|
if (nearest) {
|
2019-02-15 04:25:55 +03:00
|
|
|
return nearest->Anchor();
|
2018-11-28 00:18:03 +03:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* ScrollAnchorContainer::Frame() const { return mScrollFrame->mOuter; }
|
|
|
|
|
|
|
|
nsIScrollableFrame* ScrollAnchorContainer::ScrollableFrame() const {
|
|
|
|
return Frame()->GetScrollTargetFrame();
|
|
|
|
}
|
|
|
|
|
2018-11-28 00:45:16 +03:00
|
|
|
/**
|
|
|
|
* Set the appropriate frame flags for a frame that has become or is no longer
|
|
|
|
* an anchor node.
|
|
|
|
*/
|
|
|
|
static void SetAnchorFlags(const nsIFrame* aScrolledFrame,
|
|
|
|
nsIFrame* aAnchorNode, bool aInScrollAnchorChain) {
|
|
|
|
nsIFrame* frame = aAnchorNode;
|
|
|
|
while (frame && frame != aScrolledFrame) {
|
2020-04-13 23:58:14 +03:00
|
|
|
// TODO(emilio, bug 1629280): This commented out assertion below should
|
|
|
|
// hold, but it may not in the case of reparenting-during-reflow (due to
|
|
|
|
// inline fragmentation or such). That looks fishy!
|
|
|
|
//
|
|
|
|
// We should either invalidate the anchor when reparenting any frame on the
|
|
|
|
// chain, or fix up the chain flags.
|
|
|
|
//
|
|
|
|
// MOZ_DIAGNOSTIC_ASSERT(frame->IsInScrollAnchorChain() !=
|
|
|
|
// aInScrollAnchorChain);
|
2018-11-28 00:45:16 +03:00
|
|
|
frame->SetInScrollAnchorChain(aInScrollAnchorChain);
|
|
|
|
frame = frame->GetParent();
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(frame,
|
2020-04-13 23:58:14 +03:00
|
|
|
"The anchor node should be a descendant of the scrolled frame");
|
2018-11-28 00:40:57 +03:00
|
|
|
// If needed, invalidate the frame so that we start/stop highlighting the
|
|
|
|
// anchor
|
|
|
|
if (StaticPrefs::layout_css_scroll_anchoring_highlight()) {
|
|
|
|
for (nsIFrame* frame = aAnchorNode->FirstContinuation(); !!frame;
|
|
|
|
frame = frame->GetNextContinuation()) {
|
|
|
|
frame->InvalidateFrame();
|
|
|
|
}
|
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the scrollable overflow rect [1] of aCandidate relative to
|
2019-01-17 00:13:12 +03:00
|
|
|
* aScrollFrame with all transforms applied.
|
|
|
|
*
|
|
|
|
* The specification is ambiguous about what can be selected as a scroll anchor,
|
|
|
|
* which makes the scroll anchoring bounding rect partially undefined [2]. This
|
|
|
|
* code attempts to match the implementation in Blink.
|
|
|
|
*
|
|
|
|
* An additional unspecified behavior is that any scrollable overflow before the
|
|
|
|
* border start edge in the block axis of aScrollFrame should be clamped. This
|
|
|
|
* is to prevent absolutely positioned descendant elements from being able to
|
|
|
|
* trigger scroll adjustments [3].
|
2018-11-28 00:45:16 +03:00
|
|
|
*
|
|
|
|
* [1]
|
|
|
|
* https://drafts.csswg.org/css-scroll-anchoring-1/#scroll-anchoring-bounding-rect
|
|
|
|
* [2] https://github.com/w3c/csswg-drafts/issues/3478
|
2019-01-17 00:13:12 +03:00
|
|
|
* [3] https://bugzilla.mozilla.org/show_bug.cgi?id=1519541
|
2018-11-28 00:45:16 +03:00
|
|
|
*/
|
|
|
|
static nsRect FindScrollAnchoringBoundingRect(const nsIFrame* aScrollFrame,
|
|
|
|
nsIFrame* aCandidate) {
|
|
|
|
MOZ_ASSERT(nsLayoutUtils::IsProperAncestorFrame(aScrollFrame, aCandidate));
|
2019-01-11 21:21:09 +03:00
|
|
|
if (!!Text::FromNodeOrNull(aCandidate->GetContent())) {
|
2019-01-30 17:42:58 +03:00
|
|
|
// This is a frame for a text node. The spec says we need to accumulate the
|
|
|
|
// union of all line boxes in the coordinate space of the scroll frame
|
|
|
|
// accounting for transforms.
|
|
|
|
//
|
|
|
|
// To do this, we translate and accumulate the overflow rect for each text
|
|
|
|
// continuation to the coordinate space of the nearest ancestor block
|
|
|
|
// frame. Then we transform the resulting rect into the coordinate space of
|
|
|
|
// the scroll frame.
|
|
|
|
//
|
|
|
|
// Transforms aren't allowed on non-replaced inline boxes, so we can assume
|
|
|
|
// that these text node continuations will have the same transform as their
|
|
|
|
// nearest block ancestor. And it should be faster to transform their union
|
|
|
|
// rather than individually transforming each overflow rect
|
|
|
|
//
|
|
|
|
// XXX for fragmented blocks, blockAncestor will be an ancestor only to the
|
|
|
|
// text continuations in the first block continuation. GetOffsetTo
|
|
|
|
// should continue to work, but is it correct with transforms or a
|
|
|
|
// performance hazard?
|
|
|
|
nsIFrame* blockAncestor =
|
|
|
|
nsLayoutUtils::FindNearestBlockAncestor(aCandidate);
|
|
|
|
MOZ_ASSERT(
|
|
|
|
nsLayoutUtils::IsProperAncestorFrame(aScrollFrame, blockAncestor));
|
2018-11-28 00:45:16 +03:00
|
|
|
nsRect bounding;
|
|
|
|
for (nsIFrame* continuation = aCandidate->FirstContinuation(); continuation;
|
|
|
|
continuation = continuation->GetNextContinuation()) {
|
2019-01-17 00:13:12 +03:00
|
|
|
nsRect overflowRect =
|
2020-07-20 23:17:36 +03:00
|
|
|
continuation->ScrollableOverflowRectRelativeToSelf();
|
2019-01-30 17:42:58 +03:00
|
|
|
overflowRect += continuation->GetOffsetTo(blockAncestor);
|
|
|
|
bounding = bounding.Union(overflowRect);
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
2019-01-30 17:42:58 +03:00
|
|
|
return nsLayoutUtils::TransformFrameRectToAncestor(blockAncestor, bounding,
|
|
|
|
aScrollFrame);
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
nsRect borderRect = aCandidate->GetRectRelativeToSelf();
|
2020-07-20 23:17:36 +03:00
|
|
|
nsRect overflowRect = aCandidate->ScrollableOverflowRectRelativeToSelf();
|
2019-01-16 02:25:17 +03:00
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
NS_ASSERTION(overflowRect.Contains(borderRect),
|
|
|
|
"overflow rect must include border rect, and the clamping logic "
|
|
|
|
"here depends on that");
|
|
|
|
|
|
|
|
// Clamp the scrollable overflow rect to the border start edge on the block
|
|
|
|
// axis of the scroll frame
|
|
|
|
WritingMode writingMode = aScrollFrame->GetWritingMode();
|
|
|
|
switch (writingMode.GetBlockDir()) {
|
|
|
|
case WritingMode::eBlockTB: {
|
|
|
|
overflowRect.SetBoxY(borderRect.Y(), overflowRect.YMost());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WritingMode::eBlockLR: {
|
|
|
|
overflowRect.SetBoxX(borderRect.X(), overflowRect.XMost());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WritingMode::eBlockRL: {
|
|
|
|
overflowRect.SetBoxX(overflowRect.X(), borderRect.XMost());
|
|
|
|
break;
|
|
|
|
}
|
2019-01-16 02:25:17 +03:00
|
|
|
}
|
2019-01-17 00:13:12 +03:00
|
|
|
|
2018-11-28 00:45:16 +03:00
|
|
|
nsRect transformed = nsLayoutUtils::TransformFrameRectToAncestor(
|
2019-01-17 00:13:12 +03:00
|
|
|
aCandidate, overflowRect, aScrollFrame);
|
2018-11-28 00:45:16 +03:00
|
|
|
return transformed;
|
|
|
|
}
|
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
/**
|
|
|
|
* Compute the offset between the scrollable overflow rect start edge of
|
|
|
|
* aCandidate and the scroll-port start edge of aScrollFrame, in the block axis
|
|
|
|
* of aScrollFrame.
|
|
|
|
*/
|
|
|
|
static nscoord FindScrollAnchoringBoundingOffset(
|
|
|
|
const ScrollFrameHelper* aScrollFrame, nsIFrame* aCandidate) {
|
|
|
|
WritingMode writingMode = aScrollFrame->mOuter->GetWritingMode();
|
|
|
|
nsRect physicalBounding =
|
|
|
|
FindScrollAnchoringBoundingRect(aScrollFrame->mOuter, aCandidate);
|
|
|
|
LogicalRect logicalBounding(writingMode, physicalBounding,
|
|
|
|
aScrollFrame->mScrolledFrame->GetSize());
|
|
|
|
return logicalBounding.BStart(writingMode);
|
|
|
|
}
|
|
|
|
|
2020-04-13 23:58:14 +03:00
|
|
|
bool ScrollAnchorContainer::CanMaintainAnchor() const {
|
|
|
|
if (!StaticPrefs::layout_css_scroll_anchoring_enabled()) {
|
|
|
|
return false;
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
|
2020-04-13 23:58:14 +03:00
|
|
|
// If we've been disabled due to heuristics, we don't anchor anymore.
|
|
|
|
if (mDisabled) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
|
2020-04-13 23:58:14 +03:00
|
|
|
const nsStyleDisplay& disp = *Frame()->StyleDisplay();
|
2018-11-28 00:45:16 +03:00
|
|
|
// Don't select a scroll anchor if the scroll frame has `overflow-anchor:
|
|
|
|
// none`.
|
2020-04-13 23:58:14 +03:00
|
|
|
if (disp.mOverflowAnchor != mozilla::StyleOverflowAnchor::Auto) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
|
|
|
|
// Or if the scroll frame has not been scrolled from the logical origin. This
|
|
|
|
// is not in the specification [1], but Blink does this.
|
|
|
|
//
|
|
|
|
// [1] https://github.com/w3c/csswg-drafts/issues/3319
|
2020-04-13 23:58:14 +03:00
|
|
|
if (mScrollFrame->GetLogicalScrollPosition() == nsPoint()) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
|
|
|
|
// Or if there is perspective that could affect the scrollable overflow rect
|
|
|
|
// for descendant frames. This is not in the specification as Blink doesn't
|
|
|
|
// share this behavior with perspective [1].
|
|
|
|
//
|
|
|
|
// [1] https://github.com/w3c/csswg-drafts/issues/3322
|
2020-04-13 23:58:14 +03:00
|
|
|
if (Frame()->ChildrenHavePerspective()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollAnchorContainer::SelectAnchor() {
|
|
|
|
MOZ_ASSERT(mScrollFrame->mScrolledFrame);
|
|
|
|
MOZ_ASSERT(mAnchorNodeIsDirty);
|
|
|
|
|
|
|
|
AUTO_PROFILER_LABEL("ScrollAnchorContainer::SelectAnchor", LAYOUT);
|
|
|
|
ANCHOR_LOG(
|
|
|
|
"Selecting anchor with scroll-port=%s.\n",
|
|
|
|
mozilla::ToString(mScrollFrame->GetVisualOptimalViewingRect()).c_str());
|
2018-11-28 00:45:16 +03:00
|
|
|
|
|
|
|
// Select a new scroll anchor
|
|
|
|
nsIFrame* oldAnchor = mAnchorNode;
|
2020-04-13 23:58:14 +03:00
|
|
|
if (CanMaintainAnchor()) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(
|
|
|
|
!mScrollFrame->mScrolledFrame->IsInScrollAnchorChain(),
|
|
|
|
"Our scrolled frame can't serve as or contain an anchor for an "
|
|
|
|
"ancestor if it can maintain its own anchor");
|
|
|
|
ANCHOR_LOG("Beginning selection.\n");
|
2018-11-28 00:45:16 +03:00
|
|
|
mAnchorNode = FindAnchorIn(mScrollFrame->mScrolledFrame);
|
|
|
|
} else {
|
2020-05-20 02:15:10 +03:00
|
|
|
ANCHOR_LOG("Skipping selection, doesn't maintain a scroll anchor.\n");
|
2018-11-28 00:45:16 +03:00
|
|
|
mAnchorNode = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the anchor flags if needed
|
|
|
|
if (oldAnchor != mAnchorNode) {
|
|
|
|
ANCHOR_LOG("Anchor node has changed from (%p) to (%p).\n", oldAnchor,
|
|
|
|
mAnchorNode);
|
|
|
|
|
|
|
|
// Unset all flags for the old scroll anchor
|
|
|
|
if (oldAnchor) {
|
|
|
|
SetAnchorFlags(mScrollFrame->mScrolledFrame, oldAnchor, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set all flags for the new scroll anchor
|
|
|
|
if (mAnchorNode) {
|
2020-04-13 23:58:14 +03:00
|
|
|
// Anchor selection will never select a descendant of a nested scroll
|
|
|
|
// frame which maintains an anchor, so we can set flags without
|
|
|
|
// conflicting with other scroll anchor containers.
|
2018-11-28 00:45:16 +03:00
|
|
|
SetAnchorFlags(mScrollFrame->mScrolledFrame, mAnchorNode, true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ANCHOR_LOG("Anchor node has remained (%p).\n", mAnchorNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the position to use for scroll adjustments
|
|
|
|
if (mAnchorNode) {
|
2019-01-17 00:13:12 +03:00
|
|
|
mLastAnchorOffset =
|
|
|
|
FindScrollAnchoringBoundingOffset(mScrollFrame, mAnchorNode);
|
|
|
|
ANCHOR_LOG("Using last anchor offset = %d.\n", mLastAnchorOffset);
|
2018-11-28 00:45:16 +03:00
|
|
|
} else {
|
2019-01-17 00:13:12 +03:00
|
|
|
mLastAnchorOffset = 0;
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mAnchorNodeIsDirty = false;
|
|
|
|
}
|
|
|
|
|
2018-12-21 19:26:10 +03:00
|
|
|
void ScrollAnchorContainer::UserScrolled() {
|
|
|
|
if (mApplyingAnchorAdjustment) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
InvalidateAnchor();
|
2019-10-31 12:25:08 +03:00
|
|
|
mConsecutiveScrollAnchoringAdjustments = SaturateUint32(0);
|
|
|
|
mConsecutiveScrollAnchoringAdjustmentLength = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollAnchorContainer::AdjustmentMade(nscoord aAdjustment) {
|
|
|
|
// A reasonably large number of times that we want to check for this. If we
|
|
|
|
// haven't hit this limit after these many attempts we assume we'll never hit
|
|
|
|
// it.
|
|
|
|
//
|
|
|
|
// This is to prevent the number getting too large and making the limit round
|
|
|
|
// to zero by mere precision error.
|
|
|
|
//
|
|
|
|
// 100k should be enough for anyone :)
|
|
|
|
static const uint32_t kAnchorCheckCountLimit = 100000;
|
|
|
|
|
|
|
|
// Zero-length adjustments are common & don't have side effects, so we don't
|
|
|
|
// want them to consider them here; they'd bias our average towards 0.
|
|
|
|
MOZ_ASSERT(aAdjustment, "Don't call this API for zero-length adjustments");
|
|
|
|
|
|
|
|
mConsecutiveScrollAnchoringAdjustments++;
|
|
|
|
mConsecutiveScrollAnchoringAdjustmentLength = NSCoordSaturatingAdd(
|
|
|
|
mConsecutiveScrollAnchoringAdjustmentLength, aAdjustment);
|
|
|
|
|
|
|
|
uint32_t maxConsecutiveAdjustments =
|
|
|
|
StaticPrefs::layout_css_scroll_anchoring_max_consecutive_adjustments();
|
|
|
|
|
|
|
|
if (!maxConsecutiveAdjustments) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t consecutiveAdjustments =
|
|
|
|
mConsecutiveScrollAnchoringAdjustments.value();
|
|
|
|
if (consecutiveAdjustments < maxConsecutiveAdjustments ||
|
|
|
|
consecutiveAdjustments > kAnchorCheckCountLimit) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto cssPixels =
|
|
|
|
CSSPixel::FromAppUnits(mConsecutiveScrollAnchoringAdjustmentLength);
|
|
|
|
double average = double(cssPixels) / consecutiveAdjustments;
|
|
|
|
uint32_t minAverage = StaticPrefs::
|
|
|
|
layout_css_scroll_anchoring_min_average_adjustment_threshold();
|
2019-10-31 12:19:21 +03:00
|
|
|
if (MOZ_LIKELY(std::abs(average) >= double(minAverage))) {
|
|
|
|
return;
|
2019-10-31 12:25:08 +03:00
|
|
|
}
|
2019-10-31 12:19:21 +03:00
|
|
|
|
|
|
|
mDisabled = true;
|
|
|
|
|
|
|
|
ANCHOR_LOG(
|
|
|
|
"Disabled scroll anchoring for container: "
|
|
|
|
"%f average, %f total out of %u consecutive adjustments\n",
|
|
|
|
average, float(cssPixels), consecutiveAdjustments);
|
|
|
|
|
|
|
|
AutoTArray<nsString, 3> arguments;
|
|
|
|
arguments.AppendElement()->AppendInt(consecutiveAdjustments);
|
|
|
|
arguments.AppendElement()->AppendFloat(average);
|
|
|
|
arguments.AppendElement()->AppendFloat(cssPixels);
|
|
|
|
|
|
|
|
nsContentUtils::ReportToConsole(
|
|
|
|
nsIScriptError::warningFlag, "Layout"_ns,
|
|
|
|
Frame()->PresContext()->Document(), nsContentUtils::eLAYOUT_PROPERTIES,
|
|
|
|
"ScrollAnchoringDisabledInContainer", arguments);
|
2018-12-21 19:26:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollAnchorContainer::SuppressAdjustments() {
|
|
|
|
ANCHOR_LOG("Received a scroll anchor suppression for %p.\n", this);
|
|
|
|
mSuppressAnchorAdjustment = true;
|
2020-05-20 02:57:23 +03:00
|
|
|
|
|
|
|
// Forward to our parent if appropriate, that is, if we don't maintain an
|
|
|
|
// anchor, and we can't maintain one.
|
|
|
|
//
|
|
|
|
// Note that we need to check !CanMaintainAnchor(), instead of just whether
|
|
|
|
// our frame is in the anchor chain of our ancestor as InvalidateAnchor()
|
|
|
|
// does, given some suppression triggers apply even for nodes that are not in
|
|
|
|
// the anchor chain.
|
|
|
|
if (!mAnchorNode && !CanMaintainAnchor()) {
|
|
|
|
if (ScrollAnchorContainer* container = FindFor(Frame())) {
|
|
|
|
ANCHOR_LOG(" > Forwarding to parent anchor\n");
|
|
|
|
container->SuppressAdjustments();
|
|
|
|
}
|
|
|
|
}
|
2018-12-21 19:26:10 +03:00
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
|
2019-10-31 12:23:35 +03:00
|
|
|
void ScrollAnchorContainer::InvalidateAnchor(ScheduleSelection aSchedule) {
|
2018-11-28 00:45:16 +03:00
|
|
|
ANCHOR_LOG("Invalidating scroll anchor %p for %p.\n", mAnchorNode, this);
|
|
|
|
|
|
|
|
if (mAnchorNode) {
|
|
|
|
SetAnchorFlags(mScrollFrame->mScrolledFrame, mAnchorNode, false);
|
2020-04-13 23:58:14 +03:00
|
|
|
} else if (mScrollFrame->mScrolledFrame->IsInScrollAnchorChain()) {
|
2020-05-20 02:57:23 +03:00
|
|
|
ANCHOR_LOG(" > Forwarding to parent anchor\n");
|
2020-04-13 23:58:14 +03:00
|
|
|
// We don't maintain an anchor, and our scrolled frame is in the anchor
|
|
|
|
// chain of an ancestor. Invalidate that anchor.
|
|
|
|
//
|
|
|
|
// NOTE: Intentionally not forwarding aSchedule: Scheduling is always safe
|
|
|
|
// and not doing so is just an optimization.
|
|
|
|
FindFor(Frame())->InvalidateAnchor();
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
mAnchorNode = nullptr;
|
|
|
|
mAnchorNodeIsDirty = true;
|
2019-01-17 00:13:12 +03:00
|
|
|
mLastAnchorOffset = 0;
|
2019-01-20 10:21:55 +03:00
|
|
|
|
2020-04-13 23:58:14 +03:00
|
|
|
if (!CanMaintainAnchor() || aSchedule == ScheduleSelection::No) {
|
2019-01-20 10:21:55 +03:00
|
|
|
return;
|
|
|
|
}
|
2019-10-31 12:23:35 +03:00
|
|
|
|
2019-01-13 09:54:05 +03:00
|
|
|
Frame()->PresShell()->PostPendingScrollAnchorSelection(this);
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollAnchorContainer::Destroy() {
|
2019-10-31 12:23:35 +03:00
|
|
|
InvalidateAnchor(ScheduleSelection::No);
|
2018-11-28 00:45:16 +03:00
|
|
|
}
|
|
|
|
|
2018-12-21 19:26:10 +03:00
|
|
|
void ScrollAnchorContainer::ApplyAdjustments() {
|
2019-10-31 12:25:08 +03:00
|
|
|
if (!mAnchorNode || mAnchorNodeIsDirty || mDisabled ||
|
2019-07-15 20:48:16 +03:00
|
|
|
mScrollFrame->HasPendingScrollRestoration() ||
|
2019-08-24 01:29:49 +03:00
|
|
|
mScrollFrame->IsProcessingScrollEvent() ||
|
2020-08-02 19:58:29 +03:00
|
|
|
mScrollFrame->IsScrollAnimating() ||
|
2020-02-22 23:08:22 +03:00
|
|
|
mScrollFrame->GetScrollPosition() == nsPoint()) {
|
2019-07-15 20:46:11 +03:00
|
|
|
ANCHOR_LOG(
|
2019-10-31 12:25:08 +03:00
|
|
|
"Ignoring post-reflow (anchor=%p, dirty=%d, disabled=%d, "
|
2020-08-02 19:58:29 +03:00
|
|
|
"pendingRestoration=%d, scrollevent=%d, animating=%d, "
|
|
|
|
"zeroScrollPos=%d pendingSuppression=%d, "
|
2020-02-22 23:08:22 +03:00
|
|
|
"container=%p).\n",
|
2019-10-31 12:25:08 +03:00
|
|
|
mAnchorNode, mAnchorNodeIsDirty, mDisabled,
|
2019-07-15 20:48:16 +03:00
|
|
|
mScrollFrame->HasPendingScrollRestoration(),
|
2019-08-24 01:29:49 +03:00
|
|
|
mScrollFrame->IsProcessingScrollEvent(),
|
2020-08-02 19:58:29 +03:00
|
|
|
mScrollFrame->IsScrollAnimating(),
|
2020-02-22 23:08:22 +03:00
|
|
|
mScrollFrame->GetScrollPosition() == nsPoint(),
|
2020-02-12 21:56:43 +03:00
|
|
|
mSuppressAnchorAdjustment, this);
|
2019-10-08 01:47:15 +03:00
|
|
|
if (mSuppressAnchorAdjustment) {
|
|
|
|
mSuppressAnchorAdjustment = false;
|
|
|
|
InvalidateAnchor();
|
|
|
|
}
|
2018-12-21 19:26:10 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
nscoord current =
|
|
|
|
FindScrollAnchoringBoundingOffset(mScrollFrame, mAnchorNode);
|
|
|
|
nscoord logicalAdjustment = current - mLastAnchorOffset;
|
2018-12-21 19:26:10 +03:00
|
|
|
WritingMode writingMode = Frame()->GetWritingMode();
|
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
ANCHOR_LOG("Anchor has moved from %d to %d.\n", mLastAnchorOffset, current);
|
2018-12-21 19:26:10 +03:00
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
if (logicalAdjustment == 0) {
|
2018-12-21 19:26:10 +03:00
|
|
|
ANCHOR_LOG("Ignoring zero delta anchor adjustment for %p.\n", this);
|
|
|
|
mSuppressAnchorAdjustment = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mSuppressAnchorAdjustment) {
|
|
|
|
ANCHOR_LOG("Applying anchor adjustment suppression for %p.\n", this);
|
|
|
|
mSuppressAnchorAdjustment = false;
|
|
|
|
InvalidateAnchor();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-17 20:01:36 +03:00
|
|
|
ANCHOR_LOG("Applying anchor adjustment of %d in %s with anchor %p.\n",
|
2020-02-12 21:56:43 +03:00
|
|
|
logicalAdjustment, ToString(writingMode).c_str(), mAnchorNode);
|
2019-01-17 00:13:12 +03:00
|
|
|
|
2019-10-31 12:25:08 +03:00
|
|
|
AdjustmentMade(logicalAdjustment);
|
|
|
|
|
2019-01-17 00:13:12 +03:00
|
|
|
nsPoint physicalAdjustment;
|
|
|
|
switch (writingMode.GetBlockDir()) {
|
|
|
|
case WritingMode::eBlockTB: {
|
|
|
|
physicalAdjustment.y = logicalAdjustment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WritingMode::eBlockLR: {
|
|
|
|
physicalAdjustment.x = logicalAdjustment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WritingMode::eBlockRL: {
|
|
|
|
physicalAdjustment.x = -logicalAdjustment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-12-21 19:26:10 +03:00
|
|
|
|
2019-10-15 21:46:42 +03:00
|
|
|
MOZ_RELEASE_ASSERT(!mApplyingAnchorAdjustment);
|
2018-12-21 19:26:10 +03:00
|
|
|
// We should use AutoRestore here, but that doesn't work with bitfields
|
|
|
|
mApplyingAnchorAdjustment = true;
|
2019-02-08 05:39:49 +03:00
|
|
|
mScrollFrame->ScrollTo(mScrollFrame->GetScrollPosition() + physicalAdjustment,
|
2020-06-05 12:37:51 +03:00
|
|
|
ScrollMode::Instant, ScrollOrigin::Relative);
|
2018-12-21 19:26:10 +03:00
|
|
|
mApplyingAnchorAdjustment = false;
|
|
|
|
|
2019-01-09 00:18:12 +03:00
|
|
|
nsPresContext* pc = Frame()->PresContext();
|
2019-07-20 18:02:35 +03:00
|
|
|
if (mScrollFrame->mIsRoot) {
|
|
|
|
pc->PresShell()->RootScrollFrameAdjusted(physicalAdjustment.y);
|
|
|
|
}
|
2019-01-09 00:18:12 +03:00
|
|
|
|
2018-12-21 19:26:10 +03:00
|
|
|
// The anchor position may not be in the same relative position after
|
|
|
|
// adjustment. Update ourselves so we have consistent state.
|
2019-01-17 00:13:12 +03:00
|
|
|
mLastAnchorOffset =
|
|
|
|
FindScrollAnchoringBoundingOffset(mScrollFrame, mAnchorNode);
|
2018-12-21 19:26:10 +03:00
|
|
|
}
|
|
|
|
|
2018-11-28 00:45:16 +03:00
|
|
|
ScrollAnchorContainer::ExamineResult
|
|
|
|
ScrollAnchorContainer::ExamineAnchorCandidate(nsIFrame* aFrame) const {
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsCString tag = aFrame->ListTag();
|
|
|
|
ANCHOR_LOG("\tVisiting frame=%s (%p).\n", tag.get(), aFrame);
|
|
|
|
#else
|
|
|
|
ANCHOR_LOG("\t\tVisiting frame=%p.\n", aFrame);
|
|
|
|
#endif
|
2019-01-30 17:42:28 +03:00
|
|
|
bool isText = !!Text::FromNodeOrNull(aFrame->GetContent());
|
|
|
|
bool isContinuation = !!aFrame->GetPrevContinuation();
|
|
|
|
|
|
|
|
if (isText && isContinuation) {
|
|
|
|
ANCHOR_LOG("\t\tExcluding continuation text node.\n");
|
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
|
|
|
|
// Check if the author has opted out of scroll anchoring for this frame
|
|
|
|
// and its descendants.
|
|
|
|
const nsStyleDisplay* disp = aFrame->StyleDisplay();
|
|
|
|
if (disp->mOverflowAnchor == mozilla::StyleOverflowAnchor::None) {
|
|
|
|
ANCHOR_LOG("\t\tExcluding `overflow-anchor: none`.\n");
|
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sticky positioned elements can move with the scroll frame, making them
|
|
|
|
// unsuitable scroll anchors. This isn't in the specification yet [1], but
|
|
|
|
// matches Blink's implementation.
|
|
|
|
//
|
|
|
|
// [1] https://github.com/w3c/csswg-drafts/issues/3319
|
|
|
|
if (aFrame->IsStickyPositioned()) {
|
|
|
|
ANCHOR_LOG("\t\tExcluding `position: sticky`.\n");
|
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The frame for a <br> element has a non-zero area, but Blink treats them
|
|
|
|
// as if they have no area, so exclude them specially.
|
|
|
|
if (aFrame->IsBrFrame()) {
|
|
|
|
ANCHOR_LOG("\t\tExcluding <br>.\n");
|
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exclude frames that aren't accessible to content.
|
|
|
|
bool isChrome =
|
|
|
|
aFrame->GetContent() && aFrame->GetContent()->ChromeOnlyAccess();
|
|
|
|
bool isPseudo = aFrame->Style()->IsPseudoElement();
|
|
|
|
if (isChrome && !isPseudo) {
|
|
|
|
ANCHOR_LOG("\t\tExcluding chrome only content.\n");
|
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
|
|
|
|
2019-09-14 01:26:48 +03:00
|
|
|
const bool isReplaced = aFrame->IsFrameOfType(nsIFrame::eReplaced);
|
|
|
|
|
|
|
|
const bool isNonReplacedInline =
|
|
|
|
aFrame->StyleDisplay()->IsInlineInsideStyle() && !isReplaced;
|
|
|
|
|
|
|
|
const bool isAnonBox = aFrame->Style()->IsAnonBox();
|
|
|
|
|
2020-04-16 02:13:00 +03:00
|
|
|
// See if this frame has or could maintain its own anchor node.
|
|
|
|
const bool isScrollableWithAnchor = [&] {
|
|
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(aFrame);
|
|
|
|
if (!scrollable) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto* anchor = scrollable->Anchor();
|
|
|
|
return anchor->AnchorNode() || anchor->CanMaintainAnchor();
|
|
|
|
}();
|
2018-11-28 00:45:16 +03:00
|
|
|
|
2020-04-13 23:58:14 +03:00
|
|
|
// We don't allow scroll anchors to be selected inside of nested scrollable
|
|
|
|
// frames which maintain an anchor node as it's not clear how an anchor
|
|
|
|
// adjustment should apply to multiple scrollable frames.
|
|
|
|
//
|
|
|
|
// It is important to descend into _some_ scrollable frames, specially
|
|
|
|
// overflow: hidden, as those don't generally maintain their own anchors, and
|
|
|
|
// it is a common case in the wild where scroll anchoring ought to work.
|
2018-11-28 00:45:16 +03:00
|
|
|
//
|
2019-09-14 01:26:48 +03:00
|
|
|
// We also don't allow scroll anchors to be selected inside of replaced
|
|
|
|
// elements (like <img>, <video>, <svg>...) as they behave atomically. SVG
|
|
|
|
// uses a different layout model than CSS, and the specification doesn't say
|
|
|
|
// it should apply anyway.
|
2018-11-28 00:45:16 +03:00
|
|
|
//
|
|
|
|
// [1] https://github.com/w3c/csswg-drafts/issues/3477
|
2020-04-13 23:58:14 +03:00
|
|
|
const bool canDescend = !isScrollableWithAnchor && !isReplaced;
|
2018-11-28 00:45:16 +03:00
|
|
|
|
2019-09-14 01:26:48 +03:00
|
|
|
// Non-replaced inline boxes (including ruby frames) and anon boxes are not
|
|
|
|
// acceptable anchors, so we descend if possible, or otherwise exclude them
|
|
|
|
// altogether.
|
|
|
|
if (!isText && (isNonReplacedInline || isAnonBox)) {
|
2018-11-28 00:45:16 +03:00
|
|
|
ANCHOR_LOG(
|
2019-09-14 01:26:48 +03:00
|
|
|
"\t\tSearching descendants of anon or non-replaced inline box (a=%d, "
|
|
|
|
"i=%d).\n",
|
|
|
|
isAnonBox, isNonReplacedInline);
|
|
|
|
if (canDescend) {
|
|
|
|
return ExamineResult::PassThrough;
|
|
|
|
}
|
2018-11-28 00:45:16 +03:00
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the scroll anchoring bounding rect.
|
|
|
|
nsRect rect = FindScrollAnchoringBoundingRect(Frame(), aFrame);
|
|
|
|
ANCHOR_LOG("\t\trect = [%d %d x %d %d].\n", rect.x, rect.y, rect.width,
|
|
|
|
rect.height);
|
|
|
|
|
|
|
|
// Check if this frame is visible in the scroll port. This will exclude rects
|
|
|
|
// with zero sized area. The specification is ambiguous about this [1], but
|
|
|
|
// this matches Blink's implementation.
|
|
|
|
//
|
|
|
|
// [1] https://github.com/w3c/csswg-drafts/issues/3483
|
|
|
|
nsRect visibleRect;
|
2019-01-22 22:37:16 +03:00
|
|
|
if (!visibleRect.IntersectRect(rect,
|
|
|
|
mScrollFrame->GetVisualOptimalViewingRect())) {
|
2018-11-28 00:45:16 +03:00
|
|
|
return ExamineResult::Exclude;
|
|
|
|
}
|
|
|
|
|
2019-09-14 01:26:48 +03:00
|
|
|
// It's not clear what the scroll anchoring bounding rect is, for elements
|
|
|
|
// fragmented in the block direction (e.g. across column or page breaks).
|
|
|
|
//
|
|
|
|
// Inline-fragmented elements other than text shouldn't get here because of
|
|
|
|
// the isNonReplacedInline check.
|
2018-11-28 00:45:16 +03:00
|
|
|
//
|
2019-09-14 01:26:48 +03:00
|
|
|
// For text nodes that are fragmented, it's specified that we need to consider
|
|
|
|
// the union of its line boxes.
|
2018-11-28 00:45:16 +03:00
|
|
|
//
|
|
|
|
// So for text nodes we handle them by including the union of line boxes in
|
|
|
|
// the bounding rect of the primary frame, and not selecting any
|
|
|
|
// continuations.
|
|
|
|
//
|
|
|
|
// For block-outside elements we choose to consider the bounding rect of each
|
|
|
|
// frame individually, allowing ourselves to descend into any frame, but only
|
|
|
|
// selecting a frame if it's not a continuation.
|
|
|
|
if (canDescend && isContinuation) {
|
|
|
|
ANCHOR_LOG("\t\tSearching descendants of a continuation.\n");
|
|
|
|
return ExamineResult::PassThrough;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this frame is fully visible, then select it as the scroll anchor.
|
|
|
|
if (visibleRect.IsEqualEdges(rect)) {
|
|
|
|
ANCHOR_LOG("\t\tFully visible, taking.\n");
|
|
|
|
return ExamineResult::Accept;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we can't descend into this frame, then select it as the scroll anchor.
|
|
|
|
if (!canDescend) {
|
|
|
|
ANCHOR_LOG("\t\tIntersects a frame that we can't descend into, taking.\n");
|
|
|
|
return ExamineResult::Accept;
|
|
|
|
}
|
|
|
|
|
|
|
|
// It must be partially visible and we can descend into this frame. Examine
|
|
|
|
// its children for a better scroll anchor or fall back to this one.
|
|
|
|
ANCHOR_LOG("\t\tIntersects valid candidate, checking descendants.\n");
|
|
|
|
return ExamineResult::Traverse;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* ScrollAnchorContainer::FindAnchorIn(nsIFrame* aFrame) const {
|
|
|
|
// Visit the child lists of this frame
|
2020-05-19 15:37:37 +03:00
|
|
|
for (const auto& [list, listID] : aFrame->ChildLists()) {
|
2018-11-28 00:45:16 +03:00
|
|
|
// Skip child lists that contain out-of-flow frames, we'll visit them by
|
|
|
|
// following placeholders in the in-flow lists so that we visit these
|
|
|
|
// frames in DOM order.
|
|
|
|
// XXX do we actually need to exclude kOverflowOutOfFlowList too?
|
2020-05-18 04:09:34 +03:00
|
|
|
if (listID == FrameChildListID::kAbsoluteList ||
|
|
|
|
listID == FrameChildListID::kFixedList ||
|
|
|
|
listID == FrameChildListID::kFloatList ||
|
|
|
|
listID == FrameChildListID::kOverflowOutOfFlowList) {
|
2018-11-28 00:45:16 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search the child list, and return if we selected an anchor
|
2020-05-18 04:09:34 +03:00
|
|
|
if (nsIFrame* anchor = FindAnchorInList(list)) {
|
2018-11-28 00:45:16 +03:00
|
|
|
return anchor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The spec requires us to do an extra pass to visit absolutely positioned
|
|
|
|
// frames a second time after all the children of their containing block have
|
|
|
|
// been visited.
|
|
|
|
//
|
|
|
|
// It's not clear why this is needed [1], but it matches Blink's
|
|
|
|
// implementation, and is needed for a WPT test.
|
|
|
|
//
|
|
|
|
// [1] https://github.com/w3c/csswg-drafts/issues/3465
|
|
|
|
const nsFrameList& absPosList =
|
|
|
|
aFrame->GetChildList(FrameChildListID::kAbsoluteList);
|
|
|
|
if (nsIFrame* anchor = FindAnchorInList(absPosList)) {
|
|
|
|
return anchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* ScrollAnchorContainer::FindAnchorInList(
|
|
|
|
const nsFrameList& aFrameList) const {
|
|
|
|
for (nsIFrame* child : aFrameList) {
|
|
|
|
// If this is a placeholder, try to follow it to the out of flow frame.
|
|
|
|
nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(child);
|
|
|
|
if (child != realFrame) {
|
|
|
|
// If the out of flow frame is not a descendant of our scroll frame,
|
|
|
|
// then it must have a different containing block and cannot be an
|
|
|
|
// anchor node.
|
|
|
|
if (!nsLayoutUtils::IsProperAncestorFrame(Frame(), realFrame)) {
|
|
|
|
ANCHOR_LOG(
|
|
|
|
"\t\tSkipping out of flow frame that is not a descendant of the "
|
|
|
|
"scroll frame.\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ANCHOR_LOG("\t\tFollowing placeholder to out of flow frame.\n");
|
|
|
|
child = realFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform the candidate examination algorithm
|
|
|
|
ExamineResult examine = ExamineAnchorCandidate(child);
|
|
|
|
|
|
|
|
// See the comment before the definition of `ExamineResult` in
|
|
|
|
// `ScrollAnchorContainer.h` for an explanation of this behavior.
|
|
|
|
switch (examine) {
|
|
|
|
case ExamineResult::Exclude: {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case ExamineResult::PassThrough: {
|
|
|
|
nsIFrame* candidate = FindAnchorIn(child);
|
|
|
|
if (!candidate) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return candidate;
|
|
|
|
}
|
|
|
|
case ExamineResult::Traverse: {
|
|
|
|
nsIFrame* candidate = FindAnchorIn(child);
|
|
|
|
if (!candidate) {
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
return candidate;
|
|
|
|
}
|
|
|
|
case ExamineResult::Accept: {
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-11-28 00:18:03 +03:00
|
|
|
} // namespace layout
|
|
|
|
} // namespace mozilla
|