Shadow DOM: Implement display: contents for slots
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Apr 2016 10:29:15 +0000 (10:29 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Apr 2016 10:29:15 +0000 (10:29 +0000)
commit03db58d4028a8f3cab4ab156d43defe86f5d9a4f
tree2e6447987798223b11531c2f3d08bfb91bc18da8
parent42b7a728b3a7c51fdd22f89d3b439ea2ab762fe3
Shadow DOM: Implement display: contents for slots
https://bugs.webkit.org/show_bug.cgi?id=149439
<rdar://problem/22731922>

Reviewed by Ryosuke Niwa.

Source/WebCore:

This patch adds support for value 'contents' of the 'display' property for <slot> elements only. The value is ignored
for other elements for now. With this display value the element does not generate a box for itself but its descendants
generate them normally.

Slots already have implicit "display: contents". With this patch the value comes from the user agent stylesheet and can
be overriden by the author.

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSValueKeywords.in:

    Suport parsing display: contents.

* css/StyleResolver.cpp:
(WebCore::equivalentBlockDisplay):
(WebCore::StyleResolver::adjustRenderStyle):

    Disallow for non-slots for now.

* css/html.css:
(slot):

    Add "slot { display: contents }" to the UA sheet.

* dom/Element.cpp:
(WebCore::Element::resolveStyle):
(WebCore::Element::hasDisplayContents):
(WebCore::Element::setHasDisplayContents):

    Add a rare data bit for elements with display:contents (as we don't save the RenderStyle for them).

(WebCore::Element::rendererIsNeeded):

    Don't need renderer for display:contents.

(WebCore::Element::createElementRenderer):
* dom/Element.h:
(WebCore::Element::isVisibleInViewportChanged):
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::operator!):
(WebCore::ElementAndTextDescendantIterator::operator bool):
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::operator==):
(WebCore::ElementAndTextDescendantIterator::operator!=):

    Support initializing ElementAndTextDescendantIterator with root==current so that m_current is not nulled.
    This is needed for ComposedTreeIterator to be initialized correctly when root is a slot and the current node
    is a slotted node. The case happens in RenderTreePosition::previousSiblingRenderer when slot display is overriden
    to something else than 'contents'.

* dom/ElementRareData.h:
(WebCore::ElementRareData::hasDisplayContents):
(WebCore::ElementRareData::setHasDisplayContents):
(WebCore::ElementRareData::ElementRareData):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::createFor):
* rendering/style/RenderStyleConstants.h:
* style/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::nextSiblingRenderer):

    Test for dynamic display:contents.

* style/RenderTreeUpdater.cpp:
(WebCore::findRenderingRoot):
(WebCore::RenderTreeUpdater::updateRenderTree):
(WebCore::RenderTreeUpdater::updateElementRenderer):

    Test for dynamic display:contents.

* style/StyleTreeResolver.cpp:
(WebCore::Style::affectsRenderedSubtree):

    No need for special case.

(WebCore::Style::TreeResolver::resolveComposedTree):

    Test for dynamic display:contents.

LayoutTests:

* platform/mac/TestExpectations:

Enable fast/shadow-dom/css-scoping-shadow-slot-display-override.html, the test for overriding slot display value.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199154 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/html.css
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementAndTextDescendantIterator.h
Source/WebCore/dom/ElementRareData.h
Source/WebCore/html/HTMLSlotElement.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/style/RenderTreePosition.cpp
Source/WebCore/style/RenderTreeUpdater.cpp
Source/WebCore/style/StyleTreeResolver.cpp