Bug 1645990 - Treat table rows as separate blocks for Find-in-page purposes, rather than matching continuously across row boundaries. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D164640
This commit is contained in:
Jonathan Kew 2022-12-14 15:05:22 +00:00
Родитель 5e99b0a03c
Коммит 3372e411f9
3 изменённых файлов: 40 добавлений и 4 удалений

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

@ -41,10 +41,16 @@ const INLINE_LIKE_DISPLAY_VALUES = [
const BLOCK_LIKE_DISPLAY_VALUES = [
"block",
"table",
"list-item",
"grid",
"flex",
"grid",
"list-item",
"table-column-group",
"table-column",
"table-footer-group",
"table-header-group",
"table-row-group",
"table-row",
"table",
];
let runTests = t.step_func_done(function() {

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

@ -101,7 +101,15 @@ static bool IsBlockNode(const nsIContent* aContent) {
}
nsIFrame* frame = aContent->GetPrimaryFrame();
return frame && frame->StyleDisplay()->IsBlockOutsideStyle();
if (!frame) {
return false;
}
const auto& disp = *frame->StyleDisplay();
// We also treat internal table frames as "blocks" for the purpose of
// locating boundaries for searches (see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1645990).
return disp.IsBlockOutsideStyle() || disp.IsInternalTableStyleExceptCell();
}
static bool IsDisplayedNode(const nsINode* aNode) {

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

@ -295,6 +295,18 @@ async function runTests() {
assertFound(entireWord, "-fo");
assertFound(entireWord, "-ba");
// Searching in elements with display: table-*, bug 1645990
var table = document.getElementById("tabular");
assertFound(table, "One");
assertFound(table, "TwoThree"); // across adjacent cells
assertNotFound(table, "wordsanother"); // not across rows
rf.entireWord = true;
assertNotFound(table, "One"); // because nothing separates it from next cell
assertFound(table, "several");
assertFound(table, "whole");
assertFound(table, "words");
rf.entireWord = false;
// Do these test at the end since they trigger failure screenshots in
// the test harness, and we want as much information as possible about
// any OTHER tests that may have already failed.
@ -344,6 +356,11 @@ async function runTests() {
SimpleTest.finish();
}
</script>
<style>
#tabular { display: table; }
#tabular div { display: table-row; }
#tabular div div { display: table-cell; }
</style>
</head>
<body onload="runTests()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
@ -370,6 +387,11 @@ async function runTests() {
<div id="entireWord"><p>(one)</p><p>[two] [three]</p><p>-foo -bar</p></div>
<div id="content" style="display: none">
</div>
<div id="tabular">
<div><div>One</div><div>Two</div><div>Three</div></div>
<div><div></div><div></div><div>several whole words</div></div>
<div><div>one</div><div>more</div><div>row</div></div>
</div>
<pre id="test">
</pre>