Bug 1448791 [wpt PR 10174] - Keep track of all pending slot assignments, and recalc all before UpdateStyle phase, a=testonly
authorHayato Ito <hayato@chromium.org>
Mon, 09 Apr 2018 18:20:53 +0000
changeset 467202 47729ad34d0c910d0f3a878876cb96f582b4bd57
parent 467201 620e06af2cc635316118d703303f61df7d848505
child 467203 9b3559817a30c0b0f29d919b5ec8c145d4adfcdb
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1448791, 10174, 535493, 776656, 964062, 546458
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1448791 [wpt PR 10174] - Keep track of all pending slot assignments, and recalc all before UpdateStyle phase, a=testonly Automatic update from web-platform-testsKeep track of all pending slot assignments, and recalc all before UpdateStyle phase For the purpose of rendering, Blink must calculate all pending slot assignments before UpdateStyle phase. Unless that, a recursive RecalcStyle() may not traverse a node which should be re-attached. e.g. Suppose the following tree, where #d1 is assigned to a slot. host ├──/shadow-root │ └── slot name=s1 └── div id=d1 slot=s1 Then, we change #d1's slot attribute to s2, like: > document.querySelector('#d1').setAttribute('slot', 's2'); host ├──/shadow-root │ └── slot name=s1 └── div id=d1 slot=s2 In this case, #d1 should be removed from a LayoutTree. In other words, Blink has to reattach #d1 somehow. However, if we don't recalc a slot assignment for the shadow tree before UpdateStyle, a recursive RecalcStyle never traverses the sub-tree because child-needs-style-recalc flag is not set for the node (and its ancestor nodes). A flag should be set as a result of slot assignment recalc. Thanks to the Incremental Shadow DOM, a slot assignemt recalc now becomes a local operatoin on each shadow tree, rather than one global operation for every shadow trees. We don't need to traverse a composed tree to recalc all. We can recalc a slot assignment for each shadow tree directly, without traversing a composed tree. For a shadow tree which is not connected, we don't need to recalc its slot assignment before UpdateStyle because such a shadow tree shouldn't have any effect on rendering. Lazy slot assignment recalc is enough for such a shadow tree. This CL doesn't introduce any optimization to minimize the number of to-be-reattached nodes. I'll optimize that as a next task. I'll use a sort of dynamic programming there, as I did at https://chromium-review.googlesource.com/c/chromium/src/+/535493 for non-Incremental Shadow DOM. Except for the performance, this CL should be the last part of Incremental Shadow DOM from the external behavior's perspective. Style and Layout should work correctly after this CL, even with Incremental Shadow DOM. BUG=776656 Change-Id: Id18e87ff59d92863c68c571e7db09253c08aa91f Reviewed-on: https://chromium-review.googlesource.com/964062 Reviewed-by: Takayoshi Kochi <kochi@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Hayato Ito <hayato@chromium.org> Cr-Commit-Position: refs/heads/master@{#546458} wpt-commits: 1d25beb750906894ae1306c69ba2290e527b7048 wpt-pr: 10174 wpt-commits: 1d25beb750906894ae1306c69ba2290e527b7048 wpt-pr: 10174
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/shadow-dom/layout-slot-no-longer-assigned.html
testing/web-platform/tests/shadow-dom/layout-slot-no-longer-fallback.html
testing/web-platform/tests/shadow-dom/reference/empty.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -181492,16 +181492,40 @@
       [
        "/service-workers/service-worker/resources/svg-target-reftest-001.html",
        "=="
       ]
      ],
      {}
     ]
    ],
