Bug 1866894 - Update failing subtest for content-visibility-auto-resize.html. r=fredw
[gecko.git] / dom / events / ScrollAreaEvent.cpp
blob4cc7bc61e78760ba8fd1e4aa98682ded279c7ff4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "base/basictypes.h"
8 #include "ipc/IPCMessageUtils.h"
9 #include "ipc/IPCMessageUtilsSpecializations.h"
10 #include "mozilla/dom/DOMRect.h"
11 #include "mozilla/dom/ScrollAreaEvent.h"
12 #include "mozilla/ContentEvents.h"
14 namespace mozilla::dom {
16 ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner,
17 nsPresContext* aPresContext,
18 InternalScrollAreaEvent* aEvent)
19 : UIEvent(aOwner, aPresContext, aEvent), mClientArea(new DOMRect(nullptr)) {
20 mClientArea->SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
23 NS_IMPL_CYCLE_COLLECTION_INHERITED(ScrollAreaEvent, UIEvent, mClientArea)
25 NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent)
26 NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent)
28 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScrollAreaEvent)
29 NS_INTERFACE_MAP_END_INHERITING(UIEvent)
31 void ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
32 bool aCanBubble, bool aCancelable,
33 nsGlobalWindowInner* aView,
34 int32_t aDetail, float aX, float aY,
35 float aWidth, float aHeight) {
36 NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
38 UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
39 mClientArea->SetRect(aX, aY, aWidth, aHeight);
42 void ScrollAreaEvent::Serialize(IPC::MessageWriter* aWriter,
43 bool aSerializeInterfaceType) {
44 if (aSerializeInterfaceType) {
45 IPC::WriteParam(aWriter, u"scrollareaevent"_ns);
48 Event::Serialize(aWriter, false);
50 IPC::WriteParam(aWriter, X());
51 IPC::WriteParam(aWriter, Y());
52 IPC::WriteParam(aWriter, Width());
53 IPC::WriteParam(aWriter, Height());
56 bool ScrollAreaEvent::Deserialize(IPC::MessageReader* aReader) {
57 NS_ENSURE_TRUE(Event::Deserialize(aReader), false);
59 float x, y, width, height;
60 NS_ENSURE_TRUE(IPC::ReadParam(aReader, &x), false);
61 NS_ENSURE_TRUE(IPC::ReadParam(aReader, &y), false);
62 NS_ENSURE_TRUE(IPC::ReadParam(aReader, &width), false);
63 NS_ENSURE_TRUE(IPC::ReadParam(aReader, &height), false);
64 mClientArea->SetRect(x, y, width, height);
66 return true;
69 } // namespace mozilla::dom
71 using namespace mozilla;
72 using namespace mozilla::dom;
74 already_AddRefed<ScrollAreaEvent> NS_NewDOMScrollAreaEvent(
75 EventTarget* aOwner, nsPresContext* aPresContext,
76 InternalScrollAreaEvent* aEvent) {
77 RefPtr<ScrollAreaEvent> ev =
78 new ScrollAreaEvent(aOwner, aPresContext, aEvent);
79 return ev.forget();