Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: Source/WebKit/chromium/src/WebDOMEvent.cpp

Issue 15271012: Clean up WebDOMEvent ownership of WebCore::Event. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 class WebDOMEventPrivate : public WebCore::Event { 43 class WebDOMEventPrivate : public WebCore::Event {
44 }; 44 };
45 45
46 void WebDOMEvent::reset() 46 void WebDOMEvent::reset()
47 { 47 {
48 assign(0); 48 assign(0);
49 } 49 }
50 50
51 void WebDOMEvent::assign(const WebDOMEvent& other) 51 void WebDOMEvent::assign(const WebDOMEvent& other)
52 { 52 {
53 WebDOMEventPrivate* p = const_cast<WebDOMEventPrivate*>(other.m_private); 53 m_private = other.m_private;
54 if (p)
55 p->ref();
56 assign(p);
57 }
58
59 void WebDOMEvent::assign(WebDOMEventPrivate* p)
60 {
61 // p is already ref'd for us by the caller
62 if (m_private)
63 m_private->deref();
64 m_private = p;
65 } 54 }
66 55
67 WebDOMEvent::WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>& event) 56 WebDOMEvent::WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>& event)
68 : m_private(static_cast<WebDOMEventPrivate*>(event.leakRef())) 57 : m_private(event)
69 { 58 {
70 } 59 }
71 60
72 WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>() const 61 WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>() const
73 { 62 {
74 return static_cast<WebCore::Event*>(m_private); 63 return m_private;
dmichael (off chromium) 2013/05/20 21:58:44 This actually looks like a bug to me ^^^^ There's
75 } 64 }
76 65
77 WebString WebDOMEvent::type() const 66 WebString WebDOMEvent::type() const
78 { 67 {
79 ASSERT(m_private); 68 ASSERT(m_private);
80 return m_private->type(); 69 return m_private->type();
81 } 70 }
82 71
83 WebNode WebDOMEvent::target() const 72 WebNode WebDOMEvent::target() const
84 { 73 {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgre ssEvent); 195 return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgre ssEvent);
207 } 196 }
208 197
209 bool WebDOMEvent::isBeforeLoadEvent() const 198 bool WebDOMEvent::isBeforeLoadEvent() const
210 { 199 {
211 ASSERT(m_private); 200 ASSERT(m_private);
212 return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent); 201 return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent);
213 } 202 }
214 203
215 } // namespace WebKit 204 } // namespace WebKit
OLDNEW
« Source/WebKit/chromium/public/WebDOMEvent.h ('K') | « Source/WebKit/chromium/public/WebDOMEvent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698