mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Implement events part of CSS transitions: add support for the transitionend DOM event. (Bug 531585) r=smaug
This commit is contained in:
parent
026f0e2d0b
commit
cef8b7a5f8
@ -505,6 +505,8 @@ nsContentUtils::InitializeEventTable() {
|
||||
{ &nsGkAtoms::onMozRotateGesture, { NS_SIMPLE_GESTURE_ROTATE, EventNameType_None } },
|
||||
{ &nsGkAtoms::onMozTapGesture, { NS_SIMPLE_GESTURE_TAP, EventNameType_None } },
|
||||
{ &nsGkAtoms::onMozPressTapGesture, { NS_SIMPLE_GESTURE_PRESSTAP, EventNameType_None } },
|
||||
|
||||
{ &nsGkAtoms::ontransitionend, { NS_TRANSITION_END, EventNameType_None }},
|
||||
};
|
||||
|
||||
sEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>;
|
||||
|
@ -678,6 +678,7 @@ GK_ATOM(onselect, "onselect")
|
||||
GK_ATOM(onset, "onset")
|
||||
GK_ATOM(onsubmit, "onsubmit")
|
||||
GK_ATOM(ontext, "ontext")
|
||||
GK_ATOM(ontransitionend, "ontransitionend")
|
||||
GK_ATOM(onunderflow, "onunderflow")
|
||||
GK_ATOM(onunload, "onunload")
|
||||
GK_ATOM(open, "open")
|
||||
|
@ -115,4 +115,6 @@ nsresult
|
||||
NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsSimpleGestureEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsScrollAreaEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMTransitionEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsTransitionEvent* aEvent);
|
||||
#endif // nsIPrivateDOMEvent_h__
|
||||
|
@ -81,6 +81,7 @@ CPPSRCS = \
|
||||
nsDOMSimpleGestureEvent.cpp \
|
||||
nsDOMEventTargetHelper.cpp \
|
||||
nsDOMScrollAreaEvent.cpp \
|
||||
nsDOMTransitionEvent.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
@ -92,7 +92,8 @@ static const char* const sEventNames[] = {
|
||||
"MozRotateGesture",
|
||||
"MozTapGesture",
|
||||
"MozPressTapGesture",
|
||||
"MozScrolledAreaChanged"
|
||||
"MozScrolledAreaChanged",
|
||||
"transitionend"
|
||||
};
|
||||
|
||||
static char *sPopupAllowedEvents;
|
||||
@ -705,6 +706,10 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
|
||||
else if (atom == nsGkAtoms::onMozTapGesture)
|
||||
mEvent->message = NS_SIMPLE_GESTURE_TAP;
|
||||
}
|
||||
else if (mEvent->eventStructType == NS_TRANSITION_EVENT) {
|
||||
if (atom == nsGkAtoms::ontransitionend)
|
||||
mEvent->message = NS_TRANSITION_END;
|
||||
}
|
||||
|
||||
if (mEvent->message == NS_USER_DEFINED_EVENT)
|
||||
mEvent->userType = atom;
|
||||
@ -1007,6 +1012,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
|
||||
newEvent = simpleGestureEvent;
|
||||
break;
|
||||
}
|
||||
case NS_TRANSITION_EVENT:
|
||||
{
|
||||
nsTransitionEvent* oldTransitionEvent =
|
||||
static_cast<nsTransitionEvent*>(mEvent);
|
||||
newEvent = new nsTransitionEvent(PR_FALSE, msg,
|
||||
oldTransitionEvent->propertyName,
|
||||
oldTransitionEvent->elapsedTime);
|
||||
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
NS_WARNING("Unknown event type!!!");
|
||||
@ -1495,6 +1510,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
return sEventNames[eDOMEvents_MozPressTapGesture];
|
||||
case NS_SCROLLEDAREACHANGED:
|
||||
return sEventNames[eDOMEvents_MozScrolledAreaChanged];
|
||||
case NS_TRANSITION_END:
|
||||
return sEventNames[eDOMEvents_transitionend];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -171,7 +171,8 @@ public:
|
||||
eDOMEvents_MozRotateGesture,
|
||||
eDOMEvents_MozTapGesture,
|
||||
eDOMEvents_MozPressTapGesture,
|
||||
eDOMEvents_MozScrolledAreaChanged
|
||||
eDOMEvents_MozScrolledAreaChanged,
|
||||
eDOMEvents_transitionend
|
||||
};
|
||||
|
||||
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
|
||||
|
114
content/events/src/nsDOMTransitionEvent.cpp
Normal file
114
content/events/src/nsDOMTransitionEvent.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||||
/* ***** 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 nsDOMTransitionEvent.
|
||||
*
|
||||
* The Initial Developer of the Original Code is the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (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 "nsDOMTransitionEvent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
nsDOMTransitionEvent::nsDOMTransitionEvent(nsPresContext *aPresContext,
|
||||
nsTransitionEvent *aEvent)
|
||||
: nsDOMEvent(aPresContext, aEvent ? aEvent
|
||||
: new nsTransitionEvent(PR_FALSE, 0,
|
||||
EmptyString(),
|
||||
0.0))
|
||||
{
|
||||
if (aEvent) {
|
||||
mEventIsInternal = PR_FALSE;
|
||||
}
|
||||
else {
|
||||
mEventIsInternal = PR_TRUE;
|
||||
mEvent->time = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
nsDOMTransitionEvent::~nsDOMTransitionEvent()
|
||||
{
|
||||
if (mEventIsInternal) {
|
||||
delete TransitionEvent();
|
||||
mEvent = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMTransitionEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMTransitionEvent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(TransitionEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMTransitionEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMTransitionEvent, nsDOMEvent)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMTransitionEvent::GetPropertyName(nsAString & aPropertyName)
|
||||
{
|
||||
aPropertyName = TransitionEvent()->propertyName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMTransitionEvent::GetElapsedTime(float *aElapsedTime)
|
||||
{
|
||||
*aElapsedTime = TransitionEvent()->elapsedTime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMTransitionEvent::InitTransitionEvent(const nsAString & typeArg,
|
||||
PRBool canBubbleArg,
|
||||
PRBool cancelableArg,
|
||||
const nsAString & propertyNameArg,
|
||||
float elapsedTimeArg)
|
||||
{
|
||||
nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
TransitionEvent()->propertyName = propertyNameArg;
|
||||
TransitionEvent()->elapsedTime = elapsedTimeArg;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewDOMTransitionEvent(nsIDOMEvent **aInstancePtrResult,
|
||||
nsPresContext *aPresContext,
|
||||
nsTransitionEvent *aEvent)
|
||||
{
|
||||
nsDOMTransitionEvent *it = new nsDOMTransitionEvent(aPresContext, aEvent);
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(it, aInstancePtrResult);
|
||||
}
|
66
content/events/src/nsDOMTransitionEvent.h
Normal file
66
content/events/src/nsDOMTransitionEvent.h
Normal file
@ -0,0 +1,66 @@
|
||||
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||||
/* ***** 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 nsDOMTransitionEvent.
|
||||
*
|
||||
* The Initial Developer of the Original Code is the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (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 nsDOMTransitionEvent_h_
|
||||
#define nsDOMTransitionEvent_h_
|
||||
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIDOMTransitionEvent.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsTransitionEvent;
|
||||
|
||||
class nsDOMTransitionEvent : public nsDOMEvent,
|
||||
public nsIDOMTransitionEvent
|
||||
{
|
||||
public:
|
||||
nsDOMTransitionEvent(nsPresContext *aPresContext,
|
||||
nsTransitionEvent *aEvent);
|
||||
~nsDOMTransitionEvent();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
NS_DECL_NSIDOMTRANSITIONEVENT
|
||||
|
||||
private:
|
||||
nsTransitionEvent* TransitionEvent() {
|
||||
NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_TRANSITION_EVENT,
|
||||
"unexpected struct type");
|
||||
return static_cast<nsTransitionEvent*>(mEvent);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* !defined(nsDOMTransitionEvent_h_) */
|
@ -721,6 +721,9 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
|
||||
case NS_SIMPLE_GESTURE_EVENT:
|
||||
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aPresContext,
|
||||
static_cast<nsSimpleGestureEvent*>(aEvent));
|
||||
case NS_TRANSITION_EVENT:
|
||||
return NS_NewDOMTransitionEvent(aDOMEvent, aPresContext,
|
||||
static_cast<nsTransitionEvent*>(aEvent));
|
||||
}
|
||||
|
||||
// For all other types of events, create a vanilla event object.
|
||||
@ -789,6 +792,10 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
|
||||
return NS_NewDOMPageTransitionEvent(aDOMEvent, aPresContext, nsnull);
|
||||
if (aEventType.LowerCaseEqualsLiteral("scrollareaevent"))
|
||||
return NS_NewDOMScrollAreaEvent(aDOMEvent, aPresContext, nsnull);
|
||||
// FIXME: Should get spec to say what the right string is here! This
|
||||
// is probably wrong!
|
||||
if (aEventType.LowerCaseEqualsLiteral("transitionevent"))
|
||||
return NS_NewDOMTransitionEvent(aDOMEvent, aPresContext, nsnull);
|
||||
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
@ -234,6 +234,7 @@
|
||||
#include "nsPaintRequest.h"
|
||||
#include "nsIDOMNotifyPaintEvent.h"
|
||||
#include "nsIDOMScrollAreaEvent.h"
|
||||
#include "nsIDOMTransitionEvent.h"
|
||||
#include "nsIDOMNSDocumentStyle.h"
|
||||
#include "nsIDOMDocumentRange.h"
|
||||
#include "nsIDOMDocumentTraversal.h"
|
||||
@ -1366,6 +1367,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(EventListenerInfo, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(TransitionEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
};
|
||||
|
||||
// Objects that shuld be constructable through |new Name();|
|
||||
@ -3787,6 +3790,11 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIEventListenerInfo)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(TransitionEvent, nsIDOMTransitionEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMTransitionEvent)
|
||||
DOM_CLASSINFO_EVENT_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
{
|
||||
PRUint32 i = NS_ARRAY_LENGTH(sClassInfoData);
|
||||
|
@ -489,6 +489,8 @@ enum nsDOMClassInfoID {
|
||||
|
||||
eDOMClassInfo_EventListenerInfo_id,
|
||||
|
||||
eDOMClassInfo_TransitionEvent_id,
|
||||
|
||||
// This one better be the last one in this list
|
||||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
@ -82,6 +82,7 @@ XPIDLSRCS = \
|
||||
nsIDOMNSMouseEvent.idl \
|
||||
nsIDOMOrientationEvent.idl \
|
||||
nsIDOMScrollAreaEvent.idl \
|
||||
nsIDOMTransitionEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
55
dom/interfaces/events/nsIDOMTransitionEvent.idl
Normal file
55
dom/interfaces/events/nsIDOMTransitionEvent.idl
Normal file
@ -0,0 +1,55 @@
|
||||
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||||
/* ***** 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 nsIDOMTransitionEvent.
|
||||
*
|
||||
* The Initial Developer of the Original Code is the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (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"
|
||||
|
||||
/**
|
||||
* Transition events are defined in:
|
||||
* http://www.w3.org/TR/css3-transitions/#transition-events-
|
||||
* http://dev.w3.org/csswg/css3-transitions/#transition-events-
|
||||
*/
|
||||
|
||||
[scriptable, uuid(3e49ea4c-6f23-4aff-bd8f-e587edf514ec)]
|
||||
interface nsIDOMTransitionEvent : nsIDOMEvent {
|
||||
readonly attribute DOMString propertyName;
|
||||
readonly attribute float elapsedTime;
|
||||
void initTransitionEvent(in DOMString typeArg,
|
||||
in boolean canBubbleArg,
|
||||
in boolean cancelableArg,
|
||||
in DOMString propertyNameArg,
|
||||
in float elapsedTimeArg);
|
||||
};
|
@ -91,7 +91,7 @@ class nsHashKey;
|
||||
#define NS_POPUP_EVENT 23
|
||||
#define NS_COMMAND_EVENT 24
|
||||
#define NS_SCROLLAREA_EVENT 25
|
||||
|
||||
#define NS_TRANSITION_EVENT 26
|
||||
|
||||
#define NS_UI_EVENT 27
|
||||
#ifdef MOZ_SVG
|
||||
@ -448,6 +448,8 @@ class nsHashKey;
|
||||
#define NS_SCROLLAREA_EVENT_START 4100
|
||||
#define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
|
||||
|
||||
#define NS_TRANSITION_EVENT_START 4200
|
||||
#define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
|
||||
|
||||
/**
|
||||
* Return status for event processors, nsEventStatus, is defined in
|
||||
@ -1329,6 +1331,21 @@ public:
|
||||
PRFloat64 delta; // Delta for magnify and rotate events
|
||||
};
|
||||
|
||||
class nsTransitionEvent : public nsEvent
|
||||
{
|
||||
public:
|
||||
nsTransitionEvent(PRBool isTrusted, PRUint32 msg,
|
||||
const nsString &propertyNameArg, float elapsedTimeArg)
|
||||
: nsEvent(isTrusted, msg, NS_TRANSITION_EVENT),
|
||||
propertyName(propertyNameArg), elapsedTime(elapsedTimeArg)
|
||||
{
|
||||
}
|
||||
|
||||
nsString propertyName;
|
||||
float elapsedTime;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Event status for D&D Event
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user