Merge inbound to m-c

This commit is contained in:
Wes Kocher 2014-03-18 14:15:03 -07:00
commit 679d927c40
284 changed files with 5795 additions and 4639 deletions

View File

@ -2997,6 +2997,18 @@
tab.setAttribute("titlechanged", "true");
break;
}
case "DOMWindowClose": {
if (this.tabs.length == 1) {
window.close();
return;
}
let tab = this._getTabForBrowser(browser);
if (tab) {
this.removeTab(tab);
}
break;
}
case "contextmenu": {
gContextMenuContentData = { event: aMessage.objects.event,
browser: browser };
@ -3063,6 +3075,7 @@
.useRemoteTabs;
if (remote) {
messageManager.addMessageListener("DOMTitleChanged", this);
messageManager.addMessageListener("DOMWindowClose", this);
messageManager.addMessageListener("contextmenu", this);
}
messageManager.addMessageListener("DOMWebNotificationClicked", this);

View File

@ -71,7 +71,7 @@ GCONF_VERSION=1.2.1
GIO_VERSION=2.20
STARTUP_NOTIFICATION_VERSION=0.8
DBUS_VERSION=0.60
SQLITE_VERSION=3.8.3.1
SQLITE_VERSION=3.8.4.1
MSMANIFEST_TOOL=

View File

@ -102,6 +102,9 @@ enum {
ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET);
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
class EventChainVisitor;
class EventListenerManager;
namespace dom {
@ -1105,18 +1108,18 @@ protected:
* @param aURI the uri of the link, set only if the return value is true [OUT]
* @return true if we can handle the link event, false otherwise
*/
bool CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor,
nsIURI** aURI) const;
bool CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor,
nsIURI** aURI) const;
/**
* Handle status bar updates before they can be cancelled.
*/
nsresult PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor);
nsresult PreHandleEventForLinks(EventChainPreVisitor& aVisitor);
/**
* Handle default actions for link event if the event isn't consumed yet.
*/
nsresult PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor);
nsresult PostHandleEventForLinks(EventChainPostVisitor& aVisitor);
/**
* Get the target of this link element. Consumers should established that

View File

@ -21,6 +21,7 @@ class nsIFrame;
class nsXBLBinding;
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class ShadowRoot;
struct CustomElementData;
@ -913,7 +914,8 @@ public:
// Overloaded from nsINode
virtual already_AddRefed<nsIURI> GetBaseURI() const MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(
mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsPurple() = 0;
virtual void RemovePurple() = 0;

View File

@ -10,6 +10,7 @@
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/AttrBinding.h"
#include "mozilla/dom/Element.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/InternalMutationEvent.h"
#include "nsContentCreatorFunctions.h"
#include "nsError.h"
@ -18,7 +19,6 @@
#include "nsIContentInlines.h"
#include "nsIDocument.h"
#include "nsIDOMUserDataHandler.h"
#include "nsEventDispatcher.h"
#include "nsGkAtoms.h"
#include "nsCOMArray.h"
#include "nsNameSpaceManager.h"
@ -361,7 +361,7 @@ Attr::RemoveChildAt(uint32_t aIndex, bool aNotify)
}
nsresult
Attr::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
Attr::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = true;
return NS_OK;

View File

@ -23,6 +23,7 @@
#include "nsIDocument.h"
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
// Attribute helper class used to wrap up an attribute with a dom
@ -51,7 +52,7 @@ public:
// nsIDOMAttr interface
NS_DECL_NSIDOMATTR
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
// nsIAttribute interface
void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;

View File

@ -50,6 +50,7 @@
#include "nsIDOMMutationEvent.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/MouseEvents.h"
@ -91,7 +92,6 @@
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsEventDispatcher.h"
#include "nsContentCreatorFunctions.h"
#include "nsIControllers.h"
#include "nsView.h"
@ -2317,7 +2317,7 @@ Element::Describe(nsAString& aOutDescription) const
}
bool
Element::CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor,
Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor,
nsIURI** aURI) const
{
if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault ||
@ -2335,7 +2335,7 @@ Element::CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor,
}
nsresult
Element::PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor)
Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor)
{
// Optimisation: return early if this event doesn't interest us.
// IMPORTANT: this switch and the switch below it must be kept in sync!
@ -2396,7 +2396,7 @@ Element::PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor)
}
nsresult
Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
{
// Optimisation: return early if this event doesn't interest us.
// IMPORTANT: this switch and the switch below it must be kept in sync!

View File

@ -4,12 +4,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileIOObject.h"
#include "mozilla/EventDispatcher.h"
#include "nsDOMFile.h"
#include "nsError.h"
#include "nsIDOMEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsComponentManagerUtils.h"
#include "nsEventDispatcher.h"
#define ERROR_STR "error"
#define ABORT_STR "abort"

View File

@ -18,6 +18,7 @@
#include "mozilla/dom/FragmentOrElement.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/Attr.h"
#include "nsDOMAttributeMap.h"
@ -91,7 +92,6 @@
#include "nsGenericHTMLElement.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsEventDispatcher.h"
#include "nsContentCreatorFunctions.h"
#include "nsIControllers.h"
#include "nsView.h"
@ -703,7 +703,7 @@ FindChromeAccessOnlySubtreeOwner(nsIContent* aContent)
}
nsresult
nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
//FIXME! Document how this event retargeting works, Bug 329124.
aVisitor.mCanHandle = true;

View File

@ -17,7 +17,6 @@
#include "nsIXPConnect.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "nsEventDispatcher.h"
#include "nsError.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIURL.h"

View File

@ -41,6 +41,7 @@
#include "mozilla/dom/TextDecoder.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/InternalMutationEvent.h"
@ -74,7 +75,6 @@
#include "nsDOMJSUtils.h"
#include "nsDOMMutationObserver.h"
#include "nsError.h"
#include "nsEventDispatcher.h"
#include "nsEventStateManager.h"
#include "nsFocusManager.h"
#include "nsGenericHTMLElement.h"
@ -3630,7 +3630,7 @@ nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent,
NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc");
// This checks that IsSafeToRunScript is true since we don't want to fire
// events when that is false. We can't rely on nsEventDispatcher to assert
// events when that is false. We can't rely on EventDispatcher to assert
// this in this situation since most of the time there are no mutation
// event listeners, in which case we won't even attempt to dispatch events.
// However this also allows for two exceptions. First off, we don't assert
@ -3661,7 +3661,7 @@ nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent,
mutation.mRelatedNode = do_QueryInterface(aParent);
mozAutoSubtreeModified subtree(aOwnerDoc, aParent);
nsEventDispatcher::Dispatch(aChild, nullptr, &mutation);
EventDispatcher::Dispatch(aChild, nullptr, &mutation);
}
}

View File

@ -19,7 +19,6 @@
#include "imgIContainer.h"
#include "nsIPresShell.h"
#include "nsFocusManager.h"
#include "nsEventDispatcher.h"
#include "mozilla/dom/DataTransfer.h"
#include "nsIDocShell.h"
@ -48,9 +47,9 @@
#include "mozilla/ContentEvents.h"
#include "mozilla/dom/Element.h"
#include "mozilla/Selection.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Preferences.h"
#include "mozilla/Selection.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -652,8 +651,8 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
nsEventStatus status = nsEventStatus_eIgnore;
InternalClipboardEvent evt(true, aType);
evt.clipboardData = clipboardData;
nsEventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, nullptr,
&status);
EventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt,
nullptr, &status);
// If the event was cancelled, don't do the clipboard operation
doDefault = (status != nsEventStatus_eConsumeNoDefault);
}

View File

@ -120,7 +120,7 @@
#include "nsDateTimeFormatCID.h"
#include "nsIDateTimeFormat.h"
#include "nsEventDispatcher.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/InternalMutationEvent.h"
#include "nsDOMCID.h"
@ -4856,7 +4856,7 @@ nsDocument::DispatchContentLoadedEvents()
event->SetTrusted(true);
// To dispatch this event we must manually call
// nsEventDispatcher::Dispatch() on the ancestor document since the
// EventDispatcher::Dispatch() on the ancestor document since the
// target is not in the same document, so the event would never reach
// the ancestor document if we used the normal event
// dispatching code.
@ -4870,8 +4870,8 @@ nsDocument::DispatchContentLoadedEvents()
nsRefPtr<nsPresContext> context = shell->GetPresContext();
if (context) {
nsEventDispatcher::Dispatch(parent, context, innerEvent, event,
&status);
EventDispatcher::Dispatch(parent, context, innerEvent, event,
&status);
}
}
}
@ -7636,7 +7636,7 @@ nsDocument::GetExistingListenerManager() const
}
nsresult
nsDocument::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsDocument::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = true;
// FIXME! This is a hack to make middle mouse paste working also in Editor.
@ -7675,10 +7675,9 @@ nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const
// Create event even without presContext.
nsCOMPtr<nsIDOMEvent> ev;
rv =
nsEventDispatcher::CreateEvent(const_cast<nsIDocument*>(this),
presContext, nullptr, aEventType,
getter_AddRefs(ev));
rv = EventDispatcher::CreateEvent(const_cast<nsIDocument*>(this),
presContext, nullptr, aEventType,
getter_AddRefs(ev));
return ev ? dont_AddRef(ev.forget().take()->InternalDOMEvent()) : nullptr;
}
@ -8669,8 +8668,8 @@ nsDocument::DispatchPageTransition(EventTarget* aDispatchTarget,
aPersisted))) {
event->SetTrusted(true);
event->SetTarget(this);
nsEventDispatcher::DispatchDOMEvent(aDispatchTarget, nullptr, event,
nullptr, nullptr);
EventDispatcher::DispatchDOMEvent(aDispatchTarget, nullptr, event,
nullptr, nullptr);
}
}
}

View File

@ -98,6 +98,7 @@ class nsPointerLockPermissionRequest;
class nsISecurityConsoleMessage;
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class UndoManager;
class LifecycleCallbacks;
@ -902,7 +903,8 @@ public:
NS_DECL_NSIDOMDOCUMENTXBL
// nsIDOMEventTarget
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(
mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual mozilla::EventListenerManager*
GetOrCreateListenerManager() MOZ_OVERRIDE;
virtual mozilla::EventListenerManager*

View File

@ -45,7 +45,6 @@
#include "nsIScrollableFrame.h"
#include "nsSubDocumentFrame.h"
#include "nsError.h"
#include "nsEventDispatcher.h"
#include "nsISHistory.h"
#include "nsISHistoryInternal.h"
#include "nsIDOMHTMLDocument.h"

View File

@ -15,8 +15,10 @@
#include "nsImageLoadingContent.h"
#include "imgIRequest.h"
#include "nsEventStates.h"
#include "nsEventDispatcher.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
using namespace mozilla;
class nsGenConImageContent MOZ_FINAL : public nsXMLElement,
public nsImageLoadingContent
@ -43,7 +45,7 @@ public:
virtual void UnbindFromTree(bool aDeep, bool aNullParent);
virtual nsEventStates IntrinsicState() const;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor)
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor)
{
MOZ_ASSERT(IsInNativeAnonymousSubtree());
if (aVisitor.mEvent->message == NS_LOAD ||

View File

@ -26,7 +26,6 @@
#include "nsDOMString.h"
#include "nsIDOMUserDataHandler.h"
#include "nsChangeHint.h"
#include "nsEventDispatcher.h"
#include "nsCOMArray.h"
#include "nsNodeUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"

View File

@ -15,6 +15,7 @@
#include "mozAutoDocUpdate.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/CORSMode.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/Likely.h"
@ -39,7 +40,6 @@
#include "nsDOMMutationObserver.h"
#include "nsDOMString.h"
#include "nsDOMTokenList.h"
#include "nsEventDispatcher.h"
#include "nsEventStateManager.h"
#include "nsFocusManager.h"
#include "nsFrameManager.h"
@ -1133,7 +1133,7 @@ nsINode::RemoveEventListener(const nsAString& aType,
NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsINode)
nsresult
nsINode::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsINode::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
// This is only here so that we can use the NS_DECL_NSIDOMTARGET macro
NS_ABORT();
@ -1162,14 +1162,13 @@ nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal)
nsEventStatus status = nsEventStatus_eIgnore;
nsresult rv =
nsEventDispatcher::DispatchDOMEvent(this, nullptr, aEvent, context,
&status);
EventDispatcher::DispatchDOMEvent(this, nullptr, aEvent, context, &status);
*aRetVal = (status != nsEventStatus_eConsumeNoDefault);
return rv;
}
nsresult
nsINode::PostHandleEvent(nsEventChainPostVisitor& /*aVisitor*/)
nsINode::PostHandleEvent(EventChainPostVisitor& /*aVisitor*/)
{
return NS_OK;
}
@ -1180,8 +1179,8 @@ nsINode::DispatchDOMEvent(WidgetEvent* aEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
return nsEventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
aPresContext, aEventStatus);
return EventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
aPresContext, aEventStatus);
}
EventListenerManager*

