Changeset 190430 in webkit


Ignore:
Timestamp:
Oct 1, 2015 1:36:34 PM (8 years ago)
Author:
rniwa@webkit.org
Message:

Slot elements should support fallback contents
https://bugs.webkit.org/show_bug.cgi?id=149701

Reviewed by Antti Koivisto.

Source/WebCore:

Following discussions on Github discussions [1] [2], we're adding the default rule of display: contents
on slot elements and making slot elements render its children when there are no assigned nodes [3].

Make these changes by attaching renderers on direct-children of slot elements when there are no assigned
nodes during render tree construction. Note display: contents will be aded in webkit.org/b/149439.

[1] https://github.com/w3c/webcomponents/issues/317
[2] https://github.com/w3c/webcomponents/issues/308
[3] https://github.com/w3c/webcomponents/issues/308#issuecomment-143655347

Tests: fast/shadow-dom/css-scoping-shadow-slot-fallback.html

fast/shadow-dom/shadow-layout-after-slot-fallback-changes.html

  • style/StyleResolveTree.cpp:

(WebCore::Style::attachSlotAssignees):
(WebCore::Style::detachSlotAssignees):
(WebCore::Style::resolveSlotAssignees):

LayoutTests:

Added tests for fallback contents in slot elements. One of them could be safely submitted to CSS WG,
and the other one is a style recalc test.

  • fast/shadow-dom/css-scoping-shadow-slot-fallback-expected.html: Added.
  • fast/shadow-dom/css-scoping-shadow-slot-fallback.html: Added.
  • fast/shadow-dom/shadow-layout-after-slot-fallback-changes-expected.html: Added.
  • fast/shadow-dom/shadow-layout-after-slot-fallback-changes.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190429 r190430  
     12015-10-01  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Slot elements should support fallback contents
     4        https://bugs.webkit.org/show_bug.cgi?id=149701
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added tests for fallback contents in slot elements. One of them could be safely submitted to CSS WG,
     9        and the other one is a style recalc test.
     10
     11        * fast/shadow-dom/css-scoping-shadow-slot-fallback-expected.html: Added.
     12        * fast/shadow-dom/css-scoping-shadow-slot-fallback.html: Added.
     13        * fast/shadow-dom/shadow-layout-after-slot-fallback-changes-expected.html: Added.
     14        * fast/shadow-dom/shadow-layout-after-slot-fallback-changes.html: Added.
     15
    1162015-10-01  Keith Miller  <keith_miller@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r190423 r190430  
     12015-10-01  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Slot elements should support fallback contents
     4        https://bugs.webkit.org/show_bug.cgi?id=149701
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Following discussions on Github discussions [1] [2], we're adding the default rule of `display: contents`
     9        on slot elements and making slot elements render its children when there are no assigned nodes [3].
     10
     11        Make these changes by attaching renderers on direct-children of slot elements when there are no assigned
     12        nodes during render tree construction. Note `display: contents` will be aded in webkit.org/b/149439.
     13
     14        [1] https://github.com/w3c/webcomponents/issues/317
     15        [2] https://github.com/w3c/webcomponents/issues/308
     16        [3] https://github.com/w3c/webcomponents/issues/308#issuecomment-143655347
     17
     18        Tests: fast/shadow-dom/css-scoping-shadow-slot-fallback.html
     19               fast/shadow-dom/shadow-layout-after-slot-fallback-changes.html
     20
     21        * style/StyleResolveTree.cpp:
     22        (WebCore::Style::attachSlotAssignees):
     23        (WebCore::Style::detachSlotAssignees):
     24        (WebCore::Style::resolveSlotAssignees):
     25
    1262015-10-01  Brent Fulgham  <bfulgham@apple.com>
    227
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r190347 r190430  
    481481                attachRenderTree(downcast<Element>(*child), inheritedStyle, renderTreePosition, nullptr);
    482482        }
     483    } else {
     484        for (Node* child = slot.firstChild(); child; child = child->nextSibling()) {
     485            if (is<Text>(*child))
     486                attachTextRenderer(downcast<Text>(*child), renderTreePosition);
     487            else if (is<Element>(*child))
     488                attachRenderTree(downcast<Element>(*child), inheritedStyle, renderTreePosition, nullptr);
     489        }
    483490    }
    484491    slot.clearNeedsStyleRecalc();
     
    577584    if (auto* assignedNodes = slot.assignedNodes()) {
    578585        for (auto* child : *assignedNodes) {
     586            if (is<Text>(*child))
     587                detachTextRenderer(downcast<Text>(*child));
     588            else if (is<Element>(*child))
     589                detachRenderTree(downcast<Element>(*child), detachType);
     590        }
     591    } else {
     592        for (Node* child = slot.firstChild(); child; child = child->nextSibling()) {
    579593            if (is<Text>(*child))
    580594                detachTextRenderer(downcast<Text>(*child));
     
    853867                resolveTree(downcast<Element>(*child), inheritedStyle, renderTreePosition, change);
    854868        }
     869    } else {
     870        for (Node* child = slot.firstChild(); child; child = child->nextSibling()) {
     871            if (is<Text>(*child))
     872                resolveTextNode(downcast<Text>(*child), renderTreePosition);
     873            else if (is<Element>(*child))
     874                resolveTree(downcast<Element>(*child), inheritedStyle, renderTreePosition, change);
     875        }
    855876    }
    856877    slot.clearNeedsStyleRecalc();
Note: See TracChangeset for help on using the changeset viewer.