source: webkit/trunk/JavaScriptCore/wtf/PassRefPtr.h@ 21064

Last change on this file since 21064 was 17405, checked in by darin, 19 years ago

JavaScriptCore:

Reviewed by Maciej.

  • renamed PassRefPtr::release to releaseRef to make it clearer that it's the counterpart of adoptRef, and to make it harder to confuse it with the safer-to-use RefPtr::release
  • kjs/identifier.cpp: (KJS::CStringTranslator::translate): (KJS::UCharBufferTranslator::translate):
  • kjs/ustring.cpp: (KJS::UString::Rep::create):
  • wtf/PassRefPtr.h: (WTF::PassRefPtr::PassRefPtr): (WTF::PassRefPtr::~PassRefPtr): (WTF::PassRefPtr::get): (WTF::PassRefPtr::releaseRef): (WTF::PassRefPtr::operator->): (WTF::PassRefPtr::operator=): (WTF::adoptRef): (WTF::static_pointer_cast): (WTF::const_pointer_cast):
  • wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::operator=):

WebCore:

Reviewed by Maciej.

  • eliminated the use of Objective-C for the policy decider machinery, obviating the need for WebPolicyDecider, WebCoreFrameLoaderAsDelegate, and WebCoreMainResourceLoaderAsPolicyDelegate
  • grouped the state related to policy decisions into a PolicyCheck class to simplify the FrameLoader logic
  • removed six methods from the bridge, reducing FrameLoader's use of the bridge to a single method
  • changed form state to always use HashMap instead of NSDictionary
  • moved the defersLoading flag from WebView to WebCore::Page and changed code to consistently call it defersLoading rather than defersCallbacks
  • updated for rename of PassRefPtr::release to releaseRef
  • replaced all uses of APPLE with appropriate PLATFORM defines
  • cleaned up kjs_binding.h a bit
  • cleaned up FrameMac.h a bit
  • loader/mac/WebPolicyDecider.h: Removed.
  • loader/mac/WebPolicyDecider.mm: Removed.
  • WebCore.xcodeproj/project.pbxproj: Updated for removal.
  • WebCore.exp:
  • bindings/js/kjs_binding.cpp: (KJS::ScriptInterpreter::ScriptInterpreter): (KJS::ScriptInterpreter::wasRunByUserGesture):
  • bindings/js/kjs_binding.h: (KJS::ScriptInterpreter::setCurrentEvent): (KJS::ScriptInterpreter::setInlineCode): (KJS::ScriptInterpreter::setProcessingTimerCallback): (KJS::ScriptInterpreter::getCurrentEvent): (KJS::cacheDOMObject): (KJS::DOMExceptionTranslator::DOMExceptionTranslator):
  • bridge/AXObjectCache.h:
  • bridge/mac/BrowserExtensionMac.mm: (WebCore::BrowserExtensionMac::createNewWindow):
  • bridge/mac/FrameMac.h:
  • bridge/mac/FrameMac.mm: (WebCore::FrameMac::loadRequest): (WebCore::FrameMac::submitForm): (WebCore::FrameMac::urlSelected): (WebCore::FrameMac::userAgent): (WebCore::FrameMac::passMouseDownEventToWidget): (WebCore::FrameMac::handleMouseMoveEvent):
  • bridge/mac/PageMac.mm: (WebCore::Page::Page):
  • bridge/mac/WebCoreEditCommand.mm:
  • bridge/mac/WebCoreFrameBridge.h:
  • bridge/mac/WebCoreFrameBridge.mm: (-[WebCoreFrameBridge dragOperationForDraggingInfo:]): (-[WebCoreFrameBridge syncLoadResourceWithMethod:URL:customHeaders:postData:finalURL:responseHeaders:statusCode:]):
  • css/CSSComputedStyleDeclaration.cpp: (WebCore::): (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
  • css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::cssText):
  • css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::):
  • css/CSSValueList.cpp: (WebCore::CSSValueList::append):
  • css/cssparser.cpp: (WebCore::CSSParser::parseValue):
  • css/cssparser.h:
  • css/cssstyleselector.cpp: (WebCore::CSSStyleSelector::applyProperty):
  • dom/Document.cpp: (WebCore::Document::Document): (WebCore::Document::updateSelection): (WebCore::Document::implicitClose): (WebCore::Document::setFocusNode):
  • dom/Document.h:
  • editing/ReplaceSelectionCommand.h:
  • html/HTMLParser.cpp: (WebCore::HTMLParser::handleResidualStyleCloseTagAcrossBlocks):
  • loader/mac/FrameLoader.h: (WebCore::PolicyCheck::request):
  • loader/mac/FrameLoader.mm: (WebCore::FrameLoader::~FrameLoader): (WebCore::FrameLoader::safeLoad): (WebCore::FrameLoader::load): (WebCore::FrameLoader::open): (WebCore::FrameLoader::stopLoading): (WebCore::setAllDefersLoading): (WebCore::FrameLoader::setDefersLoading): (WebCore::FrameLoader::willSendRequest): (WebCore::FrameLoader::receivedMainResourceError): (WebCore::FrameLoader::callContinueFragmentScrollAfterNavigationPolicy): (WebCore::FrameLoader::commitProvisionalLoad): (WebCore::FrameLoader::checkNavigationPolicy): (WebCore::FrameLoader::checkContentPolicy): (WebCore::FrameLoader::cancelContentPolicyCheck): (WebCore::FrameLoader::stopPolicyCheck): (WebCore::FrameLoader::checkNewWindowPolicy): (WebCore::FrameLoader::continueAfterNewWindowPolicy): (WebCore::FrameLoader::continueAfterNavigationPolicy): (WebCore::FrameLoader::continueAfterContentPolicy): (WebCore::FrameLoader::continueAfterWillSubmitForm): (WebCore::FrameLoader::callContinueLoadAfterNavigationPolicy): (WebCore::FrameLoader::continueLoadAfterNavigationPolicy): (WebCore::FrameLoader::closeDocument): (WebCore::FrameLoader::transitionToCommitted): (WebCore::FrameLoader::callContinueLoadAfterNewWindowPolicy): (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy): (WebCore::FrameLoader::post): (WebCore::FrameLoader::detachFromParent): (WebCore::FrameLoader::addExtraFieldsToRequest): (WebCore::PolicyCheck::PolicyCheck): (WebCore::PolicyCheck::clear): (WebCore::PolicyCheck::set): (WebCore::PolicyCheck::call): (WebCore::PolicyCheck::dropRequest): (WebCore::FrameLoaderClient::~FrameLoaderClient):
  • loader/mac/WebFormState.h:
  • loader/mac/WebFormState.mm:
  • loader/mac/WebFrameLoaderClient.h:
  • loader/mac/WebLoader.h: (WebCore::WebResourceLoader::defersLoading):
  • loader/mac/WebLoader.mm: (WebCore::WebResourceLoader::WebResourceLoader): (WebCore::WebResourceLoader::load): (WebCore::WebResourceLoader::setDefersLoading):
  • loader/mac/WebMainResourceLoader.h:
  • loader/mac/WebMainResourceLoader.mm: (WebCore::MainResourceLoader::MainResourceLoader): (WebCore::MainResourceLoader::releaseDelegate): (WebCore::MainResourceLoader::didCancel): (WebCore::MainResourceLoader::callContinueAfterNavigationPolicy): (WebCore::MainResourceLoader::continueAfterNavigationPolicy): (WebCore::MainResourceLoader::willSendRequest): (WebCore::MainResourceLoader::callContinueAfterContentPolicy): (WebCore::MainResourceLoader::continueAfterContentPolicy): (WebCore::MainResourceLoader::didReceiveResponse): (WebCore::MainResourceLoader::didReceiveData): (WebCore::MainResourceLoader::didFinishLoading): (WebCore::MainResourceLoader::didFail): (WebCore::MainResourceLoader::loadNow): (WebCore::MainResourceLoader::load): (WebCore::MainResourceLoader::setDefersLoading):
  • page/Frame.cpp: (WebCore::Frame::paint):
  • page/FrameView.cpp: (WebCore::FrameView::layout):
  • page/FrameView.h:
  • page/Page.cpp: (WebCore::Page::setDefersLoading):
  • page/Page.h: (WebCore::Page::defersLoading):
  • platform/DeprecatedString.h:
  • platform/DeprecatedStringList.h:
  • platform/FontFallbackList.h:
  • platform/PlatformKeyboardEvent.h:
  • platform/PlatformMouseEvent.h:
  • platform/PlatformWheelEvent.h:
  • platform/mac/ClipboardMac.h:
  • platform/mac/ClipboardMac.mm: (WebCore::ClipboardMac::setDragImage): (WebCore::ClipboardMac::dragNSImage): (WebCore::ClipboardMac::sourceOperation): (WebCore::ClipboardMac::destinationOperation):
  • rendering/RenderObject.cpp: (WebCore::RenderObject::setStyle):
  • rendering/break_lines.cpp: (WebCore::nextBreakablePosition):

