Skip to content
Permalink
Browse files
Nodes with display::none should be considered search invisible.
https://bugs.webkit.org/show_bug.cgi?id=245170
<rdar://99905766>

Reviewed by Devin Rousso.

Address a FIXME from the spec implementation, nodes with display::none should be
considered search-invisible and not considered valid for a fragment.

* LayoutTests/http/tests/scroll-to-text-fragment/word-display-none-expected.html: Added.
* LayoutTests/http/tests/scroll-to-text-fragment/word-display-none.html: Added.
* Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp:
(WebCore::FragmentDirectiveRangeFinder::isSearchInvisible):

Canonical link: https://commits.webkit.org/254498@main
  • Loading branch information
megangardner committed Sep 14, 2022
1 parent 6691152 commit 66ee16990695ad226e81dc8571801e9741031fa7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>Scroll to text fragment - highlight simple start reference</title>
<style>
span {
display: none;
}
</style>

<p>The test passes if the following word does not have a yellow background.</p>
<div>This <span>word</span> should not be highlighted</div>
@@ -0,0 +1,17 @@
<!DOCTYPE html><!-- webkit-test-runner [ ScrollToTextFragmentIndicatorEnabled=false ] -->
<meta charset="utf-8" />
<title>Scroll to text fragment - highlight simple start text</title>
<link rel="help" href="https://wicg.github.io/scroll-to-text-fragment/">
<style>
span {
display: none;
}
</style>

<p>The test passes if the following word does not have a yellow background.</p>
<div>This <span>word</span> should not be highlighted</div>

<script>
location.href = "#:~:text=This-,word,-should";
</script>
</html>
@@ -41,6 +41,7 @@
#include "HTMLScriptElement.h"
#include "HTMLStyleElement.h"
#include "HTMLVideoElement.h"
#include "NodeRenderStyle.h"
#include "Position.h"
#include "SimpleRange.h"
#include "TextBoundaries.h"
@@ -55,7 +56,8 @@ enum class WordBounded : bool { No, Yes };
// https://wicg.github.io/scroll-to-text-fragment/#search-invisible
static bool isSearchInvisible(const Node& node)
{
// FIXME: The computed value of its display property is none.
if (!node.renderStyle() || node.renderStyle()->display() == DisplayType::None)
return true;

// FIXME: If the node serializes as void.

0 comments on commit 66ee169

Please sign in to comment.