Bug 891088 - Rename nsXBLChildrenElement -> mozilla::dom::XBLChildrenElement. r=peterv

--HG--
rename : content/xbl/src/nsXBLChildrenElement.cpp => content/xbl/src/XBLChildrenElement.cpp
rename : content/xbl/src/nsXBLChildrenElement.h => content/xbl/src/XBLChildrenElement.h
This commit is contained in:
Blake Kaplan 2013-07-01 15:09:37 -07:00
parent 70df3b06f7
commit 7f425da3b1
10 changed files with 79 additions and 60 deletions

View File

@ -5,7 +5,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ChildIterator.h"
#include "nsXBLChildrenElement.h"
#include "mozilla/dom/XBLChildrenElement.h"
namespace mozilla {
namespace dom {
@ -19,7 +19,7 @@ ExplicitChildIterator::GetNextChild()
MOZ_ASSERT(mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL));
MOZ_ASSERT(!mDefaultChild);
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(mChild);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
if (mIndexInInserted < point->mInsertedChildren.Length()) {
return point->mInsertedChildren[mIndexInInserted++];
}
@ -46,7 +46,7 @@ ExplicitChildIterator::GetNextChild()
// Iterate until we find a non-<children>, or a <children> with content.
while (mChild &&
mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(mChild);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
if (!point->mInsertedChildren.IsEmpty()) {
mIndexInInserted = 1;
return point->mInsertedChildren[0];
@ -97,7 +97,7 @@ nsIContent* FlattenedChildIterator::Get()
MOZ_ASSERT(!mIsFirst);
if (mIndexInInserted) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(mChild);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
return point->mInsertedChildren[mIndexInInserted - 1];
}
return mDefaultChild ? mDefaultChild : mChild;
@ -109,7 +109,7 @@ nsIContent* FlattenedChildIterator::GetPreviousChild()
if (mIndexInInserted) {
// NB: mIndexInInserted points one past the last returned child so we need
// to look *two* indices back in order to return the previous child.
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(mChild);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
if (--mIndexInInserted) {
return point->mInsertedChildren[mIndexInInserted - 1];
}
@ -133,7 +133,7 @@ nsIContent* FlattenedChildIterator::GetPreviousChild()
// Iterate until we find a non-<children>, or a <children> with content.
while (mChild &&
mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(mChild);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(mChild);
if (!point->mInsertedChildren.IsEmpty()) {
mIndexInInserted = point->InsertedChildrenLength();
return point->mInsertedChildren[mIndexInInserted - 1];

View File

@ -18,7 +18,7 @@
#include "nsDataHashtable.h"
#include "nsString.h"
#include "nsINodeInfo.h"
#include "nsXBLChildrenElement.h"
#include "mozilla/dom/XBLChildrenElement.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -205,7 +205,7 @@ NS_NewElement(nsIContent** aResult,
return NS_NewSVGElement(aResult, aNodeInfo, aFromParser);
}
if (ns == kNameSpaceID_XBL && aNodeInfo.get()->Equals(nsGkAtoms::children)) {
NS_ADDREF(*aResult = new nsXBLChildrenElement(aNodeInfo));
NS_ADDREF(*aResult = new XBLChildrenElement(aNodeInfo));
return NS_OK;
}
return NS_NewXMLElement(aResult, aNodeInfo);

View File

@ -4,40 +4,43 @@
* 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 "nsXBLChildrenElement.h"
#include "mozilla/dom/XBLChildrenElement.h"
#include "nsCharSeparatedTokenizer.h"
#include "mozilla/dom/NodeListBinding.h"
nsXBLChildrenElement::~nsXBLChildrenElement()
namespace mozilla {
namespace dom {
XBLChildrenElement::~XBLChildrenElement()
{
}
NS_IMPL_ADDREF_INHERITED(nsXBLChildrenElement, Element)
NS_IMPL_RELEASE_INHERITED(nsXBLChildrenElement, Element)
NS_IMPL_ADDREF_INHERITED(XBLChildrenElement, Element)
NS_IMPL_RELEASE_INHERITED(XBLChildrenElement, Element)
NS_INTERFACE_TABLE_HEAD(nsXBLChildrenElement)
NS_INTERFACE_TABLE_INHERITED2(nsXBLChildrenElement, nsIDOMNode,
NS_INTERFACE_TABLE_HEAD(XBLChildrenElement)
NS_INTERFACE_TABLE_INHERITED2(XBLChildrenElement, nsIDOMNode,
nsIDOMElement)
NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_MAP_END_INHERITING(Element)
NS_IMPL_ELEMENT_CLONE(nsXBLChildrenElement)
NS_IMPL_ELEMENT_CLONE(XBLChildrenElement)
nsIAtom*
nsXBLChildrenElement::GetIDAttributeName() const
XBLChildrenElement::GetIDAttributeName() const
{
return nullptr;
}
nsIAtom*
nsXBLChildrenElement::DoGetID() const
XBLChildrenElement::DoGetID() const
{
return nullptr;
}
nsresult
nsXBLChildrenElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
XBLChildrenElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
{
if (aAttribute == nsGkAtoms::includes &&
aNameSpaceID == kNameSpaceID_None) {
@ -48,10 +51,10 @@ nsXBLChildrenElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
}
bool
nsXBLChildrenElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
XBLChildrenElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsGkAtoms::includes &&
aNamespaceID == kNameSpaceID_None) {
@ -66,6 +69,11 @@ nsXBLChildrenElement::ParseAttribute(int32_t aNamespaceID,
return false;
}
} // namespace mozilla
} // namespace dom
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsAnonymousContentList, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAnonymousContentList)
@ -94,7 +102,7 @@ nsAnonymousContentList::GetLength(uint32_t* aLength)
child;
child = child->GetNextSibling()) {
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(child);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(child);
if (!point->mInsertedChildren.IsEmpty()) {
count += point->mInsertedChildren.Length();
}
@ -135,7 +143,7 @@ nsAnonymousContentList::Item(uint32_t aIndex)
child;
child = child->GetNextSibling()) {
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(child);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(child);
if (!point->mInsertedChildren.IsEmpty()) {
if (remIndex < point->mInsertedChildren.Length()) {
return point->mInsertedChildren[remIndex];
@ -176,7 +184,7 @@ nsAnonymousContentList::IndexOf(nsIContent* aContent)
child;
child = child->GetNextSibling()) {
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(child);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(child);
if (!point->mInsertedChildren.IsEmpty()) {
uint32_t insIndex = point->mInsertedChildren.IndexOf(aContent);
if (insIndex != point->mInsertedChildren.NoIndex) {

View File

@ -12,26 +12,23 @@
#include "nsBindingManager.h"
#include "mozilla/dom/nsXMLElement.h"
class nsAnonymousContentList;
namespace mozilla {
namespace dom {
class ExplicitChildIterator;
}
}
class nsAnonymousContentList;
class nsXBLChildrenElement : public nsXMLElement
class XBLChildrenElement : public nsXMLElement
{
public:
friend class mozilla::dom::ExplicitChildIterator;
friend class nsAnonymousContentList;
nsXBLChildrenElement(already_AddRefed<nsINodeInfo> aNodeInfo)
XBLChildrenElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsXMLElement(aNodeInfo)
{
}
~nsXBLChildrenElement();
~XBLChildrenElement();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
@ -148,6 +145,9 @@ private:
nsTArray<nsCOMPtr<nsIAtom> > mIncludes;
};
} // namespace dom
} // namespace mozilla
class nsAnonymousContentList : public nsINodeList
{
public:

View File

@ -12,13 +12,16 @@ EXPORTS += [
'nsXBLService.h',
]
EXPORTS.mozilla.dom += [
'XBLChildrenElement.h',
]
CPP_SOURCES += [
'nsBindingManager.cpp',
'nsXBLBinding.cpp',
'nsXBLContentSink.cpp',
'nsXBLDocumentInfo.cpp',
'nsXBLEventHandler.cpp',
'nsXBLChildrenElement.cpp',
'nsXBLProtoImpl.cpp',
'nsXBLProtoImplField.cpp',
'nsXBLProtoImplMethod.cpp',
@ -30,5 +33,6 @@ CPP_SOURCES += [
'nsXBLSerialize.cpp',
'nsXBLService.cpp',
'nsXBLWindowKeyHandler.cpp',
'XBLChildrenElement.cpp',
]

View File

@ -27,7 +27,7 @@
#include "nsXBLBinding.h"
#include "nsXBLPrototypeBinding.h"
#include "nsXBLDocumentInfo.h"
#include "nsXBLChildrenElement.h"
#include "mozilla/dom/XBLChildrenElement.h"
#include "nsIStyleRuleProcessor.h"
#include "nsRuleProcessorData.h"
@ -48,6 +48,7 @@
#include "mozilla/dom/NodeListBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
//
// Generic pldhash table stuff for mapping one nsISupports to another
@ -970,7 +971,7 @@ nsBindingManager::AppendAllSheets(nsTArray<nsCSSStyleSheet*>& aArray)
static void
InsertAppendedContent(nsBindingManager* aManager,
nsXBLChildrenElement* aPoint,
XBLChildrenElement* aPoint,
nsIContent* aFirstNewContent)
{
uint32_t insertionIndex;
@ -1008,7 +1009,7 @@ nsBindingManager::ContentAppended(nsIDocument* aDocument,
}
// Try to find insertion points for all the new kids.
nsXBLChildrenElement* point = nullptr;
XBLChildrenElement* point = nullptr;
nsIContent* parent = aContainer;
bool first = true;
do {
@ -1081,7 +1082,7 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument,
{
SetInsertionParent(aChild, nullptr);
nsXBLChildrenElement* point = nullptr;
XBLChildrenElement* point = nullptr;
nsIContent* parent = aContainer;
do {
nsXBLBinding* binding = GetBindingWithContent(parent);
@ -1118,7 +1119,7 @@ void
nsBindingManager::ClearInsertionPointsRecursively(nsIContent* aContent)
{
if (aContent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
static_cast<nsXBLChildrenElement*>(aContent)->ClearInsertedChildrenAndInsertionParents(this);
static_cast<XBLChildrenElement*>(aContent)->ClearInsertedChildrenAndInsertionParents(this);
}
uint32_t childCount = aContent->GetChildCount();
@ -1211,7 +1212,7 @@ nsBindingManager::HandleChildInsertion(nsIContent* aContainer,
uint32_t(aContainer->IndexOf(aChild)) == aIndexInContainer,
"Child not at the right index?");
nsXBLChildrenElement* point = nullptr;
XBLChildrenElement* point = nullptr;
nsIContent* parent = aContainer;
while (parent) {
nsXBLBinding* binding = GetBindingWithContent(parent);
@ -1263,7 +1264,7 @@ nsBindingManager::FindNestedInsertionPoint(nsIContent* aContainer,
nsIContent* parent = aContainer;
if (aContainer->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
if (static_cast<nsXBLChildrenElement*>(aContainer)->
if (static_cast<XBLChildrenElement*>(aContainer)->
HasInsertedChildren()) {
return nullptr;
}
@ -1276,7 +1277,7 @@ nsBindingManager::FindNestedInsertionPoint(nsIContent* aContainer,
break;
}
nsXBLChildrenElement* point = binding->FindInsertionPointFor(aChild);
XBLChildrenElement* point = binding->FindInsertionPointFor(aChild);
if (!point) {
return nullptr;
}
@ -1299,7 +1300,7 @@ nsBindingManager::FindNestedSingleInsertionPoint(nsIContent* aContainer,
nsIContent* parent = aContainer;
if (aContainer->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
if (static_cast<nsXBLChildrenElement*>(aContainer)->
if (static_cast<XBLChildrenElement*>(aContainer)->
HasInsertedChildren()) {
return nullptr;
}
@ -1317,7 +1318,7 @@ nsBindingManager::FindNestedSingleInsertionPoint(nsIContent* aContainer,
return nullptr;
}
nsXBLChildrenElement* point = binding->GetDefaultInsertionPoint();
XBLChildrenElement* point = binding->GetDefaultInsertionPoint();
if (!point) {
return nullptr;
}

View File

@ -48,7 +48,7 @@
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsGUIEvent.h"
#include "nsXBLChildrenElement.h"
#include "mozilla/dom/XBLChildrenElement.h"
#include "prprf.h"
#include "nsNodeUtils.h"
@ -338,7 +338,7 @@ nsXBLBinding::GenerateAnonymousContent()
// order.
for (nsIContent* child = mContent; child; child = child->GetNextNode(mContent)) {
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
nsXBLChildrenElement* point = static_cast<nsXBLChildrenElement*>(child);
XBLChildrenElement* point = static_cast<XBLChildrenElement*>(child);
if (point->IsDefaultInsertion()) {
mDefaultInsertionPoint = point;
} else {
@ -361,7 +361,7 @@ nsXBLBinding::GenerateAnonymousContent()
} else if (!mInsertionPoints.IsEmpty()) {
ExplicitChildIterator iter(mBoundElement);
for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
nsXBLChildrenElement* point = FindInsertionPointForInternal(child);
XBLChildrenElement* point = FindInsertionPointForInternal(child);
if (point) {
point->AppendInsertedChild(child, bindingManager);
}
@ -404,7 +404,7 @@ nsXBLBinding::GenerateAnonymousContent()
}
}
nsXBLChildrenElement*
XBLChildrenElement*
nsXBLBinding::FindInsertionPointFor(nsIContent* aChild)
{
// XXX We should get rid of this function as it causes us to traverse the
@ -417,11 +417,11 @@ nsXBLBinding::FindInsertionPointFor(nsIContent* aChild)
: nullptr;
}
nsXBLChildrenElement*
XBLChildrenElement*
nsXBLBinding::FindInsertionPointForInternal(nsIContent* aChild)
{
for (uint32_t i = 0; i < mInsertionPoints.Length(); ++i) {
nsXBLChildrenElement* point = mInsertionPoints[i];
XBLChildrenElement* point = mInsertionPoints[i];
if (point->Includes(aChild)) {
return point;
}
@ -681,7 +681,7 @@ nsXBLBinding::UnhookEventHandlers()
static void
UpdateInsertionParent(nsBindingManager* aBindingManager,
nsXBLChildrenElement* aPoint,
XBLChildrenElement* aPoint,
nsIContent* aOldBoundElement)
{
if (aPoint->IsDefaultInsertion()) {

View File

@ -22,7 +22,15 @@ class nsIContent;
class nsIAtom;
class nsIDocument;
class nsIScriptContext;
class nsXBLChildrenElement;
namespace mozilla {
namespace dom {
class XBLChildrenElement;
}
}
class nsAnonymousContentList;
struct JSContext;
class JSObject;
@ -136,14 +144,14 @@ public:
bool AllowScripts(); // XXX make const
nsXBLChildrenElement* FindInsertionPointFor(nsIContent* aChild);
mozilla::dom::XBLChildrenElement* FindInsertionPointFor(nsIContent* aChild);
bool HasFilteredInsertionPoints()
{
return !mInsertionPoints.IsEmpty();
}
nsXBLChildrenElement* GetDefaultInsertionPoint()
mozilla::dom::XBLChildrenElement* GetDefaultInsertionPoint()
{
return mDefaultInsertionPoint;
}
@ -176,11 +184,11 @@ protected:
// attribute. These points must be up-to-date with respect to their parent's
// children, even if their parent has another binding attached to it,
// preventing us from rendering their contents directly.
nsRefPtr<nsXBLChildrenElement> mDefaultInsertionPoint;
nsTArray<nsRefPtr<nsXBLChildrenElement> > mInsertionPoints;
nsRefPtr<mozilla::dom::XBLChildrenElement> mDefaultInsertionPoint;
nsTArray<nsRefPtr<mozilla::dom::XBLChildrenElement> > mInsertionPoints;
nsRefPtr<nsAnonymousContentList> mAnonymousContentList;
nsXBLChildrenElement* FindInsertionPointForInternal(nsIContent* aChild);
mozilla::dom::XBLChildrenElement* FindInsertionPointForInternal(nsIContent* aChild);
};
#endif // nsXBLBinding_h_

View File

@ -70,7 +70,6 @@
#include "nsRuleNode.h"
#include "nsIDOMMutationEvent.h"
#include "ChildIterator.h"
#include "nsXBLChildrenElement.h"
#include "nsCSSRendering.h"
#include "nsError.h"
#include "nsLayoutUtils.h"

View File

@ -61,7 +61,6 @@
#include "mozilla/LookAndFeel.h"
#include "mozilla/Likely.h"
#include "mozilla/Util.h"
#include "nsXBLChildrenElement.h"
using namespace mozilla;
using namespace mozilla::dom;