Changeset 128921 in webkit
- Timestamp:
- Sep 18, 2012 12:26:13 PM (12 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/ChangeLog
r128858 r128921 1 2012-09-18 Yong Li <yoli@rim.com> 2 3 [BlackBerry] Popup page should reference the client with a weak pointer 4 https://bugs.webkit.org/show_bug.cgi?id=97028 5 6 Reviewed by Rob Buis. 7 8 RIM PR# 209847. 9 Internally reviewed by Mike Fenton. 10 11 Store the pointer in a ref-coutned shared object, and clear the pointer 12 when the client is going to be destroyed, so it won't be accessed by 13 the JS function afterwards. 14 15 * WebCoreSupport/PagePopupBlackBerry.cpp: 16 (WebCore::PagePopupBlackBerry::PagePopupBlackBerry): 17 (WebCore::PagePopupBlackBerry::~PagePopupBlackBerry): 18 (WebCore::PagePopupBlackBerry::init): 19 (WebCore::setValueAndClosePopupCallback): 20 (WebCore::popUpExtensionFinalize): 21 (WebCore::PagePopupBlackBerry::installDOMFunction): 22 (WebCore::PagePopupBlackBerry::closePopup): 23 * WebCoreSupport/PagePopupBlackBerry.h: 24 (PagePopupBlackBerry): 25 (SharedClientPointer): 26 (WebCore::PagePopupBlackBerry::SharedClientPointer::SharedClientPointer): 27 (WebCore::PagePopupBlackBerry::SharedClientPointer::clear): 28 (WebCore::PagePopupBlackBerry::SharedClientPointer::get): 29 1 30 2012-09-18 Arvid Nilsson <anilsson@rim.com> 2 31 -
trunk/Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerry.cpp
r128767 r128921 51 51 : m_webPagePrivate(webPage) 52 52 , m_client(adoptPtr(client)) 53 , m_sharedClientPointer(adoptRef(new PagePopupBlackBerry::SharedClientPointer(client))) 53 54 { 54 55 m_rect = IntRect(rect.x(), rect.y() - URL_BAR_HEIGHT, client->contentSize().width(), client->contentSize().height()); … … 57 58 PagePopupBlackBerry::~PagePopupBlackBerry() 58 59 { 60 ASSERT(!m_sharedClientPointer->get()); 59 61 } 60 62 … … 68 70 generateHTML(webpage); 69 71 70 installD omFunction(webpage->d->mainFrame());72 installDOMFunction(webpage->d->mainFrame()); 71 73 72 74 return true; … … 108 110 JSObjectRef popUpObject = JSValueToObject(context, 109 111 arguments[argumentCount - 1], 0); 110 PagePopupClient* client = 111 reinterpret_cast<PagePopupClient*>(JSObjectGetPrivate(popUpObject)); 112 PagePopupBlackBerry::SharedClientPointer* client = reinterpret_cast<PagePopupBlackBerry::SharedClientPointer*>(JSObjectGetPrivate(popUpObject)); 112 113 113 ASSERT(client); 114 client->setValueAndClosePopup(0, strArgs.data()); 114 // Check the weak pointer as the owner page may have destroyed the popup. 115 if (client->get()) 116 client->get()->setValueAndClosePopup(0, strArgs.data()); 115 117 116 118 return jsRetVal; … … 125 127 static void popUpExtensionFinalize(JSObjectRef object) 126 128 { 127 UNUSED_PARAM(object); 129 // Clear the reference. See installDOMFunction(). 130 PagePopupBlackBerry::SharedClientPointer* client = reinterpret_cast<PagePopupBlackBerry::SharedClientPointer*>(JSObjectGetPrivate(object)); 131 client->deref(); 128 132 } 129 133 … … 139 143 }; 140 144 141 void PagePopupBlackBerry::installD omFunction(Frame* frame)145 void PagePopupBlackBerry::installDOMFunction(Frame* frame) 142 146 { 143 147 JSDOMWindow* window = toJSDOMWindow(frame, mainThreadNormalWorld()); … … 166 170 167 171 JSObjectRef clientClassObject = JSObjectMake(context, clientClass, 0); 168 JSObjectSetPrivate(clientClassObject, reinterpret_cast<void*>(m_client.get())); 172 173 // Add a reference. See popUpExtensionFinalize. 174 m_sharedClientPointer->ref(); 175 JSObjectSetPrivate(clientClassObject, m_sharedClientPointer.get()); 169 176 170 177 String name("popUp"); … … 179 186 void PagePopupBlackBerry::closePopup() 180 187 { 188 // Prevent the popup page from accessing the client. 189 m_sharedClientPointer->clear(); 190 181 191 m_client->didClosePopup(); 182 192 m_webPagePrivate->client()->closePopupWebView(); -
trunk/Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerry.h
r126338 r128921 22 22 #include "IntRect.h" 23 23 #include "PagePopup.h" 24 #include <wtf/RefCounted.h> 25 #include <wtf/RefPtr.h> 24 26 25 27 … … 45 47 bool init(BlackBerry::WebKit::WebPage*); 46 48 void closePopup(); 47 void installDomFunction(Frame*);48 49 void setRect(); 49 void generateHTML(BlackBerry::WebKit::WebPage*); 50 51 class SharedClientPointer : public RefCounted<SharedClientPointer> { 52 public: 53 explicit SharedClientPointer(PagePopupClient* client) : m_client(client) { } 54 void clear() { m_client = 0; } 55 PagePopupClient* get() const { return m_client; } 56 private: 57 PagePopupClient* m_client; 58 }; 50 59 51 60 private: 61 void generateHTML(BlackBerry::WebKit::WebPage*); 62 void installDOMFunction(Frame*); 63 52 64 BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate; 53 65 OwnPtr<PagePopupClient> m_client; 66 RefPtr<SharedClientPointer> m_sharedClientPointer; 54 67 IntRect m_rect; 55 68 };
Note: See TracChangeset
for help on using the changeset viewer.