View File

@ -40,7 +40,6 @@
#include "nsContentUtils.h"
#include "nsLayoutUtils.h"
#include "nsIContentPolicy.h"
#include "nsEventDispatcher.h"
#include "nsSVGEffects.h"
#include "mozAutoDocUpdate.h"

View File

@ -8,7 +8,6 @@
#include "nsContentUtils.h"
#include "nsIScriptSecurityManager.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsEventDispatcher.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIJSRuntimeService.h"
@ -19,16 +18,18 @@
#include "xpcpublic.h"
#include "nsIMozBrowserFrame.h"
#include "nsDOMClassInfoID.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/StructuredCloneUtils.h"
#include "js/StructuredClone.h"
using mozilla::dom::StructuredCloneData;
using mozilla::dom::StructuredCloneClosure;
using namespace mozilla;
bool
nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
const mozilla::dom::StructuredCloneData& aData,
const dom::StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal,
InfallibleTArray<nsString>* aJSONRetVal,
@ -138,7 +139,7 @@ nsInProcessTabChildGlobal::Init()
"Couldn't initialize nsInProcessTabChildGlobal");
mMessageManager = new nsFrameMessageManager(this,
nullptr,
mozilla::dom::ipc::MM_CHILD);
dom::ipc::MM_CHILD);
return NS_OK;
}
@ -249,7 +250,7 @@ nsInProcessTabChildGlobal::GetOwnerContent()
}
nsresult
nsInProcessTabChildGlobal::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsInProcessTabChildGlobal::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = true;

View File

@ -23,6 +23,10 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsWeakReference.h"
namespace mozilla {
class EventChainPreVisitor;
} // namespace mozilla
class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper,
public nsFrameScriptExecutor,
public nsIInProcessContentFrameMessageManager,
@ -96,7 +100,8 @@ public:
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(
mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
NS_IMETHOD AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
bool aUseCapture)

View File

@ -11,7 +11,6 @@
// Interface headers
#include "imgLoader.h"
#include "nsEventDispatcher.h"
#include "nsIContent.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
@ -81,6 +80,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Telemetry.h"
#ifdef XP_WIN
@ -376,7 +376,7 @@ nsPluginCrashedEvent::Run()
variant->SetAsBool(mSubmittedCrashReport);
containerEvent->SetData(NS_LITERAL_STRING("submittedCrashReport"), variant);
nsEventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr);
EventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr);
return NS_OK;
}

View File

@ -5,9 +5,9 @@
#include "nsScriptElement.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/Element.h"
#include "nsContentUtils.h"
#include "nsEventDispatcher.h"
#include "nsPresContext.h"
#include "nsScriptLoader.h"
#include "nsIParser.h"
@ -63,7 +63,7 @@ nsScriptElement::ScriptEvaluated(nsresult aResult,
// Load event doesn't bubble.
event.mFlags.mBubbles = (type != NS_LOAD);
nsEventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
}
return rv;

View File

