From 1c8e994b6544b026f70f025ed7de4ed50e6144ba Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 24 Jun 2025 12:18:13 +0200 Subject: [PATCH] Issue #2762 - Remove SVGZoomEvent interface. Resolves #2762 --- dom/events/EventDispatcher.cpp | 10 -- dom/events/EventNameList.h | 13 --- .../test/test_all_synthetic_events.html | 7 -- dom/svg/SVGSVGElement.cpp | 9 +- dom/svg/SVGSVGElement.h | 2 + dom/svg/SVGZoomEvent.cpp | 102 ------------------ dom/svg/SVGZoomEvent.h | 77 ------------- dom/svg/moz.build | 2 - dom/svg/test/mochitest.ini | 2 - dom/svg/test/test_zoom.xhtml | 35 ------ dom/svg/test/zoom-helper.svg | 4 - .../mochitest/general/test_interfaces.html | 2 - dom/webidl/SVGZoomEvent.webidl | 25 ----- dom/webidl/moz.build | 1 - widget/BasicEvents.h | 1 - widget/ContentEvents.h | 32 ------ widget/EventClassList.h | 1 - 17 files changed, 6 insertions(+), 319 deletions(-) delete mode 100644 dom/svg/SVGZoomEvent.cpp delete mode 100644 dom/svg/SVGZoomEvent.h delete mode 100644 dom/svg/test/test_zoom.xhtml delete mode 100644 dom/svg/test/zoom-helper.svg delete mode 100644 dom/webidl/SVGZoomEvent.webidl diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index 7b4cc1cecf..96f065ee84 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -40,7 +40,6 @@ #include "mozilla/dom/ScrollAreaEvent.h" #include "mozilla/dom/SimpleGestureEvent.h" #include "mozilla/dom/StorageEvent.h" -#include "mozilla/dom/SVGZoomEvent.h" #include "mozilla/dom/TimeEvent.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/dom/TransitionEvent.h" @@ -1047,9 +1046,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner, case eClipboardEventClass: return NS_NewDOMClipboardEvent(aOwner, aPresContext, aEvent->AsClipboardEvent()); - case eSVGZoomEventClass: - return NS_NewDOMSVGZoomEvent(aOwner, aPresContext, - aEvent->AsSVGZoomEvent()); case eSMILTimeEventClass: return NS_NewDOMTimeEvent(aOwner, aPresContext, aEvent->AsSMILTimeEvent()); @@ -1148,12 +1144,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner, if (aEventType.LowerCaseEqualsLiteral("svgevents")) { return NS_NewDOMEvent(aOwner, aPresContext, nullptr); } - if (aEventType.LowerCaseEqualsLiteral("svgzoomevent")) { - return NS_NewDOMSVGZoomEvent(aOwner, aPresContext, nullptr); - } - if (aEventType.LowerCaseEqualsLiteral("svgzoomevents")) { - return NS_NewDOMSVGZoomEvent(aOwner, aPresContext, nullptr); - } if (aEventType.LowerCaseEqualsLiteral("timeevent")) { return NS_NewDOMTimeEvent(aOwner, aPresContext, nullptr); } diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 0a17b5f147..d323345d46 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -825,19 +825,6 @@ NON_IDL_EVENT(SVGScroll, EventNameType_None, eBasicEventClass) -NON_IDL_EVENT(SVGZoom, - eSVGZoom, - EventNameType_None, - eSVGZoomEventClass) - -// Only map the ID to the real event name when MESSAGE_TO_EVENT is defined. -#ifndef MESSAGE_TO_EVENT -// This is a bit hackish, but SVG's event names are weird. -NON_IDL_EVENT(zoom, - eSVGZoom, - EventNameType_SVGSVG, - eBasicEventClass) -#endif // Only map the ID to the real event name when MESSAGE_TO_EVENT is defined. #ifndef MESSAGE_TO_EVENT NON_IDL_EVENT(begin, diff --git a/dom/events/test/test_all_synthetic_events.html b/dom/events/test/test_all_synthetic_events.html index 58560fdcef..ce8c3da15f 100644 --- a/dom/events/test/test_all_synthetic_events.html +++ b/dom/events/test/test_all_synthetic_events.html @@ -401,13 +401,6 @@ const kEventConstructors = { }, chromeOnly: true, }, - SVGZoomEvent: { create: function (aName, aProps) { - var e = document.createEvent("svgzoomevent"); - e.initUIEvent(aName, aProps.bubbles, aProps.cancelable, - aProps.view, aProps.detail); - return e; - }, - }, TCPSocketErrorEvent: { create: function(aName, aProps) { return new TCPSocketErrorEvent(aName, aProps); }, diff --git a/dom/svg/SVGSVGElement.cpp b/dom/svg/SVGSVGElement.cpp index fa60979316..48e3444921 100644 --- a/dom/svg/SVGSVGElement.cpp +++ b/dom/svg/SVGSVGElement.cpp @@ -474,7 +474,7 @@ SVGSVGElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv) } //---------------------------------------------------------------------- -// helper methods for implementing SVGZoomEvent: +// helper methods for implementing SetCurrentScale/Translate void SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) @@ -498,6 +498,8 @@ SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) // change that caused the event's dispatch, which is *not* necessarily the // same thing as the values of currentScale and currentTranslate prior to // their own last change. + // + // TODO: simplify some of this code since SVGZoomEvent was removed. mPreviousScale = mCurrentScale; mPreviousTranslate = mCurrentTranslate; @@ -510,10 +512,7 @@ SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y) nsCOMPtr presShell = doc->GetShell(); if (presShell && IsRoot()) { nsEventStatus status = nsEventStatus_eIgnore; - if (mPreviousScale != mCurrentScale) { - InternalSVGZoomEvent svgZoomEvent(true, eSVGZoom); - presShell->HandleDOMEventWithTarget(this, &svgZoomEvent, &status); - } else { + if (mPreviousScale == mCurrentScale) { WidgetEvent svgScrollEvent(true, eSVGScroll); presShell->HandleDOMEventWithTarget(this, &svgScrollEvent, &status); } diff --git a/dom/svg/SVGSVGElement.h b/dom/svg/SVGSVGElement.h index 18a2d9764d..a1c2448ce5 100644 --- a/dom/svg/SVGSVGElement.h +++ b/dom/svg/SVGSVGElement.h @@ -131,6 +131,8 @@ public: * For use by zoom controls to allow currentScale, currentTranslate.x and * currentTranslate.y to be set by a single operation that dispatches a * single SVGZoom event (instead of one SVGZoom and two SVGScroll events). + * + * XXX SVGZoomEvent was removed; is this still needed? */ void SetCurrentScaleTranslate(float s, float x, float y); diff --git a/dom/svg/SVGZoomEvent.cpp b/dom/svg/SVGZoomEvent.cpp deleted file mode 100644 index e57c8fa663..0000000000 --- a/dom/svg/SVGZoomEvent.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "DOMSVGPoint.h" -#include "mozilla/ContentEvents.h" -#include "mozilla/dom/Element.h" -#include "mozilla/dom/SVGSVGElement.h" -#include "mozilla/dom/SVGZoomEvent.h" -#include "nsIDocument.h" -#include "nsIPresShell.h" -#include "prtime.h" - -namespace mozilla { -namespace dom { - -//---------------------------------------------------------------------- -// Implementation - -NS_IMPL_CYCLE_COLLECTION_INHERITED(SVGZoomEvent, UIEvent, mPreviousTranslate, mNewTranslate) - -NS_IMPL_ADDREF_INHERITED(SVGZoomEvent, UIEvent) -NS_IMPL_RELEASE_INHERITED(SVGZoomEvent, UIEvent) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGZoomEvent) -NS_INTERFACE_MAP_END_INHERITING(UIEvent) - -SVGZoomEvent::SVGZoomEvent(EventTarget* aOwner, - nsPresContext* aPresContext, - InternalSVGZoomEvent* aEvent) - : UIEvent(aOwner, aPresContext, - aEvent ? aEvent : new InternalSVGZoomEvent(false, eSVGZoom)) - , mPreviousScale(0) - , mNewScale(0) -{ - if (aEvent) { - mEventIsInternal = false; - } - else { - mEventIsInternal = true; - mEvent->mTime = PR_Now(); - } - - // We must store the "Previous" and "New" values before this event is - // dispatched. Reading the values from the root 'svg' element after we've - // been dispatched is not an option since event handler code may change - // currentScale and currentTranslate in response to this event. - nsIPresShell *presShell; - if (mPresContext && (presShell = mPresContext->GetPresShell())) { - nsIDocument *doc = presShell->GetDocument(); - if (doc) { - Element *rootElement = doc->GetRootElement(); - if (rootElement) { - // If the root element isn't an SVG 'svg' element - // (e.g. if this event was created by calling createEvent on a - // non-SVGDocument), then the "New" and "Previous" - // properties will be left null which is probably what we want. - if (rootElement->IsSVGElement(nsGkAtoms::svg)) { - SVGSVGElement *SVGSVGElem = - static_cast(rootElement); - - mNewScale = SVGSVGElem->GetCurrentScale(); - mPreviousScale = SVGSVGElem->GetPreviousScale(); - - const SVGPoint& translate = SVGSVGElem->GetCurrentTranslate(); - mNewTranslate = - new DOMSVGPoint(translate.GetX(), translate.GetY()); - mNewTranslate->SetReadonly(true); - - const SVGPoint& prevTranslate = SVGSVGElem->GetPreviousTranslate(); - mPreviousTranslate = - new DOMSVGPoint(prevTranslate.GetX(), prevTranslate.GetY()); - mPreviousTranslate->SetReadonly(true); - } - } - } - } -} - -SVGZoomEvent::~SVGZoomEvent() -{ -} - -} // namespace dom -} // namespace mozilla - - -//////////////////////////////////////////////////////////////////////// -// Exported creation functions: - -using namespace mozilla; -using namespace mozilla::dom; - -already_AddRefed -NS_NewDOMSVGZoomEvent(EventTarget* aOwner, - nsPresContext* aPresContext, - mozilla::InternalSVGZoomEvent* aEvent) -{ - RefPtr it = new SVGZoomEvent(aOwner, aPresContext, aEvent); - return it.forget(); -} diff --git a/dom/svg/SVGZoomEvent.h b/dom/svg/SVGZoomEvent.h deleted file mode 100644 index a1374e7f83..0000000000 --- a/dom/svg/SVGZoomEvent.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_SVGZoomEvent_h -#define mozilla_dom_SVGZoomEvent_h - -#include "DOMSVGPoint.h" -#include "mozilla/dom/UIEvent.h" -#include "mozilla/dom/SVGZoomEventBinding.h" -#include "mozilla/EventForwards.h" - -class nsPresContext; - -namespace mozilla { - -class nsISVGPoint; - -namespace dom { - -class SVGZoomEvent final : public UIEvent -{ -public: - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGZoomEvent, UIEvent) - NS_DECL_ISUPPORTS_INHERITED - - SVGZoomEvent(EventTarget* aOwner, nsPresContext* aPresContext, - InternalSVGZoomEvent* aEvent); - - // Forward to base class - NS_FORWARD_TO_UIEVENT - - virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) override - { - return SVGZoomEventBinding::Wrap(aCx, this, aGivenProto); - } - - float PreviousScale() const - { - return mPreviousScale; - } - - nsISVGPoint* GetPreviousTranslate() const - { - return mPreviousTranslate; - } - - float NewScale() const - { - return mNewScale; - } - - nsISVGPoint* GetNewTranslate() const - { - return mNewTranslate; - } - -private: - ~SVGZoomEvent(); - - float mPreviousScale; - float mNewScale; - RefPtr mPreviousTranslate; - RefPtr mNewTranslate; -}; - -} // namespace dom -} // namespace mozilla - -already_AddRefed -NS_NewDOMSVGZoomEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, - mozilla::InternalSVGZoomEvent* aEvent); - -#endif // mozilla_dom_SVGZoomEvent_h diff --git a/dom/svg/moz.build b/dom/svg/moz.build index 90b7156315..66e2be5dca 100644 --- a/dom/svg/moz.build +++ b/dom/svg/moz.build @@ -100,7 +100,6 @@ EXPORTS.mozilla.dom += [ 'SVGTSpanElement.h', 'SVGUseElement.h', 'SVGViewElement.h', - 'SVGZoomEvent.h', ] UNIFIED_SOURCES += [ @@ -247,7 +246,6 @@ UNIFIED_SOURCES += [ 'SVGUseElement.cpp', 'SVGViewBoxSMILType.cpp', 'SVGViewElement.cpp', - 'SVGZoomEvent.cpp', ] include('/ipc/chromium/chromium-config.mozbuild') diff --git a/dom/svg/test/mochitest.ini b/dom/svg/test/mochitest.ini index c44776b2ff..ddc0e4b472 100644 --- a/dom/svg/test/mochitest.ini +++ b/dom/svg/test/mochitest.ini @@ -27,7 +27,6 @@ support-files = text-helper-selection.svg text-helper.svg viewport-helper.svg - zoom-helper.svg [test_a_href_01.xhtml] [test_a_href_02.xhtml] @@ -105,5 +104,4 @@ support-files = use-with-hsts-helper.html use-with-hsts-helper.html^headers^ [test_valueAsString.xhtml] [test_valueLeaks.xhtml] [test_viewport.html] -[test_zoom.xhtml] diff --git a/dom/svg/test/test_zoom.xhtml b/dom/svg/test/test_zoom.xhtml deleted file mode 100644 index ce920b29db..0000000000 --- a/dom/svg/test/test_zoom.xhtml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Test for Bug 547596 - - - - - Mozilla Bug 547596 -

