Skip to content

Commit dce19eb

Browse files
committedNov 15, 2024
Bug 1931517. Rename confusing IDTracker methods. r=emilio
Some of the Reset* methods are named ResetTo* and some are named ResetWith*. That seems to imply some sort of difference which simply doesn't exist. This commit renames them to all use ResetTo* to avoid that. Furthermore, the inconsistency in naming terminology between ResetToURIFragmentID and ResetWithLocalRef makes it less than clear that the latter is exactly the same as the former, but with only the fragment identifier being specified. This commit better aligns the naming terminology for clarity. Differential Revision: https://phabricator.services.mozilla.com/D229118
1 parent 2f036b2 commit dce19eb

7 files changed

+29
-26
lines changed
 

‎dom/base/IDTracker.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ IDTracker::IDTracker() = default;
5555

5656
IDTracker::~IDTracker() { Unlink(); }
5757

58-
void IDTracker::ResetToURIFragmentID(nsIContent* aFromContent, nsIURI* aURI,
59-
nsIReferrerInfo* aReferrerInfo,
60-
bool aWatch, bool aReferenceImage) {
58+
void IDTracker::ResetToURIWithFragmentID(nsIContent* aFromContent, nsIURI* aURI,
59+
nsIReferrerInfo* aReferrerInfo,
60+
bool aWatch, bool aReferenceImage) {
6161
MOZ_ASSERT(aFromContent,
62-
"ResetToURIFragmentID() expects non-null content pointer");
62+
"ResetToURIWithFragmentID() expects non-null content pointer");
6363

6464
Unlink();
6565

@@ -128,8 +128,9 @@ void IDTracker::ResetToURIFragmentID(nsIContent* aFromContent, nsIURI* aURI,
128128
HaveNewDocumentOrShadowRoot(docOrShadow, aWatch, ref);
129129
}
130130

131-
void IDTracker::ResetWithLocalRef(Element& aFrom, const nsAString& aLocalRef,
132-
bool aWatch) {
131+
void IDTracker::ResetToLocalFragmentID(Element& aFrom,
132+
const nsAString& aLocalRef,
133+
bool aWatch) {
133134
MOZ_ASSERT(nsContentUtils::IsLocalRefURL(aLocalRef));
134135

135136
auto ref = Substring(aLocalRef, 1);
@@ -156,10 +157,10 @@ void IDTracker::ResetWithLocalRef(Element& aFrom, const nsAString& aLocalRef,
156157
}
157158

158159
RefPtr<nsAtom> idAtom = NS_Atomize(unescaped);
159-
ResetWithID(aFrom, idAtom, aWatch);
160+
ResetToID(aFrom, idAtom, aWatch);
160161
}
161162

162-
void IDTracker::ResetWithID(Element& aFrom, nsAtom* aID, bool aWatch) {
163+
void IDTracker::ResetToID(Element& aFrom, nsAtom* aID, bool aWatch) {
163164
MOZ_ASSERT(aID);
164165

165166
Unlink();

‎dom/base/IDTracker.h

+13-11
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ class IDTracker {
7575
* property (that is, we're creating a reference an "image element", which
7676
* is subject to the document's mozSetImageElement overriding mechanism).
7777
*/
78-
void ResetToURIFragmentID(nsIContent* aFrom, nsIURI* aURI,
79-
nsIReferrerInfo* aReferrerInfo, bool aWatch = true,
80-
bool aReferenceImage = false);
78+
void ResetToURIWithFragmentID(nsIContent* aFrom, nsIURI* aURI,
79+
nsIReferrerInfo* aReferrerInfo,
80+
bool aWatch = true,
81+
bool aReferenceImage = false);
8182

8283
/**
83-
* A variation on ResetToURIFragmentID() to set up a reference that consists
84-
* only of a fragment identifier, referencing an element in the same document
85-
* as aFrom.
84+
* A variation on ResetToURIWithFragmentID() to set up a reference that
85+
* consists only of a fragment identifier, referencing an element in the same
86+
* document as aFrom.
8687
*
8788
* @param aFrom The source element that is making the reference.
8889
* @param aLocalRef The fragment identifier that identifies the target
@@ -91,20 +92,21 @@ class IDTracker {
9192
* changes, so ElementChanged won't fire and get() will always return the
9293
* same value, the current element for the ID.
9394
*/
94-
void ResetWithLocalRef(Element& aFrom, const nsAString& aLocalRef,
95-
bool aWatch = true);
95+
void ResetToLocalFragmentID(Element& aFrom, const nsAString& aLocalRef,
96+
bool aWatch = true);
9697

9798
/**
98-
* A variation on ResetToURIFragmentID() to set up a reference that consists
99-
* of a pre-parsed ID, referencing an element in the same document as aFrom.
99+
* A variation on ResetToURIWithFragmentID() to set up a reference that
100+
* consists of a pre-parsed ID, referencing an element in the same document
101+
* as aFrom.
100102
*
101103
* @param aFrom The source element that is making the reference.
102104
* @param aID The ID of the target element.
103105
* @param aWatch If false, then we do not set up the notifications to track
104106
* changes, so ElementChanged won't fire and get() will always return the
105107
* same value, the current element for the ID.
106108
*/
107-
void ResetWithID(Element& aFrom, nsAtom* aID, bool aWatch = true);
109+
void ResetToID(Element& aFrom, nsAtom* aID, bool aWatch = true);
108110

109111
/**
110112
* Clears the reference. ElementChanged is not triggered. get() will return

‎dom/smil/SMILTimeValueSpec.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void SMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
9393
RefPtr<Element> oldReferencedElement = mReferencedElement.get();
9494

9595
if (mParams.mDependentElemID) {
96-
mReferencedElement.ResetWithID(aContextElement, mParams.mDependentElemID);
96+
mReferencedElement.ResetToID(aContextElement, mParams.mDependentElemID);
9797
} else if (mParams.mType == SMILTimeValueSpecParams::EVENT) {
9898
Element* target = mOwner->GetTargetElement();
9999
mReferencedElement.ResetWithElement(target);

‎dom/svg/SVGAnimationElement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ bool SVGAnimationElement::IsEventAttributeNameInternal(nsAtom* aName) {
377377

378378
void SVGAnimationElement::UpdateHrefTarget(const nsAString& aHrefStr) {
379379
if (nsContentUtils::IsLocalRefURL(aHrefStr)) {
380-
mHrefTarget.ResetWithLocalRef(*this, aHrefStr);
380+
mHrefTarget.ResetToLocalFragmentID(*this, aHrefStr);
381381
} else {
382382
mHrefTarget.Unlink();
383383
}

‎dom/svg/SVGUseElement.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ void SVGUseElement::LookupHref() {
562562

563563
Element* treeToWatch = mOriginal ? mOriginal.get() : this;
564564
if (nsContentUtils::IsLocalRefURL(href)) {
565-
mReferencedElementTracker.ResetWithLocalRef(*treeToWatch, href);
565+
mReferencedElementTracker.ResetToLocalFragmentID(*treeToWatch, href);
566566
return;
567567
}
568568

@@ -583,8 +583,8 @@ void SVGUseElement::LookupHref() {
583583

584584
nsIReferrerInfo* referrer =
585585
OwnerDoc()->ReferrerInfoForInternalCSSAndSVGResources();
586-
mReferencedElementTracker.ResetToURIFragmentID(treeToWatch, targetURI,
587-
referrer);
586+
mReferencedElementTracker.ResetToURIWithFragmentID(treeToWatch, targetURI,
587+
referrer);
588588
}
589589

590590
void SVGUseElement::TriggerReclone() {

‎layout/forms/ListMutationObserver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void ListMutationObserver::Attach(bool aRepaint) {
1818
if (InputElement().GetAttr(nsGkAtoms::list_, id)) {
1919
Unlink();
2020
RefPtr<nsAtom> idAtom = NS_AtomizeMainThread(id);
21-
ResetWithID(InputElement(), idAtom);
21+
ResetToID(InputElement(), idAtom);
2222
AddObserverIfNeeded();
2323
}
2424
if (aRepaint) {

‎layout/svg/SVGObserverUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ SVGIDRenderingObserver::SVGIDRenderingObserver(
457457
referrerInfo = aURI->GetReferrerInfo();
458458
}
459459

460-
mObservedElementTracker.ResetToURIFragmentID(
460+
mObservedElementTracker.ResetToURIWithFragmentID(
461461
aObservingContent, uri, referrerInfo, true, aReferenceImage);
462462
TargetChanged();
463463
StartObserving();

0 commit comments

Comments
 (0)
Failed to load comments.