Support dynamic pseudo-classes on elements with display: contents
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2018 18:55:17 +0000 (18:55 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2018 18:55:17 +0000 (18:55 +0000)
commit2c37e3a1f25909ac4c389b9fee061969752b85c6
treed0d3e2da4ed42441c91ffdb11ad596409465d97e
parentba662140e903b851ce54cf8b1c1042cfa45f5ec7
Support dynamic pseudo-classes on elements with display: contents
https://bugs.webkit.org/show_bug.cgi?id=181640
<rdar://problem/36605415>

Reviewed by Dean Jackson.

Source/WebCore:

The code for :hover and :active style invalidation assumes that only elements with renderer need invalidation.

This patch fixes '.display-content-element:hover span' case but not '.display-content-element:hover' case but
includes tests for both. The latter is not super useful anyway (as it only affects rendering with inherited
text properties).

Test: fast/css/display-contents-hover-active.html

* dom/Document.cpp:
(WebCore::Document::updateHoverActiveState):

    Traverse up in composed tree instead of render tree when invalidating. This has the same order as render tree
    but also includes display:content elements. This also allows removing the special display:none case.

* dom/Element.cpp:
(WebCore::Element::setActive):
(WebCore::Element::setHovered):

    Also look into display:contents style for invalidation checks.

(WebCore::Element::renderOrDisplayContentsStyle const):

    Make this helper an Element member.

* dom/Element.h:
* dom/Node.cpp:
(WebCore::Node::parentElementInComposedTree const):

    Support starting from a PseudoElement. This is consistent with ComposedTreeAncestorIterator.

* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::nextSiblingRenderer const):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):
(WebCore::Style::TreeResolver::createAnimatedElementUpdate):
(WebCore::Style::shouldResolveElement):
(WebCore::Style::TreeResolver::resolveComposedTree):
(WebCore::Style::renderOrDisplayContentsStyle): Deleted.

    Use the Element::renderOrDisplayContentsStyle() instead.

LayoutTests:

* fast/css/display-contents-hover-active-expected.txt: Added.
* fast/css/display-contents-hover-active.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238097 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css/display-contents-hover-active-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/display-contents-hover-active.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.cpp
Source/WebCore/rendering/updating/RenderTreePosition.cpp
Source/WebCore/style/StyleTreeResolver.cpp