Support ::before/::after pseudo elements with display:contents
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Oct 2017 08:15:10 +0000 (08:15 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Oct 2017 08:15:10 +0000 (08:15 +0000)
commit26c0455a1936edfac3921932d9c122289ef249dd
tree995e9ed90df099482dafa0aea8438231bf968017
parent483a2cb982d927cc359b85bf46bc9db124b0b4d3
Support ::before/::after pseudo elements with display:contents
https://bugs.webkit.org/show_bug.cgi?id=178584

Reviewed by Ryosuke Niwa.

Source/WebCore:

This is cases like

::before { display:contents; content:'foo' }

* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustDisplayContentsStyle): Added.

    Allow display:contents on pseudo elements.
    Factor into function.

(WebCore::StyleResolver::adjustRenderStyle):
* dom/PseudoElement.h:

    Add a weak vector of content renderers.

* style/RenderTreePosition.h:
(WebCore::RenderTreePosition::moveToLastChild):

    Add a way to set a valid render tree position without a node.

* style/RenderTreeUpdaterGeneratedContent.cpp:
(WebCore::createContentRenderers):

    Take RenderTreePosition.

(WebCore::updateStyleForContentRenderers):

    Update based on the content renderer vector instead of doing a tree walk.

(WebCore::removeAndDestroyContentRenderers):

    Helper for destroying content renderers.

(WebCore::RenderTreeUpdater::GeneratedContent::updatePseudoElement):

    In the normal case create a render tree position for the pseudo element renderer and
    use RenderTreePosition::moveToLastChild to make it a valid position. (The existing
    RenderTreePosition interface didn't have way to move to positions in anonymous boxes)

    In the case of a non box generating display:contents pseudo element, use the current
    render tree position instead.

    Ensure that pseudo element renderers are destroyed before creating the new ones since in
    display:contents case they are not descendants of the pseudo renderer and don't get cleared
    automatically.

LayoutTests:

* TestExpectations: Enable imported/w3c/web-platform-tests/css/css-display-3/display-contents-before-after-002.html

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/PseudoElement.h
Source/WebCore/style/RenderTreePosition.h
Source/WebCore/style/RenderTreeUpdaterGeneratedContent.cpp