Ignore:
Timestamp:
Apr 8, 2013, 4:41:02 PM (12 years ago)
Author:
[email protected]
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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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{
Note: See TracChangeset for help on using the changeset viewer.