Bug 1457336: Make some functions static. r=mats

This patch should have no change in behavior.

MozReview-Commit-ID: AOAZ09g78fr
This commit is contained in:
Emilio Cobos Álvarez 2018-05-22 11:18:50 +02:00
Родитель b6544fd549
Коммит 576df97088
2 изменённых файлов: 61 добавлений и 66 удалений

Просмотреть файл

@ -504,6 +504,67 @@ DumpNode(nsINode* aNode)
#endif
}
static bool
IsBlockNode(nsIContent* aContent)
{
if (aContent->IsElement() && aContent->AsElement()->IsDisplayContents()) {
return false;
}
// FIXME(emilio): This is dubious...
if (aContent->IsAnyOfHTMLElements(nsGkAtoms::img,
nsGkAtoms::hr,
nsGkAtoms::th,
nsGkAtoms::td)) {
return true;
}
nsIFrame* frame = aContent->GetPrimaryFrame();
return frame && frame->StyleDisplay()->IsBlockOutsideStyle();
}
static bool
IsVisibleNode(nsINode* aNode)
{
if (!aNode->IsContent()) {
return false;
}
nsIFrame* frame = aNode->AsContent()->GetPrimaryFrame();
if (!frame) {
// No frame! Not visible then, unless it's display: contents.
return aNode->IsElement() && aNode->AsElement()->IsDisplayContents();
}
return frame->StyleVisibility()->IsVisible();
}
static bool
SkipNode(nsIContent* aContent)
{
nsIContent* content = aContent;
while (content) {
if (!IsVisibleNode(content) ||
content->IsComment() ||
content->IsAnyOfHTMLElements(nsGkAtoms::script,
nsGkAtoms::noframes,
nsGkAtoms::select)) {
DEBUG_FIND_PRINTF("Skipping node: ");
DumpNode(content);
return true;
}
// Only climb to the nearest block node
if (IsBlockNode(content)) {
return false;
}
content = content->GetParent();
}
return false;
}
nsresult
nsFind::InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset,
nsIDOMNode* aEndNode, int32_t aEndOffset)
@ -808,67 +869,6 @@ nsFind::PeekNextChar(nsRange* aSearchRange,
return t1b ? CHAR_TO_UNICHAR(t1b[index]) : t2b[index];
}
bool
nsFind::IsBlockNode(nsIContent* aContent)
{
if (aContent->IsElement() && aContent->AsElement()->IsDisplayContents()) {
return false;
}
// FIXME(emilio): This is dubious...
if (aContent->IsAnyOfHTMLElements(nsGkAtoms::img,
nsGkAtoms::hr,
nsGkAtoms::th,
nsGkAtoms::td)) {
return true;
}
nsIFrame* frame = aContent->GetPrimaryFrame();
return frame && frame->StyleDisplay()->IsBlockOutsideStyle();
}
bool
nsFind::IsVisibleNode(nsINode* aNode)
{
if (!aNode->IsContent()) {
return false;
}
nsIFrame* frame = aNode->AsContent()->GetPrimaryFrame();
if (!frame) {
// No frame! Not visible then, unless it's display: contents.
return aNode->IsElement() && aNode->AsElement()->IsDisplayContents();
}
return frame->StyleVisibility()->IsVisible();
}
bool
nsFind::SkipNode(nsIContent* aContent)
{
nsIContent* content = aContent;
while (content) {
if (!IsVisibleNode(content) ||
content->IsComment() ||
content->IsAnyOfHTMLElements(nsGkAtoms::script,
nsGkAtoms::noframes,
nsGkAtoms::select)) {
DEBUG_FIND_PRINTF("Skipping node: ");
DumpNode(content);
return true;
}
// Only climb to the nearest block node
if (IsBlockNode(content)) {
return false;
}
content = content->GetParent();
}
return false;
}
nsresult
nsFind::GetBlockParent(nsINode* aNode, nsINode** aParent)
{

Просмотреть файл

@ -52,11 +52,6 @@ protected:
nsCOMPtr<nsINode> mLastBlockParent;
nsresult GetBlockParent(nsINode* aNode, nsINode** aParent);
// Utility routines:
bool IsBlockNode(nsIContent* aNode);
bool SkipNode(nsIContent* aNode);
bool IsVisibleNode(nsINode* aNode);
// Move in the right direction for our search:
nsresult NextNode(nsRange* aSearchRange,
nsRange* aStartPoint, nsRange* aEndPoint,