Changeset 154962 in webkit


Ignore:
Timestamp:
Sep 2, 2013 11:50:01 AM (11 years ago)
Author:
akling@apple.com
Message:

Ref: A smart pointer for the reference age.
<https://webkit.org/b/120570>

Reviewed by Antti Koivisto.

Source/WebCore:

Use Ref<T> for various stack guards where null checking isn't needed.

Source/WTF:

Add a very simple simple Ref<T> smart pointer class that is never null.
It's initialized by passing a T& to the constructor and cannot be assigned to.

operator-> is not overloaded, to prevent unsafe-looking code.
The value is extracted by "T& get()", since C++ does not let you override operator.()

  • wtf/Ref.h:
Location:
trunk/Source
Files:
68 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r154902 r154962  
     12013-09-01  Andreas Kling  <akling@apple.com>
     2
     3        Ref: A smart pointer for the reference age.
     4        <https://webkit.org/b/120570>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Add a very simple simple Ref<T> smart pointer class that is never null.
     9        It's initialized by passing a T& to the constructor and cannot be assigned to.
     10
     11        operator-> is not overloaded, to prevent unsafe-looking code.
     12        The value is extracted by "T& get()", since C++ does not let you override operator.()
     13
     14        * wtf/Ref.h:
     15
    1162013-08-30  Oliver Hunt  <oliver@apple.com>
    217
  • trunk/Source/WTF/WTF.pro

    r154498 r154962  
    8686    MetaAllocator.h \
    8787    MetaAllocatorHandle.h \
     88    Ref.h \
    8889    Noncopyable.h \
    8990    NonCopyingSort.h \
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters

    r154507 r154962  
    495495      <Filter>wtf</Filter>
    496496    </ClInclude>
     497    <ClInclude Include="..\wtf\Ref.h">
     498      <Filter>wtf</Filter>
     499    </ClInclude>
    497500    <ClInclude Include="..\wtf\Noncopyable.h">
    498501      <Filter>wtf</Filter>
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r154499 r154962  
    5555                1FA47C8B152502DA00568D1B /* WebCoreThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FA47C89152502DA00568D1B /* WebCoreThread.h */; };
    5656                26147B0A15DDCCDC00DDB907 /* IntegerToStringConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */; };
     57                26299B6E17A9E5B800ADEBE5 /* Ref.h in Headers */ = {isa = PBXBuildFile; fileRef = 26299B6D17A9E5B800ADEBE5 /* Ref.h */; };
    5758                2C05385415BC819000F21B96 /* GregorianDateTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C05385315BC819000F21B96 /* GregorianDateTime.h */; };
    5859                2CCD892A15C0390200285083 /* GregorianDateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CCD892915C0390200285083 /* GregorianDateTime.cpp */; };
     
    321322                1FA47C89152502DA00568D1B /* WebCoreThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThread.h; sourceTree = "<group>"; };
    322323                26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegerToStringConversion.h; sourceTree = "<group>"; };
     324                26299B6D17A9E5B800ADEBE5 /* Ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Ref.h; sourceTree = "<group>"; };
    323325                2C05385315BC819000F21B96 /* GregorianDateTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GregorianDateTime.h; sourceTree = "<group>"; };
    324326                2CCD892915C0390200285083 /* GregorianDateTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GregorianDateTime.cpp; sourceTree = "<group>"; };
     
    709711                                A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */,
    710712                                1A3F6BE6174ADA2100B2EEA7 /* NeverDestroyed.h */,
     713                                26299B6D17A9E5B800ADEBE5 /* Ref.h */,
    711714                                0F0D85B317234CB100338210 /* NoLock.h */,
    712715                                A8A472D0151A825B004123FF /* Noncopyable.h */,
     
    10021005                                A8A473DB151A825B004123FF /* HexNumber.h in Headers */,
    10031006                                A8A473DC151A825B004123FF /* InlineASM.h in Headers */,
     1007                                26299B6E17A9E5B800ADEBE5 /* Ref.h in Headers */,
    10041008                                A70DA0841799F04D00529A9B /* Insertion.h in Headers */,
    10051009                                26147B0A15DDCCDC00DDB907 /* IntegerToStringConversion.h in Headers */,
     
    10641068                                A748745317A0BDAE00FA04CB /* SixCharacterHash.h in Headers */,
    10651069                                A8A47426151A825B004123FF /* Spectrum.h in Headers */,
     1070                                26A7052617445A5F00118ACA /* Ref.h in Headers */,
    10661071                                A8A47428151A825B004123FF /* StackBounds.h in Headers */,
    10671072                                FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */,
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r154498 r154962  
    5656    NonCopyingSort.h
    5757    ThreadRestrictionVerifier.h
     58    Ref.h
    5859    Noncopyable.h
    5960    NotFound.h
  • trunk/Source/WTF/wtf/Forward.h

    r153728 r154962  
    3333    template<typename T> class PassRefPtr;
    3434    template<typename T> class RefPtr;
     35    template<typename T> class Ref;
    3536    template<typename T, size_t inlineCapacity, typename OverflowHandler> class Vector;
    3637
     
    5657using WTF::PassRefPtr;
    5758using WTF::RefPtr;
     59using WTF::Ref;
    5860using WTF::Vector;
    5961
  • trunk/Source/WebCore/ChangeLog

    r154961 r154962  
     12013-09-01  Andreas Kling  <akling@apple.com>
     2
     3        Ref: A smart pointer for the reference age.
     4        <https://webkit.org/b/120570>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Use Ref<T> for various stack guards where null checking isn't needed.
     9
    1102013-09-02  Andreas Kling  <akling@apple.com>
    211
  • trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp

    r146537 r154962  
    3636#include "Page.h"
    3737#include <wtf/CurrentTime.h>
     38#include <wtf/Ref.h>
    3839
    3940#include "Coordinates.h"
     
    148149    // Protect this GeoNotifier object, since it
    149150    // could be deleted by a call to clearWatch in a callback.
    150     RefPtr<GeoNotifier> protect(this);
     151    Ref<GeoNotifier> protect(*this);
    151152
    152153    // Test for fatal error first. This is required for the case where the Frame is
     
    434435{
    435436    // Protect the Geolocation object from garbage collection during a callback.
    436     RefPtr<Geolocation> protect(this);
     437    Ref<Geolocation> protect(*this);
    437438
    438439    // This may be due to either a new position from the service, or a cached
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r153728 r154962  
    8585#include <wtf/OwnPtr.h>
    8686#include <wtf/PassOwnPtr.h>
     87#include <wtf/Ref.h>
    8788#include <wtf/RefCounted.h>
    8889#include <wtf/text/WTFString.h>
     
    844845
    845846    // Protect this object from being deleted before we release the mutex locked by AutoLocker.
    846     RefPtr<AudioContext> protect(this);
     847    Ref<AudioContext> protect(*this);
    847848    {
    848849        AutoLocker locker(this);
  • trunk/Source/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp

    r148696 r154962  
    3737#include "ScriptExecutionContext.h"
    3838#include <runtime/JSLock.h>
     39#include <wtf/Ref.h>
    3940
    4041namespace WebCore {
     
    4748        return true;
    4849
    49     RefPtr<JSSQLStatementErrorCallback> protect(this);
     50    Ref<JSSQLStatementErrorCallback> protect(*this);
    5051
    5152    JSC::JSLockHolder lock(m_data->globalObject()->vm());
  • trunk/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp

    r153872 r154962  
    3636#include "SecurityOrigin.h"
    3737#include <runtime/JSLock.h>
     38#include <wtf/Ref.h>
    3839
    3940namespace WebCore {
     
    8788    }
    8889
    89     RefPtr<JSCustomXPathNSResolver> selfProtector(this);
     90    Ref<JSCustomXPathNSResolver> selfProtector(*this);
    9091
    9192    MarkedArgumentBuffer args;
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObjectTask.cpp

    r154629 r154962  
    3030#include "JSMainThreadExecState.h"
    3131#include <heap/StrongInlines.h>
     32#include <wtf/Ref.h>
    3233
    3334using namespace JSC;
     
    4748            return;
    4849
    49         RefPtr<JSGlobalObjectCallback> protect(this);
     50        Ref<JSGlobalObjectCallback> protect(*this);
    5051        JSLockHolder lock(m_globalObject->vm());
    5152
  • trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp

    r153480 r154962  
    3939#include "JSMainThreadExecState.h"
    4040#include <runtime/JSLock.h>
     41#include <wtf/Ref.h>
    4142
    4243using namespace JSC;
     
    8081
    8182    if (callType != CallTypeNone) {
    82         RefPtr<JSErrorHandler> protectedctor(this);
     83        Ref<JSErrorHandler> protectedctor(*this);
    8384
    8485        Event* savedEvent = globalObject->currentEvent();
  • trunk/Source/WebCore/bindings/js/JSEventListener.cpp

    r154192 r154962  
    3131#include <runtime/ExceptionHelpers.h>
    3232#include <runtime/JSLock.h>
     33#include <wtf/Ref.h>
    3334#include <wtf/RefCountedLeakCounter.h>
    3435
     
    112113
    113114    if (callType != CallTypeNone) {
    114         RefPtr<JSEventListener> protect(this);
     115        Ref<JSEventListener> protect(*this);
    115116
    116117        MarkedArgumentBuffer args;
  • trunk/Source/WebCore/bindings/js/JSEventListener.h

    r148696 r154962  
    2727#include <heap/Weak.h>
    2828#include <heap/WeakInlines.h>
     29#include <wtf/Ref.h>
    2930
    3031namespace WebCore {
     
    8081        // initializeJSFunction can trigger code that deletes this event listener
    8182        // before we're done. It should always return 0 in this case.
    82         RefPtr<JSEventListener> protect(const_cast<JSEventListener*>(this));
     83        Ref<JSEventListener> protect(const_cast<JSEventListener&>(*this));
    8384        JSC::Strong<JSC::JSObject> wrapper(*m_isolatedWorld->vm(), m_wrapper.get());
    8485
  • trunk/Source/WebCore/bridge/runtime_root.cpp

    r148696 r154962  
    3535#include <wtf/HashCountedSet.h>
    3636#include <wtf/HashSet.h>
     37#include <wtf/Ref.h>
    3738#include <wtf/StdLibExtras.h>
    3839
     
    202203    RuntimeObject* object = static_cast<RuntimeObject*>(handle.get().asCell());
    203204
    204     RefPtr<RootObject> protect(this);
     205    Ref<RootObject> protect(*this);
    205206    object->invalidate();
    206207    weakRemove(m_runtimeObjects, object, object);
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r154219 r154962  
    5151#include "StyleRule.h"
    5252#include "WebKitFontFamilyNames.h"
     53#include <wtf/Ref.h>
    5354#include <wtf/text/AtomicString.h>
    5455
     
    599600
    600601    // CSSFontSelector could get deleted via beginLoadIfNeeded() or loadDone() unless protected.
    601     RefPtr<CSSFontSelector> protect(this);
     602    Ref<CSSFontSelector> protect(*this);
    602603
    603604    CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader();
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r154877 r154962  
    3535#include "StyleRuleImport.h"
    3636#include <wtf/Deque.h>
     37#include <wtf/Ref.h>
    3738
    3839namespace WebCore {
     
    342343        return;
    343344
    344     RefPtr<StyleSheetContents> protect(this);
    345 
    346345    // Avoid |this| being deleted by scripts that run via
    347346    // ScriptableDocumentParser::executeScriptsWaitingForStylesheets().
    348347    // See <rdar://problem/6622300>.
    349     RefPtr<StyleSheetContents> protector(this);
     348    Ref<StyleSheetContents> protect(*this);
    350349    StyleSheetContents* parentSheet = parentStyleSheet();
    351350    if (parentSheet) {
  • trunk/Source/WebCore/dom/CharacterData.cpp

    r154957 r154962  
    3636#include "Text.h"
    3737#include "TextBreakIterator.h"
     38#include <wtf/Ref.h>
    3839
    3940using namespace std;
     
    4748        return;
    4849
    49     RefPtr<CharacterData> protect = this;
     50    Ref<CharacterData> protect(*this);
    5051
    5152    unsigned oldLength = length();
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r154957 r154962  
    5656#include "Text.h"
    5757#include <wtf/CurrentTime.h>
     58#include <wtf/Ref.h>
    5859#include <wtf/Vector.h>
    5960
     
    263264    ASSERT(refCount() || parentOrShadowHostNode());
    264265
    265     RefPtr<Node> protect(this);
     266    Ref<ContainerNode> protect(*this);
    266267
    267268    ec = 0;
     
    404405    ASSERT(refCount() || parentOrShadowHostNode());
    405406
    406     RefPtr<Node> protect(this);
     407    Ref<ContainerNode> protect(*this);
    407408
    408409    ec = 0;
     
    527528    ASSERT(refCount() || parentOrShadowHostNode());
    528529
    529     RefPtr<Node> protect(this);
     530    Ref<ContainerNode> protect(*this);
    530531
    531532    ec = 0;
     
    638639
    639640    // The container node can be removed from event handlers.
    640     RefPtr<ContainerNode> protect(this);
     641    Ref<ContainerNode> protect(*this);
    641642
    642643    // exclude this node when looking for removed focusedNode since only children will be removed
     
    649650    // Do any prep work needed before actually starting to detach
    650651    // and remove... e.g. stop loading frames, fire unload events.
    651     willRemoveChildren(protect.get());
     652    willRemoveChildren(this);
    652653
    653654    NodeVector removedChildren;
     
    675676bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, AttachBehavior attachBehavior)
    676677{
    677     RefPtr<ContainerNode> protect(this);
     678    Ref<ContainerNode> protect(*this);
    678679
    679680    // Check that this node is not "floating".
     
    778779{
    779780    if (s_attachDepth == 1) {
    780         RefPtr<ContainerNode> protect(this);
     781        Ref<ContainerNode> protect(*this);
    781782
    782783        if (s_postAttachCallbackQueue)
  • trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h

    r154877 r154962  
    3131#include "ShadowRoot.h"
    3232#include <wtf/Assertions.h>
     33#include <wtf/Ref.h>
    3334
    3435namespace WebCore {
     
    184185                tail = n;
    185186            } else {
    186                 RefPtr<GenericNode> protect(n); // removedFromDocument may remove remove all references to this node.
     187                Ref<GenericNode> protect(*n); // removedFromDocument may remove remove all references to this node.
    187188                NodeRemovalDispatcher<GenericNode, GenericNodeContainer, ShouldDispatchRemovalNotification<GenericNode>::value>::dispatch(n, container);
    188189            }
     
    197198{
    198199    ASSERT(m_insertionPoint->inDocument());
    199     RefPtr<Node> protect(node);
     200    Ref<Node> protect(*node);
    200201    if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node->insertedInto(m_insertionPoint))
    201202        m_postInsertionNotificationTargets.append(node);
     
    222223#endif
    223224
    224     RefPtr<Document> protectDocument(&node->document());
    225     RefPtr<Node> protectNode(node);
     225    Ref<Document> protectDocument(node->document());
     226    Ref<Node> protectNode(*node);
    226227
    227228    if (m_insertionPoint->inDocument())
  • trunk/Source/WebCore/dom/Document.cpp

    r154961 r154962  
    166166#include <wtf/MainThread.h>
    167167#include <wtf/PassRefPtr.h>
     168#include <wtf/Ref.h>
    168169#include <wtf/TemporaryChange.h>
    169170#include <wtf/text/StringBuffer.h>
     
    23732374
    23742375    // Call to dispatchWindowLoadEvent can blow us from underneath.
    2375     RefPtr<Document> protect(this);
     2376    Ref<Document> protect(*this);
    23762377
    23772378    m_processingLoadEvent = true;
     
    53235324    // document will be detached and GC'd. We protect it here to make sure we
    53245325    // can finish the function successfully.
    5325     RefPtr<Document> protectDocument(this);
     5326    Ref<Document> protect(*this);
    53265327    Deque<RefPtr<Node> > changeQueue;
    53275328    m_fullScreenChangeEventTargetQueue.swap(changeQueue);
  • trunk/Source/WebCore/dom/DocumentEventQueue.cpp

    r154877 r154962  
    3535#include "ScriptExecutionContext.h"
    3636#include "SuspendableTimer.h"
     37#include <wtf/Ref.h>
    3738
    3839namespace WebCore {
     
    136137    ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
    137138
    138     RefPtr<DocumentEventQueue> protector(this);
     139    Ref<DocumentEventQueue> protect(*this);
    139140
    140141    while (!m_queuedEvents.isEmpty()) {
  • trunk/Source/WebCore/dom/EventTarget.cpp

    r154673 r154962  
    3939#include "WebKitTransitionEvent.h"
    4040#include <wtf/MainThread.h>
     41#include <wtf/Ref.h>
    4142#include <wtf/StdLibExtras.h>
    4243#include <wtf/Vector.h>
     
    241242void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventListenerVector& entry)
    242243{
    243     RefPtr<EventTarget> protect = this;
     244    Ref<EventTarget> protect(*this);
    244245
    245246    // Fire all listeners registered for this event. Don't fire listeners removed during event dispatch.
  • trunk/Source/WebCore/dom/Node.cpp

    r154928 r154962  
    21812181        return true;
    21822182
    2183     RefPtr<Node> protector(this);
     2183    Ref<Node> protect(*this);
    21842184    RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL);
    21852185    dispatchEvent(beforeLoadEvent.get());
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r153480 r154962  
    3939#include "WorkerThread.h"
    4040#include <wtf/MainThread.h>
     41#include <wtf/Ref.h>
    4142
    4243// FIXME: This is a layering violation.
     
    124125void ScriptExecutionContext::dispatchMessagePortEvents()
    125126{
    126     RefPtr<ScriptExecutionContext> protect(this);
     127    Ref<ScriptExecutionContext> protect(*this);
    127128
    128129    // Make a frozen copy.
  • trunk/Source/WebCore/dom/ScriptedAnimationController.cpp

    r154754 r154962  
    3535#include "RequestAnimationFrameCallback.h"
    3636#include "Settings.h"
     37#include <wtf/Ref.h>
    3738
    3839#if USE(REQUEST_ANIMATION_FRAME_TIMER)
     
    141142    // Invoking callbacks may detach elements from our document, which clears the document's
    142143    // reference to us, so take a defensive reference.
    143     RefPtr<ScriptedAnimationController> protector(this);
     144    Ref<ScriptedAnimationController> protect(*this);
    144145
    145146    for (size_t i = 0; i < callbacks.size(); ++i) {
  • trunk/Source/WebCore/html/HTMLEmbedElement.cpp

    r154877 r154962  
    3838#include "RenderWidget.h"
    3939#include "Settings.h"
     40#include <wtf/Ref.h>
    4041
    4142namespace WebCore {
     
    155156    parametersForPlugin(paramNames, paramValues);
    156157
    157     RefPtr<HTMLEmbedElement> protect(this); // Loading the plugin might remove us from the document.
     158    Ref<HTMLEmbedElement> protect(*this); // Loading the plugin might remove us from the document.
    158159    bool beforeLoadAllowedLoad = guardedDispatchBeforeLoadEvent(m_url);
    159160    if (!beforeLoadAllowedLoad) {
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r154877 r154962  
    4242#include "ValidationMessage.h"
    4343#include "ValidityState.h"
     44#include <wtf/Ref.h>
    4445#include <wtf/Vector.h>
    4546
     
    414415        return true;
    415416    // An event handler can deref this object.
    416     RefPtr<HTMLFormControlElement> protector(this);
    417     RefPtr<Document> originalDocument(&document());
     417    Ref<HTMLFormControlElement> protect(*this);
     418    Ref<Document> originalDocument(document());
    418419    bool needsDefaultAction = dispatchEvent(Event::create(eventNames().invalidEvent, false, true));
    419     if (needsDefaultAction && unhandledInvalidControls && inDocument() && originalDocument == &document())
     420    if (needsDefaultAction && unhandledInvalidControls && inDocument() && &originalDocument.get() == &document())
    420421        unhandledInvalidControls->append(this);
    421422    return false;
  • trunk/Source/WebCore/html/HTMLFormElement.cpp

    r154877 r154962  
    4848#include "Settings.h"
    4949#include <limits>
     50#include <wtf/Ref.h>
    5051
    5152using namespace std;
     
    228229    document().updateLayoutIgnorePendingStylesheets();
    229230
    230     RefPtr<HTMLFormElement> protector(this);
     231    Ref<HTMLFormElement> protect(*this);
    231232    // Focus on the first focusable control and show a validation message.
    232233    for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) {
     
    596597bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<FormAssociatedElement> >& unhandledInvalidControls)
    597598{
    598     RefPtr<HTMLFormElement> protector(this);
     599    Ref<HTMLFormElement> protect(*this);
    599600    // Copy m_associatedElements because event handlers called from
    600601    // HTMLFormControlElement::checkValidity() might change m_associatedElements.
  • trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp

    r154165 r154962  
    2727#include "RenderPart.h"
    2828#include "ShadowRoot.h"
     29#include <wtf/Ref.h>
    2930
    3031#if ENABLE(SVG)
     
    8283    // see if this behavior is really needed as Gecko does not allow this.
    8384    if (Frame* frame = contentFrame()) {
    84         RefPtr<Frame> protect(frame);
     85        Ref<Frame> protect(*frame);
    8586        frame->loader().frameDetached();
    8687        frame->disconnectOwnerElement();
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r154903 r154962  
    6969#include "StyleResolver.h"
    7070#include <wtf/MathExtras.h>
     71#include <wtf/Ref.h>
    7172
    7273#if ENABLE(INPUT_TYPE_COLOR)
     
    10351036        return;
    10361037
    1037     RefPtr<HTMLInputElement> protector(this);
     1038    Ref<HTMLInputElement> protect(*this);
    10381039    EventQueueScope scope;
    10391040    String sanitizedValue = sanitizeValue(value);
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r154901 r154962  
    5252#include "StyleResolveForDocument.h"
    5353#include "StyleSheetContents.h"
     54#include <wtf/Ref.h>
    5455#include <wtf/StdLibExtras.h>
    5556
     
    299300    }
    300301    // Completing the sheet load may cause scripts to execute.
    301     RefPtr<Node> protector(this);
     302    Ref<HTMLLinkElement> protect(*this);
    302303
    303304    CSSParserContext parserContext(&document(), baseURL, charset);
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r154937 r154962  
    8484#include <wtf/MathExtras.h>
    8585#include <wtf/NonCopyingSort.h>
     86#include <wtf/Ref.h>
    8687#include <wtf/text/CString.h>
    8788
     
    709710void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*)
    710711{
    711     RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
     712    Ref<HTMLMediaElement> protect(*this); // loadNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
    712713
    713714#if ENABLE(VIDEO_TRACK)
     
    772773void HTMLMediaElement::load()
    773774{
    774     RefPtr<HTMLMediaElement> protect(this); // loadInternal may result in a 'beforeload' event, which can make arbitrary DOM mutations.
     775    Ref<HTMLMediaElement> protect(*this); // loadInternal may result in a 'beforeload' event, which can make arbitrary DOM mutations.
    775776   
    776777    LOG(Media, "HTMLMediaElement::load()");
     
    43094310void HTMLMediaElement::getPluginProxyParams(KURL& url, Vector<String>& names, Vector<String>& values)
    43104311{
    4311     RefPtr<HTMLMediaElement> protect(this); // selectNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
     4312    Ref<HTMLMediaElement> protect(*this); // selectNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
    43124313
    43134314    Frame* frame = document().frame();
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r154957 r154962  
    5353#include "Text.h"
    5454#include "Widget.h"
     55#include <wtf/Ref.h>
    5556
    5657namespace WebCore {
     
    311312    }
    312313
    313     RefPtr<HTMLObjectElement> protect(this); // beforeload and plugin loading can make arbitrary DOM mutations.
     314    Ref<HTMLObjectElement> protect(*this); // beforeload and plugin loading can make arbitrary DOM mutations.
    314315    bool beforeLoadAllowedLoad = guardedDispatchBeforeLoadEvent(url);
    315316    if (!renderer()) // Do not load the plugin if beforeload removed this element or its renderer.
  • trunk/Source/WebCore/html/HTMLOptionElement.cpp

    r154957 r154962  
    4343#include "StyleResolver.h"
    4444#include "Text.h"
     45#include <wtf/Ref.h>
    4546#include <wtf/Vector.h>
    4647#include <wtf/text/StringBuilder.h>
     
    131132void HTMLOptionElement::setText(const String &text, ExceptionCode& ec)
    132133{
    133     RefPtr<Node> protectFromMutationEvents(this);
     134    Ref<HTMLOptionElement> protectFromMutationEvents(*this);
    134135
    135136    // Changing the text causes a recalc of a select's items, which will reset the selected
  • trunk/Source/WebCore/html/HTMLScriptElement.cpp

    r154957 r154962  
    3131#include "ScriptEventListener.h"
    3232#include "Text.h"
     33#include <wtf/Ref.h>
    3334
    3435namespace WebCore {
     
    8081void HTMLScriptElement::setText(const String &value)
    8182{
    82     RefPtr<Node> protectFromMutationEvents(this);
     83    Ref<HTMLScriptElement> protectFromMutationEvents(*this);
    8384
    8485    int numChildren = childNodeCount();
  • trunk/Source/WebCore/html/HTMLTableElement.cpp

    r154877 r154962  
    4141#include "RenderTable.h"
    4242#include "StylePropertySet.h"
     43#include <wtf/Ref.h>
    4344
    4445namespace WebCore {
     
    190191    }
    191192
    192     RefPtr<Node> protectFromMutationEvents(this);
     193    Ref<HTMLTableElement> protectFromMutationEvents(*this);
    193194
    194195    RefPtr<HTMLTableRowElement> lastRow = 0;
  • trunk/Source/WebCore/html/HTMLTextAreaElement.cpp

    r154957 r154962  
    4949#include "TextIterator.h"
    5050#include "TextNodeTraversal.h"
     51#include <wtf/Ref.h>
    5152#include <wtf/StdLibExtras.h>
    5253#include <wtf/text/StringBuilder.h>
     
    407408void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
    408409{
    409     RefPtr<Node> protectFromMutationEvents(this);
     410    Ref<HTMLTextAreaElement> protectFromMutationEvents(*this);
    410411
    411412    // To preserve comments, remove only the text nodes, then add a single text node.
  • trunk/Source/WebCore/html/HTMLTitleElement.cpp

    r154957 r154962  
    3030#include "Text.h"
    3131#include "TextNodeTraversal.h"
     32#include <wtf/Ref.h>
    3233#include <wtf/text/StringBuilder.h>
    3334
     
    9192void HTMLTitleElement::setText(const String &value)
    9293{
    93     RefPtr<Node> protectFromMutationEvents(this);
     94    Ref<HTMLTitleElement> protectFromMutationEvents(*this);
    9495
    9596    int numChildren = childNodeCount();
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r154877 r154962  
    4848#include "Settings.h"
    4949#include <wtf/Functional.h>
     50#include <wtf/Ref.h>
    5051
    5152namespace WebCore {
     
    182183    // pumpTokenizer can cause this parser to be detached from the Document,
    183184    // but we need to ensure it isn't deleted yet.
    184     RefPtr<HTMLDocumentParser> protect(this);
     185    Ref<HTMLDocumentParser> protect(*this);
    185186
    186187    // NOTE: This pump should only ever emit buffered character tokens,
     
    246247    // pumpTokenizer can cause this parser to be detached from the Document,
    247248    // but we need to ensure it isn't deleted yet.
    248     RefPtr<HTMLDocumentParser> protect(this);
     249    Ref<HTMLDocumentParser> protect(*this);
    249250
    250251#if ENABLE(THREADED_HTML_PARSER)
     
    321322    // processParsedChunkFromBackgroundParser can cause this parser to be detached from the Document,
    322323    // but we need to ensure it isn't deleted yet.
    323     RefPtr<HTMLDocumentParser> protect(this);
     324    Ref<HTMLDocumentParser> protect(*this);
    324325
    325326    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), lineNumber().zeroBasedInt());
     
    630631    // pumpTokenizer can cause this parser to be detached from the Document,
    631632    // but we need to ensure it isn't deleted yet.
    632     RefPtr<HTMLDocumentParser> protect(this);
     633    Ref<HTMLDocumentParser> protect(*this);
    633634
    634635#if ENABLE(THREADED_HTML_PARSER)
     
    721722    // pumpTokenizer can cause this parser to be detached from the Document,
    722723    // but we need to ensure it isn't deleted yet.
    723     RefPtr<HTMLDocumentParser> protect(this);
     724    Ref<HTMLDocumentParser> protect(*this);
    724725    String source(inputSource);
    725726
     
    894895        // processParsedChunkFromBackgroundParser can cause this parser to be detached from the Document,
    895896        // but we need to ensure it isn't deleted yet.
    896         RefPtr<HTMLDocumentParser> protect(this);
     897        Ref<HTMLDocumentParser> protect(*this);
    897898        pumpPendingSpeculations();
    898899        return;
     
    930931    // pumpTokenizer can cause this parser to be detached from the Document,
    931932    // but we need to ensure it isn't deleted yet.
    932     RefPtr<HTMLDocumentParser> protect(this);
     933    Ref<HTMLDocumentParser> protect(*this);
    933934
    934935    ASSERT(m_scriptRunner);
     
    957958    // pumpTokenizer can cause this parser to be detached from the Document,
    958959    // but we need to ensure it isn't deleted yet.
    959     RefPtr<HTMLDocumentParser> protect(this);
     960    Ref<HTMLDocumentParser> protect(*this);
    960961    m_scriptRunner->executeScriptsWaitingForStylesheets();
    961962    if (!isWaitingForScripts())
  • trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp

    r154877 r154962  
    3838#include "ScrollbarTheme.h"
    3939#include "WheelEvent.h"
     40#include <wtf/Ref.h>
    4041
    4142namespace WebCore {
     
    9899            // code which detaches this shadow node. We need to take a reference
    99100            // and check renderer() after such function calls.
    100             RefPtr<Node> protector(this);
     101            Ref<SpinButtonElement> protect(*this);
    101102            if (m_spinButtonOwner)
    102103                m_spinButtonOwner->focusAndSelectSpinButtonOwner();
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r154877 r154962  
    4343#include "TextEvent.h"
    4444#include "TextEventInputType.h"
     45#include <wtf/Ref.h>
    4546
    4647namespace WebCore {
     
    309310            }
    310311        }
    311         RefPtr<InputFieldSpeechButtonElement> holdRefButton(this);
     312        Ref<InputFieldSpeechButtonElement> protect(*this);
    312313        input->focus();
    313314        input->select();
     
    386387        return;
    387388
    388     RefPtr<InputFieldSpeechButtonElement> holdRefButton(this);
     389    Ref<InputFieldSpeechButtonElement> protect(*this);
    389390    if (document().domWindow()) {
    390391        // Call selectionChanged, causing the element to cache the selection,
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r154887 r154962  
    6262#include <wtf/CurrentTime.h>
    6363#include <wtf/HashSet.h>
     64#include <wtf/Ref.h>
    6465#include <wtf/Vector.h>
    6566#include <wtf/text/CString.h>
     
    748749
    749750    ErrorString errorString;
    750     RefPtr<WebKitNamedFlow> protector(namedFlow);
     751    Ref<WebKitNamedFlow> protect(*namedFlow);
    751752
    752753    m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
     
    770771   
    771772    ErrorString errorString;
    772     RefPtr<WebKitNamedFlow> protector(namedFlow);
     773    Ref<WebKitNamedFlow> protect(*namedFlow);
    773774   
    774775    m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r154558 r154962  
    6363#include "TextResourceDecoder.h"
    6464#include <wtf/Assertions.h>
     65#include <wtf/Ref.h>
    6566#include <wtf/text/CString.h>
    6667#include <wtf/text/WTFString.h>
     
    250251{
    251252    RefPtr<Frame> protectFrame(m_frame);
    252     RefPtr<DocumentLoader> protectLoader(this);
     253    Ref<DocumentLoader> protectLoader(*this);
    253254
    254255    // In some rare cases, calling FrameLoader::stopLoading could cause isLoading() to return false.
     
    362363#endif
    363364
    364     RefPtr<DocumentLoader> protect(this);
     365    Ref<DocumentLoader> protect(*this);
    365366
    366367    if (m_identifierForLoadWithoutResourceLoader) {
     
    562563{
    563564    ASSERT_UNUSED(resource, m_mainResource == resource);
    564     RefPtr<DocumentLoader> protect(this);
     565    Ref<DocumentLoader> protect(*this);
    565566    bool willLoadFallback = m_applicationCacheHost->maybeLoadFallbackForMainResponse(request(), response);
    566567
     
    732733    // by starting a new load, so retain temporarily.
    733734    RefPtr<Frame> protectFrame(m_frame);
    734     RefPtr<DocumentLoader> protectLoader(this);
     735    Ref<DocumentLoader> protectLoader(*this);
    735736
    736737    commitIfReady();
     
    915916    ASSERT(m_frame);
    916917    RefPtr<Frame> protectFrame(m_frame);
    917     RefPtr<DocumentLoader> protectLoader(this);
     918    Ref<DocumentLoader> protectLoader(*this);
    918919
    919920    // It never makes sense to have a document loader that is detached from its
     
    14201421void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError)
    14211422{
    1422     RefPtr<DocumentLoader> protect(this);
     1423    Ref<DocumentLoader> protect(*this);
    14231424    ResourceError error = resourceError.isNull() ? frameLoader()->cancelledError(m_request) : resourceError;
    14241425
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r154142 r154962  
    4949#include "ThreadableLoaderClient.h"
    5050#include <wtf/Assertions.h>
     51#include <wtf/Ref.h>
    5152
    5253#if ENABLE(INSPECTOR)
     
    145146void DocumentThreadableLoader::cancel()
    146147{
    147     RefPtr<DocumentThreadableLoader> protect(this);
     148    Ref<DocumentThreadableLoader> protect(*this);
    148149
    149150    // Cancel can re-enter and m_resource might be null here as a result.
     
    181182    ASSERT_UNUSED(resource, resource == m_resource);
    182183
    183     RefPtr<DocumentThreadableLoader> protect(this);
     184    Ref<DocumentThreadableLoader> protect(*this);
    184185    // Allow same origin requests to continue after allowing clients to audit the redirect.
    185186    if (isAllowedRedirect(request.url())) {
  • trunk/Source/WebCore/loader/DocumentWriter.cpp

    r154558 r154962  
    4747#include "SinkDocument.h"
    4848#include "TextResourceDecoder.h"
     49#include <wtf/Ref.h>
    4950
    5051namespace WebCore {
     
    234235    // The frame's last ref may be removed and it can be deleted by checkCompleted(),
    235236    // so we'll add a protective refcount
    236     RefPtr<Frame> protector(m_frame);
     237    Ref<Frame> protect(*m_frame);
    237238
    238239    if (!m_parser)
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r154715 r154962  
    109109#include "XMLDocumentParser.h"
    110110#include <wtf/CurrentTime.h>
     111#include <wtf/Ref.h>
    111112#include <wtf/StdLibExtras.h>
    112113#include <wtf/text/CString.h>
     
    304305    ASSERT(!m_suppressOpenerInNewFrame);
    305306
    306     RefPtr<Frame> protect(&m_frame);
     307    Ref<Frame> protect(m_frame);
    307308    FrameLoadRequest frameRequest(passedRequest);
    308309
     
    477478    // http://bugs.webkit.org/show_bug.cgi?id=10854
    478479    // The frame's last ref may be removed and it will be deleted by checkCompleted().
    479     RefPtr<Frame> protector(&m_frame);
     480    Ref<Frame> protect(m_frame);
    480481
    481482    if (DocumentParser* parser = m_frame.document()->parser()) {
     
    758759void FrameLoader::checkCompleted()
    759760{
    760     RefPtr<Frame> protect(&m_frame);
     761    Ref<Frame> protect(m_frame);
    761762    m_shouldCallCheckCompleted = false;
    762763
     
    803804void FrameLoader::checkTimerFired(Timer<FrameLoader>*)
    804805{
    805     RefPtr<Frame> protect(&m_frame);
     806    Ref<Frame> protect(m_frame);
    806807
    807808    if (Page* page = m_frame.page()) {
     
    10901091void FrameLoader::completed()
    10911092{
    1092     RefPtr<Frame> protect(&m_frame);
     1093    Ref<Frame> protect(m_frame);
    10931094
    10941095    for (Frame* descendant = m_frame.tree().traverseNext(&m_frame); descendant; descendant = descendant->tree().traverseNext(&m_frame))
     
    11551156{   
    11561157    // Protect frame from getting blown away inside dispatchBeforeLoadEvent in loadWithDocumentLoader.
    1157     RefPtr<Frame> protect(&m_frame);
     1158    Ref<Frame> protect(m_frame);
    11581159
    11591160    KURL url = request.resourceRequest().url();
     
    13661367{
    13671368    // Retain because dispatchBeforeLoadEvent may release the last reference to it.
    1368     RefPtr<Frame> protect(&m_frame);
     1369    Ref<Frame> protect(m_frame);
    13691370
    13701371    ASSERT(m_client.hasWebView());
     
    15631564    // Calling stopLoading() on the provisional document loader can blow away
    15641565    // the frame from underneath.
    1565     RefPtr<Frame> protect(&m_frame);
     1566    Ref<Frame> protect(m_frame);
    15661567
    15671568    m_inStopAllLoaders = true;
     
    17011702    RefPtr<CachedPage> cachedPage = m_loadingFromCachedPage ? pageCache()->get(history().provisionalItem()) : 0;
    17021703    RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
    1703     RefPtr<Frame> protect(&m_frame);
     1704    Ref<Frame> protect(m_frame);
    17041705
    17051706    LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame.tree().uniqueName().string().utf8().data(),
     
    26152616{
    26162617    // Retain because the stop may release the last reference to it.
    2617     RefPtr<Frame> protect(&m_frame);
     2618    Ref<Frame> protect(m_frame);
    26182619
    26192620    RefPtr<DocumentLoader> loader = activeDocumentLoader();
  • trunk/Source/WebCore/loader/NavigationScheduler.cpp

    r154558 r154962  
    5151#include "UserGestureIndicator.h"
    5252#include <wtf/CurrentTime.h>
     53#include <wtf/Ref.h>
    5354
    5455namespace WebCore {
     
    421422    }
    422423
    423     RefPtr<Frame> protect(m_frame);
     424    Ref<Frame> protect(*m_frame);
    424425
    425426    OwnPtr<ScheduledNavigation> redirect(m_redirect.release());
     
    432433    ASSERT(m_frame->page());
    433434
    434     RefPtr<Frame> protect(m_frame);
     435    Ref<Frame> protect(*m_frame);
    435436
    436437    // If a redirect was scheduled during a load, then stop the current load.
  • trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp

    r154449 r154962  
    3333#include "FrameLoader.h"
    3434#include "FrameLoaderClient.h"
     35#include <wtf/Ref.h>
    3536
    3637namespace WebCore {
     
    6970void NetscapePlugInStreamLoader::didReceiveResponse(const ResourceResponse& response)
    7071{
    71     RefPtr<NetscapePlugInStreamLoader> protect(this);
     72    Ref<NetscapePlugInStreamLoader> protect(*this);
    7273
    7374    m_client->didReceiveResponse(this, response);
     
    106107void NetscapePlugInStreamLoader::didReceiveDataOrBuffer(const char* data, int length, PassRefPtr<SharedBuffer> buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
    107108{
    108     RefPtr<NetscapePlugInStreamLoader> protect(this);
     109    Ref<NetscapePlugInStreamLoader> protect(*this);
    109110   
    110111    m_client->didReceiveData(this, buffer ? buffer->data() : data, buffer ? buffer->size() : length);
     
    115116void NetscapePlugInStreamLoader::didFinishLoading(double finishTime)
    116117{
    117     RefPtr<NetscapePlugInStreamLoader> protect(this);
     118    Ref<NetscapePlugInStreamLoader> protect(*this);
    118119
    119120    m_documentLoader->removePlugInStreamLoader(this);
     
    124125void NetscapePlugInStreamLoader::didFail(const ResourceError& error)
    125126{
    126     RefPtr<NetscapePlugInStreamLoader> protect(this);
     127    Ref<NetscapePlugInStreamLoader> protect(*this);
    127128
    128129    m_documentLoader->removePlugInStreamLoader(this);
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r154449 r154962  
    5050#include "Settings.h"
    5151#include "SharedBuffer.h"
     52#include <wtf/Ref.h>
    5253
    5354namespace WebCore {
     
    7879    // We need to retain to avoid accessing the object after it
    7980    // has been deallocated and also to avoid reentering this method.
    80     RefPtr<ResourceLoader> protector(this);
     81    Ref<ResourceLoader> protect(*this);
    8182
    8283    m_frame = 0;
     
    225226    // Protect this in this delegate method since the additional processing can do
    226227    // anything including possibly derefing this; one example of this is Radar 3266216.
    227     RefPtr<ResourceLoader> protector(this);
     228    Ref<ResourceLoader> protect(*this);
    228229
    229230    ASSERT(!m_reachedTerminalState);
     
    266267    // Protect this in this delegate method since the additional processing can do
    267268    // anything including possibly derefing this; one example of this is Radar 3266216.
    268     RefPtr<ResourceLoader> protector(this);
     269    Ref<ResourceLoader> protect(*this);
    269270
    270271    m_response = r;
     
    300301    // Protect this in this delegate method since the additional processing can do
    301302    // anything including possibly derefing this; one example of this is Radar 3266216.
    302     RefPtr<ResourceLoader> protector(this);
     303    Ref<ResourceLoader> protect(*this);
    303304    RefPtr<SharedBuffer> buffer = prpBuffer;
    304305
     
    355356    // Protect this in this delegate method since the additional processing can do
    356357    // anything including possibly derefing this; one example of this is Radar 3266216.
    357     RefPtr<ResourceLoader> protector(this);
     358    Ref<ResourceLoader> protect(*this);
    358359
    359360    cleanupForError(error);
     
    396397    // willCancel() and didFailToLoad() both call out to clients that might do
    397398    // something causing the last reference to this object to go away.
    398     RefPtr<ResourceLoader> protector(this);
     399    Ref<ResourceLoader> protect(*this);
    399400   
    400401    // If we re-enter cancel() from inside willCancel(), we want to pick up from where we left
     
    511512        return false;
    512513   
    513     RefPtr<ResourceLoader> protector(this);
     514    Ref<ResourceLoader> protect(*this);
    514515    return frameLoader()->client().shouldUseCredentialStorage(documentLoader(), identifier());
    515516}
     
    521522    // Protect this in this delegate method since the additional processing can do
    522523    // anything including possibly derefing this; one example of this is Radar 3266216.
    523     RefPtr<ResourceLoader> protector(this);
     524    Ref<ResourceLoader> protect(*this);
    524525
    525526    if (m_options.allowCredentials == AllowStoredCredentials) {
     
    543544    // Protect this in this delegate method since the additional processing can do
    544545    // anything including possibly derefing this; one example of this is Radar 3266216.
    545     RefPtr<ResourceLoader> protector(this);
     546    Ref<ResourceLoader> protect(*this);
    546547    frameLoader()->notifier()->didCancelAuthenticationChallenge(this, challenge);
    547548}
     
    550551bool ResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
    551552{
    552     RefPtr<ResourceLoader> protector(this);
     553    Ref<ResourceLoader> protect(*this);
    553554    return frameLoader()->client().canAuthenticateAgainstProtectionSpace(documentLoader(), identifier(), protectionSpace);
    554555}
  • trunk/Source/WebCore/loader/SubresourceLoader.cpp

    r153072 r154962  
    4040#include "PageActivityAssertionToken.h"
    4141#include "ResourceBuffer.h"
     42#include <wtf/Ref.h>
    4243#include <wtf/RefCountedLeakCounter.h>
    4344#include <wtf/StdLibExtras.h>
     
    124125    // Store the previous URL because the call to ResourceLoader::willSendRequest will modify it.
    125126    KURL previousURL = request().url();
    126     RefPtr<SubresourceLoader> protect(this);
     127    Ref<SubresourceLoader> protect(*this);
    127128
    128129    ASSERT(!newRequest.isNull());
     
    159160{
    160161    ASSERT(m_state == Initialized);
    161     RefPtr<SubresourceLoader> protect(this);
     162    Ref<SubresourceLoader> protect(*this);
    162163    m_resource->didSendData(bytesSent, totalBytesToBeSent);
    163164}
     
    170171    // Reference the object in this method since the additional processing can do
    171172    // anything including removing the last reference to this object; one example of this is 3266216.
    172     RefPtr<SubresourceLoader> protect(this);
     173    Ref<SubresourceLoader> protect(*this);
    173174
    174175    if (m_resource->resourceToRevalidate()) {
     
    241242    // Reference the object in this method since the additional processing can do
    242243    // anything including removing the last reference to this object; one example of this is 3266216.
    243     RefPtr<SubresourceLoader> protect(this);
     244    Ref<SubresourceLoader> protect(*this);
    244245    RefPtr<SharedBuffer> buffer = prpBuffer;
    245246   
     
    275276    LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().data());
    276277
    277     RefPtr<SubresourceLoader> protect(this);
     278    Ref<SubresourceLoader> protect(*this);
    278279    CachedResourceHandle<CachedResource> protectResource(m_resource);
    279280    m_state = Finishing;
     
    300301    LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data());
    301302
    302     RefPtr<SubresourceLoader> protect(this);
     303    Ref<SubresourceLoader> protect(*this);
    303304    CachedResourceHandle<CachedResource> protectResource(m_resource);
    304305    m_state = Finishing;
     
    324325    LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string().latin1().data());
    325326
    326     RefPtr<SubresourceLoader> protect(this);
     327    Ref<SubresourceLoader> protect(*this);
    327328    m_state = Finishing;
    328329    m_activityAssertion.clear();
  • trunk/Source/WebCore/loader/cf/SubresourceLoaderCF.cpp

    r133233 r154962  
    2626#include "SubresourceLoader.h"
    2727
     28#include <wtf/Ref.h>
     29
    2830namespace WebCore {
    2931
     
    3335    // Reference the object in this method since the additional processing can do
    3436    // anything including removing the last reference to this object; one example of this is 3266216.
    35     RefPtr<SubresourceLoader> protect(this);
     37    Ref<SubresourceLoader> protect(*this);
    3638
    3739    ResourceLoader::didReceiveDataArray(dataArray);
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r154715 r154962  
    106106#include <wtf/MainThread.h>
    107107#include <wtf/MathExtras.h>
     108#include <wtf/Ref.h>
    108109#include <wtf/text/Base64.h>
    109110#include <wtf/text/WTFString.h>
     
    17191720bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget)
    17201721{
    1721     RefPtr<EventTarget> protect = this;
     1722    Ref<EventTarget> protect(*this);
    17221723    RefPtr<Event> event = prpEvent;
    17231724
  • trunk/Source/WebCore/page/DOMWindowExtension.cpp

    r154449 r154962  
    3232#include "FrameLoader.h"
    3333#include "FrameLoaderClient.h"
     34#include <wtf/Ref.h>
    3435
    3536namespace WebCore {
     
    4849    // Calling out to the client might result in this DOMWindowExtension being destroyed
    4950    // while there is still work to do.
    50     RefPtr<DOMWindowExtension> protector = this;
     51    Ref<DOMWindowExtension> protect(*this);
    5152   
    5253    Frame* frame = this->frame();
     
    7475    // Calling out to the client might result in this DOMWindowExtension being destroyed
    7576    // while there is still work to do.
    76     RefPtr<DOMWindowExtension> protector = this;
    77    
     77    Ref<DOMWindowExtension> protect(*this);
     78
    7879    m_disconnectedFrame->loader().client().dispatchWillDestroyGlobalObjectForDOMWindowExtension(this);
    7980    m_disconnectedFrame = 0;
     
    8889    // Calling out to the client might result in this DOMWindowExtension being destroyed
    8990    // while there is still work to do.
    90     RefPtr<DOMWindowExtension> protector = this;
     91    Ref<DOMWindowExtension> protect(*this);
    9192
    9293    if (!m_wasDetached) {
     
    106107    // Calling out to the client might result in this DOMWindowExtension being destroyed
    107108    // while there is still work to do.
    108     RefPtr<DOMWindowExtension> protector = this;
     109    Ref<DOMWindowExtension> protect(*this);
    109110
    110111    Frame* frame = this->frame();
  • trunk/Source/WebCore/page/FocusController.cpp

    r154877 r154962  
    6262#include "htmlediting.h" // For firstPositionInOrBeforeNode
    6363#include <limits>
     64#include <wtf/Ref.h>
    6465
    6566namespace WebCore {
     
    632633    setFocusedFrame(newFocusedFrame);
    633634
    634     RefPtr<Element> protect(element);
     635    Ref<Element> protect(*element);
    635636    if (newDocument) {
    636637        bool successfullyFocused = newDocument->setFocusedElement(element, direction);
  • trunk/Source/WebCore/page/FrameView.cpp

    r154937 r154962  
    7979
    8080#include <wtf/CurrentTime.h>
     81#include <wtf/Ref.h>
    8182#include <wtf/TemporaryChange.h>
    8283
     
    11161117
    11171118    // Protect the view from being deleted during layout (in recalcStyle)
    1118     RefPtr<FrameView> protector(this);
     1119    Ref<FrameView> protect(*this);
    11191120
    11201121    // Every scroll that happens during layout is programmatic.
     
    11841185        // If there is only one ref to this view left, then its going to be destroyed as soon as we exit,
    11851186        // so there's no point to continuing to layout
    1186         if (protector->hasOneRef())
     1187        if (hasOneRef())
    11871188            return;
    11881189
     
    27602761    // layout() protects FrameView, but it still can get destroyed when updateWidgets()
    27612762    // is called through the post layout timer.
    2762     RefPtr<FrameView> protector(this);
     2763    Ref<FrameView> protect(*this);
    27632764    for (unsigned i = 0; i < maxUpdateWidgetsIterations; i++) {
    27642765        if (updateWidgets())
  • trunk/Source/WebCore/page/animation/AnimationBase.cpp

    r154877 r154962  
    4343#include <algorithm>
    4444#include <wtf/CurrentTime.h>
     45#include <wtf/Ref.h>
    4546
    4647using namespace std;
     
    454455    // and it ref counts this object, we will keep a ref to that instead. That way the AnimationBase
    455456    // can still access the resources of its CompositeAnimation as needed.
    456     RefPtr<AnimationBase> protector(this);
    457     RefPtr<CompositeAnimation> compProtector(m_compAnim);
     457    Ref<AnimationBase> protect(*this);
     458    Ref<CompositeAnimation> protectCompositeAnimation(*m_compAnim);
    458459   
    459460    // Check for start timeout
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp

    r131131 r154962  
    3131
    3232#include <wtf/CurrentTime.h>
     33#include <wtf/Ref.h>
    3334
    3435namespace WebCore {
     
    106107    // The call back can cause all our clients to be unregistered, so we need to protect
    107108    // against deletion until the end of the method.
    108     RefPtr<DisplayRefreshMonitor> protector(this);
     109    Ref<DisplayRefreshMonitor> protect(*this);
    109110   
    110111    Vector<DisplayRefreshMonitorClient*> clients;
  • trunk/Source/WebCore/platform/mac/WidgetMac.mm

    r153917 r154962  
    4141#import "WebCoreFrameView.h"
    4242#import "WebCoreView.h"
     43#import <wtf/Ref.h>
    4344#import <wtf/RetainPtr.h>
    4445
     
    171172    // Take a reference to this Widget, because sending messages to outerView can invoke arbitrary
    172173    // code, which can deref it.
    173     RefPtr<Widget> protectedThis(this);
     174    Ref<Widget> protect(*this);
    174175
    175176    NSRect visibleRect = [outerView visibleRect];
     
    213214    // Take a reference to this Widget, because sending messages to the views can invoke arbitrary
    214215    // code, which can deref it.
    215     RefPtr<Widget> protectedThis(this);
     216    Ref<Widget> protect(*this);
    216217
    217218    NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r148068 r154962  
    4747#include "SharedBuffer.h"
    4848#include <wtf/MainThread.h>
     49#include <wtf/Ref.h>
    4950
    5051namespace WebCore {
     
    246247        getSizeForNext();
    247248    else {
    248         RefPtr<BlobResourceHandle> protect(this); // getSizeForNext calls the client
     249        Ref<BlobResourceHandle> protect(*this); // getSizeForNext calls the client
    249250        for (size_t i = 0; i < m_blobData->items().size() && !m_aborted && !m_errorCode; ++i)
    250251            getSizeForNext();
     
    261262        // Start reading if in asynchronous mode.
    262263        if (m_async) {
    263             RefPtr<BlobResourceHandle> protect(this);
     264            Ref<BlobResourceHandle> protect(*this);
    264265            notifyResponse();
    265266            m_buffer.resize(bufferSize);
     
    346347{
    347348    ASSERT(!m_async);
    348     RefPtr<BlobResourceHandle> protect(this);
     349    Ref<BlobResourceHandle> protect(*this);
    349350
    350351    int offset = 0;
     
    468469{
    469470    ASSERT(m_async);
    470     RefPtr<BlobResourceHandle> protect(this);
     471    Ref<BlobResourceHandle> protect(*this);
    471472
    472473    long long bytesToRead = item.length - m_currentItemReadSize;
     
    520521{
    521522    ASSERT(m_async);
    522     RefPtr<BlobResourceHandle> protect(this);
     523    Ref<BlobResourceHandle> protect(*this);
    523524
    524525    m_totalRemainingSize -= bytesRead;
     
    550551{
    551552    ASSERT(m_async);
    552     RefPtr<BlobResourceHandle> protect(this);
     553    Ref<BlobResourceHandle> protect(*this);
    553554
    554555    // Notify the client.
     
    568569
    569570    if (m_errorCode) {
    570         RefPtr<BlobResourceHandle> protect(this);
     571        Ref<BlobResourceHandle> protect(*this);
    571572        notifyResponseOnError();
    572573        notifyFinish();
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp

    r149255 r154962  
    4848#include <sys/types.h>
    4949#include <wtf/HashMap.h>
     50#include <wtf/Ref.h>
    5051#include <wtf/Threading.h>
    5152#include <wtf/text/Base64.h>
     
    503504    }
    504505
    505     RefPtr<ResourceHandle> protect(this);
     506    Ref<ResourceHandle> protect(*this);
    506507    client()->willSendRequest(this, request, redirectResponse);
    507508
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r154314 r154962  
    5252#import "WebCoreSystemInterface.h"
    5353#import "WebCoreURLResponse.h"
     54#import <wtf/Ref.h>
    5455#import <wtf/SchedulePair.h>
    5556#import <wtf/text/Base64.h>
     
    390391        client()->willSendRequestAsync(this, request, redirectResponse);
    391392    } else {
    392         RefPtr<ResourceHandle> protect(this);
     393        Ref<ResourceHandle> protect(*this);
    393394        client()->willSendRequest(this, request, redirectResponse);
    394395
  • trunk/Source/WebCore/rendering/RenderWidget.cpp

    r154877 r154962  
    3434#include "RenderWidgetProtector.h"
    3535#include <wtf/StackStats.h>
     36#include <wtf/Ref.h>
    3637
    3738#if USE(ACCELERATED_COMPOSITING)
     
    154155
    155156    RenderWidgetProtector protector(this);
    156     RefPtr<Node> protectedNode(node());
     157    Ref<Node> protectNode(*node());
    157158    m_widget->setFrameRect(newFrame);
    158159
  • trunk/Source/WebCore/workers/WorkerScriptLoader.cpp

    r152080 r154962  
    4141#include "WorkerThreadableLoader.h"
    4242#include <wtf/OwnPtr.h>
     43#include <wtf/Ref.h>
    4344#include <wtf/RefPtr.h>
    4445
     
    9192
    9293    // During create, callbacks may happen which remove the last reference to this object.
    93     RefPtr<WorkerScriptLoader> protect(this);
     94    Ref<WorkerScriptLoader> protect(*this);
    9495    m_threadableLoader = ThreadableLoader::create(scriptExecutionContext, this, *request, options);
    9596}
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r154800 r154962  
    6363#include <runtime/JSLock.h>
    6464#include <runtime/Operations.h>
     65#include <wtf/Ref.h>
    6566#include <wtf/RefCountedLeakCounter.h>
    6667#include <wtf/StdLibExtras.h>
     
    823824{
    824825    // internalAbort() calls dropProtection(), which may release the last reference.
    825     RefPtr<XMLHttpRequest> protect(this);
     826    Ref<XMLHttpRequest> protect(*this);
    826827
    827828    bool sendFlag = m_loader;
     
    12421243{
    12431244    // internalAbort() calls dropProtection(), which may release the last reference.
    1244     RefPtr<XMLHttpRequest> protect(this);
     1245    Ref<XMLHttpRequest> protect(*this);
    12451246    internalAbort();
    12461247
  • trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp

    r154877 r154962  
    5151#include "TreeDepthLimit.h"
    5252#include "XMLErrors.h"
     53#include <wtf/Ref.h>
    5354#include <wtf/StringExtras.h>
    5455#include <wtf/Threading.h>
     
    257258
    258259    // JavaScript can detach this parser, make sure it's kept alive even if detached.
    259     RefPtr<XMLDocumentParser> protect(this);
     260    Ref<XMLDocumentParser> protect(*this);
    260261   
    261262    if (errorOccurred)
  • trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

    r154903 r154962  
    6262#include <libxml/parser.h>
    6363#include <libxml/parserInternals.h>
    64 #include <wtf/text/CString.h>
     64#include <wtf/Ref.h>
    6565#include <wtf/StringExtras.h>
    6666#include <wtf/Threading.h>
    6767#include <wtf/Vector.h>
     68#include <wtf/text/CString.h>
    6869#include <wtf/unicode/UTF8.h>
    6970
     
    685686        // JavaScript may cause the parser to detach during xmlParseChunk
    686687        // keep this alive until this function is done.
    687         RefPtr<XMLDocumentParser> protect(this);
     688        Ref<XMLDocumentParser> protect(*this);
    688689
    689690        switchToUTF16(context->context());
     
    884885    // JavaScript can detach the parser.  Make sure this is not released
    885886    // before the end of this method.
    886     RefPtr<XMLDocumentParser> protect(this);
     887    Ref<XMLDocumentParser> protect(*this);
    887888
    888889    exitText();
Note: See TracChangeset for help on using the changeset viewer.