mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Bug 1754579 - Don't keep so much alive when returning DOMRects & co. r=smaug
We keep the parent alive for wrapping. It's unnecessary to keep alive the individual element / range / etc. Pass the relevant global / document. Differential Revision: https://phabricator.services.mozilla.com/D138357
This commit is contained in:
parent
b5f84ec27c
commit
6fb72d4a3f
@ -724,17 +724,17 @@ void DOMIntersectionObserver::QueueIntersectionObserverEntry(
|
||||
bool aIsIntersecting, double aIntersectionRatio) {
|
||||
RefPtr<DOMRect> rootBounds;
|
||||
if (aRootRect.isSome()) {
|
||||
rootBounds = new DOMRect(this);
|
||||
rootBounds = new DOMRect(mOwner);
|
||||
rootBounds->SetLayoutRect(aRootRect.value());
|
||||
}
|
||||
RefPtr<DOMRect> boundingClientRect = new DOMRect(this);
|
||||
RefPtr<DOMRect> boundingClientRect = new DOMRect(mOwner);
|
||||
boundingClientRect->SetLayoutRect(aTargetRect);
|
||||
RefPtr<DOMRect> intersectionRect = new DOMRect(this);
|
||||
RefPtr<DOMRect> intersectionRect = new DOMRect(mOwner);
|
||||
if (aIntersectionRect.isSome()) {
|
||||
intersectionRect->SetLayoutRect(aIntersectionRect.value());
|
||||
}
|
||||
RefPtr<DOMIntersectionObserverEntry> entry = new DOMIntersectionObserverEntry(
|
||||
this, time, rootBounds.forget(), boundingClientRect.forget(),
|
||||
mOwner, time, rootBounds.forget(), boundingClientRect.forget(),
|
||||
intersectionRect.forget(), aIsIntersecting, aTarget, aIntersectionRatio);
|
||||
mQueuedEntries.AppendElement(entry.forget());
|
||||
}
|
||||
|
@ -1029,7 +1029,7 @@ nsRect Element::GetClientAreaRect() {
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect> Element::GetBoundingClientRect() {
|
||||
RefPtr<DOMRect> rect = new DOMRect(this);
|
||||
RefPtr<DOMRect> rect = new DOMRect(ToSupports(OwnerDoc()));
|
||||
|
||||
nsIFrame* frame = GetPrimaryFrame(FlushType::Layout);
|
||||
if (!frame) {
|
||||
|
@ -325,7 +325,7 @@ uint32_t ResizeObserver::BroadcastActiveObservations() {
|
||||
gfx::Size devicePixelContentBoxSize = CalculateBoxSize(
|
||||
target, ResizeObserverBoxOptions::Device_pixel_content_box);
|
||||
RefPtr<ResizeObserverEntry> entry =
|
||||
new ResizeObserverEntry(this, *target, borderBoxSize, contentBoxSize,
|
||||
new ResizeObserverEntry(mOwner, *target, borderBoxSize, contentBoxSize,
|
||||
devicePixelContentBoxSize);
|
||||
|
||||
if (!entries.AppendElement(entry.forget(), fallible)) {
|
||||
@ -413,7 +413,7 @@ void ResizeObserverEntry::GetDevicePixelContentBoxSize(
|
||||
void ResizeObserverEntry::SetBorderBoxSize(const gfx::Size& aSize) {
|
||||
nsIFrame* frame = mTarget->GetPrimaryFrame();
|
||||
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
|
||||
mBorderBoxSize = new ResizeObserverSize(this, aSize, wm);
|
||||
mBorderBoxSize = new ResizeObserverSize(mOwner, aSize, wm);
|
||||
}
|
||||
|
||||
void ResizeObserverEntry::SetContentRectAndSize(const gfx::Size& aSize) {
|
||||
@ -425,19 +425,19 @@ void ResizeObserverEntry::SetContentRectAndSize(const gfx::Size& aSize) {
|
||||
// our contentRect.
|
||||
nsRect rect(nsPoint(padding.left, padding.top),
|
||||
CSSPixel::ToAppUnits(CSSSize::FromUnknownSize(aSize)));
|
||||
RefPtr<DOMRect> contentRect = new DOMRect(this);
|
||||
RefPtr<DOMRect> contentRect = new DOMRect(mOwner);
|
||||
contentRect->SetLayoutRect(rect);
|
||||
mContentRect = std::move(contentRect);
|
||||
|
||||
// 2. Update mContentBoxSize.
|
||||
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
|
||||
mContentBoxSize = new ResizeObserverSize(this, aSize, wm);
|
||||
mContentBoxSize = new ResizeObserverSize(mOwner, aSize, wm);
|
||||
}
|
||||
|
||||
void ResizeObserverEntry::SetDevicePixelContentSize(const gfx::Size& aSize) {
|
||||
nsIFrame* frame = mTarget->GetPrimaryFrame();
|
||||
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
|
||||
mDevicePixelContentBoxSize = new ResizeObserverSize(this, aSize, wm);
|
||||
mDevicePixelContentBoxSize = new ResizeObserverSize(mOwner, aSize, wm);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ResizeObserverSize, mOwner)
|
||||
|
@ -94,7 +94,7 @@ DocGroup* nsRange::GetDocGroup() const {
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* stack based utilty class for managing monitor
|
||||
* stack based utility class for managing monitor
|
||||
******************************************************/
|
||||
|
||||
static void InvalidateAllFrames(nsINode* aNode) {
|
||||
@ -2785,7 +2785,7 @@ void nsRange::CollectClientRectsAndText(
|
||||
|
||||
already_AddRefed<DOMRect> nsRange::GetBoundingClientRect(bool aClampToEdge,
|
||||
bool aFlushLayout) {
|
||||
RefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
|
||||
RefPtr<DOMRect> rect = new DOMRect(ToSupports(mOwner));
|
||||
if (!mIsPositioned) {
|
||||
return rect.forget();
|
||||
}
|
||||
@ -2810,8 +2810,7 @@ already_AddRefed<DOMRectList> nsRange::GetClientRects(bool aClampToEdge,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<DOMRectList> rectList =
|
||||
new DOMRectList(static_cast<AbstractRange*>(this));
|
||||
RefPtr<DOMRectList> rectList = new DOMRectList(ToSupports(mOwner));
|
||||
|
||||
nsLayoutUtils::RectListBuilder builder(rectList);
|
||||
|
||||
@ -2830,7 +2829,7 @@ void nsRange::GetClientRectsAndTexts(mozilla::dom::ClientRectsAndTexts& aResult,
|
||||
return;
|
||||
}
|
||||
|
||||
aResult.mRectList = new DOMRectList(static_cast<AbstractRange*>(this));
|
||||
aResult.mRectList = new DOMRectList(ToSupports(mOwner));
|
||||
|
||||
nsLayoutUtils::RectListBuilder builder(aResult.mRectList);
|
||||
|
||||
|
@ -33,7 +33,7 @@ JSObject* PaintRequest::WrapObject(JSContext* aCx,
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect> PaintRequest::ClientRect() {
|
||||
RefPtr<DOMRect> clientRect = new DOMRect(this);
|
||||
RefPtr<DOMRect> clientRect = new DOMRect(mParent);
|
||||
clientRect->SetLayoutRect(mRequest);
|
||||
return clientRect.forget();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsView.h"
|
||||
#include "mozilla/AppUnits.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/XULPopupElement.h"
|
||||
@ -256,7 +257,7 @@ Element* XULPopupElement::GetAnchorNode() const {
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect> XULPopupElement::GetOuterScreenRect() {
|
||||
RefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
|
||||
RefPtr<DOMRect> rect = new DOMRect(ToSupports(OwnerDoc()));
|
||||
|
||||
// Return an empty rectangle if the popup is not open.
|
||||
nsMenuPopupFrame* menuPopupFrame =
|
||||
|
@ -351,8 +351,8 @@ already_AddRefed<DOMRect> XULTreeElement::GetCoordsForCellItem(
|
||||
nsIntRect rect = GetCoordsForCellItem(aRow, &aCol, aElement, rv);
|
||||
aRv = rv;
|
||||
|
||||
RefPtr<DOMRect> domRect =
|
||||
new DOMRect(this, rect.x, rect.y, rect.width, rect.height);
|
||||
RefPtr<DOMRect> domRect = new DOMRect(ToSupports(OwnerDoc()), rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
return domRect.forget();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user