Skip to content

Commit

Permalink
[content-visibility] Make innerText take content-visibility: hidden i…
Browse files Browse the repository at this point in the history
…nto account

https://bugs.webkit.org/show_bug.cgi?id=247196

Reviewed by Ryosuke Niwa.

Make innerText take css content-visibility: hidden into account as specified here:
https://w3c.github.io/csswg-drafts/css-contain/#cv-notes (Item 8).

* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-047-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-080-expected.txt:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::innerText):
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::advance):

Canonical link: https://commits.webkit.org/258187@main
  • Loading branch information
rwlbuis committed Dec 21, 2022
1 parent 59d042a commit 63fdf6b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
@@ -1,4 +1,4 @@
This text should be visible.

FAIL innerText on locked element. assert_equals: expected "This text should be visible." but got "This text should be visible.\n"
PASS innerText on locked element.

@@ -1,5 +1,4 @@



PASS Tab order navigation skips hidden subtrees

3 changes: 3 additions & 0 deletions Source/WebCore/dom/Element.cpp
Expand Up @@ -3618,6 +3618,9 @@ String Element::innerText()
if (!renderer())
return textContent(true);

if (renderer()->isSkippedContent())
return String();

return plainText(makeRangeSelectingNodeContents(*this));
}

Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/editing/TextIterator.cpp
Expand Up @@ -478,6 +478,8 @@ void TextIterator::advance()
if (!isRendererVisible(renderer, m_behaviors)) {
m_handledNode = true;
m_handledChildren = !hasDisplayContents(*m_node) && !renderer;
} else if (is<Element>(m_node) && renderer->shouldSkipContent()) {
m_handledChildren = true;
} else {
// handle current node according to its type
if (renderer->isText() && m_node->isTextNode())
Expand Down

0 comments on commit 63fdf6b

Please sign in to comment.