Changeset 147962 in webkit


Ignore:
Timestamp:
Apr 8, 2013 4:41:02 PM (11 years ago)
Author:
ggaren@apple.com
Message:

Stop #include-ing all of JavaScriptCore in every DOM-related file
https://bugs.webkit.org/show_bug.cgi?id=114220

Reviewed by Sam Weinig.

../JavaScriptCore:

I separated WeakInlines.h from Weak.h so WebCore data types that need
to declare a Weak<T> data member don't have to #include all of the
infrastructure for accessing that data member.

This also required separating Weak<T> from PassWeak<T> by removing the
WeakImplAccessor class template and pushing code down into its subclasses.

  • API/JSWeakObjectMapRefPrivate.cpp:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/UnlinkedCodeBlock.h:
  • heap/PassWeak.h:

(JSC):
(PassWeak):
(JSC::::PassWeak):
(JSC::::operator):
(JSC::::get):

  • heap/SlotVisitorInlines.h:
  • heap/Weak.h:

(JSC):
(Weak):

  • heap/WeakInlines.h: Copied from Source/JavaScriptCore/heap/Weak.h.

(JSC):
(JSC::::Weak):
(JSC::::operator):
(JSC::::get):
(JSC::::was):
(JSC::weakClear):

  • jit/JITThunks.h:
  • runtime/RegExpCache.h:
  • runtime/Structure.h:
  • runtime/WeakGCMap.h:

../WebCore:

I separated ScriptWrappableInlines.h from ScriptWrappable.h so
WebCore data types that inherit from ScriptWrappable don't
have to #include all of the infrastructure for accessing that data member.

  • ForwardingHeaders/heap/PassWeak.h: Added.
  • ForwardingHeaders/heap/WeakInlines.h: Added.
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/DOMWrapperWorld.h:
  • bindings/js/JSDOMBinding.h:

(JSC):

  • bindings/js/JSEventListener.h:
  • bindings/js/JSMutationCallback.cpp:
  • bindings/js/JSNodeFilterCondition.h:
  • bindings/js/ScriptWrappable.h:

(JSC):
(WebCore):
(ScriptWrappable):

  • bindings/js/ScriptWrappableInlines.h: Added.

(WebCore):
(WebCore::ScriptWrappable::wrapper):
(WebCore::ScriptWrappable::setWrapper):
(WebCore::ScriptWrappable::clearWrapper):

  • bridge/qt/qt_instance.h:
  • bridge/qt/qt_runtime.h:
  • bridge/runtime_root.cpp:
  • bridge/runtime_root.h:
  • css/StylePropertySet.cpp:
  • dom/LiveNodeList.cpp:

(WebCore::LiveNodeListBase::reportMemoryUsage):

  • dom/Node.cpp:

(WebCore::Node::reportMemoryUsage):

  • inspector/InspectorDebuggerAgent.cpp:
  • inspector/NetworkResourcesData.cpp:
  • loader/cache/CachedSVGDocument.cpp:
  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::reportMemoryUsage):

../WebKit2:

  • Shared/WebCoreArgumentCoders.cpp:
  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