@ -8,6 +8,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/MemoryReporting.h"
#include "nsDOMBlobBuilder.h"
@ -36,7 +37,6 @@
#include "nsICachingChannel.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "nsEventDispatcher.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIContentPolicy.h"
#include "nsContentPolicyUtils.h"
@ -1393,9 +1393,9 @@ nsXMLHttpRequest::GetLoadGroup() const
nsresult
nsXMLHttpRequest::CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent)
{
nsresult rv = nsEventDispatcher::CreateEvent(this, nullptr, nullptr,
NS_LITERAL_STRING("Events"),
aDOMEvent);
nsresult rv = EventDispatcher::CreateEvent(this, nullptr, nullptr,
NS_LITERAL_STRING("Events"),
aDOMEvent);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -1691,6 +1691,29 @@ CanvasRenderingContext2D::Fill(const CanvasWindingRule& winding)
Redraw();
}
void CanvasRenderingContext2D::Fill(const CanvasPath& path, const CanvasWindingRule& winding)
{
EnsureTarget();
RefPtr<gfx::Path> gfxpath = path.GetPath(winding, mTarget);
if (!gfxpath) {
return;
}
mgfx::Rect bounds;
if (NeedToDrawShadow()) {
bounds = gfxpath->GetBounds(mTarget->GetTransform());
}
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
Fill(gfxpath, CanvasGeneralPattern().ForStyle(this, STYLE_FILL, mTarget),
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
Redraw();
}
void
CanvasRenderingContext2D::Stroke()
{
@ -1720,6 +1743,37 @@ CanvasRenderingContext2D::Stroke()
Redraw();
}
void
CanvasRenderingContext2D::Stroke(const CanvasPath& path)
{
EnsureTarget();
RefPtr<gfx::Path> gfxpath = path.GetPath(CanvasWindingRule::Nonzero, mTarget);
if (!gfxpath) {
return;
}
const ContextState &state = CurrentState();
StrokeOptions strokeOptions(state.lineWidth, state.lineJoin,
state.lineCap, state.miterLimit,
state.dash.Length(), state.dash.Elements(),
state.dashOffset);
mgfx::Rect bounds;
if (NeedToDrawShadow()) {
bounds =
gfxpath->GetStrokedBounds(strokeOptions, mTarget->GetTransform());
}
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
Stroke(gfxpath, CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
strokeOptions, DrawOptions(state.globalAlpha, UsedOperation()));
Redraw();
}
void CanvasRenderingContext2D::DrawFocusIfNeeded(mozilla::dom::Element& aElement)
{
EnsureUserSpacePath();
@ -1800,6 +1854,21 @@ CanvasRenderingContext2D::Clip(const CanvasWindingRule& winding)
CurrentState().clipsPushed.push_back(mPath);
}
void
CanvasRenderingContext2D::Clip(const CanvasPath& path, const CanvasWindingRule& winding)
{
EnsureTarget();
RefPtr<gfx::Path> gfxpath = path.GetPath(winding, mTarget);
if (!gfxpath) {
return;
}
mTarget->PushClip(gfxpath);
CurrentState().clipsPushed.push_back(gfxpath);
}
void
CanvasRenderingContext2D::ArcTo(double x1, double y1, double x2,
double y2, double radius,
@ -4226,5 +4295,212 @@ CanvasRenderingContext2D::ShouldForceInactiveLayer(LayerManager *aManager)
return !aManager->CanUseCanvasLayerForSize(IntSize(mWidth, mHeight));
}
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(CanvasPath, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(CanvasPath, Release)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(CanvasPath)
CanvasPath::CanvasPath(nsCOMPtr<nsISupports> aParent) : mParent(aParent)
{
SetIsDOMBinding();
mPathBuilder = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreatePathBuilder();
}
CanvasPath::CanvasPath(nsCOMPtr<nsISupports> aParent, RefPtr<PathBuilder> aPathBuilder): mParent(aParent), mPathBuilder(aPathBuilder)
{
SetIsDOMBinding();
if (!mPathBuilder) {
mPathBuilder = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreatePathBuilder();
}
}
JSObject*
CanvasPath::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return Path2DBinding::Wrap(aCx, aScope, this);
}
already_AddRefed<CanvasPath>
CanvasPath::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{
nsRefPtr<CanvasPath> path = new CanvasPath(aGlobal.GetAsSupports());
return path.forget();
}
already_AddRefed<CanvasPath>
CanvasPath::Constructor(const GlobalObject& aGlobal, CanvasPath& aCanvasPath, ErrorResult& aRv)
{
RefPtr<gfx::Path> tempPath = aCanvasPath.GetPath(CanvasWindingRule::Nonzero,
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
nsRefPtr<CanvasPath> path = new CanvasPath(aGlobal.GetAsSupports(), tempPath->CopyToBuilder());
return path.forget();
}
void
CanvasPath::ClosePath()
{
mPathBuilder->Close();
}
void
CanvasPath::MoveTo(double x, double y)
{
mPathBuilder->MoveTo(Point(ToFloat(x), ToFloat(y)));
}
void
CanvasPath::LineTo(double x, double y)
{
mPathBuilder->LineTo(Point(ToFloat(x), ToFloat(y)));
}
void
CanvasPath::QuadraticCurveTo(double cpx, double cpy, double x, double y)
{
mPathBuilder->QuadraticBezierTo(gfx::Point(ToFloat(cpx), ToFloat(cpy)),
gfx::Point(ToFloat(x), ToFloat(y)));
}
void
CanvasPath::BezierCurveTo(double cp1x, double cp1y,
double cp2x, double cp2y,
double x, double y)
{
BezierTo(gfx::Point(ToFloat(cp1x), ToFloat(cp1y)),
gfx::Point(ToFloat(cp2x), ToFloat(cp2y)),
gfx::Point(ToFloat(x), ToFloat(y)));
}
void
CanvasPath::ArcTo(double x1, double y1, double x2, double y2, double radius,
ErrorResult& error)
{
if (radius < 0) {
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
// Current point in user space!
Point p0 = mPathBuilder->CurrentPoint();
Point p1(x1, y1);
Point p2(x2, y2);
// Execute these calculations in double precision to avoid cumulative
// rounding errors.
double dir, a2, b2, c2, cosx, sinx, d, anx, any,
bnx, bny, x3, y3, x4, y4, cx, cy, angle0, angle1;
bool anticlockwise;
if (p0 == p1 || p1 == p2 || radius == 0) {
LineTo(p1.x, p1.y);
return;
}
// Check for colinearity
dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x);
if (dir == 0) {
LineTo(p1.x, p1.y);
return;
}
// XXX - Math for this code was already available from the non-azure code
// and would be well tested. Perhaps converting to bezier directly might
// be more efficient longer run.
a2 = (p0.x-x1)*(p0.x-x1) + (p0.y-y1)*(p0.y-y1);
b2 = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
c2 = (p0.x-x2)*(p0.x-x2) + (p0.y-y2)*(p0.y-y2);
cosx = (a2+b2-c2)/(2*sqrt(a2*b2));
sinx = sqrt(1 - cosx*cosx);
d = radius / ((1 - cosx) / sinx);
anx = (x1-p0.x) / sqrt(a2);
any = (y1-p0.y) / sqrt(a2);
bnx = (x1-x2) / sqrt(b2);
bny = (y1-y2) / sqrt(b2);
x3 = x1 - anx*d;
y3 = y1 - any*d;
x4 = x1 - bnx*d;
y4 = y1 - bny*d;
anticlockwise = (dir < 0);
cx = x3 + any*radius*(anticlockwise ? 1 : -1);
cy = y3 - anx*radius*(anticlockwise ? 1 : -1);
angle0 = atan2((y3-cy), (x3-cx));
angle1 = atan2((y4-cy), (x4-cx));
LineTo(x3, y3);
Arc(cx, cy, radius, angle0, angle1, anticlockwise, error);
}
void
CanvasPath::Rect(double x, double y, double w, double h)
{
MoveTo(x, y);
LineTo(x + w, y);
LineTo(x + w, y + h);
LineTo(x, y + h);
ClosePath();
}
void
CanvasPath::Arc(double x, double y, double radius,
double startAngle, double endAngle, bool anticlockwise,
ErrorResult& error)
{
if (radius < 0.0) {
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
ArcToBezier(this, Point(x, y), Size(radius, radius), startAngle, endAngle, anticlockwise);
}
void
CanvasPath::LineTo(const gfx::Point& aPoint)
{
mPathBuilder->LineTo(aPoint);
}
void
CanvasPath::BezierTo(const gfx::Point& aCP1,
const gfx::Point& aCP2,
const gfx::Point& aCP3)
{
mPathBuilder->BezierTo(aCP1, aCP2, aCP3);
}
RefPtr<gfx::Path>
CanvasPath::GetPath(const CanvasWindingRule& winding, const mozilla::RefPtr<mozilla::gfx::DrawTarget>& mTarget) const
{
FillRule fillRule = FillRule::FILL_WINDING;
if (winding == CanvasWindingRule::Evenodd) {
fillRule = FillRule::FILL_EVEN_ODD;
}
RefPtr<Path> mTempPath = mPathBuilder->Finish();
if (!mTempPath)
return mTempPath;
// retarget our backend if we're used with a different backend
if (mTempPath->GetBackendType() != mTarget->GetType()) {
mPathBuilder = mTarget->CreatePathBuilder(fillRule);
mTempPath->StreamToSink(mPathBuilder);
mTempPath = mPathBuilder->Finish();
} else if (mTempPath->GetFillRule() != fillRule) {
mPathBuilder = mTempPath->CopyToBuilder(fillRule);
mTempPath = mPathBuilder->Finish();
}
mPathBuilder = mTempPath->CopyToBuilder();
return mTempPath;
}
}
}

View File

@ -45,6 +45,57 @@ extern const mozilla::gfx::Float SIGMA_MAX;
template<typename T> class Optional;
class CanvasPath :
public nsWrapperCache
{
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasPath)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CanvasPath)
nsCOMPtr<nsISupports> GetParentObject() { return mParent; }
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
static already_AddRefed<CanvasPath> Constructor(const GlobalObject& aGlobal,
ErrorResult& rv);
static already_AddRefed<CanvasPath> Constructor(const GlobalObject& aGlobal,
CanvasPath& aCanvasPath,
ErrorResult& rv);
void ClosePath();
void MoveTo(double x, double y);
void LineTo(double x, double y);
void QuadraticCurveTo(double cpx, double cpy, double x, double y);
void BezierCurveTo(double cp1x, double cp1y,
double cp2x, double cp2y,
double x, double y);
void ArcTo(double x1, double y1, double x2, double y2, double radius,
ErrorResult& error);
void Rect(double x, double y, double w, double h);
void Arc(double x, double y, double radius,
double startAngle, double endAngle, bool anticlockwise,
ErrorResult& error);
void LineTo(const gfx::Point& aPoint);
void BezierTo(const gfx::Point& aCP1,
const gfx::Point& aCP2,
const gfx::Point& aCP3);
mozilla::RefPtr<mozilla::gfx::Path> GetPath(const CanvasWindingRule& winding,
const mozilla::RefPtr<mozilla::gfx::DrawTarget>& mTarget) const;
CanvasPath(nsCOMPtr<nsISupports> aParent);
CanvasPath(nsCOMPtr<nsISupports> aParent, RefPtr<gfx::PathBuilder> mPathBuilder);
virtual ~CanvasPath() {}
private:
nsCOMPtr<nsISupports> mParent;
static gfx::Float ToFloat(double aValue) { return gfx::Float(aValue); }
mutable RefPtr<gfx::PathBuilder> mPathBuilder;
};
struct CanvasBidiProcessor;
class CanvasRenderingContext2DUserData;
@ -172,10 +223,13 @@ public:
void StrokeRect(double x, double y, double w, double h);
void BeginPath();
void Fill(const CanvasWindingRule& winding);
void Fill(const CanvasPath& path, const CanvasWindingRule& winding);
void Stroke();
void Stroke(const CanvasPath& path);
void DrawFocusIfNeeded(mozilla::dom::Element& element);
bool DrawCustomFocusRing(mozilla::dom::Element& element);
void Clip(const CanvasWindingRule& winding);
void Clip(const CanvasPath& path, const CanvasWindingRule& winding);
bool IsPointInPath(double x, double y, const CanvasWindingRule& winding);
bool IsPointInStroke(double x, double y);
void FillText(const nsAString& text, double x, double y,

View File

@ -192,6 +192,7 @@ skip-if = (toolkit == 'gonk' && debug) #debug-only crash; bug 933541
[test_canvas_focusring.html]
skip-if = (toolkit == 'gonk' && !debug) #specialpowers.wrap
[test_canvas_font_setter.html]
[test_canvas_path.html]
[test_hitregion_canvas.html]
skip-if = os == "android" || appname == "b2g"
[test_canvas_strokeStyle_getter.html]

View File

@ -0,0 +1,199 @@
<!DOCTYPE HTML>
<title>Canvas Tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<script>
SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.Cc;
const Cr = SpecialPowers.Cr;
SpecialPowers.setBoolPref("canvas.path.enabled", true);
function isPixel(ctx, x,y, c, d) {
var pos = x + "," + y;
var color = c[0] + "," + c[1] + "," + c[2] + "," + c[3];
var pixel = ctx.getImageData(x, y, 1, 1);
var pr = pixel.data[0],
pg = pixel.data[1],
pb = pixel.data[2],
pa = pixel.data[3];
ok(c[0]-d <= pr && pr <= c[0]+d &&
c[1]-d <= pg && pg <= c[1]+d &&
c[2]-d <= pb && pb <= c[2]+d &&
c[3]-d <= pa && pa <= c[3]+d,
"pixel "+pos+" of "+ctx.canvas.id+" is "+pr+","+pg+","+pb+","+pa+"; expected "+color+" +/- "+d);
}
</script>
<p>Canvas test: test_drawClipPath_canvas</p>
<canvas id="c1" class="output" width="100" height="100">+
</canvas>
<script type="text/javascript">
function test_drawClipPath_canvas() {
var c = document.getElementById("c1");
var ctx = c.getContext("2d");
var path = new Path2D();
path.rect(0, 0, 100, 100);
path.rect(25, 25, 50, 50);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.beginPath();
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.save();
ctx.clip(path);
ctx.fillRect(0, 0, 100, 100);
isPixel(ctx, 50, 50, [0, 255, 0, 255], 5);
ctx.restore();
ctx.fillStyle = 'rgb(255,0,0)';
ctx.beginPath();
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.save();
ctx.clip(path, 'nonzero');
ctx.fillRect(0, 0, 100, 100);
isPixel(ctx, 50, 50, [0, 255, 0, 255], 5);
ctx.restore();
ctx.fillStyle = 'rgb(255,0,0)';
ctx.beginPath();
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.save();
ctx.clip(path, 'evenodd');
ctx.fillRect(0, 0, 100, 100);
isPixel(ctx, 50, 50, [255, 0, 0, 255], 5);
ctx.restore();
}
</script>
<p>Canvas test: test_drawFillPath_canvas</p>
<canvas id="c2" class="output" width="100" height="100">+
</canvas>
<script type="text/javascript">
function test_drawFillPath_canvas() {
var c = document.getElementById("c2");
var ctx = c.getContext("2d");
var path = new Path2D();
path.rect(0, 0, 100, 100);
path.rect(25, 25, 50, 50);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fill(path);
isPixel(ctx, 50, 50, [0, 255, 0, 255], 5);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fill(path, 'nonzero');
isPixel(ctx, 50, 50, [0, 255, 0, 255], 5);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fill(path, 'evenodd');
isPixel(ctx, 50, 50, [255, 0, 0, 255], 5);
}
</script>
<p>Canvas test: test_drawStrokePath_canvas</p>
<canvas id="c3" class="output" width="100" height="100">+
</canvas>
<script type="text/javascript">
function test_drawStrokePath_canvas() {
var c = document.getElementById("c3");
var ctx = c.getContext("2d");
var path = new Path2D();
path.rect(0, 0, 100, 100);
path.rect(25, 25, 50, 50);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.strokeStyle = 'rgb(0,255,0)';
ctx.lineWidth = 5;
ctx.stroke(path);
isPixel(ctx, 0, 0, [0, 255, 0, 255], 5);
isPixel(ctx, 25, 25, [0, 255, 0, 255], 5);
isPixel(ctx, 10, 10, [255, 0, 0, 255], 5);
}
</script>
<p>Canvas test: test_large_canvas</p>
<canvas id="c4" class="output" width="10000" height="100">+
</canvas>
<script type="text/javascript">
function test_large_canvas() {
// test paths on large canvases. On certain platforms this will
// trigger retargeting of the backend
var c = document.getElementById("c4");
var ctx = c.getContext("2d");
var path = new Path2D();
path.rect(0, 0, 100, 100);
path.rect(25, 25, 50, 50);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fill(path);
isPixel(ctx, 50, 50, [0, 255, 0, 255], 5);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fill(path, 'nonzero');
isPixel(ctx, 50, 50, [0, 255, 0, 255], 5);
ctx.fillStyle = 'rgb(255,0,0)';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fill(path, 'evenodd');
isPixel(ctx, 50, 50, [255, 0, 0, 255], 5);
}
</script>
<script>
function runTests() {
try {
test_drawClipPath_canvas();
} catch(e) {
throw e;
ok(false, "unexpected exception thrown in: test_drawClipPath_canvas");
}
try {
test_drawFillPath_canvas();
} catch(e) {
throw e;
ok(false, "unexpected exception thrown in: test_drawFillPath_canvas");
}
try {
test_drawStrokePath_canvas();
} catch(e) {
throw e;
ok(false, "unexpected exception thrown in: test_drawStrokePath_canvas");
}
try {
test_large_canvas();
} catch(e) {
throw e;
ok(false, "unexpected exception thrown in: test_large_canvas");
}
SpecialPowers.setBoolPref("canvas.path.enabled", false);
SimpleTest.finish();
}
addLoadEvent(runTests);
</script>

View File

@ -7,6 +7,7 @@
#include "mozilla/dom/HTMLAnchorElement.h"
#include "mozilla/dom/HTMLAnchorElementBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MemoryReporting.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
@ -244,13 +245,13 @@ HTMLAnchorElement::IsHTMLFocusable(bool aWithMouse,
}
nsresult
HTMLAnchorElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLAnchorElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
return PreHandleEventForAnchors(aVisitor);
}
nsresult
HTMLAnchorElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLAnchorElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
return PostHandleEventForAnchors(aVisitor);
}

