Skip to content

Commit

Permalink
Make IntersectionObserver and ResizeObserver classes be ISO-allocated.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259572
rdar://112989166

Reviewed by Ryosuke Niwa.

Make the following classes be ISO-allocated: IntersectionObserver, IntersectionObserverEntry,
ResizeObserver, ResizeObservation.

* Source/WebCore/page/IntersectionObserver.cpp:
* Source/WebCore/page/IntersectionObserver.h:
* Source/WebCore/page/IntersectionObserverEntry.cpp:
* Source/WebCore/page/IntersectionObserverEntry.h:
* Source/WebCore/page/ResizeObservation.cpp:
* Source/WebCore/page/ResizeObservation.h:
* Source/WebCore/page/ResizeObserver.cpp:
* Source/WebCore/page/ResizeObserver.h:

Canonical link: https://commits.webkit.org/266369@main
  • Loading branch information
smfr committed Jul 27, 2023
1 parent 8e237a1 commit 9df05cf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Source/WebCore/page/IntersectionObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "RenderView.h"
#include "WebCoreOpaqueRootInlines.h"
#include <JavaScriptCore/AbstractSlotVisitorInlines.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/Vector.h>

namespace WebCore {
Expand Down Expand Up @@ -123,6 +124,8 @@ ExceptionOr<Ref<IntersectionObserver>> IntersectionObserver::create(Document& do
return adoptRef(*new IntersectionObserver(document, WTFMove(callback), root.get(), rootMarginOrException.releaseReturnValue(), WTFMove(thresholds)));
}

WTF_MAKE_ISO_ALLOCATED_IMPL(IntersectionObserver);

IntersectionObserver::IntersectionObserver(Document& document, Ref<IntersectionObserverCallback>&& callback, ContainerNode* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds)
: m_root(root)
, m_rootMargin(WTFMove(parsedRootMargin))
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/page/IntersectionObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct IntersectionObserverData {
};

class IntersectionObserver : public RefCounted<IntersectionObserver>, public CanMakeWeakPtr<IntersectionObserver> {
WTF_MAKE_ISO_ALLOCATED(IntersectionObserver);
public:
struct Init {
std::optional<std::variant<RefPtr<Element>, RefPtr<Document>>> root;
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/page/IntersectionObserverEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
#include "IntersectionObserverEntry.h"

#include "Element.h"
#include <wtf/IsoMallocInlines.h>

namespace WebCore {

WTF_MAKE_ISO_ALLOCATED_IMPL(IntersectionObserverEntry);

IntersectionObserverEntry::IntersectionObserverEntry(const Init& init)
: m_time(init.time)
, m_boundingClientRect(DOMRectReadOnly::fromRect(init.boundingClientRect))
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/IntersectionObserverEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace WebCore {
class Element;

class IntersectionObserverEntry : public RefCounted<IntersectionObserverEntry> {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_ISO_ALLOCATED(IntersectionObserverEntry);
public:

struct Init {
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/page/ResizeObservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "RenderBoxInlines.h"
#include "RenderElementInlines.h"
#include "SVGElement.h"
#include <wtf/IsoMallocInlines.h>

namespace WebCore {

Expand All @@ -40,6 +41,8 @@ Ref<ResizeObservation> ResizeObservation::create(Element& target, ResizeObserver
return adoptRef(*new ResizeObservation(target, observedBox));
}

WTF_MAKE_ISO_ALLOCATED_IMPL(ResizeObservation);

ResizeObservation::ResizeObservation(Element& element, ResizeObserverBoxOptions observedBox)
: m_target { element }
, m_lastObservationSizes { LayoutSize(-1, -1), LayoutSize(-1, -1), LayoutSize(-1, -1) }
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/ResizeObservation.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Element;
class WeakPtrImplWithEventTargetData;

class ResizeObservation : public RefCounted<ResizeObservation> {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_ISO_ALLOCATED(ResizeObservation);
public:
static Ref<ResizeObservation> create(Element& target, ResizeObserverBoxOptions);

Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/page/ResizeObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "ResizeObserverOptions.h"
#include "WebCoreOpaqueRootInlines.h"
#include <JavaScriptCore/AbstractSlotVisitorInlines.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/TextStream.h>

namespace WebCore {
Expand All @@ -50,6 +51,8 @@ Ref<ResizeObserver> ResizeObserver::createNativeObserver(Document& document, Nat
return adoptRef(*new ResizeObserver(document, { WTFMove(nativeCallback) }));
}

WTF_MAKE_ISO_ALLOCATED_IMPL(ResizeObserver);

ResizeObserver::ResizeObserver(Document& document, JSOrNativeResizeObserverCallback&& callback)
: m_document(document)
, m_JSOrNativeCallback(WTFMove(callback))
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/page/ResizeObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ using NativeResizeObserverCallback = void (*)(const Vector<Ref<ResizeObserverEnt
using JSOrNativeResizeObserverCallback = std::variant<RefPtr<ResizeObserverCallback>, NativeResizeObserverCallback>;

class ResizeObserver : public RefCounted<ResizeObserver>, public CanMakeWeakPtr<ResizeObserver> {
WTF_MAKE_ISO_ALLOCATED(ResizeObserver);
public:
static Ref<ResizeObserver> create(Document&, Ref<ResizeObserverCallback>&&);
static Ref<ResizeObserver> createNativeObserver(Document&, NativeResizeObserverCallback&&);
Expand Down

0 comments on commit 9df05cf

Please sign in to comment.