This commit is contained in:
jwatt%jwatt.org 2005-08-25 21:31:09 +00:00
Родитель 5efc7980f6
Коммит 59e42c6cd2
31 изменённых файлов: 1224 добавлений и 55 удалений

Просмотреть файл

@ -107,7 +107,7 @@
#include "nsICategoryManager.h"
#include "nsIDOMNSFeatureFactory.h"
#ifdef MOZ_SVG
#ifdef MOZ_SVG
PRBool NS_SVG_TestFeature(const nsAString &fstr);
#endif /* MOZ_SVG */
@ -1197,18 +1197,17 @@ nsGenericElement::InternalIsSupported(nsISupports* aObject,
*aReturn = gHaveXPathDOM;
}
#ifdef MOZ_SVG
// Check for SVG Features
else if (NS_SVG_TestFeature(aFeature)) {
// Should we test the version also? The SVG Test
// Suite (struct-dom-02-b.svg) uses version 2.0 in the
// domImpl.hasFeature call. This makes no sense to me,
// so I'm going to skip testing the version here for now....
*aReturn = PR_TRUE;
#ifdef MOZ_SVG
else if (PL_strcasecmp(f, "SVGEvents") == 0 ||
PL_strcasecmp(f, "SVGZoomEvents") == 0 ||
NS_SVG_TestFeature(aFeature)) {
if (aVersion.IsEmpty() ||
PL_strcmp(v, "1.0") == 0 ||
PL_strcmp(v, "1.1") == 0) {
*aReturn = PR_TRUE;
}
}
#endif /* MOZ_SVG */
else {
nsCOMPtr<nsIDOMNSFeatureFactory> factory =
GetDOMFeatureFactory(aFeature, aVersion);

Просмотреть файл

@ -87,5 +87,11 @@ nsresult
NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsBeforePageUnloadEvent* aEvent);
nsresult
NS_NewDOMPageTransitionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsPageTransitionEvent* aEvent);
#ifdef MOZ_SVG
nsresult
NS_NewDOMSVGEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsEvent* aEvent);
nsresult
NS_NewDOMSVGZoomEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsGUIEvent* aEvent);
#endif // MOZ_SVG
#endif // nsIPrivateDOMEvent_h__

Просмотреть файл

@ -69,7 +69,12 @@ static const char* const sEventNames[] = {
"DOMAttrModified", "DOMCharacterDataModified",
"DOMActivate", "DOMFocusIn", "DOMFocusOut",
"pageshow", "pagehide"
};
#ifdef MOZ_SVG
,
"SVGLoad", "SVGUnload", "SVGAbort", "SVGError", "SVGResize", "SVGScroll",
"SVGZoom"
#endif // MOZ_SVG
};
static char *sPopupAllowedEvents;
@ -466,6 +471,25 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
else if (atom == nsLayoutAtoms::onpagehide)
mEvent->message = NS_PAGE_HIDE;
}
#ifdef MOZ_SVG
else if (mEvent->eventStructType == NS_SVG_EVENT) {
if (atom == nsLayoutAtoms::onSVGLoad)
mEvent->message = NS_SVG_LOAD;
else if (atom == nsLayoutAtoms::onSVGUnload)
mEvent->message = NS_SVG_UNLOAD;
else if (atom == nsLayoutAtoms::onSVGAbort)
mEvent->message = NS_SVG_ABORT;
else if (atom == nsLayoutAtoms::onSVGError)
mEvent->message = NS_SVG_ERROR;
else if (atom == nsLayoutAtoms::onSVGResize)
mEvent->message = NS_SVG_RESIZE;
else if (atom == nsLayoutAtoms::onSVGScroll)
mEvent->message = NS_SVG_SCROLL;
} else if (mEvent->eventStructType == NS_SVGZOOM_EVENT) {
if (atom == nsLayoutAtoms::onSVGZoom)
mEvent->message = NS_SVG_ZOOM;
}
#endif // MOZ_SVG
if (mEvent->message == NS_USER_DEFINED_EVENT)
mEvent->userType = new nsStringKey(aEventTypeArg);
@ -929,6 +953,22 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return sEventNames[eDOMEvents_pageshow];
case NS_PAGE_HIDE:
return sEventNames[eDOMEvents_pagehide];
#ifdef MOZ_SVG
case NS_SVG_LOAD:
return sEventNames[eDOMEvents_SVGLoad];
case NS_SVG_UNLOAD:
return sEventNames[eDOMEvents_SVGUnload];
case NS_SVG_ABORT:
return sEventNames[eDOMEvents_SVGAbort];
case NS_SVG_ERROR:
return sEventNames[eDOMEvents_SVGError];
case NS_SVG_RESIZE:
return sEventNames[eDOMEvents_SVGResize];
case NS_SVG_SCROLL:
return sEventNames[eDOMEvents_SVGScroll];
case NS_SVG_ZOOM:
return sEventNames[eDOMEvents_SVGZoom];
#endif // MOZ_SVG
default:
break;
}

Просмотреть файл

@ -124,6 +124,16 @@ public:
eDOMEvents_DOMFocusOut,
eDOMEvents_pageshow,
eDOMEvents_pagehide
#ifdef MOZ_SVG
,
eDOMEvents_SVGLoad,
eDOMEvents_SVGUnload,
eDOMEvents_SVGAbort,
eDOMEvents_SVGError,
eDOMEvents_SVGResize,
eDOMEvents_SVGScroll,
eDOMEvents_SVGZoom
#endif // MOZ_SVG
};
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);

Просмотреть файл

