mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Merge m-c to m-i.
This commit is contained in:
commit
93257af4d7
@ -419,8 +419,6 @@ public:
|
||||
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetAttributes(nsIDOMMozNamedAttrMap** aAttributes);
|
||||
|
||||
/**
|
||||
* Helper for SetAttr/SetParsedAttr. This method will return true if aNotify
|
||||
* is true or there are mutation listeners that must be triggered, the
|
||||
@ -657,7 +655,7 @@ public:
|
||||
already_AddRefed<nsIDOMAttr> SetAttributeNodeNS(nsIDOMAttr* aNewAttr,
|
||||
ErrorResult& aError);
|
||||
|
||||
already_AddRefed<nsClientRectList> GetClientRects(ErrorResult& aError);
|
||||
already_AddRefed<nsClientRectList> GetClientRects();
|
||||
already_AddRefed<nsClientRect> GetBoundingClientRect();
|
||||
void ScrollIntoView(bool aTop);
|
||||
int32_t ScrollTop()
|
||||
@ -1320,6 +1318,11 @@ NS_IMETHOD GetClassList(nsISupports** aClassList) MOZ_FINAL \
|
||||
Element::GetClassList(aClassList); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMMozNamedAttrMap** aAttributes) MOZ_FINAL \
|
||||
{ \
|
||||
NS_ADDREF(*aAttributes = Attributes()); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
using Element::GetAttribute; \
|
||||
NS_IMETHOD GetAttribute(const nsAString& name, nsAString& _retval) MOZ_FINAL \
|
||||
{ \
|
||||
@ -1507,9 +1510,8 @@ NS_IMETHOD SetOnmouseleave(JSContext* cx, \
|
||||
} \
|
||||
NS_IMETHOD GetClientRects(nsIDOMClientRectList** _retval) MOZ_FINAL \
|
||||
{ \
|
||||
mozilla::ErrorResult rv; \
|
||||
*_retval = Element::GetClientRects(rv).get(); \
|
||||
return rv.ErrorCode(); \
|
||||
*_retval = Element::GetClientRects().get(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHOD GetBoundingClientRect(nsIDOMClientRect** _retval) MOZ_FINAL \
|
||||
{ \
|
||||
|
@ -19,6 +19,7 @@ nsIAttribute.h \
|
||||
nsIContentIterator.h \
|
||||
nsContentPolicyUtils.h \
|
||||
nsContentUtils.h \
|
||||
nsDocElementCreatedNotificationRunner.h \
|
||||
nsIDocument.h \
|
||||
nsIDocumentInlines.h \
|
||||
nsDeprecatedOperationList.h \
|
||||
|
@ -18,106 +18,120 @@
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
#include "nsAString.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIXPCScriptable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsHtml5StringParser.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentSink.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentList.h"
|
||||
|
||||
#include "js/RootingAPI.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentListDeclarations.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
struct nsNativeKeyEvent; // Don't include nsINativeKeyBindings.h here: it will force strange compilation error!
|
||||
|
||||
class nsIDOMScriptObjectFactory;
|
||||
class nsIXPConnect;
|
||||
class nsIContent;
|
||||
class nsIDOMKeyEvent;
|
||||
class nsIDocument;
|
||||
class nsIDocumentObserver;
|
||||
class nsIDocShell;
|
||||
class nsINameSpaceManager;
|
||||
class nsIFragmentContentSink;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIScriptSecurityManager;
|
||||
class nsTextFragment;
|
||||
class nsIJSContextStack;
|
||||
class nsIThreadJSContextStack;
|
||||
class nsIParser;
|
||||
class nsIParserService;
|
||||
class nsIIOService;
|
||||
class nsIURI;
|
||||
class imgICache;
|
||||
class imgIContainer;
|
||||
class imgINotificationObserver;
|
||||
class imgRequestProxy;
|
||||
class imgIRequest;
|
||||
class imgLoader;
|
||||
class imgICache;
|
||||
class nsIImageLoadingContent;
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIDOMDocument;
|
||||
class nsIConsoleService;
|
||||
class nsIStringBundleService;
|
||||
class nsIStringBundle;
|
||||
class nsIContentPolicy;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsIJSRuntimeService;
|
||||
class nsEventListenerManager;
|
||||
class nsIScriptContext;
|
||||
class nsIRunnable;
|
||||
class nsIInterfaceRequestor;
|
||||
class nsINodeInfo;
|
||||
template<class E> class nsCOMArray;
|
||||
template<class K, class V> class nsRefPtrHashtable;
|
||||
struct JSRuntime;
|
||||
class nsIWidget;
|
||||
class nsIDragSession;
|
||||
class nsIPresShell;
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
#ifdef IBMBIDI
|
||||
class nsIBidiKeyboard;
|
||||
#endif
|
||||
class nsIMIMEHeaderParam;
|
||||
class nsIObserver;
|
||||
class nsPresContext;
|
||||
class nsIChannel;
|
||||
class imgRequestProxy;
|
||||
class nsAutoScriptBlockerSuppressNodeRemoved;
|
||||
struct nsIntMargin;
|
||||
class nsPIDOMWindow;
|
||||
class nsDragEvent;
|
||||
class nsEvent;
|
||||
class nsEventListenerManager;
|
||||
class nsHtml5StringParser;
|
||||
class nsIChannel;
|
||||
class nsIConsoleService;
|
||||
class nsIContent;
|
||||
class nsIContentPolicy;
|
||||
class nsIDocShell;
|
||||
class nsIDocument;
|
||||
class nsIDocumentLoaderFactory;
|
||||
class nsIDocumentObserver;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsIDOMEvent;
|
||||
class nsIDOMEventTarget;
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIDOMHTMLInputElement;
|
||||
|
||||
class nsIDOMKeyEvent;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMScriptObjectFactory;
|
||||
class nsIDOMWindow;
|
||||
class nsIDragSession;
|
||||
class nsIEditor;
|
||||
class nsIFragmentContentSink;
|
||||
class nsIImageLoadingContent;
|
||||
class nsIInterfaceRequestor;
|
||||
class nsIIOService;
|
||||
class nsIJSContextStack;
|
||||
class nsIJSRuntimeService;
|
||||
class nsILineBreaker;
|
||||
class nsIMIMEHeaderParam;
|
||||
class nsINameSpaceManager;
|
||||
class nsINodeInfo;
|
||||
class nsIObserver;
|
||||
class nsIParser;
|
||||
class nsIParserService;
|
||||
class nsIPresShell;
|
||||
class nsIPrincipal;
|
||||
class nsIRunnable;
|
||||
class nsIScriptContext;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIScriptSecurityManager;
|
||||
class nsIStringBundle;
|
||||
class nsIStringBundleService;
|
||||
class nsISupportsHashKey;
|
||||
class nsIThreadJSContextStack;
|
||||
class nsIURI;
|
||||
class nsIWidget;
|
||||
class nsIWordBreaker;
|
||||
class nsIXPConnect;
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
class nsKeyEvent;
|
||||
class nsNodeInfoManager;
|
||||
class nsPIDOMWindow;
|
||||
class nsPresContext;
|
||||
class nsScriptObjectTracer;
|
||||
class nsStringHashKey;
|
||||
class nsTextFragment;
|
||||
class nsViewportInfo;
|
||||
|
||||
struct JSContext;
|
||||
struct JSPropertyDescriptor;
|
||||
struct JSRuntime;
|
||||
struct nsIntMargin;
|
||||
struct nsNativeKeyEvent; // Don't include nsINativeKeyBindings.h here: it will force strange compilation error!
|
||||
|
||||
template<class E> class nsCOMArray;
|
||||
template<class E> class nsTArray;
|
||||
template<class K, class V> class nsDataHashtable;
|
||||
template<class K, class V> class nsRefPtrHashtable;
|
||||
|
||||
namespace JS {
|
||||
class Value;
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
class Selection;
|
||||
|
||||
namespace layers {
|
||||
class LayerManager;
|
||||
} // namespace layers
|
||||
|
||||
namespace dom {
|
||||
class DocumentFragment;
|
||||
class Element;
|
||||
} // namespace dom
|
||||
|
||||
namespace layers {
|
||||
class LayerManager;
|
||||
} // namespace layers
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#ifdef IBMBIDI
|
||||
class nsIBidiKeyboard;
|
||||
#endif
|
||||
|
||||
extern const char kLoadAsData[];
|
||||
|
||||
enum EventNameType {
|
||||
@ -242,13 +256,7 @@ public:
|
||||
* Returns true if aNode1 is before aNode2 in the same connected
|
||||
* tree.
|
||||
*/
|
||||
static bool PositionIsBefore(nsINode* aNode1, nsINode* aNode2)
|
||||
{
|
||||
return (aNode2->CompareDocumentPosition(*aNode1) &
|
||||
(nsIDOMNode::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED)) ==
|
||||
nsIDOMNode::DOCUMENT_POSITION_PRECEDING;
|
||||
}
|
||||
static bool PositionIsBefore(nsINode* aNode1, nsINode* aNode2);
|
||||
|
||||
/**
|
||||
* Utility routine to compare two "points", where a point is a
|
||||
@ -679,16 +687,7 @@ public:
|
||||
* from aNodeInfo.
|
||||
*/
|
||||
static nsresult NameChanged(nsINodeInfo* aNodeInfo, nsIAtom* aName,
|
||||
nsINodeInfo** aResult)
|
||||
{
|
||||
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
||||
|
||||
*aResult = niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(),
|
||||
aNodeInfo->NamespaceID(),
|
||||
aNodeInfo->NodeType(),
|
||||
aNodeInfo->GetExtraName()).get();
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsINodeInfo** aResult);
|
||||
|
||||
/**
|
||||
* Returns the appropriate event argument names for the specified
|
||||
@ -1665,8 +1664,9 @@ public:
|
||||
static bool CanAccessNativeAnon();
|
||||
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
nsISupports *native, const nsIID* aIID, jsval *vp,
|
||||
// If non-null aHolder will keep the jsval alive
|
||||
nsISupports *native, const nsIID* aIID,
|
||||
JS::Value *vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
nsIXPConnectJSObjectHolder** aHolder = nullptr,
|
||||
bool aAllowWrapping = false)
|
||||
@ -1677,8 +1677,8 @@ public:
|
||||
|
||||
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
nsISupports *native, jsval *vp,
|
||||
// If non-null aHolder will keep the jsval alive
|
||||
nsISupports *native, JS::Value *vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
nsIXPConnectJSObjectHolder** aHolder = nullptr,
|
||||
bool aAllowWrapping = false)
|
||||
@ -1688,8 +1688,8 @@ public:
|
||||
}
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
jsval *vp,
|
||||
// If non-null aHolder will keep the jsval alive
|
||||
JS::Value *vp,
|
||||
// If non-null aHolder will keep the Value alive
|
||||
// while there's a ref to it
|
||||
nsIXPConnectJSObjectHolder** aHolder = nullptr,
|
||||
bool aAllowWrapping = false)
|
||||
@ -1706,7 +1706,7 @@ public:
|
||||
|
||||
static nsresult CreateBlobBuffer(JSContext* aCx,
|
||||
const nsACString& aData,
|
||||
jsval& aBlob);
|
||||
JS::Value& aBlob);
|
||||
|
||||
static void StripNullChars(const nsAString& aInStr, nsAString& aOutStr);
|
||||
|
||||
@ -2114,7 +2114,7 @@ private:
|
||||
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
nsISupports *native, nsWrapperCache *cache,
|
||||
const nsIID* aIID, jsval *vp,
|
||||
const nsIID* aIID, JS::Value *vp,
|
||||
nsIXPConnectJSObjectHolder** aHolder,
|
||||
bool aAllowWrapping);
|
||||
|
||||
@ -2434,21 +2434,4 @@ private:
|
||||
nsIMIMEHeaderParam* mService;
|
||||
};
|
||||
|
||||
class nsDocElementCreatedNotificationRunner : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsDocElementCreatedNotificationRunner(nsIDocument* aDoc)
|
||||
: mDoc(aDoc)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsContentSink::NotifyDocElementCreated(mDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
};
|
||||
|
||||
#endif /* nsContentUtils_h___ */
|
||||
|
32
content/base/public/nsDocElementCreatedNotificationRunner.h
Normal file
32
content/base/public/nsDocElementCreatedNotificationRunner.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsDocElementCreatedNotificationRunner_h
|
||||
#define nsDocElementCreatedNotificationRunner_h
|
||||
|
||||
#include "nsThreadUtils.h" /* nsRunnable */
|
||||
|
||||
#include "nsContentSink.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
class nsDocElementCreatedNotificationRunner : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsDocElementCreatedNotificationRunner(nsIDocument* aDoc)
|
||||
: mDoc(aDoc)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsContentSink::NotifyDocElementCreated(mDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
};
|
||||
|
||||
#endif /* nsDocElementCreatedNotificationRunner_h */
|
@ -250,6 +250,10 @@ interface nsIFrameLoader : nsISupports
|
||||
readonly attribute nsIDOMElement ownerElement;
|
||||
};
|
||||
|
||||
%{C++
|
||||
class nsFrameLoader;
|
||||
%}
|
||||
|
||||
native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);
|
||||
|
||||
[scriptable, uuid(5879040e-83e9-40e3-b2bb-5ddf43b76e47)]
|
||||
|
@ -34,7 +34,6 @@ class nsDOMAttributeMap;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMMozNamedAttrMap;
|
||||
class nsIDOMNodeList;
|
||||
class nsIDOMUserDataHandler;
|
||||
class nsIEditor;
|
||||
@ -1653,7 +1652,6 @@ protected:
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
nsresult CompareDocumentPosition(nsIDOMNode* aOther,
|
||||
uint16_t* aReturn);
|
||||
nsresult GetAttributes(nsIDOMMozNamedAttrMap** aAttributes);
|
||||
|
||||
nsresult ReplaceOrInsertBefore(bool aReplace, nsIDOMNode *aNewChild,
|
||||
nsIDOMNode *aRefChild, nsIDOMNode **aReturn);
|
||||
@ -1955,10 +1953,6 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID)
|
||||
{ \
|
||||
return nsINode::GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMMozNamedAttrMap** aAttributes) __VA_ARGS__ \
|
||||
{ \
|
||||
return nsINode::GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) __VA_ARGS__ \
|
||||
{ \
|
||||
return nsINode::GetOwnerDocument(aOwnerDocument); \
|
||||
|
@ -654,7 +654,7 @@ Element::GetClientAreaRect()
|
||||
already_AddRefed<nsClientRect>
|
||||
Element::GetBoundingClientRect()
|
||||
{
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect();
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect(this);
|
||||
|
||||
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
|
||||
if (!frame) {
|
||||
@ -670,7 +670,7 @@ Element::GetBoundingClientRect()
|
||||
}
|
||||
|
||||
already_AddRefed<nsClientRectList>
|
||||
Element::GetClientRects(ErrorResult& aError)
|
||||
Element::GetClientRects()
|
||||
{
|
||||
nsRefPtr<nsClientRectList> rectList = new nsClientRectList(this);
|
||||
|
||||
@ -684,10 +684,6 @@ Element::GetClientRects(ErrorResult& aError)
|
||||
nsLayoutUtils::GetAllInFlowRects(frame,
|
||||
nsLayoutUtils::GetContainingBlockForClientRect(frame), &builder,
|
||||
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
|
||||
if (NS_FAILED(builder.mRV)) {
|
||||
aError.Throw(builder.mRV);
|
||||
return nullptr;
|
||||
}
|
||||
return rectList.forget();
|
||||
}
|
||||
|
||||
@ -1472,13 +1468,6 @@ Element::GetExistingAttrNameFromQName(const nsAString& aStr) const
|
||||
return nodeInfo;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Element::GetAttributes(nsIDOMMozNamedAttrMap** aAttributes)
|
||||
{
|
||||
NS_ADDREF(*aAttributes = Attributes());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
Element::ShouldBlur(nsIContent *aContent)
|
||||
|
@ -19,6 +19,7 @@ EXPORTS = \
|
||||
nsAtomListUtils.h \
|
||||
nsAttrName.h \
|
||||
nsContentList.h \
|
||||
nsContentListDeclarations.h \
|
||||
nsContentSink.h \
|
||||
nsGkAtomList.h \
|
||||
nsGkAtoms.h \
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "mozilla/dom/TreeWalker.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsError.h"
|
||||
#include "nsINode.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef nsContentList_h___
|
||||
#define nsContentList_h___
|
||||
|
||||
#include "nsContentListDeclarations.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsStringGlue.h"
|
||||
@ -26,21 +27,6 @@
|
||||
#include "nsHashKeys.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
|
||||
// Magic namespace id that means "match all namespaces". This is
|
||||
// negative so it won't collide with actual namespace constants.
|
||||
#define kNameSpaceID_Wildcard INT32_MIN
|
||||
|
||||
// This is a callback function type that can be used to implement an
|
||||
// arbitrary matching algorithm. aContent is the content that may
|
||||
// match the list, while aNamespaceID, aAtom, and aData are whatever
|
||||
// was passed to the list's constructor.
|
||||
typedef bool (*nsContentListMatchFunc)(nsIContent* aContent,
|
||||
int32_t aNamespaceID,
|
||||
nsIAtom* aAtom,
|
||||
void* aData);
|
||||
|
||||
typedef void (*nsContentListDestroyFunc)(void* aData);
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
@ -472,14 +458,6 @@ private:
|
||||
const nsAString& mString;
|
||||
};
|
||||
|
||||
/**
|
||||
* A function that allocates the matching data for this
|
||||
* FuncStringContentList. Returning aString is perfectly fine; in
|
||||
* that case the destructor function should be a no-op.
|
||||
*/
|
||||
typedef void* (*nsFuncStringContentListDataAllocator)(nsINode* aRootNode,
|
||||
const nsString* aString);
|
||||
|
||||
// aDestroyFunc is allowed to be null
|
||||
// aDataAllocator must always return a non-null pointer
|
||||
class nsCacheableFuncStringContentList : public nsContentList {
|
||||
@ -568,26 +546,4 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
// If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a
|
||||
// content list which matches ASCIIToLower(aTagname) against HTML
|
||||
// elements in HTML documents and aTagname against everything else.
|
||||
// For any other value of aMatchNameSpaceId, the list will match
|
||||
// aTagname against all elements.
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetContentList(nsINode* aRootNode,
|
||||
int32_t aMatchNameSpaceId,
|
||||
const nsAString& aTagname);
|
||||
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetFuncStringNodeList(nsINode* aRootNode,
|
||||
nsContentListMatchFunc aFunc,
|
||||
nsContentListDestroyFunc aDestroyFunc,
|
||||
nsFuncStringContentListDataAllocator aDataAllocator,
|
||||
const nsAString& aString);
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetFuncStringHTMLCollection(nsINode* aRootNode,
|
||||
nsContentListMatchFunc aFunc,
|
||||
nsContentListDestroyFunc aDestroyFunc,
|
||||
nsFuncStringContentListDataAllocator aDataAllocator,
|
||||
const nsAString& aString);
|
||||
#endif // nsContentList_h___
|
||||
|
64
content/base/src/nsContentListDeclarations.h
Normal file
64
content/base/src/nsContentListDeclarations.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsContentListDeclarations_h
|
||||
#define nsContentListDeclarations_h
|
||||
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
class nsContentList;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsINode;
|
||||
|
||||
// Magic namespace id that means "match all namespaces". This is
|
||||
// negative so it won't collide with actual namespace constants.
|
||||
#define kNameSpaceID_Wildcard INT32_MIN
|
||||
|
||||
// This is a callback function type that can be used to implement an
|
||||
// arbitrary matching algorithm. aContent is the content that may
|
||||
// match the list, while aNamespaceID, aAtom, and aData are whatever
|
||||
// was passed to the list's constructor.
|
||||
typedef bool (*nsContentListMatchFunc)(nsIContent* aContent,
|
||||
int32_t aNamespaceID,
|
||||
nsIAtom* aAtom,
|
||||
void* aData);
|
||||
|
||||
typedef void (*nsContentListDestroyFunc)(void* aData);
|
||||
|
||||
/**
|
||||
* A function that allocates the matching data for this
|
||||
* FuncStringContentList. Returning aString is perfectly fine; in
|
||||
* that case the destructor function should be a no-op.
|
||||
*/
|
||||
typedef void* (*nsFuncStringContentListDataAllocator)(nsINode* aRootNode,
|
||||
const nsString* aString);
|
||||
|
||||
// If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a
|
||||
// content list which matches ASCIIToLower(aTagname) against HTML
|
||||
// elements in HTML documents and aTagname against everything else.
|
||||
// For any other value of aMatchNameSpaceId, the list will match
|
||||
// aTagname against all elements.
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetContentList(nsINode* aRootNode,
|
||||
int32_t aMatchNameSpaceId,
|
||||
const nsAString& aTagname);
|
||||
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetFuncStringNodeList(nsINode* aRootNode,
|
||||
nsContentListMatchFunc aFunc,
|
||||
nsContentListDestroyFunc aDestroyFunc,
|
||||
nsFuncStringContentListDataAllocator aDataAllocator,
|
||||
const nsAString& aString);
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetFuncStringHTMLCollection(nsINode* aRootNode,
|
||||
nsContentListMatchFunc aFunc,
|
||||
nsContentListDestroyFunc aDestroyFunc,
|
||||
nsFuncStringContentListDataAllocator aDataAllocator,
|
||||
const nsAString& aString);
|
||||
|
||||
#endif // nsContentListDeclarations_h
|
@ -6,172 +6,170 @@
|
||||
|
||||
/* A namespace class for static layout utilities. */
|
||||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
#include "DecoderTraits.h"
|
||||
#include "harfbuzz/hb.h"
|
||||
#include "imgICache.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgINotificationObserver.h"
|
||||
#include "imgLoader.h"
|
||||
#include "imgRequestProxy.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "mozilla/dom/TextDecoderBase.h"
|
||||
|
||||
#include "js/Value.h"
|
||||
#include "Layers.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIContent.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIIdleService.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIFragmentContentSink.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "mozilla/dom/TextDecoderBase.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Selection.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsChannelPolicy.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentDLF.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "imgINotificationObserver.h"
|
||||
#include "imgRequestProxy.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgLoader.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsCPrefetchService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMDataTransfer.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsDOMMutationObserver.h"
|
||||
#include "nsDOMTouchEvent.h"
|
||||
#include "nsError.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsHtml5Module.h"
|
||||
#include "nsHtml5StringParser.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetDetectionObserver.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
#include "nsIDragService.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFragmentContentSink.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIIdleService.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsINativeKeyBindings.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsLWBrkCIID.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsIWordBreaker.h"
|
||||
#include "nsUnicodeProperties.h"
|
||||
#include "harfbuzz/hb.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsIOfflineCacheUpdate.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsError.h"
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsINativeKeyBindings.h"
|
||||
#include "nsXULPopupManager.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsReferencedElement.h"
|
||||
#include "nsIDragService.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIOfflineCacheUpdate.h"
|
||||
#include "nsCPrefetchService.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsIDOMXULCommandEvent.h"
|
||||
#include "nsDOMDataTransfer.h"
|
||||
#include "nsHtml5Module.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsTextEditorState.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsParserConstants.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIWordBreaker.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsLWBrkCIID.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsParserConstants.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReferencedElement.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsSVGFeatures.h"
|
||||
#include "nsTextEditorState.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "mozilla/Selection.h"
|
||||
#include <algorithm>
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsUnicodeProperties.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsViewportInfo.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "nsXULPopupManager.h"
|
||||
#include "xpcprivate.h" // nsXPConnect
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
#endif
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
// for ReportToConsole
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIConsoleService.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "imgICache.h"
|
||||
#include "imgLoader.h"
|
||||
#include "xpcprivate.h" // nsXPConnect
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsChannelPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsContentDLF.h"
|
||||
#ifdef MOZ_MEDIA
|
||||
#include "nsHTMLMediaElement.h"
|
||||
#endif
|
||||
#include "nsDOMTouchEvent.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsDOMMutationObserver.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsICharsetDetectionObserver.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsSVGFeatures.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "DecoderTraits.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "nsViewportInfo.h"
|
||||
|
||||
extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end,
|
||||
const char** next, PRUnichar* result);
|
||||
@ -1976,6 +1974,16 @@ nsContentUtils::GetCommonAncestor(nsINode* aNode1,
|
||||
return parent;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
nsContentUtils::PositionIsBefore(nsINode* aNode1, nsINode* aNode2)
|
||||
{
|
||||
return (aNode2->CompareDocumentPosition(*aNode1) &
|
||||
(nsIDOMNode::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED)) ==
|
||||
nsIDOMNode::DOCUMENT_POSITION_PRECEDING;
|
||||
}
|
||||
|
||||
/* static */
|
||||
int32_t
|
||||
nsContentUtils::ComparePoints(nsINode* aParent1, int32_t aOffset1,
|
||||
@ -2881,6 +2889,21 @@ nsContentUtils::IsDraggableLink(const nsIContent* aContent) {
|
||||
return aContent->IsLink(getter_AddRefs(absURI));
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::NameChanged(nsINodeInfo* aNodeInfo, nsIAtom* aName,
|
||||
nsINodeInfo** aResult)
|
||||
{
|
||||
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
||||
|
||||
*aResult = niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(),
|
||||
aNodeInfo->NamespaceID(),
|
||||
aNodeInfo->NodeType(),
|
||||
aNodeInfo->GetExtraName()).get();
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
TestSitePerm(nsIPrincipal* aPrincipal, const char* aType, uint32_t aPerm, bool aExactHostMatch)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsError.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIConverterInputStream.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -4,7 +4,10 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsDOMSerializer.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsError.h"
|
||||
|
@ -2404,14 +2404,6 @@ nsINode::GetAttributes()
|
||||
return AsElement()->Attributes();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::GetAttributes(nsIDOMMozNamedAttrMap** aAttributes)
|
||||
{
|
||||
nsRefPtr<nsDOMAttributeMap> map = GetAttributes();
|
||||
map.forget(aAttributes);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
EventTarget::DispatchEvent(nsDOMEvent& aEvent,
|
||||
ErrorResult& aRv)
|
||||
|
@ -4,8 +4,9 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsMixedContentBlocker.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
@ -2938,12 +2938,13 @@ nsRange::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMClientRect>
|
||||
already_AddRefed<nsClientRect>
|
||||
nsRange::GetBoundingClientRect()
|
||||
{
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect();
|
||||
if (!mStartParent)
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect(ToSupports(this));
|
||||
if (!mStartParent) {
|
||||
return rect.forget();
|
||||
}
|
||||
|
||||
nsLayoutUtils::RectAccumulator accumulator;
|
||||
CollectClientRects(&accumulator, this, mStartParent, mStartOffset,
|
||||
@ -2958,16 +2959,16 @@ nsRange::GetBoundingClientRect()
|
||||
NS_IMETHODIMP
|
||||
nsRange::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aResult = GetClientRects(rv).get();
|
||||
return rv.ErrorCode();
|
||||
*aResult = GetClientRects().get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsClientRectList>
|
||||
nsRange::GetClientRects(ErrorResult& rv)
|
||||
nsRange::GetClientRects()
|
||||
{
|
||||
if (!mStartParent)
|
||||
if (!mStartParent) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<nsClientRectList> rectList =
|
||||
new nsClientRectList(static_cast<nsIDOMRange*>(this));
|
||||
@ -2976,11 +2977,6 @@ nsRange::GetClientRects(ErrorResult& rv)
|
||||
|
||||
CollectClientRects(&builder, this, mStartParent, mStartOffset,
|
||||
mEndParent, mEndOffset);
|
||||
|
||||
if (NS_FAILED(builder.mRV)) {
|
||||
rv.Throw(builder.mRV);
|
||||
return nullptr;
|
||||
}
|
||||
return rectList.forget();
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsClientRect;
|
||||
class nsClientRectList;
|
||||
class nsIDOMDocumentFragment;
|
||||
|
||||
@ -192,8 +193,8 @@ public:
|
||||
void SetStartAfter(nsINode& aNode, ErrorResult& aErr);
|
||||
void SetStartBefore(nsINode& aNode, ErrorResult& aErr);
|
||||
void SurroundContents(nsINode& aNode, ErrorResult& aErr);
|
||||
already_AddRefed<nsIDOMClientRect> GetBoundingClientRect();
|
||||
already_AddRefed<nsClientRectList> GetClientRects(ErrorResult& aErr);
|
||||
already_AddRefed<nsClientRect> GetBoundingClientRect();
|
||||
already_AddRefed<nsClientRectList> GetClientRects();
|
||||
|
||||
nsINode* GetParentObject() const { return mOwner; }
|
||||
virtual JSObject* WrapObject(JSContext* cx, JSObject* scope) MOZ_OVERRIDE MOZ_FINAL;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "nsPIWindowRoot.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
static char *sPopupAllowedEvents;
|
||||
|
||||
@ -92,7 +93,7 @@ nsDOMEvent::InitPresContextData(nsPresContext* aPresContext)
|
||||
// Get the explicit original target (if it's anonymous make it null)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = GetTargetFromFrame();
|
||||
mExplicitOriginalTarget = do_QueryInterface(content);
|
||||
mExplicitOriginalTarget = content;
|
||||
if (content && content->IsInAnonymousSubtree()) {
|
||||
mExplicitOriginalTarget = nullptr;
|
||||
}
|
||||
@ -222,28 +223,36 @@ NS_METHOD nsDOMEvent::GetType(nsAString& aType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetDOMEventTarget(nsIDOMEventTarget* aTarget,
|
||||
nsIDOMEventTarget** aDOMTarget)
|
||||
static EventTarget*
|
||||
GetDOMEventTarget(nsIDOMEventTarget* aTarget)
|
||||
{
|
||||
nsIDOMEventTarget* realTarget =
|
||||
aTarget ? aTarget->GetTargetForDOMEvent() : aTarget;
|
||||
return aTarget ? aTarget->GetTargetForDOMEvent() : nullptr;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aDOMTarget = realTarget);
|
||||
|
||||
return NS_OK;
|
||||
EventTarget*
|
||||
nsDOMEvent::GetTarget() const
|
||||
{
|
||||
return GetDOMEventTarget(mEvent->target);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsDOMEvent::GetTarget(nsIDOMEventTarget** aTarget)
|
||||
{
|
||||
return GetDOMEventTarget(mEvent->target, aTarget);
|
||||
NS_IF_ADDREF(*aTarget = GetTarget());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
EventTarget*
|
||||
nsDOMEvent::GetCurrentTarget() const
|
||||
{
|
||||
return GetDOMEventTarget(mEvent->currentTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)
|
||||
{
|
||||
return GetDOMEventTarget(mEvent->currentTarget, aCurrentTarget);
|
||||
NS_IF_ADDREF(*aCurrentTarget = GetCurrentTarget());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
@ -264,26 +273,37 @@ nsDOMEvent::GetTargetFromFrame()
|
||||
return realEventContent.forget();
|
||||
}
|
||||
|
||||
EventTarget*
|
||||
nsDOMEvent::GetExplicitOriginalTarget() const
|
||||
{
|
||||
if (mExplicitOriginalTarget) {
|
||||
return mExplicitOriginalTarget;
|
||||
}
|
||||
return GetTarget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetExplicitOriginalTarget(nsIDOMEventTarget** aRealEventTarget)
|
||||
{
|
||||
if (mExplicitOriginalTarget) {
|
||||
*aRealEventTarget = mExplicitOriginalTarget;
|
||||
NS_ADDREF(*aRealEventTarget);
|
||||
NS_IF_ADDREF(*aRealEventTarget = GetExplicitOriginalTarget());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return GetTarget(aRealEventTarget);
|
||||
EventTarget*
|
||||
nsDOMEvent::GetOriginalTarget() const
|
||||
{
|
||||
if (mEvent->originalTarget) {
|
||||
return GetDOMEventTarget(mEvent->originalTarget);
|
||||
}
|
||||
|
||||
return GetTarget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)
|
||||
{
|
||||
if (mEvent->originalTarget) {
|
||||
return GetDOMEventTarget(mEvent->originalTarget, aOriginalTarget);
|
||||
}
|
||||
|
||||
return GetTarget(aOriginalTarget);
|
||||
NS_IF_ADDREF(*aOriginalTarget = GetOriginalTarget());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
@ -376,43 +396,50 @@ nsDOMEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetEventPhase(uint16_t* aEventPhase)
|
||||
uint16_t
|
||||
nsDOMEvent::EventPhase() const
|
||||
{
|
||||
// Note, remember to check that this works also
|
||||
// if or when Bug 235441 is fixed.
|
||||
if ((mEvent->currentTarget &&
|
||||
mEvent->currentTarget == mEvent->target) ||
|
||||
mEvent->mFlags.InTargetPhase()) {
|
||||
*aEventPhase = nsIDOMEvent::AT_TARGET;
|
||||
} else if (mEvent->mFlags.mInCapturePhase) {
|
||||
*aEventPhase = nsIDOMEvent::CAPTURING_PHASE;
|
||||
} else if (mEvent->mFlags.mInBubblingPhase) {
|
||||
*aEventPhase = nsIDOMEvent::BUBBLING_PHASE;
|
||||
} else {
|
||||
*aEventPhase = nsIDOMEvent::NONE;
|
||||
return nsIDOMEvent::AT_TARGET;
|
||||
}
|
||||
if (mEvent->mFlags.mInCapturePhase) {
|
||||
return nsIDOMEvent::CAPTURING_PHASE;
|
||||
}
|
||||
if (mEvent->mFlags.mInBubblingPhase) {
|
||||
return nsIDOMEvent::BUBBLING_PHASE;
|
||||
}
|
||||
return nsIDOMEvent::NONE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetEventPhase(uint16_t* aEventPhase)
|
||||
{
|
||||
*aEventPhase = EventPhase();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetBubbles(bool* aBubbles)
|
||||
{
|
||||
*aBubbles = mEvent->mFlags.mBubbles;
|
||||
*aBubbles = Bubbles();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetCancelable(bool* aCancelable)
|
||||
{
|
||||
*aCancelable = mEvent->mFlags.mCancelable;
|
||||
*aCancelable = Cancelable();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetTimeStamp(uint64_t* aTimeStamp)
|
||||
{
|
||||
*aTimeStamp = mEvent->time;
|
||||
*aTimeStamp = TimeStamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -478,7 +505,7 @@ nsDOMEvent::PreventCapture()
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetIsTrusted(bool *aIsTrusted)
|
||||
{
|
||||
*aIsTrusted = mEvent->mFlags.mIsTrusted;
|
||||
*aIsTrusted = IsTrusted();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -489,7 +516,7 @@ nsDOMEvent::PreventDefault()
|
||||
mEvent->mFlags.mDefaultPrevented = true;
|
||||
|
||||
// Need to set an extra flag for drag events.
|
||||
if (mEvent->eventStructType == NS_DRAG_EVENT && mEvent->mFlags.mIsTrusted) {
|
||||
if (mEvent->eventStructType == NS_DRAG_EVENT && IsTrusted()) {
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(mEvent->currentTarget);
|
||||
if (!node) {
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mEvent->currentTarget);
|
||||
@ -520,7 +547,7 @@ nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, bool aCanBubbleArg, bool a
|
||||
// Make sure this event isn't already being dispatched.
|
||||
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
|
||||
|
||||
if (mEvent->mFlags.mIsTrusted) {
|
||||
if (IsTrusted()) {
|
||||
// Ensure the caller is permitted to dispatch trusted DOM events.
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
SetTrusted(false);
|
||||
@ -1207,14 +1234,16 @@ NS_IMETHODIMP
|
||||
nsDOMEvent::GetPreventDefault(bool* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = mEvent && mEvent->mFlags.mDefaultPrevented;
|
||||
*aReturn = GetPreventDefault();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetDefaultPrevented(bool* aReturn)
|
||||
{
|
||||
return GetPreventDefault(aReturn);
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = DefaultPrevented();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
@ -1228,17 +1257,9 @@ nsDOMEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType)
|
||||
GetType(type);
|
||||
IPC::WriteParam(aMsg, type);
|
||||
|
||||
bool bubbles = false;
|
||||
GetBubbles(&bubbles);
|
||||
IPC::WriteParam(aMsg, bubbles);
|
||||
|
||||
bool cancelable = false;
|
||||
GetCancelable(&cancelable);
|
||||
IPC::WriteParam(aMsg, cancelable);
|
||||
|
||||
bool trusted = false;
|
||||
GetIsTrusted(&trusted);
|
||||
IPC::WriteParam(aMsg, trusted);
|
||||
IPC::WriteParam(aMsg, Bubbles());
|
||||
IPC::WriteParam(aMsg, Cancelable());
|
||||
IPC::WriteParam(aMsg, IsTrusted());
|
||||
|
||||
// No timestamp serialization for now!
|
||||
}
|
||||
|
@ -126,28 +126,10 @@ public:
|
||||
// Implemented as xpidl method
|
||||
// void GetType(nsString& aRetval) {}
|
||||
|
||||
already_AddRefed<mozilla::dom::EventTarget> GetTarget()
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> t;
|
||||
GetTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<mozilla::dom::EventTarget> et = do_QueryInterface(t);
|
||||
return et.forget();
|
||||
}
|
||||
mozilla::dom::EventTarget* GetTarget() const;
|
||||
mozilla::dom::EventTarget* GetCurrentTarget() const;
|
||||
|
||||
already_AddRefed<mozilla::dom::EventTarget> GetCurrentTarget()
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> t;
|
||||
GetCurrentTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<mozilla::dom::EventTarget> et = do_QueryInterface(t);
|
||||
return et.forget();
|
||||
}
|
||||
|
||||
uint16_t EventPhase()
|
||||
{
|
||||
uint16_t p;
|
||||
GetEventPhase(&p);
|
||||
return p;
|
||||
}
|
||||
uint16_t EventPhase() const;
|
||||
|
||||
// xpidl implementation
|
||||
// void StopPropagation();
|
||||
@ -155,47 +137,37 @@ public:
|
||||
// xpidl implementation
|
||||
// void StopImmediatePropagation();
|
||||
|
||||
bool Bubbles()
|
||||
bool Bubbles() const
|
||||
{
|
||||
bool b;
|
||||
GetBubbles(&b);
|
||||
return b;
|
||||
return mEvent->mFlags.mBubbles;
|
||||
}
|
||||
|
||||
bool Cancelable()
|
||||
bool Cancelable() const
|
||||
{
|
||||
bool c;
|
||||
GetCancelable(&c);
|
||||
return c;
|
||||
return mEvent->mFlags.mCancelable;
|
||||
}
|
||||
|
||||
// xpidl implementation
|
||||
// void PreventDefault();
|
||||
|
||||
bool DefaultPrevented()
|
||||
bool DefaultPrevented() const
|
||||
{
|
||||
bool d;
|
||||
GetDefaultPrevented(&d);
|
||||
return d;
|
||||
return mEvent && mEvent->mFlags.mDefaultPrevented;
|
||||
}
|
||||
|
||||
bool MultipleActionsPrevented()
|
||||
bool MultipleActionsPrevented() const
|
||||
{
|
||||
return mEvent->mFlags.mMultipleActionsPrevented;
|
||||
}
|
||||
|
||||
bool IsTrusted()
|
||||
bool IsTrusted() const
|
||||
{
|
||||
bool i;
|
||||
GetIsTrusted(&i);
|
||||
return i;
|
||||
return mEvent->mFlags.mIsTrusted;
|
||||
}
|
||||
|
||||
uint64_t TimeStamp()
|
||||
uint64_t TimeStamp() const
|
||||
{
|
||||
uint64_t t;
|
||||
GetTimeStamp(&t);
|
||||
return t;
|
||||
return mEvent->time;
|
||||
}
|
||||
|
||||
void InitEvent(const nsAString& aType, bool aBubbles, bool aCancelable,
|
||||
@ -204,27 +176,12 @@ public:
|
||||
aRv = InitEvent(aType, aBubbles, aCancelable);
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::EventTarget> GetOriginalTarget()
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> t;
|
||||
GetOriginalTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<mozilla::dom::EventTarget> et = do_QueryInterface(t);
|
||||
return et.forget();
|
||||
}
|
||||
mozilla::dom::EventTarget* GetOriginalTarget() const;
|
||||
mozilla::dom::EventTarget* GetExplicitOriginalTarget() const;
|
||||
|
||||
already_AddRefed<mozilla::dom::EventTarget> GetExplicitOriginalTarget()
|
||||
bool GetPreventDefault() const
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> t;
|
||||
GetExplicitOriginalTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<mozilla::dom::EventTarget> et = do_QueryInterface(t);
|
||||
return et.forget();
|
||||
}
|
||||
|
||||
bool GetPreventDefault()
|
||||
{
|
||||
bool d;
|
||||
GetDefaultPrevented(&d);
|
||||
return d;
|
||||
return DefaultPrevented();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -235,7 +192,7 @@ protected:
|
||||
|
||||
nsEvent* mEvent;
|
||||
nsRefPtr<nsPresContext> mPresContext;
|
||||
nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
|
||||
nsCOMPtr<mozilla::dom::EventTarget> mExplicitOriginalTarget;
|
||||
nsCOMPtr<nsPIDOMWindow> mOwner; // nsPIDOMWindow for now.
|
||||
nsString mCachedType;
|
||||
bool mEventIsInternal;
|
||||
|
@ -178,10 +178,10 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMEventTargetHelper,
|
||||
NS_IMETHOD DispatchEvent(nsIDOMEvent *evt, bool *_retval) { \
|
||||
return _to DispatchEvent(evt, _retval); \
|
||||
} \
|
||||
virtual nsIDOMEventTarget * GetTargetForDOMEvent(void) { \
|
||||
virtual mozilla::dom::EventTarget* GetTargetForDOMEvent() { \
|
||||
return _to GetTargetForDOMEvent(); \
|
||||
} \
|
||||
virtual nsIDOMEventTarget * GetTargetForEventTargetChain(void) { \
|
||||
virtual mozilla::dom::EventTarget* GetTargetForEventTargetChain() { \
|
||||
return _to GetTargetForEventTargetChain(); \
|
||||
} \
|
||||
virtual nsresult WillHandleEvent(nsEventChainPostVisitor & aVisitor) { \
|
||||
|
@ -54,33 +54,26 @@ nsDOMNotifyPaintEvent::GetRegion()
|
||||
NS_IMETHODIMP
|
||||
nsDOMNotifyPaintEvent::GetBoundingClientRect(nsIDOMClientRect** aResult)
|
||||
{
|
||||
// Weak ref, since we addref it below
|
||||
nsClientRect* rect = new nsClientRect();
|
||||
if (!rect)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult = rect);
|
||||
if (!mPresContext)
|
||||
return NS_OK;
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect(ToSupports(this));
|
||||
|
||||
if (mPresContext) {
|
||||
rect->SetLayoutRect(GetRegion().GetBounds());
|
||||
}
|
||||
|
||||
rect.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMNotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
{
|
||||
nsRefPtr<nsClientRectList> rectList =
|
||||
new nsClientRectList(static_cast<nsIDOMEvent*>(static_cast<nsDOMEvent*>(this)));
|
||||
if (!rectList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsISupports* parent = ToSupports(this);
|
||||
nsRefPtr<nsClientRectList> rectList = new nsClientRectList(parent);
|
||||
|
||||
nsRegion r = GetRegion();
|
||||
nsRegionRectIterator iter(r);
|
||||
for (const nsRect* rgnRect = iter.Next(); rgnRect; rgnRect = iter.Next()) {
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect();
|
||||
if (!rect)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect(parent);
|
||||
|
||||
rect->SetLayoutRect(*rgnRect);
|
||||
rectList->Append(rect);
|
||||
|
@ -17,6 +17,7 @@ nsDOMScrollAreaEvent::nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext *aPresContext,
|
||||
nsScrollAreaEvent *aEvent)
|
||||
: nsDOMUIEvent(aOwner, aPresContext, aEvent)
|
||||
, mClientArea(nullptr)
|
||||
{
|
||||
mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
|
||||
}
|
||||
@ -42,29 +43,18 @@ NS_INTERFACE_MAP_BEGIN(nsDOMScrollAreaEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScrollAreaEvent::GetX(float *aX)
|
||||
{
|
||||
return mClientArea.GetLeft(aX);
|
||||
#define FORWARD_GETTER(_name) \
|
||||
NS_IMETHODIMP \
|
||||
nsDOMScrollAreaEvent::Get ## _name(float* aResult) \
|
||||
{ \
|
||||
*aResult = _name(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScrollAreaEvent::GetY(float *aY)
|
||||
{
|
||||
return mClientArea.GetTop(aY);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScrollAreaEvent::GetWidth(float *aWidth)
|
||||
{
|
||||
return mClientArea.GetWidth(aWidth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScrollAreaEvent::GetHeight(float *aHeight)
|
||||
{
|
||||
return mClientArea.GetHeight(aHeight);
|
||||
}
|
||||
FORWARD_GETTER(X)
|
||||
FORWARD_GETTER(Y)
|
||||
FORWARD_GETTER(Width)
|
||||
FORWARD_GETTER(Height)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMScrollAreaEvent::InitScrollAreaEvent(const nsAString &aEventType,
|
||||
@ -93,15 +83,10 @@ nsDOMScrollAreaEvent::Serialize(IPC::Message* aMsg,
|
||||
|
||||
nsDOMEvent::Serialize(aMsg, false);
|
||||
|
||||
float val;
|
||||
mClientArea.GetLeft(&val);
|
||||
IPC::WriteParam(aMsg, val);
|
||||
mClientArea.GetTop(&val);
|
||||
IPC::WriteParam(aMsg, val);
|
||||
mClientArea.GetWidth(&val);
|
||||
IPC::WriteParam(aMsg, val);
|
||||
mClientArea.GetHeight(&val);
|
||||
IPC::WriteParam(aMsg, val);
|
||||
IPC::WriteParam(aMsg, X());
|
||||
IPC::WriteParam(aMsg, Y());
|
||||
IPC::WriteParam(aMsg, Width());
|
||||
IPC::WriteParam(aMsg, Height());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
@ -35,6 +35,26 @@ public:
|
||||
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
|
||||
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter);
|
||||
|
||||
float X() const
|
||||
{
|
||||
return mClientArea.Left();
|
||||
}
|
||||
|
||||
float Y() const
|
||||
{
|
||||
return mClientArea.Top();
|
||||
}
|
||||
|
||||
float Width() const
|
||||
{
|
||||
return mClientArea.Width();
|
||||
}
|
||||
|
||||
float Height() const
|
||||
{
|
||||
return mClientArea.Height();
|
||||
}
|
||||
|
||||
protected:
|
||||
nsClientRect mClientArea;
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ nsPaintRequest::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
already_AddRefed<nsClientRect>
|
||||
nsPaintRequest::ClientRect()
|
||||
{
|
||||
nsRefPtr<nsClientRect> clientRect = new nsClientRect();
|
||||
nsRefPtr<nsClientRect> clientRect = new nsClientRect(this);
|
||||
clientRect->SetLayoutRect(mRequest.mRect);
|
||||
return clientRect.forget();
|
||||
}
|
||||
|
@ -12,6 +12,9 @@
|
||||
struct JSContext;
|
||||
class JSObject;
|
||||
class nsINode;
|
||||
class nsString;
|
||||
template<class> class nsTArray;
|
||||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "mozilla/dom/HTMLFieldSetElement.h"
|
||||
#include "mozilla/dom/HTMLFieldSetElementBinding.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)
|
||||
|
@ -168,7 +168,7 @@ HTMLOptionElement::GetIndex(int32_t* aIndex)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsHTMLOptionCollection* options = selectElement->GetOptions();
|
||||
HTMLOptionsCollection* options = selectElement->GetOptions();
|
||||
if (!options) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
416
content/html/content/src/HTMLOptionsCollection.cpp
Normal file
416
content/html/content/src/HTMLOptionsCollection.cpp
Normal file
@ -0,0 +1,416 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/HTMLOptionsCollection.h"
|
||||
|
||||
#include "HTMLOptGroupElement.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
#include "mozilla/dom/HTMLOptionsCollectionBinding.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsFormSubmission.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsHTMLSelectElement.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMHTMLOptGroupElement.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFormProcessor.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "nsRuleData.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
DOMCI_DATA(HTMLOptionsCollection, mozilla::dom::HTMLOptionsCollection)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
HTMLOptionsCollection::HTMLOptionsCollection(nsHTMLSelectElement* aSelect)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
|
||||
// Do not maintain a reference counted reference. When
|
||||
// the select goes away, it will let us know.
|
||||
mSelect = aSelect;
|
||||
}
|
||||
|
||||
HTMLOptionsCollection::~HTMLOptionsCollection()
|
||||
{
|
||||
DropReference();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLOptionsCollection::DropReference()
|
||||
{
|
||||
// Drop our (non ref-counted) reference
|
||||
mSelect = nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLOptionsCollection::GetOptionIndex(Element* aOption,
|
||||
int32_t aStartIndex,
|
||||
bool aForward,
|
||||
int32_t* aIndex)
|
||||
{
|
||||
// NOTE: aIndex shouldn't be set if the returned value isn't NS_OK.
|
||||
|
||||
int32_t index;
|
||||
|
||||
// Make the common case fast
|
||||
if (aStartIndex == 0 && aForward) {
|
||||
index = mElements.IndexOf(aOption);
|
||||
if (index == -1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t high = mElements.Length();
|
||||
int32_t step = aForward ? 1 : -1;
|
||||
|
||||
for (index = aStartIndex; index < high && index > -1; index += step) {
|
||||
if (mElements[index] == aOption) {
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLOptionsCollection)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mElements)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HTMLOptionsCollection)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < tmp->mElements.Length(); ++i) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mElements[i]");
|
||||
cb.NoteXPCOMChild(static_cast<Element*>(tmp->mElements[i]));
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(HTMLOptionsCollection)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
// nsISupports
|
||||
|
||||
// QueryInterface implementation for HTMLOptionsCollection
|
||||
NS_INTERFACE_TABLE_HEAD(HTMLOptionsCollection)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_TABLE3(HTMLOptionsCollection,
|
||||
nsIHTMLCollection,
|
||||
nsIDOMHTMLOptionsCollection,
|
||||
nsIDOMHTMLCollection)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(HTMLOptionsCollection)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLOptionsCollection)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLOptionsCollection)
|
||||
|
||||
|
||||
JSObject*
|
||||
HTMLOptionsCollection::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return HTMLOptionsCollectionBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::GetLength(uint32_t* aLength)
|
||||
{
|
||||
*aLength = mElements.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::SetLength(uint32_t aLength)
|
||||
{
|
||||
if (!mSelect) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return mSelect->SetLength(aLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::SetOption(uint32_t aIndex,
|
||||
nsIDOMHTMLOptionElement* aOption)
|
||||
{
|
||||
if (!mSelect) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if the new option is null, just remove this option. Note that it's safe
|
||||
// to pass a too-large aIndex in here.
|
||||
if (!aOption) {
|
||||
mSelect->Remove(aIndex);
|
||||
|
||||
// We're done.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
uint32_t index = uint32_t(aIndex);
|
||||
|
||||
// Now we're going to be setting an option in our collection
|
||||
if (index > mElements.Length()) {
|
||||
// Fill our array with blank options up to (but not including, since we're
|
||||
// about to change it) aIndex, for compat with other browsers.
|
||||
rv = SetLength(index);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NS_ASSERTION(index <= mElements.Length(), "SetLength lied");
|
||||
|
||||
nsCOMPtr<nsIDOMNode> ret;
|
||||
if (index == mElements.Length()) {
|
||||
rv = mSelect->AppendChild(aOption, getter_AddRefs(ret));
|
||||
} else {
|
||||
// Find the option they're talking about and replace it
|
||||
// hold a strong reference to follow COM rules.
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> refChild = ItemAsOption(index);
|
||||
NS_ENSURE_TRUE(refChild, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
refChild->GetParentNode(getter_AddRefs(parent));
|
||||
if (parent) {
|
||||
rv = parent->ReplaceChild(aOption, refChild, getter_AddRefs(ret));
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t
|
||||
HTMLOptionsCollection::GetSelectedIndex(ErrorResult& aError)
|
||||
{
|
||||
if (!mSelect) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t selectedIndex;
|
||||
aError = mSelect->GetSelectedIndex(&selectedIndex);
|
||||
return selectedIndex;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::GetSelectedIndex(int32_t* aSelectedIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aSelectedIndex = GetSelectedIndex(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mSelect) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
aError = mSelect->SetSelectedIndex(aSelectedIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetSelectedIndex(aSelectedIndex, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsISupports* item = GetElementAt(aIndex);
|
||||
if (!item) {
|
||||
*aReturn = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(item, aReturn);
|
||||
}
|
||||
|
||||
Element*
|
||||
HTMLOptionsCollection::GetElementAt(uint32_t aIndex)
|
||||
{
|
||||
return ItemAsOption(aIndex);
|
||||
}
|
||||
|
||||
static HTMLOptionElement*
|
||||
GetNamedItemHelper(nsTArray<nsRefPtr<HTMLOptionElement> > &aElements,
|
||||
const nsAString& aName)
|
||||
{
|
||||
uint32_t count = aElements.Length();
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
HTMLOptionElement* content = aElements.ElementAt(i);
|
||||
if (content &&
|
||||
(content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
|
||||
eCaseMatters) ||
|
||||
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
|
||||
eCaseMatters))) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsINode*
|
||||
HTMLOptionsCollection::GetParentObject()
|
||||
{
|
||||
return mSelect;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::NamedItem(const nsAString& aName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_IF_ADDREF(*aReturn = GetNamedItemHelper(mElements, aName));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLOptionsCollection::NamedItem(JSContext* cx, const nsAString& name,
|
||||
ErrorResult& error)
|
||||
{
|
||||
nsINode* item = GetNamedItemHelper(mElements, name);
|
||||
if (!item) {
|
||||
return nullptr;
|
||||
}
|
||||
JSObject* wrapper = nsWrapperCache::GetWrapper();
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JS::Value v;
|
||||
if (!mozilla::dom::WrapObject(cx, wrapper, item, item, nullptr, &v)) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
return &v.toObject();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
|
||||
{
|
||||
nsAutoTArray<nsIAtom*, 8> atoms;
|
||||
for (uint32_t i = 0; i < mElements.Length(); ++i) {
|
||||
HTMLOptionElement* content = mElements.ElementAt(i);
|
||||
if (content) {
|
||||
// Note: HasName means the names is exposed on the document,
|
||||
// which is false for options, so we don't check it here.
|
||||
const nsAttrValue* val = content->GetParsedAttr(nsGkAtoms::name);
|
||||
if (val && val->Type() == nsAttrValue::eAtom) {
|
||||
nsIAtom* name = val->GetAtomValue();
|
||||
if (!atoms.Contains(name)) {
|
||||
atoms.AppendElement(name);
|
||||
}
|
||||
}
|
||||
if (content->HasID()) {
|
||||
nsIAtom* id = content->GetID();
|
||||
if (!atoms.Contains(id)) {
|
||||
atoms.AppendElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aNames.SetCapacity(atoms.Length());
|
||||
for (uint32_t i = 0; i < atoms.Length(); ++i) {
|
||||
aNames.AppendElement(nsDependentAtomString(atoms[i]));
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::GetSelect(nsIDOMHTMLSelectElement** aReturn)
|
||||
{
|
||||
NS_IF_ADDREF(*aReturn = mSelect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::Add(nsIDOMHTMLOptionElement* aOption,
|
||||
nsIVariant* aBefore)
|
||||
{
|
||||
if (!aOption) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!mSelect) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return mSelect->Add(aOption, aBefore);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLOptionsCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
|
||||
const Nullable<HTMLElementOrLong>& aBefore,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsGenericHTMLElement& element =
|
||||
aElement.IsHTMLOptionElement() ?
|
||||
static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptionElement()) :
|
||||
static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptGroupElement());
|
||||
|
||||
if (aBefore.IsNull()) {
|
||||
mSelect->Add(element, (nsGenericHTMLElement*)nullptr, aError);
|
||||
} else if (aBefore.Value().IsHTMLElement()) {
|
||||
mSelect->Add(element, &aBefore.Value().GetAsHTMLElement(), aError);
|
||||
} else {
|
||||
mSelect->Add(element, aBefore.Value().GetAsLong(), aError);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLOptionsCollection::Remove(int32_t aIndex, ErrorResult& aError)
|
||||
{
|
||||
if (!mSelect) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t len = 0;
|
||||
mSelect->GetLength(&len);
|
||||
if (aIndex < 0 || (uint32_t)aIndex >= len)
|
||||
aIndex = 0;
|
||||
|
||||
aError = mSelect->Remove(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLOptionsCollection::Remove(int32_t aIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
Remove(aIndex, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
147
content/html/content/src/HTMLOptionsCollection.h
Normal file
147
content/html/content/src/HTMLOptionsCollection.h
Normal file
@ -0,0 +1,147 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef mozilla_dom_HTMLOptionsCollection_h
|
||||
#define mozilla_dom_HTMLOptionsCollection_h
|
||||
|
||||
#include "nsIHTMLCollection.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsError.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsHTMLSelectElement;
|
||||
class nsIDOMHTMLOptionElement;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* The collection of options in the select (what you get back when you do
|
||||
* select.options in DOM)
|
||||
*/
|
||||
class HTMLOptionsCollection : public nsIHTMLCollection
|
||||
, public nsIDOMHTMLOptionsCollection
|
||||
, public nsWrapperCache
|
||||
{
|
||||
typedef HTMLOptionElementOrHTMLOptGroupElement HTMLOptionOrOptGroupElement;
|
||||
public:
|
||||
HTMLOptionsCollection(nsHTMLSelectElement* aSelect);
|
||||
virtual ~HTMLOptionsCollection();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JSObject* scope) MOZ_OVERRIDE;
|
||||
|
||||
// nsIDOMHTMLOptionsCollection interface
|
||||
NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION
|
||||
|
||||
// nsIDOMHTMLCollection interface, all its methods are defined in
|
||||
// nsIDOMHTMLOptionsCollection
|
||||
|
||||
virtual Element* GetElementAt(uint32_t aIndex);
|
||||
virtual nsINode* GetParentObject();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(HTMLOptionsCollection,
|
||||
nsIHTMLCollection)
|
||||
|
||||
// Helpers for nsHTMLSelectElement
|
||||
/**
|
||||
* Insert an option
|
||||
* @param aOption the option to insert
|
||||
* @param aIndex the index to insert at
|
||||
*/
|
||||
void InsertOptionAt(mozilla::dom::HTMLOptionElement* aOption, uint32_t aIndex)
|
||||
{
|
||||
mElements.InsertElementAt(aIndex, aOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an option
|
||||
* @param aIndex the index of the option to remove
|
||||
*/
|
||||
void RemoveOptionAt(uint32_t aIndex)
|
||||
{
|
||||
mElements.RemoveElementAt(aIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the option at the index
|
||||
* @param aIndex the index
|
||||
* @param aReturn the option returned [OUT]
|
||||
*/
|
||||
mozilla::dom::HTMLOptionElement* ItemAsOption(uint32_t aIndex)
|
||||
{
|
||||
return mElements.SafeElementAt(aIndex, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out all options
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
mElements.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an option to end of array
|
||||
*/
|
||||
void AppendOption(mozilla::dom::HTMLOptionElement* aOption)
|
||||
{
|
||||
mElements.AppendElement(aOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the reference to the select. Called during select destruction.
|
||||
*/
|
||||
void DropReference();
|
||||
|
||||
/**
|
||||
* Finds the index of a given option element.
|
||||
* If the option isn't part of the collection, return NS_ERROR_FAILURE
|
||||
* without setting aIndex.
|
||||
*
|
||||
* @param aOption the option to get the index of
|
||||
* @param aStartIndex the index to start looking at
|
||||
* @param aForward TRUE to look forward, FALSE to look backward
|
||||
* @return the option index
|
||||
*/
|
||||
nsresult GetOptionIndex(Element* aOption,
|
||||
int32_t aStartIndex, bool aForward,
|
||||
int32_t* aIndex);
|
||||
|
||||
virtual JSObject* NamedItem(JSContext* aCx, const nsAString& aName,
|
||||
ErrorResult& error);
|
||||
|
||||
void Add(const HTMLOptionOrOptGroupElement& aElement,
|
||||
const Nullable<HTMLElementOrLong>& aBefore,
|
||||
ErrorResult& aError);
|
||||
void Remove(int32_t aIndex, ErrorResult& aError);
|
||||
int32_t GetSelectedIndex(ErrorResult& aError);
|
||||
void SetSelectedIndex(int32_t aSelectedIndex, ErrorResult& aError);
|
||||
void IndexedSetter(uint32_t aIndex, nsIDOMHTMLOptionElement* aOption,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
aError = SetOption(aIndex, aOption);
|
||||
}
|
||||
virtual void GetSupportedNames(nsTArray<nsString>& aNames);
|
||||
|
||||
private:
|
||||
/** The list of options (holds strong references). This is infallible, so
|
||||
* various members such as InsertOptionAt are also infallible. */
|
||||
nsTArray<nsRefPtr<mozilla::dom::HTMLOptionElement> > mElements;
|
||||
/** The select element that contains this array */
|
||||
nsHTMLSelectElement* mSelect;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_HTMLOptionsCollection_h
|
@ -56,6 +56,7 @@ EXPORTS_mozilla/dom = \
|
||||
HTMLModElement.h \
|
||||
HTMLObjectElement.h \
|
||||
HTMLOptionElement.h \
|
||||
HTMLOptionsCollection.h \
|
||||
HTMLOptGroupElement.h \
|
||||
HTMLOutputElement.h \
|
||||
HTMLParagraphElement.h \
|
||||
@ -122,6 +123,7 @@ CPPSRCS = \
|
||||
HTMLObjectElement.cpp \
|
||||
nsHTMLSharedObjectElement.cpp \
|
||||
HTMLOptionElement.cpp \
|
||||
HTMLOptionsCollection.cpp \
|
||||
HTMLOptGroupElement.cpp \
|
||||
HTMLOutputElement.cpp \
|
||||
HTMLParagraphElement.cpp \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -9,66 +9,45 @@
|
||||
|
||||
#include "nsPresContext.h"
|
||||
#include "mozilla/dom/ClientRectListBinding.h"
|
||||
#include "mozilla/dom/ClientRectBinding.h"
|
||||
|
||||
DOMCI_DATA(ClientRect, nsClientRect)
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsClientRect)
|
||||
NS_INTERFACE_TABLE1(nsClientRect, nsIDOMClientRect)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ClientRect)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsClientRect, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsClientRect)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsClientRect)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsClientRect)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMClientRect)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(nsClientRect)
|
||||
NS_IMPL_RELEASE(nsClientRect)
|
||||
|
||||
nsClientRect::nsClientRect()
|
||||
: mX(0.0), mY(0.0), mWidth(0.0), mHeight(0.0)
|
||||
{
|
||||
#define FORWARD_GETTER(_name) \
|
||||
NS_IMETHODIMP \
|
||||
nsClientRect::Get ## _name(float* aResult) \
|
||||
{ \
|
||||
*aResult = _name(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClientRect::GetLeft(float* aResult)
|
||||
FORWARD_GETTER(Left)
|
||||
FORWARD_GETTER(Top)
|
||||
FORWARD_GETTER(Right)
|
||||
FORWARD_GETTER(Bottom)
|
||||
FORWARD_GETTER(Width)
|
||||
FORWARD_GETTER(Height)
|
||||
|
||||
JSObject*
|
||||
nsClientRect::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
*aResult = mX;
|
||||
return NS_OK;
|
||||
MOZ_ASSERT(mParent);
|
||||
return ClientRectBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClientRect::GetTop(float* aResult)
|
||||
{
|
||||
*aResult = mY;
|
||||
return NS_OK;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClientRect::GetRight(float* aResult)
|
||||
{
|
||||
*aResult = mX + mWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClientRect::GetBottom(float* aResult)
|
||||
{
|
||||
*aResult = mY + mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClientRect::GetWidth(float* aResult)
|
||||
{
|
||||
*aResult = mWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClientRect::GetHeight(float* aResult)
|
||||
{
|
||||
*aResult = mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsClientRectList, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsClientRectList, mParent, mArray)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsClientRectList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -8,28 +8,78 @@
|
||||
|
||||
#include "nsIDOMClientRect.h"
|
||||
#include "nsIDOMClientRectList.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsClientRect : public nsIDOMClientRect
|
||||
class nsClientRect MOZ_FINAL : public nsIDOMClientRect
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsClientRect();
|
||||
void SetRect(float aX, float aY, float aWidth, float aHeight) {
|
||||
mX = aX; mY = aY; mWidth = aWidth; mHeight = aHeight;
|
||||
nsClientRect(nsISupports* aParent)
|
||||
: mParent(aParent), mX(0.0), mY(0.0), mWidth(0.0), mHeight(0.0)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
virtual ~nsClientRect() {}
|
||||
|
||||
NS_DECL_NSIDOMCLIENTRECT
|
||||
|
||||
void SetRect(float aX, float aY, float aWidth, float aHeight) {
|
||||
mX = aX; mY = aY; mWidth = aWidth; mHeight = aHeight;
|
||||
}
|
||||
void SetLayoutRect(const nsRect& aLayoutRect);
|
||||
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsClientRect)
|
||||
NS_DECL_NSIDOMCLIENTRECT
|
||||
|
||||
|
||||
nsISupports* GetParentObject() const
|
||||
{
|
||||
MOZ_ASSERT(mParent);
|
||||
return mParent;
|
||||
}
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
|
||||
float Left() const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
float Top() const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
float Right() const
|
||||
{
|
||||
return mX + mWidth;
|
||||
}
|
||||
|
||||
float Bottom() const
|
||||
{
|
||||
return mY + mHeight;
|
||||
}
|
||||
|
||||
float Width() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
float Height() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
float mX, mY, mWidth, mHeight;
|
||||
};
|
||||
|
||||
@ -54,7 +104,7 @@ public:
|
||||
return mParent;
|
||||
}
|
||||
|
||||
void Append(nsIDOMClientRect* aElement) { mArray.AppendObject(aElement); }
|
||||
void Append(nsClientRect* aElement) { mArray.AppendElement(aElement); }
|
||||
|
||||
static nsClientRectList* FromSupports(nsISupports* aSupports)
|
||||
{
|
||||
@ -75,22 +125,25 @@ public:
|
||||
|
||||
uint32_t Length()
|
||||
{
|
||||
return mArray.Count();
|
||||
return mArray.Length();
|
||||
}
|
||||
nsIDOMClientRect* Item(uint32_t aIndex)
|
||||
nsClientRect* Item(uint32_t aIndex)
|
||||
{
|
||||
return mArray.SafeObjectAt(aIndex);
|
||||
return mArray.SafeElementAt(aIndex);
|
||||
}
|
||||
nsIDOMClientRect* IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
nsClientRect* IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
aFound = aIndex < static_cast<uint32_t>(mArray.Count());
|
||||
return aFound ? mArray.ObjectAt(aIndex) : nullptr;
|
||||
aFound = aIndex < mArray.Length();
|
||||
if (!aFound) {
|
||||
return nullptr;
|
||||
}
|
||||
return mArray[aIndex];
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~nsClientRectList() {}
|
||||
|
||||
nsCOMArray<nsIDOMClientRect> mArray;
|
||||
nsTArray< nsRefPtr<nsClientRect> > mArray;
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
};
|
||||
|
||||
|
@ -3,39 +3,35 @@
|
||||
* 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/Util.h"
|
||||
|
||||
#include "nsHTMLSelectElement.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsFormSubmission.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMHTMLOptGroupElement.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFormProcessor.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsFormSubmission.h"
|
||||
#include "nsIFormProcessor.h"
|
||||
|
||||
#include "nsIDOMHTMLOptGroupElement.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
// Notify/query select frame for selectedIndex
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
#include "nsError.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsPresState.h"
|
||||
#include "nsRuleData.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/dom/HTMLOptionsCollectionBinding.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -106,7 +102,7 @@ NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Select)
|
||||
nsHTMLSelectElement::nsHTMLSelectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
FromParser aFromParser)
|
||||
: nsGenericHTMLFormElement(aNodeInfo),
|
||||
mOptions(new nsHTMLOptionCollection(this)),
|
||||
mOptions(new HTMLOptionsCollection(this)),
|
||||
mIsDoneAddingChildren(!aFromParser),
|
||||
mDisabledChanged(false),
|
||||
mMutating(false),
|
||||
@ -143,7 +139,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLSelectElement,
|
||||
nsGenericHTMLFormElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHTMLSelectElement, Element)
|
||||
NS_IMPL_RELEASE_INHERITED(nsHTMLSelectElement, Element)
|
||||
@ -1811,7 +1807,7 @@ nsHTMLSelectElement::DispatchContentReset()
|
||||
}
|
||||
|
||||
static void
|
||||
AddOptionsRecurse(nsIContent* aRoot, nsHTMLOptionCollection* aArray)
|
||||
AddOptionsRecurse(nsIContent* aRoot, HTMLOptionsCollection* aArray)
|
||||
{
|
||||
for (nsIContent* cur = aRoot->GetFirstChild();
|
||||
cur;
|
||||
@ -1897,7 +1893,7 @@ nsHTMLSelectElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
|
||||
static void
|
||||
VerifyOptionsRecurse(nsIContent* aRoot, int32_t& aIndex,
|
||||
nsHTMLOptionCollection* aArray)
|
||||
HTMLOptionsCollection* aArray)
|
||||
{
|
||||
for (nsIContent* cur = aRoot->GetFirstChild();
|
||||
cur;
|
||||
@ -1921,365 +1917,6 @@ nsHTMLSelectElement::VerifyOptionsArray()
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsHTMLOptionCollection implementation
|
||||
//
|
||||
|
||||
nsHTMLOptionCollection::nsHTMLOptionCollection(nsHTMLSelectElement* aSelect)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
|
||||
// Do not maintain a reference counted reference. When
|
||||
// the select goes away, it will let us know.
|
||||
mSelect = aSelect;
|
||||
}
|
||||
|
||||
nsHTMLOptionCollection::~nsHTMLOptionCollection()
|
||||
{
|
||||
DropReference();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLOptionCollection::DropReference()
|
||||
{
|
||||
// Drop our (non ref-counted) reference
|
||||
mSelect = nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLOptionCollection::GetOptionIndex(mozilla::dom::Element* aOption,
|
||||
int32_t aStartIndex,
|
||||
bool aForward,
|
||||
int32_t* aIndex)
|
||||
{
|
||||
// NOTE: aIndex shouldn't be set if the returned value isn't NS_OK.
|
||||
|
||||
int32_t index;
|
||||
|
||||
// Make the common case fast
|
||||
if (aStartIndex == 0 && aForward) {
|
||||
index = mElements.IndexOf(aOption);
|
||||
if (index == -1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t high = mElements.Length();
|
||||
int32_t step = aForward ? 1 : -1;
|
||||
|
||||
for (index = aStartIndex; index < high && index > -1; index += step) {
|
||||
if (mElements[index] == aOption) {
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHTMLOptionCollection)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mElements)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHTMLOptionCollection)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < tmp->mElements.Length(); ++i) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mElements[i]");
|
||||
cb.NoteXPCOMChild(static_cast<Element*>(tmp->mElements[i]));
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsHTMLOptionCollection)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
// nsISupports
|
||||
|
||||
// QueryInterface implementation for nsHTMLOptionCollection
|
||||
NS_INTERFACE_TABLE_HEAD(nsHTMLOptionCollection)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_TABLE3(nsHTMLOptionCollection,
|
||||
nsIHTMLCollection,
|
||||
nsIDOMHTMLOptionsCollection,
|
||||
nsIDOMHTMLCollection)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsHTMLOptionCollection)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHTMLOptionCollection)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHTMLOptionCollection)
|
||||
|
||||
|
||||
JSObject*
|
||||
nsHTMLOptionCollection::WrapObject(JSContext* cx, JSObject* scope)
|
||||
{
|
||||
return HTMLOptionsCollectionBinding::Wrap(cx, scope, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::GetLength(uint32_t* aLength)
|
||||
{
|
||||
*aLength = mElements.Length();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::SetLength(uint32_t aLength)
|
||||
{
|
||||
if (!mSelect) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return mSelect->SetLength(aLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::SetOption(uint32_t aIndex,
|
||||
nsIDOMHTMLOptionElement* aOption)
|
||||
{
|
||||
if (!mSelect) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if the new option is null, just remove this option. Note that it's safe
|
||||
// to pass a too-large aIndex in here.
|
||||
if (!aOption) {
|
||||
mSelect->Remove(aIndex);
|
||||
|
||||
// We're done.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
uint32_t index = uint32_t(aIndex);
|
||||
|
||||
// Now we're going to be setting an option in our collection
|
||||
if (index > mElements.Length()) {
|
||||
// Fill our array with blank options up to (but not including, since we're
|
||||
// about to change it) aIndex, for compat with other browsers.
|
||||
rv = SetLength(index);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NS_ASSERTION(index <= mElements.Length(), "SetLength lied");
|
||||
|
||||
nsCOMPtr<nsIDOMNode> ret;
|
||||
if (index == mElements.Length()) {
|
||||
rv = mSelect->AppendChild(aOption, getter_AddRefs(ret));
|
||||
} else {
|
||||
// Find the option they're talking about and replace it
|
||||
// hold a strong reference to follow COM rules.
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> refChild = ItemAsOption(index);
|
||||
NS_ENSURE_TRUE(refChild, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
refChild->GetParentNode(getter_AddRefs(parent));
|
||||
if (parent) {
|
||||
rv = parent->ReplaceChild(aOption, refChild, getter_AddRefs(ret));
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsHTMLOptionCollection::GetSelectedIndex(ErrorResult& aError)
|
||||
{
|
||||
if (!mSelect) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t selectedIndex;
|
||||
aError = mSelect->GetSelectedIndex(&selectedIndex);
|
||||
return selectedIndex;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::GetSelectedIndex(int32_t* aSelectedIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aSelectedIndex = GetSelectedIndex(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLOptionCollection::SetSelectedIndex(int32_t aSelectedIndex,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mSelect) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
aError = mSelect->SetSelectedIndex(aSelectedIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::SetSelectedIndex(int32_t aSelectedIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
SetSelectedIndex(aSelectedIndex, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsISupports* item = GetElementAt(aIndex);
|
||||
if (!item) {
|
||||
*aReturn = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(item, aReturn);
|
||||
}
|
||||
|
||||
Element*
|
||||
nsHTMLOptionCollection::GetElementAt(uint32_t aIndex)
|
||||
{
|
||||
return ItemAsOption(aIndex);
|
||||
}
|
||||
|
||||
static HTMLOptionElement*
|
||||
GetNamedItemHelper(nsTArray<nsRefPtr<HTMLOptionElement> > &aElements,
|
||||
const nsAString& aName)
|
||||
{
|
||||
uint32_t count = aElements.Length();
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
HTMLOptionElement* content = aElements.ElementAt(i);
|
||||
if (content &&
|
||||
(content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
|
||||
eCaseMatters) ||
|
||||
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
|
||||
eCaseMatters))) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsINode*
|
||||
nsHTMLOptionCollection::GetParentObject()
|
||||
{
|
||||
return mSelect;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::NamedItem(const nsAString& aName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_IF_ADDREF(*aReturn = GetNamedItemHelper(mElements, aName));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
nsHTMLOptionCollection::NamedItem(JSContext* cx, const nsAString& name,
|
||||
ErrorResult& error)
|
||||
{
|
||||
nsINode* item = GetNamedItemHelper(mElements, name);
|
||||
if (!item) {
|
||||
return nullptr;
|
||||
}
|
||||
JSObject* wrapper = nsWrapperCache::GetWrapper();
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JS::Value v;
|
||||
if (!mozilla::dom::WrapObject(cx, wrapper, item, item, nullptr, &v)) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
return &v.toObject();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLOptionCollection::GetSupportedNames(nsTArray<nsString>& aNames)
|
||||
{
|
||||
nsAutoTArray<nsIAtom*, 8> atoms;
|
||||
for (uint32_t i = 0; i < mElements.Length(); ++i) {
|
||||
HTMLOptionElement* content = mElements.ElementAt(i);
|
||||
if (content) {
|
||||
// Note: HasName means the names is exposed on the document,
|
||||
// which is false for options, so we don't check it here.
|
||||
const nsAttrValue* val = content->GetParsedAttr(nsGkAtoms::name);
|
||||
if (val && val->Type() == nsAttrValue::eAtom) {
|
||||
nsIAtom* name = val->GetAtomValue();
|
||||
if (!atoms.Contains(name)) {
|
||||
atoms.AppendElement(name);
|
||||
}
|
||||
}
|
||||
if (content->HasID()) {
|
||||
nsIAtom* id = content->GetID();
|
||||
if (!atoms.Contains(id)) {
|
||||
atoms.AppendElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aNames.SetCapacity(atoms.Length());
|
||||
for (uint32_t i = 0; i < atoms.Length(); ++i) {
|
||||
aNames.AppendElement(nsDependentAtomString(atoms[i]));
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::GetSelect(nsIDOMHTMLSelectElement** aReturn)
|
||||
{
|
||||
NS_IF_ADDREF(*aReturn = mSelect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::Add(nsIDOMHTMLOptionElement* aOption,
|
||||
nsIVariant* aBefore)
|
||||
{
|
||||
if (!aOption) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!mSelect) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return mSelect->Add(aOption, aBefore);
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLOptionCollection::Remove(int32_t aIndex, ErrorResult& aError)
|
||||
{
|
||||
if (!mSelect) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t len = 0;
|
||||
mSelect->GetLength(&len);
|
||||
if (aIndex < 0 || (uint32_t)aIndex >= len)
|
||||
aIndex = 0;
|
||||
|
||||
aError = mSelect->Remove(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollection::Remove(int32_t aIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
Remove(aIndex, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLSelectElement::UpdateBarredFromConstraintValidation()
|
||||
{
|
||||
|
@ -5,150 +5,21 @@
|
||||
#ifndef nsHTMLSelectElement_h___
|
||||
#define nsHTMLSelectElement_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIHTMLCollection.h"
|
||||
#include "nsIConstraintValidation.h"
|
||||
#include "mozilla/dom/HTMLOptGroupElement.h"
|
||||
|
||||
// PresState
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsPresState.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCheapSets.h"
|
||||
#include "nsError.h"
|
||||
#include "HTMLOptGroupElement.h"
|
||||
#include "mozilla/dom/HTMLOptionElement.h"
|
||||
#include "nsHTMLFormElement.h"
|
||||
#include "mozilla/dom/HTMLOptionsCollection.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsCheapSets.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsError.h"
|
||||
#include "nsHTMLFormElement.h"
|
||||
|
||||
class nsHTMLSelectElement;
|
||||
|
||||
/**
|
||||
* The collection of options in the select (what you get back when you do
|
||||
* select.options in DOM)
|
||||
*/
|
||||
class nsHTMLOptionCollection: public nsIHTMLCollection,
|
||||
public nsIDOMHTMLOptionsCollection,
|
||||
public nsWrapperCache
|
||||
{
|
||||
typedef mozilla::dom::HTMLOptionElementOrHTMLOptGroupElement HTMLOptionOrOptGroupElement;
|
||||
typedef mozilla::dom::HTMLElementOrLong HTMLElementOrLong;
|
||||
public:
|
||||
nsHTMLOptionCollection(nsHTMLSelectElement* aSelect);
|
||||
virtual ~nsHTMLOptionCollection();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JSObject* scope) MOZ_OVERRIDE;
|
||||
|
||||
// nsIDOMHTMLOptionsCollection interface
|
||||
NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION
|
||||
|
||||
// nsIDOMHTMLCollection interface, all its methods are defined in
|
||||
// nsIDOMHTMLOptionsCollection
|
||||
|
||||
virtual mozilla::dom::Element* GetElementAt(uint32_t aIndex);
|
||||
virtual nsINode* GetParentObject();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsHTMLOptionCollection,
|
||||
nsIHTMLCollection)
|
||||
|
||||
// Helpers for nsHTMLSelectElement
|
||||
/**
|
||||
* Insert an option
|
||||
* @param aOption the option to insert
|
||||
* @param aIndex the index to insert at
|
||||
*/
|
||||
void InsertOptionAt(mozilla::dom::HTMLOptionElement* aOption, uint32_t aIndex)
|
||||
{
|
||||
mElements.InsertElementAt(aIndex, aOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an option
|
||||
* @param aIndex the index of the option to remove
|
||||
*/
|
||||
void RemoveOptionAt(uint32_t aIndex)
|
||||
{
|
||||
mElements.RemoveElementAt(aIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the option at the index
|
||||
* @param aIndex the index
|
||||
* @param aReturn the option returned [OUT]
|
||||
*/
|
||||
mozilla::dom::HTMLOptionElement* ItemAsOption(uint32_t aIndex)
|
||||
{
|
||||
return mElements.SafeElementAt(aIndex, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out all options
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
mElements.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an option to end of array
|
||||
*/
|
||||
void AppendOption(mozilla::dom::HTMLOptionElement* aOption)
|
||||
{
|
||||
mElements.AppendElement(aOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the reference to the select. Called during select destruction.
|
||||
*/
|
||||
void DropReference();
|
||||
|
||||
/**
|
||||
* Finds the index of a given option element.
|
||||
* If the option isn't part of the collection, return NS_ERROR_FAILURE
|
||||
* without setting aIndex.
|
||||
*
|
||||
* @param aOption the option to get the index of
|
||||
* @param aStartIndex the index to start looking at
|
||||
* @param aForward TRUE to look forward, FALSE to look backward
|
||||
* @return the option index
|
||||
*/
|
||||
nsresult GetOptionIndex(mozilla::dom::Element* aOption,
|
||||
int32_t aStartIndex, bool aForward,
|
||||
int32_t* aIndex);
|
||||
|
||||
virtual JSObject* NamedItem(JSContext* aCx, const nsAString& aName,
|
||||
mozilla::ErrorResult& error);
|
||||
|
||||
inline void Add(const HTMLOptionOrOptGroupElement& aElement,
|
||||
const Nullable<HTMLElementOrLong>& aBefore,
|
||||
mozilla::ErrorResult& aError);
|
||||
void Remove(int32_t aIndex, mozilla::ErrorResult& aError);
|
||||
int32_t GetSelectedIndex(mozilla::ErrorResult& aError);
|
||||
void SetSelectedIndex(int32_t aSelectedIndex, mozilla::ErrorResult& aError);
|
||||
void IndexedSetter(uint32_t aIndex, nsIDOMHTMLOptionElement* aOption,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
aError = SetOption(aIndex, aOption);
|
||||
}
|
||||
virtual void GetSupportedNames(nsTArray<nsString>& aNames);
|
||||
|
||||
private:
|
||||
/** The list of options (holds strong references). This is infallible, so
|
||||
* various members such as InsertOptionAt are also infallible. */
|
||||
nsTArray<nsRefPtr<mozilla::dom::HTMLOptionElement> > mElements;
|
||||
/** The select element that contains this array */
|
||||
nsHTMLSelectElement* mSelect;
|
||||
};
|
||||
class nsIDOMHTMLOptionElement;
|
||||
class nsISelectControlFrame;
|
||||
class nsPresState;
|
||||
|
||||
#define NS_SELECT_STATE_IID \
|
||||
{ /* 4db54c7c-d159-455f-9d8e-f60ee466dbf3 */ \
|
||||
@ -230,6 +101,7 @@ class nsHTMLSelectElement : public nsGenericHTMLFormElement,
|
||||
public nsIConstraintValidation
|
||||
{
|
||||
public:
|
||||
typedef mozilla::dom::HTMLOptionsCollection HTMLOptionsCollection;
|
||||
using nsIConstraintValidation::GetValidationMessage;
|
||||
|
||||
nsHTMLSelectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
@ -300,7 +172,7 @@ public:
|
||||
{
|
||||
SetHTMLBoolAttr(nsGkAtoms::required, aVal, aRv);
|
||||
}
|
||||
nsHTMLOptionCollection* Options() const
|
||||
HTMLOptionsCollection* Options() const
|
||||
{
|
||||
return mOptions;
|
||||
}
|
||||
@ -454,7 +326,7 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLSelectElement,
|
||||
nsGenericHTMLFormElement)
|
||||
|
||||
nsHTMLOptionCollection* GetOptions()
|
||||
HTMLOptionsCollection* GetOptions()
|
||||
{
|
||||
return mOptions;
|
||||
}
|
||||
@ -681,7 +553,7 @@ protected:
|
||||
}
|
||||
|
||||
/** The options[] array */
|
||||
nsRefPtr<nsHTMLOptionCollection> mOptions;
|
||||
nsRefPtr<HTMLOptionsCollection> mOptions;
|
||||
/** false if the parser is in the middle of adding children. */
|
||||
bool mIsDoneAddingChildren;
|
||||
/** true if our disabled state has changed from the default **/
|
||||
@ -727,23 +599,4 @@ protected:
|
||||
nsCOMPtr<nsSelectState> mRestoreState;
|
||||
};
|
||||
|
||||
void
|
||||
nsHTMLOptionCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
|
||||
const Nullable<HTMLElementOrLong>& aBefore,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
nsGenericHTMLElement& element =
|
||||
aElement.IsHTMLOptionElement() ?
|
||||
static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptionElement()) :
|
||||
static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptGroupElement());
|
||||
|
||||
if (aBefore.IsNull()) {
|
||||
mSelect->Add(element, (nsGenericHTMLElement*)nullptr, aError);
|
||||
} else if (aBefore.Value().IsHTMLElement()) {
|
||||
mSelect->Add(element, &aBefore.Value().GetAsHTMLElement(), aError);
|
||||
} else {
|
||||
mSelect->Add(element, aBefore.Value().GetAsLong(), aError);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "nsCharsetSource.h" // kCharsetFrom* macro definition
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocElementCreatedNotificationRunner.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -937,15 +937,19 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
|
||||
//
|
||||
// nsIDOMHTMLDocument interface implementation
|
||||
//
|
||||
void
|
||||
nsHTMLDocument::GetDomainURI(nsIURI **aURI)
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLDocument::GetDomainURI()
|
||||
{
|
||||
nsIPrincipal* principal = NodePrincipal();
|
||||
|
||||
principal->GetDomain(aURI);
|
||||
if (!*aURI) {
|
||||
principal->GetURI(aURI);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
principal->GetDomain(getter_AddRefs(uri));
|
||||
if (uri) {
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
principal->GetURI(getter_AddRefs(uri));
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
|
||||
@ -960,8 +964,7 @@ nsHTMLDocument::GetDomain(nsAString& aDomain)
|
||||
void
|
||||
nsHTMLDocument::GetDomain(nsAString& aDomain, ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetDomainURI(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetDomainURI();
|
||||
|
||||
if (!uri) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
@ -996,8 +999,7 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain, ErrorResult& rv)
|
||||
}
|
||||
|
||||
// Create new URI
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetDomainURI(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetDomainURI();
|
||||
|
||||
if (!uri) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -268,7 +268,7 @@ protected:
|
||||
|
||||
static void DocumentWriteTerminationFunc(nsISupports *aRef);
|
||||
|
||||
void GetDomainURI(nsIURI **uri);
|
||||
already_AddRefed<nsIURI> GetDomainURI();
|
||||
|
||||
nsresult WriteCommon(JSContext *cx, const nsAString& aText,
|
||||
bool aNewlineTerminate);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "AudioSegment.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "AudioContext.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "AudioDestinationNode.h"
|
||||
@ -59,10 +60,9 @@ AudioContext::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AudioContext* object = new AudioContext(window);
|
||||
NS_ADDREF(object);
|
||||
nsRefPtr<AudioContext> object = new AudioContext(window);
|
||||
window->AddAudioContext(object);
|
||||
return object;
|
||||
return object.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<AudioBufferSourceNode>
|
||||
|
@ -12,22 +12,22 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIThreadPool.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include <utility>
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
namespace mozilla {
|
||||
|
||||
class MediaDecoderReader;
|
||||
namespace dom
|
||||
{
|
||||
namespace dom {
|
||||
class AudioBuffer;
|
||||
class AudioContext;
|
||||
class DecodeErrorCallback;
|
||||
class DecodeSuccessCallback;
|
||||
}
|
||||
|
||||
struct WebAudioDecodeJob {
|
||||
struct WebAudioDecodeJob
|
||||
{
|
||||
WebAudioDecodeJob(const nsACString& aContentType,
|
||||
const dom::ArrayBuffer& aBuffer,
|
||||
dom::AudioContext* aContext,
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "nsString.h"
|
||||
#include "nsXBLProtoImplMember.h"
|
||||
|
||||
class nsIObjectInputStream;
|
||||
class nsIObjectOutputStream;
|
||||
class nsIURI;
|
||||
|
||||
class nsXBLProtoImplField
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIObjectOutputStream;
|
||||
class nsIScriptContext;
|
||||
|
||||
struct nsXBLTextWithLineNumber
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "xptcall.h"
|
||||
#include "txXPathObjectAdaptor.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIClassInfo.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(txXPathObjectAdaptor, txIXPathObject)
|
||||
|
||||
|
@ -12,25 +12,28 @@
|
||||
* see http://developer.mozilla.org/en/docs/XUL
|
||||
*/
|
||||
|
||||
#include "nsXULContentSink.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsXULContentSink.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsForwardReference.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptRuntime.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptRuntime.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsParserBase.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define nsXULControllers_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
XPIDL_SOURCES += [
|
||||
'nsIActivityProxy.idl',
|
||||
'nsIActivityUIGlue.idl',
|
||||
'nsIDOMActivity.idl',
|
||||
'nsIDOMActivityHandlerDescription.idl',
|
||||
'nsIDOMActivityOptions.idl',
|
||||
'nsIDOMActivityRequestHandler.idl',
|
||||
|
@ -4,17 +4,16 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMMozActivity;
|
||||
interface nsIDOMMozActivityOptions;
|
||||
interface nsIDOMWindow;
|
||||
|
||||
/**
|
||||
* Implemented by @mozilla.org/dom/activities/proxy;1
|
||||
*/
|
||||
[scriptable, uuid(3f9e0695-f466-4111-a8fa-ed5c0751c42b)]
|
||||
[scriptable, uuid(c7a258f7-26a6-46c6-a887-a6c936034f98)]
|
||||
interface nsIActivityProxy : nsISupports
|
||||
{
|
||||
void startActivity(in nsIDOMMozActivity activity,
|
||||
void startActivity(in nsISupports /* MozActivity */ activity,
|
||||
in nsIDOMMozActivityOptions options,
|
||||
in nsIDOMWindow window);
|
||||
void cleanup();
|
||||
|
@ -1,14 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsIDOMDOMRequest.idl"
|
||||
|
||||
/**
|
||||
* The constructor will accept a nsIDOMActivityOptions parameter.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(1f59cd9a-b8b5-4a98-bd2a-897b73584946)]
|
||||
interface nsIDOMMozActivity : nsIDOMDOMRequest
|
||||
{
|
||||
};
|
@ -3,24 +3,17 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Activity.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
#include "mozilla/dom/MozActivityBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMActivityOptions.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#ifdef MOZ_SYS_MSG
|
||||
DOMCI_DATA(MozActivity, Activity)
|
||||
#endif
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Activity)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozActivity)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
#ifdef MOZ_SYS_MSG
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozActivity)
|
||||
#endif
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(Activity, DOMRequest)
|
||||
@ -32,19 +25,24 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED_1(Activity, DOMRequest,
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(Activity, DOMRequest)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
Activity::Initialize(nsISupports* aOwner,
|
||||
JSContext* aContext,
|
||||
JSObject* aObject,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv)
|
||||
/* virtual */ JSObject*
|
||||
Activity::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return MozActivityBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsresult
|
||||
Activity::Initialize(nsISupports* aOwner,
|
||||
nsIDOMMozActivityOptions* aOptions)
|
||||
{
|
||||
MOZ_ASSERT(aOptions);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aOwner);
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
|
||||
|
||||
Init(window);
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(window->GetExtantDoc());
|
||||
nsCOMPtr<nsIDocument> document = window->GetExtantDoc();
|
||||
|
||||
bool isActive;
|
||||
window->GetDocShell()->GetIsActive(&isActive);
|
||||
@ -67,27 +65,13 @@ Activity::Initialize(nsISupports* aOwner,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We expect a single argument, which is a nsIDOMMozActivityOptions.
|
||||
if (aArgc != 1 || !aArgv[0].isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> tmp;
|
||||
nsContentUtils::XPConnect()->WrapJS(aContext, aArgv[0].toObjectOrNull(),
|
||||
NS_GET_IID(nsIDOMMozActivityOptions),
|
||||
getter_AddRefs(tmp));
|
||||
nsCOMPtr<nsIDOMMozActivityOptions> options = do_QueryInterface(tmp);
|
||||
if (!options) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Instantiate a JS proxy that will do the child <-> parent communication
|
||||
// with the JS implementation of the backend.
|
||||
nsresult rv;
|
||||
mProxy = do_CreateInstance("@mozilla.org/dom/activities/proxy;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mProxy->StartActivity(this, options, window);
|
||||
mProxy->StartActivity(static_cast<nsIDOMDOMRequest*>(this), aOptions, window);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -104,5 +88,6 @@ Activity::Activity()
|
||||
// Unfortunately we must explicitly declare the default constructor in order
|
||||
// to prevent an implicitly deleted constructor in DOMRequest compile error
|
||||
// in GCC 4.6.
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,9 @@
|
||||
#ifndef mozilla_dom_activities_Activity_h
|
||||
#define mozilla_dom_activities_Activity_h
|
||||
|
||||
#include "nsIDOMActivity.h"
|
||||
#include "nsIActivityProxy.h"
|
||||
#include "DOMRequest.h"
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsIActivityProxy.h"
|
||||
|
||||
#define NS_DOMACTIVITY_CID \
|
||||
{0x1c5b0930, 0xc90c, 0x4e9c, {0xaf, 0x4e, 0xb0, 0xb7, 0xa6, 0x59, 0xb4, 0xed}}
|
||||
@ -18,24 +17,40 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Activity : public nsIDOMMozActivity
|
||||
, public nsIJSNativeInitializer // In order to get a window for the DOMRequest
|
||||
, public DOMRequest
|
||||
class Activity : public DOMRequest
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMMOZACTIVITY
|
||||
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
|
||||
NS_FORWARD_NSIDOMDOMREQUEST(DOMRequest::)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Activity, DOMRequest)
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aContext,
|
||||
JSObject* aObject, uint32_t aArgc, jsval* aArgv);
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
static bool PrefEnabled()
|
||||
{
|
||||
#ifdef MOZ_SYS_MSG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static already_AddRefed<Activity>
|
||||
Constructor(const GlobalObject& aOwner,
|
||||
nsIDOMMozActivityOptions* aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<Activity> activity = new Activity();
|
||||
aRv = activity->Initialize(aOwner.Get(), aOptions);
|
||||
return activity.forget();
|
||||
}
|
||||
|
||||
Activity();
|
||||
|
||||
protected:
|
||||
nsresult Initialize(nsISupports* aOwner,
|
||||
nsIDOMMozActivityOptions* aOptions);
|
||||
|
||||
nsCOMPtr<nsIActivityProxy> mProxy;
|
||||
|
||||
~Activity();
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "AudioChannelAgent.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "DOMCursor.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsError.h"
|
||||
#include "mozilla/dom/DOMCursorBinding.h"
|
||||
|
||||
DOMCI_DATA(DOMCursor, mozilla::dom::DOMCursor)
|
||||
|
||||
@ -64,24 +65,37 @@ DOMCursor::FireDone()
|
||||
NS_IMETHODIMP
|
||||
DOMCursor::GetDone(bool *aDone)
|
||||
{
|
||||
*aDone = mFinished;
|
||||
*aDone = Done();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMCursor::Continue()
|
||||
{
|
||||
ErrorResult rv;
|
||||
Continue(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
DOMCursor::Continue(ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(mCallback, "If you're creating your own cursor class with no callback, you should override Continue()");
|
||||
|
||||
// We need to have a result here because we must be in a 'success' state.
|
||||
if (mResult == JSVAL_VOID) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
Reset();
|
||||
mCallback->HandleContinue();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
/* virtual */ JSObject*
|
||||
DOMCursor::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return DOMCursorBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -16,8 +16,8 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DOMCursor : public nsIDOMDOMCursor
|
||||
, public DOMRequest
|
||||
class DOMCursor : public DOMRequest
|
||||
, public nsIDOMDOMCursor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
@ -25,13 +25,23 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMCursor,
|
||||
DOMRequest)
|
||||
|
||||
DOMCursor() MOZ_DELETE;
|
||||
DOMCursor(nsIDOMWindow* aWindow, nsICursorContinueCallback *aCallback);
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
bool Done() const
|
||||
{
|
||||
return mFinished;
|
||||
}
|
||||
virtual void Continue(ErrorResult& aRv);
|
||||
|
||||
void Reset();
|
||||
void FireDone();
|
||||
|
||||
private:
|
||||
DOMCursor() MOZ_DELETE;
|
||||
|
||||
nsCOMPtr<nsICursorContinueCallback> mCallback;
|
||||
bool mFinished;
|
||||
};
|
||||
|
@ -25,6 +25,7 @@ DOMRequest::DOMRequest(nsIDOMWindow* aWindow)
|
||||
, mDone(false)
|
||||
, mRooted(false)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
Init(aWindow);
|
||||
}
|
||||
|
||||
@ -35,6 +36,7 @@ DOMRequest::DOMRequest()
|
||||
, mDone(false)
|
||||
, mRooted(false)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
void
|
||||
@ -75,14 +77,29 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(DOMRequest, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(DOMRequest, nsDOMEventTargetHelper)
|
||||
|
||||
/* virtual */ JSObject*
|
||||
DOMRequest::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return DOMRequestBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(DOMRequest, success)
|
||||
NS_IMPL_EVENT_HANDLER(DOMRequest, error)
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMRequest::GetReadyState(nsAString& aReadyState)
|
||||
{
|
||||
mDone ? aReadyState.AssignLiteral("done") :
|
||||
DOMRequestReadyState readyState = ReadyState();
|
||||
switch (readyState) {
|
||||
case DOMRequestReadyStateValues::Pending:
|
||||
aReadyState.AssignLiteral("pending");
|
||||
break;
|
||||
case DOMRequestReadyStateValues::Done:
|
||||
aReadyState.AssignLiteral("done");
|
||||
break;
|
||||
default:
|
||||
MOZ_NOT_REACHED("Unrecognized readyState.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -90,21 +107,14 @@ DOMRequest::GetReadyState(nsAString& aReadyState)
|
||||
NS_IMETHODIMP
|
||||
DOMRequest::GetResult(jsval* aResult)
|
||||
{
|
||||
NS_ASSERTION(mDone || mResult == JSVAL_VOID,
|
||||
"Result should be undefined when pending");
|
||||
*aResult = mResult;
|
||||
|
||||
*aResult = Result();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMRequest::GetError(nsIDOMDOMError** aError)
|
||||
{
|
||||
NS_ASSERTION(mDone || !mError,
|
||||
"Error should be null when pending");
|
||||
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
|
||||
NS_IF_ADDREF(*aError = GetError());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsIDOMDOMError.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/DOMRequestBinding.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
@ -34,6 +35,40 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
|
||||
// WrapperCache
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL Interface
|
||||
DOMRequestReadyState ReadyState() const
|
||||
{
|
||||
return mDone ? DOMRequestReadyStateValues::Done
|
||||
: DOMRequestReadyStateValues::Pending;
|
||||
}
|
||||
|
||||
JS::Value Result(JSContext* = nullptr) const
|
||||
{
|
||||
NS_ASSERTION(mDone || mResult == JSVAL_VOID,
|
||||
"Result should be undefined when pending");
|
||||
return mResult;
|
||||
}
|
||||
|
||||
nsIDOMDOMError* GetError() const
|
||||
{
|
||||
NS_ASSERTION(mDone || !mError,
|
||||
"Error should be null when pending");
|
||||
return mError;
|
||||
}
|
||||
|
||||
IMPL_EVENT_HANDLER(success)
|
||||
IMPL_EVENT_HANDLER(error)
|
||||
|
||||
|
||||
void FireSuccess(jsval aResult);
|
||||
void FireError(const nsAString& aError);
|
||||
void FireError(nsresult aError);
|
||||
|
@ -99,7 +99,6 @@
|
||||
#include "nsIDOMMediaList.h"
|
||||
#include "nsIDOMChromeWindow.h"
|
||||
#include "nsIDOMConstructor.h"
|
||||
#include "nsClientRect.h"
|
||||
|
||||
// DOM core includes
|
||||
#include "nsError.h"
|
||||
@ -286,8 +285,6 @@
|
||||
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsDOMFileReader.h"
|
||||
#include "ArchiveReader.h"
|
||||
#include "ArchiveRequest.h"
|
||||
|
||||
#include "nsIDOMDesktopNotification.h"
|
||||
#include "nsIDOMNavigatorDesktopNotification.h"
|
||||
@ -377,7 +374,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
|
||||
#include "nsIAsyncScrollEventDetail.h"
|
||||
#include "nsIDOMGlobalObjectConstructor.h"
|
||||
#include "nsIDOMCanvasRenderingContext2D.h"
|
||||
#include "FileRequest.h"
|
||||
#include "LockedFile.h"
|
||||
#include "GeneratedEvents.h"
|
||||
#include "nsDebug.h"
|
||||
@ -385,10 +381,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
#ifdef MOZ_SYS_MSG
|
||||
#include "mozilla/dom/Activity.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
#include "TimeManager.h"
|
||||
#endif
|
||||
@ -908,9 +900,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsEventSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -925,8 +914,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(ArchiveRequest, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
|
||||
DEFAULT_SCRIPTABLE_FLAGS |
|
||||
@ -941,9 +928,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(DeviceStorage, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(DeviceStorageCursor, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(GeoGeolocation, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -1138,14 +1122,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(AsyncScrollEventDetail, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(FileRequest, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(LockedFile, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
#ifdef MOZ_SYS_MSG
|
||||
NS_DEFINE_CLASSINFO_DATA(MozActivity, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
NS_DEFINE_CLASSINFO_DATA(MozTimeManager, nsDOMGenericSH,
|
||||
@ -1173,9 +1151,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CONTRACT_CTOR(FileReader, NS_FILEREADER_CONTRACTID)
|
||||
NS_DEFINE_CONTRACT_CTOR(XSLTProcessor,
|
||||
"@mozilla.org/document-transformer;1?type=xslt")
|
||||
#ifdef MOZ_SYS_MSG
|
||||
NS_DEFINE_CONTRACT_CTOR(MozActivity, NS_DOMACTIVITY_CONTRACTID)
|
||||
#endif
|
||||
|
||||
#undef NS_DEFINE_CONTRACT_CTOR
|
||||
|
||||
@ -1232,9 +1207,6 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, SmsFilter::NewSmsFilter)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(FileReader, FileReaderCtor)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
|
||||
#ifdef MOZ_SYS_MSG
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozActivity, MozActivityCtor)
|
||||
#endif
|
||||
};
|
||||
#undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
|
||||
#undef NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA
|
||||
@ -2442,10 +2414,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(ClientRect, nsIDOMClientRect)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRect)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@ -2460,11 +2428,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(ArchiveRequest, nsIDOMArchiveRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMArchiveRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
|
||||
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
|
||||
@ -2485,12 +2448,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DeviceStorageCursor, nsIDOMDOMCursor)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMCursor)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(GeoGeolocation, nsIDOMGeoGeolocation)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoGeolocation)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
@ -2840,24 +2797,10 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIAsyncScrollEventDetail)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(FileRequest, nsIDOMFileRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(LockedFile, nsIDOMLockedFile)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLockedFile)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef MOZ_SYS_MSG
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozActivity, nsIDOMMozActivity)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozActivity)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozTimeManager, nsIDOMMozTimeManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozTimeManager)
|
||||
@ -4928,13 +4871,6 @@ ConstructorEnabled(const nsGlobalNameStruct *aStruct, nsGlobalWindow *aWin)
|
||||
}
|
||||
}
|
||||
|
||||
// Don't expose ArchiveRequest unless user has explicitly enabled it
|
||||
if (aStruct->mDOMClassInfoID == eDOMClassInfo_ArchiveRequest_id) {
|
||||
if (!dom::file::ArchiveReader::PrefEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -7514,7 +7450,7 @@ nsHTMLSelectElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext
|
||||
nsHTMLSelectElement *s =
|
||||
nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
|
||||
|
||||
nsHTMLOptionCollection *options = s->GetOptions();
|
||||
HTMLOptionsCollection *options = s->GetOptions();
|
||||
if (options) {
|
||||
nsISupports *node = options->GetElementAt(n);
|
||||
if (node) {
|
||||
@ -7542,7 +7478,7 @@ nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
nsHTMLSelectElement *s =
|
||||
nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
|
||||
|
||||
nsHTMLOptionCollection *options = s->GetOptions();
|
||||
HTMLOptionsCollection *options = s->GetOptions();
|
||||
|
||||
if (options) {
|
||||
nsISupports *node = options->GetElementAt(n);
|
||||
|
@ -170,8 +170,6 @@ DOMCI_CLASS(StorageObsolete)
|
||||
DOMCI_CLASS(Storage)
|
||||
DOMCI_CLASS(StorageItem)
|
||||
|
||||
DOMCI_CLASS(ClientRect)
|
||||
|
||||
DOMCI_CLASS(XULCommandEvent)
|
||||
DOMCI_CLASS(CommandEvent)
|
||||
DOMCI_CLASS(OfflineResourceList)
|
||||
@ -179,7 +177,6 @@ DOMCI_CLASS(OfflineResourceList)
|
||||
DOMCI_CLASS(Blob)
|
||||
DOMCI_CLASS(File)
|
||||
DOMCI_CLASS(FileReader)
|
||||
DOMCI_CLASS(ArchiveRequest)
|
||||
|
||||
// DOM modal content window class, almost identical to Window
|
||||
DOMCI_CLASS(ModalContentWindow)
|
||||
@ -192,7 +189,6 @@ DOMCI_CLASS(DataContainerEvent)
|
||||
DOMCI_CLASS(MessageEvent)
|
||||
|
||||
DOMCI_CLASS(DeviceStorage)
|
||||
DOMCI_CLASS(DeviceStorageCursor)
|
||||
|
||||
// Geolocation
|
||||
DOMCI_CLASS(GeoGeolocation)
|
||||
@ -305,13 +301,8 @@ DOMCI_CLASS(DOMCursor)
|
||||
DOMCI_CLASS(OpenWindowEventDetail)
|
||||
DOMCI_CLASS(AsyncScrollEventDetail)
|
||||
|
||||
DOMCI_CLASS(FileRequest)
|
||||
DOMCI_CLASS(LockedFile)
|
||||
|
||||
#ifdef MOZ_SYS_MSG
|
||||
DOMCI_CLASS(MozActivity)
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
DOMCI_CLASS(MozTimeManager)
|
||||
#endif
|
||||
|
@ -1501,14 +1501,10 @@ nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
// Weak ref, since we addref it below
|
||||
nsClientRect* rect = new nsClientRect();
|
||||
NS_ADDREF(*aResult = rect);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
|
||||
NS_ENSURE_STATE(window);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
nsRect bounds(0, 0, 0, 0);
|
||||
@ -1524,10 +1520,12 @@ nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<nsClientRect> rect = new nsClientRect(window);
|
||||
rect->SetRect(nsPresContext::AppUnitsToFloatCSSPixels(bounds.x),
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(bounds.y),
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(bounds.width),
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(bounds.height));
|
||||
rect.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2679,17 +2679,16 @@ nsGlobalWindow::GetIsTabModalPromptAllowed()
|
||||
return allowTabModal;
|
||||
}
|
||||
|
||||
nsIDOMEventTarget*
|
||||
EventTarget*
|
||||
nsGlobalWindow::GetTargetForDOMEvent()
|
||||
{
|
||||
return static_cast<nsIDOMEventTarget*>(GetOuterWindowInternal());
|
||||
return GetOuterWindowInternal();
|
||||
}
|
||||
|
||||
nsIDOMEventTarget*
|
||||
EventTarget*
|
||||
nsGlobalWindow::GetTargetForEventTargetChain()
|
||||
{
|
||||
return IsInnerWindow() ?
|
||||
this : static_cast<nsIDOMEventTarget*>(GetCurrentInnerWindowInternal());
|
||||
return IsInnerWindow() ? this : GetCurrentInnerWindowInternal();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIVariant.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
@ -78,6 +78,10 @@
|
||||
|
||||
DOMInterfaces = {
|
||||
|
||||
'MozActivity': {
|
||||
'nativeType': 'mozilla::dom::Activity',
|
||||
},
|
||||
|
||||
'AnimationEvent': {
|
||||
'nativeType': 'nsDOMAnimationEvent',
|
||||
},
|
||||
@ -86,6 +90,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'mozilla::dom::file::ArchiveReader',
|
||||
},
|
||||
|
||||
'ArchiveRequest': {
|
||||
'nativeType': 'mozilla::dom::file::ArchiveRequest',
|
||||
},
|
||||
|
||||
'AudioChannelManager': {
|
||||
'nativeType': 'mozilla::dom::system::AudioChannelManager',
|
||||
'headerFile': 'AudioChannelManager.h'
|
||||
@ -157,6 +165,10 @@ DOMInterfaces = {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'ClientRect': {
|
||||
'nativeType': 'nsClientRect',
|
||||
},
|
||||
|
||||
'ClientRectList': {
|
||||
'nativeType': 'nsClientRectList',
|
||||
'headerFile': 'nsClientRect.h',
|
||||
@ -314,6 +326,10 @@ DOMInterfaces = {
|
||||
'implicitJSContext' : [ 'undo', 'redo', 'transact' ]
|
||||
}],
|
||||
|
||||
'FileRequest': {
|
||||
'nativeType': 'mozilla::dom::file::DOMFileRequest',
|
||||
},
|
||||
|
||||
'FormData': [
|
||||
{
|
||||
'nativeType': 'nsFormData'
|
||||
@ -389,12 +405,7 @@ DOMInterfaces = {
|
||||
},
|
||||
|
||||
'HTMLOptionsCollection': {
|
||||
'nativeType': 'nsHTMLOptionCollection',
|
||||
'headerFile': 'nsHTMLSelectElement.h',
|
||||
'resultNotAddRefed': [ 'item' ],
|
||||
'binaryNames': {
|
||||
'__indexedsettercreator': 'SetOption'
|
||||
}
|
||||
},
|
||||
|
||||
'HTMLParamElement': {
|
||||
@ -1276,14 +1287,14 @@ def addExternalHTMLElement(element):
|
||||
|
||||
addExternalHTMLElement('HTMLFormElement')
|
||||
addExternalHTMLElement('HTMLVideoElement')
|
||||
addExternalIface('ArchiveRequest')
|
||||
addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
|
||||
headerFile='nsIDOMActivityOptions.h')
|
||||
addExternalIface('Attr')
|
||||
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('ClientRect')
|
||||
addExternalIface('Counter')
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('DOMRequest')
|
||||
addExternalIface('DOMError')
|
||||
addExternalIface('DOMStringList')
|
||||
addExternalIface('File')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
|
@ -23,8 +23,9 @@
|
||||
#include "jsapi.h"
|
||||
#include "jswrapper.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsContentUtils.h" // nsCxPusher
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "xpcpublic.h"
|
||||
|
@ -34,6 +34,7 @@ CPPSRCS = \
|
||||
|
||||
EXPORTS = \
|
||||
DeviceStorage.h \
|
||||
nsDeviceStorage.h \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
@ -2,19 +2,19 @@
|
||||
* 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/Attributes.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "nsDeviceStorage.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/devicestorage/PDeviceStorageRequestChild.h"
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
#include "mozilla/dom/PContentPermissionRequestChild.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsDOMEvent.h"
|
||||
@ -28,20 +28,16 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "DictionaryHelpers.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "TabChild.h"
|
||||
#include "DeviceStorageRequestChild.h"
|
||||
#include "nsIDOMDeviceStorageChangeEvent.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "GeneratedEvents.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
@ -1072,12 +1068,8 @@ private:
|
||||
nsRefPtr<DOMRequest> mRequest;
|
||||
};
|
||||
|
||||
DOMCI_DATA(DeviceStorageCursor, nsDOMDeviceStorageCursor)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDeviceStorageCursor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMCursor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentPermissionRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceStorageCursor)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMCursor)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMDeviceStorageCursor, DOMCursor)
|
||||
@ -1180,11 +1172,12 @@ nsDOMDeviceStorageCursor::Allow()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDeviceStorageCursor::Continue()
|
||||
void
|
||||
nsDOMDeviceStorageCursor::Continue(ErrorResult& aRv)
|
||||
{
|
||||
if (!mOkToCallContinue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mRooted) {
|
||||
@ -1200,7 +1193,6 @@ nsDOMDeviceStorageCursor::Continue()
|
||||
event->Continue();
|
||||
|
||||
mOkToCallContinue = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2441,13 +2433,13 @@ nsDOMDeviceStorage::DispatchEvent(nsIDOMEvent *aEvt,
|
||||
return nsDOMEventTargetHelper::DispatchEvent(aEvt, aRetval);
|
||||
}
|
||||
|
||||
nsIDOMEventTarget *
|
||||
EventTarget*
|
||||
nsDOMDeviceStorage::GetTargetForDOMEvent()
|
||||
{
|
||||
return nsDOMEventTargetHelper::GetTargetForDOMEvent();
|
||||
}
|
||||
|
||||
nsIDOMEventTarget *
|
||||
EventTarget *
|
||||
nsDOMDeviceStorage::GetTargetForEventTargetChain()
|
||||
{
|
||||
return nsDOMEventTargetHelper::GetTargetForEventTargetChain();
|
||||
|
@ -28,8 +28,11 @@ class nsPIDOMWindow;
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "prtime.h"
|
||||
#include "DeviceStorage.h"
|
||||
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
||||
|
||||
#include "DeviceStorageRequestChild.h"
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
} // namespace mozilla
|
||||
|
||||
#define POST_ERROR_EVENT_FILE_EXISTS "NoModificationAllowedError"
|
||||
#define POST_ERROR_EVENT_FILE_DOES_NOT_EXIST "NotFoundError"
|
||||
@ -96,10 +99,10 @@ class nsDOMDeviceStorageCursor MOZ_FINAL
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSICONTENTPERMISSIONREQUEST
|
||||
NS_FORWARD_NSIDOMDOMCURSOR(mozilla::dom::DOMCursor::)
|
||||
|
||||
// nsIDOMDOMCursor interface.
|
||||
// We use DOMCursor::GetDone.
|
||||
NS_IMETHOD Continue() MOZ_OVERRIDE;
|
||||
// DOMCursor
|
||||
virtual void Continue(mozilla::ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
|
||||
nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
|
||||
nsIPrincipal* aPrincipal,
|
||||
|
@ -3,6 +3,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
#include "mozilla/Util.h" // ArrayLength
|
||||
#include "nsUConvPropertySearch.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -171,7 +171,7 @@ ArchiveReader::RequestReady(ArchiveRequest* aRequest)
|
||||
aRequest->ReaderReady(mData.fileList, mData.status);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMArchiveRequest>
|
||||
already_AddRefed<ArchiveRequest>
|
||||
ArchiveReader::GetFilenames()
|
||||
{
|
||||
nsRefPtr<ArchiveRequest> request = GenerateArchiveRequest();
|
||||
@ -180,7 +180,7 @@ ArchiveReader::GetFilenames()
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMArchiveRequest>
|
||||
already_AddRefed<ArchiveRequest>
|
||||
ArchiveReader::GetFile(const nsAString& filename)
|
||||
{
|
||||
nsRefPtr<ArchiveRequest> request = GenerateArchiveRequest();
|
||||
@ -189,7 +189,7 @@ ArchiveReader::GetFile(const nsAString& filename)
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMArchiveRequest>
|
||||
already_AddRefed<ArchiveRequest>
|
||||
ArchiveReader::GetFiles()
|
||||
{
|
||||
nsRefPtr<ArchiveRequest> request = GenerateArchiveRequest();
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "nsIDOMFile.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIDOMArchiveRequest;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class ArchiveReaderOptions;
|
||||
@ -53,9 +51,9 @@ public:
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
already_AddRefed<nsIDOMArchiveRequest> GetFilenames();
|
||||
already_AddRefed<nsIDOMArchiveRequest> GetFile(const nsAString& filename);
|
||||
already_AddRefed<nsIDOMArchiveRequest> GetFiles();
|
||||
already_AddRefed<ArchiveRequest> GetFilenames();
|
||||
already_AddRefed<ArchiveRequest> GetFile(const nsAString& filename);
|
||||
already_AddRefed<ArchiveRequest> GetFiles();
|
||||
|
||||
nsresult GetInputStream(nsIInputStream** aInputStream);
|
||||
nsresult GetSize(uint64_t* aSize);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "ArchiveRequest.h"
|
||||
|
||||
#include "mozilla/dom/ArchiveRequestBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
@ -51,6 +52,8 @@ ArchiveRequest::ArchiveRequest(nsIDOMWindow* aWindow,
|
||||
: DOMRequest(aWindow),
|
||||
mArchiveReader(aReader)
|
||||
{
|
||||
MOZ_ASSERT(aReader);
|
||||
|
||||
MOZ_COUNT_CTOR(ArchiveRequest);
|
||||
nsLayoutStatics::AddRef();
|
||||
|
||||
@ -73,14 +76,18 @@ ArchiveRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ArchiveRequest::GetReader(nsISupports** aArchiveReader)
|
||||
/* virtual */ JSObject*
|
||||
ArchiveRequest::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return ArchiveRequestBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
ArchiveReader*
|
||||
ArchiveRequest::Reader() const
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsCOMPtr<nsISupports> archiveReader(mArchiveReader);
|
||||
archiveReader.forget(aArchiveReader);
|
||||
return NS_OK;
|
||||
return mArchiveReader;
|
||||
}
|
||||
|
||||
// Here the request is processed:
|
||||
@ -267,8 +274,6 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED_1(ArchiveRequest, DOMRequest,
|
||||
mArchiveReader)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ArchiveRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMArchiveRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ArchiveRequest)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(ArchiveRequest, DOMRequest)
|
||||
|
@ -7,7 +7,6 @@
|
||||
#ifndef mozilla_dom_file_domarchiverequest_h__
|
||||
#define mozilla_dom_file_domarchiverequest_h__
|
||||
|
||||
#include "nsIDOMArchiveRequest.h"
|
||||
#include "ArchiveReader.h"
|
||||
#include "DOMRequest.h"
|
||||
|
||||
@ -20,15 +19,21 @@ BEGIN_FILE_NAMESPACE
|
||||
* This is the ArchiveRequest that handles any operation
|
||||
* related to ArchiveReader
|
||||
*/
|
||||
class ArchiveRequest : public mozilla::dom::DOMRequest,
|
||||
public nsIDOMArchiveRequest
|
||||
class ArchiveRequest : public mozilla::dom::DOMRequest
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMARCHIVEREQUEST
|
||||
static bool PrefEnabled()
|
||||
{
|
||||
return ArchiveReader::PrefEnabled();
|
||||
}
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
ArchiveReader* Reader() const;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_FORWARD_NSIDOMDOMREQUEST(DOMRequest::)
|
||||
NS_FORWARD_NSIDOMEVENTTARGET_NOPREHANDLEEVENT(DOMRequest::)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
|
||||
|
||||
ArchiveRequest(nsIDOMWindow* aWindow,
|
||||
|
30
dom/file/DOMFileRequest.cpp
Normal file
30
dom/file/DOMFileRequest.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DOMFileRequest.h"
|
||||
|
||||
#include "mozilla/dom/FileRequestBinding.h"
|
||||
#include "LockedFile.h"
|
||||
|
||||
USING_FILE_NAMESPACE
|
||||
|
||||
DOMFileRequest::DOMFileRequest(nsIDOMWindow* aWindow)
|
||||
: FileRequest(aWindow)
|
||||
{
|
||||
}
|
||||
|
||||
/* virtual */ JSObject*
|
||||
DOMFileRequest::WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return FileRequestBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsIDOMLockedFile*
|
||||
DOMFileRequest::GetLockedFile() const
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
return mLockedFile;
|
||||
}
|
30
dom/file/DOMFileRequest.h
Normal file
30
dom/file/DOMFileRequest.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_file_DOMFileRequest_h
|
||||
#define mozilla_dom_file_DOMFileRequest_h
|
||||
|
||||
#include "FileRequest.h"
|
||||
|
||||
class nsIDOMLockedFile;
|
||||
|
||||
BEGIN_FILE_NAMESPACE
|
||||
|
||||
class DOMFileRequest : public FileRequest
|
||||
{
|
||||
public:
|
||||
DOMFileRequest(nsIDOMWindow* aWindow);
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
||||
|
||||
nsIDOMLockedFile* GetLockedFile() const;
|
||||
IMPL_EVENT_HANDLER(progress)
|
||||
};
|
||||
|
||||
END_FILE_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_file_DOMFileRequest_h
|
@ -133,12 +133,12 @@ NS_IMETHODIMP
|
||||
FileHandle::GetFile(nsIDOMDOMRequest** _retval)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIDOMDOMRequest> request = GetFile(rv);
|
||||
nsRefPtr<DOMRequest> request = GetFile(rv);
|
||||
request.forget(_retval);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMDOMRequest>
|
||||
already_AddRefed<DOMRequest>
|
||||
FileHandle::GetFile(ErrorResult& aError)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -170,8 +170,7 @@ FileHandle::GetFile(ErrorResult& aError)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<DOMRequest> domRequest = request.forget();
|
||||
return domRequest.forget();
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(int64_t)
|
||||
|
@ -21,6 +21,12 @@
|
||||
class nsIDOMFile;
|
||||
class nsIFileStorage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DOMRequest;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
BEGIN_FILE_NAMESPACE
|
||||
|
||||
class FileService;
|
||||
@ -61,7 +67,7 @@ public:
|
||||
aType = mType;
|
||||
}
|
||||
already_AddRefed<nsIDOMLockedFile> Open(FileMode aMode, ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMDOMRequest> GetFile(ErrorResult& aError);
|
||||
already_AddRefed<DOMRequest> GetFile(ErrorResult& aError);
|
||||
IMPL_EVENT_HANDLER(abort)
|
||||
IMPL_EVENT_HANDLER(error)
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "nsIJSContextStack.h"
|
||||
|
||||
#include "DOMFileRequest.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsError.h"
|
||||
@ -19,7 +20,7 @@
|
||||
USING_FILE_NAMESPACE
|
||||
|
||||
FileRequest::FileRequest(nsIDOMWindow* aWindow)
|
||||
: DOMRequest(aWindow), mIsFileRequest(true)
|
||||
: DOMRequest(aWindow)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
}
|
||||
@ -37,9 +38,13 @@ FileRequest::Create(nsIDOMWindow* aOwner,
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsRefPtr<FileRequest> request = new FileRequest(aOwner);
|
||||
nsRefPtr<FileRequest> request;
|
||||
if (aIsFileRequest) {
|
||||
request = new DOMFileRequest(aOwner);
|
||||
} else {
|
||||
request = new FileRequest(aOwner);
|
||||
}
|
||||
request->mLockedFile = aLockedFile;
|
||||
request->mIsFileRequest = aIsFileRequest;
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
@ -97,32 +102,15 @@ FileRequest::NotifyHelperCompleted(FileHelper* aFileHelper)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileRequest::GetLockedFile(nsIDOMLockedFile** aLockedFile)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsCOMPtr<nsIDOMLockedFile> lockedFile(mLockedFile);
|
||||
lockedFile.forget(aLockedFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(FileRequest, DOMRequest,
|
||||
mLockedFile)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileRequest)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFileRequest, mIsFileRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(FileRequest, mIsFileRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(DOMRequest, !mIsFileRequest)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(FileRequest, DOMRequest)
|
||||
NS_IMPL_RELEASE_INHERITED(FileRequest, DOMRequest)
|
||||
|
||||
DOMCI_DATA(FileRequest, FileRequest)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(FileRequest, progress)
|
||||
|
||||
void
|
||||
FileRequest::FireProgressEvent(uint64_t aLoaded, uint64_t aTotal)
|
||||
{
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
#include "FileCommon.h"
|
||||
|
||||
#include "nsIDOMFileRequest.h"
|
||||
|
||||
#include "DOMRequest.h"
|
||||
|
||||
BEGIN_FILE_NAMESPACE
|
||||
@ -18,14 +16,10 @@ BEGIN_FILE_NAMESPACE
|
||||
class FileHelper;
|
||||
class LockedFile;
|
||||
|
||||
class FileRequest : public mozilla::dom::DOMRequest,
|
||||
public nsIDOMFileRequest
|
||||
class FileRequest : public mozilla::dom::DOMRequest
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMFILEREQUEST
|
||||
NS_FORWARD_NSIDOMDOMREQUEST(DOMRequest::)
|
||||
NS_FORWARD_NSIDOMEVENTTARGET_NOPREHANDLEEVENT(DOMRequest::)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileRequest, DOMRequest)
|
||||
|
||||
static already_AddRefed<FileRequest>
|
||||
@ -44,7 +38,7 @@ public:
|
||||
nsresult
|
||||
NotifyHelperCompleted(FileHelper* aFileHelper);
|
||||
|
||||
private:
|
||||
protected:
|
||||
FileRequest(nsIDOMWindow* aWindow);
|
||||
~FileRequest();
|
||||
|
||||
@ -52,7 +46,6 @@ private:
|
||||
FireProgressEvent(uint64_t aLoaded, uint64_t aTotal);
|
||||
|
||||
nsRefPtr<LockedFile> mLockedFile;
|
||||
bool mIsFileRequest;
|
||||
};
|
||||
|
||||
END_FILE_NAMESPACE
|
||||
|
@ -533,7 +533,7 @@ LockedFile::SetLocation(JSContext* aCx,
|
||||
NS_IMETHODIMP
|
||||
LockedFile::GetMetadata(const jsval& aParameters,
|
||||
JSContext* aCx,
|
||||
nsIDOMFileRequest** _retval)
|
||||
nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -570,14 +570,15 @@ LockedFile::GetMetadata(const jsval& aParameters,
|
||||
nsresult rv = helper->Enqueue();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
|
||||
|
||||
fileRequest.forget(_retval);
|
||||
nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LockedFile::ReadAsArrayBuffer(uint64_t aSize,
|
||||
JSContext* aCx,
|
||||
nsIDOMFileRequest** _retval)
|
||||
nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -612,14 +613,15 @@ LockedFile::ReadAsArrayBuffer(uint64_t aSize,
|
||||
|
||||
mLocation += aSize;
|
||||
|
||||
fileRequest.forget(_retval);
|
||||
nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LockedFile::ReadAsText(uint64_t aSize,
|
||||
const nsAString& aEncoding,
|
||||
nsIDOMFileRequest** _retval)
|
||||
nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -654,14 +656,15 @@ LockedFile::ReadAsText(uint64_t aSize,
|
||||
|
||||
mLocation += aSize;
|
||||
|
||||
fileRequest.forget(_retval);
|
||||
nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LockedFile::Write(const jsval& aValue,
|
||||
JSContext* aCx,
|
||||
nsIDOMFileRequest** _retval)
|
||||
nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -671,7 +674,7 @@ LockedFile::Write(const jsval& aValue,
|
||||
NS_IMETHODIMP
|
||||
LockedFile::Append(const jsval& aValue,
|
||||
JSContext* aCx,
|
||||
nsIDOMFileRequest** _retval)
|
||||
nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -681,7 +684,7 @@ LockedFile::Append(const jsval& aValue,
|
||||
NS_IMETHODIMP
|
||||
LockedFile::Truncate(uint64_t aSize,
|
||||
uint8_t aOptionalArgCount,
|
||||
nsIDOMFileRequest** _retval)
|
||||
nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -724,12 +727,13 @@ LockedFile::Truncate(uint64_t aSize,
|
||||
mLocation = aSize;
|
||||
}
|
||||
|
||||
fileRequest.forget(_retval);
|
||||
nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LockedFile::Flush(nsIDOMFileRequest** _retval)
|
||||
LockedFile::Flush(nsISupports** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
@ -754,7 +758,8 @@ LockedFile::Flush(nsIDOMFileRequest** _retval)
|
||||
nsresult rv = helper->Enqueue();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
|
||||
|
||||
fileRequest.forget(_retval);
|
||||
nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -837,7 +842,7 @@ LockedFile::OpenInputStream(bool aWholeFile, uint64_t aStart, uint64_t aLength,
|
||||
nsresult
|
||||
LockedFile::WriteOrAppend(const jsval& aValue,
|
||||
JSContext* aCx,
|
||||
nsIDOMFileRequest** _retval,
|
||||
nsISupports** _retval,
|
||||
bool aAppend)
|
||||
{
|
||||
if (!IsOpen()) {
|
||||
@ -886,7 +891,8 @@ LockedFile::WriteOrAppend(const jsval& aValue,
|
||||
mLocation += inputLength;
|
||||
}
|
||||
|
||||
fileRequest.forget(_retval);
|
||||
nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ private:
|
||||
|
||||
nsresult
|
||||
WriteOrAppend(const jsval& aValue, JSContext* aCx,
|
||||
nsIDOMFileRequest** _retval, bool aAppend);
|
||||
nsISupports** _retval, bool aAppend);
|
||||
|
||||
nsresult
|
||||
Finish();
|
||||
|
@ -24,6 +24,7 @@ EXPORTS_NAMESPACES = mozilla/dom/file
|
||||
CPPSRCS = \
|
||||
AsyncHelper.cpp \
|
||||
DOMFileHandle.cpp \
|
||||
DOMFileRequest.cpp \
|
||||
File.cpp \
|
||||
FileHandle.cpp \
|
||||
FileHelper.cpp \
|
||||
@ -46,6 +47,7 @@ EXPORTS = \
|
||||
|
||||
EXPORTS_mozilla/dom/file = \
|
||||
DOMFileHandle.h \
|
||||
DOMFileRequest.h \
|
||||
File.h \
|
||||
FileCommon.h \
|
||||
FileHandle.h \
|
||||
|
@ -6,9 +6,7 @@
|
||||
TEST_DIRS += ['test']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMArchiveRequest.idl',
|
||||
'nsIDOMFileHandle.idl',
|
||||
'nsIDOMFileRequest.idl',
|
||||
'nsIDOMLockedFile.idl',
|
||||
]
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIDOMDOMRequest.idl"
|
||||
|
||||
interface nsIDOMArchiveReader;
|
||||
|
||||
[scriptable, builtinclass, uuid(cb72a719-f07d-4271-a120-16e9148a8699)]
|
||||
interface nsIDOMArchiveRequest : nsIDOMDOMRequest
|
||||
{
|
||||
readonly attribute nsISupports /* ArchiveReader */ reader;
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIDOMDOMRequest.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMLockedFile;
|
||||
|
||||
[scriptable, builtinclass, uuid(6733d649-0acb-487d-8a7d-f102ac4419e9)]
|
||||
interface nsIDOMFileRequest : nsIDOMDOMRequest
|
||||
{
|
||||
readonly attribute nsIDOMLockedFile lockedFile;
|
||||
|
||||
[implicit_jscontext] attribute jsval onprogress;
|
||||
};
|
@ -8,7 +8,6 @@
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMFileHandle;
|
||||
interface nsIDOMFileRequest;
|
||||
|
||||
dictionary DOMFileMetadataParameters
|
||||
{
|
||||
@ -16,7 +15,7 @@ dictionary DOMFileMetadataParameters
|
||||
boolean lastModified;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(589e0d26-20b5-4355-ac1e-9c6fd0dd83f2)]
|
||||
[scriptable, builtinclass, uuid(a09cdc35-6b1e-42ce-95bb-f8f10a354202)]
|
||||
interface nsIDOMLockedFile : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMFileHandle fileHandle;
|
||||
@ -30,31 +29,31 @@ interface nsIDOMLockedFile : nsISupports
|
||||
attribute jsval location;
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
getMetadata(/* DOMFileMetadataParameters */
|
||||
[optional /* all */] in jsval parameters);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
readAsArrayBuffer(in unsigned long long size);
|
||||
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
readAsText(in unsigned long long size,
|
||||
[optional] in DOMString encoding);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
write(in jsval value);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
append(in jsval value);
|
||||
|
||||
[optional_argc]
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
truncate([optional] in unsigned long long size);
|
||||
|
||||
nsIDOMFileRequest
|
||||
nsISupports /* FileRequest */
|
||||
flush();
|
||||
|
||||
void
|
||||
|
@ -60,7 +60,6 @@
|
||||
"Element interface: attribute namespaceURI": true,
|
||||
"Element interface: attribute prefix": true,
|
||||
"Element interface: attribute localName": true,
|
||||
"Element interface: attribute attributes": true,
|
||||
"Element interface: attribute className": true,
|
||||
"Element interface: operation remove()": true,
|
||||
"Element interface: element must inherit property \"className\" with the proper type (5)": true,
|
||||
|
@ -14,7 +14,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, builtinclass, uuid(d8db04e0-cbee-4063-9c16-8b0693146519)]
|
||||
[scriptable, builtinclass, uuid(a974a4d3-2ff1-445b-8b8e-0aada5d4eedc)]
|
||||
interface nsIDOMAttr : nsIDOMNode
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(6e2f1af8-cc86-4ed5-948a-007bb40c65da)]
|
||||
[scriptable, uuid(cfad94e0-92d6-4b32-ab18-c61f9b8cb313)]
|
||||
interface nsIDOMCDATASection : nsIDOMText
|
||||
{
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(f891fa15-2652-4a88-9be5-364b9192b209)]
|
||||
[scriptable, uuid(05c29ae6-5533-42b6-9085-257f60445d5a)]
|
||||
interface nsIDOMCharacterData : nsIDOMNode
|
||||
{
|
||||
attribute DOMString data;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(02f2c4cc-47c6-4e5e-9934-da93373b9e47)]
|
||||
[scriptable, uuid(cf5493dc-ba25-423a-81e7-b417494f103a)]
|
||||
interface nsIDOMComment : nsIDOMCharacterData
|
||||
{
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ interface nsIDOMLocation;
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(23fdb479-2543-4885-9d7a-47dd646966a5)]
|
||||
[scriptable, uuid(75996de6-6b0f-43e5-ae79-c98fa669da9a)]
|
||||
interface nsIDOMDocument : nsIDOMNode
|
||||
{
|
||||
readonly attribute nsIDOMDocumentType doctype;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, builtinclass, uuid(b098fc8f-9ef4-4de8-bbd0-4a0fc712dd6e)]
|
||||
[scriptable, builtinclass, uuid(33127aed-9d6a-4b0d-95aa-0529f51bcb9c)]
|
||||
interface nsIDOMDocumentFragment : nsIDOMNode
|
||||
{
|
||||
};
|
||||
|
@ -15,7 +15,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(2ce127d8-5aaf-440e-b572-bfb7ba81062b)]
|
||||
[scriptable, uuid(7568365e-240f-4818-b2fc-0680bfb50942)]
|
||||
interface nsIDOMDocumentType : nsIDOMNode
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "nsIDOMNode.idl"
|
||||
|
||||
interface nsIDOMMozNamedAttrMap;
|
||||
|
||||
/**
|
||||
* The nsIDOMElement interface represents an element in an HTML or
|
||||
* XML document.
|
||||
@ -13,7 +15,7 @@
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element
|
||||
*/
|
||||
|
||||
[scriptable, uuid(9387fd9b-46e9-4a1e-997f-713c0123c7f8)]
|
||||
[scriptable, uuid(ccc2bbbc-5b44-4b01-b718-dd51f339fef8)]
|
||||
interface nsIDOMElement : nsIDOMNode
|
||||
{
|
||||
readonly attribute DOMString tagName;
|
||||
@ -23,6 +25,7 @@ interface nsIDOMElement : nsIDOMNode
|
||||
*/
|
||||
readonly attribute nsISupports classList;
|
||||
|
||||
readonly attribute nsIDOMMozNamedAttrMap attributes;
|
||||
DOMString getAttribute(in DOMString name);
|
||||
DOMString getAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString localName);
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIVariant;
|
||||
interface nsIDOMMozNamedAttrMap;
|
||||
interface nsIDOMUserDataHandler;
|
||||
|
||||
/**
|
||||
@ -18,7 +17,7 @@ interface nsIDOMUserDataHandler;
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(a8cae9dc-bd35-4a99-a8e9-4170f8a38566)]
|
||||
[scriptable, uuid(56545150-a001-484e-9ed4-cb319eebd7b3)]
|
||||
interface nsIDOMNode : nsISupports
|
||||
{
|
||||
const unsigned short ELEMENT_NODE = 1;
|
||||
@ -46,7 +45,6 @@ interface nsIDOMNode : nsISupports
|
||||
readonly attribute nsIDOMNode lastChild;
|
||||
readonly attribute nsIDOMNode previousSibling;
|
||||
readonly attribute nsIDOMNode nextSibling;
|
||||
readonly attribute nsIDOMMozNamedAttrMap attributes;
|
||||
// Modified in DOM Level 2:
|
||||
readonly attribute nsIDOMDocument ownerDocument;
|
||||
nsIDOMNode insertBefore(in nsIDOMNode newChild,
|
||||
|
@ -15,7 +15,7 @@
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(bc6d94d8-cf2c-4a37-aae7-491fc9a62608)]
|
||||
[scriptable, uuid(9ee8b1c3-2b0d-49e2-b2d6-f6bb8bf21b9e)]
|
||||
interface nsIDOMProcessingInstruction : nsIDOMCharacterData
|
||||
{
|
||||
readonly attribute DOMString target;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(d3c734f2-47e9-4eac-84f9-3592022aac13)]
|
||||
[scriptable, uuid(3de88cc9-1462-4bb8-a2fc-845b132547ac)]
|
||||
interface nsIDOMText : nsIDOMCharacterData
|
||||
{
|
||||
nsIDOMText splitText(in unsigned long offset)
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "nsIDOMDocument.idl"
|
||||
|
||||
[scriptable, uuid(7f7abfbb-263f-4a4a-9944-397f0b64bad8)]
|
||||
[scriptable, uuid(79547ba5-291e-4775-b71e-2440a4621b54)]
|
||||
interface nsIDOMXMLDocument : nsIDOMDocument
|
||||
{
|
||||
// DOM Level 3 Load & Save, DocumentLS
|
||||
|
@ -11,6 +11,12 @@
|
||||
|
||||
using mozilla::dom::Nullable;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class EventTarget;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsPresContext;
|
||||
class nsEventChainPreVisitor;
|
||||
class nsEventChainPostVisitor;
|
||||
@ -33,6 +39,7 @@ class nsEventListenerManager;
|
||||
[ptr] native nsEventStatusPtr(nsEventStatus);
|
||||
[ptr] native JSContextPtr(JSContext);
|
||||
[ptr] native nsEventListenerManagerPtr(nsEventListenerManager);
|
||||
[ptr] native EventTargetPtr(mozilla::dom::EventTarget);
|
||||
|
||||
interface nsIScriptContext;
|
||||
interface nsIDOMEventListener;
|
||||
@ -191,7 +198,7 @@ interface nsIDOMEventTarget : nsISupports
|
||||
* Usually |this| is returned, but for example global object returns
|
||||
* the outer object.
|
||||
*/
|
||||
[notxpcom, nostdcall] nsIDOMEventTarget GetTargetForDOMEvent();
|
||||
[notxpcom, nostdcall] EventTargetPtr GetTargetForDOMEvent();
|
||||
|
||||
/**
|
||||
* Returns the nsIDOMEventTarget object which should be used as the target
|
||||
@ -199,7 +206,7 @@ interface nsIDOMEventTarget : nsISupports
|
||||
* Usually |this| is returned, but for example global object returns
|
||||
* the inner object.
|
||||
*/
|
||||
[notxpcom, nostdcall] nsIDOMEventTarget GetTargetForEventTargetChain();
|
||||
[notxpcom, nostdcall] EventTargetPtr GetTargetForEventTargetChain();
|
||||
|
||||
/**
|
||||
* Called before the capture phase of the event flow.
|
||||
@ -287,8 +294,8 @@ interface nsIDOMEventTarget : nsISupports
|
||||
%{C++
|
||||
|
||||
#define NS_IMPL_DOMTARGET_DEFAULTS(_class) \
|
||||
nsIDOMEventTarget* _class::GetTargetForDOMEvent() { return this; } \
|
||||
nsIDOMEventTarget* _class::GetTargetForEventTargetChain() { return this; } \
|
||||
mozilla::dom::EventTarget* _class::GetTargetForDOMEvent() { return this; } \
|
||||
mozilla::dom::EventTarget* _class::GetTargetForEventTargetChain() { return this; } \
|
||||
nsresult _class::WillHandleEvent(nsEventChainPostVisitor& aVisitor) { return NS_OK; } \
|
||||
JSContext* _class::GetJSContextForEventHandlers() { return nullptr; }
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(5651dd01-40f3-43af-9901-759472830133)]
|
||||
[scriptable, uuid(c75e7bb1-cc7a-4169-9467-9513a95e3b94)]
|
||||
interface nsIDOMHTMLAnchorElement : nsIDOMHTMLElement
|
||||
{
|
||||
attribute DOMString href;
|
||||
|
@ -16,7 +16,7 @@
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(387a4315-cb8c-4235-a1ec-636a3613ba0d)]
|
||||
[scriptable, uuid(351dd451-0077-4298-b569-a41529baca32)]
|
||||
interface nsIDOMHTMLAppletElement : nsIDOMHTMLElement
|
||||
{
|
||||
attribute DOMString align;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user