Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit c68cd30

Browse files
author
Brendan Dahl
committed
Bug 1510785 - Only build XBL related code when MOZ_XBL is defined. r=bzbarsky
When XBL is disabled, no code in dom/xbl will be built. Also, adds ifdefs to remove any of the XBL related code elsewhere. There's definitely more that can be done here, but I think it's better to wait to do the rest of the cleanup when we actually remove the code. Depends on D45612 Differential Revision: https://phabricator.services.mozilla.com/D45613 --HG-- extra : moz-landing-system : lando
1 parent 8f5cb3d commit c68cd30

59 files changed

Lines changed: 421 additions & 73 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

accessible/base/AccIterator.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,16 @@ dom::Element* IDRefsIterator::GetElem(nsIContent* aContent,
264264
aContent->GetUncomposedDocOrConnectedShadowRoot();
265265
if (docOrShadowRoot) {
266266
dom::Element* refElm = docOrShadowRoot->GetElementById(aID);
267-
if (refElm || !aContent->GetXBLBinding()) {
267+
if (refElm
268+
#ifdef MOZ_XBL
269+
|| !aContent->GetXBLBinding()
270+
#endif
271+
)
268272
return refElm;
269-
}
270273
}
271274
}
272275

276+
#ifdef MOZ_XBL
273277
// If content is in anonymous subtree or an element having anonymous subtree
274278
// then use "anonid" attribute to get elements in anonymous subtree.
275279

@@ -288,6 +292,7 @@ dom::Element* IDRefsIterator::GetElem(nsIContent* aContent,
288292
return aContent->OwnerDoc()->GetAnonymousElementByAttribute(
289293
aContent, nsGkAtoms::anonid, aID);
290294
}
295+
#endif
291296

292297
return nullptr;
293298
}