@ -57,6 +57,11 @@
#include "nsIDOMMutationListener.h"
#include "nsIDOMUIListener.h"
#include "nsIDOMPageTransitionListener.h"
#ifdef MOZ_SVG
#include "nsIDOMSVGListener.h"
#include "nsIDOMSVGZoomListener.h"
#include "nsSVGAtoms.h"
#endif // MOZ_SVG
#include "nsIEventStateManager.h"
#include "nsPIDOMWindow.h"
#include "nsIPrivateDOMEvent.h"
@ -326,6 +331,28 @@ static const EventDispatchData sPageTransitionEvents[] = {
NS_EVENT_BITS_PAGETRANSITION_HIDE }
};
#ifdef MOZ_SVG
static const EventDispatchData sSVGEvents[] = {
{ NS_SVG_LOAD, HANDLER(&nsIDOMSVGListener::Load),
NS_EVENT_BITS_SVG_LOAD },
{ NS_SVG_UNLOAD, HANDLER(&nsIDOMSVGListener::Unload),
NS_EVENT_BITS_SVG_UNLOAD },
{ NS_SVG_ABORT, HANDLER(&nsIDOMSVGListener::Abort),
NS_EVENT_BITS_SVG_ABORT },
{ NS_SVG_ERROR, HANDLER(&nsIDOMSVGListener::Error),
NS_EVENT_BITS_SVG_ERROR },
{ NS_SVG_RESIZE, HANDLER(&nsIDOMSVGListener::Resize),
NS_EVENT_BITS_SVG_RESIZE },
{ NS_SVG_SCROLL, HANDLER(&nsIDOMSVGListener::Scroll),
NS_EVENT_BITS_SVG_SCROLL }
};
static const EventDispatchData sSVGZoomEvents[] = {
{ NS_SVG_ZOOM, HANDLER(&nsIDOMSVGZoomListener::Zoom),
NS_EVENT_BITS_SVGZOOM_ZOOM }
};
#endif // MOZ_SVG
#define IMPL_EVENTTYPEDATA(type) \
{ \
s##type##Events, \
@ -352,6 +379,11 @@ static const EventTypeData sEventTypes[] = {
IMPL_EVENTTYPEDATA(Mutation),
IMPL_EVENTTYPEDATA(UI),
IMPL_EVENTTYPEDATA(PageTransition)
#ifdef MOZ_SVG
,
IMPL_EVENTTYPEDATA(SVG),
IMPL_EVENTTYPEDATA(SVGZoom)
#endif // MOZ_SVG
};
// Strong references to event groups
@ -629,6 +661,14 @@ nsEventListenerManager::GetTypeForIID(const nsIID& aIID)
if (aIID.Equals(NS_GET_IID(nsIDOMUIListener)))
return eEventArrayType_DOMUI;
#ifdef MOZ_SVG
if (aIID.Equals(NS_GET_IID(nsIDOMSVGListener)))
return eEventArrayType_SVG;
if (aIID.Equals(NS_GET_IID(nsIDOMSVGZoomListener)))
return eEventArrayType_SVGZoom;
#endif // MOZ_SVG
return eEventArrayType_None;
}
@ -1035,6 +1075,36 @@ nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType,
*aArrayType = eEventArrayType_PageTransition;
*aFlags = NS_EVENT_BITS_PAGETRANSITION_HIDE;
}
#ifdef MOZ_SVG
else if (aType == nsLayoutAtoms::onSVGLoad) {
*aArrayType = eEventArrayType_SVG;
*aFlags = NS_EVENT_BITS_SVG_LOAD;
}
else if (aType == nsLayoutAtoms::onSVGUnload) {
*aArrayType = eEventArrayType_SVG;
*aFlags = NS_EVENT_BITS_SVG_UNLOAD;
}
else if (aType == nsLayoutAtoms::onSVGAbort) {
*aArrayType = eEventArrayType_SVG;
*aFlags = NS_EVENT_BITS_SVG_ABORT;
}
else if (aType == nsLayoutAtoms::onSVGError) {
*aArrayType = eEventArrayType_SVG;
*aFlags = NS_EVENT_BITS_SVG_ERROR;
}
else if (aType == nsLayoutAtoms::onSVGResize) {
*aArrayType = eEventArrayType_SVG;
*aFlags = NS_EVENT_BITS_SVG_RESIZE;
}
else if (aType == nsLayoutAtoms::onSVGScroll) {
*aArrayType = eEventArrayType_SVG;
*aFlags = NS_EVENT_BITS_SVG_SCROLL;
}
else if (aType == nsLayoutAtoms::onSVGZoom) {
*aArrayType = eEventArrayType_SVGZoom;
*aFlags = NS_EVENT_BITS_SVGZOOM_ZOOM;
}
#endif // MOZ_SVG
else {
return NS_ERROR_FAILURE;
}
@ -1494,7 +1564,25 @@ nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext,
NS_ASSERTION(content, "only content should have event handler attributes");
if (content) {
nsAutoString handlerBody;
result = content->GetAttr(kNameSpaceID_None, aName, handlerBody);
nsIAtom* attrName = aName;
#ifdef MOZ_SVG
if (aName == nsLayoutAtoms::onSVGLoad)
attrName = nsSVGAtoms::onload;
else if (aName == nsLayoutAtoms::onSVGUnload)
attrName = nsSVGAtoms::onunload;
else if (aName == nsLayoutAtoms::onSVGAbort)
attrName = nsSVGAtoms::onabort;
else if (aName == nsLayoutAtoms::onSVGError)
attrName = nsSVGAtoms::onerror;
else if (aName == nsLayoutAtoms::onSVGResize)
attrName = nsSVGAtoms::onresize;
else if (aName == nsLayoutAtoms::onSVGScroll)
attrName = nsSVGAtoms::onscroll;
else if (aName == nsLayoutAtoms::onSVGZoom)
attrName = nsSVGAtoms::onzoom;
#endif // MOZ_SVG
result = content->GetAttr(kNameSpaceID_None, attrName, handlerBody);
if (NS_SUCCEEDED(result)) {
PRUint32 lineNo = 0;
@ -1757,6 +1845,14 @@ nsEventListenerManager::CreateEvent(nsPresContext* aPresContext,
return NS_NewDOMPageTransitionEvent(aDOMEvent, aPresContext,
NS_STATIC_CAST(nsPageTransitionEvent*,
aEvent));
#ifdef MOZ_SVG
case NS_SVG_EVENT:
return NS_NewDOMSVGEvent(aDOMEvent, aPresContext,
aEvent);
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext,
NS_STATIC_CAST(nsGUIEvent*,aEvent));
#endif // MOZ_SVG
}
// For all other types of events, create a vanilla event object.
@ -1795,6 +1891,16 @@ nsEventListenerManager::CreateEvent(nsPresContext* aPresContext,
aEventType.LowerCaseEqualsLiteral("events") ||
aEventType.LowerCaseEqualsLiteral("htmlevents"))
return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
#ifdef MOZ_SVG
if (aEventType.LowerCaseEqualsLiteral("svgevent") ||
aEventType.LowerCaseEqualsLiteral("svgevents"))
return NS_NewDOMSVGEvent(aDOMEvent, aPresContext,
aEvent);
if (aEventType.LowerCaseEqualsLiteral("svgzoomevent") ||
aEventType.LowerCaseEqualsLiteral("svgzoomevents"))
return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext,
NS_STATIC_CAST(nsGUIEvent*,aEvent));
#endif // MOZ_SVG
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}

Просмотреть файл

