haikuwebkit/LayoutTests/fast/shadow-dom/shadow-layout-after-slot-ch...

66 lines
1.8 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<body>
<p>Test passes if you see a single 100px by 100px green box below.</p>
<my-host id="host1" style="background: green;"><div style="background: red;">FAIL</div></my-host>
<my-host id="host2" style="background: green;"><div slot="foo" style="background: red;">FAIL</div></my-host>
<my-host id="host3" style="background: red;"><div style="background: green;"></div><div slot="foo" style="background: red;">FAIL</div></my-host>
<my-host id="host4" style="background: red;"><div style="background: green;"></div></my-host>
<style>
my-host {
display: block;
width: 100px;
height: 25px;
overflow: hidden;
}
my-host > div {
width: 100%;
height: 100%;
}
</style>
<script>
invalidateSlotAssignments should trigger style recalc https://bugs.webkit.org/show_bug.cgi?id=149447 Reviewed by Antti Koivisto. Source/WebCore: Invalidate the render tree of a shadow host when a new child is inserted, an existing child is removed, or slot attribute of a child is modified. No new tests. Covered by existing tests added in r190101. * dom/Element.cpp: (WebCore::Element::childrenChanged): Call invalidateSlotAssignments or invalidateDefaultSlotAssignments depending on the types of children being inserted or removed since text nodes can only be assigned into a default slot. * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::invalidateSlotAssignments): (WebCore::ShadowRoot::invalidateDefaultSlotAssignments): Added. * dom/ShadowRoot.h: * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::invalidate): Reconstruct the render tree for the whole host. We can optimize in the future by only invalidating active slot elements instead. (WebCore::SlotAssignment::invalidateDefaultSlot): Added. * dom/SlotAssignment.h: LayoutTests: Removed failing expectations from newly passing tests. Also added test cases for inserting and removing text nodes, and modified the style recalc tests to force layout between each DOM change to test case separately. * fast/shadow-dom/shadow-layout-after-host-child-changes.html: * fast/shadow-dom/shadow-layout-after-inserting-or-removing-host-child.html: * fast/shadow-dom/shadow-layout-after-slot-changes.html: * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/167540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-22 08:17:09 +00:00
function forceLayout() {
if (window.internals)
internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
else
document.querySelector('p').getBoundingClientRect();
}
try {
var shadow1 = document.getElementById('host1').attachShadow({mode: 'open'});
shadow1.innerHTML = '<slot></slot>';
var shadow2 = document.getElementById('host2').attachShadow({mode: 'open'});
shadow2.innerHTML = '<slot name="foo"></slot>';
var shadow3 = document.getElementById('host3').attachShadow({mode: 'open'});
shadow3.innerHTML = '<slot name="foo"></slot>';
var shadow4 = document.getElementById('host4').attachShadow({mode: 'open'});
shadow4.innerHTML = 'FAIL';
invalidateSlotAssignments should trigger style recalc https://bugs.webkit.org/show_bug.cgi?id=149447 Reviewed by Antti Koivisto. Source/WebCore: Invalidate the render tree of a shadow host when a new child is inserted, an existing child is removed, or slot attribute of a child is modified. No new tests. Covered by existing tests added in r190101. * dom/Element.cpp: (WebCore::Element::childrenChanged): Call invalidateSlotAssignments or invalidateDefaultSlotAssignments depending on the types of children being inserted or removed since text nodes can only be assigned into a default slot. * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::invalidateSlotAssignments): (WebCore::ShadowRoot::invalidateDefaultSlotAssignments): Added. * dom/ShadowRoot.h: * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::invalidate): Reconstruct the render tree for the whole host. We can optimize in the future by only invalidating active slot elements instead. (WebCore::SlotAssignment::invalidateDefaultSlot): Added. * dom/SlotAssignment.h: LayoutTests: Removed failing expectations from newly passing tests. Also added test cases for inserting and removing text nodes, and modified the style recalc tests to force layout between each DOM change to test case separately. * fast/shadow-dom/shadow-layout-after-host-child-changes.html: * fast/shadow-dom/shadow-layout-after-inserting-or-removing-host-child.html: * fast/shadow-dom/shadow-layout-after-slot-changes.html: * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/167540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-22 08:17:09 +00:00
forceLayout();
shadow1.removeChild(shadow1.firstChild);
invalidateSlotAssignments should trigger style recalc https://bugs.webkit.org/show_bug.cgi?id=149447 Reviewed by Antti Koivisto. Source/WebCore: Invalidate the render tree of a shadow host when a new child is inserted, an existing child is removed, or slot attribute of a child is modified. No new tests. Covered by existing tests added in r190101. * dom/Element.cpp: (WebCore::Element::childrenChanged): Call invalidateSlotAssignments or invalidateDefaultSlotAssignments depending on the types of children being inserted or removed since text nodes can only be assigned into a default slot. * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::invalidateSlotAssignments): (WebCore::ShadowRoot::invalidateDefaultSlotAssignments): Added. * dom/ShadowRoot.h: * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::invalidate): Reconstruct the render tree for the whole host. We can optimize in the future by only invalidating active slot elements instead. (WebCore::SlotAssignment::invalidateDefaultSlot): Added. * dom/SlotAssignment.h: LayoutTests: Removed failing expectations from newly passing tests. Also added test cases for inserting and removing text nodes, and modified the style recalc tests to force layout between each DOM change to test case separately. * fast/shadow-dom/shadow-layout-after-host-child-changes.html: * fast/shadow-dom/shadow-layout-after-inserting-or-removing-host-child.html: * fast/shadow-dom/shadow-layout-after-slot-changes.html: * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/167540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-22 08:17:09 +00:00
forceLayout();
shadow2.firstChild.name = 'bar';
invalidateSlotAssignments should trigger style recalc https://bugs.webkit.org/show_bug.cgi?id=149447 Reviewed by Antti Koivisto. Source/WebCore: Invalidate the render tree of a shadow host when a new child is inserted, an existing child is removed, or slot attribute of a child is modified. No new tests. Covered by existing tests added in r190101. * dom/Element.cpp: (WebCore::Element::childrenChanged): Call invalidateSlotAssignments or invalidateDefaultSlotAssignments depending on the types of children being inserted or removed since text nodes can only be assigned into a default slot. * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::invalidateSlotAssignments): (WebCore::ShadowRoot::invalidateDefaultSlotAssignments): Added. * dom/ShadowRoot.h: * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::invalidate): Reconstruct the render tree for the whole host. We can optimize in the future by only invalidating active slot elements instead. (WebCore::SlotAssignment::invalidateDefaultSlot): Added. * dom/SlotAssignment.h: LayoutTests: Removed failing expectations from newly passing tests. Also added test cases for inserting and removing text nodes, and modified the style recalc tests to force layout between each DOM change to test case separately. * fast/shadow-dom/shadow-layout-after-host-child-changes.html: * fast/shadow-dom/shadow-layout-after-inserting-or-removing-host-child.html: * fast/shadow-dom/shadow-layout-after-slot-changes.html: * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/167540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-22 08:17:09 +00:00
forceLayout();
Settings a reflected DOMString attribute to null should set it to the "null" string rather than the empty string https://bugs.webkit.org/show_bug.cgi?id=153504 <rdar://problem/24353072> Reviewed by Ryosuke Niwa. Source/WebCore: Settings a reflected DOMString attribute to null should set it to the "null" string rather than the empty string: - https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes - http://heycam.github.io/webidl/#es-DOMString - http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring Firefox and Chrome match the specification here. This is causing a lot of W3C HTML reflection tests to fail on WebKit, e.g.: - http://w3c-test.org/html/dom/reflection-text.html No new tests, already covered by existing tests. * bindings/scripts/CodeGeneratorJS.pm: (JSValueToNative): Call toString() instead of valueToStringWithNullCheck() for reflected attributes. This way, null gets converted to the string "null", as expected, instead of a null String object. * html/HTMLInputElement.idl: Dropping [TreatNullAs=NullString] IDL extended attribute for input.defaultValue, as this is not present in the specification: - https://html.spec.whatwg.org/#htmlinputelement Without this change, assigning null to input.defaultValue would not set to to the "null" string, as is expected. * html/HTMLTextAreaElement.idl: Dropping [TreatNullAs=NullString] IDL extended attribute for textArea.defaultValue, as this is not present in the specification: - https://html.spec.whatwg.org/#htmltextareaelement Without this change, assigning null to textArea.defaultValue would not set to to the "null" string, as is expected. * html/HTMLTitleElement.idl: Dropping [TreatNullAs=NullString] IDL extended attribute for title.text, as this is not present in the specification: - https://html.spec.whatwg.org/#htmltitleelement Without this change, assigning null to title.text would not set to to the "null" string, as is expected. LayoutTests: Update existing tests as a lot of them were expecting that setting a reflected DOMString attribute to null would set it to the empty string instead of the string "null". * fast/dom/domstring-attribute-reflection-expected.txt: * fast/dom/domstring-attribute-reflection.html: * fast/dom/element-attribute-js-null-expected.txt: * fast/dom/element-attribute-js-null.html: * fast/dom/ping-attribute-dom-binding-expected.txt: * fast/dom/ping-attribute-dom-binding.html: * fast/forms/fieldset/fieldset-name-expected.txt: * fast/forms/fieldset/fieldset-name.html: * fast/forms/input-minmax-expected.txt: * fast/forms/input-minmax.html: * fast/forms/input-pattern-expected.txt: * fast/forms/input-pattern.html: * fast/forms/submit-form-attributes-expected.txt: * fast/forms/submit-form-attributes.html: * fast/shadow-dom/HTMLSlotElement-interface.html: * fast/shadow-dom/NonDocumentTypeChildNode-interface-assignedSlot.html: * fast/shadow-dom/shadow-layout-after-slot-changes.html: * svg/dom/svg-element-attribute-js-null-expected.txt: * svg/dom/svg-element-attribute-js-null.xhtml: Canonical link: https://commits.webkit.org/171638@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195700 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-27 23:42:46 +00:00
shadow3.firstChild.removeAttribute("name");
invalidateSlotAssignments should trigger style recalc https://bugs.webkit.org/show_bug.cgi?id=149447 Reviewed by Antti Koivisto. Source/WebCore: Invalidate the render tree of a shadow host when a new child is inserted, an existing child is removed, or slot attribute of a child is modified. No new tests. Covered by existing tests added in r190101. * dom/Element.cpp: (WebCore::Element::childrenChanged): Call invalidateSlotAssignments or invalidateDefaultSlotAssignments depending on the types of children being inserted or removed since text nodes can only be assigned into a default slot. * dom/ShadowRoot.cpp: (WebCore::ShadowRoot::invalidateSlotAssignments): (WebCore::ShadowRoot::invalidateDefaultSlotAssignments): Added. * dom/ShadowRoot.h: * dom/SlotAssignment.cpp: (WebCore::SlotAssignment::invalidate): Reconstruct the render tree for the whole host. We can optimize in the future by only invalidating active slot elements instead. (WebCore::SlotAssignment::invalidateDefaultSlot): Added. * dom/SlotAssignment.h: LayoutTests: Removed failing expectations from newly passing tests. Also added test cases for inserting and removing text nodes, and modified the style recalc tests to force layout between each DOM change to test case separately. * fast/shadow-dom/shadow-layout-after-host-child-changes.html: * fast/shadow-dom/shadow-layout-after-inserting-or-removing-host-child.html: * fast/shadow-dom/shadow-layout-after-slot-changes.html: * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/167540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-22 08:17:09 +00:00
forceLayout();
shadow4.insertBefore(document.createElement('slot'), shadow4.firstChild);
} catch (exception) {
document.body.appendChild(document.createTextNode(exception));
}
</script>
</body>
</html>