зеркало из https://github.com/mozilla/gecko-dev.git
Bug 883892. Remove HTMLFormElement classinfo. r=peterv
This commit is contained in:
Родитель
b6986ad28f
Коммит
e5a1a7564c
|
@ -1256,14 +1256,6 @@ _elementName::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const \
|
|||
return rv; \
|
||||
}
|
||||
|
||||
#define DOMCI_NODE_DATA(_interface, _class) \
|
||||
DOMCI_DATA(_interface, _class) \
|
||||
nsXPCClassInfo* _class::GetClassInfo() \
|
||||
{ \
|
||||
return static_cast<nsXPCClassInfo*>( \
|
||||
NS_GetDOMClassInfoInstance(eDOMClassInfo_##_interface##_id)); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/dom/Element.h" // DOMCI_NODE_DATA
|
||||
#include "mozilla/dom/Comment.h"
|
||||
#include "mozilla/dom/CommentBinding.h"
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/Element.h" // for DOMCI_NODE_DATA
|
||||
#include "mozilla/dom/Element.h" // for NS_IMPL_ELEMENT_CLONE
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
@ -133,10 +133,8 @@ NS_INTERFACE_MAP_BEGIN(DocumentFragment)
|
|||
new nsNodeSupportsWeakRefTearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNodeSelector,
|
||||
new nsNodeSelectorTearoff(this))
|
||||
// nsNodeSH::PreCreate() depends on the identity pointer being the
|
||||
// same as nsINode (which nsIContent inherits), so if you change the
|
||||
// below line, make sure nsNodeSH::PreCreate() still does the right
|
||||
// thing!
|
||||
// DOM bindings depend on the identity pointer being the
|
||||
// same as nsINode (which nsIContent inherits).
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
|
|
@ -1699,10 +1699,8 @@ NS_INTERFACE_MAP_BEGIN(FragmentOrElement)
|
|||
new nsTouchEventReceiverTearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIInlineEventHandlers,
|
||||
new nsInlineEventHandlersTearoff(this))
|
||||
// nsNodeSH::PreCreate() depends on the identity pointer being the
|
||||
// same as nsINode (which nsIContent inherits), so if you change the
|
||||
// below line, make sure nsNodeSH::PreCreate() still does the right
|
||||
// thing!
|
||||
// DOM bindings depend on the identity pointer being the
|
||||
// same as nsINode (which nsIContent inherits).
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
|
|
@ -104,10 +104,8 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
|
|||
new nsNodeSupportsWeakRefTearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMXPathNSResolver,
|
||||
new nsNode3Tearoff(this))
|
||||
// nsNodeSH::PreCreate() depends on the identity pointer being the
|
||||
// same as nsINode (which nsIContent inherits), so if you change the
|
||||
// below line, make sure nsNodeSH::PreCreate() still does the right
|
||||
// thing!
|
||||
// DOM bindings depend on the identity pointer being the
|
||||
// same as nsINode (which nsIContent inherits).
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@
|
|||
// images
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
|
||||
DOMCI_NODE_DATA(HTMLFormElement, mozilla::dom::HTMLFormElement)
|
||||
|
||||
// construction, destruction
|
||||
nsGenericHTMLElement*
|
||||
NS_NewHTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
|
@ -337,7 +335,6 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLFormElement)
|
|||
nsIWebProgressListener,
|
||||
nsIRadioGroupContainer)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLFormElement)
|
||||
NS_ELEMENT_INTERFACE_MAP_END
|
||||
|
||||
|
||||
|
|
|
@ -21,13 +21,6 @@
|
|||
#include "nsDataHashtable.h"
|
||||
#include "nsAsyncDOMEvent.h"
|
||||
|
||||
// Including 'windows.h' will #define GetClassInfo to something else.
|
||||
#ifdef XP_WIN
|
||||
#ifdef GetClassInfo
|
||||
#undef GetClassInfo
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class nsIMutableArray;
|
||||
class nsIURI;
|
||||
|
||||
|
@ -289,8 +282,6 @@ public:
|
|||
*/
|
||||
bool CheckValidFormSubmission();
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,13 +17,10 @@ NS_NewXMLElement(nsIContent** aInstancePtrResult, already_AddRefed<nsINodeInfo>
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
DOMCI_NODE_DATA(Element, nsXMLElement)
|
||||
|
||||
// QueryInterface implementation for nsXMLElement
|
||||
NS_INTERFACE_TABLE_HEAD(nsXMLElement)
|
||||
NS_INTERFACE_TABLE_INHERITED2(nsXMLElement, nsIDOMNode, nsIDOMElement)
|
||||
NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Element)
|
||||
NS_ELEMENT_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsXMLElement, Element)
|
||||
|
|
|
@ -32,8 +32,6 @@ public:
|
|||
// nsINode interface methods
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; }
|
||||
|
||||
// nsIContent interface methods
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "mozilla/dom/Element.h" // DOMCI_NODE_DATA
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/XMLDocumentBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
|
|
@ -103,12 +103,6 @@
|
|||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDOMStringList.h"
|
||||
|
||||
// HTMLFormElement helper includes
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
|
||||
// Event related includes
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
@ -319,20 +313,11 @@ static const char kDOMStringBundleURL[] =
|
|||
nsIXPCScriptable::IS_GLOBAL_OBJECT | \
|
||||
nsIXPCScriptable::WANT_OUTER_OBJECT)
|
||||
|
||||
#define NODE_SCRIPTABLE_FLAGS \
|
||||
((DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY) & \
|
||||
~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
|
||||
|
||||
// We need to let JavaScript QI elements to interfaces that are not in
|
||||
// the classinfo since XBL can be used to dynamically implement new
|
||||
// unknown interfaces on elements, accessibility relies on this being
|
||||
// possible.
|
||||
|
||||
#define ELEMENT_SCRIPTABLE_FLAGS \
|
||||
((NODE_SCRIPTABLE_FLAGS & ~nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY) | \
|
||||
nsIXPCScriptable::WANT_POSTCREATE)
|
||||
|
||||
#define ARRAY_SCRIPTABLE_FLAGS \
|
||||
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_GETPROPERTY | \
|
||||
|
@ -504,8 +489,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
// Core classes
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(Element, nsElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
|
||||
// Misc Core related classes
|
||||
|
||||
|
@ -514,12 +497,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(DeviceRotationRate, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
// HTML element classes
|
||||
NS_DEFINE_CLASSINFO_DATA(HTMLFormElement, HTMLFormElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_GETPROPERTY |
|
||||
nsIXPCScriptable::WANT_NEWENUMERATE)
|
||||
|
||||
// CSS classes
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
@ -1263,24 +1240,6 @@ nsDOMClassInfo::RegisterExternalClasses()
|
|||
d.mInterfaces = interface_list; \
|
||||
}
|
||||
|
||||
#define DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
|
||||
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMDocumentTouch, \
|
||||
nsDOMTouchEvent::PrefEnabled())
|
||||
|
||||
|
||||
#define DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
|
||||
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
|
||||
nsDOMTouchEvent::PrefEnabled())
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
#define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow) \
|
||||
|
@ -1428,15 +1387,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIException)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Element, nsIDOMElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
|
||||
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
|
||||
nsDOMTouchEvent::PrefEnabled())
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(DeviceAcceleration, nsIDOMDeviceAcceleration)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceAcceleration)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -1445,11 +1395,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceRotationRate)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(HTMLFormElement, nsIDOMHTMLFormElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFormElement)
|
||||
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSStyleRule, nsIDOMCSSStyleRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -4942,153 +4887,6 @@ nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
|||
return SetParentToWindow(win, parentObj);
|
||||
}
|
||||
|
||||
// DOM Node helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *aGlobalObj,
|
||||
JSObject **parentObj)
|
||||
{
|
||||
JS::Rooted<JSObject*> globalObj(cx, aGlobalObj);
|
||||
nsINode *node = static_cast<nsINode*>(nativeObj);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINode> node_qi(do_QueryInterface(nativeObj));
|
||||
|
||||
// If this assertion fires the QI implementation for the object in
|
||||
// question doesn't use the nsINode pointer as the nsISupports
|
||||
// pointer. That must be fixed, or we'll crash...
|
||||
NS_ABORT_IF_FALSE(node_qi == node, "Uh, fix QI!");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Make sure that we get the owner document of the content node, in case
|
||||
// we're in document teardown. If we are, it's important to *not* use
|
||||
// globalObj as the nodes parent since that would give the node the
|
||||
// principal of globalObj (i.e. the principal of the document that's being
|
||||
// loaded) and not the principal of the document that's being unloaded.
|
||||
// See http://bugzilla.mozilla.org/show_bug.cgi?id=227417
|
||||
nsIDocument* doc = node->OwnerDoc();
|
||||
|
||||
nsINode *native_parent;
|
||||
|
||||
bool nodeIsElement = node->IsElement();
|
||||
if (nodeIsElement && node->AsElement()->IsXUL()) {
|
||||
// For XUL elements, use the parent, if any.
|
||||
native_parent = node->GetParent();
|
||||
|
||||
if (!native_parent) {
|
||||
native_parent = doc;
|
||||
}
|
||||
} else if (!node->IsNodeOfType(nsINode::eDOCUMENT)) {
|
||||
NS_ASSERTION(node->IsNodeOfType(nsINode::eCONTENT) ||
|
||||
node->IsNodeOfType(nsINode::eATTRIBUTE),
|
||||
"Unexpected node type");
|
||||
|
||||
// For attributes and non-XUL content, use the document as scope parent.
|
||||
native_parent = doc;
|
||||
|
||||
// But for HTML form controls, use the form as scope parent.
|
||||
if (nodeIsElement) {
|
||||
if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
|
||||
nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
|
||||
|
||||
if (form_control) {
|
||||
Element *form = form_control->GetFormElement();
|
||||
|
||||
if (form) {
|
||||
// Found a form, use it.
|
||||
native_parent = form;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Legend isn't an HTML form control but should have its fieldset form
|
||||
// as scope parent at least for backward compatibility.
|
||||
HTMLLegendElement *legend =
|
||||
HTMLLegendElement::FromContent(node->AsElement());
|
||||
if (legend) {
|
||||
Element *form = legend->GetFormElement();
|
||||
|
||||
if (form) {
|
||||
native_parent = form;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// We're called for a document object; set the parent to be the
|
||||
// document's global object
|
||||
|
||||
// Document should know its global but if the owner window of the
|
||||
// document is already dead at this point, then just throw.
|
||||
nsIGlobalObject* scope = doc->GetScopeObject();
|
||||
NS_ENSURE_TRUE(scope, NS_ERROR_UNEXPECTED);
|
||||
|
||||
*parentObj = scope->GetGlobalJSObject();
|
||||
// Guarding against the case when the native global is still alive
|
||||
// but the JS global is not.
|
||||
NS_ENSURE_TRUE(*parentObj, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// No slim wrappers for a document's scope object.
|
||||
return node->ChromeOnlyAccess() ?
|
||||
NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
|
||||
}
|
||||
|
||||
// XXXjst: Maybe we need to find the global to use from the
|
||||
// nsIScriptGlobalObject that's reachable from the node we're about
|
||||
// to wrap here? But that's not always reachable, let's use
|
||||
// globalObj for now...
|
||||
|
||||
nsresult rv = WrapNativeParent(cx, globalObj, native_parent, parentObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return node->ChromeOnlyAccess() ? NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, jsval *vp, bool *_retval)
|
||||
{
|
||||
nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *aObj, jsid aId, uint32_t flags,
|
||||
JSObject **objp, bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
if (id == sOnload_id || id == sOnerror_id) {
|
||||
// Make sure that this node can't go away while waiting for a
|
||||
// network load that could fire an event handler.
|
||||
// XXXbz won't this fail if the listener is added using
|
||||
// addEventListener? On the other hand, even if I comment this
|
||||
// code out I can't seem to reproduce the bug it was trying to
|
||||
// fix....
|
||||
nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
|
||||
}
|
||||
|
||||
return nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
|
||||
_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::GetFlags(uint32_t *aFlags)
|
||||
{
|
||||
*aFlags = DOMCLASSINFO_STANDARD_FLAGS | nsIClassInfo::CONTENT_NODE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsNodeSH::PreserveWrapper(nsISupports *aNative)
|
||||
{
|
||||
static_cast<nsINode*>(aNative)->PreserveWrapper(aNative);
|
||||
}
|
||||
|
||||
// EventTarget helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -5137,150 +4935,6 @@ IDBEventTargetSH::PreCreate(nsISupports *aNativeObj, JSContext *aCx,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Element helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
nsresult rv = nsNodeSH::PreCreate(nativeObj, cx, globalObj, parentObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
Element *element = static_cast<Element*>(nativeObj);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIContent> content_qi(do_QueryInterface(nativeObj));
|
||||
|
||||
// If this assertion fires the QI implementation for the object in
|
||||
// question doesn't use the nsIContent pointer as the nsISupports
|
||||
// pointer. That must be fixed, or we'll crash...
|
||||
NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIDocument *doc = element->HasFlag(NODE_FORCE_XBL_BINDINGS) ?
|
||||
element->OwnerDoc() :
|
||||
element->GetCurrentDoc();
|
||||
|
||||
if (!doc) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (element->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
|
||||
doc->BindingManager()->GetBinding(element)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mozilla::css::URLValue *bindingURL;
|
||||
bool ok = element->GetBindingURL(doc, &bindingURL);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
// Only allow slim wrappers if there's no binding.
|
||||
if (!bindingURL) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
element->SetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
Element *element = static_cast<Element*>(wrapper->Native());
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIContent> content_qi(do_QueryWrappedNative(wrapper));
|
||||
|
||||
// If this assertion fires the QI implementation for the object in
|
||||
// question doesn't use the nsIContent pointer as the nsISupports
|
||||
// pointer. That must be fixed, or we'll crash...
|
||||
NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIDocument* doc;
|
||||
if (element->HasFlag(NODE_FORCE_XBL_BINDINGS)) {
|
||||
doc = element->OwnerDoc();
|
||||
}
|
||||
else {
|
||||
doc = element->GetCurrentDoc();
|
||||
}
|
||||
|
||||
if (!doc) {
|
||||
// There's no baseclass that cares about this call so we just
|
||||
// return here.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We must ensure that the XBL Binding is installed before we hand
|
||||
// back this object.
|
||||
|
||||
if (!element->HasFlag(NODE_ATTACH_BINDING_ON_POSTCREATE)) {
|
||||
// There's already a binding for this element so nothing left to
|
||||
// be done here.
|
||||
|
||||
// In theory we could call ExecuteAttachedHandler here when it's safe to
|
||||
// run script if we also removed the binding from the PAQ queue, but that
|
||||
// seems like a scary change that would mosly just add more
|
||||
// inconsistencies.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
element->UnsetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
|
||||
|
||||
// Make sure the style context goes away _before_ we load the binding
|
||||
// since that can destroy the relevant presshell.
|
||||
mozilla::css::URLValue *bindingURL;
|
||||
bool ok = element->GetBindingURL(doc, &bindingURL);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
if (!bindingURL) {
|
||||
// No binding, nothing left to do here.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri = bindingURL->GetURI();
|
||||
nsCOMPtr<nsIPrincipal> principal = bindingURL->mOriginPrincipal;
|
||||
|
||||
// We have a binding that must be installed.
|
||||
bool dummy;
|
||||
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
xblService->LoadBindings(element, uri, principal, getter_AddRefs(binding), &dummy);
|
||||
|
||||
if (binding) {
|
||||
if (nsContentUtils::IsSafeToRunScript()) {
|
||||
binding->ExecuteAttachedHandler();
|
||||
}
|
||||
else {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsElementSH::PostTransplant(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
// XBL bindings are reapplied asynchronously when the node is inserted into a
|
||||
// new document and frame construction occurs.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Generic array scriptable helper.
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -5804,158 +5458,6 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
|||
return ::JS_GetUCProperty(cx, self, chars, length, vp);
|
||||
}
|
||||
|
||||
|
||||
// HTMLFormElement helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *aObj, jsid aId,
|
||||
uint32_t flags, JSObject **objp,
|
||||
bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
// For native wrappers, do not resolve random names on form
|
||||
if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
|
||||
(!ObjectIsNativeWrapper(cx, obj) ||
|
||||
xpc::WrapperFactory::XrayWrapperNotShadowing(obj, id))) {
|
||||
nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
|
||||
|
||||
nsDependentJSString name(id);
|
||||
nsWrapperCache* cache;
|
||||
nsCOMPtr<nsISupports> result =
|
||||
static_cast<HTMLFormElement*>(form.get())->FindNamedItem(name, &cache);
|
||||
|
||||
if (result) {
|
||||
*_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nullptr,
|
||||
nullptr, JSPROP_ENUMERATE);
|
||||
|
||||
*objp = obj;
|
||||
|
||||
return *_retval ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *aObj, jsid aId,
|
||||
jsval *vp, bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
|
||||
|
||||
if (JSID_IS_STRING(id)) {
|
||||
// For native wrappers, do not get random names on form
|
||||
nsDependentJSString name(id);
|
||||
nsWrapperCache* cache;
|
||||
nsCOMPtr<nsISupports> result =
|
||||
static_cast<HTMLFormElement*>(form.get())->FindNamedItem(name, &cache);
|
||||
|
||||
if (result) {
|
||||
// Wrap result, result can be either an element or a list of
|
||||
// elements
|
||||
nsresult rv = WrapNative(cx, obj, result, cache, true, vp);
|
||||
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
|
||||
}
|
||||
} else {
|
||||
int32_t n = GetArrayIndexFromId(cx, id);
|
||||
|
||||
if (n >= 0) {
|
||||
nsIFormControl* control = form->GetElementAt(n);
|
||||
|
||||
if (control) {
|
||||
Element *element =
|
||||
static_cast<nsGenericHTMLFormElement*>(form->GetElementAt(n));
|
||||
nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), element,
|
||||
element, true, vp);
|
||||
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLFormElementSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj,
|
||||
uint32_t enum_op, jsval *statep,
|
||||
jsid *idp, bool *_retval)
|
||||
{
|
||||
switch (enum_op) {
|
||||
case JSENUMERATE_INIT:
|
||||
case JSENUMERATE_INIT_ALL:
|
||||
{
|
||||
nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
|
||||
|
||||
if (!form) {
|
||||
*statep = JSVAL_NULL;
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
*statep = INT_TO_JSVAL(0);
|
||||
|
||||
if (idp) {
|
||||
uint32_t count = form->GetElementCount();
|
||||
|
||||
*idp = INT_TO_JSID(count);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
{
|
||||
nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
|
||||
NS_ENSURE_TRUE(form, NS_ERROR_FAILURE);
|
||||
|
||||
int32_t index = (int32_t)JSVAL_TO_INT(*statep);
|
||||
|
||||
uint32_t count = form->GetElementCount();
|
||||
|
||||
if ((uint32_t)index < count) {
|
||||
nsIFormControl* controlNode = form->GetElementAt(index);
|
||||
NS_ENSURE_TRUE(controlNode, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(controlNode);
|
||||
NS_ENSURE_TRUE(domElement, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString attr;
|
||||
domElement->GetAttribute(NS_LITERAL_STRING("name"), attr);
|
||||
if (attr.IsEmpty()) {
|
||||
// If name is not there, use index instead
|
||||
attr.AppendInt(index);
|
||||
}
|
||||
|
||||
JSString *jsname =
|
||||
JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
|
||||
(attr.get()),
|
||||
attr.Length());
|
||||
NS_ENSURE_TRUE(jsname, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS_ValueToId(cx, STRING_TO_JSVAL(jsname), idp);
|
||||
|
||||
*statep = INT_TO_JSVAL(++index);
|
||||
} else {
|
||||
*statep = JSVAL_NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case JSENUMERATE_DESTROY:
|
||||
*statep = JSVAL_NULL;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Plugin helper
|
||||
|
||||
nsISupports*
|
||||
|
|
|
@ -414,67 +414,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// DOM Node helper, this class deals with setting the parent for the
|
||||
// wrappers
|
||||
|
||||
class nsNodeSH : public nsDOMGenericSH
|
||||
{
|
||||
protected:
|
||||
nsNodeSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsNodeSH()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj) MOZ_OVERRIDE;
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, jsval *vp, bool *_retval) MOZ_OVERRIDE;
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, uint32_t flags,
|
||||
JSObject **objp, bool *_retval) MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetFlags(uint32_t *aFlags) MOZ_OVERRIDE;
|
||||
|
||||
virtual void PreserveWrapper(nsISupports *aNative) MOZ_OVERRIDE;
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsNodeSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Element helper
|
||||
|
||||
class nsElementSH : public nsNodeSH
|
||||
{
|
||||
protected:
|
||||
nsElementSH(nsDOMClassInfoData* aData) : nsNodeSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsElementSH()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj) MOZ_OVERRIDE;
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj) MOZ_OVERRIDE;
|
||||
NS_IMETHOD PostTransplant(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj) MOZ_OVERRIDE;
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Generic array scriptable helper
|
||||
|
||||
class nsGenericArraySH : public nsDOMClassInfo
|
||||
|
@ -585,39 +524,6 @@ public:
|
|||
};
|
||||
|
||||
|
||||
// HTMLFormElement helper
|
||||
|
||||
class HTMLFormElementSH : public nsElementSH
|
||||
{
|
||||
protected:
|
||||
HTMLFormElementSH(nsDOMClassInfoData* aData) : nsElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~HTMLFormElementSH()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, uint32_t flags,
|
||||
JSObject **objp, bool *_retval) MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
bool *_retval) MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj,
|
||||
uint32_t enum_op, jsval *statep,
|
||||
jsid *idp, bool *_retval) MOZ_OVERRIDE;
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new HTMLFormElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Plugin helper
|
||||
|
||||
class nsPluginSH : public nsNamedArraySH
|
||||
|
|
|
@ -16,14 +16,10 @@ DOMCI_CLASS(DOMConstructor)
|
|||
|
||||
// Core classes
|
||||
DOMCI_CLASS(DOMException)
|
||||
DOMCI_CLASS(Element)
|
||||
|
||||
DOMCI_CLASS(DeviceAcceleration)
|
||||
DOMCI_CLASS(DeviceRotationRate)
|
||||
|
||||
// HTML element classes
|
||||
DOMCI_CLASS(HTMLFormElement)
|
||||
|
||||
// CSS classes
|
||||
DOMCI_CLASS(CSSStyleRule)
|
||||
DOMCI_CLASS(CSSCharsetRule)
|
||||
|
|
Загрузка…
Ссылка в новой задаче