@ -85,6 +85,10 @@ enum EventArrayType {
eEventArrayType_Mutation = 13,
eEventArrayType_DOMUI = 14,
eEventArrayType_PageTransition = 15,
#ifdef MOZ_SVG
eEventArrayType_SVG = 16,
eEventArrayType_SVGZoom = 17,
#endif // MOZ_SVG
eEventArrayType_Hash,
eEventArrayType_None
};
@ -358,4 +362,19 @@ protected:
#define NS_EVENT_BITS_PAGETRANSITION_SHOW 0x01
#define NS_EVENT_BITS_PAGETRANSITION_HIDE 0x02
#ifdef MOZ_SVG
// nsIDOMSVGEventListener
#define NS_EVENT_BITS_SVG_NONE 0x00
#define NS_EVENT_BITS_SVG_LOAD 0x01
#define NS_EVENT_BITS_SVG_UNLOAD 0x02
#define NS_EVENT_BITS_SVG_ABORT 0x04
#define NS_EVENT_BITS_SVG_ERROR 0x08
#define NS_EVENT_BITS_SVG_RESIZE 0x10
#define NS_EVENT_BITS_SVG_SCROLL 0x20
// nsIDOMSVGZoomEventListener
#define NS_EVENT_BITS_SVGZOOM_NONE 0x00
#define NS_EVENT_BITS_SVGZOOM_ZOOM 0x01
#endif // MOZ_SVG
#endif // nsEventListenerManager_h__

Просмотреть файл

@ -66,6 +66,8 @@ REQUIRES = xpcom \
docshell
CPPSRCS = \
nsDOMSVGZoomEvent.cpp \
nsDOMSVGEvent.cpp \
nsSVGAngle.cpp \
nsSVGAnimatedAngle.cpp \
nsSVGAnimatedEnumeration.cpp \
@ -139,6 +141,8 @@ include $(topsrcdir)/config/config.mk
FORCE_STATIC_LIB = 1
EXPORTS = \
nsIDOMSVGListener.h \
nsIDOMSVGZoomListener.h \
nsISVGTextContentMetrics.h \
nsISVGValue.h \
nsISVGValueObserver.h \
@ -166,6 +170,7 @@ INCLUDES += \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../../layout/svg/base/src \
-I$(srcdir)/../../../../layout/style \
-I$(srcdir)/../../../events/src \
-I$(srcdir)/../../../html/content/src \
-I$(topsrcdir)/content/xbl/src \
$(NULL)

Просмотреть файл

@ -0,0 +1,89 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMSVGEvent.h"
#include "nsContentUtils.h"
//----------------------------------------------------------------------
// Implementation
nsDOMSVGEvent::nsDOMSVGEvent(nsPresContext* aPresContext,
nsEvent* aEvent)
: nsDOMEvent(aPresContext,
aEvent ? aEvent : new nsEvent(PR_FALSE, 0))
{
if (aEvent) {
mEventIsInternal = PR_FALSE;
}
else {
mEventIsInternal = PR_TRUE;
mEvent->eventStructType = NS_SVG_EVENT;
mEvent->time = PR_Now();
}
mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
if (mEvent->message == NS_SVG_LOAD || mEvent->message == NS_SVG_UNLOAD) {
mEvent->flags |= NS_EVENT_FLAG_CANT_BUBBLE;
}
}
//----------------------------------------------------------------------
// nsISupports methods:
NS_IMPL_ADDREF_INHERITED(nsDOMSVGEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMSVGEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMSVGEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
////////////////////////////////////////////////////////////////////////
// Exported creation functions:
nsresult
NS_NewDOMSVGEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent *aEvent)
{
nsDOMSVGEvent* it = new nsDOMSVGEvent(aPresContext, aEvent);
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
return CallQueryInterface(it, aInstancePtrResult);
}

Просмотреть файл

@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_SVGEVENT_H__
#define __NS_SVGEVENT_H__
#include "nsIDOMSVGEvent.h"
#include "nsDOMEvent.h"
class nsDOMSVGEvent : public nsIDOMSVGEvent,
public nsDOMEvent
{
public:
nsDOMSVGEvent(nsPresContext* aPresContext, nsEvent* aEvent);
// nsISupports interface:
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMSVGEvent interface:
NS_DECL_NSIDOMSVGEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMEVENT
};
#endif // __NS_SVGEVENT_H__

Просмотреть файл

@ -0,0 +1,190 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMSVGZoomEvent.h"
#include "nsContentUtils.h"
#include "nsSVGRect.h"
#include "nsSVGPoint.h"
#include "nsISVGSVGElement.h"
#include "nsIDOMSVGSVGElement.h"
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
//----------------------------------------------------------------------
// Implementation
nsDOMSVGZoomEvent::nsDOMSVGZoomEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent)
: nsDOMUIEvent(aPresContext,
aEvent ? aEvent : new nsGUIEvent(PR_FALSE, NS_SVG_ZOOM, 0))
{
if (aEvent) {
mEventIsInternal = PR_FALSE;
}
else {
mEventIsInternal = PR_TRUE;
mEvent->eventStructType = NS_SVGZOOM_EVENT;
mEvent->time = PR_Now();
}
mEvent->flags |= NS_EVENT_FLAG_CANT_CANCEL;
// 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) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
// If the root element isn't an SVG 'svg' element these QIs will fail
// (e.g. if this event was created by calling createEvent on a
// non-SVGDocument). In these circumstances the "New" and "Previous"
// properties will be left null which is probably what we want.
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(rootContent);
if (svgElement) {
svgElement->GetCurrentScale(&mNewScale);
float x, y;
nsCOMPtr<nsIDOMSVGPoint> currentTranslate;
svgElement->GetCurrentTranslate(getter_AddRefs(currentTranslate));
currentTranslate->GetX(&x);
currentTranslate->GetY(&y);
NS_NewSVGReadonlyPoint(getter_AddRefs(mNewTranslate), x, y);
}
nsCOMPtr<nsISVGSVGElement> privSVGElement = do_QueryInterface(rootContent);
if (svgElement) {
mPreviousScale = privSVGElement->GetPreviousScale();
NS_NewSVGReadonlyPoint(getter_AddRefs(mPreviousTranslate),
privSVGElement->GetPreviousTranslate_x(),
privSVGElement->GetPreviousTranslate_y());
// Important: we call RecordCurrentST() here to make sure that
// scripts that create an SVGZoomEvent won't get our "Previous" data
privSVGElement->RecordCurrentScaleTranslate();
}
}
}
}
}
//----------------------------------------------------------------------
// nsISupports methods:
NS_IMPL_ADDREF_INHERITED(nsDOMSVGZoomEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMSVGZoomEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMSVGZoomEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGZoomEvent)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGZoomEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
//----------------------------------------------------------------------
// nsIDOMSVGZoomEvent methods:
/* readonly attribute SVGRect zoomRectScreen; */
NS_IMETHODIMP nsDOMSVGZoomEvent::GetZoomRectScreen(nsIDOMSVGRect **aZoomRectScreen)
{
// The spec says about this attribute:
//
// The specified zoom rectangle in screen units.
// The object itself and its contents are both readonly.
//
// This is so badly underspecified we don't implement it. It was probably
// thrown in without much thought as a way of finding the zoom box ASV style
// zooming uses. I don't see how this is useful though since SVGZoom event's
// get dispatched *after* the zoom level has changed.
//
// Be sure to use NS_NewSVGReadonlyRect and not NS_NewSVGRect if we
// eventually do implement this!
*aZoomRectScreen = nsnull;
NS_NOTYETIMPLEMENTED("nsDOMSVGZoomEvent::GetZoomRectScreen");
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute float previousScale; */
NS_IMETHODIMP
nsDOMSVGZoomEvent::GetPreviousScale(float *aPreviousScale)
{
*aPreviousScale = mPreviousScale;
return NS_OK;
}
/* readonly attribute SVGPoint previousTranslate; */
NS_IMETHODIMP
nsDOMSVGZoomEvent::GetPreviousTranslate(nsIDOMSVGPoint **aPreviousTranslate)
{
*aPreviousTranslate = mPreviousTranslate;
NS_IF_ADDREF(*aPreviousTranslate);
return NS_OK;
}
/* readonly attribute float newScale; */
NS_IMETHODIMP nsDOMSVGZoomEvent::GetNewScale(float *aNewScale)
{
*aNewScale = mNewScale;
return NS_OK;
}
/* readonly attribute SVGPoint newTranslate; */
NS_IMETHODIMP
nsDOMSVGZoomEvent::GetNewTranslate(nsIDOMSVGPoint **aNewTranslate)
{
*aNewTranslate = mNewTranslate;
NS_IF_ADDREF(*aNewTranslate);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// Exported creation functions:
nsresult
NS_NewDOMSVGZoomEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsGUIEvent *aEvent)
{
nsDOMSVGZoomEvent* it = new nsDOMSVGZoomEvent(aPresContext, aEvent);
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
return CallQueryInterface(it, aInstancePtrResult);
}

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_SVGZOOMEVENT_H__
#define __NS_SVGZOOMEVENT_H__
#include "nsIDOMSVGZoomEvent.h"
#include "nsDOMUIEvent.h"
#include "nsIDOMSVGSVGElement.h"
class nsDOMSVGZoomEvent : public nsIDOMSVGZoomEvent,
public nsDOMUIEvent
{
public:
nsDOMSVGZoomEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent);
// nsISupports interface:
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMSVGZoomEvent interface:
NS_DECL_NSIDOMSVGZOOMEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
private:
float mPreviousScale;
nsCOMPtr<nsIDOMSVGPoint> mPreviousTranslate;
float mNewScale;
nsCOMPtr<nsIDOMSVGPoint> mNewTranslate;
};
#endif // __NS_SVGZOOMEVENT_H__

