Diff
Modified: trunk/Source/WebCore/ChangeLog (183008 => 183009)
--- trunk/Source/WebCore/ChangeLog 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/ChangeLog 2015-04-20 09:18:26 UTC (rev 183009)
@@ -1,3 +1,27 @@
+2015-04-20 Andreas Kling <akl...@apple.com>
+
+ Merge TreeShared into Node.
+ <https://webkit.org/b/143942>
+
+ Reviewed by Darin Adler.
+
+ Node was the only remaining user of TreeShared, so just fold the class into Node.
+
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Node.cpp:
+ (WebCore::Node::Node):
+ (WebCore::Node::~Node):
+ * dom/Node.h:
+ (WebCore::Node::ref):
+ (WebCore::Node::deref):
+ (WebCore::Node::hasOneRef):
+ (WebCore::Node::refCount):
+ (WebCore::adopted):
+ (WebCore::Node::hasTreeSharedParent): Deleted.
+ * platform/TreeShared.h: Removed.
+
2015-04-19 Benjamin Poulain <benja...@webkit.org>
Improve the feature.json files
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (183008 => 183009)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-04-20 09:18:26 UTC (rev 183009)
@@ -19897,7 +19897,6 @@
<ClInclude Include="..\platform\ThreadGlobalData.h" />
<ClInclude Include="..\platform\ThreadTimers.h" />
<ClInclude Include="..\platform\Timer.h" />
- <ClInclude Include="..\platform\TreeShared.h" />
<ClInclude Include="..\platform\UserActivity.h" />
<ClInclude Include="..\platform\HysteresisActivity.h" />
<ClInclude Include="..\platform\UUID.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (183008 => 183009)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-04-20 09:18:26 UTC (rev 183009)
@@ -8310,9 +8310,6 @@
<ClInclude Include="..\platform\Timer.h">
<Filter>platform</Filter>
</ClInclude>
- <ClInclude Include="..\platform\TreeShared.h">
- <Filter>platform</Filter>
- </ClInclude>
<ClInclude Include="..\platform\UserActivity.h">
<Filter>platform</Filter>
</ClInclude>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (183008 => 183009)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-04-20 09:18:26 UTC (rev 183009)
@@ -584,7 +584,6 @@
14115B7209F84CD600CA4FC1 /* JSNodeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14115B7009F84CD600CA4FC1 /* JSNodeFilter.cpp */; };
14115B7309F84CD600CA4FC1 /* JSNodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 14115B7109F84CD600CA4FC1 /* JSNodeFilter.h */; };
1411DCB1164C39A800D49BC1 /* WidthCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1411DCB0164C39A800D49BC1 /* WidthCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1419D2C40CEA6F6100FF507A /* TreeShared.h */; settings = {ATTRIBUTES = (Private, ); }; };
141DC0481648348F00371E5A /* LayoutUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 141DC0471648348F00371E5A /* LayoutUnit.h */; settings = {ATTRIBUTES = (Private, ); }; };
141DC04F164834B900371E5A /* LayoutBoxExtent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 141DC049164834B900371E5A /* LayoutBoxExtent.cpp */; };
141DC050164834B900371E5A /* LayoutBoxExtent.h in Headers */ = {isa = PBXBuildFile; fileRef = 141DC04A164834B900371E5A /* LayoutBoxExtent.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7633,7 +7632,6 @@
14115B7009F84CD600CA4FC1 /* JSNodeFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilter.cpp; sourceTree = "<group>"; };
14115B7109F84CD600CA4FC1 /* JSNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSNodeFilter.h; sourceTree = "<group>"; };
1411DCB0164C39A800D49BC1 /* WidthCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidthCache.h; sourceTree = "<group>"; };
- 1419D2C40CEA6F6100FF507A /* TreeShared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeShared.h; sourceTree = "<group>"; };
141B94E509EC4223000E9413 /* MouseEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = MouseEvent.idl; sourceTree = "<group>"; };
141B94EE09EC425A000E9413 /* UIEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = UIEvent.idl; sourceTree = "<group>"; };
141DC0471648348F00371E5A /* LayoutUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutUnit.h; sourceTree = "<group>"; };
@@ -21767,7 +21765,6 @@
185BCF270F3279CE000EA262 /* ThreadTimers.h */,
93309EA1099EB78C0056E581 /* Timer.cpp */,
9305B24C098F1B6B00C28855 /* Timer.h */,
- 1419D2C40CEA6F6100FF507A /* TreeShared.h */,
6593923509AE4346002C531F /* URL.cpp */,
6593923609AE4346002C531F /* URL.h */,
BCBD21AA0E417AD400A070F2 /* URLHash.h */,
@@ -26858,7 +26855,6 @@
6F995A241A7078B100A735F4 /* WebGLTransformFeedback.h in Headers */,
14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */,
A77E1FF014AACB6E005B7CB6 /* TreeScopeAdopter.h in Headers */,
- 1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */,
854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */,
C375D7FE16639519006184AB /* TypeAhead.h in Headers */,
E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */,
Modified: trunk/Source/WebCore/dom/Node.cpp (183008 => 183009)
--- trunk/Source/WebCore/dom/Node.cpp 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/dom/Node.cpp 2015-04-20 09:18:26 UTC (rev 183009)
@@ -287,12 +287,15 @@
}
Node::Node(Document& document, ConstructionType type)
- : m_nodeFlags(type)
+ : m_refCount(1)
+ , m_nodeFlags(type)
, m_parentNode(nullptr)
, m_treeScope(&document)
, m_previous(nullptr)
, m_next(nullptr)
{
+ ASSERT(isMainThread());
+
document.incrementReferencingNodeCount();
#if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
@@ -302,6 +305,11 @@
Node::~Node()
{
+ ASSERT(isMainThread());
+ ASSERT(!m_refCount);
+ ASSERT(m_deletionHasBegun);
+ ASSERT(!m_adoptionIsRequired);
+
#ifndef NDEBUG
if (!ignoreSet().remove(this))
nodeCounter.decrement();
Modified: trunk/Source/WebCore/dom/Node.h (183008 => 183009)
--- trunk/Source/WebCore/dom/Node.h 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/dom/Node.h 2015-04-20 09:18:26 UTC (rev 183009)
@@ -32,20 +32,11 @@
#include "RenderStyleConstants.h"
#include "ScriptWrappable.h"
#include "TreeScope.h"
-#include "TreeShared.h"
#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
+#include <wtf/MainThread.h>
#include <wtf/TypeCasts.h>
-namespace JSC {
-class VM;
-class SlotVisitor;
-}
-
-namespace WTF {
-class AtomicString;
-}
-
// This needs to be here because Document.h also depends on it.
#define DUMP_NODE_STATISTICS 0
@@ -120,7 +111,7 @@
RenderObject* m_renderer;
};
-class Node : public EventTarget, public ScriptWrappable, public TreeShared<Node> {
+class Node : public EventTarget, public ScriptWrappable {
friend class Document;
friend class TreeScope;
friend class TreeScopeAdopter;
@@ -544,9 +535,17 @@
// Perform the default action for an event.
virtual void defaultEventHandler(Event*);
- using TreeShared<Node>::ref;
- using TreeShared<Node>::deref;
+ void ref();
+ void deref();
+ bool hasOneRef() const;
+ int refCount() const;
+#ifndef NDEBUG
+ bool m_deletionHasBegun { false };
+ bool m_inRemovedLastRefFunction { false };
+ bool m_adoptionIsRequired { true };
+#endif
+
virtual EventTargetData* eventTargetData() override final;
virtual EventTargetData& ensureEventTargetData() override final;
@@ -668,8 +667,6 @@
void updateAncestorsForStyleRecalc();
private:
- friend class TreeShared<Node>;
-
virtual PseudoId customPseudoId() const
{
ASSERT(hasCustomStyleResolveCallbacks());
@@ -677,7 +674,6 @@
}
WEBCORE_EXPORT void removedLastRef();
- bool hasTreeSharedParent() const { return !!parentNode(); }
virtual void refEventTarget() override;
virtual void derefEventTarget() override;
@@ -690,7 +686,9 @@
Vector<std::unique_ptr<MutationObserverRegistration>>* mutationObserverRegistry();
HashSet<MutationObserverRegistration*>* transientMutationObserverRegistry();
+ int m_refCount;
mutable uint32_t m_nodeFlags;
+
ContainerNode* m_parentNode;
TreeScope* m_treeScope;
Node* m_previous;
@@ -708,6 +706,53 @@
void clearIsParsingChildrenFinished() { clearFlag(IsParsingChildrenFinishedFlag); }
};
+#ifndef NDEBUG
+inline void adopted(Node* node)
+{
+ if (!node)
+ return;
+ ASSERT(!node->m_deletionHasBegun);
+ ASSERT(!node->m_inRemovedLastRefFunction);
+ node->m_adoptionIsRequired = false;
+}
+#endif
+
+inline void Node::ref()
+{
+ ASSERT(isMainThread());
+ ASSERT(!m_deletionHasBegun);
+ ASSERT(!m_inRemovedLastRefFunction);
+ ASSERT(!m_adoptionIsRequired);
+ ++m_refCount;
+}
+
+inline void Node::deref()
+{
+ ASSERT(isMainThread());
+ ASSERT(m_refCount >= 0);
+ ASSERT(!m_deletionHasBegun);
+ ASSERT(!m_inRemovedLastRefFunction);
+ ASSERT(!m_adoptionIsRequired);
+ if (--m_refCount <= 0 && !parentNode()) {
+#ifndef NDEBUG
+ m_inRemovedLastRefFunction = true;
+#endif
+ removedLastRef();
+ }
+}
+
+inline bool Node::hasOneRef() const
+{
+ ASSERT(!m_deletionHasBegun);
+ ASSERT(!m_inRemovedLastRefFunction);
+ return m_refCount == 1;
+}
+
+inline int Node::refCount() const
+{
+ return m_refCount;
+}
+
// Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs()
inline void addSubresourceURL(ListHashSet<URL>& urls, const URL& url)
{
Deleted: trunk/Source/WebCore/platform/TreeShared.h (183008 => 183009)
--- trunk/Source/WebCore/platform/TreeShared.h 2015-04-20 08:31:04 UTC (rev 183008)
+++ trunk/Source/WebCore/platform/TreeShared.h 2015-04-20 09:18:26 UTC (rev 183009)
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2009, 2010, 2012 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TreeShared_h
-#define TreeShared_h
-
-#include <wtf/Assertions.h>
-#include <wtf/MainThread.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-#ifndef NDEBUG
-template<typename NodeType> class TreeShared;
-template<typename NodeType> void adopted(TreeShared<NodeType>*);
-#endif
-
-template<typename NodeType> class TreeShared {
- WTF_MAKE_NONCOPYABLE(TreeShared); WTF_MAKE_FAST_ALLOCATED;
-protected:
- TreeShared()
- : m_refCount(1)
-#ifndef NDEBUG
- , m_adoptionIsRequired(true)
-#endif
- {
- ASSERT(isMainThread());
-#ifndef NDEBUG
- m_deletionHasBegun = false;
- m_inRemovedLastRefFunction = false;
-#endif
- }
-
- ~TreeShared()
- {
- ASSERT(isMainThread());
- ASSERT(!m_refCount);
- ASSERT(m_deletionHasBegun);
- ASSERT(!m_adoptionIsRequired);
- }
-
-public:
- void ref()
- {
- ASSERT(isMainThread());
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_inRemovedLastRefFunction);
- ASSERT(!m_adoptionIsRequired);
- ++m_refCount;
- }
-
- void deref()
- {
- ASSERT(isMainThread());
- ASSERT(m_refCount >= 0);
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_inRemovedLastRefFunction);
- ASSERT(!m_adoptionIsRequired);
- NodeType* thisNode = static_cast<NodeType*>(this);
- if (--m_refCount <= 0 && !thisNode->hasTreeSharedParent()) {
-#ifndef NDEBUG
- m_inRemovedLastRefFunction = true;
-#endif
- thisNode->removedLastRef();
- }
- }
-
- bool hasOneRef() const
- {
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_inRemovedLastRefFunction);
- return m_refCount == 1;
- }
-
- int refCount() const
- {
- return m_refCount;
- }
-
-#ifndef NDEBUG
- bool m_deletionHasBegun;
- bool m_inRemovedLastRefFunction;
-#endif
-
-private:
-#ifndef NDEBUG
- friend void adopted<>(TreeShared<NodeType>*);
-#endif
-
- int m_refCount;
-
-#ifndef NDEBUG
- bool m_adoptionIsRequired;
-#endif
-};
-
-#ifndef NDEBUG
-
-template<typename NodeType> inline void adopted(TreeShared<NodeType>* object)
-{
- if (!object)
- return;
- ASSERT(!object->m_deletionHasBegun);
- ASSERT(!object->m_inRemovedLastRefFunction);
- object->m_adoptionIsRequired = false;
-}
-
-#endif
-
-}
-
-#endif // TreeShared.h