Backed out 6 changesets (bug 1781046, bug 1784575) for pressumably causing Bug 1784591 and Bug 1784625. a=backout

Backed out changeset 84e0f04d939c (bug 1781046)
Backed out changeset 84228a1b82da (bug 1781046)
Backed out changeset a0574f6e88e1 (bug 1781046)
Backed out changeset 6dc8a407aa1f (bug 1781046)
Backed out changeset a3724891b9c9 (bug 1781046)
Backed out changeset 617f9a8b7512 (bug 1784575)
This commit is contained in:
Cosmin Sabou 2022-08-19 23:37:15 +03:00
Родитель 465eb2d28d
Коммит eef1e137ae
9 изменённых файлов: 61 добавлений и 218 удалений

Просмотреть файл

@ -2522,7 +2522,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(Document)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnloadBlocker)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLazyLoadImageObserver)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLazyLoadImageObserverViewport)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLastRememberedSizeObserver)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMImplementation)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImageMaps)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOrientationPendingPromise)
@ -2642,7 +2641,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Document)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLazyLoadImageObserver)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLazyLoadImageObserverViewport)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLastRememberedSizeObserver)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFontFaceSet)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReadyForIdle)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentL10n)
@ -15792,27 +15790,6 @@ void Document::IncLazyLoadImageReachViewport(bool aLoading) {
}
}
ResizeObserver& Document::EnsureLastRememberedSizeObserver() {
if (!mLastRememberedSizeObserver) {
mLastRememberedSizeObserver =
ResizeObserver::CreateLastRememberedSizeObserver(*this);
}
return *mLastRememberedSizeObserver;
}
void Document::ObserveForLastRememberedSize(Element& aElement) {
// Options are initialized with ResizeObserverBoxOptions::Content_box by
// default, which is what we want.
static ResizeObserverOptions options;
EnsureLastRememberedSizeObserver().Observe(aElement, options);
}
void Document::UnobserveForLastRememberedSize(Element& aElement) {
if (mLastRememberedSizeObserver) {
mLastRememberedSizeObserver->Unobserve(aElement);
}
}
void Document::NotifyLayerManagerRecreated() {
NotifyActivityChanged();
EnumerateSubDocuments([](Document& aSubDoc) {

Просмотреть файл

@ -3755,13 +3755,6 @@ class Document : public nsINode,
void IncLazyLoadImageStarted() { ++mLazyLoadImageStarted; }
void IncLazyLoadImageReachViewport(bool aLoading);
ResizeObserver* GetLastRememberedSizeObserver() {
return mLastRememberedSizeObserver;
}
ResizeObserver& EnsureLastRememberedSizeObserver();
void ObserveForLastRememberedSize(Element&);
void UnobserveForLastRememberedSize(Element&);
// Dispatch a runnable related to the document.
nsresult Dispatch(TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) final;
@ -5127,10 +5120,6 @@ class Document : public nsINode,
// Used to measure how effective the lazyload thresholds are.
RefPtr<DOMIntersectionObserver> mLazyLoadImageObserverViewport;
// ResizeObserver for storing and removing the last remembered size.
// @see {@link https://drafts.csswg.org/css-sizing-4/#last-remembered}
RefPtr<ResizeObserver> mLastRememberedSizeObserver;
// Stack of top layer elements.
nsTArray<nsWeakPtr> mTopLayer;

Просмотреть файл

@ -482,26 +482,6 @@ void Element::SetShadowRoot(ShadowRoot* aShadowRoot) {
slots->mShadowRoot = aShadowRoot;
}
void Element::SetLastRememberedBSize(float aBSize) {
ExtendedDOMSlots()->mLastRememberedBSize = Some(aBSize);
}
void Element::SetLastRememberedISize(float aISize) {
ExtendedDOMSlots()->mLastRememberedISize = Some(aISize);
}
void Element::RemoveLastRememberedBSize() {
if (nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots()) {
slots->mLastRememberedBSize.reset();
}
}
void Element::RemoveLastRememberedISize() {
if (nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots()) {
slots->mLastRememberedISize.reset();
}
}
void Element::Blur(mozilla::ErrorResult& aError) {
if (!ShouldBlur(this)) {
return;

Просмотреть файл

@ -298,11 +298,6 @@ class Element : public FragmentOrElement {
*/
void SetShadowRoot(ShadowRoot* aShadowRoot);
void SetLastRememberedBSize(float aBSize);
void SetLastRememberedISize(float aISize);
void RemoveLastRememberedBSize();
void RemoveLastRememberedISize();
/**
* Make focus on this element.
*/
@ -1316,21 +1311,6 @@ class Element : public FragmentOrElement {
return slots ? slots->mShadowRoot.get() : nullptr;
}
const Maybe<float> GetLastRememberedBSize() const {
const nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
return slots ? slots->mLastRememberedBSize : Nothing();
}
const Maybe<float> GetLastRememberedISize() const {
const nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
return slots ? slots->mLastRememberedISize : Nothing();
}
bool HasLastRememberedBSize() const {
return GetLastRememberedBSize().isSome();
}
bool HasLastRememberedISize() const {
return GetLastRememberedISize().isSome();
}
private:
// DO NOT USE THIS FUNCTION directly in C++. This function is supposed to be
// called from JS. Use PresShell::ScrollContentIntoView instead.

Просмотреть файл

@ -197,13 +197,6 @@ class FragmentOrElement : public nsIContent {
* Web components custom element data.
*/
UniquePtr<CustomElementData> mCustomElementData;
/**
* Last remembered size (in CSS pixels) for the element.
* @see {@link https://drafts.csswg.org/css-sizing-4/#last-remembered}
*/
Maybe<float> mLastRememberedBSize;
Maybe<float> mLastRememberedISize;
};
class nsDOMSlots : public nsIContent::nsContentSlots {

Просмотреть файл

@ -202,23 +202,14 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(ResizeObserver)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(ResizeObserver)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ResizeObserver)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner, mDocument, mActiveTargets,
mObservationMap);
if (tmp->mCallback.is<RefPtr<ResizeObserverCallback>>()) {
ImplCycleCollectionTraverse(
cb, tmp->mCallback.as<RefPtr<ResizeObserverCallback>>(), "mCallback",
0);
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner, mDocument, mCallback,
mActiveTargets, mObservationMap);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ResizeObserver)
tmp->Disconnect();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner, mDocument, mActiveTargets,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner, mDocument, mCallback, mActiveTargets,
mObservationMap);
if (tmp->mCallback.is<RefPtr<ResizeObserverCallback>>()) {
ImplCycleCollectionUnlink(
tmp->mCallback.as<RefPtr<ResizeObserverCallback>>());
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -229,14 +220,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ResizeObserver)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
ResizeObserver::ResizeObserver(Document& aDocument, NativeCallback aCallback)
: mOwner(aDocument.GetInnerWindow()),
mDocument(&aDocument),
mCallback(aCallback) {
MOZ_ASSERT(mOwner, "Need a non-null owner window");
MOZ_ASSERT(mDocument == mOwner->GetExtantDoc());
}
already_AddRefed<ResizeObserver> ResizeObserver::Constructor(
const GlobalObject& aGlobal, ResizeObserverCallback& aCb,
ErrorResult& aRv) {
@ -295,18 +278,6 @@ void ResizeObserver::Observe(Element& aTarget,
observation =
new ResizeObservation(aTarget, *this, aOptions.mBox,
frame ? frame->GetWritingMode() : WritingMode());
if (this == mDocument->GetLastRememberedSizeObserver()) {
// Resize observations are initialized with a (0, 0) mLastReportedSize,
// this means that the callback won't be called if the element is 0x0.
// But we need it called for handling the last remembered size, so set
// mLastReportedSize to an invalid size to ensure IsActive() is true
// for the current element size.
// See https://github.com/w3c/csswg-drafts/issues/3664 about doing this in
// the general case, then we won't need this hack for the last remembered
// size, and will have consistency with IntersectionObserver.
observation->UpdateLastReportedSize(gfx::Size(-1, -1));
MOZ_ASSERT(observation->IsActive());
}
mObservationList.insertBack(observation);
// Per the spec, we need to trigger notification in event loop that
@ -412,13 +383,8 @@ uint32_t ResizeObserver::BroadcastActiveObservations() {
}
}
if (mCallback.is<RefPtr<ResizeObserverCallback>>()) {
RefPtr<ResizeObserverCallback> callback(
mCallback.as<RefPtr<ResizeObserverCallback>>());
callback->Call(this, entries, *this);
} else {
mCallback.as<NativeCallback>()(entries, *this);
}
RefPtr<ResizeObserverCallback> callback(mCallback);
callback->Call(this, entries, *this);
mActiveTargets.Clear();
mHasSkippedTargets = false;
@ -503,17 +469,6 @@ void ResizeObserverEntry::SetDevicePixelContentSize(const gfx::Size& aSize) {
mDevicePixelContentBoxSize = new ResizeObserverSize(mOwner, aSize, wm);
}
static void LastRememberedSizeCallback(
const Sequence<OwningNonNull<ResizeObserverEntry>>& aEntries,
ResizeObserver& aObserver) {
// TODO.
}
/* static */ already_AddRefed<ResizeObserver>
ResizeObserver::CreateLastRememberedSizeObserver(Document& aDocument) {
return do_AddRef(new ResizeObserver(aDocument, LastRememberedSizeCallback));
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ResizeObserverSize, mOwner)
NS_IMPL_CYCLE_COLLECTING_ADDREF(ResizeObserverSize)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ResizeObserverSize)

Просмотреть файл

@ -115,19 +115,13 @@ class ResizeObservation final : public LinkedListElement<ResizeObservation> {
* https://drafts.csswg.org/resize-observer/#api
*/
class ResizeObserver final : public nsISupports, public nsWrapperCache {
using NativeCallback = void (*)(
const Sequence<OwningNonNull<ResizeObserverEntry>>&, ResizeObserver&);
ResizeObserver(Document& aDocument, NativeCallback aCallback);
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ResizeObserver)
ResizeObserver(nsCOMPtr<nsPIDOMWindowInner>&& aOwner, Document* aDocument,
ResizeObserverCallback& aCb)
: mOwner(std::move(aOwner)),
mDocument(aDocument),
mCallback(RefPtr<ResizeObserverCallback>(&aCb)) {
: mOwner(std::move(aOwner)), mDocument(aDocument), mCallback(&aCb) {
MOZ_ASSERT(mOwner, "Need a non-null owner window");
MOZ_ASSERT(mDocument, "Need a non-null doc");
MOZ_ASSERT(mDocument == mOwner->GetExtantDoc());
@ -180,22 +174,19 @@ class ResizeObserver final : public nsISupports, public nsWrapperCache {
*/
MOZ_CAN_RUN_SCRIPT uint32_t BroadcastActiveObservations();
static already_AddRefed<ResizeObserver> CreateLastRememberedSizeObserver(
Document&);
protected:
~ResizeObserver() { Disconnect(); }
nsCOMPtr<nsPIDOMWindowInner> mOwner;
// The window's document at the time of ResizeObserver creation.
RefPtr<Document> mDocument;
Variant<RefPtr<ResizeObserverCallback>, NativeCallback> mCallback;
RefPtr<ResizeObserverCallback> mCallback;
nsTArray<RefPtr<ResizeObservation>> mActiveTargets;
// The spec uses a list to store the skipped targets. However, it seems what
// we want is to check if there are any skipped targets (i.e. existence).
// Therefore, we use a boolean value to represent the existence of skipped
// targets.
bool mHasSkippedTargets = false;
bool mHasSkippedTargets;
// Combination of HashTable and LinkedList so we can iterate through
// the elements of HashTable in order of insertion time, so we can deliver
@ -291,8 +282,8 @@ class ResizeObserverSize final : public nsISupports, public nsWrapperCache {
return ResizeObserverSize_Binding::Wrap(aCx, this, aGivenProto);
}
float InlineSize() const { return mSize.ISize(); }
float BlockSize() const { return mSize.BSize(); }
double InlineSize() const { return mSize.ISize(); }
double BlockSize() const { return mSize.BSize(); }
protected:
~ResizeObserverSize() = default;

Просмотреть файл

@ -1319,16 +1319,6 @@ nsChangeHint nsStylePosition::CalcDifference(
return hint;
}
const StyleContainIntrinsicSize& nsStylePosition::ContainIntrinsicBSize(
const WritingMode& aWM) const {
return aWM.IsVertical() ? mContainIntrinsicWidth : mContainIntrinsicHeight;
}
const StyleContainIntrinsicSize& nsStylePosition::ContainIntrinsicISize(
const WritingMode& aWM) const {
return aWM.IsVertical() ? mContainIntrinsicHeight : mContainIntrinsicWidth;
}
StyleAlignSelf nsStylePosition::UsedAlignSelf(
const ComputedStyle* aParent) const {
if (mAlignSelf._0 != StyleAlignFlags::AUTO) {
@ -3594,24 +3584,8 @@ nscoord StyleCalcNode::Resolve(nscoord aBasis,
return ResolveInternal(aBasis, aRounder);
}
static bool CanUseLastRememberedSize(const nsIFrame& aFrame) {
switch (aFrame.StyleDisplay()->mContentVisibility) {
case StyleContentVisibility::Visible:
return false;
case StyleContentVisibility::Auto:
// TODO: return true if the element skips its contents, i.e. if it's not
// relevant to the user.
return false;
case StyleContentVisibility::Hidden:
return true;
}
MOZ_ASSERT_UNREACHABLE("Unknown content-visibility value");
return false;
}
static nscoord Resolve(const StyleContainIntrinsicSize& aSize,
nscoord aNoneValue, const nsIFrame& aFrame,
LogicalAxis aAxis) {
nscoord aNoneValue) {
if (aSize.IsNone()) {
return aNoneValue;
}
@ -3619,50 +3593,29 @@ static nscoord Resolve(const StyleContainIntrinsicSize& aSize,
return aSize.AsLength().ToAppUnits();
}
MOZ_ASSERT(aSize.IsAutoLength());
if (const auto* element = Element::FromNodeOrNull(aFrame.GetContent())) {
Maybe<float> lastSize = aAxis == eLogicalAxisBlock
? element->GetLastRememberedBSize()
: element->GetLastRememberedISize();
if (lastSize && CanUseLastRememberedSize(aFrame)) {
return CSSPixel::ToAppUnits(*lastSize);
}
}
// TODO: use last remembered size if possible.
return aSize.AsAutoLength().ToAppUnits();
}
Maybe<nscoord> ContainSizeAxes::ContainIntrinsicBSize(
const nsIFrame& aFrame, nscoord aNoneValue) const {
if (!mBContained) {
return Nothing();
}
const StyleContainIntrinsicSize& bSize =
aFrame.StylePosition()->ContainIntrinsicBSize(aFrame.GetWritingMode());
return Some(Resolve(bSize, aNoneValue, aFrame, eLogicalAxisBlock));
}
Maybe<nscoord> ContainSizeAxes::ContainIntrinsicISize(
const nsIFrame& aFrame, nscoord aNoneValue) const {
if (!mIContained) {
return Nothing();
}
const StyleContainIntrinsicSize& iSize =
aFrame.StylePosition()->ContainIntrinsicISize(aFrame.GetWritingMode());
return Some(Resolve(iSize, aNoneValue, aFrame, eLogicalAxisInline));
}
nsSize ContainSizeAxes::ContainSize(const nsSize& aUncontainedSize,
const nsIFrame& aFrame) const {
if (!IsAny()) {
return aUncontainedSize;
}
if (aFrame.GetWritingMode().IsVertical()) {
return nsSize(
ContainIntrinsicBSize(aFrame).valueOr(aUncontainedSize.Width()),
ContainIntrinsicISize(aFrame).valueOr(aUncontainedSize.Height()));
const nsStylePosition* stylePos = aFrame.StylePosition();
if (IsBoth()) {
return nsSize(Resolve(stylePos->mContainIntrinsicWidth, 0),
Resolve(stylePos->mContainIntrinsicHeight, 0));
}
return nsSize(
ContainIntrinsicISize(aFrame).valueOr(aUncontainedSize.Width()),
ContainIntrinsicBSize(aFrame).valueOr(aUncontainedSize.Height()));
// At this point, we know that precisely one of our dimensions is contained.
const bool containsWidth =
aFrame.GetWritingMode().IsVertical() ? mBContained : mIContained;
if (containsWidth) {
return nsSize(Resolve(stylePos->mContainIntrinsicWidth, 0),
aUncontainedSize.Height());
}
return nsSize(aUncontainedSize.Width(),
Resolve(stylePos->mContainIntrinsicHeight, 0));
}
IntrinsicSize ContainSizeAxes::ContainIntrinsicSize(
@ -3670,13 +3623,43 @@ IntrinsicSize ContainSizeAxes::ContainIntrinsicSize(
if (!IsAny()) {
return aUncontainedSize;
}
IntrinsicSize result(aUncontainedSize);
const bool isVerticalWM = aFrame.GetWritingMode().IsVertical();
if (Maybe<nscoord> containBSize = ContainIntrinsicBSize(aFrame)) {
(isVerticalWM ? result.width : result.height) = containBSize;
const nsStylePosition* stylePos = aFrame.StylePosition();
if (IsBoth()) {
return IntrinsicSize(Resolve(stylePos->mContainIntrinsicWidth, 0),
Resolve(stylePos->mContainIntrinsicHeight, 0));
}
if (Maybe<nscoord> containISize = ContainIntrinsicISize(aFrame)) {
(isVerticalWM ? result.height : result.width) = containISize;
// At this point, we know that precisely one of our dimensions is contained.
const bool containsWidth =
aFrame.GetWritingMode().IsVertical() ? mBContained : mIContained;
IntrinsicSize result(aUncontainedSize);
if (containsWidth) {
result.width = Some(Resolve(stylePos->mContainIntrinsicWidth, 0));
} else {
result.height = Some(Resolve(stylePos->mContainIntrinsicHeight, 0));
}
return result;
}
Maybe<nscoord> ContainSizeAxes::ContainIntrinsicBSize(
const nsIFrame& aFrame, nscoord aNoneValue) const {
if (!mBContained) {
return Nothing();
}
const nsStylePosition* stylePos = aFrame.StylePosition();
return Some(Resolve(aFrame.GetWritingMode().IsVertical()
? stylePos->mContainIntrinsicWidth
: stylePos->mContainIntrinsicHeight,
aNoneValue));
}
Maybe<nscoord> ContainSizeAxes::ContainIntrinsicISize(
const nsIFrame& aFrame, nscoord aNoneValue) const {
if (!mIContained) {
return Nothing();
}
const nsStylePosition* stylePos = aFrame.StylePosition();
return Some(Resolve(aFrame.GetWritingMode().IsVertical()
? stylePos->mContainIntrinsicHeight
: stylePos->mContainIntrinsicWidth,
aNoneValue));
}

Просмотреть файл

@ -771,11 +771,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
mOffset.Get(mozilla::eSideBottom).IsAuto());
}
const mozilla::StyleContainIntrinsicSize& ContainIntrinsicBSize(
const WritingMode& aWM) const;
const mozilla::StyleContainIntrinsicSize& ContainIntrinsicISize(
const WritingMode& aWM) const;
/**
* Return the used value for 'align-self' given our parent ComputedStyle
* (or null for the root).