Просмотреть файл

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_SVGEVENT_H__
#define __NS_SVGEVENT_H__
#include "nsIDOMEventListener.h"
class nsIDOMEvent;
/*
* SVG event listener interface.
*/
#define NS_IDOMSVGLISTENER_IID \
{ 0xcb6f30f1, 0x5754, 0x49a3, { 0xa6, 0x6f, 0x2d, 0x6b, 0xa1, 0xb6, 0x3a, 0x58 } }
class nsIDOMSVGListener : public nsIDOMEventListener {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMSVGLISTENER_IID)
NS_IMETHOD Load (nsIDOMEvent* aEvent) = 0;
NS_IMETHOD Unload (nsIDOMEvent* aEvent) = 0;
NS_IMETHOD Abort (nsIDOMEvent* aEvent) = 0;
NS_IMETHOD Error (nsIDOMEvent* aEvent) = 0;
NS_IMETHOD Resize (nsIDOMEvent* aEvent) = 0;
NS_IMETHOD Scroll (nsIDOMEvent* aEvent) = 0;
};
#endif // __NS_SVGEVENT_H__

Просмотреть файл

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_SVGZOOMEVENT_H__
#define __NS_SVGZOOMEVENT_H__
#include "nsIDOMEventListener.h"
class nsIDOMEvent;
/*
* SVG zoom event listener interface.
*/
#define NS_IDOMSVGZOOMLISTENER_IID \
{ 0xccbeadab, 0xb3fe, 0x42f7, { 0x90, 0xed, 0xd6, 0xe4, 0x0f, 0x71, 0x2c, 0x29 } }
class nsIDOMSVGZoomListener : public nsIDOMEventListener {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMSVGZOOMLISTENER_IID)
NS_IMETHOD Zoom (nsIDOMEvent* aEvent) = 0;
};
#endif // __NS_SVGZOOMEVENT_H__

Просмотреть файл

@ -21,6 +21,7 @@
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
* Jonathan Watt <jonathan.watt@strath.ac.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -50,7 +51,7 @@ class nsISVGEnum;
// nsISVGSVGElement: private interface implemented by <svg>-elements
#define NS_ISVGSVGELEMENT_IID \
{ 0x8ae345f3, 0x5232, 0x426b, { 0xba, 0x23, 0x47, 0x1e, 0x45, 0x64, 0x50, 0xf9 } }
{ 0x968b7ff3, 0xcaa7, 0x4604, { 0x92, 0x98, 0x7a, 0x66, 0xee, 0x91, 0x83, 0xca } }
class nsISVGSVGElement : public nsIDOMSVGSVGElement
{
@ -60,6 +61,34 @@ public:
NS_IMETHOD SetParentCoordCtxProvider(nsSVGCoordCtxProvider *parentCtx)=0;
NS_IMETHOD GetCurrentScaleNumber(nsIDOMSVGNumber **aResult)=0;
NS_IMETHOD GetZoomAndPanEnum(nsISVGEnum **aResult)=0;
/**
* 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).
*/
NS_IMETHOD SetCurrentScaleTranslate(float s, float x, float y)=0;
/**
* For use by pan controls to allow currentTranslate.x and currentTranslate.y
* to be set by a single operation that dispatches a single SVGScroll event
* (instead of two).
*/
NS_IMETHOD SetCurrentTranslate(float x, float y)=0;
/**
* Record the current values of currentScale, currentTranslate.x and
* currentTranslate.y prior to changing the value of one of them.
*/
NS_IMETHOD_(void) RecordCurrentScaleTranslate()=0;
/**
* Retrieve the value of currentScale, currentTranslate.x or
* currentTranslate.y prior to the last change made to any one of them.
*/
NS_IMETHOD_(float) GetPreviousScale()=0;
NS_IMETHOD_(float) GetPreviousTranslate_x()=0;
NS_IMETHOD_(float) GetPreviousTranslate_y()=0;
};
#endif // __NS_ISVGSVGELEMENT__

Просмотреть файл