accessible/base/moz.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ LOCAL_INCLUDES += [
8282
'/accessible/xpcom',
8383
'/accessible/xul',
8484
'/dom/base',
85-
'/dom/xbl',
8685
'/ipc/chromium/src',
8786
'/layout/generic',
8887
'/layout/style',
@@ -91,6 +90,9 @@ LOCAL_INCLUDES += [
9190
'/layout/xul/tree/',
9291
]
9392

93+
if CONFIG['MOZ_XBL']:
94+
LOCAL_INCLUDES += ['/dom/xbl']
95+
9496
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
9597
LOCAL_INCLUDES += [
9698
'/accessible/atk',

accessible/base/nsAccessibilityService.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
#include "nsTreeBodyFrame.h"
6666
#include "nsTreeColumns.h"
6767
#include "nsTreeUtils.h"
68-
#include "nsXBLPrototypeBinding.h"
69-
#include "nsXBLBinding.h"
7068
#include "mozilla/ArrayUtils.h"
7169
#include "mozilla/dom/DOMStringList.h"
7270
#include "mozilla/dom/EventTarget.h"

dom/base/BindContext.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#ifndef mozilla_dom_BindContext_h__
1010
#define mozilla_dom_BindContext_h__
1111

12-
#include "nsXBLBinding.h"
12+
#ifdef MOZ_XBL
13+
# include "nsXBLBinding.h"
14+
#endif
1315
#include "mozilla/Attributes.h"
1416
#include "mozilla/AutoRestore.h"
1517
#include "mozilla/dom/Document.h"
@@ -97,6 +99,7 @@ struct MOZ_STACK_CLASS BindContext final {
9799
MOZ_ASSERT(mInComposedDoc, "Binding NAC in a disconnected subtree?");
98100
}
99101

102+
#ifdef MOZ_XBL
100103
// This is meant to be used to bind XBL anonymous content.
101104
BindContext(nsXBLBinding& aBinding, Element& aParentElement)
102105
: mDoc(*aParentElement.OwnerDoc()),
@@ -107,6 +110,7 @@ struct MOZ_STACK_CLASS BindContext final {
107110
mCollectingDisplayedNodeDataDuringLoad(
108111
ShouldCollectDisplayedNodeDataDuringLoad(mInComposedDoc, mDoc,
109112
aParentElement)) {}
113+
#endif
110114

111115
bool CollectingDisplayedNodeDataDuringLoad() const {
112116
return mCollectingDisplayedNodeDataDuringLoad;

dom/base/CharacterData.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#include "nsCOMArray.h"
3030
#include "nsNodeUtils.h"
3131
#include "mozilla/dom/DirectionalityUtils.h"
32-
#include "nsBindingManager.h"
32+
#ifdef MOZ_XBL
33+
# include "nsBindingManager.h"
34+
#endif
3335
#include "nsCCUncollectableMarker.h"
3436
#include "mozAutoDocUpdate.h"
3537
#include "nsTextNode.h"
@@ -513,7 +515,9 @@ void CharacterData::UnbindFromTree(bool aNullParent) {
513515

514516
HandleShadowDOMRelatedRemovalSteps(aNullParent);
515517

518+
#ifdef MOZ_XBL
516519
Document* document = GetComposedDoc();
520+
#endif
517521

518522
if (aNullParent) {
519523
if (IsRootOfNativeAnonymousSubtree()) {
@@ -536,6 +540,7 @@ void CharacterData::UnbindFromTree(bool aNullParent) {
536540
SetSubtreeRootPointer(aNullParent ? this : mParent->SubtreeRoot());
537541
}
538542

543+
#ifdef MOZ_XBL
539544
if (document && !GetContainingShadow()) {
540545
// Notify XBL- & nsIAnonymousContentCreator-generated
541546
// anonymous content that the document is changing.
@@ -546,6 +551,7 @@ void CharacterData::UnbindFromTree(bool aNullParent) {
546551
document->BindingManager(), this, document));
547552
}
548553
}
554+
#endif
549555

550556
nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
551557
if (slots) {

dom/base/CharacterData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ class CharacterData : public nsIContent {
169169
void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override {}
170170
#endif
171171

172+
#ifdef MOZ_XBL
172173
nsXBLBinding* DoGetXBLBinding() const final { return nullptr; }
174+
#endif
173175

174176
bool IsNodeOfType(uint32_t aFlags) const override { return false; }
175177

dom/base/ChildIterator.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include "nsContentUtils.h"
99
#include "mozilla/dom/Document.h"
1010
#include "mozilla/dom/HTMLSlotElement.h"
11-
#include "mozilla/dom/XBLChildrenElement.h"
11+
#ifdef MOZ_XBL
12+
# include "mozilla/dom/XBLChildrenElement.h"
13+
#endif
1214
#include "mozilla/dom/ShadowRoot.h"
1315
#include "nsIAnonymousContentCreator.h"
1416
#include "nsIFrame.h"
@@ -46,13 +48,17 @@ nsIContent* ExplicitChildIterator::GetNextChild() {
4648
return mChild;
4749
}
4850

51+
#ifdef MOZ_XBL
4952
MOZ_ASSERT(mChild->IsActiveChildrenElement());
5053
auto* childrenElement = static_cast<XBLChildrenElement*>(mChild);
5154
if (mIndexInInserted < childrenElement->InsertedChildrenLength()) {
5255
return childrenElement->InsertedChild(mIndexInInserted++);
5356
}
5457
mIndexInInserted = 0;
5558
mChild = mChild->GetNextSibling();
59+
#else
60+
MOZ_ASSERT_UNREACHABLE("This needs to be revisited");
61+
#endif
5662
} else if (mDefaultChild) {
5763
// If we're already in default content, check if there are more nodes there
5864
MOZ_ASSERT(mChild);
@@ -88,6 +94,7 @@ nsIContent* ExplicitChildIterator::GetNextChild() {
8894
// content.
8995
while (mChild) {
9096
if (mChild->IsActiveChildrenElement()) {
97+
#ifdef MOZ_XBL
9198
// If the current child being iterated is a content insertion point
9299
// then the iterator needs to return the nodes distributed into
93100
// the content insertion point.
@@ -108,6 +115,9 @@ nsIContent* ExplicitChildIterator::GetNextChild() {
108115
// If we have an insertion point with no assigned nodes and
109116
// no default content, move on to the next node.
110117
mChild = mChild->GetNextSibling();
118+
#else
119+
MOZ_ASSERT_UNREACHABLE("This needs to be revisited");
120+
#endif
111121
} else {
112122
// mChild is not an insertion point, thus it is the next node to
113123
// return from this iterator.
@@ -134,6 +144,7 @@ void FlattenedChildIterator::Init(bool aIgnoreXBL) {
134144
}
135145
}
136146

147+
#ifdef MOZ_XBL
137148
nsXBLBinding* binding =
138149
mParent->OwnerDoc()->BindingManager()->GetBindingWithContent(mParent);
139150

@@ -142,6 +153,7 @@ void FlattenedChildIterator::Init(bool aIgnoreXBL) {
142153
mParent = binding->GetAnonymousContent();
143154
mXBLInvolved = Some(true);
144155
}
156+
#endif
145157
}
146158

147159
bool FlattenedChildIterator::ComputeWhetherXBLIsInvolved() const {
@@ -199,9 +211,13 @@ nsIContent* ExplicitChildIterator::Get() const {
199211
}
200212

201213
if (mIndexInInserted) {
214+
#ifdef MOZ_XBL
202215
MOZ_ASSERT(mChild->IsActiveChildrenElement());
203216
auto* childrenElement = static_cast<XBLChildrenElement*>(mChild);
204217
return childrenElement->InsertedChild(mIndexInInserted - 1);
218+
#else
219+
MOZ_ASSERT_UNREACHABLE("This needs to be revisited");
220+
#endif
205221
}
206222

207223
return mDefaultChild ? mDefaultChild : mChild;
@@ -224,6 +240,7 @@ nsIContent* ExplicitChildIterator::GetPreviousChild() {
224240
return mChild;
225241
}
226242

243+
#ifdef MOZ_XBL
227244
// NB: mIndexInInserted points one past the last returned child so we need
228245
// to look *two* indices back in order to return the previous child.
229246
MOZ_ASSERT(mChild->IsActiveChildrenElement());
@@ -232,6 +249,9 @@ nsIContent* ExplicitChildIterator::GetPreviousChild() {
232249
return childrenElement->InsertedChild(mIndexInInserted - 1);
233250
}
234251
mChild = mChild->GetPreviousSibling();
252+
#else
253+
MOZ_ASSERT_UNREACHABLE("This needs to be revisited");
254+
#endif
235255
} else if (mDefaultChild) {
236256
// If we're already in default content, check if there are more nodes there
237257
mDefaultChild = mDefaultChild->GetPreviousSibling();
@@ -264,6 +284,7 @@ nsIContent* ExplicitChildIterator::GetPreviousChild() {
264284
// content.
265285
while (mChild) {
266286
if (mChild->IsActiveChildrenElement()) {
287+
#ifdef MOZ_XBL
267288
// If the current child being iterated is a content insertion point
268289
// then the iterator needs to return the nodes distributed into
269290
// the content insertion point.
@@ -279,6 +300,9 @@ nsIContent* ExplicitChildIterator::GetPreviousChild() {
279300
}
280301

281302
mChild = mChild->GetPreviousSibling();
303+
#else
304+
MOZ_ASSERT_UNREACHABLE("This needs to be revisited");
305+
#endif
282306
} else {
283307
// mChild is not an insertion point, thus it is the next node to
284308
// return from this iterator.

0 commit comments

Comments
 (0)