Location:
trunk/Source
Files:
3 added
43 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp

    r140718 r147962  
    3333#include "JSWeakObjectMapRefInternal.h"
    3434#include "Operations.h"
     35#include "Weak.h"
    3536#include <wtf/HashMap.h>
    3637#include <wtf/text/StringHash.h>
  • trunk/Source/JavaScriptCore/ChangeLog

    r147950 r147962  
     12013-04-08  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Stop #include-ing all of JavaScriptCore in every DOM-related file
     4        https://bugs.webkit.org/show_bug.cgi?id=114220
     5
     6        Reviewed by Sam Weinig.
     7
     8        I separated WeakInlines.h from Weak.h so WebCore data types that need
     9        to declare a Weak<T> data member don't have to #include all of the
     10        infrastructure for accessing that data member.
     11
     12        This also required separating Weak<T> from PassWeak<T> by removing the
     13        WeakImplAccessor class template and pushing code down into its subclasses.
     14
     15        * API/JSWeakObjectMapRefPrivate.cpp:
     16        * JavaScriptCore.xcodeproj/project.pbxproj:
     17        * bytecode/UnlinkedCodeBlock.h:
     18        * heap/PassWeak.h:
     19        (JSC):
     20        (PassWeak):
     21        (JSC::::PassWeak):
     22        (JSC::::operator):
     23        (JSC::::get):
     24        * heap/SlotVisitorInlines.h:
     25        * heap/Weak.h:
     26        (JSC):
     27        (Weak):
     28        * heap/WeakInlines.h: Copied from Source/JavaScriptCore/heap/Weak.h.
     29        (JSC):
     30        (JSC::::Weak):
     31        (JSC::::operator):
     32        (JSC::::get):
     33        (JSC::::was):
     34        (JSC::weakClear):
     35        * jit/JITThunks.h:
     36        * runtime/RegExpCache.h:
     37        * runtime/Structure.h:
     38        * runtime/WeakGCMap.h:
     39
    1402013-04-05  Roger Fong  <roger_fong@apple.com>
    241
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r147324 r147962  
    492492                14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */; };
    493493                14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */; };
     494                14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BE7D3217135CF400D1807A /* WeakInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    494495                14BFCE6910CDB1FC00364CCE /* WeakGCMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    495496                14C5242B0F5355E900BA3D04 /* JITStubs.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A6581A0F4E36F4000150FD /* JITStubs.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    13541355                14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSValueRef.cpp; sourceTree = "<group>"; };
    13551356                14BD5A2D0A3E91F600BAF59C /* testapi.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testapi.c; path = API/tests/testapi.c; sourceTree = "<group>"; };
     1357                14BE7D3217135CF400D1807A /* WeakInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakInlines.h; sourceTree = "<group>"; };
    13561358                14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMap.h; sourceTree = "<group>"; };
    13571359                14CA958A16AB50DE00938A06 /* StaticPropertyAnalyzer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticPropertyAnalyzer.h; sourceTree = "<group>"; };
     
    21142116                                C21122DF15DD9AB300790E3A /* GCThreadSharedData.h */,
    21152117                                142E312B134FF0A600AFADB5 /* Handle.h */,
     2118                                C28318FF16FE4B7D00157BFD /* HandleBlock.h */,
     2119                                C283190116FE533E00157BFD /* HandleBlockInlines.h */,
    21162120                                142E312C134FF0A600AFADB5 /* HandleSet.cpp */,
    21172121                                142E312D134FF0A600AFADB5 /* HandleSet.h */,
     
    21472151                                C21122E015DD9AB300790E3A /* MarkStackInlines.h */,
    21482152                                1497209014EB831500FEB1B7 /* PassWeak.h */,
     2153                                C20B25981706536200C21F4E /* Region.h */,
    21492154                                C225494215F7DBAA0065E898 /* SlotVisitor.cpp */,
    21502155                                14BA78F013AAB88F005B7C2C /* SlotVisitor.h */,
     
    21522157                                142E3132134FF0A600AFADB5 /* Strong.h */,
    21532158                                145722851437E140005FDE26 /* StrongInlines.h */,
     2159                                C2DF442D1707AC0100A5CA96 /* SuperRegion.cpp */,
     2160                                C2DF442E1707AC0100A5CA96 /* SuperRegion.h */,
    21542161                                141448CC13A1783700F5BA1A /* TinyBloomFilter.h */,
    21552162                                0F5F08CE146C762F000472A9 /* UnconditionalFinalizer.h */,
     
    21622169                                14F7256414EE265E00B1652B /* WeakHandleOwner.h */,
    21632170                                14E84F9D14EE1ACC00D6D5D4 /* WeakImpl.h */,
     2171                                14BE7D3217135CF400D1807A /* WeakInlines.h */,
    21642172                                0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */,
    21652173                                14E84F9B14EE1ACC00D6D5D4 /* WeakSet.cpp */,
     
    21682176                                0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */,
    21692177                                0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */,
    2170                                 C28318FF16FE4B7D00157BFD /* HandleBlock.h */,
    2171                                 C283190116FE533E00157BFD /* HandleBlockInlines.h */,
    2172                                 C20B25981706536200C21F4E /* Region.h */,
    2173                                 C2DF442D1707AC0100A5CA96 /* SuperRegion.cpp */,
    2174                                 C2DF442E1707AC0100A5CA96 /* SuperRegion.h */,
    21752178                        );
    21762179                        path = heap;
     
    33093312                                0FF729BD166AD360000F5BA3 /* ProfilerDatabase.h in Headers */,
    33103313                                0FF729BE166AD360000F5BA3 /* ProfilerExecutionCounter.h in Headers */,
     3314                                14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */,
    33113315                                0FF729BF166AD360000F5BA3 /* ProfilerOrigin.h in Headers */,
    33123316                                0FF729C0166AD360000F5BA3 /* ProfilerOriginStack.h in Headers */,
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r147892 r147962  
    3939#include "SpecialPointer.h"
    4040#include "SymbolTable.h"
    41 #include "Weak.h"
    4241
    4342#include <wtf/RefCountedArray.h>
  • trunk/Source/JavaScriptCore/heap/PassWeak.h

    r118483 r147962  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535namespace JSC {
    3636
    37 template<typename T> class Weak;
    3837template<typename T> class PassWeak;
    3938template<typename T> PassWeak<T> adoptWeak(WeakImpl*);
    4039
    41 template<typename Base, typename T> class WeakImplAccessor {
     40template<typename T> class PassWeak {
    4241public:
    43     typedef T* GetType;
    44 
    45     T* operator->() const;
    46     T& operator*() const;
    47     GetType get() const;
    48 
    49     bool was(GetType) const;
    50 };
    51 
    52 template<typename T> class PassWeak : public WeakImplAccessor<PassWeak<T>, T> {
    53 public:
    54     friend class WeakImplAccessor<PassWeak<T>, T>;
    55     typedef typename WeakImplAccessor<PassWeak<T>, T>::GetType GetType;
    56 
    5742    PassWeak();
    5843    PassWeak(std::nullptr_t);
    59     PassWeak(GetType, WeakHandleOwner* = 0, void* context = 0);
     44    PassWeak(T*, WeakHandleOwner* = 0, void* context = 0);
    6045
    6146    // It somewhat breaks the type system to allow transfer of ownership out of
     
    6752    ~PassWeak();
    6853
     54    T* operator->() const;
     55    T& operator*() const;
     56    T* get() const;
     57
    6958    bool operator!() const;
    7059
    7160    // This conversion operator allows implicit conversion to bool but not to other integer types.
    72     typedef JSValue (PassWeak::*UnspecifiedBoolType);
     61    typedef void* (PassWeak::*UnspecifiedBoolType);
    7362    operator UnspecifiedBoolType*() const;
    7463
     
    8271};
    8372
    84 template<typename Base, typename T> inline T* WeakImplAccessor<Base, T>::operator->() const
    85 {
    86     ASSERT(static_cast<const Base*>(this)->m_impl && static_cast<const Base*>(this)->m_impl->state() == WeakImpl::Live);
    87     return jsCast<T*>(static_cast<const Base*>(this)->m_impl->jsValue().asCell());
    88 }
    89 
    90 template<typename Base, typename T> inline T& WeakImplAccessor<Base, T>::operator*() const
    91 {
    92     ASSERT(static_cast<const Base*>(this)->m_impl && static_cast<const Base*>(this)->m_impl->state() == WeakImpl::Live);
    93     return *jsCast<T*>(static_cast<const Base*>(this)->m_impl->jsValue().asCell());
    94 }
    95 
    96 template<typename Base, typename T> inline typename WeakImplAccessor<Base, T>::GetType WeakImplAccessor<Base, T>::get() const
    97 {
    98     if (!static_cast<const Base*>(this)->m_impl || static_cast<const Base*>(this)->m_impl->state() != WeakImpl::Live)
    99         return GetType();
    100     return jsCast<T*>(static_cast<const Base*>(this)->m_impl->jsValue().asCell());
    101 }
    102 
    103 template<typename Base, typename T> inline bool WeakImplAccessor<Base, T>::was(typename WeakImplAccessor<Base, T>::GetType other) const
    104 {
    105     return jsCast<T*>(static_cast<const Base*>(this)->m_impl->jsValue().asCell()) == other;
    106 }
    107 
    10873template<typename T> inline PassWeak<T>::PassWeak()
    10974    : m_impl(0)
     
    11681}
    11782
    118 template<typename T> inline PassWeak<T>::PassWeak(typename PassWeak<T>::GetType getType, WeakHandleOwner* weakOwner, void* context)
    119     : m_impl(getType ? WeakSet::allocate(getType, weakOwner, context) : 0)
     83template<typename T> inline PassWeak<T>::PassWeak(T* cell, WeakHandleOwner* weakOwner, void* context)
     84    : m_impl(cell ? WeakSet::allocate(cell, weakOwner, context) : 0)
    12085{
    12186}
     
    138103}
    139104
     105template<typename T> inline T* PassWeak<T>::operator->() const
     106{
     107    ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
     108    return jsCast<T*>(m_impl->jsValue().asCell());
     109}
     110
     111template<typename T> inline T& PassWeak<T>::operator*() const
     112{
     113    ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
     114    return *jsCast<T*>(m_impl->jsValue().asCell());
     115}
     116
     117template<typename T> inline T* PassWeak<T>::get() const
     118{
     119    if (!m_impl || m_impl->state() != WeakImpl::Live)
     120        return 0;
     121    return jsCast<T*>(m_impl->jsValue().asCell());
     122}
     123
    140124template<typename T> inline bool PassWeak<T>::operator!() const
    141125{
  • trunk/Source/JavaScriptCore/heap/SlotVisitorInlines.h

    r146558 r147962  
    3232#include "SlotVisitor.h"
    3333#include "Weak.h"
     34#include "WeakInlines.h"
    3435
    3536namespace JSC {
  • trunk/Source/JavaScriptCore/heap/Weak.h

    r140194 r147962  
    11/*
    2  * Copyright (C) 2009, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#define Weak_h
    2828
    29 #include "PassWeak.h"
    30 #include "WeakSetInlines.h"
    31 #include <wtf/Assertions.h>
    32 #include <wtf/HashMap.h>
     29#include <wtf/Noncopyable.h>
     30#include <wtf/NullPtr.h>
    3331
    3432namespace JSC {
    3533
    36 template<typename T> class Weak : public WeakImplAccessor<Weak<T>, T> {
     34template<typename T> class PassWeak;
     35class WeakImpl;
     36class WeakHandleOwner;
     37
     38template<typename T> class Weak {
    3739    WTF_MAKE_NONCOPYABLE(Weak);
    3840public:
    39     friend class WeakImplAccessor<Weak<T>, T>;
    40     typedef typename WeakImplAccessor<Weak<T>, T>::GetType GetType;
    41 
    4241    Weak();
    4342    explicit Weak(std::nullptr_t);
    44     explicit Weak(GetType, WeakHandleOwner* = 0, void* context = 0);
     43    explicit Weak(T*, WeakHandleOwner* = 0, void* context = 0);
    4544
    4645    enum HashTableDeletedValueTag { HashTableDeletedValue };
     
    5655   
    5756    bool operator!() const;
     57    T* operator->() const;
     58    T& operator*() const;
     59    T* get() const;
     60
     61    bool was(T*) const;
    5862
    5963    // This conversion operator allows implicit conversion to bool but not to other integer types.
    60     typedef JSValue (HandleBase::*UnspecifiedBoolType);
     64    typedef void* (Weak::*UnspecifiedBoolType);
    6165    operator UnspecifiedBoolType*() const;
    6266
     
    7074};
    7175
    72 template<typename T> inline Weak<T>::Weak()
    73     : m_impl(0)
    74 {
    75 }
    76 
    77 template<typename T> inline Weak<T>::Weak(std::nullptr_t)
    78     : m_impl(0)
    79 {
    80 }
    81 
    82 template<typename T> inline Weak<T>::Weak(typename Weak<T>::GetType getType, WeakHandleOwner* weakOwner, void* context)
    83     : m_impl(getType ? WeakSet::allocate(getType, weakOwner, context) : 0)
    84 {
    85 }
    86 
    87 template<typename T> inline bool Weak<T>::isHashTableDeletedValue() const
    88 {
    89     return m_impl == hashTableDeletedValue();
    90 }
    91 
    92 template<typename T> inline Weak<T>::Weak(typename Weak<T>::HashTableDeletedValueTag)
    93     : m_impl(hashTableDeletedValue())
    94 {
    95 }
    96 
    97 template<typename T> template<typename U>  inline Weak<T>::Weak(const PassWeak<U>& other)
    98     : m_impl(other.leakImpl())
    99 {
    100 }
    101 
    102 template<typename T> inline Weak<T>::~Weak()
    103 {
    104     clear();
    105 }
    106 
    107 template<class T> inline void swap(Weak<T>& a, Weak<T>& b)
    108 {
    109     a.swap(b);
    110 }
    111 
    112 template<typename T> inline void Weak<T>::swap(Weak& other)
    113 {
    114     std::swap(m_impl, other.m_impl);
    115 }
    116 
    117 template<typename T> inline Weak<T>& Weak<T>::operator=(const PassWeak<T>& o)
    118 {
    119     clear();
    120     m_impl = o.leakImpl();
    121     return *this;
    122 }
    123 
    124 template<typename T> inline bool Weak<T>::operator!() const
    125 {
    126     return !m_impl || !m_impl->jsValue() || m_impl->state() != WeakImpl::Live;
    127 }
    128 
    129 template<typename T> inline Weak<T>::operator UnspecifiedBoolType*() const
    130 {
    131     return reinterpret_cast<UnspecifiedBoolType*>(!!*this);
    132 }
    133 
    134 template<typename T> inline PassWeak<T> Weak<T>::release()
    135 {
    136     PassWeak<T> tmp = adoptWeak<T>(m_impl);
    137     m_impl = 0;
    138     return tmp;
    139 }
    140 
    141 template<typename T> inline void Weak<T>::clear()
    142 {
    143     if (!m_impl)
    144         return;
    145     WeakSet::deallocate(m_impl);
    146     m_impl = 0;
    147 }
    148    
    149 template<typename T> inline WeakImpl* Weak<T>::hashTableDeletedValue()
    150 {
    151     return reinterpret_cast<WeakImpl*>(-1);
    152 }
    153 
    154 template <typename T> inline bool operator==(const Weak<T>& lhs, const Weak<T>& rhs)
    155 {
    156     return lhs.get() == rhs.get();
    157 }
    158 
    159 // This function helps avoid modifying a weak table while holding an iterator into it. (Object allocation
    160 // can run a finalizer that modifies the table. We avoid that by requiring a pre-constructed object as our value.)
    161 template<typename Map, typename Key, typename Value> inline void weakAdd(Map& map, const Key& key, Value value)
    162 {
    163     ASSERT(!map.get(key));
    164     map.set(key, value); // The table may still have a zombie for value.
    165 }
    166 
    167 template<typename Map, typename Key, typename Value> inline void weakRemove(Map& map, const Key& key, Value value)
    168 {
    169     typename Map::iterator it = map.find(key);
    170     ASSERT_UNUSED(value, value);
    171     ASSERT(it != map.end());
    172     ASSERT(it->value.was(value));
    173     ASSERT(!it->value);
    174     map.remove(it);
    175 }
    176 
    177 template<typename T> inline void weakClear(Weak<T>& weak, typename Weak<T>::GetType value)
    178 {
    179     ASSERT_UNUSED(value, value);
    180     ASSERT(weak.was(value));
    181     ASSERT(!weak);
    182     weak.clear();
    183 }
    184 
    18576} // namespace JSC
    18677
    187 namespace WTF {
    188 
    189 template<typename T> struct VectorTraits<JSC::Weak<T> > : SimpleClassVectorTraits {
    190     static const bool canCompareWithMemcmp = false;
    191 };
    192 
    193 template<typename T> struct HashTraits<JSC::Weak<T> > : SimpleClassHashTraits<JSC::Weak<T> > {
    194     typedef JSC::Weak<T> StorageType;
    195 
    196     typedef std::nullptr_t EmptyValueType;
    197     static EmptyValueType emptyValue() { return nullptr; }
    198 
    199     typedef JSC::PassWeak<T> PassInType;
    200     static void store(PassInType value, StorageType& storage) { storage = value; }
    201 
    202     typedef JSC::PassWeak<T> PassOutType;
    203     static PassOutType passOut(StorageType& value) { return value.release(); }
    204     static PassOutType passOut(EmptyValueType) { return PassOutType(); }
    205 
    206     typedef typename StorageType::GetType PeekType;
    207     static PeekType peek(const StorageType& value) { return value.get(); }
    208     static PeekType peek(EmptyValueType) { return PeekType(); }
    209 };
    210 
    211 }
    212 
    21378#endif // Weak_h
  • trunk/Source/JavaScriptCore/heap/WeakInlines.h

    r147938 r147962  
    11/*
    2  * Copyright (C) 2009, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef Weak_h
    27 #define Weak_h
     26#ifndef WeakInlines_h
     27#define WeakInlines_h
    2828
    2929#include "PassWeak.h"
    3030#include "WeakSetInlines.h"
    3131#include <wtf/Assertions.h>
    32 #include <wtf/HashMap.h>
     32#include <wtf/HashTraits.h>
    3333
    3434namespace JSC {
    35 
    36 template<typename T> class Weak : public WeakImplAccessor<Weak<T>, T> {
    37     WTF_MAKE_NONCOPYABLE(Weak);
    38 public:
    39     friend class WeakImplAccessor<Weak<T>, T>;
    40     typedef typename WeakImplAccessor<Weak<T>, T>::GetType GetType;
    41 
    42     Weak();
    43     explicit Weak(std::nullptr_t);
    44     explicit Weak(GetType, WeakHandleOwner* = 0, void* context = 0);
    45 
    46     enum HashTableDeletedValueTag { HashTableDeletedValue };
    47     bool isHashTableDeletedValue() const;
    48     Weak(HashTableDeletedValueTag);
    49 
    50     template<typename U> Weak(const PassWeak<U>&);
    51 
    52     ~Weak();
    53 
    54     void swap(Weak&);
    55     Weak& operator=(const PassWeak<T>&);
    56    
    57     bool operator!() const;
    58 
    59     // This conversion operator allows implicit conversion to bool but not to other integer types.
    60     typedef JSValue (HandleBase::*UnspecifiedBoolType);
    61     operator UnspecifiedBoolType*() const;
    62 
    63     PassWeak<T> release();
    64     void clear();
    65    
    66 private:
    67     static WeakImpl* hashTableDeletedValue();
    68 
    69     WeakImpl* m_impl;
    70 };
    7135
    7236template<typename T> inline Weak<T>::Weak()
     
    8044}
    8145
    82 template<typename T> inline Weak<T>::Weak(typename Weak<T>::GetType getType, WeakHandleOwner* weakOwner, void* context)
    83     : m_impl(getType ? WeakSet::allocate(getType, weakOwner, context) : 0)
     46template<typename T> inline Weak<T>::Weak(T* cell, WeakHandleOwner* weakOwner, void* context)
     47    : m_impl(cell ? WeakSet::allocate(cell, weakOwner, context) : 0)
    8448{
    8549}
     
    12084    m_impl = o.leakImpl();
    12185    return *this;
     86}
     87
     88template<typename T> inline T* Weak<T>::operator->() const
     89{
     90    ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
     91    return jsCast<T*>(m_impl->jsValue().asCell());
     92}
     93
     94template<typename T> inline T& Weak<T>::operator*() const
     95{
     96    ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
     97    return *jsCast<T*>(m_impl->jsValue().asCell());
     98}
     99
     100template<typename T> inline T* Weak<T>::get() const
     101{
     102    if (!m_impl || m_impl->state() != WeakImpl::Live)
     103        return 0;
     104    return jsCast<T*>(m_impl->jsValue().asCell());
     105}
     106
     107template<typename T> inline bool Weak<T>::was(T* other) const
     108{
     109    return jsCast<T*>(m_impl->jsValue().asCell()) == other;
    122110}
    123111
     
    175163}
    176164
    177 template<typename T> inline void weakClear(Weak<T>& weak, typename Weak<T>::GetType value)
    178 {
    179     ASSERT_UNUSED(value, value);
    180     ASSERT(weak.was(value));
     165template<typename T> inline void weakClear(Weak<T>& weak, T* cell)
     166{
     167    ASSERT_UNUSED(cell, cell);
     168    ASSERT(weak.was(cell));
    181169    ASSERT(!weak);
    182170    weak.clear();
     
    204192    static PassOutType passOut(EmptyValueType) { return PassOutType(); }
    205193
    206     typedef typename StorageType::GetType PeekType;
     194    typedef T* PeekType;
    207195    static PeekType peek(const StorageType& value) { return value.get(); }
    208196    static PeekType peek(EmptyValueType) { return PeekType(); }
    209197};
    210198
    211 }
    212 
    213 #endif // Weak_h
     199} // namespace WTF
     200
     201#endif // WeakInlines_h
  • trunk/Source/JavaScriptCore/jit/JITThunks.h

    r139541 r147962  
    3737#include "ThunkGenerator.h"
    3838#include "Weak.h"
     39#include "WeakInlines.h"
    3940#include <wtf/HashMap.h>
    4041#include <wtf/OwnPtr.h>
  • trunk/Source/JavaScriptCore/runtime/RegExpCache.h

    r127191 r147962  
    3030#include "Strong.h"
    3131#include "Weak.h"
     32#include "WeakInlines.h"
    3233#include <wtf/FixedArray.h>
    3334#include <wtf/HashMap.h>
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r145945 r147962  
    4040#include "JSTypeInfo.h"
    4141#include "Watchpoint.h"
    42 #include "Weak.h"
    4342#include <wtf/PassRefPtr.h>
    4443#include <wtf/RefCounted.h>
  • trunk/Source/JavaScriptCore/runtime/WeakGCMap.h

    r140284 r147962  
    2727#define WeakGCMap_h
    2828
    29 #include "Weak.h"
     29#include <heap/Weak.h>
     30#include <heap/WeakInlines.h>
    3031#include <wtf/HashMap.h>
    3132
  • trunk/Source/WebCore/ChangeLog

    r147958 r147962  
     12013-04-08  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Stop #include-ing all of JavaScriptCore in every DOM-related file
     4        https://bugs.webkit.org/show_bug.cgi?id=114220
     5
     6        Reviewed by Sam Weinig.
     7
     8        I separated ScriptWrappableInlines.h from ScriptWrappable.h so
     9        WebCore data types that inherit from ScriptWrappable don't
     10        have to #include all of the infrastructure for accessing that data member.
     11
     12        * ForwardingHeaders/heap/PassWeak.h: Added.
     13        * ForwardingHeaders/heap/WeakInlines.h: Added.
     14        * WebCore.xcodeproj/project.pbxproj:
     15        * bindings/js/DOMWrapperWorld.h:
     16        * bindings/js/JSDOMBinding.h:
     17        (JSC):
     18        * bindings/js/JSEventListener.h:
     19        * bindings/js/JSMutationCallback.cpp:
     20        * bindings/js/JSNodeFilterCondition.h:
     21        * bindings/js/ScriptWrappable.h:
     22        (JSC):
     23        (WebCore):
     24        (ScriptWrappable):
     25        * bindings/js/ScriptWrappableInlines.h: Added.
     26        (WebCore):
     27        (WebCore::ScriptWrappable::wrapper):
     28        (WebCore::ScriptWrappable::setWrapper):
     29        (WebCore::ScriptWrappable::clearWrapper):
     30        * bridge/qt/qt_instance.h:
     31        * bridge/qt/qt_runtime.h:
     32        * bridge/runtime_root.cpp:
     33        * bridge/runtime_root.h:
     34        * css/StylePropertySet.cpp:
     35        * dom/LiveNodeList.cpp:
     36        (WebCore::LiveNodeListBase::reportMemoryUsage):
     37        * dom/Node.cpp:
     38        (WebCore::Node::reportMemoryUsage):
     39        * inspector/InspectorDebuggerAgent.cpp:
     40        * inspector/NetworkResourcesData.cpp:
     41        * loader/cache/CachedSVGDocument.cpp:
     42        * xml/XMLHttpRequest.cpp:
     43        (WebCore::XMLHttpRequest::reportMemoryUsage):
     44
    1452013-04-08  Tiancheng Jiang  <tijiang@rim.com>
    246
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r147921 r147962  
    303303                1059459F15B42B1A004D37FD /* JSPropertyNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1059459E15B42B1A004D37FD /* JSPropertyNodeList.h */; };
    304304                10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; };
     305                1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    305306                1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1402645D0AFDC19B005919E2 /* LoggingMac.mm */; };
    306307                1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    65316532                1059459E15B42B1A004D37FD /* JSPropertyNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPropertyNodeList.h; sourceTree = "<group>"; };
    65326533                10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = "<group>"; };
     6534                1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappableInlines.h; sourceTree = "<group>"; };
    65336535                1402645D0AFDC19B005919E2 /* LoggingMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingMac.mm; sourceTree = "<group>"; };
    65346536                1403B90C09EB124500797C7F /* DOMWindow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindow.idl; sourceTree = "<group>"; };
     
    1873218734                                934CC0E00ED39D6F00A658F2 /* ScriptValue.h */,
    1873318735                                228C284410D82500009D0D0E /* ScriptWrappable.h */,
     18736                                1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */,
    1873418737                                A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */,
    1873518738                                A75E497410752ACB00C9B896 /* SerializedScriptValue.h */,
     
    2390123904                                6E47E66110B7944B00B186C8 /* WebGLGetInfo.h in Headers */,
    2390223905                                49FFBF3F11C93EE3006A7118 /* WebGLLayer.h in Headers */,
     23906                                1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */,
    2390323907                                93F1D5BB12D532C400832BEC /* WebGLLoseContext.h in Headers */,
    2390423908                                49C7B9D51042D32F0009D447 /* WebGLObject.h in Headers */,
  • trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h

    r140194 r147962  
    2424
    2525#include "JSDOMGlobalObject.h"
    26 #include <heap/Weak.h>
    2726#include <runtime/WeakGCMap.h>
    2827#include <wtf/Forward.h>
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r146430 r147962  
    3131#include "Document.h"
    3232#include "ScriptWrappable.h"
     33#include "ScriptWrappableInlines.h"
    3334#include <heap/SlotVisitor.h>
    3435#include <heap/Weak.h>
     36#include <heap/WeakInlines.h>
    3537#include <runtime/Error.h>
    3638#include <runtime/FunctionPrototype.h>
     
    4547
    4648namespace JSC {
    47 
    4849class HashEntry;
    49 
    5050}
    5151
  • trunk/Source/WebCore/bindings/js/JSEventListener.h

    r134697 r147962  
    2323#include "EventListener.h"
    2424#include "JSDOMWindow.h"
     25#include <heap/PassWeak.h>
    2526#include <heap/StrongInlines.h>
    2627#include <heap/Weak.h>
     28#include <heap/WeakInlines.h>
    2729
    2830namespace WebCore {
  • trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp

    r145379 r147962  
    3333#include "JSMutationRecord.h"
    3434#include "ScriptExecutionContext.h"
     35#include <heap/WeakInlines.h>
    3536#include <runtime/JSLock.h>
    3637
  • trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.h

    r140718 r147962  
    2323#include "NodeFilterCondition.h"
    2424#include <heap/Weak.h>
     25#include <heap/WeakInlines.h>
    2526#include <runtime/JSCJSValue.h>
    2627#include <runtime/Operations.h>
  • trunk/Source/WebCore/bindings/js/ScriptWrappable.h

    r141570 r147962  
    11/*
     2 * Copyright (C) 2013 Apple Inc. All rights reserved.
    23 * Copyright (c) 2010, Google Inc. All rights reserved.
    34 *
     
    3233#define ScriptWrappable_h
    3334
    34 #include "JSDOMWrapper.h"
    35 #include "WebCoreMemoryInstrumentation.h"
    3635#include <heap/Weak.h>
    37 #include <runtime/Operations.h>
     36
     37namespace JSC {
     38class JSGlobalData;
     39class WeakHandleOwner;
     40}
    3841
    3942namespace WebCore {
    4043
     44class JSDOMWrapper;
     45
    4146class ScriptWrappable {
    4247public:
    43     JSDOMWrapper* wrapper() const
    44     {
    45         return m_wrapper.get();
    46     }
    47 
    48     void setWrapper(JSC::JSGlobalData&, JSDOMWrapper* wrapper, JSC::WeakHandleOwner* wrapperOwner, void* context)
    49     {
    50         ASSERT(!m_wrapper);
    51         m_wrapper = JSC::PassWeak<JSDOMWrapper>(wrapper, wrapperOwner, context);
    52     }
    53 
    54     void clearWrapper(JSDOMWrapper* wrapper)
    55     {
    56         weakClear(m_wrapper, wrapper);
    57     }
    58 
    59     void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    60     {
    61         MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    62         info.addMember(m_wrapper, "wrapper");
    63     }
     48    JSDOMWrapper* wrapper() const;
     49    void setWrapper(JSC::JSGlobalData&, JSDOMWrapper*, JSC::WeakHandleOwner*, void*);
     50    void clearWrapper(JSDOMWrapper*);
    6451
    6552private:
  • trunk/Source/WebCore/bridge/qt/qt_instance.h

    r129647 r147962  
    2424#include "JSWeakObjectMapRefPrivate.h"
    2525#include "Weak.h"
     26#include "WeakInlines.h"
    2627#include "runtime_root.h"
    2728#include <QPointer>
  • trunk/Source/WebCore/bridge/qt/qt_runtime.h

    r127238 r147962  
    2525#include "JavaScript.h"
    2626#include "Weak.h"
     27#include "WeakInlines.h"
    2728#include "qt_instance.h"
    2829#include "runtime_method.h"
  • trunk/Source/WebCore/bridge/runtime_root.cpp

    r130612 r147962  
    3131#include <heap/StrongInlines.h>
    3232#include <heap/Weak.h>
     33#include <heap/WeakInlines.h>
    3334#include <runtime/JSGlobalObject.h>
    3435#include <wtf/HashCountedSet.h>
  • trunk/Source/WebCore/bridge/runtime_root.h

    r129964 r147962  
    2929#include <heap/Strong.h>
    3030#include <heap/Weak.h>
     31#include <heap/WeakInlines.h>
    3132#include <wtf/Forward.h>
    3233#include <wtf/HashCountedSet.h>
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h

    r147751 r147962  
    2929#include "CSSStyleDeclaration.h"
    3030#include <wtf/HashMap.h>
     31#include <wtf/OwnPtr.h>
     32#include <wtf/RefPtr.h>
    3133
    3234namespace WebCore {
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r145029 r147962  
    3131#include "StylePropertyShorthand.h"
    3232#include "StyleSheetContents.h"
     33#include "WebCoreMemoryInstrumentation.h"
    3334#include <wtf/BitArray.h>
    3435#include <wtf/MemoryInstrumentationVector.h>
  • trunk/Source/WebCore/css/WebKitCSSMatrix.cpp

    r142810 r147962  
    3131#include "CSSValueKeywords.h"
    3232#include "ExceptionCode.h"
     33#include "ScriptWrappableInlines.h"
    3334#include "StylePropertySet.h"
    3435#include "StyleResolver.h"
  • trunk/Source/WebCore/dom/ClientRect.cpp

    r95901 r147962  
    2828#include "ClientRect.h"
    2929
     30#include "ScriptWrappableInlines.h"
     31
    3032namespace WebCore {
    3133
  • trunk/Source/WebCore/dom/ClientRectList.cpp

    r95901 r147962  
    3030#include "ExceptionCode.h"
    3131#include "ClientRect.h"
     32#include "ScriptWrappableInlines.h"
    3233
    3334namespace WebCore {
  • trunk/Source/WebCore/dom/DOMStringMap.cpp

    r95901 r147962  
    2727#include "DOMStringMap.h"
    2828
     29#include "ScriptWrappableInlines.h"
     30
    2931namespace WebCore {
     32
     33DOMStringMap::DOMStringMap()
     34{
     35}
    3036
    3137DOMStringMap::~DOMStringMap()
  • trunk/Source/WebCore/dom/DOMStringMap.h

    r135058 r147962  
    5454
    5555protected:
    56     DOMStringMap()
    57     {
    58     }
     56    DOMStringMap();
    5957};
    6058
  • trunk/Source/WebCore/dom/Event.cpp

    r142072 r147962  
    2727#include "EventNames.h"
    2828#include "EventTarget.h"
     29#include "ScriptWrappableInlines.h"
    2930#include "UserGestureIndicator.h"
    3031#include "WebCoreMemoryInstrumentation.h"
  • trunk/Source/WebCore/dom/LiveNodeList.cpp

    r145818 r147962  
    9494{
    9595    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    96     NodeList::reportMemoryUsage(memoryObjectInfo);
    9796    info.addMember(m_ownerNode, "ownerNode");
    9897    info.addWeakPointer(m_cachedItem);
  • trunk/Source/WebCore/dom/MutationRecord.cpp

    r138811 r147962  
    3636#include "NodeList.h"
    3737#include "QualifiedName.h"
     38#include "ScriptWrappableInlines.h"
    3839#include "StaticNodeList.h"
    3940#include <wtf/Assertions.h>
  • trunk/Source/WebCore/dom/Node.cpp

    r147795 r147962  
    26282628{
    26292629    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    2630     ScriptWrappable::reportMemoryUsage(memoryObjectInfo);
    26312630    info.addMember(m_parentOrShadowHostNode, "parentOrShadowHostNode");
    26322631    info.addMember(m_treeScope, "treeScope");
  • trunk/Source/WebCore/fileapi/FileList.cpp

    r95901 r147962  
    2828
    2929#include "File.h"
     30#include "ScriptWrappableInlines.h"
    3031
    3132namespace WebCore {
  • trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp

    r144568 r147962  
    4545#include "ScriptDebugServer.h"
    4646#include "ScriptObject.h"
     47#include "WebCoreMemoryInstrumentation.h"
    4748#include <wtf/MemoryInstrumentationHashMap.h>
    4849#include <wtf/MemoryInstrumentationVector.h>
  • trunk/Source/WebCore/inspector/NetworkResourcesData.cpp

    r144568 r147962  
    3838#include "SharedBuffer.h"
    3939#include "TextResourceDecoder.h"
     40#include "WebCoreMemoryInstrumentation.h"
    4041#include <wtf/MemoryInstrumentationHashMap.h>
    4142
  • trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp

    r141570 r147962  
    2929#include "CachedResourceHandle.h"
    3030#include "ResourceBuffer.h"
     31#include "WebCoreMemoryInstrumentation.h"
    3132#include <wtf/text/StringBuilder.h>
    3233
  • trunk/Source/WebCore/page/Crypto.cpp

    r134440 r147962  
    3232
    3333#include "ExceptionCode.h"
     34#include "ScriptWrappableInlines.h"
    3435#include <wtf/ArrayBufferView.h>
    3536#include <wtf/CryptographicallyRandomNumber.h>
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r147888 r147962  
    13211321{
    13221322    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    1323     ScriptWrappable::reportMemoryUsage(memoryObjectInfo);
    13241323    ActiveDOMObject::reportMemoryUsage(memoryObjectInfo);
    13251324    info.addMember(m_upload, "upload");
  • trunk/Source/WebKit2/ChangeLog

    r147953 r147962  
     12013-04-08  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Stop #include-ing all of JavaScriptCore in every DOM-related file
     4        https://bugs.webkit.org/show_bug.cgi?id=114220
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Shared/WebCoreArgumentCoders.cpp:
     9        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
     10
    1112013-04-08  Brady Eidson  <beidson@apple.com>
    212
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r146544 r147962  
    5151#include <WebCore/ViewportArguments.h>
    5252#include <WebCore/WindowFeatures.h>
     53#include <wtf/text/CString.h>
    5354#include <wtf/text/StringHash.h>
    5455
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h

    r117212 r147962  
    3131#include <WebCore/RunLoop.h>
    3232#include <heap/Weak.h>
     33#include <heap/WeakInlines.h>
    3334#include <wtf/Forward.h>
    3435#include <wtf/HashMap.h>
Note: See TracChangeset for help on using the changeset viewer.