Computed style should work correctly with slotted elements that have display:none
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Oct 2015 20:50:22 +0000 (20:50 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Oct 2015 20:50:22 +0000 (20:50 +0000)
commit3b1037553f46b031c5726bcf33c33c117b5ff6bb
treee315f208b62c80592a426a9a4dacdb843da38121
parenteb10e6e40df437dc37c3ef4dce1ebfc321f8c699
Computed style should work correctly with slotted elements that have display:none
https://bugs.webkit.org/show_bug.cgi?id=150237

Reviewed by Andreas Kling.

Source/WebCore:

If an element has display:none we don't normally retain or even compute its style (as it is not rendered).
If getComputedStyle is invoked for such element we resolve the style (along with any ancestors) and cache
it separately to rare data. This path needs to work with slotted elements in shadow trees.

This patch also make computedStyle() iterative rather than recursive.

Test: fast/shadow-dom/computed-style-display-none.html

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

    Pass in the parent style instead of invoking computedStyle() recursively.

* dom/Document.h:
* dom/Element.cpp:
(WebCore::beforeOrAfterPseudoElement):
(WebCore::Element::existingComputedStyle):
(WebCore::Element::resolveComputedStyle):

    Iterative resolve function that uses composed tree iterator.

(WebCore::Element::computedStyle):

    Factor into helpers.

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

    Use the composed tree iterator.

LayoutTests:

* editing/style/apply-style-atomic-expected.txt:

    Rebase.

* fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html:

    We now also compute style of display:none pseudo elements correctly.
    This is a progression and matches other browsers.

* fast/shadow-dom/computed-style-display-none-expected.txt: Added.
* fast/shadow-dom/computed-style-display-none.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/style/apply-style-atomic-expected.txt
LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element-expected.txt
LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html
LayoutTests/fast/shadow-dom/computed-style-display-none-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/computed-style-display-none.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.cpp