@ -139,13 +139,19 @@ SVG_ATOM(markerWidth, "markerWidth")
SVG_ATOM(mask, "mask")
SVG_ATOM(media, "media")
SVG_ATOM(offset, "offset")
SVG_ATOM(onabort, "onabort")
SVG_ATOM(onclick, "onclick")
SVG_ATOM(onerror, "onerror")
SVG_ATOM(onload, "onload")
SVG_ATOM(onmousedown, "onmousedown")
SVG_ATOM(onmouseup, "onmouseup")
SVG_ATOM(onmouseover, "onmouseover")
SVG_ATOM(onmousemove, "onmousemove")
SVG_ATOM(onmouseout, "onmouseout")
SVG_ATOM(onload, "onload")
SVG_ATOM(onresize, "onresize")
SVG_ATOM(onscroll, "onscroll")
SVG_ATOM(onunload, "onunload")
SVG_ATOM(onzoom, "onzoom")
SVG_ATOM(opacity, "opacity")
SVG_ATOM(orient, "orient")
SVG_ATOM(overflow, "overflow")

Просмотреть файл

@ -53,6 +53,7 @@
#include "nsIServiceManager.h"
#include "nsIXBLService.h"
#include "nsSVGAtoms.h"
#include "nsLayoutAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsICSSStyleRule.h"
#include "nsISVGSVGElement.h"
@ -230,9 +231,9 @@ nsSVGElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix,
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(getter_AddRefs(manager));
if (manager) {
nsIAtom* eventName = GetEventNameForAttr(aName);
nsIDocument *ownerDoc = GetOwnerDoc();
manager->AddScriptEventListener(NS_STATIC_CAST(nsIContent*, this), aName,
manager->AddScriptEventListener(NS_STATIC_CAST(nsIContent*, this), eventName,
aValue, PR_TRUE,
!nsContentUtils::IsChromeDoc(ownerDoc));
}
@ -249,9 +250,9 @@ nsSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
if (aNamespaceID == kNameSpaceID_None && IsEventName(aName)) {
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(getter_AddRefs(manager));
if (manager) {
manager->RemoveScriptEventListener(aName);
nsIAtom* eventName = GetEventNameForAttr(aName);
manager->RemoveScriptEventListener(eventName);
}
}
@ -840,7 +841,9 @@ nsSVGElement::IsGraphicElementEventName(nsIAtom* aName)
return PR_FALSE;
}
return (aName == nsSVGAtoms::onclick ||
return (aName == nsSVGAtoms::onabort ||
aName == nsSVGAtoms::onclick ||
aName == nsSVGAtoms::onerror ||
aName == nsSVGAtoms::onload ||
aName == nsSVGAtoms::onmousedown ||
aName == nsSVGAtoms::onmouseup ||
@ -848,3 +851,24 @@ nsSVGElement::IsGraphicElementEventName(nsIAtom* aName)
aName == nsSVGAtoms::onmousemove ||
aName == nsSVGAtoms::onmouseout);
}
/* static */
nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr)
{
if (aAttr == nsSVGAtoms::onload)
return nsLayoutAtoms::onSVGLoad;
if (aAttr == nsSVGAtoms::onunload)
return nsLayoutAtoms::onSVGUnload;
if (aAttr == nsSVGAtoms::onabort)
return nsLayoutAtoms::onSVGAbort;
if (aAttr == nsSVGAtoms::onerror)
return nsLayoutAtoms::onSVGError;
if (aAttr == nsSVGAtoms::onresize)
return nsLayoutAtoms::onSVGResize;
if (aAttr == nsSVGAtoms::onscroll)
return nsLayoutAtoms::onSVGScroll;
if (aAttr == nsSVGAtoms::onzoom)
return nsLayoutAtoms::onSVGZoom;
return aAttr;
}

Просмотреть файл

@ -157,6 +157,7 @@ protected:
PRInt32 aNamespaceID = kNameSpaceID_None);
static PRBool IsGraphicElementEventName(nsIAtom* aName);
static nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr);
nsCOMPtr<nsICSSStyleRule> mContentStyleRule;
nsAttrAndChildArray mMappedAttributes;

Просмотреть файл

@ -21,6 +21,7 @@
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
* Jonathan Watt <jonathan.watt@strath.ac.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -161,3 +162,36 @@ nsSVGPoint::GetValueString(nsAString& aValue)
NS_NOTYETIMPLEMENTED("nsSVGPoint::GetValueString");
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////
// Implement a readonly version of SVGPoint
//
// We need this because attributes of some SVG interfaces *and* the objects the
// attributes refer to (including SVGPoints) are supposed to be readonly
class nsSVGReadonlyPoint : public nsSVGPoint
{
public:
nsSVGReadonlyPoint(float x, float y)
: nsSVGPoint(x, y)
{
};
// override setters to make the whole object readonly
NS_IMETHODIMP SetX(float) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
NS_IMETHODIMP SetY(float) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
NS_IMETHODIMP SetValueString(const nsAString&) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
};
nsresult
NS_NewSVGReadonlyPoint(nsIDOMSVGPoint** result, float x, float y)
{
*result = new nsSVGReadonlyPoint(x, y);
if (!*result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*result);
return NS_OK;
}

Просмотреть файл

@ -21,6 +21,7 @@
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
* Jonathan Watt <jonathan.watt@strath.ac.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -44,4 +45,7 @@
nsresult
NS_NewSVGPoint(nsIDOMSVGPoint** result, float x = 0.0f, float y = 0.0f);
nsresult
NS_NewSVGReadonlyPoint(nsIDOMSVGPoint** result, float x = 0.0f, float y = 0.0f);
#endif //__NS_SVGPOINT_H__

Просмотреть файл

