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

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

Issue 2322213002: Refactor ElementShadow by separating v0 related features as ElementShadowV0 (Closed)
Patch Set: minor Created 4 years, 3 months 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 3a4fbb1fd402a8c5b3f52b4ab99e2a53479e8e1d..f20a471aa1537ea9e3d9b8534795c18f211282a8 100644
--- a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
+++ b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
@@ -1,75 +1,49 @@
-/*
tkent 2016/09/13 07:09:45 To me this file doesn't look a new file. Probably
hayato 2016/09/13 07:14:56 Sure. Done.
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef ElementShadow_h
#define ElementShadow_h
#include "core/CoreExport.h"
-#include "core/dom/shadow/InsertionPoint.h"
-#include "core/dom/shadow/SelectRuleFeatureSet.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "platform/heap/Handle.h"
-#include "wtf/HashMap.h"
#include "wtf/Noncopyable.h"
namespace blink {
+class ElementShadowV0;
+
class CORE_EXPORT ElementShadow final : public GarbageCollectedFinalized<ElementShadow> {
WTF_MAKE_NONCOPYABLE(ElementShadow);
public:
static ElementShadow* create();
~ElementShadow();
- Element& host() const;
+ Element& host() const { DCHECK(m_shadowRoot); return m_shadowRoot->host(); }
+
+ // TODO(hayato): Remove youngestShadowRoot() and oldestShadowRoot() from ElementShadow
ShadowRoot& youngestShadowRoot() const;
ShadowRoot& oldestShadowRoot() const { DCHECK(m_shadowRoot); return *m_shadowRoot; }
+
ElementShadow* containingShadow() const;
ShadowRoot& addShadowRoot(Element& shadowHost, ShadowRootType);
- bool hasSameStyles(const ElementShadow*) const;
+ bool hasSameStyles(const ElementShadow&) const;
void attach(const Node::AttachContext&);
void detach(const Node::AttachContext&);
void distributeIfNeeded();
+
void setNeedsDistributionRecalc();
bool needsDistributionRecalc() const { return m_needsDistributionRecalc; }
- bool isV1() const { return youngestShadowRoot().isV1(); };
- bool isOpenOrV0() const { return youngestShadowRoot().isOpenOrV0(); };
+ bool isV1() const { return youngestShadowRoot().isV1(); }
+ bool isOpenOrV0() const { return youngestShadowRoot().isOpenOrV0(); }
- // For only v0
- void willAffectSelector();
- const SelectRuleFeatureSet& ensureSelectFeatureSet();
-
- const InsertionPoint* finalDestinationInsertionPointFor(const Node*) const;
- const DestinationInsertionPoints* destinationInsertionPointsFor(const Node*) const;
-
- void didDistributeNode(const Node*, InsertionPoint*);
+ ElementShadowV0& v0() const { DCHECK(m_elementShadowV0); return *m_elementShadowV0; }
DECLARE_TRACE();
DECLARE_TRACE_WRAPPERS();
@@ -78,39 +52,17 @@ private:
ElementShadow();
void appendShadowRoot(ShadowRoot&);
-
void distribute();
- void clearDistributionV0();
-
- void distributeV0();
- void distributeV1();
-
- void collectSelectFeatureSetFrom(ShadowRoot&);
- void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*);
-
- bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; }
- void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; }
+ Member<ElementShadowV0> m_elementShadowV0;
Member<ShadowRoot> m_shadowRoot;
bool m_needsDistributionRecalc;
-
- // For only v0
- using NodeToDestinationInsertionPoints = HeapHashMap<Member<const Node>, Member<DestinationInsertionPoints>>;
- NodeToDestinationInsertionPoints m_nodeToInsertionPoints;
- SelectRuleFeatureSet m_selectFeatures;
- bool m_needsSelectFeatureSet;
};
-inline Element& ElementShadow::host() const
-{
- DCHECK(m_shadowRoot);
- return m_shadowRoot->host();
-}
-
inline ShadowRoot* Node::youngestShadowRoot() const
{
if (!isElementNode())
- return 0;
+ return nullptr;
return toElement(this)->youngestShadowRoot();
}
@@ -118,14 +70,14 @@ inline ShadowRoot* Element::youngestShadowRoot() const
{
if (ElementShadow* shadow = this->shadow())
return &shadow->youngestShadowRoot();
- return 0;
+ return nullptr;
}
inline ElementShadow* ElementShadow::containingShadow() const
{
if (ShadowRoot* parentRoot = host().containingShadowRoot())
return parentRoot->owner();
- return 0;
+ return nullptr;
}
inline void ElementShadow::distributeIfNeeded()

Powered by Google App Engine
This is Rietveld 408576698