Changeset 183009 in webkit


Ignore:
Timestamp:
Apr 20, 2015, 2:18:26 AM (10 years ago)
Author:
akling@apple.com
Message:

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.
Location:
trunk/Source/WebCore
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r182998 r183009  
     12015-04-20  Andreas Kling  <akling@apple.com>
     2
     3        Merge TreeShared into Node.
     4        <https://webkit.org/b/143942>
     5
     6        Reviewed by Darin Adler.
     7
     8        Node was the only remaining user of TreeShared, so just fold the class into Node.
     9
     10        * WebCore.vcxproj/WebCore.vcxproj:
     11        * WebCore.vcxproj/WebCore.vcxproj.filters:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * dom/Node.cpp:
     14        (WebCore::Node::Node):
     15        (WebCore::Node::~Node):
     16        * dom/Node.h:
     17        (WebCore::Node::ref):
     18        (WebCore::Node::deref):
     19        (WebCore::Node::hasOneRef):
     20        (WebCore::Node::refCount):
     21        (WebCore::adopted):
     22        (WebCore::Node::hasTreeSharedParent): Deleted.
     23        * platform/TreeShared.h: Removed.
     24
    1252015-04-19  Benjamin Poulain  <benjamin@webkit.org>
    226
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r182768 r183009  
    1989819898    <ClInclude Include="..\platform\ThreadTimers.h" />
    1989919899    <ClInclude Include="..\platform\Timer.h" />
    19900     <ClInclude Include="..\platform\TreeShared.h" />
    1990119900    <ClInclude Include="..\platform\UserActivity.h" />
    1990219901    <ClInclude Include="..\platform\HysteresisActivity.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r182768 r183009  
    83118311      <Filter>platform</Filter>
    83128312    </ClInclude>
    8313     <ClInclude Include="..\platform\TreeShared.h">
    8314       <Filter>platform</Filter>
    8315     </ClInclude>
    83168313    <ClInclude Include="..\platform\UserActivity.h">
    83178314      <Filter>platform</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r182808 r183009  
    585585                14115B7309F84CD600CA4FC1 /* JSNodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 14115B7109F84CD600CA4FC1 /* JSNodeFilter.h */; };
    586586                1411DCB1164C39A800D49BC1 /* WidthCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1411DCB0164C39A800D49BC1 /* WidthCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
    587                 1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1419D2C40CEA6F6100FF507A /* TreeShared.h */; settings = {ATTRIBUTES = (Private, ); }; };
    588587                141DC0481648348F00371E5A /* LayoutUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 141DC0471648348F00371E5A /* LayoutUnit.h */; settings = {ATTRIBUTES = (Private, ); }; };
    589588                141DC04F164834B900371E5A /* LayoutBoxExtent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 141DC049164834B900371E5A /* LayoutBoxExtent.cpp */; };
     
    76347633                14115B7109F84CD600CA4FC1 /* JSNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSNodeFilter.h; sourceTree = "<group>"; };
    76357634                1411DCB0164C39A800D49BC1 /* WidthCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidthCache.h; sourceTree = "<group>"; };
    7636                 1419D2C40CEA6F6100FF507A /* TreeShared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeShared.h; sourceTree = "<group>"; };
    76377635                141B94E509EC4223000E9413 /* MouseEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = MouseEvent.idl; sourceTree = "<group>"; };
    76387636                141B94EE09EC425A000E9413 /* UIEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = UIEvent.idl; sourceTree = "<group>"; };
     
    2176821766                                93309EA1099EB78C0056E581 /* Timer.cpp */,
    2176921767                                9305B24C098F1B6B00C28855 /* Timer.h */,
    21770                                 1419D2C40CEA6F6100FF507A /* TreeShared.h */,
    2177121768                                6593923509AE4346002C531F /* URL.cpp */,
    2177221769                                6593923609AE4346002C531F /* URL.h */,
     
    2685926856                                14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */,
    2686026857                                A77E1FF014AACB6E005B7CB6 /* TreeScopeAdopter.h in Headers */,
    26861                                 1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */,
    2686226858                                854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */,
    2686326859                                C375D7FE16639519006184AB /* TypeAhead.h in Headers */,
  • trunk/Source/WebCore/dom/Node.cpp

    r182349 r183009  
    288288
    289289Node::Node(Document& document, ConstructionType type)
    290     : m_nodeFlags(type)
     290    : m_refCount(1)
     291    , m_nodeFlags(type)
    291292    , m_parentNode(nullptr)
    292293    , m_treeScope(&document)
     
    294295    , m_next(nullptr)
    295296{
     297    ASSERT(isMainThread());
     298
    296299    document.incrementReferencingNodeCount();
    297300
     
    303306Node::~Node()
    304307{
     308    ASSERT(isMainThread());
     309    ASSERT(!m_refCount);
     310    ASSERT(m_deletionHasBegun);
     311    ASSERT(!m_adoptionIsRequired);
     312
    305313#ifndef NDEBUG
    306314    if (!ignoreSet().remove(this))
  • trunk/Source/WebCore/dom/Node.h

    r181418 r183009  
    3333#include "ScriptWrappable.h"
    3434#include "TreeScope.h"
    35 #include "TreeShared.h"
    3635#include <wtf/Forward.h>
    3736#include <wtf/ListHashSet.h>
     37#include <wtf/MainThread.h>
    3838#include <wtf/TypeCasts.h>
    39 
    40 namespace JSC {
    41 class VM;
    42 class SlotVisitor;
    43 }
    44 
    45 namespace WTF {
    46 class AtomicString;
    47 }
    4839
    4940// This needs to be here because Document.h also depends on it.
     
    121112};
    122113
    123 class Node : public EventTarget, public ScriptWrappable, public TreeShared<Node> {
     114class Node : public EventTarget, public ScriptWrappable {
    124115    friend class Document;
    125116    friend class TreeScope;
     
    545536    virtual void defaultEventHandler(Event*);
    546537
    547     using TreeShared<Node>::ref;
    548     using TreeShared<Node>::deref;
     538    void ref();
     539    void deref();
     540    bool hasOneRef() const;
     541    int refCount() const;
     542
     543#ifndef NDEBUG
     544    bool m_deletionHasBegun { false };
     545    bool m_inRemovedLastRefFunction { false };
     546    bool m_adoptionIsRequired { true };
     547#endif
    549548
    550549    virtual EventTargetData* eventTargetData() override final;
     
    669668
    670669private:
    671     friend class TreeShared<Node>;
    672 
    673670    virtual PseudoId customPseudoId() const
    674671    {
     
    678675
    679676    WEBCORE_EXPORT void removedLastRef();
    680     bool hasTreeSharedParent() const { return !!parentNode(); }
    681677
    682678    virtual void refEventTarget() override;
     
    691687    HashSet<MutationObserverRegistration*>* transientMutationObserverRegistry();
    692688
     689    int m_refCount;
    693690    mutable uint32_t m_nodeFlags;
     691
    694692    ContainerNode* m_parentNode;
    695693    TreeScope* m_treeScope;
     
    709707};
    710708
     709#ifndef NDEBUG
     710inline void adopted(Node* node)
     711{
     712    if (!node)
     713        return;
     714    ASSERT(!node->m_deletionHasBegun);
     715    ASSERT(!node->m_inRemovedLastRefFunction);
     716    node->m_adoptionIsRequired = false;
     717}
     718#endif
     719
     720inline void Node::ref()
     721{
     722    ASSERT(isMainThread());
     723    ASSERT(!m_deletionHasBegun);
     724    ASSERT(!m_inRemovedLastRefFunction);
     725    ASSERT(!m_adoptionIsRequired);
     726    ++m_refCount;
     727}
     728
     729inline void Node::deref()
     730{
     731    ASSERT(isMainThread());
     732    ASSERT(m_refCount >= 0);
     733    ASSERT(!m_deletionHasBegun);
     734    ASSERT(!m_inRemovedLastRefFunction);
     735    ASSERT(!m_adoptionIsRequired);
     736    if (--m_refCount <= 0 && !parentNode()) {
     737#ifndef NDEBUG
     738        m_inRemovedLastRefFunction = true;
     739#endif
     740        removedLastRef();
     741    }
     742}
     743
     744inline bool Node::hasOneRef() const
     745{
     746    ASSERT(!m_deletionHasBegun);
     747    ASSERT(!m_inRemovedLastRefFunction);
     748    return m_refCount == 1;
     749}
     750
     751inline int Node::refCount() const
     752{
     753    return m_refCount;
     754}
     755
    711756// Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs()
    712757inline void addSubresourceURL(ListHashSet<URL>& urls, const URL& url)
Note: See TracChangeset for help on using the changeset viewer.