From eed3b8d8ab89b724e97831fbfcc64013a2bcad1b Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Tue, 21 Jan 2020 16:02:20 +0000 Subject: [PATCH] Bug 1609662: part 15) Rename some methods in `Selection`. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D60256 --HG-- extra : moz-landing-system : lando --- dom/base/Selection.cpp | 15 +++++++-------- dom/base/Selection.h | 13 +++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index 2b85a722e4d9..4c705de52494 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -1361,8 +1361,7 @@ nsresult Selection::GetPrimaryOrCaretFrameForNodeOffset(nsIContent* aContent, return NS_OK; } -void Selection::SelectFramesForContent(nsIContent* aContent, - bool aSelected) const { +void Selection::SelectFramesOf(nsIContent* aContent, bool aSelected) const { nsIFrame* frame = aContent->GetPrimaryFrame(); if (!frame) { return; @@ -1378,14 +1377,13 @@ void Selection::SelectFramesForContent(nsIContent* aContent, } } -// select all content children of aContent -nsresult Selection::SelectAllFramesForContent( +nsresult Selection::SelectFramesOfInclusiveDescendantsOfContent( PostContentIterator& aPostOrderIter, nsIContent* aContent, bool aSelected) const { // If aContent doesn't have children, we should avoid to use the content // iterator for performance reason. if (!aContent->HasChildren()) { - SelectFramesForContent(aContent, aSelected); + SelectFramesOf(aContent, aSelected); return NS_OK; } @@ -1397,7 +1395,7 @@ nsresult Selection::SelectAllFramesForContent( nsINode* node = aPostOrderIter.GetCurrentNode(); MOZ_ASSERT(node); nsIContent* innercontent = node->IsContent() ? node->AsContent() : nullptr; - SelectFramesForContent(innercontent, aSelected); + SelectFramesOf(innercontent, aSelected); } return NS_OK; @@ -1488,7 +1486,7 @@ nsresult Selection::SelectFrames(nsPresContext* aPresContext, nsRange* aRange, if (aRange->Collapsed() || (startNode == endNode && !startNode->HasChildren())) { if (!isFirstContentTextNode) { - SelectFramesForContent(startContent, aSelect); + SelectFramesOf(startContent, aSelect); } return NS_OK; } @@ -1504,7 +1502,8 @@ nsresult Selection::SelectFrames(nsPresContext* aPresContext, nsRange* aRange, nsINode* node = subtreeIter.GetCurrentNode(); MOZ_ASSERT(node); nsIContent* content = node->IsContent() ? node->AsContent() : nullptr; - SelectAllFramesForContent(postOrderIter, content, aSelect); + SelectFramesOfInclusiveDescendantsOfContent(postOrderIter, content, + aSelect); } // We must now do the last one if it is not the same as the first diff --git a/dom/base/Selection.h b/dom/base/Selection.h index 8b8e8568845b..8f943bbca66e 100644 --- a/dom/base/Selection.h +++ b/dom/base/Selection.h @@ -707,10 +707,15 @@ class Selection final : public nsSupportsWeakReference, * nothing. */ void SetAnchorFocusRange(int32_t aIndex); - void SelectFramesForContent(nsIContent* aContent, bool aSelected) const; - nsresult SelectAllFramesForContent(PostContentIterator& aPostOrderIter, - nsIContent* aContent, - bool aSelected) const; + void SelectFramesOf(nsIContent* aContent, bool aSelected) const; + + /** + * https://dom.spec.whatwg.org/#concept-tree-inclusive-descendant. + */ + nsresult SelectFramesOfInclusiveDescendantsOfContent( + PostContentIterator& aPostOrderIter, nsIContent* aContent, + bool aSelected) const; + nsresult SelectFrames(nsPresContext* aPresContext, nsRange* aRange, bool aSelect);