Rewrite HTMLDetailsElement using HTMLSlotElement
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Oct 2015 18:16:37 +0000 (18:16 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Oct 2015 18:16:37 +0000 (18:16 +0000)
commit5504bff484d2575128f35e72502455dcbb47c606
tree99294f527c7ec4a3445ad89ea926a10cc80ad930
parentcefbf1b11b8ebf314b441788744e2743db8b7f61
Rewrite HTMLDetailsElement using HTMLSlotElement
https://bugs.webkit.org/show_bug.cgi?id=149698

Reviewed by Andreas Kling.

Source/WebCore:

Use the modern Shadow DOM to implement <details> element. After this the legacy InsertionPoint and
related code can be removed.

Based on a patch by Ryosuke.

* dom/Element.cpp:
(WebCore::Element::childrenChanged):
* dom/EventDispatcher.cpp:
(WebCore::EventPath::EventPath):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::ShadowRoot):
(WebCore::ShadowRoot::~ShadowRoot):
(WebCore::ShadowRoot::removeAllEventListeners):
(WebCore::ShadowRoot::findAssignedSlot):
(WebCore::ShadowRoot::addSlotElementByName):
(WebCore::ShadowRoot::removeSlotElementByName):
(WebCore::ShadowRoot::invalidateSlotAssignments):
(WebCore::ShadowRoot::invalidateDefaultSlotAssignments):
(WebCore::ShadowRoot::assignedNodesForSlot):
* dom/ShadowRoot.h:
(WebCore::ShadowRoot::create):
(WebCore::ShadowRoot::distributor):
(WebCore::ShadowRoot::isOrphan):
* dom/SlotAssignment.cpp:
(WebCore::slotNameFromAttributeValue):

    Rename for clarity.

(WebCore::slotNameFromSlotAttribute):

    SlotAssignment can now be specialized by providing function that maps from node to slot name.
    This is the default function that gets the name from the slot attribute.

(WebCore::SlotAssignment::SlotAssignment):
(WebCore::SlotAssignment::findAssignedSlot):

    Use the name mapping function.
    Ensure that the slots are assigned.

(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::assignedNodesForSlot):
(WebCore::SlotAssignment::invalidate):
(WebCore::SlotAssignment::invalidateDefaultSlot):
(WebCore::SlotAssignment::resolveAllSlotElements):
(WebCore::SlotAssignment::assignSlots):

    Use the name mapping function.

(WebCore::SlotAssignment::assignToSlot):

    Factor into function.

(WebCore::treatNullAsEmpty): Deleted.
* dom/SlotAssignment.h:
(WebCore::SlotAssignment::~SlotAssignment):
(WebCore::SlotAssignment::defaultSlotName):

    Add static getter for emptyAtom for clarity.

(WebCore::SlotAssignment::SlotAssignment): Deleted.
* html/HTMLDetailsElement.cpp:
(WebCore::summarySlotName):
(WebCore::slotNameFunction):

    Slot name function for <details>. It assigns the first <summary> child to the summary slot and others
    to the default content slot if the element is open.

(WebCore::HTMLDetailsElement::create):
(WebCore::HTMLDetailsElement::didAddUserAgentShadowRoot):
(WebCore::HTMLDetailsElement::isActiveSummary):
(WebCore::HTMLDetailsElement::parseAttribute):
(WebCore::HTMLDetailsElement::toggleOpen):
(WebCore::summaryQuerySelector): Deleted.
(WebCore::DetailsContentElement::create): Deleted.
(WebCore::DetailsSummaryElement::create): Deleted.
(WebCore::HTMLDetailsElement::findMainSummary): Deleted.
(WebCore::HTMLDetailsElement::childShouldCreateRenderer): Deleted.
* html/HTMLDetailsElement.h:
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::create):
(WebCore::HTMLSummaryElement::createElementRenderer):
(WebCore::HTMLSummaryElement::didAddUserAgentShadowRoot):
(WebCore::HTMLSummaryElement::detailsElement):
(WebCore::HTMLSummaryElement::isActiveSummary):
(WebCore::isClickableControl):
(WebCore::HTMLSummaryElement::supportsFocus):
(WebCore::HTMLSummaryElement::defaultEventHandler):
(WebCore::HTMLSummaryElement::willRespondToMouseClickEvents):
(WebCore::SummaryContentElement::create): Deleted.
(WebCore::HTMLSummaryElement::childShouldCreateRenderer): Deleted.
(WebCore::HTMLSummaryElement::isMainSummary): Deleted.
* html/HTMLSummaryElement.h:
* html/shadow/DetailsMarkerControl.cpp:
(WebCore::DetailsMarkerControl::rendererIsNeeded):
* style/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):

    Skip the verification assert for shadow host children. Getting this right requires
    better shadow-aware traversal code.

* style/StyleResolveTree.cpp:
(WebCore::Style::invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded):
(WebCore::Style::attachChildren):
(WebCore::Style::attachShadowRoot):
(WebCore::Style::attachBeforeOrAfterPseudoElementIfNeeded):
(WebCore::Style::attachSlotAssignees):
(WebCore::Style::attachRenderTree):
(WebCore::Style::detachChildren):
(WebCore::Style::detachShadowRoot):
(WebCore::Style::detachSlotAssignees):
(WebCore::Style::detachRenderTree):
(WebCore::Style::resolveChildren):
(WebCore::Style::resolveSlotAssignees):
(WebCore::Style::resolveTree):
(WebCore::Style::attachDistributedChildren): Deleted.
(WebCore::Style::detachDistributedChildren): Deleted.

    Remove InsertionPoint related code paths.

LayoutTests:

* TestExpectations:
* platform/mac/fast/html/details-add-child-2-expected.txt:
* platform/mac/fast/html/details-open2-expected.txt:
* platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt:
* platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/platform/mac-mavericks/fast/html/details-open2-expected.txt
LayoutTests/platform/mac/fast/css-generated-content/details-summary-before-after-expected.txt
LayoutTests/platform/mac/fast/html/details-add-child-2-expected.txt
LayoutTests/platform/mac/fast/html/details-open2-expected.txt
LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt
LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/SlotAssignment.cpp
Source/WebCore/dom/SlotAssignment.h
Source/WebCore/html/HTMLDetailsElement.cpp
Source/WebCore/html/HTMLDetailsElement.h
Source/WebCore/html/HTMLSlotElement.cpp
Source/WebCore/html/HTMLSlotElement.h
Source/WebCore/html/HTMLSummaryElement.cpp
Source/WebCore/html/HTMLSummaryElement.h
Source/WebCore/html/shadow/DetailsMarkerControl.cpp
Source/WebCore/style/RenderTreePosition.cpp
Source/WebCore/style/StyleResolveTree.cpp