View File

@ -14,6 +14,8 @@
#include "nsDOMTokenList.h"
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLAnchorElement MOZ_FINAL : public nsGenericHTMLElement,
@ -54,8 +56,9 @@ public:
bool aNullParent = true) MOZ_OVERRIDE;
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE;
virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
virtual already_AddRefed<nsIURI> GetHrefURI() const MOZ_OVERRIDE;

View File

@ -8,6 +8,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/HTMLAreaElementBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MemoryReporting.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Area)
@ -92,13 +93,13 @@ HTMLAreaElement::SetTarget(const nsAString& aValue)
}
nsresult
HTMLAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
return PreHandleEventForAnchors(aVisitor);
}
nsresult
HTMLAreaElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
return PostHandleEventForAnchors(aVisitor);
}

View File

@ -18,6 +18,8 @@
class nsIDocument;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLAreaElement MOZ_FINAL : public nsGenericHTMLElement,
@ -43,8 +45,8 @@ public:
// nsIDOMHTMLAreaElement
NS_DECL_NSIDOMHTMLAREAELEMENT
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE;
virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
virtual already_AddRefed<nsIURI> GetHrefURI() const MOZ_OVERRIDE;

View File

@ -23,11 +23,11 @@
#include "nsIDOMEvent.h"
#include "nsIDocument.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "nsUnicharUtils.h"
#include "nsLayoutUtils.h"
#include "nsEventDispatcher.h"
#include "nsPresState.h"
#include "nsError.h"
#include "nsFocusManager.h"
@ -187,7 +187,7 @@ HTMLButtonElement::IsDisabledForEvents(uint32_t aMessage)
}
nsresult
HTMLButtonElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = false;
if (IsDisabledForEvents(aVisitor.mEvent->message)) {
@ -219,7 +219,7 @@ HTMLButtonElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
nsresult rv = NS_OK;
if (!aVisitor.mPresContext) {
@ -278,9 +278,9 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
NS_MOUSE_CLICK, nullptr,
WidgetMouseEvent::eReal);
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aVisitor.mPresContext, &event, nullptr,
&status);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aVisitor.mPresContext, &event, nullptr,
&status);
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
}

View File

@ -12,6 +12,8 @@
#include "nsIConstraintValidation.h"
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLButtonElement MOZ_FINAL : public nsGenericHTMLFormElementWithState,
@ -47,8 +49,9 @@ public:
virtual bool IsDisabledForEvents(uint32_t aMessage) MOZ_OVERRIDE;
// nsIDOMEventTarget
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
// nsINode
virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;

View File

@ -4,10 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLFieldSetElement.h"
#include "mozilla/dom/HTMLFieldSetElementBinding.h"
#include "nsContentList.h"
#include "nsEventDispatcher.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)
@ -67,7 +67,7 @@ HTMLFieldSetElement::IsDisabledForEvents(uint32_t aMessage)
// nsIContent
nsresult
HTMLFieldSetElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLFieldSetElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
// Do not process any DOM events if the element is disabled.
aVisitor.mCanHandle = false;

View File

@ -14,6 +14,7 @@
#include "mozilla/dom/ValidityState.h"
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class HTMLFieldSetElement MOZ_FINAL : public nsGenericHTMLFormElement,
@ -38,7 +39,7 @@ public:
NS_DECL_NSIDOMHTMLFIELDSETELEMENT
// nsIContent
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;

View File

@ -7,6 +7,7 @@
#include "jsapi.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLFormControlsCollection.h"
#include "mozilla/dom/HTMLFormElementBinding.h"
#include "nsIHTMLDocument.h"
@ -47,8 +48,6 @@
#include "nsLayoutUtils.h"
#include "nsEventDispatcher.h"
#include "mozAutoDocUpdate.h"
#include "nsIHTMLCollection.h"
@ -289,8 +288,7 @@ NS_IMETHODIMP
HTMLFormElement::Reset()
{
InternalFormEvent event(true, NS_FORM_RESET);
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), nullptr,
&event);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), nullptr, &event);
return NS_OK;
}
@ -482,7 +480,7 @@ HTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent)
}
nsresult
HTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mWantsWillHandleEvent = true;
if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
@ -511,7 +509,7 @@ HTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
HTMLFormElement::WillHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLFormElement::WillHandleEvent(EventChainPostVisitor& aVisitor)
{
// If this is the bubble stage and there is a nested form below us which
// received a submit event we do *not* want to handle the submit event
@ -526,7 +524,7 @@ HTMLFormElement::WillHandleEvent(nsEventChainPostVisitor& aVisitor)
}
nsresult
HTMLFormElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
uint32_t msg = aVisitor.mEvent->message;

View File

@ -27,6 +27,8 @@ class nsIMutableArray;
class nsIURI;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLFormControlsCollection;
class HTMLImageElement;
@ -89,9 +91,11 @@ public:
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult WillHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult WillHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,

View File

@ -36,7 +36,7 @@
#include "nsRuleData.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsEventDispatcher.h"
#include "mozilla/EventDispatcher.h"
#include "nsLayoutUtils.h"
@ -341,7 +341,7 @@ HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsresult
HTMLImageElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLImageElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
// If we are a map and get a mouse click, don't let it be handled by
// the Generic Element as this could cause a click event to fire

View File

@ -14,6 +14,7 @@
#include "Units.h"
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class HTMLImageElement MOZ_FINAL : public nsGenericHTMLElement,
@ -51,7 +52,7 @@ public:
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;

View File

