From b1edbf02d09326093c10503c4751c1e0fff83342 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 10 Oct 2012 22:04:42 +0300 Subject: [PATCH] Bug 733305, add a way to hide XBL, r=bz, a=bbajaj --- content/base/public/nsIContent.h | 16 +++++--- content/base/public/nsINode.h | 20 +++++++-- content/base/src/FragmentOrElement.cpp | 41 ++++++++++--------- content/base/src/nsContentUtils.cpp | 2 +- content/base/src/nsDOMMutationObserver.cpp | 10 ++--- content/base/src/nsDocument.cpp | 6 +-- content/base/src/nsGenericDOMDataNode.cpp | 3 ++ content/base/src/nsGenericElement.cpp | 9 +++- content/base/src/nsGkAtomList.h | 1 + content/events/src/nsDOMMouseEvent.cpp | 4 +- content/events/src/nsDOMUIEvent.cpp | 2 +- content/events/src/nsEventDispatcher.cpp | 2 +- content/events/src/nsEventStateManager.cpp | 4 +- content/xbl/src/nsXBLBinding.cpp | 14 +++++-- content/xbl/src/nsXBLBinding.h | 3 +- content/xbl/src/nsXBLPrototypeBinding.cpp | 12 ++++++ content/xbl/src/nsXBLPrototypeBinding.h | 4 ++ content/xbl/src/nsXBLSerialize.h | 3 ++ dom/base/nsDOMClassInfo.cpp | 4 +- .../libeditor/base/nsEditorEventListener.cpp | 4 +- embedding/components/find/src/nsFind.cpp | 4 +- layout/base/nsPresShell.cpp | 2 +- layout/xul/base/src/nsResizerFrame.cpp | 4 +- .../mozapps/plugins/content/pluginProblem.xml | 2 +- 24 files changed, 116 insertions(+), 60 deletions(-) diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 39eb74f08196..139b35b99d8a 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -35,8 +35,8 @@ enum nsLinkState { // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x98fb308d, 0xc6dd, 0x4c6d, \ - { 0xb7, 0x7c, 0x91, 0x18, 0x0c, 0xf0, 0x6f, 0x23 } } +{ 0xe2985850, 0x81ca, 0x4b5d, \ + { 0xb0, 0xf3, 0xe3, 0x95, 0xd5, 0x0d, 0x85, 0x64 } } /** * A node of content in a document's content model. This interface @@ -177,6 +177,12 @@ public: return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT); } + bool IsRootOfChromeAccessOnlySubtree() const + { + return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT | + NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS); + } + /** * Makes this content anonymous * @see nsIAnonymousContentCreator @@ -188,10 +194,10 @@ public: } /** - * Returns |this| if it is not native anonymous, otherwise - * first non native anonymous ancestor. + * Returns |this| if it is not chrome-only/native anonymous, otherwise + * first non chrome-only/native anonymous ancestor. */ - virtual nsIContent* FindFirstNonNativeAnonymous() const; + virtual nsIContent* FindFirstNonChromeOnlyAccessContent() const; /** * Returns true if and only if this node has a parent, but is not in diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index c8a633d19ce3..5e8f41f3b54e 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -155,8 +155,12 @@ enum { NODE_ALL_DIRECTION_FLAGS = NODE_HAS_DIRECTION_LTR | NODE_HAS_DIRECTION_RTL, + NODE_CHROME_ONLY_ACCESS = NODE_FLAG_BIT(22), + + NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS = NODE_FLAG_BIT(23), + // Remaining bits are node type specific. - NODE_TYPE_SPECIFIC_BITS_OFFSET = 22 + NODE_TYPE_SPECIFIC_BITS_OFFSET = 24 }; /** @@ -239,8 +243,8 @@ private: // IID for the nsINode interface #define NS_INODE_IID \ -{ 0xf73e3890, 0xe4ab, 0x453e, \ - { 0x8c, 0x78, 0x2d, 0x1f, 0xa4, 0x0b, 0x48, 0x00 } } +{ 0x9aede57e, 0xe39e, 0x42e8, \ + { 0x8d, 0x33, 0x7a, 0xc3, 0xd0, 0xbb, 0x5b, 0xf9 } } /** * An internal interface that abstracts some DOMNode-related parts that both @@ -911,7 +915,8 @@ public: NODE_IS_IN_ANONYMOUS_SUBTREE | NODE_ATTACH_BINDING_ON_POSTCREATE | NODE_DESCENDANTS_NEED_FRAMES | - NODE_NEEDS_FRAME)) || + NODE_NEEDS_FRAME | + NODE_CHROME_ONLY_ACCESS)) || IsNodeOfType(eCONTENT), "Flag only permitted on nsIContent nodes"); mFlags |= aFlagsToSet; @@ -962,6 +967,13 @@ public: #endif } + // True for native anonymous content and for XBL content if the binging + // has chromeOnlyContent="true". + bool ChromeOnlyAccess() const + { + return HasFlag(NODE_IS_IN_ANONYMOUS_SUBTREE | NODE_CHROME_ONLY_ACCESS); + } + /** * Returns true if |this| node is the common ancestor of the start/end * nodes of a Range in a Selection or a descendant of such a common ancestor. diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index cea941caac08..fd312f21b5be 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -135,12 +135,12 @@ bool nsIContent::sTabFocusModelAppliesToXUL = false; uint32_t nsMutationGuard::sMutationCount = 0; nsIContent* -nsIContent::FindFirstNonNativeAnonymous() const +nsIContent::FindFirstNonChromeOnlyAccessContent() const { // This handles also nested native anonymous content. for (const nsIContent *content = this; content; content = content->GetBindingParent()) { - if (!content->IsInNativeAnonymousSubtree()) { + if (!content->ChromeOnlyAccess()) { // Oops, this function signature allows casting const to // non-const. (Then again, so does GetChildAt(0)->GetParent().) return const_cast(content); @@ -851,12 +851,12 @@ FragmentOrElement::GetChildren(uint32_t aFilter) } static nsIContent* -FindNativeAnonymousSubtreeOwner(nsIContent* aContent) +FindChromeAccessOnlySubtreeOwner(nsIContent* aContent) { - if (aContent->IsInNativeAnonymousSubtree()) { - bool isNativeAnon = false; - while (aContent && !isNativeAnon) { - isNativeAnon = aContent->IsRootOfNativeAnonymousSubtree(); + if (aContent->ChromeOnlyAccess()) { + bool chromeAccessOnly = false; + while (aContent && !chromeAccessOnly) { + chromeAccessOnly = aContent->IsRootOfChromeAccessOnlySubtree(); aContent = aContent->GetParent(); } } @@ -871,15 +871,15 @@ nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor) aVisitor.mMayHaveListenerManager = HasListenerManager(); // Don't propagate mouseover and mouseout events when mouse is moving - // inside native anonymous content. - bool isAnonForEvents = IsRootOfNativeAnonymousSubtree(); + // inside chrome access only content. + bool isAnonForEvents = IsRootOfChromeAccessOnlySubtree(); if ((aVisitor.mEvent->message == NS_MOUSE_ENTER_SYNTH || aVisitor.mEvent->message == NS_MOUSE_EXIT_SYNTH) && // Check if we should stop event propagation when event has just been // dispatched or when we're about to propagate from - // native anonymous subtree. + // chrome access only subtree. ((this == aVisitor.mEvent->originalTarget && - !IsInNativeAnonymousSubtree()) || isAnonForEvents)) { + !ChromeOnlyAccess()) || isAnonForEvents)) { nsCOMPtr relatedTarget = do_QueryInterface(static_cast (aVisitor.mEvent)->relatedTarget); @@ -894,19 +894,19 @@ nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor) if (isAnonForEvents || aVisitor.mRelatedTargetIsInAnon || (aVisitor.mEvent->originalTarget == this && (aVisitor.mRelatedTargetIsInAnon = - relatedTarget->IsInNativeAnonymousSubtree()))) { - nsIContent* anonOwner = FindNativeAnonymousSubtreeOwner(this); + relatedTarget->ChromeOnlyAccess()))) { + nsIContent* anonOwner = FindChromeAccessOnlySubtreeOwner(this); if (anonOwner) { nsIContent* anonOwnerRelated = - FindNativeAnonymousSubtreeOwner(relatedTarget); + FindChromeAccessOnlySubtreeOwner(relatedTarget); if (anonOwnerRelated) { // Note, anonOwnerRelated may still be inside some other // native anonymous subtree. The case where anonOwner is still // inside native anonymous subtree will be handled when event // propagates up in the DOM tree. while (anonOwner != anonOwnerRelated && - anonOwnerRelated->IsInNativeAnonymousSubtree()) { - anonOwnerRelated = FindNativeAnonymousSubtreeOwner(anonOwnerRelated); + anonOwnerRelated->ChromeOnlyAccess()) { + anonOwnerRelated = FindChromeAccessOnlySubtreeOwner(anonOwnerRelated); } if (anonOwner == anonOwnerRelated) { #ifdef DEBUG_smaug @@ -927,13 +927,14 @@ nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor) NS_ConvertUTF16toUTF8(ct).get(), isAnonForEvents ? "(is native anonymous)" - : (IsInNativeAnonymousSubtree() + : (ChromeOnlyAccess() ? "(is in native anonymous subtree)" : ""), NS_ConvertUTF16toUTF8(rt).get(), - relatedTarget->IsInNativeAnonymousSubtree() + relatedTarget->ChromeOnlyAccess() ? "(is in native anonymous subtree)" : "", - (originalTarget && relatedTarget->FindFirstNonNativeAnonymous() == - originalTarget->FindFirstNonNativeAnonymous()) + (originalTarget && + relatedTarget->FindFirstNonChromeOnlyAccessContent() == + originalTarget->FindFirstNonChromeOnlyAccessContent()) ? "" : "Wrong event propagation!?!\n"); #endif aVisitor.mParentTarget = nullptr; diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 9a92ffe63504..c449a58ef0cf 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -3840,7 +3840,7 @@ nsContentUtils::HasMutationListeners(nsINode* aNode, } if (aNode->IsNodeOfType(nsINode::eCONTENT) && - static_cast(aNode)->IsInNativeAnonymousSubtree()) { + static_cast(aNode)->ChromeOnlyAccess()) { return false; } diff --git a/content/base/src/nsDOMMutationObserver.cpp b/content/base/src/nsDOMMutationObserver.cpp index 052b7f8fbeeb..964644160e63 100644 --- a/content/base/src/nsDOMMutationObserver.cpp +++ b/content/base/src/nsDOMMutationObserver.cpp @@ -176,7 +176,7 @@ nsMutationReceiver::AttributeWillChange(nsIDocument* aDocument, { if (nsAutoMutationBatch::IsBatching() || !ObservesAttr(aElement, aNameSpaceID, aAttribute) || - aElement->IsInNativeAnonymousSubtree()) { + aElement->ChromeOnlyAccess()) { return; } @@ -213,7 +213,7 @@ nsMutationReceiver::CharacterDataWillChange(nsIDocument *aDocument, { if (nsAutoMutationBatch::IsBatching() || !CharacterData() || !(Subtree() || aContent == Target()) || - aContent->IsInNativeAnonymousSubtree()) { + aContent->ChromeOnlyAccess()) { return; } @@ -239,7 +239,7 @@ nsMutationReceiver::ContentAppended(nsIDocument* aDocument, { nsINode* parent = NODE_FROM(aContainer, aDocument); bool wantsChildList = ChildList() && (Subtree() || parent == Target()); - if (!wantsChildList || aFirstNewContent->IsInNativeAnonymousSubtree()) { + if (!wantsChildList || aFirstNewContent->ChromeOnlyAccess()) { return; } @@ -277,7 +277,7 @@ nsMutationReceiver::ContentInserted(nsIDocument* aDocument, { nsINode* parent = NODE_FROM(aContainer, aDocument); bool wantsChildList = ChildList() && (Subtree() || parent == Target()); - if (!wantsChildList || aChild->IsInNativeAnonymousSubtree()) { + if (!wantsChildList || aChild->ChromeOnlyAccess()) { return; } @@ -308,7 +308,7 @@ nsMutationReceiver::ContentRemoved(nsIDocument* aDocument, int32_t aIndexInContainer, nsIContent* aPreviousSibling) { - if (aChild->IsInNativeAnonymousSubtree()) { + if (aChild->ChromeOnlyAccess()) { return; } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index d79cbf8020c6..8dd642d595e9 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2859,8 +2859,8 @@ nsDocument::GetActiveElement(nsIDOMElement **aElement) getter_AddRefs(focusedWindow)); // be safe and make sure the element is from this document if (focusedContent && focusedContent->OwnerDoc() == this) { - if (focusedContent->IsInNativeAnonymousSubtree()) { - focusedContent = focusedContent->FindFirstNonNativeAnonymous(); + if (focusedContent->ChromeOnlyAccess()) { + focusedContent = focusedContent->FindFirstNonChromeOnlyAccessContent(); } if (focusedContent) { CallQueryInterface(focusedContent, aElement); @@ -7583,7 +7583,7 @@ nsDocument::MutationEventDispatched(nsINode* aTarget) for (int32_t i = 0; i < count; ++i) { nsINode* possibleTarget = mSubtreeModifiedTargets[i]; nsCOMPtr content = do_QueryInterface(possibleTarget); - if (content && content->IsInNativeAnonymousSubtree()) { + if (content && content->ChromeOnlyAccess()) { continue; } diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 98103101ca42..51d505e1b260 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -467,6 +467,9 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent, if (aParent->IsInNativeAnonymousSubtree()) { SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE); } + if (aParent->HasFlag(NODE_CHROME_ONLY_ACCESS)) { + SetFlags(NODE_CHROME_ONLY_ACCESS); + } } // Set parent diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 82b9468464f7..a5aa31abb143 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1300,8 +1300,13 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, (aParent && aParent->IsInNativeAnonymousSubtree()), "Trying to re-bind content from native anonymous subtree to " "non-native anonymous parent!"); - if (aParent && aParent->IsInNativeAnonymousSubtree()) { - SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE); + if (aParent) { + if (aParent->IsInNativeAnonymousSubtree()) { + SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE); + } + if (aParent->HasFlag(NODE_CHROME_ONLY_ACCESS)) { + SetFlags(NODE_CHROME_ONLY_ACCESS); + } } bool hadForceXBL = HasFlag(NODE_FORCE_XBL_BINDINGS); diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 464b885523e6..2c6ecf8cb93a 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -172,6 +172,7 @@ GK_ATOM(child, "child") GK_ATOM(children, "children") GK_ATOM(choose, "choose") GK_ATOM(chromemargin, "chromemargin") +GK_ATOM(chromeOnlyContent, "chromeOnlyContent") GK_ATOM(circ, "circ") GK_ATOM(circle, "circle") GK_ATOM(cite, "cite") diff --git a/content/events/src/nsDOMMouseEvent.cpp b/content/events/src/nsDOMMouseEvent.cpp index 40d143a229aa..caf875c69df0 100644 --- a/content/events/src/nsDOMMouseEvent.cpp +++ b/content/events/src/nsDOMMouseEvent.cpp @@ -261,9 +261,9 @@ nsDOMMouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget) if (relatedTarget) { nsCOMPtr content = do_QueryInterface(relatedTarget); - if (content && content->IsInNativeAnonymousSubtree() && + if (content && content->ChromeOnlyAccess() && !nsContentUtils::CanAccessNativeAnon()) { - relatedTarget = content->FindFirstNonNativeAnonymous(); + relatedTarget = content->FindFirstNonChromeOnlyAccessContent(); if (!relatedTarget) { return NS_OK; } diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp index 39bb54d41ab4..d9014b3c8a6d 100644 --- a/content/events/src/nsDOMUIEvent.cpp +++ b/content/events/src/nsDOMUIEvent.cpp @@ -254,7 +254,7 @@ nsDOMUIEvent::GetRangeParent(nsIDOMNode** aRangeParent) targetFrame); nsCOMPtr parent = targetFrame->GetContentOffsetsFromPoint(pt).content; if (parent) { - if (parent->IsInNativeAnonymousSubtree() && + if (parent->ChromeOnlyAccess() && !nsContentUtils::CanAccessNativeAnon()) { return NS_OK; } diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index 6915e704b3bc..02c1a0637983 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -468,7 +468,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, nsCOMPtr content = do_QueryInterface(target); if (content && content->IsInNativeAnonymousSubtree()) { nsCOMPtr newTarget = - do_QueryInterface(content->FindFirstNonNativeAnonymous()); + do_QueryInterface(content->FindFirstNonChromeOnlyAccessContent()); NS_ENSURE_STATE(newTarget); aEvent->originalTarget = target; diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 53a49240333a..bc55d3d6360f 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -3945,7 +3945,7 @@ public: aTarget ? aTarget->OwnerDoc()->GetInnerWindow() : nullptr; if (win && win->HasMouseEnterLeaveEventListeners()) { mRelatedTarget = aRelatedTarget ? - aRelatedTarget->FindFirstNonNativeAnonymous() : nullptr; + aRelatedTarget->FindFirstNonChromeOnlyAccessContent() : nullptr; nsINode* commonParent = nullptr; if (aTarget && aRelatedTarget) { commonParent = @@ -3954,7 +3954,7 @@ public: nsIContent* current = aTarget; // Note, it is ok if commonParent is null! while (current && current != commonParent) { - if (!current->IsInNativeAnonymousSubtree()) { + if (!current->ChromeOnlyAccess()) { mTargets.AppendObject(current); } // mouseenter/leave is fired only on elements. diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index b18a82a0dd8e..4faed17a9f1f 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -465,7 +465,8 @@ nsXBLBinding::SetBaseBinding(nsXBLBinding* aBinding) } void -nsXBLBinding::InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement) +nsXBLBinding::InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement, + bool aChromeOnlyContent) { // We need to ensure two things. // (1) The anonymous content should be fooled into thinking it's in the bound @@ -484,6 +485,10 @@ nsXBLBinding::InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElem child; child = child->GetNextSibling()) { child->UnbindFromTree(); + if (aChromeOnlyContent) { + child->SetFlags(NODE_CHROME_ONLY_ACCESS | + NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS); + } nsresult rv = child->BindToTree(doc, aElement, mBoundElement, allowScripts); if (NS_FAILED(rv)) { @@ -693,7 +698,9 @@ RealizeDefaultContent(nsISupports* aKey, // Now that we have the cloned content, install the default content as // if it were additional anonymous content. nsCOMPtr clonedContent(do_QueryInterface(clonedNode)); - binding->InstallAnonymousContent(clonedContent, insParent); + binding->InstallAnonymousContent(clonedContent, insParent, + binding->PrototypeBinding()-> + ChromeOnlyContent()); // Cache the clone so that it can be properly destroyed if/when our // other anonymous content is destroyed. @@ -805,7 +812,8 @@ nsXBLBinding::GenerateAnonymousContent() nodesWithProperties, getter_AddRefs(clonedNode)); mContent = do_QueryInterface(clonedNode); - InstallAnonymousContent(mContent, mBoundElement); + InstallAnonymousContent(mContent, mBoundElement, + mPrototypeBinding->ChromeOnlyContent()); if (hasInsertionPoints) { // Now check and see if we have a single insertion point diff --git a/content/xbl/src/nsXBLBinding.h b/content/xbl/src/nsXBLBinding.h index 7d6b99552458..0a3d4d6bdbb1 100644 --- a/content/xbl/src/nsXBLBinding.h +++ b/content/xbl/src/nsXBLBinding.h @@ -69,7 +69,8 @@ public: bool ImplementsInterface(REFNSIID aIID) const; void GenerateAnonymousContent(); - void InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement); + void InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement, + bool aNativeAnon); static void UninstallAnonymousContent(nsIDocument* aDocument, nsIContent* aAnonParent); void InstallEventHandlers(); diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index 95deff6d878f..dfac4effa9af 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -274,6 +274,7 @@ nsXBLPrototypeBinding::nsXBLPrototypeBinding() mInheritStyle(true), mCheckedBaseProto(false), mKeyHandlersRegistered(false), + mChromeOnlyContent(false), mResources(nullptr), mAttributeTable(nullptr), mInsertionPointTable(nullptr), @@ -442,6 +443,11 @@ nsXBLPrototypeBinding::SetBindingElement(nsIContent* aElement) if (mBinding->AttrValueIs(kNameSpaceID_None, nsGkAtoms::inheritstyle, nsGkAtoms::_false, eCaseMatters)) mInheritStyle = false; + + mChromeOnlyContent = IsChrome() && + mBinding->AttrValueIs(kNameSpaceID_None, + nsGkAtoms::chromeOnlyContent, + nsGkAtoms::_true, eCaseMatters); } bool @@ -1466,6 +1472,8 @@ nsXBLPrototypeBinding::Read(nsIObjectInputStream* aStream, uint8_t aFlags) { mInheritStyle = (aFlags & XBLBinding_Serialize_InheritStyle) ? true : false; + mChromeOnlyContent = + (aFlags & XBLBinding_Serialize_ChromeOnlyContent) ? true : false; // nsXBLContentSink::ConstructBinding doesn't create a binding with an empty // id, so we don't here either. @@ -1676,6 +1684,10 @@ nsXBLPrototypeBinding::Write(nsIObjectOutputStream* aStream) flags |= XBLBinding_Serialize_IsFirstBinding; } + if (mChromeOnlyContent) { + flags |= XBLBinding_Serialize_ChromeOnlyContent; + } + nsresult rv = aStream->Write8(flags); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xbl/src/nsXBLPrototypeBinding.h b/content/xbl/src/nsXBLPrototypeBinding.h index 5350a3cf948d..13d6526a3084 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.h +++ b/content/xbl/src/nsXBLPrototypeBinding.h @@ -192,6 +192,8 @@ public: * aFlags can contain XBLBinding_Serialize_InheritStyle to indicate that * mInheritStyle flag should be set, and XBLBinding_Serialize_IsFirstBinding * to indicate the first binding in a document. + * XBLBinding_Serialize_ChromeOnlyContent indicates that + * nsXBLPrototypeBinding::mChromeOnlyContent should be true. */ nsresult Read(nsIObjectInputStream* aStream, nsXBLDocumentInfo* aDocInfo, @@ -301,6 +303,7 @@ public: nsIContent* aCopyRoot, nsIContent* aTemplChild); + bool ChromeOnlyContent() { return mChromeOnlyContent; } protected: // Ensure that mAttributeTable has been created. void EnsureAttributeTable(); @@ -332,6 +335,7 @@ protected: bool mInheritStyle; bool mCheckedBaseProto; bool mKeyHandlersRegistered; + bool mChromeOnlyContent; nsXBLPrototypeResources* mResources; // If we have any resources, this will be non-null. diff --git a/content/xbl/src/nsXBLSerialize.h b/content/xbl/src/nsXBLSerialize.h index a7b2c1f477dd..e0855cc73795 100644 --- a/content/xbl/src/nsXBLSerialize.h +++ b/content/xbl/src/nsXBLSerialize.h @@ -25,6 +25,9 @@ typedef uint8_t XBLBindingSerializeDetails; // Set to indicate that nsXBLPrototypeBinding::mInheritStyle should be true #define XBLBinding_Serialize_InheritStyle 2 +// Set to indicate that nsXBLPrototypeBinding::mChromeOnlyContent should be true +#define XBLBinding_Serialize_ChromeOnlyContent 4 + // Appears at the end of the serialized data to indicate that no more bindings // are present for this document. #define XBLBinding_Serialize_NoMoreBindings 0x80 diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 50afeabb5e39..a7779c0be8ff 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -7856,7 +7856,7 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, } // No slim wrappers for a document's scope object. - return node->IsInNativeAnonymousSubtree() ? + return node->ChromeOnlyAccess() ? NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK; } @@ -7868,7 +7868,7 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, nsresult rv = WrapNativeParent(cx, globalObj, native_parent, parentObj); NS_ENSURE_SUCCESS(rv, rv); - return node->IsInNativeAnonymousSubtree() ? + return node->ChromeOnlyAccess() ? NS_SUCCESS_CHROME_ACCESS_ONLY : NS_SUCCESS_ALLOW_SLIM_WRAPPERS; } diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index 582075f5c652..03e147a149aa 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -979,8 +979,8 @@ bool nsEditorEventListener::IsFileControlTextBox() { dom::Element* root = mEditor->GetRoot(); - if (root && root->IsInNativeAnonymousSubtree()) { - nsIContent* parent = root->FindFirstNonNativeAnonymous(); + if (root && root->ChromeOnlyAccess()) { + nsIContent* parent = root->FindFirstNonChromeOnlyAccessContent(); if (parent && parent->IsHTML(nsGkAtoms::input)) { nsCOMPtr formControl = do_QueryInterface(parent); MOZ_ASSERT(formControl); diff --git a/embedding/components/find/src/nsFind.cpp b/embedding/components/find/src/nsFind.cpp index aebc02696b88..49ed52cbddbe 100644 --- a/embedding/components/find/src/nsFind.cpp +++ b/embedding/components/find/src/nsFind.cpp @@ -248,13 +248,13 @@ nsFindContentIterator::Reset() // see if the start node is an anonymous text node inside a text control nsCOMPtr startContent(do_QueryInterface(mStartNode)); if (startContent) { - mStartOuterContent = startContent->FindFirstNonNativeAnonymous(); + mStartOuterContent = startContent->FindFirstNonChromeOnlyAccessContent(); } // see if the end node is an anonymous text node inside a text control nsCOMPtr endContent(do_QueryInterface(mEndNode)); if (endContent) { - mEndOuterContent = endContent->FindFirstNonNativeAnonymous(); + mEndOuterContent = endContent->FindFirstNonChromeOnlyAccessContent(); } // Note: OK to just set up the outer iterator here; if our range has a native diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 27f46e9e58be..64f0cde728e1 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -6749,7 +6749,7 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTarge NS_ENSURE_TRUE(node, false); nsCOMPtr content(do_QueryInterface(node)); if (content) { - nsIContent* nonNative = content->FindFirstNonNativeAnonymous(); + nsIContent* nonNative = content->FindFirstNonChromeOnlyAccessContent(); content = nonNative; } diff --git a/layout/xul/base/src/nsResizerFrame.cpp b/layout/xul/base/src/nsResizerFrame.cpp index aa28157b90dd..a2b718c16fda 100644 --- a/layout/xul/base/src/nsResizerFrame.cpp +++ b/layout/xul/base/src/nsResizerFrame.cpp @@ -349,7 +349,7 @@ nsResizerFrame::GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWi if (!isChromeShell) { // don't allow resizers in content shells, except for the viewport // scrollbar which doesn't have a parent - nsIContent* nonNativeAnon = mContent->FindFirstNonNativeAnonymous(); + nsIContent* nonNativeAnon = mContent->FindFirstNonChromeOnlyAccessContent(); if (!nonNativeAnon || nonNativeAnon->GetParent()) { return nullptr; } @@ -375,7 +375,7 @@ nsResizerFrame::GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWi if (elementid.EqualsLiteral("_parent")) { // return the parent, but skip over native anonymous content nsIContent* parent = mContent->GetParent(); - return parent ? parent->FindFirstNonNativeAnonymous() : nullptr; + return parent ? parent->FindFirstNonChromeOnlyAccessContent() : nullptr; } return aPresShell->GetDocument()->GetElementById(elementid); diff --git a/toolkit/mozapps/plugins/content/pluginProblem.xml b/toolkit/mozapps/plugins/content/pluginProblem.xml index f09c53715cfb..7e2bf2027e18 100644 --- a/toolkit/mozapps/plugins/content/pluginProblem.xml +++ b/toolkit/mozapps/plugins/content/pluginProblem.xml @@ -15,7 +15,7 @@ xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> - +