Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: third_party/WebKit/Source/core/dom/shadow/ElementShadow.h

Issue 1489433002: Support the essential part of Shadow DOM v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert Internals.* Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
diff --git a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
index ea06f7786de792acfe1a44ddf5d0918c224697e7..bd67343226c0eea6d9d0c7e1dd60c6bc74069c69 100644
--- a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
+++ b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
@@ -31,6 +31,7 @@
#include "core/dom/shadow/InsertionPoint.h"
#include "core/dom/shadow/SelectRuleFeatureSet.h"
#include "core/dom/shadow/ShadowRoot.h"
+#include "core/dom/shadow/SlotAssignment.h"
#include "platform/heap/Handle.h"
#include "wtf/DoublyLinkedList.h"
#include "wtf/HashMap.h"
@@ -51,6 +52,19 @@ public:
ShadowRoot* oldestShadowRoot() const { return m_shadowRoots.tail(); }
ElementShadow* containingShadow() const;
+ ShadowRoot* shadowRootIfV1() const
+ {
+ if (isV1())
+ return &youngestShadowRoot();
+ return nullptr;
+ }
+
+ HTMLSlotElement* assignedSlotFor(const Node& node) const
+ {
+ ASSERT(m_slotAssignment);
+ return m_slotAssignment->assignedSlotFor(node);
+ }
+
ShadowRoot& addShadowRoot(Element& shadowHost, ShadowRootType);
bool hasSameStyles(const ElementShadow*) const;
@@ -69,6 +83,8 @@ public:
void didDistributeNode(const Node*, InsertionPoint*);
+ bool isV1() const { return youngestShadowRoot().isV1(); };
+
DECLARE_TRACE();
private:
@@ -90,8 +106,6 @@ private:
bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; }
void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; }
- bool isV1() const { return youngestShadowRoot().type() == ShadowRootType::Open || youngestShadowRoot().type() == ShadowRootType::Closed; };
-
#if ENABLE(OILPAN)
// The cost of |new| in Oilpan is lower than non-Oilpan. We should reduce
// the size of HashMap entry.
@@ -106,6 +120,9 @@ private:
DoublyLinkedList<ShadowRoot> m_shadowRoots;
bool m_needsDistributionRecalc;
bool m_needsSelectFeatureSet;
+
+ // TODO(hayato): ShadowRoot should be an owner of SlotAssigment
+ OwnPtr<SlotAssignment> m_slotAssignment;
};
inline Element* ElementShadow::host() const
@@ -128,6 +145,13 @@ inline ShadowRoot* Element::youngestShadowRoot() const
return 0;
}
+inline ShadowRoot* Element::shadowRootIfV1() const
+{
+ if (ElementShadow* shadow = this->shadow())
+ return shadow->shadowRootIfV1();
+ return nullptr;
+}
+
inline ElementShadow* ElementShadow::containingShadow() const
{
if (ShadowRoot* parentRoot = host()->containingShadowRoot())

Powered by Google App Engine
This is Rietveld 408576698