@ -57,11 +57,11 @@
#include "nsLinebreakConverter.h" //to strip out carriage returns
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsEventDispatcher.h"
#include "nsLayoutUtils.h"
#include "nsIDOMMutationEvent.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
@ -3201,8 +3201,8 @@ HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext)
WidgetEvent event(nsContentUtils::IsCallerChrome(), NS_FORM_SELECTED);
mHandlingSelectEvent = true;
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aPresContext, &event, nullptr, &status);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aPresContext, &event, nullptr, &status);
mHandlingSelectEvent = false;
}
@ -3222,7 +3222,8 @@ HTMLInputElement::SelectAll(nsPresContext* aPresContext)
}
bool
HTMLInputElement::NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const
HTMLInputElement::NeedToInitializeEditorForEvent(
EventChainPreVisitor& aVisitor) const
{
// We only need to initialize the editor for single line input controls because they
// are lazily initialized. We don't need to initialize the control for
@ -3253,7 +3254,7 @@ HTMLInputElement::IsDisabledForEvents(uint32_t aMessage)
}
nsresult
HTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
// Do not process any DOM events if the element is disabled
aVisitor.mCanHandle = false;
@ -3730,7 +3731,7 @@ HTMLInputElement::ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget)
}
nsresult
HTMLInputElement::MaybeInitPickers(nsEventChainPostVisitor& aVisitor)
HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor)
{
// Open a file picker when we receive a click on a <input type='file'>, or
// open a color picker when we receive a click on a <input type='color'>.
@ -3756,7 +3757,7 @@ HTMLInputElement::MaybeInitPickers(nsEventChainPostVisitor& aVisitor)
}
nsresult
HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (!aVisitor.mPresContext) {
// Hack alert! In order to open file picker even in case the element isn't
@ -3982,9 +3983,9 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
nsEventStatus status = nsEventStatus_eIgnore;
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aVisitor.mPresContext, &event,
nullptr, &status);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aVisitor.mPresContext, &event,
nullptr, &status);
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
} // case
} // switch
@ -4016,9 +4017,10 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
NS_MOUSE_CLICK, nullptr,
WidgetMouseEvent::eReal);
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
rv = nsEventDispatcher::Dispatch(ToSupports(selectedRadioButton),
aVisitor.mPresContext,
&event, nullptr, &status);
rv =
EventDispatcher::Dispatch(ToSupports(selectedRadioButton),
aVisitor.mPresContext,
&event, nullptr, &status);
if (NS_SUCCEEDED(rv)) {
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
@ -4239,7 +4241,7 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
}
void
HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor)
HTMLInputElement::PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor)
{
MOZ_ASSERT(mType == NS_FORM_INPUT_RANGE);
@ -5465,13 +5467,14 @@ FireEventForAccessibility(nsIDOMHTMLInputElement* aTarget,
{
nsCOMPtr<nsIDOMEvent> event;
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(aTarget);
if (NS_SUCCEEDED(nsEventDispatcher::CreateEvent(element, aPresContext, nullptr,
NS_LITERAL_STRING("Events"),
getter_AddRefs(event)))) {
if (NS_SUCCEEDED(EventDispatcher::CreateEvent(element, aPresContext, nullptr,
NS_LITERAL_STRING("Events"),
getter_AddRefs(event)))) {
event->InitEvent(aEventType, true, true);
event->SetTrusted(true);
nsEventDispatcher::DispatchDOMEvent(aTarget, nullptr, event, aPresContext, nullptr);
EventDispatcher::DispatchDOMEvent(aTarget, nullptr, event, aPresContext,
nullptr);
}
return NS_OK;

View File

@ -29,6 +29,10 @@ class nsIRadioVisitor;
class nsTextEditorState;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class Date;
@ -148,9 +152,10 @@ public:
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
void PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor);
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
void PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor);
void StartRangeThumbDrag(WidgetGUIEvent* aEvent);
void FinishRangeThumbDrag(WidgetGUIEvent* aEvent = nullptr);
void CancelRangeThumbDrag(bool aIsForUserEvent = true);
@ -891,7 +896,7 @@ protected:
* Determine whether the editor needs to be initialized explicitly for
* a particular event.
*/
bool NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const;
bool NeedToInitializeEditorForEvent(EventChainPreVisitor& aVisitor) const;
/**
* Get the value mode of the element, depending of the type.
@ -1179,7 +1184,7 @@ protected:
* this function checks if it is needed, and if so, open the corresponding
* picker (color picker or file picker).
*/
nsresult MaybeInitPickers(nsEventChainPostVisitor& aVisitor);
nsresult MaybeInitPickers(EventChainPostVisitor& aVisitor);
enum FilePickerType {
FILE_PICKER_FILE,

View File

@ -7,10 +7,10 @@
* Implementation of HTML <label> elements.
*/
#include "HTMLLabelElement.h"
#include "mozilla/dom/HTMLLabelElementBinding.h"
#include "nsEventDispatcher.h"
#include "nsFocusManager.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/dom/HTMLLabelElementBinding.h"
#include "nsFocusManager.h"
#include "nsIDOMMouseEvent.h"
// construction, destruction
@ -112,7 +112,7 @@ DestroyMouseDownPoint(void * /*aObject*/,
}
nsresult
HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLLabelElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (mHandlingEvent ||
@ -238,8 +238,8 @@ HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ?
openAllowed : openAbused);
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event);
}
}

View File

@ -14,6 +14,7 @@
#include "nsIDOMHTMLLabelElement.h"
namespace mozilla {
class EventChainPostVisitor;
namespace dom {
class HTMLLabelElement MOZ_FINAL : public nsGenericHTMLFormElement,
@ -60,7 +61,8 @@ public:
virtual bool IsDisabled() const MOZ_OVERRIDE { return false; }
// nsIContent
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual void PerformAccesskey(bool aKeyCausesActivation,
bool aIsTrustedEvent) MOZ_OVERRIDE;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;

View File

@ -8,6 +8,7 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLLinkElementBinding.h"
#include "mozilla/MemoryReporting.h"
#include "nsContentUtils.h"
@ -302,13 +303,13 @@ HTMLLinkElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
}
nsresult
HTMLLinkElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLLinkElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
return PreHandleEventForAnchors(aVisitor);
}
nsresult
HTMLLinkElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLLinkElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
return PostHandleEventForAnchors(aVisitor);
}

View File

@ -13,6 +13,8 @@
#include "nsStyleLinkElement.h"
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLLinkElement MOZ_FINAL : public nsGenericHTMLElement,
@ -41,8 +43,9 @@ public:
void LinkRemoved();
// nsIDOMEventTarget
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
// nsINode
virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;

View File

@ -41,7 +41,6 @@
#include "nsITimer.h"
#include "nsEventDispatcher.h"
#include "MediaError.h"
#include "MediaDecoder.h"
#include "nsICategoryManager.h"
@ -3951,6 +3950,7 @@ HTMLMediaElement::AddTextTrack(TextTrackKind aKind,
{
if (mTextTrackManager) {
return mTextTrackManager->AddTextTrack(aKind, aLabel, aLanguage,
TextTrackMode::Hidden,
TextTrackSource::AddTextTrack);
}
return nullptr;

View File

@ -6,11 +6,11 @@
#include "mozilla/dom/HTMLMenuElement.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLMenuElementBinding.h"
#include "mozilla/dom/HTMLMenuItemElement.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
#include "nsEventDispatcher.h"
#include "nsXULContextMenuBuilder.h"
#include "nsIURI.h"
@ -86,8 +86,8 @@ HTMLMenuElement::SendShowEvent()
nsRefPtr<nsPresContext> presContext = shell->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event, nullptr, &status);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event, nullptr, &status);
return NS_OK;
}

View File

@ -6,10 +6,10 @@
#include "mozilla/dom/HTMLMenuItemElement.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLMenuItemElementBinding.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
#include "nsEventDispatcher.h"
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(MenuItem)
@ -251,7 +251,7 @@ HTMLMenuItemElement::SetChecked(bool aChecked)
}
nsresult
HTMLMenuItemElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLMenuItemElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
if (aVisitor.mEvent->message == NS_MOUSE_CLICK) {
@ -286,7 +286,7 @@ HTMLMenuItemElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
HTMLMenuItemElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLMenuItemElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
// Check to see if the event was cancelled.
if (aVisitor.mEvent->message == NS_MOUSE_CLICK &&

View File

@ -11,6 +11,9 @@
#include "nsGenericHTMLElement.h"
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class Visitor;
@ -33,8 +36,9 @@ public:
// nsIDOMHTMLMenuItemElement
NS_DECL_NSIDOMHTMLMENUITEMELEMENT
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,

View File

@ -3,6 +3,7 @@
* 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 "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLOptGroupElement.h"
#include "mozilla/dom/HTMLOptGroupElementBinding.h"
#include "mozilla/dom/HTMLSelectElement.h" // SafeOptionListMutation
@ -12,8 +13,6 @@
#include "nsIFormControlFrame.h"
#include "nsEventStates.h"
#include "nsEventDispatcher.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(OptGroup)
namespace mozilla {
@ -48,7 +47,7 @@ NS_IMPL_STRING_ATTR(HTMLOptGroupElement, Label, label)
nsresult
HTMLOptGroupElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLOptGroupElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = false;
// Do not process any DOM events if the element is disabled

View File

@ -11,6 +11,7 @@
#include "nsGenericHTMLElement.h"
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class HTMLOptGroupElement MOZ_FINAL : public nsGenericHTMLElement,
@ -34,7 +35,7 @@ public:
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
// nsIContent
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;

View File

@ -14,7 +14,6 @@
#include "mozilla/dom/HTMLSelectElement.h"
#include "nsContentCreatorFunctions.h"
#include "nsError.h"
#include "nsEventDispatcher.h"
#include "nsEventStates.h"
#include "nsFormSubmission.h"
#include "nsGkAtoms.h"

View File

@ -8,6 +8,7 @@
#include "mozAutoDocUpdate.h"
#include "mozilla/Attributes.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLOptGroupElement.h"
#include "mozilla/dom/HTMLOptionElement.h"
@ -15,7 +16,6 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentList.h"
#include "nsError.h"
#include "nsEventDispatcher.h"
#include "nsEventStates.h"
#include "nsFormSubmission.h"
#include "nsGkAtoms.h"
@ -1478,7 +1478,7 @@ HTMLSelectElement::IsDisabledForEvents(uint32_t aMessage)
}
nsresult
HTMLSelectElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLSelectElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = false;
if (IsDisabledForEvents(aVisitor.mEvent->message)) {
@ -1489,7 +1489,7 @@ HTMLSelectElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
HTMLSelectElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->message == NS_FOCUS_CONTENT) {
// If the invalid UI is shown, we should show it while focused and

View File

@ -25,6 +25,10 @@ class nsISelectControlFrame;
class nsPresState;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLSelectElement;
@ -259,8 +263,9 @@ public:
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// nsIContent
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) MOZ_OVERRIDE;
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,

View File

@ -10,12 +10,12 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MouseEvents.h"
#include "nsAttrValueInlines.h"
#include "nsContentCID.h"
#include "nsContentCreatorFunctions.h"
#include "nsError.h"
#include "nsEventDispatcher.h"
#include "nsFocusManager.h"
#include "nsFormSubmission.h"
#include "nsIComponentManager.h"
@ -137,8 +137,8 @@ HTMLTextAreaElement::Select()
nsEventStatus status = nsEventStatus_eIgnore;
WidgetGUIEvent event(true, NS_FORM_SELECTED, nullptr);
// XXXbz HTMLInputElement guards against this reentering; shouldn't we?
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event, nullptr, &status);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event, nullptr, &status);
// If the DOM event was not canceled (e.g. by a JS event handler
// returning false)
@ -454,7 +454,7 @@ HTMLTextAreaElement::IsDisabledForEvents(uint32_t aMessage)
}
nsresult
HTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mCanHandle = false;
if (IsDisabledForEvents(aVisitor.mEvent->message)) {
@ -509,7 +509,7 @@ HTMLTextAreaElement::FireChangeEventIfNeeded()
}
nsresult
HTMLTextAreaElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->message == NS_FORM_SELECTED) {
mHandlingSelect = false;

View File

@ -29,6 +29,10 @@ class nsPresContext;
class nsPresState;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
class HTMLTextAreaElement MOZ_FINAL : public nsGenericHTMLFormElementWithState,
@ -113,8 +117,9 @@ public:
int32_t aModType) const MOZ_OVERRIDE;
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;