@ -21,6 +21,7 @@
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
* Jonathan Watt <jonathan.watt@strath.ac.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -45,6 +46,7 @@
#include "nsWeakReference.h"
#include "nsIDOMSVGLength.h"
#include "nsContentUtils.h"
#include "nsDOMError.h"
////////////////////////////////////////////////////////////////////////
// nsSVGRect class
@ -205,6 +207,31 @@ NS_IMETHODIMP nsSVGRect::SetHeight(float aHeight)
}
////////////////////////////////////////////////////////////////////////
// Implement a readonly version of SVGRect
//
// We need this because attributes of some SVG interfaces *and* the objects the
// attributes refer to (including SVGRects) are supposed to be readonly
class nsSVGReadonlyRect : public nsSVGRect
{
public:
nsSVGReadonlyRect(float x, float y, float width, float height)
: nsSVGRect(x, y, width, height)
{
};
// override setters to make the whole object readonly
NS_IMETHODIMP SetX(float) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
NS_IMETHODIMP SetY(float) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
NS_IMETHODIMP SetWidth(float) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
NS_IMETHODIMP SetHeight(float) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
NS_IMETHODIMP SetValueString(const nsAString&) { return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; }
};
////////////////////////////////////////////////////////////////////////
// nsSVGViewBox : a special kind of nsIDOMSVGRect that defaults to
// (0,0,viewportWidth.value,viewportHeight.value) until set explicitly.
@ -362,6 +389,16 @@ NS_NewSVGRect(nsIDOMSVGRect** result, float x, float y,
return NS_OK;
}
nsresult
NS_NewSVGReadonlyRect(nsIDOMSVGRect** result, float x, float y,
float width, float height)
{
*result = new nsSVGReadonlyRect(x, y, width, height);
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*result);
return NS_OK;
}
nsresult
NS_NewSVGViewBox(nsIDOMSVGRect** result,
nsIDOMSVGLength *viewportWidth,

Просмотреть файл

@ -21,6 +21,7 @@
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
* Jonathan Watt <jonathan.watt@strath.ac.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -48,6 +49,11 @@ NS_NewSVGRect(nsIDOMSVGRect** result,
float x=0.0f, float y=0.0f,
float width=0.0f, float height=0.0f);
nsresult
NS_NewSVGReadonlyRect(nsIDOMSVGRect** result,
float x=0.0f, float y=0.0f,
float width=0.0f, float height=0.0f);
// A 'viewbox' is a special kind of nsIDOMSVGRect that defaults to
// (0,0,viewportWidth.value,viewportHeight.value) until set explicitly.
nsresult

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsIDOMSVGZoomAndPan.h"
#include "nsSVGEnum.h"
#include "nsISVGChildFrame.h"
#include "nsGUIEvent.h"
typedef nsSVGStylableElement nsSVGSVGElementBase;
@ -103,6 +104,12 @@ public:
NS_IMETHOD SetParentCoordCtxProvider(nsSVGCoordCtxProvider *parentCtx);
NS_IMETHOD GetCurrentScaleNumber(nsIDOMSVGNumber **aResult);
NS_IMETHOD GetZoomAndPanEnum(nsISVGEnum **aResult);
NS_IMETHOD SetCurrentScaleTranslate(float s, float x, float y);
NS_IMETHOD SetCurrentTranslate(float x, float y);
NS_IMETHOD_(void) RecordCurrentScaleTranslate();
NS_IMETHOD_(float) GetPreviousTranslate_x();
NS_IMETHOD_(float) GetPreviousTranslate_y();
NS_IMETHOD_(float) GetPreviousScale();
// nsIStyledContent interface
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -129,10 +136,16 @@ protected:
nsCOMPtr<nsIDOMSVGAnimatedLength> mY;
// zoom and pan
// IMPORTANT: only RecordCurrentScaleTranslate should change the "mPreviousX"
// members below - see the comment in RecordCurrentScaleTranslate
nsCOMPtr<nsISVGEnum> mZoomAndPan;
nsCOMPtr<nsIDOMSVGPoint> mCurrentTranslate;
nsCOMPtr<nsIDOMSVGNumber> mCurrentScale;
float mPreviousTranslate_x;
float mPreviousTranslate_y;
float mPreviousScale;
PRBool mZooming;
PRInt32 mRedrawSuspendCount;
};
@ -302,6 +315,10 @@ nsSVGSVGElement::Init()
NS_ADD_SVGVALUE_OBSERVER(mCurrentTranslate);
}
// initialise "Previous" values
RecordCurrentScaleTranslate();
mZooming = PR_FALSE;
return rv;
}
@ -482,6 +499,8 @@ NS_IMETHODIMP
nsSVGSVGElement::SetCurrentScale(float aCurrentScale)
{
return mCurrentScale->SetValue(aCurrentScale);
// We have to dispatch the required SVGZoom event from DidModifySVGObservable
// since dispatching it here is too late (i.e. after repaint)
}
/* readonly attribute nsIDOMSVGPoint currentTranslate; */
@ -1240,6 +1259,91 @@ nsSVGSVGElement::GetZoomAndPanEnum(nsISVGEnum **aResult)
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y)
{
RecordCurrentScaleTranslate();
mZooming = PR_TRUE; // prevent event dispatch by the following setters
mCurrentScale->SetValue(s);
mCurrentTranslate->SetX(x);
mCurrentTranslate->SetY(y);
mZooming = PR_FALSE;
// now dispatch an SVGZoom event if we are the root element
nsIDocument* doc = GetCurrentDoc();
if (doc) {
nsIPresShell* presShell = doc->GetShellAt(0);
NS_ASSERTION(presShell, "no presShell");
if (presShell &&
doc->GetRootContent() == NS_STATIC_CAST(nsIContent*, this)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsGUIEvent event(PR_TRUE, NS_SVG_ZOOM, 0);
event.eventStructType = NS_SVGZOOM_EVENT;
presShell->HandleDOMEventWithTarget(this, &event, &status);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::SetCurrentTranslate(float x, float y)
{
RecordCurrentScaleTranslate();
mZooming = PR_TRUE; // prevent event dispatch by the following setters
mCurrentTranslate->SetX(x);
mCurrentTranslate->SetY(y);
mZooming = PR_FALSE;
// now dispatch an SVGScroll event if we are the root element
nsIDocument* doc = GetCurrentDoc();
if (doc) {
nsIPresShell* presShell = doc->GetShellAt(0);
NS_ASSERTION(presShell, "no presShell");
if (presShell &&
doc->GetRootContent() == NS_STATIC_CAST(nsIContent*, this)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(PR_TRUE, NS_SVG_SCROLL);
event.eventStructType = NS_SVG_EVENT;
presShell->HandleDOMEventWithTarget(this, &event, &status);
}
}
return NS_OK;
}
NS_IMETHODIMP_(void)
nsSVGSVGElement::RecordCurrentScaleTranslate()
{
// IMPORTANT: If either mCurrentTranslate *or* mCurrentScale is changed then
// mPreviousTranslate_x, mPreviousTranslate_y *and* mPreviousScale must all
// be updated otherwise SVGZoomEvents will end up with invalid data. I.e. an
// SVGZoomEvent's properties previousScale and previousTranslate must contain
// the state of currentScale and currentTranslate immediately before the
// 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.
mCurrentScale->GetValue(&mPreviousScale);
mCurrentTranslate->GetX(&mPreviousTranslate_x);
mCurrentTranslate->GetY(&mPreviousTranslate_y);
}
NS_IMETHODIMP_(float)
nsSVGSVGElement::GetPreviousTranslate_x()
{
return mPreviousTranslate_x;
}
NS_IMETHODIMP_(float)
nsSVGSVGElement::GetPreviousTranslate_y()
{
return mPreviousTranslate_y;
}
NS_IMETHODIMP_(float)
nsSVGSVGElement::GetPreviousScale()
{
return mPreviousScale;
}
//----------------------------------------------------------------------
// nsIStyledContent methods
@ -1268,25 +1372,70 @@ nsSVGSVGElement::WillModifySVGObservable(nsISVGValue* observable,
#ifdef DEBUG
printf("viewport/viewbox/preserveAspectRatio will be changed\n");
#endif
if (!mZooming) {
// Modification isn't due to calling SetCurrent[Scale]Translate, so if
// currentScale or currentTranslate is about to change we must record their
// current values.
nsCOMPtr<nsIDOMSVGNumber> n = do_QueryInterface(observable);
if (n && n==mCurrentScale) {
RecordCurrentScaleTranslate();
}
else {
nsCOMPtr<nsIDOMSVGPoint> p = do_QueryInterface(observable);
if (p && p==mCurrentTranslate) {
RecordCurrentScaleTranslate();
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsSVGSVGElement::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
// either viewport, viewbox or preserveAspectRatio have changed
// invalidate viewbox -> viewport xform & inform frames
mViewBoxToViewportTransform = nsnull;
nsIDocument* doc = GetCurrentDoc();
if (!doc) return NS_ERROR_FAILURE;
nsIPresShell* presShell = doc->GetShellAt(0);
NS_ASSERTION(presShell, "no presShell");
if (!presShell) return NS_ERROR_FAILURE;
// If currentScale or currentTranslate has changed, we are the root element,
// and the changes wasn't caused by SetCurrent[Scale]Translate then we must
// dispatch an SVGZoom or SVGScroll DOM event before repainting
nsCOMPtr<nsIDOMSVGNumber> n = do_QueryInterface(observable);
if (n && n==mCurrentScale) {
if (!mZooming &&
doc->GetRootContent() == NS_STATIC_CAST(nsIContent*, this)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsGUIEvent event(PR_TRUE, NS_SVG_ZOOM, 0);
event.eventStructType = NS_SVGZOOM_EVENT;
presShell->HandleDOMEventWithTarget(this, &event, &status);
}
else {
return NS_OK; // we don't care about currentScale changes on non-root
}
}
else {
nsCOMPtr<nsIDOMSVGPoint> p = do_QueryInterface(observable);
if (p && p==mCurrentTranslate) {
if (!mZooming &&
doc->GetRootContent() == NS_STATIC_CAST(nsIContent*, this)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(PR_TRUE, NS_SVG_SCROLL);
event.eventStructType = NS_SVG_EVENT;
presShell->HandleDOMEventWithTarget(this, &event, &status);
}
else {
return NS_OK; // we don't care about currentScale changes on non-root
}
}
}
// invalidate viewbox -> viewport xform & inform frames
mViewBoxToViewportTransform = nsnull;
nsIFrame* frame =
presShell->GetPrimaryFrameFor(NS_STATIC_CAST(nsIStyledContent*, this));
if (frame) {
@ -1318,7 +1467,17 @@ nsSVGSVGElement::DidModifySVGObservable (nsISVGValue* observable,
PRBool
nsSVGSVGElement::IsEventName(nsIAtom* aName)
{
return IsGraphicElementEventName(aName);
return IsGraphicElementEventName(aName) ||
/* The following are for events that are only applicable to outermost 'svg'
elements. We don't check if we're an outer 'svg' element in case we're not
inserted into the document yet, but since the target of the events in
question will always be the outermost 'svg' element, this shouldn't cause
any real problems.
*/
aName == nsSVGAtoms::onunload ||
aName == nsSVGAtoms::onscroll ||
aName == nsSVGAtoms::onzoom;
}
//----------------------------------------------------------------------

Просмотреть файл

@ -1008,7 +1008,8 @@ nsXMLContentSink::HandleEndElement(const PRUnichar *aName)
if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
content->HasAttr(kNameSpaceID_None, nsSVGAtoms::onload)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(PR_TRUE, NS_PAGE_LOAD);
nsEvent event(PR_TRUE, NS_SVG_LOAD);
event.eventStructType = NS_SVG_EVENT;
nsIPresShell *presShell = mDocument->GetShellAt(0);
if (presShell)
presShell->HandleDOMEventWithTarget(content, &event, &status);

Просмотреть файл

@ -70,6 +70,7 @@ XPIDLSRCS = \
nsIDOMSVGDocument.idl \
nsIDOMSVGElement.idl \
nsIDOMSVGEllipseElement.idl \
nsIDOMSVGEvent.idl \
nsIDOMSVGException.idl \
nsIDOMSVGFitToViewBox.idl \
nsIDOMSVGForeignObjectElem.idl \
@ -112,6 +113,7 @@ XPIDLSRCS = \
nsIDOMSVGURIReference.idl \
nsIDOMSVGUseElement.idl \
nsIDOMSVGZoomAndPan.idl \
nsIDOMSVGZoomEvent.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,48 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMEvent.idl"
/**
* For more information on this interface please see
* http://www.w3.org/TR/SVG11/script.html#InterfaceSVGEvent
*/
[scriptable, uuid(13aed1cc-a505-45d5-bbc2-0052c6bf200f)]
interface nsIDOMSVGEvent : nsIDOMEvent
{
};

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla SVG Project code.
*
* The Initial Developer of the Original Code is Jonathan Watt.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Watt <jonathan.watt@strath.ac.uk> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMUIEvent.idl"
/**
* For more information on this interface please see
* http://www.w3.org/TR/SVG11/script.html#InterfaceSVGZoomEvent
*/
interface nsIDOMSVGRect;
interface nsIDOMSVGPoint;
[scriptable, uuid(339a8c7a-552e-4cbc-8d96-8370a3939358)]
interface nsIDOMSVGZoomEvent : nsIDOMUIEvent
{
readonly attribute nsIDOMSVGRect zoomRectScreen;
readonly attribute float previousScale;
readonly attribute nsIDOMSVGPoint previousTranslate;
readonly attribute float newScale;
readonly attribute nsIDOMSVGPoint newTranslate;
};

Просмотреть файл

@ -288,6 +288,7 @@ enum nsDOMClassInfoID {
eDOMClassInfo_SVGAnimatedRect_id,
eDOMClassInfo_SVGAnimatedString_id,
eDOMClassInfo_SVGAnimatedTransformList_id,
eDOMClassInfo_SVGEvent_id,
eDOMClassInfo_SVGException_id,
eDOMClassInfo_SVGLength_id,
eDOMClassInfo_SVGLengthList_id,
@ -320,6 +321,7 @@ enum nsDOMClassInfoID {
eDOMClassInfo_SVGRect_id,
eDOMClassInfo_SVGTransform_id,
eDOMClassInfo_SVGTransformList_id,
eDOMClassInfo_SVGZoomEvent_id,
#endif // MOZ_SVG
// Canvas

Просмотреть файл

@ -336,6 +336,7 @@
#include "nsIDOMSVGDocument.h"
#include "nsIDOMSVGElement.h"
#include "nsIDOMSVGEllipseElement.h"
#include "nsIDOMSVGEvent.h"
#include "nsIDOMSVGException.h"
#include "nsIDOMSVGFitToViewBox.h"
#ifdef MOZ_SVG_FOREIGNOBJECT
@ -378,6 +379,7 @@
#include "nsIDOMSVGURIReference.h"
#include "nsIDOMSVGUseElement.h"
#include "nsIDOMSVGZoomAndPan.h"
#include "nsIDOMSVGZoomEvent.h"
#endif // MOZ_SVG
#ifdef MOZ_ENABLE_CANVAS
@ -929,6 +931,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGAnimatedTransformList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGException, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
@ -993,6 +997,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#endif // MOZ_SVG
NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsHTMLElementSH,
@ -2584,6 +2590,11 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGEvent, nsIDOMSVGEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGException, nsIDOMSVGException)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGException)
DOM_CLASSINFO_MAP_ENTRY(nsIException)
@ -2712,6 +2723,11 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(SVGTransformList, nsIDOMSVGTransformList)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformList)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGZoomEvent, nsIDOMSVGZoomEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#endif // MOZ_SVG
DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)

Просмотреть файл

@ -216,6 +216,17 @@ LAYOUT_ATOM(onDOMCharacterDataModified, "onDOMCharacterDataModified")
LAYOUT_ATOM(onpageshow, "onpageshow")
LAYOUT_ATOM(onpagehide, "onpagehide")
#ifdef MOZ_SVG
// Note: the attribute name for the 'SVGLoad' event is actually 'onload' etc.
LAYOUT_ATOM(onSVGLoad, "onSVGLoad")
LAYOUT_ATOM(onSVGUnload, "onSVGUnload")
LAYOUT_ATOM(onSVGAbort, "onSVGAbort")
LAYOUT_ATOM(onSVGError, "onSVGError")
LAYOUT_ATOM(onSVGResize, "onSVGResize")
LAYOUT_ATOM(onSVGScroll, "onSVGScroll")
LAYOUT_ATOM(onSVGZoom, "onSVGZoom")
#endif // MOZ_SVG
// Alphabetical list of languages for lang-specific transforms
LAYOUT_ATOM(Japanese, "ja")
LAYOUT_ATOM(Chinese, "zh-CN")

Просмотреть файл

@ -78,6 +78,7 @@
#include "nsIDialogParamBlock.h"
#include "nsIDOMWindow.h"
#include "nsLayoutAtoms.h"
#include "nsIDocument.h"
////////////////////////////////////////////////////////////////////////
// VMRectInvalidator: helper class for invalidating rects on the viewmanager.
@ -326,10 +327,6 @@ nsSVGOuterSVGFrame::~nsSVGOuterSVGFrame()
if (mZoomAndPan)
NS_REMOVE_SVGVALUE_OBSERVER(mZoomAndPan);
if (mCurrentTranslate)
NS_REMOVE_SVGVALUE_OBSERVER(mCurrentTranslate);
if (mCurrentScale)
NS_REMOVE_SVGVALUE_OBSERVER(mCurrentScale);
RemoveAsWidthHeightObserver();
}
@ -420,13 +417,15 @@ nsresult nsSVGOuterSVGFrame::Init()
NS_ASSERTION(SVGElement, "wrong content element");
SVGElement->SetParentCoordCtxProvider(this);
SVGElement->GetZoomAndPanEnum(getter_AddRefs(mZoomAndPan));
NS_ADD_SVGVALUE_OBSERVER(mZoomAndPan);
SVGElement->GetCurrentTranslate(getter_AddRefs(mCurrentTranslate));
NS_ADD_SVGVALUE_OBSERVER(mCurrentTranslate);
SVGElement->GetCurrentScaleNumber(getter_AddRefs(mCurrentScale));
NS_ADD_SVGVALUE_OBSERVER(mCurrentScale);
// we only care about our content's zoom and pan values if it's the root element
nsIDocument* doc = mContent->GetCurrentDoc();
if (doc && doc->GetRootContent() == mContent) {
SVGElement->GetZoomAndPanEnum(getter_AddRefs(mZoomAndPan));
NS_ADD_SVGVALUE_OBSERVER(mZoomAndPan);
SVGElement->GetCurrentTranslate(getter_AddRefs(mCurrentTranslate));
SVGElement->GetCurrentScaleNumber(getter_AddRefs(mCurrentScale));
}
AddAsWidthHeightObserver();
SuspendRedraw();
return NS_OK;
@ -639,7 +638,6 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
AddAsWidthHeightObserver();
UnsuspendRedraw();
return NS_OK;
}
@ -1111,20 +1109,24 @@ nsSVGOuterSVGFrame::GetCanvasTM()
NS_ASSERTION(svgElement, "wrong content element");
svgElement->GetViewboxToViewportTransform(getter_AddRefs(mCanvasTM));
PRUint16 val;
mZoomAndPan->GetIntegerValue(val);
if (val == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
nsCOMPtr<nsIDOMSVGMatrix> temp;
float scale, x, y;
mCurrentScale->GetValue(&scale);
mCurrentTranslate->GetX(&x);
mCurrentTranslate->GetY(&y);
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Translate(x, y, getter_AddRefs(temp));
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
temp.swap(mCanvasTM);
if (mZoomAndPan) {
// our content is the document element so we must premultiply the values
// of it's currentScale and currentTranslate properties
PRUint16 val;
mZoomAndPan->GetIntegerValue(val);
if (val == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
nsCOMPtr<nsIDOMSVGMatrix> temp;
float scale, x, y;
mCurrentScale->GetValue(&scale);
mCurrentTranslate->GetX(&x);
mCurrentTranslate->GetY(&y);
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Translate(x, y, getter_AddRefs(temp));
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
temp.swap(mCanvasTM);
}
}
}
nsIDOMSVGMatrix* retval = mCanvasTM.get();

Просмотреть файл

@ -93,6 +93,10 @@ class nsIURI;
#define NS_UI_EVENT 27
#define NS_QUERYCARETRECT_EVENT 28
#define NS_PAGETRANSITION_EVENT 29
#ifdef MOZ_SVG
#define NS_SVG_EVENT 30
#define NS_SVGZOOM_EVENT 31
#endif // MOZ_SVG
// These flags are sort of a mess. They're sort of shared between event
// listener flags and event flags, but only some of them. You've been
@ -335,6 +339,21 @@ class nsIURI;
#define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
#define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
#ifdef MOZ_SVG
// SVG events
#define NS_SVG_EVENT_START 2800
#define NS_SVG_LOAD (NS_SVG_EVENT_START)
#define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
#define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
#define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
#define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
#define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
// SVG Zoom events
#define NS_SVGZOOM_EVENT_START 2900
#define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
#endif // MOZ_SVG
/**
* Return status for event processors, nsEventStatus, is defined in
* nsEvent.h.