Bug 1470861: Make GetBlockParent static. r?mats
MozReview-Commit-ID: L5JfCfnlKzM
--- a/toolkit/components/find/nsFind.cpp
+++ b/toolkit/components/find/nsFind.cpp
@@ -620,16 +620,33 @@ SkipNode(nsIContent* aContent)
}
content = content->GetParent();
}
return false;
}
+static nsIContent*
+GetBlockParent(nsINode* aNode)
+{
+ if (!aNode) {
+ return nullptr;
+ }
+ // FIXME(emilio): This should use GetFlattenedTreeParent instead to properly
+ // handle Shadow DOM.
+ for (nsIContent* current = aNode->GetParent(); current;
+ current = current->GetParent()) {
+ if (IsBlockNode(current)) {
+ return current;
+ }
+ }
+ return nullptr;
+}
+
nsresult
nsFind::InitIterator(State& aState,
nsINode* aStartNode,
int32_t aStartOffset,
nsINode* aEndNode,
int32_t aEndOffset)
{
if (!aState.mIterator) {
@@ -889,33 +906,16 @@ nsFind::PeekNextChar(State& aState,
}
// Index of char to return.
int32_t index = mFindBackward ? fragLen - 1 : 0;
return t1b ? CHAR_TO_UNICHAR(t1b[index]) : t2b[index];
}
-nsIContent*
-nsFind::GetBlockParent(nsINode* aNode)
-{
- if (!aNode) {
- return nullptr;
- }
- // FIXME(emilio): This should use GetFlattenedTreeParent instead to properly
- // handle Shadow DOM.
- for (nsIContent* current = aNode->GetParent(); current;
- current = current->GetParent()) {
- if (IsBlockNode(current)) {
- return current;
- }
- }
- return nullptr;
-}
-
#define NBSP_CHARCODE (CHAR_TO_UNICHAR(160))
#define IsSpace(c) (nsCRT::IsAsciiSpace(c) || (c) == NBSP_CHARCODE)
#define OVERFLOW_PINDEX (mFindBackward ? pindex < 0 : pindex > patLen)
#define DONE_WITH_PINDEX (mFindBackward ? pindex <= 0 : pindex >= patLen)
#define ALMOST_DONE_WITH_PINDEX (mFindBackward ? pindex <= 0 : pindex >= patLen - 1)
// Take nodes out of the tree with NextNode, until null (NextNode will return 0
// at the end of our range).
--- a/toolkit/components/find/nsFind.h
+++ b/toolkit/components/find/nsFind.h
@@ -42,17 +42,16 @@ protected:
bool mCaseSensitive;
// Use "find entire words" mode by setting to a word breaker or null, to
// disable "entire words" mode.
RefPtr<mozilla::intl::WordBreaker> mWordBreaker;
struct State;
class StateRestorer;
- nsIContent* GetBlockParent(nsINode* aNode);
// Move in the right direction for our search:
nsresult NextNode(State&,
nsRange* aSearchRange,
nsRange* aStartPoint,
nsRange* aEndPoint);
// Get the first character from the next node (last if mFindBackward).