View File

@ -154,7 +154,7 @@ HTMLTrackElement::CreateTextTrack()
}
mTrack = new TextTrack(OwnerDoc()->GetParentObject(), kind, label, srcLang,
TextTrackSource::Track);
TextTrackMode::Disabled, TextTrackSource::Track);
mTrack->SetTrackElement(this);
if (mMediaParent) {

View File

@ -25,7 +25,6 @@
#include "nsITimer.h"
#include "nsEventDispatcher.h"
#include "nsIDOMProgressEvent.h"
#include "MediaError.h"
#include "MediaDecoder.h"

View File

@ -112,13 +112,14 @@ TextTrackManager::TextTracks() const
already_AddRefed<TextTrack>
TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource)
{
if (!mMediaElement) {
return nullptr;
}
nsRefPtr<TextTrack> ttrack =
mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aTextTrackSource,
mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aTextTrackSource,
CompareTextTracks(mMediaElement));
ttrack->SetReadyState(HTMLTrackElement::READY_STATE_LOADED);
AddCues(ttrack);

View File

@ -46,6 +46,7 @@ public:
already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource);
void AddTextTrack(TextTrack* aTextTrack);
void RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly);

View File

@ -15,13 +15,13 @@
#include "nsVariant.h"
#include "nsINode.h"
#include "nsIDOMDOMTransactionEvent.h"
#include "nsEventDispatcher.h"
#include "nsContentUtils.h"
#include "jsapi.h"
#include "nsIDocument.h"
#include "mozilla/Preferences.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Preferences.h"
// Includes for mutation observer.
#include "nsIDOMHTMLElement.h"
@ -1181,8 +1181,8 @@ UndoManager::DispatchTransactionEvent(JSContext* aCx, const nsAString& aType,
transactions))) {
event->SetTrusted(true);
event->SetTarget(mHostNode);
nsEventDispatcher::DispatchDOMEvent(mHostNode, nullptr, event,
nullptr, nullptr);
EventDispatcher::DispatchDOMEvent(mHostNode, nullptr, event,
nullptr, nullptr);
}
}

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/Likely.h"
@ -75,7 +76,6 @@
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsEventDispatcher.h"
#include "nsLayoutUtils.h"
#include "mozAutoDocUpdate.h"
#include "nsHtml5Module.h"
@ -695,7 +695,8 @@ nsGenericHTMLElement::FindAncestorForm(HTMLFormElement* aCurrentForm)
}
bool
nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(nsEventChainVisitor& aVisitor)
nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(
EventChainVisitor& aVisitor)
{
NS_PRECONDITION(nsCOMPtr<Link>(do_QueryObject(this)),
"should be called only when |this| implements |Link|");
@ -717,7 +718,7 @@ nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(nsEventChainVisito
}
nsresult
nsGenericHTMLElement::PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor)
nsGenericHTMLElement::PreHandleEventForAnchors(EventChainPreVisitor& aVisitor)
{
nsresult rv = nsGenericHTMLElementBase::PreHandleEvent(aVisitor);
NS_ENSURE_SUCCESS(rv, rv);
@ -730,7 +731,7 @@ nsGenericHTMLElement::PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor)
}
nsresult
nsGenericHTMLElement::PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor)
nsGenericHTMLElement::PostHandleEventForAnchors(EventChainPostVisitor& aVisitor)
{
if (!CheckHandleEventForAnchorsPreconditions(aVisitor)) {
return NS_OK;
@ -2284,7 +2285,7 @@ nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
nsresult
nsGenericHTMLFormElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
if (aVisitor.mEvent->mFlags.mIsTrusted) {
switch (aVisitor.mEvent->message) {
@ -2694,7 +2695,7 @@ nsGenericHTMLElement::Click()
NS_MOUSE_CLICK, nullptr, WidgetMouseEvent::eReal);
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), context, &event);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), context, &event);
ClearHandlingClick();
}
@ -2800,7 +2801,8 @@ nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ?
openAllowed : openAbused);
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext, &event);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
presContext, &event);
}
}

View File

@ -40,6 +40,9 @@ class nsIDOMHTMLCollection;
class nsDOMSettableTokenList;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
class EventChainVisitor;
class EventListenerManager;
namespace dom {
class HTMLFormElement;
@ -588,9 +591,10 @@ public:
* Check if an event for an anchor can be handled
* @return true if the event can be handled, false otherwise
*/
bool CheckHandleEventForAnchorsPreconditions(nsEventChainVisitor& aVisitor);
nsresult PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor);
nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor);
bool CheckHandleEventForAnchorsPreconditions(
mozilla::EventChainVisitor& aVisitor);
nsresult PreHandleEventForAnchors(mozilla::EventChainPreVisitor& aVisitor);
nsresult PostHandleEventForAnchors(mozilla::EventChainPostVisitor& aVisitor);
bool IsHTMLLink(nsIURI** aURI) const;
// HTML element methods
@ -1326,7 +1330,8 @@ public:
virtual IMEState GetDesiredIMEState() MOZ_OVERRIDE;
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(
mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsDisabled() const MOZ_OVERRIDE;

View File

@ -20,6 +20,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=622558
</div>
<pre id="test">
<script type="application/javascript">
// Bug 940203
if (navigator.platform.startsWith("Win")) {
SimpleTest.expectAssertions(0, 1);
}
/** Test for Bug 622558 **/

View File

@ -22,6 +22,7 @@
#include "nsContentUtils.h"
#include "nsIURI.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/ElementBinding.h"
using namespace mozilla;
@ -897,7 +898,7 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
}
nsresult
nsMathMLElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsMathMLElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
nsresult rv = Element::PreHandleEvent(aVisitor);
NS_ENSURE_SUCCESS(rv, rv);
@ -906,7 +907,7 @@ nsMathMLElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
nsMathMLElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
nsMathMLElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
return PostHandleEventForLinks(aVisitor);
}

View File

@ -17,6 +17,11 @@ class nsCSSValue;
typedef nsMappedAttributeElement nsMathMLElementBase;
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
} // namespace mozilla
/*
* The base class for MathML elements.
*/
@ -68,8 +73,10 @@ public:
static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
nsRuleData* aRuleData);
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(
mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
mozilla::EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
nsresult Clone(nsINodeInfo*, nsINode**) const MOZ_OVERRIDE;
virtual nsEventStates IntrinsicState() const MOZ_OVERRIDE;
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;

View File

@ -1521,7 +1521,7 @@ void
MediaDecoderStateMachine::DispatchDecodeTasksIfNeeded()
{
AssertCurrentThreadInMonitor();
// NeedToDecodeAudio() can go from false to true while we hold the
// monitor, but it can't go from true to false. This can happen because
// NeedToDecodeAudio() takes into account the amount of decoded audio
@ -2274,9 +2274,16 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
int64_t clockTime = std::max(mEndTime, std::max(videoTime, GetAudioClock()));
UpdatePlaybackPosition(clockTime);
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &MediaDecoder::PlaybackEnded);
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
{
// Wait for the state change is completed in the main thread,
// otherwise we might see |mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING|
// in next loop and send |MediaDecoder::PlaybackEnded| again to trigger 'ended'
// event twice in the media element.
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &MediaDecoder::PlaybackEnded);
NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
}
}
return NS_OK;
}
@ -2756,6 +2763,12 @@ nsresult MediaDecoderStateMachine::ScheduleStateMachine(int64_t aUsecs) {
return NS_OK;
}
// Since there is already a pending task that will run immediately,
// we don't need to schedule a timer task.
if (mRunAgain) {
return NS_OK;
}
mTimeout = timeout;
nsresult res;

View File

@ -41,6 +41,7 @@ TextTrack::TextTrack(nsISupports* aParent,
TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource)
: mParent(aParent)
, mTextTrackSource(aTextTrackSource)
@ -49,6 +50,7 @@ TextTrack::TextTrack(nsISupports* aParent,
mKind = aKind;
mLabel = aLabel;
mLanguage = aLanguage;
mMode = aMode;
SetIsDOMBinding();
}
@ -57,6 +59,7 @@ TextTrack::TextTrack(nsISupports* aParent,
TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource)
: mParent(aParent)
, mTextTrackList(aTextTrackList)
@ -66,6 +69,7 @@ TextTrack::TextTrack(nsISupports* aParent,
mKind = aKind;
mLabel = aLabel;
mLanguage = aLanguage;
mMode = aMode;
SetIsDOMBinding();
}

View File

@ -40,12 +40,14 @@ public:
TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource);
TextTrack(nsISupports* aParent,
TextTrackList* aTextTrackList,
TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource);
void SetDefaultSettings();

View File

@ -65,11 +65,12 @@ already_AddRefed<TextTrack>
TextTrackList::AddTextTrack(TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource,
const CompareTextTracks& aCompareTT)
{
nsRefPtr<TextTrack> track = new TextTrack(mGlobal, this, aKind, aLabel, aLanguage,
aTextTrackSource);
aMode, aTextTrackSource);
AddTextTrack(track, aCompareTT);
return track.forget();
}

View File

@ -50,6 +50,7 @@ public:
already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind,
const nsAString& aLabel,
const nsAString& aLanguage,
TextTrackMode aMode,
TextTrackSource aTextTrackSource,
const CompareTextTracks& aCompareTT);
TextTrack* GetTrackById(const nsAString& aId);

View File

@ -36,6 +36,8 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
return;
}
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
// Set mode to hidden so that the active cue lists are being updated.
trackElement.track.mode = "hidden";
var expected = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4]];
var cueList = trackElement.track.cues;

View File

