Bug 1457286: Teach nsFind about display: contents. r=mats

MozReview-Commit-ID: LODyc8yuuSs
This commit is contained in:
Emilio Cobos Álvarez 2018-04-26 22:38:31 +02:00
parent c91cd00748
commit 340d7141bb

View File

@ -815,9 +815,13 @@ nsFind::PeekNextChar(nsRange* aSearchRange,
return t1b ? CHAR_TO_UNICHAR(t1b[index]) : t2b[index];
}
// FIXME(emilio): This very probably wants to look at frames instead.
bool
nsFind::IsBlockNode(nsIContent* aContent)
{
if (aContent->IsElement() && aContent->AsElement()->IsDisplayContents()) {
return false;
}
if (aContent->IsAnyOfHTMLElements(nsGkAtoms::img,
nsGkAtoms::hr,
nsGkAtoms::th,
@ -829,17 +833,16 @@ nsFind::IsBlockNode(nsIContent* aContent)
}
bool
nsFind::IsVisibleNode(nsINode* aDOMNode)
nsFind::IsVisibleNode(nsINode* aNode)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aDOMNode));
if (!content) {
if (!aNode->IsContent()) {
return false;
}
nsIFrame* frame = content->GetPrimaryFrame();
nsIFrame* frame = aNode->AsContent()->GetPrimaryFrame();
if (!frame) {
// No frame! Not visible then.
return false;
// No frame! Not visible then, unless it's display: contents.
return aNode->IsElement() && aNode->AsElement()->IsDisplayContents();
}
return frame->StyleVisibility()->IsVisible();