Skip to content
Permalink
Browse files
Rename ShadowRoot::hostElement to shadowRoot::host to match the lates…
…t spec

https://bugs.webkit.org/show_bug.cgi?id=148694

Reviewed by Chris Dumez.

Renamed ShadowRoot::hostElement to ShadowRoot::host to match the latest shadow DOM spec.
This will help us implementing shadow DOM in near future.

* dom/ContainerNodeAlgorithms.cpp:
(WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
(WebCore::ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::removeShadowRoot):
* dom/EventDispatcher.cpp:
(WebCore::EventRelatedNodeResolver::moveToParentOrShadowHost):
(WebCore::EventRelatedNodeResolver::findHostOfTreeScopeInTargetTreeScope):
(WebCore::shouldEventCrossShadowBoundary):
(WebCore::EventPath::EventPath):
* dom/Node.cpp:
(WebCore::Node::shadowHost):
(WebCore::Node::deprecatedShadowAncestorNode):
(WebCore::Node::parentOrShadowHostElement):
* dom/NodeRenderingTraversal.cpp:
(WebCore::NodeRenderingTraversal::traverseParent):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::setInnerHTML):
(WebCore::ShadowRoot::setResetStyleInheritance):
* dom/ShadowRoot.h:
(WebCore::Node::parentOrShadowHostNode):
* dom/Text.cpp:
(WebCore::isSVGShadowText):
* dom/TreeScope.cpp:
(WebCore::TreeScope::focusedElement):
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::ensureDistribution):
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::insertedInto):
(WebCore::InsertionPoint::removedFrom):
* page/DragController.cpp:
(WebCore::asFileInput):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
* page/FocusController.cpp:
(WebCore::FocusNavigationScope::owner):
* rendering/RenderLayer.cpp:
(WebCore::rendererForScrollbar):
* style/StyleResolveTree.cpp:
(WebCore::Style::attachShadowRoot):
(WebCore::Style::resolveShadowTree):
* svg/SVGElement.cpp:
(WebCore::SVGElement::correspondingUseElement):


Canonical link: https://commits.webkit.org/166817@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Sep 2, 2015
1 parent bb7f2df commit cdb6baa9e5ed3682205266bac71c46224357b5f8
Showing 18 changed files with 89 additions and 34 deletions.
@@ -1,3 +1,58 @@
2015-09-01 Ryosuke Niwa <rniwa@webkit.org>

Rename ShadowRoot::hostElement to shadowRoot::host to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=148694

Reviewed by Chris Dumez.

Renamed ShadowRoot::hostElement to ShadowRoot::host to match the latest shadow DOM spec.
This will help us implementing shadow DOM in near future.

* dom/ContainerNodeAlgorithms.cpp:
(WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
(WebCore::ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::removeShadowRoot):
* dom/EventDispatcher.cpp:
(WebCore::EventRelatedNodeResolver::moveToParentOrShadowHost):
(WebCore::EventRelatedNodeResolver::findHostOfTreeScopeInTargetTreeScope):
(WebCore::shouldEventCrossShadowBoundary):
(WebCore::EventPath::EventPath):
* dom/Node.cpp:
(WebCore::Node::shadowHost):
(WebCore::Node::deprecatedShadowAncestorNode):
(WebCore::Node::parentOrShadowHostElement):
* dom/NodeRenderingTraversal.cpp:
(WebCore::NodeRenderingTraversal::traverseParent):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::setInnerHTML):
(WebCore::ShadowRoot::setResetStyleInheritance):
* dom/ShadowRoot.h:
(WebCore::Node::parentOrShadowHostNode):
* dom/Text.cpp:
(WebCore::isSVGShadowText):
* dom/TreeScope.cpp:
(WebCore::TreeScope::focusedElement):
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::ensureDistribution):
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::insertedInto):
(WebCore::InsertionPoint::removedFrom):
* page/DragController.cpp:
(WebCore::asFileInput):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
* page/FocusController.cpp:
(WebCore::FocusNavigationScope::owner):
* rendering/RenderLayer.cpp:
(WebCore::rendererForScrollbar):
* style/StyleResolveTree.cpp:
(WebCore::Style::attachShadowRoot):
(WebCore::Style::resolveShadowTree):
* svg/SVGElement.cpp:
(WebCore::SVGElement::correspondingUseElement):

