Skip to content

Commit

Permalink
Bug 1552911 - Drop the constructor of ResizeObserverEntry. r=dholbert…
Browse files Browse the repository at this point in the history
…,smaug

There is a spec issue about should we expose this API:
w3c/csswg-drafts#3946

It's no clear that should we really need this API, so let's match
Chromium for now.

Differential Revision: https://phabricator.services.mozilla.com/D31891
  • Loading branch information
BorisChiou authored and hawkeye116477 committed Aug 19, 2020
1 parent 550a266 commit 15f11c2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
10 changes: 2 additions & 8 deletions dom/base/ResizeObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "mozilla/dom/ResizeObserver.h"

#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/Document.h"
#include "nsIContent.h"
#include "nsSVGUtils.h"
Expand Down Expand Up @@ -271,13 +272,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ResizeObserverEntry)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END

already_AddRefed<ResizeObserverEntry> ResizeObserverEntry::Constructor(
const GlobalObject& aGlobal, Element& aTarget, ErrorResult& aRv) {
RefPtr<ResizeObserverEntry> observerEntry =
new ResizeObserverEntry(aGlobal.GetAsSupports(), aTarget);
return observerEntry.forget();
}

void ResizeObserverEntry::SetBorderBoxSize(const nsSize& aSize) {
nsIFrame* frame = mTarget->GetPrimaryFrame();
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
Expand All @@ -292,7 +286,7 @@ void ResizeObserverEntry::SetContentRectAndSize(const nsSize& aSize) {
// Per the spec, we need to use the top-left padding offset as the origin of
// our contentRect.
nsRect rect(nsPoint(padding.left, padding.top), aSize);
RefPtr<DOMRect> contentRect = new DOMRect(mTarget);
RefPtr<DOMRect> contentRect = new DOMRect(this);
contentRect->SetLayoutRect(rect);
mContentRect = contentRect.forget();

Expand Down
3 changes: 0 additions & 3 deletions dom/base/ResizeObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ class ResizeObserverEntry final : public nsISupports, public nsWrapperCache {
return ResizeObserverEntry_Binding::Wrap(aCx, this, aGivenProto);
}

static already_AddRefed<ResizeObserverEntry> Constructor(
const GlobalObject& global, Element& target, ErrorResult& aRv);

Element* Target() const { return mTarget; }

/**
Expand Down
3 changes: 1 addition & 2 deletions dom/webidl/ResizeObserver.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ interface ResizeObserver {

callback ResizeObserverCallback = void (sequence<ResizeObserverEntry> entries, ResizeObserver observer);

[Constructor(Element target),
Pref="layout.css.resizeobserver.enabled"]
[Pref="layout.css.resizeobserver.enabled"]
interface ResizeObserverEntry {
readonly attribute Element target;
readonly attribute DOMRectReadOnly contentRect;
Expand Down
15 changes: 15 additions & 0 deletions layout/style/crashtests/1552911.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<script>
function start() {
const o1 =
document.createElementNS('http://www.w3.org/1999/xhtml', 'slot');
const observer = new ResizeObserverEntry(o1);
typeof observer.borderBoxSize;
typeof observer.contentBoxSize;
}

window.addEventListener('load', start);
</script>
</head>
</html>
1 change: 1 addition & 0 deletions layout/style/crashtests/crashtests.list
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,4 @@ load 1533891.html
pref(gfx.omta.background-color,true) load 1533968.html
load 1541126.html
load 1545177.html
pref(layout.css.resizeobserver.enabled,true) load 1552911.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
[ResizeObservation interface: attribute observedBox]
expected: FAIL
bug: https://github.com/w3c/csswg-drafts/issues/3839

[ResizeObserverEntry interface object length]
expected: FAIL
bug: https://github.com/w3c/csswg-drafts/issues/3946

0 comments on commit 15f11c2

Please sign in to comment.