Changeset 89283 in webkit
- Timestamp:
- Jun 20, 2011 1:21:56 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r89281 r89283 1 2011-06-18 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Disallow assigning into PassOwnArrayPtr, PassOwnPtr and PassRefPtr 6 https://bugs.webkit.org/show_bug.cgi?id=62940 7 8 Remove clear() and all assignment operators except one which now has a COMPILE_ASSERT. 9 10 * wtf/PassOwnArrayPtr.h: 11 (WTF::PassOwnArrayPtr::operator=): 12 * wtf/PassOwnPtr.h: 13 (WTF::PassOwnPtr::operator=): 14 * wtf/PassRefPtr.h: 15 (WTF::PassRefPtr::operator=): 16 (WTF::NonNullPassRefPtr::operator=): 17 18 <<<<<<< .mine 19 2011-06-20 Anders Carlsson <andersca@apple.com> 20 21 Reviewed by Darin Adler. 22 23 Disallow assigning into PassOwnArrayPtr, PassOwnPtr and PassRefPtr 24 https://bugs.webkit.org/show_bug.cgi?id=62940 25 26 Remove clear() and all assignment operators except one which now has a COMPILE_ASSERT. 27 28 * wtf/PassOwnArrayPtr.h: 29 (WTF::PassOwnArrayPtr::operator=): 30 * wtf/PassOwnPtr.h: 31 (WTF::PassOwnPtr::operator=): 32 * wtf/PassRefPtr.h: 33 (WTF::PassRefPtr::operator=): 34 (WTF::NonNullPassRefPtr::operator=): 35 36 ======= 1 37 2011-06-20 Oliver Hunt <oliver@apple.com> 2 38 … … 13 49 (WTF::parseDateFromNullTerminatedCharacters): 14 50 51 >>>>>>> .r89282 15 52 2011-06-20 Juan C. Montemayor <jmont@apple.com> 16 53 -
trunk/Source/JavaScriptCore/wtf/PassOwnArrayPtr.h
r88988 r89283 55 55 PtrType get() const { return m_ptr; } 56 56 57 void clear();58 57 PtrType leakPtr() const WARN_UNUSED_RETURN; 59 58 … … 71 70 #endif 72 71 73 PassOwnArrayPtr& operator=(const PassOwnArrayPtr<T>&); 74 PassOwnArrayPtr& operator=(std::nullptr_t) { clear(); return *this; } 75 template<typename U> PassOwnArrayPtr& operator=(const PassOwnArrayPtr<U>&); 72 PassOwnArrayPtr& operator=(const PassOwnArrayPtr&) { COMPILE_ASSERT(!sizeof(T*), PassOwnArrayPtr_should_never_be_assigned_to); return *this; } 76 73 77 74 template<typename U> friend PassOwnArrayPtr<U> adoptArrayPtr(U*); … … 83 80 }; 84 81 85 template<typename T> inline void PassOwnArrayPtr<T>::clear()86 {87 PtrType ptr = m_ptr;88 m_ptr = 0;89 deleteOwnedArrayPtr(ptr);90 }91 92 82 template<typename T> inline typename PassOwnArrayPtr<T>::PtrType PassOwnArrayPtr<T>::leakPtr() const 93 83 { … … 95 85 m_ptr = 0; 96 86 return ptr; 97 }98 99 template<typename T> inline PassOwnArrayPtr<T>& PassOwnArrayPtr<T>::operator=(const PassOwnArrayPtr<T>& optr)100 {101 PtrType ptr = m_ptr;102 m_ptr = optr.leakPtr();103 ASSERT(!ptr || m_ptr != ptr);104 if (ptr)105 deleteOwnedArrayPtr(ptr);106 return *this;107 }108 109 template<typename T> template<typename U> inline PassOwnArrayPtr<T>& PassOwnArrayPtr<T>::operator=(const PassOwnArrayPtr<U>& optr)110 {111 PtrType ptr = m_ptr;112 m_ptr = optr.leakPtr();113 ASSERT(!ptr || m_ptr != ptr);114 if (ptr)115 deleteOwnedArrayPtr(ptr);116 return *this;117 87 } 118 88 -
trunk/Source/JavaScriptCore/wtf/PassOwnPtr.h
r88988 r89283 58 58 PtrType get() const { return m_ptr; } 59 59 60 void clear();61 60 PtrType leakPtr() const WARN_UNUSED_RETURN; 62 61 … … 70 69 operator UnspecifiedBoolType() const { return m_ptr ? &PassOwnPtr::m_ptr : 0; } 71 70 72 PassOwnPtr& operator=(const PassOwnPtr<T>&); 73 PassOwnPtr& operator=(std::nullptr_t) { clear(); return *this; } 74 template<typename U> PassOwnPtr& operator=(const PassOwnPtr<U>&); 71 PassOwnPtr& operator=(const PassOwnPtr&) { COMPILE_ASSERT(!sizeof(T*), PassOwnPtr_should_never_be_assigned_to); return *this; } 75 72 76 73 template<typename U> friend PassOwnPtr<U> adoptPtr(U*); … … 89 86 }; 90 87 91 template<typename T> inline void PassOwnPtr<T>::clear()92 {93 PtrType ptr = m_ptr;94 m_ptr = 0;95 deleteOwnedPtr(ptr);96 }97 98 88 template<typename T> inline typename PassOwnPtr<T>::PtrType PassOwnPtr<T>::leakPtr() const 99 89 { … … 101 91 m_ptr = 0; 102 92 return ptr; 103 }104 105 template<typename T> inline PassOwnPtr<T>& PassOwnPtr<T>::operator=(const PassOwnPtr<T>& optr)106 {107 PtrType ptr = m_ptr;108 m_ptr = optr.leakPtr();109 ASSERT(!ptr || m_ptr != ptr);110 if (ptr)111 deleteOwnedPtr(ptr);112 return *this;113 }114 115 template<typename T> template<typename U> inline PassOwnPtr<T>& PassOwnPtr<T>::operator=(const PassOwnPtr<U>& optr)116 {117 PtrType ptr = m_ptr;118 m_ptr = optr.leakPtr();119 ASSERT(!ptr || m_ptr != ptr);120 if (ptr)121 deleteOwnedPtr(ptr);122 return *this;123 93 } 124 94 -
trunk/Source/JavaScriptCore/wtf/PassRefPtr.h
r74695 r89283 78 78 T* get() const { return m_ptr; } 79 79 80 void clear();81 80 T* leakRef() const WARN_UNUSED_RETURN; 82 81 … … 90 89 operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; } 91 90 92 PassRefPtr& operator=(T*); 93 PassRefPtr& operator=(const PassRefPtr&); 94 #if !HAVE(NULLPTR) 95 PassRefPtr& operator=(std::nullptr_t) { clear(); return *this; } 96 #endif 97 template<typename U> PassRefPtr& operator=(const PassRefPtr<U>&); 98 template<typename U> PassRefPtr& operator=(const RefPtr<U>&); 91 PassRefPtr& operator=(const PassRefPtr&) { COMPILE_ASSERT(!sizeof(T*), PassRefPtr_should_never_be_assigned_to); return *this; } 99 92 100 93 friend PassRefPtr adoptRef<T>(T*); … … 156 149 T* get() const { return m_ptr; } 157 150 158 void clear();159 151 T* leakRef() const WARN_UNUSED_RETURN { T* tmp = m_ptr; m_ptr = 0; return tmp; } 160 152 161 153 T& operator*() const { return *m_ptr; } 162 154 T* operator->() const { return m_ptr; } 155 156 NonNullPassRefPtr& operator=(const NonNullPassRefPtr&) { COMPILE_ASSERT(!sizeof(T*), NonNullPassRefPtr_should_never_be_assigned_to); return *this; } 163 157 164 158 // FIXME: Remove releaseRef once we change all callers to call leakRef instead. … … 176 170 } 177 171 178 template<typename T> inline void PassRefPtr<T>::clear()179 {180 T* ptr = m_ptr;181 m_ptr = 0;182 derefIfNotNull(ptr);183 }184 185 172 template<typename T> inline T* PassRefPtr<T>::leakRef() const 186 173 { … … 190 177 } 191 178 192 template<typename T> template<typename U> inline PassRefPtr<T>& PassRefPtr<T>::operator=(const RefPtr<U>& o)193 {194 T* optr = o.get();195 refIfNotNull(optr);196 T* ptr = m_ptr;197 m_ptr = optr;198 derefIfNotNull(ptr);199 return *this;200 }201 202 template<typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(T* optr)203 {204 refIfNotNull(optr);205 T* ptr = m_ptr;206 m_ptr = optr;207 derefIfNotNull(ptr);208 return *this;209 }210 211 template<typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(const PassRefPtr<T>& ref)212 {213 T* ptr = m_ptr;214 m_ptr = ref.leakRef();215 derefIfNotNull(ptr);216 return *this;217 }218 219 template<typename T> template<typename U> inline PassRefPtr<T>& PassRefPtr<T>::operator=(const PassRefPtr<U>& ref)220 {221 T* ptr = m_ptr;222 m_ptr = ref.leakRef();223 derefIfNotNull(ptr);224 return *this;225 }226 227 179 template<typename T, typename U> inline bool operator==(const PassRefPtr<T>& a, const PassRefPtr<U>& b) 228 180 { … … 294 246 { 295 247 return p.get(); 296 }297 298 template<typename T> inline void NonNullPassRefPtr<T>::clear()299 {300 T* ptr = m_ptr;301 m_ptr = 0;302 derefIfNotNull(ptr);303 248 } 304 249 -
trunk/Source/WebCore/ChangeLog
r89273 r89283 1 2011-06-18 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Disallow assigning into PassOwnArrayPtr, PassOwnPtr and PassRefPtr 6 https://bugs.webkit.org/show_bug.cgi?id=62940 7 8 Make sure that we never assign into any already existing PassRefPtr. 9 10 * accessibility/AccessibilityMediaControls.cpp: 11 (WebCore::AccessibilityMediaControl::create): 12 Remove local PassRefPtr variable. 13 14 * dom/Document.cpp: 15 (WebCore::Document::setBody): 16 Rename the PassRefPtr parameter and create a RefPtr variable. 17 18 (WebCore::Document::setFocusedNode): 19 Ditto. 20 21 * editing/ApplyStyleCommand.cpp: 22 (WebCore::ApplyStyleCommand::removeInlineStyle): 23 There's no reason to use a PassRefPtr here. Use a RefPtr, and don't initialize it since it's implicitly initialized. 24 25 * editing/CompositeEditCommand.cpp: 26 (WebCore::CompositeEditCommand::prune): 27 Rename the PassRefPtr parameter and create a RefPtr variable. 28 29 * editing/ReplaceSelectionCommand.cpp: 30 (WebCore::ReplaceSelectionCommand::insertAsListItems): 31 Ditto. 32 33 * editing/htmlediting.cpp: 34 (WebCore::createTabSpanElement): 35 Ditto. 36 37 * html/canvas/CanvasRenderingContext2D.cpp: 38 (WebCore::CanvasRenderingContext2D::setStrokeStyle): 39 (WebCore::CanvasRenderingContext2D::setFillStyle): 40 Ditto. 41 42 * platform/network/mac/FormDataStreamMac.mm: 43 (WebCore::formFinalize): 44 Ditto. 45 46 (WebCore::setHTTPBody): 47 Use an OwnPtr instead of explicitly deleting the form variable. 48 49 <<<<<<< .mine 50 2011-06-20 Anders Carlsson <andersca@apple.com> 51 52 Reviewed by Darin Adler. 53 54 Disallow assigning into PassOwnArrayPtr, PassOwnPtr and PassRefPtr 55 https://bugs.webkit.org/show_bug.cgi?id=62940 56 57 Make sure that we never assign into any already existing PassRefPtr. 58 59 * accessibility/AccessibilityMediaControls.cpp: 60 (WebCore::AccessibilityMediaControl::create): 61 Remove local PassRefPtr variable. 62 63 * dom/Document.cpp: 64 (WebCore::Document::setBody): 65 Rename the PassRefPtr parameter and create a RefPtr variable. 66 67 (WebCore::Document::setFocusedNode): 68 Ditto. 69 70 * editing/ApplyStyleCommand.cpp: 71 (WebCore::ApplyStyleCommand::removeInlineStyle): 72 There's no reason to use a PassRefPtr here. Use a RefPtr, and don't initialize it since it's implicitly initialized. 73 74 * editing/CompositeEditCommand.cpp: 75 (WebCore::CompositeEditCommand::prune): 76 Rename the PassRefPtr parameter and create a RefPtr variable. 77 78 * editing/ReplaceSelectionCommand.cpp: 79 (WebCore::ReplaceSelectionCommand::insertAsListItems): 80 Ditto. 81 82 * editing/htmlediting.cpp: 83 (WebCore::createTabSpanElement): 84 Ditto. 85 86 * html/canvas/CanvasRenderingContext2D.cpp: 87 (WebCore::CanvasRenderingContext2D::setStrokeStyle): 88 (WebCore::CanvasRenderingContext2D::setFillStyle): 89 Ditto. 90 91 * platform/network/mac/FormDataStreamMac.mm: 92 (WebCore::formFinalize): 93 Ditto. 94 95 (WebCore::setHTTPBody): 96 Use an OwnPtr instead of explicitly deleting the form variable. 97 98 ======= 1 99 2011-06-20 Alex Milowski <alex@milowski.com> 2 100 … … 71 169 (-[WebWindowFadeAnimation initWithDuration:window:initialAlpha:finalAlpha:]): 72 170 171 >>>>>>> .r89282 73 172 2011-06-20 Mark Pilgrim <pilgrim@chromium.org> 74 173 -
trunk/Source/WebCore/accessibility/AccessibilityMediaControls.cpp
r57093 r89283 64 64 controlType = static_cast<MediaControlElement*>(node)->displayType(); 65 65 66 PassRefPtr<AccessibilityObject> obj;67 66 switch (controlType) { 68 67 case MediaSlider: 69 obj = AccessibilityMediaTimeline::create(renderer); 70 break; 68 return AccessibilityMediaTimeline::create(renderer); 71 69 72 70 case MediaCurrentTimeDisplay: 73 71 case MediaTimeRemainingDisplay: 74 obj = AccessibilityMediaTimeDisplay::create(renderer); 75 break; 72 return AccessibilityMediaTimeDisplay::create(renderer); 76 73 77 74 case MediaControlsPanel: 78 obj = AccessibilityMediaControlsContainer::create(renderer); 79 break; 75 return AccessibilityMediaControlsContainer::create(renderer); 80 76 81 77 default: 82 obj = adoptRef(new AccessibilityMediaControl(renderer)); 83 break; 78 return adoptRef(new AccessibilityMediaControl(renderer)); 84 79 } 85 86 return obj;87 80 } 88 81 -
trunk/Source/WebCore/dom/Document.cpp
r89212 r89283 2014 2014 } 2015 2015 2016 void Document::setBody(PassRefPtr<HTMLElement> newBody, ExceptionCode& ec) 2017 { 2016 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionCode& ec) 2017 { 2018 RefPtr<HTMLElement> newBody = prpNewBody; 2019 2018 2020 if (!newBody || !documentElement() || !newBody->hasTagName(bodyTag)) { 2019 2021 ec = HIERARCHY_REQUEST_ERR; … … 2032 2034 HTMLElement* b = body(); 2033 2035 if (!b) 2034 documentElement()->appendChild(newBody , ec);2036 documentElement()->appendChild(newBody.release(), ec); 2035 2037 else 2036 documentElement()->replaceChild(newBody , b, ec);2038 documentElement()->replaceChild(newBody.release(), b, ec); 2037 2039 } 2038 2040 … … 3069 3071 #endif 3070 3072 3071 bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) 3072 { 3073 bool Document::setFocusedNode(PassRefPtr<Node> prpNewFocusedNode) 3074 { 3075 RefPtr<Node> newFocusedNode = prpNewFocusedNode; 3076 3073 3077 // Make sure newFocusedNode is actually in this document 3074 3078 if (newFocusedNode && (newFocusedNode->document() != this)) … … 3143 3147 } 3144 3148 // Set focus on the new node 3145 m_focusedNode = newFocusedNode .get();3149 m_focusedNode = newFocusedNode; 3146 3150 3147 3151 // Dispatch the focus event and let the node do any other focus related activities (important for text fields) -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r87952 r89283 1059 1059 RefPtr<Node> next = elem->traverseNextNode(); 1060 1060 RefPtr<EditingStyle> styleToPushDown; 1061 PassRefPtr<Node> childNode = 0;1061 RefPtr<Node> childNode; 1062 1062 if (isStyledInlineElementToRemove(elem.get())) { 1063 1063 styleToPushDown = EditingStyle::create(); -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r89224 r89283 248 248 } 249 249 250 void CompositeEditCommand::prune(PassRefPtr<Node> node) 251 { 250 void CompositeEditCommand::prune(PassRefPtr<Node> prpNode) 251 { 252 RefPtr<Node> node = prpNode; 253 252 254 while (node) { 253 255 // If you change this rule you may have to add an updateLayout() here. -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r87937 r89283 1236 1236 // If the user is inserting a list into an existing list, instead of nesting the list, 1237 1237 // we put the list items into the existing list. 1238 Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<Node> listElement, Node* insertionBlock, const Position& insertPos) 1239 { 1238 Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<Node> prpListElement, Node* insertionBlock, const Position& insertPos) 1239 { 1240 RefPtr<Node> listElement = prpListElement; 1241 1240 1242 while (listElement->hasChildNodes() && isListElement(listElement->firstChild()) && listElement->childNodeCount() == 1) 1241 1243 listElement = listElement->firstChild(); -
trunk/Source/WebCore/editing/htmlediting.cpp
r88476 r89283 883 883 } 884 884 885 PassRefPtr<Element> createTabSpanElement(Document* document, PassRefPtr<Node> tabTextNode) 886 { 885 PassRefPtr<Element> createTabSpanElement(Document* document, PassRefPtr<Node> prpTabTextNode) 886 { 887 RefPtr<Node> tabTextNode = prpTabTextNode; 888 887 889 // Make the span to hold the tab. 888 890 RefPtr<Element> spanElement = document->createElement(spanTag, false); … … 895 897 896 898 ExceptionCode ec = 0; 897 spanElement->appendChild(tabTextNode , ec);899 spanElement->appendChild(tabTextNode.release(), ec); 898 900 ASSERT(ec == 0); 899 901 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r88896 r89283 367 367 } 368 368 369 void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr<CanvasStyle> style) 370 { 369 void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr<CanvasStyle> prpStyle) 370 { 371 RefPtr<CanvasStyle> style = prpStyle; 372 371 373 if (!style) 372 374 return; … … 383 385 checkOrigin(style->canvasPattern()); 384 386 385 state().m_strokeStyle = style ;387 state().m_strokeStyle = style.release(); 386 388 GraphicsContext* c = drawingContext(); 387 389 if (!c) … … 396 398 } 397 399 398 void CanvasRenderingContext2D::setFillStyle(PassRefPtr<CanvasStyle> style) 399 { 400 void CanvasRenderingContext2D::setFillStyle(PassRefPtr<CanvasStyle> prpStyle) 401 { 402 RefPtr<CanvasStyle> style = prpStyle; 403 400 404 if (!style) 401 405 return; … … 412 416 checkOrigin(style->canvasPattern()); 413 417 414 state().m_fillStyle = style ;418 state().m_fillStyle = style.release(); 415 419 GraphicsContext* c = drawingContext(); 416 420 if (!c) -
trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm
r81452 r89283 255 255 static void formFinalize(CFReadStreamRef stream, void* context) 256 256 { 257 FormStreamFields* form = static_cast<FormStreamFields*>(context);257 OwnPtr<FormStreamFields> form = adoptPtr(static_cast<FormStreamFields*>(context)); 258 258 259 259 getStreamFormDataMap().remove(stream); 260 260 261 closeCurrentStream(form); 262 delete form; 261 closeCurrentStream(form.get()); 263 262 } 264 263 … … 384 383 } 385 384 386 void setHTTPBody(NSMutableURLRequest *request, PassRefPtr<FormData> formData) 387 { 385 void setHTTPBody(NSMutableURLRequest *request, PassRefPtr<FormData> prpFormData) 386 { 387 RefPtr<FormData> formData = prpFormData; 388 388 389 if (!formData) 389 390 return; … … 440 441 } 441 442 } 442 formData = newFormData ;443 formData = newFormData.release(); 443 444 count = formData->elements().size(); 444 445 } … … 471 472 472 473 // Pass the length along with the formData so it does not have to be recomputed. 473 FormContext formContext = { formData.release Ref(), length };474 FormContext formContext = { formData.release().leakRef(), length }; 474 475 475 476 RetainPtr<CFReadStreamRef> stream(AdoptCF, wkCreateCustomCFReadStream(formCreate, formFinalize,
Note: See TracChangeset
for help on using the changeset viewer.