Make XUL elements really native anonymous b=410119 r=smaug sr+a=sicking

This commit is contained in:
neil@parkwaycc.co.uk 2008-01-04 03:24:41 -08:00
parent 764bd927ef
commit dafb9ad144
10 changed files with 38 additions and 94 deletions

View File

@ -62,43 +62,29 @@ class nsIDocShell;
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0xe0c5d967, 0x2c15, 0x4097, \
{ 0xb0, 0xdc, 0x75, 0xa3, 0xa7, 0xfc, 0xcd, 0x1a } }
// hack to make egcs / gcc 2.95.2 happy
class nsIContent_base : public nsINode {
public:
#ifdef MOZILLA_INTERNAL_API
// If you're using the external API, the only thing you can know about
// nsIContent is that it exists with an IID
nsIContent_base(nsINodeInfo *aNodeInfo)
: nsINode(aNodeInfo)
{
}
#endif
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
};
{ 0xfba9aa39, 0x016e, 0x4d5d, \
{ 0xab, 0x62, 0x22, 0xa1, 0xb8, 0x4a, 0x3c, 0x7b } }
/**
* A node of content in a document's content model. This interface
* is supported by all content objects.
*/
class nsIContent : public nsIContent_base {
class nsIContent : public nsINode {
public:
#ifdef MOZILLA_INTERNAL_API
// If you're using the external API, the only thing you can know about
// nsIContent is that it exists with an IID
nsIContent(nsINodeInfo *aNodeInfo)
: nsIContent_base(aNodeInfo)
: nsINode(aNodeInfo)
{
NS_ASSERTION(aNodeInfo,
"No nsINodeInfo passed to nsIContent, PREPARE TO CRASH!!!");
}
#endif // MOZILLA_INTERNAL_API
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
/**
* Bind this content node to a tree. If this method throws, the caller must
* call UnbindFromTree() on the node. In the typical case of a node being
@ -166,20 +152,13 @@ public:
}
/**
* Returns PR_TRUE if this content is anonymous for event handling.
*/
PRBool IsAnonymousForEvents() const
{
return HasFlag(NODE_IS_ANONYMOUS_FOR_EVENTS);
}
/**
* Set whether this content is anonymous
* This is virtual and non-inlined due to nsXULElement::SetNativeAnonymous
* Makes this content anonymous
* @see nsIAnonymousContentCreator
* @param aAnonymous whether this content is anonymous
*/
virtual void SetNativeAnonymous(PRBool aAnonymous);
void SetNativeAnonymous()
{
SetFlags(NODE_IS_ANONYMOUS);
}
/**
* Get the namespace that this element's tag is defined in

View File

@ -76,33 +76,29 @@ enum {
// NOTE: Should only be used on nsIContent nodes
NODE_IS_ANONYMOUS = 0x00000008U,
// Whether this node is anonymous for events
// NOTE: Should only be used on nsIContent nodes
NODE_IS_ANONYMOUS_FOR_EVENTS = 0x00000010U,
// Whether this node may have a frame
// NOTE: Should only be used on nsIContent nodes
NODE_MAY_HAVE_FRAME = 0x00000020U,
NODE_MAY_HAVE_FRAME = 0x00000010U,
// Forces the XBL code to treat this node as if it were
// in the document and therefore should get bindings attached.
NODE_FORCE_XBL_BINDINGS = 0x00000040U,
NODE_FORCE_XBL_BINDINGS = 0x00000020U,
// Whether a binding manager may have a pointer to this
NODE_MAY_BE_IN_BINDING_MNGR = 0x00000080U,
NODE_MAY_BE_IN_BINDING_MNGR = 0x00000040U,
NODE_IS_EDITABLE = 0x00000100U,
NODE_IS_EDITABLE = 0x00000080U,
// Optimizations to quickly check whether element may have ID, class or style
// attributes. Not all element implementations may use these!
NODE_MAY_HAVE_ID = 0x00000200U,
NODE_MAY_HAVE_CLASS = 0x00000400U,
NODE_MAY_HAVE_STYLE = 0x00000800U,
NODE_MAY_HAVE_ID = 0x00000100U,
NODE_MAY_HAVE_CLASS = 0x00000200U,
NODE_MAY_HAVE_STYLE = 0x00000400U,
NODE_IS_INSERTION_PARENT = 0x00001000U,
NODE_IS_INSERTION_PARENT = 0x00000800U,
// Four bits for the script-type ID
NODE_SCRIPT_TYPE_OFFSET = 13,
NODE_SCRIPT_TYPE_OFFSET = 12,
NODE_SCRIPT_TYPE_SIZE = 4,
@ -127,22 +123,18 @@ inline nsINode* NODE_FROM(C& aContent, D& aDocument)
// IID for the nsINode interface
#define NS_INODE_IID \
{ 0xdfcef311, 0xba28, 0x4600, \
{ 0xbe, 0xff, 0x2f, 0x9d, 0x42, 0x77, 0x07, 0x4e } }
// hack to make egcs / gcc 2.95.2 happy
class nsINode_base : public nsPIDOMEventTarget {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
};
{ 0xcf677826, 0xd7f1, 0x4ec5, \
{ 0xbf, 0x3a, 0xd4, 0x18, 0x11, 0xac, 0x58, 0x46 } }
/**
* An internal interface that abstracts some DOMNode-related parts that both
* nsIContent and nsIDocument share. An instance of this interface has a list
* of nsIContent children and provides access to them.
*/
class nsINode : public nsINode_base {
class nsINode : public nsPIDOMEventTarget {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
friend class nsNodeUtils;
friend class nsNodeWeakReference;
friend class nsNodeSupportsWeakRefTearoff;
@ -711,6 +703,6 @@ protected:
PtrBits mFlagsOrSlots;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsINode_base, NS_INODE_IID)
NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID)
#endif /* nsINode_h___ */

View File

@ -5801,7 +5801,7 @@ nsDocument::MutationEventDispatched(nsINode* aTarget)
for (PRInt32 i = 0; i < count; ++i) {
nsINode* possibleTarget = mSubtreeModifiedTargets[i];
nsCOMPtr<nsIContent> content = do_QueryInterface(possibleTarget);
if (content && content->IsAnonymousForEvents()) {
if (content && content->IsNativeAnonymous()) {
if (realTargets.IndexOf(possibleTarget) == -1) {
realTargets.AppendObject(possibleTarget);
}

View File

@ -349,18 +349,6 @@ nsINode::IsEditableInternal() const
//----------------------------------------------------------------------
void
nsIContent::SetNativeAnonymous(PRBool aAnonymous)
{
if (aAnonymous) {
SetFlags(NODE_IS_ANONYMOUS);
SetFlags(NODE_IS_ANONYMOUS_FOR_EVENTS);
} else {
UnsetFlags(NODE_IS_ANONYMOUS);
UnsetFlags(NODE_IS_ANONYMOUS_FOR_EVENTS);
}
}
PRInt32
nsIContent::IntrinsicState() const
{
@ -2185,7 +2173,7 @@ nsGenericElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
static nsIContent*
FindFirstNonAnonContent(nsIContent* aContent)
{
while (aContent && aContent->IsAnonymousForEvents()) {
while (aContent && aContent->IsNativeAnonymous()) {
aContent = aContent->GetParent();
}
return aContent;
@ -2194,7 +2182,7 @@ FindFirstNonAnonContent(nsIContent* aContent)
static PRBool
IsInAnonContent(nsIContent* aContent)
{
while (aContent && !aContent->IsAnonymousForEvents()) {
while (aContent && !aContent->IsNativeAnonymous()) {
aContent = aContent->GetParent();
}
return !!aContent;
@ -2209,7 +2197,7 @@ nsGenericElement::doPreHandleEvent(nsIContent* aContent,
// Don't propagate mouseover and mouseout events when mouse is moving
// inside native anonymous content.
PRBool isAnonForEvents = aContent->IsAnonymousForEvents();
PRBool isAnonForEvents = aContent->IsNativeAnonymous();
if (aVisitor.mEvent->message == NS_MOUSE_ENTER_SYNTH ||
aVisitor.mEvent->message == NS_MOUSE_EXIT_SYNTH) {
nsCOMPtr<nsIContent> relatedTarget =

View File

@ -832,22 +832,6 @@ nsXULElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
nsGenericElement::UnbindFromTree(aDeep, aNullParent);
}
void
nsXULElement::SetNativeAnonymous(PRBool aAnonymous)
{
// XXX Workaround for bug 280541, wallpaper for bug 326644
if (NodeInfo()->Equals(nsGkAtoms::popupgroup)) {
nsGenericElement::SetNativeAnonymous(aAnonymous);
} else {
// We still want to set the anonymous bit for events.
if (aAnonymous) {
SetFlags(NODE_IS_ANONYMOUS_FOR_EVENTS);
} else {
UnsetFlags(NODE_IS_ANONYMOUS_FOR_EVENTS);
}
}
}
PRUint32
nsXULElement::GetChildCount() const
{

View File

@ -547,7 +547,6 @@ public:
// nsIContent
virtual void UnbindFromTree(PRBool aDeep, PRBool aNullParent);
virtual void SetNativeAnonymous(PRBool aAnonymous);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual nsIAtom *GetIDAttributeName() const;
virtual nsIAtom *GetClassAttributeName() const;

View File

@ -152,7 +152,7 @@ nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode * aPare
}
// establish parenthood of the element
newContent->SetNativeAnonymous(PR_TRUE);
newContent->SetNativeAnonymous();
res = newContent->BindToTree(doc, parentContent, newContent, PR_TRUE);
if (NS_FAILED(res)) {
newContent->UnbindFromTree();

View File

@ -1947,7 +1947,7 @@ nsCSSFrameConstructor::CreateAttributeContent(nsIContent* aParentContent,
getter_AddRefs(content));
NS_ENSURE_SUCCESS(rv, rv);
content->SetNativeAnonymous(PR_TRUE);
content->SetNativeAnonymous();
// Set aContent as the parent content so that event handling works.
rv = content->BindToTree(mDocument, aParentContent, content, PR_TRUE);
@ -2016,7 +2016,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
data.mContent.mImage);
NS_ENSURE_SUCCESS(rv, rv);
content->SetNativeAnonymous(PR_TRUE);
content->SetNativeAnonymous();
// Set aContent as the parent content and set the document object. This
// way event handling works
@ -2200,7 +2200,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
NS_ASSERTION(*textPtr, "must implement nsIDOMCharacterData");
}
textContent->SetNativeAnonymous(PR_TRUE);
textContent->SetNativeAnonymous();
// Set aContent as the parent content so that event handling works.
nsresult rv = textContent->BindToTree(mDocument, aContent, textContent,
@ -5735,7 +5735,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
nsIContent* content = newAnonymousItems[i];
NS_ASSERTION(content, "null anonymous content?");
content->SetNativeAnonymous(PR_TRUE);
content->SetNativeAnonymous();
nsIContent* bindingParent = content;
#ifdef MOZ_SVG

View File

@ -1690,7 +1690,7 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
// Set the div native anonymous, so CSS will be its style language
// no matter what.
mAnonymousDiv->SetNativeAnonymous(PR_TRUE);
mAnonymousDiv->SetNativeAnonymous();
// Set the necessary style attributes on the text control.

View File

@ -69,6 +69,8 @@ function is(left, right, message) {
function eventOccured(event)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (gPopupTests.length <= gTestIndex) {
ok(false, "Extra " + event.type + " event fired");
return;