+   "shadow-dom/layout-slot-no-longer-assigned.html": [
+    [
+     "/shadow-dom/layout-slot-no-longer-assigned.html",
+     [
+      [
+       "/shadow-dom/reference/empty.html",
+       "=="
+      ]
+     ],
+     {}
+    ]
+   ],
+   "shadow-dom/layout-slot-no-longer-fallback.html": [
+    [
+     "/shadow-dom/layout-slot-no-longer-fallback.html",
+     [
+      [
+       "/shadow-dom/reference/empty.html",
+       "=="
+      ]
+     ],
+     {}
+    ]
+   ],
    "shadow-dom/untriaged/shadow-trees/nested-shadow-trees/nested_tree_reftest.html": [
     [
      "/shadow-dom/untriaged/shadow-trees/nested-shadow-trees/nested_tree_reftest.html",
      [
       [
        "/shadow-dom/untriaged/shadow-trees/nested-shadow-trees/nested_tree_reftest-ref.html",
        "=="
       ]
@@ -293348,16 +293372,21 @@
      {}
     ]
    ],
    "shadow-dom/OWNERS": [
     [
      {}
     ]
    ],
+   "shadow-dom/reference/empty.html": [
+    [
+     {}
+    ]
+   ],
    "shadow-dom/resources/Document-prototype-currentScript-helper.js": [
     [
      {}
     ]
    ],
    "shadow-dom/resources/event-path-test-helpers.js": [
     [
      {}
@@ -595621,28 +595650,40 @@
   "shadow-dom/event-with-related-target.html": [
    "572ddb9624ba8871d93cb13fad830f1acc8d4cac",
    "testharness"
   ],
   "shadow-dom/historical.html": [
    "1469992db34a25397dc3d5a5e1eb600e8afcf71b",
    "testharness"
   ],
+  "shadow-dom/layout-slot-no-longer-assigned.html": [
+   "224a688177941774e0bd3be74cb4aef20160d903",
+   "reftest"
+  ],
+  "shadow-dom/layout-slot-no-longer-fallback.html": [
+   "a9be2ec9174a8944a237462b51519a8f88b4987a",
+   "reftest"
+  ],
   "shadow-dom/leaktests/get-elements.html": [
    "ceffb5ff2e8b171975acb616d83079f0cfa7a82a",
    "testharness"
   ],
   "shadow-dom/leaktests/html-collection.html": [
    "b7d7b4e6f6632965459787809c1fb5075ae11b7b",
    "testharness"
   ],
   "shadow-dom/leaktests/window-frames.html": [
    "2e7c236bb756dfbd3a6c42c547fc7d7e897883ce",
    "testharness"
   ],
+  "shadow-dom/reference/empty.html": [
+   "51a23151c28992fe062b36914463de216bd55fbe",
+   "support"
+  ],
   "shadow-dom/resources/Document-prototype-currentScript-helper.js": [
    "f7d4af7942bcd858df4a2f1a8bbda86b32baee31",
    "support"
   ],
   "shadow-dom/resources/event-path-test-helpers.js": [
    "0b3340091c93e37362c5008fded9ac4efd042f35",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/shadow-dom/layout-slot-no-longer-assigned.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title>Layout using slot elements</title>
+<link rel="author" title="Hayato Ito" href="mailto:hayato@google.com"/>
+<link rel="help" href="https://dom.spec.whatwg.org/#shadow-tree-slots">
+<link rel="match" href="reference/empty.html"/>
+<div id="host"></div>
+<script>
+const host = document.querySelector('#host');
+const sr = host.attachShadow({ mode: 'open' });
+sr.innerHTML = '<slot name=s1></slot>'
+host.innerHTML = '<div id=d1 slot=s1></div>';
+
+document.body.offsetLeft;
+document.querySelector('#d1').setAttribute('slot', 's2');
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/shadow-dom/layout-slot-no-longer-fallback.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title>Layout using slot elements</title>
+<link rel="author" title="Hayato Ito" href="mailto:hayato@google.com"/>
+<link rel="help" href="https://dom.spec.whatwg.org/#shadow-tree-slots">
+<link rel="match" href="reference/empty.html"/>
+<div id="host"></div>
+<script>
+const host = document.querySelector('#host');
+const sr = host.attachShadow({ mode: 'open' });
+
+sr.innerHTML = '<slot><div id="fallback">Should not be displayed</div></slot>'
+
+document.body.offsetLeft;
+host.appendChild(document.createElement('div'));
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/shadow-dom/reference/empty.html
@@ -0,0 +1,1 @@
+<!DOCTYPE html>