WebKit:

Reviewed by Maciej.

  • eliminated the use of Objective-C for the policy decider machinery, obviating the need for WebPolicyDeciderMac
  • moved the defersLoading flag from WebView to WebCore::Page
  • removed unused copies of four methods that in the frame bridge; the actually-used copies are in the page bridge
  • updated for rename of PassRefPtr::release to releaseRef
  • WebView/WebPolicyDeciderMac.h: Removed.
  • WebView/WebPolicyDeciderMac.m: Removed.
  • WebKit.xcodeproj/project.pbxproj: Updated for removal.
  • Plugins/WebBaseNetscapePluginView.mm: (-[WebBaseNetscapePluginView sendEvent:]):
  • Plugins/WebNetscapePluginStream.mm:
  • WebCoreSupport/WebFrameBridge.mm:
  • WebCoreSupport/WebFrameLoaderClient.h:
  • WebCoreSupport/WebFrameLoaderClient.mm: (getWebView): (WebFrameLoaderClient::WebFrameLoaderClient): (WebFrameLoaderClient::willCloseDocument): (WebFrameLoaderClient::dispatchDecidePolicyForMIMEType): (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction): (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): (WebFrameLoaderClient::cancelPolicyCheck): (WebFrameLoaderClient::dispatchWillSubmitForm): (WebFrameLoaderClient::setDefersLoading): (WebFrameLoaderClient::setTitle): (WebFrameLoaderClient::deliverArchivedResourcesAfterDelay): (WebFrameLoaderClient::deliverArchivedResources): (WebFrameLoaderClient::setUpPolicyListener): (WebFrameLoaderClient::receivedPolicyDecison): (WebFrameLoaderClient::userAgent): (-[WebFramePolicyListener initWithWebCoreFrame:]): (-[WebFramePolicyListener invalidate]): (-[WebFramePolicyListener dealloc]): (-[WebFramePolicyListener finalize]): (-[WebFramePolicyListener receivedPolicyDecision:]): (-[WebFramePolicyListener ignore]): (-[WebFramePolicyListener download]): (-[WebFramePolicyListener use]): (-[WebFramePolicyListener continue]):
  • WebCoreSupport/WebPageBridge.mm: (-[WebPageBridge runModal]):
  • WebView/WebArchiver.m: (+[WebArchiver archiveSelectionInFrame:]):
  • WebView/WebFormDelegate.h:
  • WebView/WebFormDelegate.m: (+[WebFormDelegate _sharedWebFormDelegate]): (-[WebFormDelegate textFieldDidBeginEditing:inFrame:]): (-[WebFormDelegate textFieldDidEndEditing:inFrame:]): (-[WebFormDelegate textDidChangeInTextField:inFrame:]): (-[WebFormDelegate textDidChangeInTextArea:inFrame:]): (-[WebFormDelegate frame:sourceFrame:willSubmitForm:withValues:submissionListener:]):
  • WebView/WebFrame.mm: (-[WebFrame _loadURL:referrer:intoChild:]): (-[WebFrame _isFrameSet]):
  • WebView/WebFrameInternal.h:
  • WebView/WebFrameView.mm: (-[WebFrameView _shouldDrawBorder]):
  • WebView/WebHTMLView.m: (-[NSArray knowsPageRange:]):
  • WebView/WebView.mm: (-[WebView _formDelegate]):
  • WebView/WebViewInternal.h:
  • WebView/WebViewPrivate.h:
  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 2005, 2006 Apple Computer, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef WTF_PassRefPtr_h
