diff --git a/dom/base/test/test_find.html b/dom/base/test/test_find.html index 7dd6c172c410..aec6f0fbaafa 100644 --- a/dom/base/test/test_find.html +++ b/dom/base/test/test_find.html @@ -67,5 +67,13 @@ iframe.onload = t.step_func_done(function() { testFindable(false, "me and me", ` me
me `); + + testFindable(true, "This text should be visible", ` + + `); }); diff --git a/toolkit/components/find/nsFind.cpp b/toolkit/components/find/nsFind.cpp index 68d1ea5326bb..0a91543a957d 100644 --- a/toolkit/components/find/nsFind.cpp +++ b/toolkit/components/find/nsFind.cpp @@ -524,7 +524,7 @@ IsBlockNode(nsIContent* aContent) } static bool -IsVisibleNode(nsINode* aNode) +IsDisplayedNode(nsINode* aNode) { if (!aNode->IsContent()) { return false; @@ -536,6 +536,22 @@ IsVisibleNode(nsINode* aNode) return aNode->IsElement() && aNode->AsElement()->IsDisplayContents(); } + return true; +} + +static bool +IsVisibleNode(nsINode* aNode) +{ + if (!IsDisplayedNode(aNode)) { + return false; + } + + nsIFrame* frame = aNode->AsContent()->GetPrimaryFrame(); + if (!frame) { + // display: contents + return true; + } + return frame->StyleVisibility()->IsVisible(); } @@ -544,7 +560,7 @@ SkipNode(nsIContent* aContent) { nsIContent* content = aContent; while (content) { - if (!IsVisibleNode(content) || + if (!IsDisplayedNode(content) || content->IsComment() || content->IsAnyOfHTMLElements(nsGkAtoms::script, nsGkAtoms::noframes,