@ -43,6 +43,10 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
return;
}
// Set mode to hidden so that the active cue lists are being updated.
trackElement.track.mode = "hidden";
trackElementTwo.track.mode = "hidden";
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
is(trackElementTwo.readyState, 2, "Track::ReadyState should be set to LOADED.");

View File

@ -60,9 +60,8 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
is(textTrack.mode, value, message);
}
// Test that text tracks are sorted correctly when being inserted on the
// MediaElements list of text tracks. For this test we add four tracks, the
// first one was at the start of the test, the next three are below.
// Insert some tracks in an order that is not sorted, we will test if they
// are sorted later.
var trackOne = document.createElement("track");
trackOne.label = "first";
trackOne.src = "basic.vtt";
@ -90,16 +89,30 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
is(trackOne.readyState, 2, "First Track::ReadyState should be set to LOADED.");
is(trackTwo.readyState, 2, "Second Track::ReadyState should be set to LOADED.");
// We're testing two things here, firstly that tracks created from a track
// element have a default mode 'disabled' and tracks created with the
// 'addTextTrack' method have a default mode of 'hidden'.
// Secondly we're testing that the tracks are sorted properly.
// For the tracks to be sorted the first two tracks, added through a
// TrackElement, must occupy the first two indexes in their TrackElement
// tree order. The second two tracks, added through the 'addTextTrack'
// method, will occupy the last two indexes in the order that they were
// added in.
var labels = [ "first", "second", "third", "fourth" ];
is(video.textTracks.length, labels.length, "TextTracks length should be " + labels.length);
var trackInfo = [
{ label: "first", mode: "disabled" },
{ label: "second", mode: "disabled" },
{ label: "third", mode: "hidden" },
{ label: "fourth", mode:"hidden"}
];
is(video.textTracks.length, trackInfo.length, "TextTracks length should be " + trackInfo.length);
for (var i = 0; i < video.textTracks.length; i++) {
isnot(video.textTracks[i], null, "Video should have a text track at " + i + " index.");
is(video.textTracks[i].label, labels[i], "Text track at " + i + " should be " + labels[i]);
var track = video.textTracks[i];
isnot(track, null, "Video should have a text track at " + i + " index.");
var info = trackInfo[i];
for (var key in info) {
is(track[key], info[key], "Track at " + i + " should have a '" + key + "'' property " +
"with a value of '" + info[key] + "'.");
}
}
SimpleTest.finish();
});

View File

@ -36,6 +36,8 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true],
return;
}
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
// Set mode to hidden so that the active cue lists are being updated.
trackElement.track.mode = "hidden";
var cueList = trackElement.track.cues;
is(cueList.length, 6, "Cue list length should be 6.");

View File

@ -36,6 +36,8 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true],
return;
}
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
// Set mode to hidden so that the active cue lists are being updated.
trackElement.track.mode = "hidden";
var cues = trackElement.track.cues;
is(cues.length, 1, "Cue list length should be 1.");

View File

@ -112,11 +112,13 @@ int HRTFPanner::calculateDesiredAzimuthIndexAndBlend(double azimuth, double& azi
void HRTFPanner::pan(double desiredAzimuth, double elevation, const AudioChunk* inputBus, AudioChunk* outputBus)
{
#ifdef DEBUG
unsigned numInputChannels =
inputBus->IsNull() ? 0 : inputBus->mChannelData.Length();
MOZ_ASSERT(numInputChannels <= 2);
MOZ_ASSERT(inputBus->mDuration == WEBAUDIO_BLOCK_SIZE);
#endif
bool isOutputGood = outputBus && outputBus->mChannelData.Length() == 2 && outputBus->mDuration == WEBAUDIO_BLOCK_SIZE;
MOZ_ASSERT(isOutputGood);

View File

@ -112,7 +112,7 @@ DOMSVGPoint::MatrixTransform(dom::SVGMatrix& matrix)
float x = HasOwner() ? InternalItem().mX : mPt.mX;
float y = HasOwner() ? InternalItem().mY : mPt.mY;
gfxPoint pt = matrix.Matrix().Transform(gfxPoint(x, y));
gfxPoint pt = matrix.GetMatrix().Transform(gfxPoint(x, y));
nsCOMPtr<nsISVGPoint> newPoint = new DOMSVGPoint(pt);
return newPoint.forget();
}

View File

@ -342,7 +342,7 @@ DOMSVGTransformList::RemoveItem(uint32_t index, ErrorResult& error)
already_AddRefed<SVGTransform>
DOMSVGTransformList::CreateSVGTransformFromMatrix(dom::SVGMatrix& matrix)
{
nsRefPtr<SVGTransform> result = new SVGTransform(matrix.Matrix());
nsRefPtr<SVGTransform> result = new SVGTransform(matrix.GetMatrix());
return result.forget();
}

View File

@ -6,6 +6,7 @@
#include "mozilla/dom/SVGAElement.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/SVGAElementBinding.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
@ -76,7 +77,7 @@ SVGAElement::Href()
// nsINode methods
nsresult
SVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
SVGAElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
nsresult rv = Element::PreHandleEvent(aVisitor);
NS_ENSURE_SUCCESS(rv, rv);
@ -85,7 +86,7 @@ SVGAElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
nsresult
SVGAElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
SVGAElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
return PostHandleEventForLinks(aVisitor);
}

View File

@ -14,6 +14,10 @@ nsresult NS_NewSVGAElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo>&& aNodeInfo);
namespace mozilla {
class EventChainPostVisitor;
class EventChainPreVisitor;
namespace dom {
typedef SVGGraphicsElement SVGAElementBase;
@ -33,8 +37,9 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
// nsINode interface methods
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PostHandleEvent(
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
// nsIContent

View File

@ -10,8 +10,10 @@
#define _USE_MATH_DEFINES
#include <math.h>
#include "gfxMatrix.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/RangedPtr.h"
#include "nsError.h"
#include "nsStringFwd.h"
class nsIContent;
class nsIDocument;

View File

@ -5,7 +5,6 @@
#include "mozilla/dom/SVGFECompositeElement.h"
#include "mozilla/dom/SVGFECompositeElementBinding.h"
#include "gfxContext.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEComposite)

View File

@ -4,9 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGFEFloodElement.h"
#include "FilterSupport.h"
#include "mozilla/dom/SVGFEFloodElementBinding.h"
#include "gfxContext.h"
#include "gfxColor.h"
#include "nsColor.h"
#include "nsIFrame.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEFlood)

View File

@ -6,7 +6,6 @@
#include "mozilla/dom/SVGFETileElement.h"
#include "mozilla/dom/SVGFETileElementBinding.h"
#include "nsSVGFilterInstance.h"
#include "gfxUtils.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FETile)

View File

@ -301,19 +301,19 @@ SVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
float aX, float aY, float aAutoAngle,
bool aIsStart)
{
gfxFloat scale = mEnumAttributes[MARKERUNITS].GetAnimValue() ==
SVG_MARKERUNITS_STROKEWIDTH ? aStrokeWidth : 1.0;
float scale = mEnumAttributes[MARKERUNITS].GetAnimValue() ==
SVG_MARKERUNITS_STROKEWIDTH ? aStrokeWidth : 1.0f;
gfxFloat angle;
float angle;
switch (mOrientType.GetAnimValueInternal()) {
case SVG_MARKER_ORIENT_AUTO:
angle = aAutoAngle;
break;
case SVG_MARKER_ORIENT_AUTO_START_REVERSE:
angle = aAutoAngle + (aIsStart ? M_PI : 0.0);
angle = aAutoAngle + (aIsStart ? M_PI : 0.0f);
break;
default: // SVG_MARKER_ORIENT_ANGLE
angle = mAngleAttributes[ORIENT].GetAnimValue() * M_PI / 180.0;
angle = mAngleAttributes[ORIENT].GetAnimValue() * M_PI / 180.0f;
break;
}

View File

@ -39,7 +39,7 @@ SVGMatrix::SetA(float aA, ErrorResult& rv)
return;
}
gfxMatrix mx = Matrix();
gfxMatrix mx = GetMatrix();
mx.xx = aA;
SetMatrix(mx);
}
@ -52,7 +52,7 @@ SVGMatrix::SetB(float aB, ErrorResult& rv)
return;
}
gfxMatrix mx = Matrix();
gfxMatrix mx = GetMatrix();
mx.yx = aB;
SetMatrix(mx);
}
@ -65,7 +65,7 @@ SVGMatrix::SetC(float aC, ErrorResult& rv)
return;
}
gfxMatrix mx = Matrix();
gfxMatrix mx = GetMatrix();
mx.xy = aC;
SetMatrix(mx);
}
@ -78,7 +78,7 @@ SVGMatrix::SetD(float aD, ErrorResult& rv)
return;
}
gfxMatrix mx = Matrix();
gfxMatrix mx = GetMatrix();
mx.yy = aD;
SetMatrix(mx);
}
@ -91,7 +91,7 @@ SVGMatrix::SetE(float aE, ErrorResult& rv)
return;
}
gfxMatrix mx = Matrix();
gfxMatrix mx = GetMatrix();
mx.x0 = aE;
SetMatrix(mx);
}
@ -104,7 +104,7 @@ SVGMatrix::SetF(float aF, ErrorResult& rv)
return;
}
gfxMatrix mx = Matrix();
gfxMatrix mx = GetMatrix();
mx.y0 = aF;
SetMatrix(mx);
}
@ -112,18 +112,18 @@ SVGMatrix::SetF(float aF, ErrorResult& rv)
already_AddRefed<SVGMatrix>
SVGMatrix::Multiply(SVGMatrix& aMatrix)
{
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(aMatrix.Matrix() * Matrix());
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(aMatrix.GetMatrix() * GetMatrix());
return matrix.forget();
}
already_AddRefed<SVGMatrix>
SVGMatrix::Inverse(ErrorResult& rv)
{
if (Matrix().IsSingular()) {
if (GetMatrix().IsSingular()) {
rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(gfxMatrix(Matrix()).Invert());
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(gfxMatrix(GetMatrix()).Invert());
return matrix.forget();
}
@ -131,7 +131,7 @@ already_AddRefed<SVGMatrix>
SVGMatrix::Translate(float x, float y)
{
nsRefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(Matrix()).Translate(gfxPoint(x, y)));
new SVGMatrix(gfxMatrix(GetMatrix()).Translate(gfxPoint(x, y)));
return matrix.forget();
}
@ -146,7 +146,7 @@ SVGMatrix::ScaleNonUniform(float scaleFactorX,
float scaleFactorY)
{
nsRefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(Matrix()).Scale(scaleFactorX, scaleFactorY));
new SVGMatrix(gfxMatrix(GetMatrix()).Scale(scaleFactorX, scaleFactorY));
return matrix.forget();
}
@ -154,7 +154,7 @@ already_AddRefed<SVGMatrix>
SVGMatrix::Rotate(float angle)
{
nsRefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(Matrix()).Rotate(angle*radPerDegree));
new SVGMatrix(gfxMatrix(GetMatrix()).Rotate(angle*radPerDegree));
return matrix.forget();
}
@ -167,14 +167,14 @@ SVGMatrix::RotateFromVector(float x, float y, ErrorResult& rv)
}
nsRefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(Matrix()).Rotate(atan2(y, x)));
new SVGMatrix(gfxMatrix(GetMatrix()).Rotate(atan2(y, x)));
return matrix.forget();
}
already_AddRefed<SVGMatrix>
SVGMatrix::FlipX()
{
const gfxMatrix& mx = Matrix();
const gfxMatrix& mx = GetMatrix();
nsRefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(-mx.xx, -mx.yx, mx.xy, mx.yy, mx.x0, mx.y0));
return matrix.forget();
@ -183,7 +183,7 @@ SVGMatrix::FlipX()
already_AddRefed<SVGMatrix>
SVGMatrix::FlipY()
{
const gfxMatrix& mx = Matrix();
const gfxMatrix& mx = GetMatrix();
nsRefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(mx.xx, mx.yx, -mx.xy, -mx.yy, mx.x0, mx.y0));
return matrix.forget();
@ -198,7 +198,7 @@ SVGMatrix::SkewX(float angle, ErrorResult& rv)
return nullptr;
}
const gfxMatrix& mx = Matrix();
const gfxMatrix& mx = GetMatrix();
gfxMatrix skewMx(mx.xx, mx.yx,
(float) (mx.xy + mx.xx*ta), (float) (mx.yy + mx.yx*ta),
mx.x0, mx.y0);
@ -215,7 +215,7 @@ SVGMatrix::SkewY(float angle, ErrorResult& rv)
return nullptr;
}
const gfxMatrix& mx = Matrix();
const gfxMatrix& mx = GetMatrix();
gfxMatrix skewMx((float) (mx.xx + mx.xy*ta), (float) (mx.yx + mx.yy*ta),
mx.xy, mx.yy,
mx.x0, mx.y0);