24#define WTF_PassRefPtr_h
25
26namespace WTF {
27
28 template<typename T> class RefPtr;
29 template<typename T> class PassRefPtr;
30 template <typename T> PassRefPtr<T> adoptRef(T*);
31
32 template<typename T>
33 class PassRefPtr
34 {
35 public:
36 PassRefPtr() : m_ptr(0) {}
37 PassRefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
38 // It somewhat breaks the type system to allow transfer of ownership out of
39 // a const PassRefPtr. However, it makes it much easier to work with PassRefPtr
40 // temporaries, and we don't really have a need to use real const PassRefPtrs
41 // anyway.
42 PassRefPtr(const PassRefPtr& o) : m_ptr(o.releaseRef()) {}
43 template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { }
44
45 ~PassRefPtr() { if (T* ptr = m_ptr) ptr->deref(); }
46
47 template <class U>
48 PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
49
50 T* get() const { return m_ptr; }
51
52 T* releaseRef() const { T* tmp = m_ptr; m_ptr = 0; return tmp; }
53
54 T& operator*() const { return *m_ptr; }
55 T* operator->() const { return m_ptr; }
56
57 bool operator!() const { return !m_ptr; }
58
59 // This conversion operator allows implicit conversion to bool but not to other integer types.
60 typedef T* (PassRefPtr::*UnspecifiedBoolType)() const;
61 operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::get : 0; }
62
63 PassRefPtr& operator=(T*);
64 PassRefPtr& operator=(const PassRefPtr&);
65 template <typename U> PassRefPtr& operator=(const PassRefPtr<U>&);
66 template <typename U> PassRefPtr& operator=(const RefPtr<U>&);
67
68 friend PassRefPtr adoptRef<T>(T*);
69 private:
70 // adopting constructor
71 PassRefPtr(T* ptr, bool) : m_ptr(ptr) {}
72 mutable T* m_ptr;
73 };
74
75 template <typename T> template <typename U> inline PassRefPtr<T>& PassRefPtr<T>::operator=(const RefPtr<U>& o)
76 {
77 T* optr = o.get();
78 if (optr)
79 optr->ref();
80 T* ptr = m_ptr;
81 m_ptr = optr;
82 if (ptr)
83 ptr->deref();
84 return *this;
85 }
86
87 template <typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(T* optr)
88 {
89 if (optr)
90 optr->ref();
91 T* ptr = m_ptr;
92 m_ptr = optr;
93 if (ptr)
94 ptr->deref();
95 return *this;
96 }
97
98 template <typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(const PassRefPtr<T>& ref)
99 {
100 T* ptr = m_ptr;
101 m_ptr = ref.releaseRef();
102 if (ptr)
103 ptr->deref();
104 return *this;
105 }
106
107 template <typename T> template <typename U> inline PassRefPtr<T>& PassRefPtr<T>::operator=(const PassRefPtr<U>& ref)
108 {
109 T* ptr = m_ptr;
110 m_ptr = ref.releaseRef();
111 if (ptr)
112 ptr->deref();
113 return *this;
114 }
115
116 template <typename T, typename U> inline bool operator==(const PassRefPtr<T>& a, const PassRefPtr<U>& b)
117 {
118 return a.get() == b.get();
119 }
120
121 template <typename T, typename U> inline bool operator==(const PassRefPtr<T>& a, const RefPtr<U>& b)
122 {
123 return a.get() == b.get();
124 }
125
126 template <typename T, typename U> inline bool operator==(const RefPtr<T>& a, const PassRefPtr<U>& b)
127 {
128 return a.get() == b.get();
129 }
130
131 template <typename T, typename U> inline bool operator==(const PassRefPtr<T>& a, U* b)
132 {
133 return a.get() == b;
134 }
135
136 template <typename T, typename U> inline bool operator==(T* a, const PassRefPtr<U>& b)
137 {
138 return a == b.get();
139 }
140
141 template <typename T, typename U> inline bool operator!=(const PassRefPtr<T>& a, const PassRefPtr<U>& b)
142 {
143 return a.get() != b.get();
144 }
145
146 template <typename T, typename U> inline bool operator!=(const PassRefPtr<T>& a, const RefPtr<U>& b)
147 {
148 return a.get() != b.get();
149 }
150
151 template <typename T, typename U> inline bool operator!=(const RefPtr<T>& a, const PassRefPtr<U>& b)
152 {
153 return a.get() != b.get();
154 }
155
156 template <typename T, typename U> inline bool operator!=(const PassRefPtr<T>& a, U* b)
157 {
158 return a.get() != b;
159 }
160
161 template <typename T, typename U> inline bool operator!=(T* a, const PassRefPtr<U>& b)
162 {
163 return a != b.get();
164 }
165
166 template <typename T> inline PassRefPtr<T> adoptRef(T* p)
167 {
168 return PassRefPtr<T>(p, true);
169 }
170
171 template <typename T, typename U> inline PassRefPtr<T> static_pointer_cast(const PassRefPtr<U>& p)
172 {
173 return adoptRef(static_cast<T*>(p.releaseRef()));
174 }
175
176 template <typename T, typename U> inline PassRefPtr<T> const_pointer_cast(const PassRefPtr<U>& p)
177 {
178 return adoptRef(const_cast<T*>(p.releaseRef()));
179 }
180
181 template <typename T> inline T* getPtr(const PassRefPtr<T>& p)
182 {
183 return p.get();
184 }
185
186} // namespace WTF
187
188using WTF::PassRefPtr;
189using WTF::adoptRef;
190using WTF::static_pointer_cast;
191using WTF::const_pointer_cast;
192
193#endif // WTF_PassRefPtr_h
Note: See TracBrowser for help on using the repository browser.