- - - - - - - diff --git a/dom/svg/test/zoom-helper.svg b/dom/svg/test/zoom-helper.svg deleted file mode 100644 index a9e40cdaa8..0000000000 --- a/dom/svg/test/zoom-helper.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 03101b888c..2fd08910ba 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -1124,8 +1124,6 @@ var interfaceNamesInGlobalScope = "SVGViewElement", // IMPORTANT: Do not change this list without review from a DOM peer! "SVGZoomAndPan", -// IMPORTANT: Do not change this list without review from a DOM peer! - "SVGZoomEvent", // IMPORTANT: Do not change this list without review from a DOM peer! "Text", // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/SVGZoomEvent.webidl b/dom/webidl/SVGZoomEvent.webidl deleted file mode 100644 index 044247f3ca..0000000000 --- a/dom/webidl/SVGZoomEvent.webidl +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGZoomEvent : UIEvent { - // Not implemented - // readonly attribute SVGRect zoomRectScreen; - - [Constant] - readonly attribute float previousScale; - [Constant] - readonly attribute SVGPoint? previousTranslate; - [Constant] - readonly attribute float newScale; - [Constant] - readonly attribute SVGPoint? newTranslate; -}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 5e3c8f8c1e..560e1600aa 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -521,7 +521,6 @@ WEBIDL_FILES = [ 'SVGViewElement.webidl', 'SVGZoomAndPan.webidl', 'SVGZoomAndPanValues.webidl', - 'SVGZoomEvent.webidl', 'SystemUpdate.webidl', 'TCPServerSocket.webidl', 'TCPServerSocketEvent.webidl', diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index 95a51ff4ca..81c9ef99a5 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -312,7 +312,6 @@ private: break; case eTransitionEventClass: case eAnimationEventClass: - case eSVGZoomEventClass: mFlags.mCancelable = false; mFlags.mBubbles = true; break; diff --git a/widget/ContentEvents.h b/widget/ContentEvents.h index 09d4d9928c..34b1116e65 100644 --- a/widget/ContentEvents.h +++ b/widget/ContentEvents.h @@ -312,38 +312,6 @@ public: } }; -/****************************************************************************** - * mozilla::InternalSVGZoomEvent - ******************************************************************************/ - -class InternalSVGZoomEvent : public WidgetGUIEvent -{ -public: - virtual InternalSVGZoomEvent* AsSVGZoomEvent() override { return this; } - - InternalSVGZoomEvent(bool aIsTrusted, EventMessage aMessage) - : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eSVGZoomEventClass) - { - } - - virtual WidgetEvent* Duplicate() const override - { - MOZ_ASSERT(mClass == eSVGZoomEventClass, - "Duplicate() must be overridden by sub class"); - // Not copying widget, it is a weak reference. - InternalSVGZoomEvent* result = new InternalSVGZoomEvent(false, mMessage); - result->AssignSVGZoomEventData(*this, true); - result->mFlags = mFlags; - return result; - } - - void AssignSVGZoomEventData(const InternalSVGZoomEvent& aEvent, - bool aCopyTargets) - { - AssignGUIEventData(aEvent, aCopyTargets); - } -}; - /****************************************************************************** * mozilla::InternalSMILTimeEvent ******************************************************************************/ diff --git a/widget/EventClassList.h b/widget/EventClassList.h index 9667a72c5b..6582a12e45 100644 --- a/widget/EventClassList.h +++ b/widget/EventClassList.h @@ -49,7 +49,6 @@ NS_EVENT_CLASS(Internal, ClipboardEvent) NS_EVENT_CLASS(Internal, FocusEvent) NS_EVENT_CLASS(Internal, TransitionEvent) NS_EVENT_CLASS(Internal, AnimationEvent) -NS_EVENT_CLASS(Internal, SVGZoomEvent) NS_EVENT_CLASS(Internal, SMILTimeEvent) // MiscEvents.h