2015-09-01 Chris Dumez <cdumez@apple.com>

NodeFilter should be a callback interface
@@ -44,7 +44,7 @@ void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN
return;

if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
if (node.inDocument() && root->hostElement() == &node)
if (node.inDocument() && root->host() == &node)
notifyNodeInsertedIntoDocument(*root, postInsertionNotificationTargets);
}
}
@@ -78,7 +78,7 @@ void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode
node.document().setCSSTarget(0);

if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
if (!node.inDocument() && root->hostElement() == &node)
if (!node.inDocument() && root->host() == &node)
notifyNodeRemovedFromDocument(*root.get());
}
}
@@ -1631,7 +1631,7 @@ void Element::addShadowRoot(Ref<ShadowRoot>&& newShadowRoot)
ShadowRoot& shadowRoot = newShadowRoot.get();
ensureElementRareData().setShadowRoot(WTF::move(newShadowRoot));

shadowRoot.setHostElement(this);
shadowRoot.setHost(this);
shadowRoot.setParentTreeScope(&treeScope());
shadowRoot.distributor().didShadowBoundaryChange(this);

@@ -1660,7 +1660,7 @@ void Element::removeShadowRoot()

elementRareData()->clearShadowRoot();

oldRoot->setHostElement(0);
oldRoot->setHost(0);
oldRoot->setParentTreeScope(&document());

ChildNodeRemovalNotifier(*this).notify(*oldRoot);
@@ -143,7 +143,7 @@ class EventRelatedNodeResolver {

if (m_currentTreeScope) {
ASSERT(is<ShadowRoot>(m_currentTreeScope->rootNode()));
ASSERT(&newTarget == downcast<ShadowRoot>(m_currentTreeScope->rootNode()).hostElement());
ASSERT(&newTarget == downcast<ShadowRoot>(m_currentTreeScope->rootNode()).host());
ASSERT(m_currentTreeScope->parentTreeScope() == &newTreeScope);
}

@@ -184,7 +184,7 @@ class EventRelatedNodeResolver {
return previousHost;
}
if (is<ShadowRoot>(scope->rootNode()))
previousHost = downcast<ShadowRoot>(scope->rootNode()).hostElement();
previousHost = downcast<ShadowRoot>(scope->rootNode()).host();
else
ASSERT_WITH_SECURITY_IMPLICATION(!scope->parentTreeScope());
}
@@ -385,7 +385,7 @@ static inline bool shouldEventCrossShadowBoundary(Event& event, ShadowRoot& shad
if (Element* element = targetNode->document().webkitCurrentFullScreenElement()) {
// FIXME: We assume that if the full screen element is a media element that it's
// the video-only full screen. Both here and elsewhere. But that is probably wrong.
if (element->isMediaElement() && shadowRoot.hostElement() == element)
if (element->isMediaElement() && shadowRoot.host() == element)
return false;
}
}
@@ -444,7 +444,7 @@ EventPath::EventPath(Node& targetNode, Event& event)
}
if (!node || !shouldEventCrossShadowBoundary(event, downcast<ShadowRoot>(*node), *target))
return;
node = downcast<ShadowRoot>(*node).hostElement();
node = downcast<ShadowRoot>(*node).host();
}
}

@@ -1034,14 +1034,14 @@ bool Node::canStartSelection() const
Element* Node::shadowHost() const
{
if (ShadowRoot* root = containingShadowRoot())
return root->hostElement();
return root->host();
return 0;
}

Node* Node::deprecatedShadowAncestorNode() const
{
if (ShadowRoot* root = containingShadowRoot())
return root->hostElement();
return root->host();

return const_cast<Node*>(this);
}
@@ -1086,7 +1086,7 @@ Element* Node::parentOrShadowHostElement() const
return nullptr;

if (is<ShadowRoot>(*parent))
return downcast<ShadowRoot>(*parent).hostElement();
return downcast<ShadowRoot>(*parent).host();

if (!is<Element>(*parent))
return nullptr;
@@ -133,7 +133,7 @@ static ContainerNode* traverseParent(const Node* node, ShadowRootCrossing shadow
return nullptr;

if (is<ShadowRoot>(*parent))
return shadowRootCrossing == CrossShadowRoot ? downcast<ShadowRoot>(parent)->hostElement() : parent;
return shadowRootCrossing == CrossShadowRoot ? downcast<ShadowRoot>(parent)->host() : parent;

if (is<InsertionPoint>(*parent)) {
const InsertionPoint& insertionPoint = downcast<InsertionPoint>(*parent);
@@ -91,7 +91,7 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec)
return;
}