View File

@ -75,7 +75,7 @@ public:
SetIsDOMBinding();
}
const gfxMatrix& Matrix() const {
const gfxMatrix& GetMatrix() const {
return mTransform ? mTransform->Matrixgfx() : mMatrix;
}
@ -84,17 +84,17 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
float A() const { return static_cast<float>(Matrix().xx); }
float A() const { return static_cast<float>(GetMatrix().xx); }
void SetA(float aA, ErrorResult& rv);
float B() const { return static_cast<float>(Matrix().yx); }
float B() const { return static_cast<float>(GetMatrix().yx); }
void SetB(float aB, ErrorResult& rv);
float C() const { return static_cast<float>(Matrix().xy); }
float C() const { return static_cast<float>(GetMatrix().xy); }
void SetC(float aC, ErrorResult& rv);
float D() const { return static_cast<float>(Matrix().yy); }
float D() const { return static_cast<float>(GetMatrix().yy); }
void SetD(float aD, ErrorResult& rv);
float E() const { return static_cast<float>(Matrix().x0); }
float E() const { return static_cast<float>(GetMatrix().x0); }
void SetE(float aE, ErrorResult& rv);
float F() const { return static_cast<float>(Matrix().y0); }
float F() const { return static_cast<float>(GetMatrix().y0); }
void SetF(float aF, ErrorResult& rv);
already_AddRefed<SVGMatrix> Multiply(SVGMatrix& aMatrix);
already_AddRefed<SVGMatrix> Inverse(ErrorResult& aRv);

View File

@ -8,6 +8,7 @@
#include "SVGPathSegUtils.h"
#include "gfx2DGlue.h"
#include "gfxPoint.h"
#include "nsSVGPathDataParser.h"
#include "nsTextFormatter.h"

View File

@ -6,7 +6,6 @@
#ifndef MOZILLA_SVGPATHSEGUTILS_H__
#define MOZILLA_SVGPATHSEGUTILS_H__
#include "gfxPoint.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/gfx/Point.h"
#include "nsDebug.h"

View File

@ -6,6 +6,8 @@
#include "mozilla/dom/SVGRect.h"
#include "nsSVGElement.h"
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -47,9 +49,9 @@ NS_NewSVGRect(nsIContent* aParent, float aX, float aY, float aWidth,
}
already_AddRefed<mozilla::dom::SVGRect>
NS_NewSVGRect(nsIContent* aParent, const gfxRect& aRect)
NS_NewSVGRect(nsIContent* aParent, const Rect& aRect)
{
return NS_NewSVGRect(aParent, aRect.X(), aRect.Y(),
aRect.Width(), aRect.Height());
return NS_NewSVGRect(aParent, aRect.x, aRect.y,
aRect.width, aRect.height);
}

View File

@ -6,8 +6,8 @@
#ifndef mozilla_dom_SVGRect_h
#define mozilla_dom_SVGRect_h
#include "gfxRect.h"
#include "mozilla/dom/SVGIRect.h"
#include "mozilla/gfx/Rect.h"
#include "nsSVGElement.h"
////////////////////////////////////////////////////////////////////////
@ -84,6 +84,6 @@ NS_NewSVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f,
float width=0.0f, float height=0.0f);
already_AddRefed<mozilla::dom::SVGRect>
NS_NewSVGRect(nsIContent* aParent, const gfxRect& rect);
NS_NewSVGRect(nsIContent* aParent, const mozilla::gfx::Rect& rect);
#endif //mozilla_dom_SVGRect_h

View File

@ -6,6 +6,7 @@
#include <stdint.h>
#include "mozilla/ArrayUtils.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Likely.h"
#include "nsGkAtoms.h"
@ -32,7 +33,6 @@
#include "nsStyleUtil.h"
#include "SVGContentUtils.h"
#include "nsEventDispatcher.h"
#include "nsSMILTimeContainer.h"
#include "nsSMILAnimationController.h"
#include "nsSMILTypes.h"
@ -433,7 +433,7 @@ SVGSVGElement::CreateSVGTransform()
already_AddRefed<SVGTransform>
SVGSVGElement::CreateSVGTransformFromMatrix(SVGMatrix& matrix)
{
nsRefPtr<SVGTransform> transform = new SVGTransform(matrix.Matrix());
nsRefPtr<SVGTransform> transform = new SVGTransform(matrix.GetMatrix());
return transform.forget();
}
@ -589,7 +589,7 @@ SVGSVGElement::IsAttributeMapped(const nsIAtom* name) const
// nsIContent methods:
nsresult
SVGSVGElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
SVGSVGElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
if (aVisitor.mEvent->message == NS_SVG_LOAD) {
if (mTimedDocumentRoot) {

View File

@ -28,9 +28,10 @@ class nsSVGInnerSVGFrame;
class nsSVGImageFrame;
namespace mozilla {
class DOMSVGAnimatedPreserveAspectRatio;
class SVGFragmentIdentifier;
class AutoSVGRenderingState;
class DOMSVGAnimatedPreserveAspectRatio;
class EventChainPreVisitor;
class SVGFragmentIdentifier;
namespace dom {
class SVGAngle;
@ -127,7 +128,7 @@ public:
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;

View File

@ -170,7 +170,7 @@ SVGTransform::Type() const
}
SVGMatrix*
SVGTransform::Matrix()
SVGTransform::GetMatrix()
{
SVGMatrix* wrapper =
SVGMatrixTearoffTable().GetTearoff(this);
@ -194,7 +194,7 @@ SVGTransform::SetMatrix(SVGMatrix& aMatrix, ErrorResult& rv)
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
return;
}
SetMatrix(aMatrix.Matrix());
SetMatrix(aMatrix.GetMatrix());
}
void

View File

@ -123,7 +123,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
uint16_t Type() const;
dom::SVGMatrix* Matrix();
dom::SVGMatrix* GetMatrix();
float Angle() const;
void SetMatrix(dom::SVGMatrix& matrix, ErrorResult& rv);
void SetTranslate(float tx, float ty, ErrorResult& rv);
@ -139,7 +139,7 @@ protected:
return mIsAnimValItem;
}
const gfxMatrix& Matrixgfx() const {
return Transform().Matrix();
return Transform().GetMatrix();
}
void SetMatrix(const gfxMatrix& aMatrix);

View File

@ -22,13 +22,13 @@ SVGTransformList::GetConsolidationMatrix() const
if (mItems.IsEmpty())
return result;
result = mItems[0].Matrix();
result = mItems[0].GetMatrix();
if (mItems.Length() == 1)
return result;
for (uint32_t i = 1; i < mItems.Length(); ++i) {
result.PreMultiply(mItems[i].Matrix());
result.PreMultiply(mItems[i].GetMatrix());
}
return result;

View File

@ -3,6 +3,7 @@
* 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 "gfx2DGlue.h"
#include "mozilla/dom/SVGAnimatedTransformList.h"
#include "mozilla/dom/SVGTransformableElement.h"
#include "mozilla/dom/SVGMatrix.h"
@ -15,6 +16,8 @@
#include "nsSVGUtils.h"
#include "SVGContentUtils.h"
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -183,7 +186,7 @@ SVGTransformableElement::GetBBox(ErrorResult& rv)
return nullptr;
}
return NS_NewSVGRect(this, nsSVGUtils::GetBBox(frame));
return NS_NewSVGRect(this, ToRect(nsSVGUtils::GetBBox(frame)));
}
already_AddRefed<SVGMatrix>

View File

@ -23,13 +23,10 @@
#include "nsSVGUtils.h"
#include "nsStyleContext.h"
#include "nsIFrame.h"
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "imgIContainer.h"
#include "nsNetUtil.h"
#include "mozilla/dom/SVGFilterElement.h"
#include "nsSVGString.h"
#include "gfxUtils.h"
#include "SVGContentUtils.h"
#include <algorithm>
#include "mozilla/dom/SVGAnimatedLength.h"

Some files were not shown because too many files have changed in this diff Show More