if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, hostElement(), AllowScriptingContent, ec))
if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, host(), AllowScriptingContent, ec))
replaceChildrenWithFragment(*this, fragment.release(), ec);
}

@@ -117,7 +117,7 @@ void ShadowRoot::setResetStyleInheritance(bool value)

if (value != m_resetStyleInheritance) {
m_resetStyleInheritance = value;
if (hostElement())
if (host())
setNeedsStyleRecalc();
}
}
@@ -53,8 +53,8 @@ class ShadowRoot final : public DocumentFragment, public TreeScope {
bool resetStyleInheritance() const { return m_resetStyleInheritance; }
void setResetStyleInheritance(bool);

Element* hostElement() const { return m_hostElement; }
void setHostElement(Element* hostElement) { m_hostElement = hostElement; }
Element* host() const { return m_hostElement; }
void setHost(Element* hostElement) { m_hostElement = hostElement; }

String innerHTML() const;
void setInnerHTML(const String&, ExceptionCode&);
@@ -66,7 +66,7 @@ class ShadowRoot final : public DocumentFragment, public TreeScope {
PassRefPtr<Node> cloneNode(bool, ExceptionCode&);

ContentDistributor& distributor() { return m_distributor; }
void invalidateDistribution() { m_distributor.invalidateDistribution(hostElement()); }
void invalidateDistribution() { m_distributor.invalidateDistribution(m_hostElement); }

virtual void removeAllEventListeners() override;

@@ -79,7 +79,7 @@ class ShadowRoot final : public DocumentFragment, public TreeScope {
virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;

// FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
bool isOrphan() const { return !hostElement(); }
bool isOrphan() const { return !m_hostElement; }

unsigned m_resetStyleInheritance : 1;
unsigned m_type : 1;
@@ -105,7 +105,7 @@ inline ContainerNode* Node::parentOrShadowHostNode() const
{
ASSERT(isMainThreadOrGCThread());
if (is<ShadowRoot>(*this))
return downcast<ShadowRoot>(*this).hostElement();
return downcast<ShadowRoot>(*this).host();
return parentNode();
}

@@ -175,7 +175,7 @@ static bool isSVGShadowText(Text* text)
{
Node* parentNode = text->parentNode();
ASSERT(parentNode);
return is<ShadowRoot>(*parentNode) && downcast<ShadowRoot>(*parentNode).hostElement()->hasTagName(SVGNames::trefTag);
return is<ShadowRoot>(*parentNode) && downcast<ShadowRoot>(*parentNode).host()->hasTagName(SVGNames::trefTag);
}

static bool isSVGText(Text* text)
@@ -313,7 +313,7 @@ Element* TreeScope::focusedElement()
return nullptr;
TreeScope* treeScope = &element->treeScope();
while (treeScope != this && treeScope != &document) {
element = downcast<ShadowRoot>(treeScope->rootNode()).hostElement();
element = downcast<ShadowRoot>(treeScope->rootNode()).host();
treeScope = &element->treeScope();
}
if (this != treeScope)
@@ -126,15 +126,15 @@ void ContentDistributor::ensureDistribution(ShadowRoot* shadowRoot)
ASSERT(shadowRoot);

Vector<ShadowRoot*, 8> shadowRoots;
for (Element* current = shadowRoot->hostElement(); current; current = current->shadowHost()) {
for (Element* current = shadowRoot->host(); current; current = current->shadowHost()) {
ShadowRoot* currentRoot = current->shadowRoot();
if (!currentRoot->distributor().needsDistribution())
break;
shadowRoots.append(currentRoot);
}

for (size_t i = shadowRoots.size(); i > 0; --i)
shadowRoots[i - 1]->distributor().distribute(shadowRoots[i - 1]->hostElement());
shadowRoots[i - 1]->distributor().distribute(shadowRoots[i - 1]->host());
}

void ContentDistributor::invalidateDistribution(Element* host)
@@ -85,7 +85,7 @@ Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode& i
HTMLElement::insertedInto(insertionPoint);

if (ShadowRoot* root = containingShadowRoot()) {
root->distributor().didShadowBoundaryChange(root->hostElement());
root->distributor().didShadowBoundaryChange(root->host());
root->distributor().invalidateInsertionPointList();
}

@@ -98,7 +98,7 @@ void InsertionPoint::removedFrom(ContainerNode& insertionPoint)
if (!root)
root = insertionPoint.containingShadowRoot();

if (root && root->hostElement()) {
if (root && root->host()) {
root->invalidateDistribution();
root->distributor().invalidateInsertionPointList();
}
@@ -290,7 +290,7 @@ static HTMLInputElement* asFileInput(Node* node)

// If this is a button inside of the a file input, move up to the file input.
if (inputElement && inputElement->isTextButton() && is<ShadowRoot>(inputElement->treeScope().rootNode()))
inputElement = downcast<ShadowRoot>(inputElement->treeScope().rootNode()).hostElement()->toInputElement();
inputElement = downcast<ShadowRoot>(inputElement->treeScope().rootNode()).host()->toInputElement();

return inputElement && inputElement->isFileUpload() ? inputElement : 0;
}
@@ -1816,7 +1816,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& platformMouse
// If a mouse event handler changes the input element type to one that has a widget associated,
// we'd like to EventHandler::handleMousePressEvent to pass the event to the widget and thus the
// event target node can't still be the shadow node.
if (is<ShadowRoot>(*mouseEvent.targetNode()) && is<HTMLInputElement>(*downcast<ShadowRoot>(*mouseEvent.targetNode()).hostElement()))
if (is<ShadowRoot>(*mouseEvent.targetNode()) && is<HTMLInputElement>(*downcast<ShadowRoot>(*mouseEvent.targetNode()).host()))
mouseEvent = m_frame.document()->prepareMouseEvent(HitTestRequest(), documentPoint, platformMouseEvent);

FrameView* view = m_frame.view();
@@ -83,7 +83,7 @@ Element* FocusNavigationScope::owner() const
{
ContainerNode* root = rootNode();
if (is<ShadowRoot>(*root))
return downcast<ShadowRoot>(*root).hostElement();
return downcast<ShadowRoot>(*root).host();
if (Frame* frame = root->document().frame())
return frame->ownerElement();
return nullptr;
@@ -3063,7 +3063,7 @@ static inline RenderElement* rendererForScrollbar(RenderLayerModelObject& render
if (Element* element = renderer.element()) {
if (ShadowRoot* shadowRoot = element->containingShadowRoot()) {
if (shadowRoot->type() == ShadowRoot::UserAgentShadowRoot)
return shadowRoot->hostElement()->renderer();
return shadowRoot->host()->renderer();
}
}

@@ -385,10 +385,10 @@ static void attachDistributedChildren(InsertionPoint& insertionPoint, RenderStyl

static void attachShadowRoot(ShadowRoot& shadowRoot)
{
ASSERT(shadowRoot.hostElement());
ASSERT(shadowRoot.hostElement()->renderer());
ASSERT(shadowRoot.host());
ASSERT(shadowRoot.host()->renderer());

auto& renderer = *shadowRoot.hostElement()->renderer();
auto& renderer = *shadowRoot.host()->renderer();
RenderTreePosition renderTreePosition(renderer);
attachChildren(shadowRoot, renderer.style(), renderTreePosition);

@@ -678,7 +678,7 @@ void resolveTextNode(Text& text, RenderTreePosition& renderTreePosition)

static void resolveShadowTree(ShadowRoot& shadowRoot, Element& host, Style::Change change)
{
ASSERT(shadowRoot.hostElement() == &host);
ASSERT(shadowRoot.host() == &host);
ASSERT(host.renderer());
RenderTreePosition renderTreePosition(*host.renderer());
for (Node* child = shadowRoot.firstChild(); child; child = child->nextSibling()) {
@@ -490,7 +490,7 @@ SVGUseElement* SVGElement::correspondingUseElement() const
return nullptr;
if (root->type() != ShadowRoot::UserAgentShadowRoot)
return nullptr;
auto* host = root->hostElement();
auto* host = root->host();
if (!is<SVGUseElement>(host))
return nullptr;
return &downcast<SVGUseElement>(*host);

0 comments on commit cdb6baa

Please sign in to comment.