Changeset 150756 in webkit
- Timestamp:
- May 27, 2013 8:35:15 AM (11 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
- 10 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r150670 r150756 1 2013-05-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [BlackBerry] Move PagePopup implementation to WebKitSupport 4 https://bugs.webkit.org/show_bug.cgi?id=116824 5 6 Reviewed by Rob Buis. 7 8 * PlatformBlackBerry.cmake: Update new file paths and names. 9 1 10 2013-05-24 Brent Fulgham <bfulgham@apple.com> 2 11 -
trunk/Source/WebKit/PlatformBlackBerry.cmake
r150434 r150756 102 102 blackberry/WebCoreSupport/NetworkInfoClientBlackBerry.cpp 103 103 blackberry/WebCoreSupport/NotificationClientBlackBerry.cpp 104 blackberry/WebCoreSupport/PagePopupBlackBerry.cpp105 blackberry/WebCoreSupport/PagePopupBlackBerryClient.cpp106 104 blackberry/WebCoreSupport/PlatformStrategiesBlackBerry.cpp 107 105 blackberry/WebCoreSupport/NavigatorContentUtilsClientBlackBerry.cpp 108 blackberry/WebCoreSupport/SelectPopupClient.cpp109 106 blackberry/WebCoreSupport/SuggestionBoxHandler.cpp 110 107 blackberry/WebCoreSupport/SuggestionBoxElement.cpp 111 108 blackberry/WebCoreSupport/VibrationClientBlackBerry.cpp 112 blackberry/WebCoreSupport/DatePickerClient.cpp113 blackberry/WebCoreSupport/ColorPickerClient.cpp114 109 blackberry/WebKitSupport/AboutData.cpp 115 110 blackberry/WebKitSupport/BackingStoreTile.cpp 116 111 blackberry/WebKitSupport/BackingStoreClient.cpp 117 112 blackberry/WebKitSupport/BackingStoreVisualizationViewportAccessor.cpp 113 blackberry/WebKitSupport/ColorPickerClient.cpp 114 blackberry/WebKitSupport/DatePickerClient.cpp 118 115 blackberry/WebKitSupport/DefaultTapHighlight.cpp 119 116 blackberry/WebKitSupport/DOMSupport.cpp … … 124 121 blackberry/WebKitSupport/InspectorOverlayBlackBerry.cpp 125 122 blackberry/WebKitSupport/NotificationManager.cpp 123 blackberry/WebKitSupport/PagePopup.cpp 124 blackberry/WebKitSupport/PagePopupClient.cpp 126 125 blackberry/WebKitSupport/ProximityDetector.cpp 127 126 blackberry/WebKitSupport/RenderQueue.cpp 127 blackberry/WebKitSupport/SelectPopupClient.cpp 128 128 blackberry/WebKitSupport/SelectionHandler.cpp 129 129 blackberry/WebKitSupport/SelectionOverlay.cpp -
trunk/Source/WebKit/blackberry/Api/WebPage.cpp
r150735 r150756 101 101 #include "PageCache.h" 102 102 #include "PageGroup.h" 103 #include "PagePopup BlackBerry.h"104 #include "PagePopup BlackBerryClient.h"103 #include "PagePopup.h" 104 #include "PagePopupClient.h" 105 105 #include "PlatformTouchEvent.h" 106 106 #include "PlatformWheelEvent.h" … … 417 417 , m_updateDelegatedOverlaysDispatched(false) 418 418 , m_deferredTasksTimer(this, &WebPagePrivate::deferredTasksTimerFired) 419 , m_ selectPopup(0)419 , m_pagePopup(0) 420 420 , m_autofillManager(AutofillManager::create(this)) 421 421 , m_documentStyleRecalcPostponed(false) … … 4942 4942 void WebPage::initPopupWebView(BlackBerry::WebKit::WebPage* webPage) 4943 4943 { 4944 d->m_ selectPopup->init(webPage);4944 d->m_pagePopup->initialize(webPage); 4945 4945 } 4946 4946 … … 6063 6063 } 6064 6064 6065 bool WebPagePrivate::openPagePopup(PagePopup BlackBerryClient* popupClient, const WebCore::IntRect& originBoundsInRootView)6065 bool WebPagePrivate::openPagePopup(PagePopupClient* popupClient, const WebCore::IntRect& originBoundsInRootView) 6066 6066 { 6067 6067 closePagePopup(); 6068 m_ selectPopup = new PagePopupBlackBerry(this, popupClient);6068 m_pagePopup = PagePopup::create(this, popupClient); 6069 6069 6070 6070 WebCore::IntRect popupRect = m_page->chrome().client()->rootViewToScreen(originBoundsInRootView); … … 6080 6080 void WebPagePrivate::closePagePopup() 6081 6081 { 6082 if (!m_ selectPopup)6083 return; 6084 6085 m_ selectPopup->closePopup();6082 if (!m_pagePopup) 6083 return; 6084 6085 m_pagePopup->close(); 6086 6086 m_client->closePopupWebView(); 6087 delete m_selectPopup; 6088 m_selectPopup = 0; 6087 m_pagePopup = 0; 6089 6088 } 6090 6089 6091 6090 bool WebPagePrivate::hasOpenedPopup() const 6092 6091 { 6093 return m_ selectPopup;6092 return m_pagePopup; 6094 6093 } 6095 6094 -
trunk/Source/WebKit/blackberry/Api/WebPage.h
r150434 r150756 62 62 class BackingStorePrivate; 63 63 class InRegionScroller; 64 class PagePopup BlackBerry;64 class PagePopup; 65 65 class RenderQueue; 66 66 class WebCookieJar; … … 390 390 friend class WebKit::BackingStoreClient; 391 391 friend class WebKit::BackingStorePrivate; 392 friend class WebKit::PagePopup BlackBerry;392 friend class WebKit::PagePopup; 393 393 friend class WebKit::RenderQueue; 394 394 friend class WebKit::WebPageCompositor; -
trunk/Source/WebKit/blackberry/Api/WebPage_p.h
r150434 r150756 80 80 class InPageSearchManager; 81 81 class InputHandler; 82 class PagePopup BlackBerry;83 class PagePopup BlackBerryClient;82 class PagePopup; 83 class PagePopupClient; 84 84 class SelectionHandler; 85 85 class TouchEventHandler; … … 414 414 BackingStoreClient* backingStoreClient() const; 415 415 416 bool openPagePopup(PagePopup BlackBerryClient*, const WebCore::IntRect& originBoundsInRootView);416 bool openPagePopup(PagePopupClient*, const WebCore::IntRect& originBoundsInRootView); 417 417 void closePagePopup(); 418 418 bool hasOpenedPopup() const; … … 639 639 640 640 // The popup that opened in this webpage 641 PagePopupBlackBerry* m_selectPopup;641 RefPtr<PagePopup> m_pagePopup; 642 642 643 643 RefPtr<WebCore::AutofillManager> m_autofillManager; -
trunk/Source/WebKit/blackberry/ChangeLog
r150735 r150756 1 2013-05-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [BlackBerry] Move PagePopup implementation to WebKitSupport 4 https://bugs.webkit.org/show_bug.cgi?id=116824 5 6 Reviewed by Rob Buis. 7 8 After r150434 PagePopup implementation in BlackBerry port is 9 independent from WebCore. The classes are now in the 10 BlackBerry::WebKit namespace so they can be moved from 11 WebCoresupport to WebKitSupport and renamed to remove the 12 BlackBerry suffix which is now redundant. Also, now that the 13 implementation is not shared, it can be simplified a bit more. 14 15 * Api/WebPage.cpp: 16 (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate): Update to 17 API changes. 18 (BlackBerry::WebKit::WebPage::initPopupWebView): Ditto. 19 (BlackBerry::WebKit::WebPagePrivate::openPagePopup): Ditto. 20 (BlackBerry::WebKit::WebPagePrivate::closePagePopup): Ditto. 21 (BlackBerry::WebKit::WebPagePrivate::hasOpenedPopup): Ditto. 22 * Api/WebPage.h: 23 (WebKit): Ditto. 24 * Api/WebPage_p.h: 25 (WebKit): Ditto. 26 (WebPagePrivate): Rename m_selectPopup as m_pagePopup, since it 27 can also point to a color picker or date picker page popup. Also 28 use RefPtr instead of raw pointer. 29 * WebKitSupport/ColorPickerClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/ColorPickerClient.cpp. 30 (BlackBerry::WebKit::ColorPickerClient::ColorPickerClient): 31 (BlackBerry::WebKit::ColorPickerClient::generateHTML): 32 (BlackBerry::WebKit::ColorPickerClient::setValueAndClosePopup): 33 Return early if popup has been closed already. 34 (BlackBerry::WebKit::ColorPickerClient::didClosePopup): 35 * WebKitSupport/ColorPickerClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/ColorPickerClient.h. 36 * WebKitSupport/DatePickerClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.cpp. 37 (BlackBerry::WebKit::DatePickerClient::DatePickerClient): 38 (BlackBerry::WebKit::DatePickerClient::~DatePickerClient): 39 (BlackBerry::WebKit::DatePickerClient::generateHTML): 40 (BlackBerry::WebKit::DatePickerClient::setValueAndClosePopup): 41 Return early if popup has been closed already. 42 (BlackBerry::WebKit::DatePickerClient::didClosePopup): 43 (BlackBerry::WebKit::DatePickerClient::generateDateLabels): 44 * WebKitSupport/DatePickerClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.h. 45 * WebKitSupport/PagePopup.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerry.cpp. 46 (BlackBerry::WebKit::PagePopup::PagePopup): 47 (BlackBerry::WebKit::PagePopup::~PagePopup): 48 (BlackBerry::WebKit::PagePopup::initialize): Renamed as initialize 49 and made void, since it always returned true and the callers 50 ignored the return value. 51 (BlackBerry::WebKit::PagePopup::writeDocument): Renamed from 52 generateHTML for consistency with PagePopupClient::writeDocument() 53 and to avoid confusion with generateHTML method in the clients 54 that create the HTML contents but they don't write the document. 55 (BlackBerry::WebKit::PagePopup::setValueAndClosePopupCallback): 56 Make it static member of PagePopup since the JS object now holds a 57 reference of PagePopup instance as private data. 58 (BlackBerry::WebKit::popUpExtensionInitialize): Take a reference 59 of the PagePopup instance saved as private data of the JS object. 60 (BlackBerry::WebKit::popUpExtensionFinalize): Unref the PagePopup 61 instance saved as private data of the JS object. 62 (BlackBerry::WebKit::PagePopup::installDOMFunction): Instead of 63 saving the client as private data of the JS object using a wrapper 64 refcounted object, save the PagePopup instance that is now 65 refcounted and access the client from the PagePopup instance in 66 the callback. 67 (BlackBerry::WebKit::PagePopup::close): Renamed from closePagePopup 68 since PagePopup::closePagePopup was a bit redundant. 69 * WebKitSupport/PagePopup.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerry.h. 70 (BlackBerry::WebKit::PagePopup::create): Static member to create 71 instances of PagePopup now that it's refcounted. 72 * WebKitSupport/PagePopupClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerryClient.cpp. 73 (BlackBerry::WebKit::PagePopupClient::PagePopupClient): 74 (BlackBerry::WebKit::PagePopupClient::closePopup): 75 (BlackBerry::WebKit::PagePopupClient::didClosePopup): 76 (BlackBerry::WebKit::PagePopupClient::contentSize): 77 (BlackBerry::WebKit::PagePopupClient::writeDocument): 78 * WebKitSupport/PagePopupClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerryClient.h. 79 * WebKitSupport/SelectPopupClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.cpp. 80 (BlackBerry::WebKit::SelectPopupClient::SelectPopupClient): 81 (BlackBerry::WebKit::SelectPopupClient::~SelectPopupClient): 82 (BlackBerry::WebKit::SelectPopupClient::generateHTML): 83 (BlackBerry::WebKit::SelectPopupClient::setValueAndClosePopup): 84 Return early if popup has been closed already. 85 (BlackBerry::WebKit::SelectPopupClient::didClosePopup): 86 (BlackBerry::WebKit::SelectPopupClient::notifySelectionChange): 87 * WebKitSupport/SelectPopupClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.h. 88 1 89 2013-05-26 Jakob Petsovits <jpetsovits@blackberry.com> 2 90 -
trunk/Source/WebKit/blackberry/WebKitSupport/ColorPickerClient.cpp
r150755 r150756 36 36 DEFINE_STATIC_LOCAL(BlackBerry::Platform::LocalizeResource, s_resource, ()); 37 37 38 ColorPickerClient::ColorPickerClient(const BlackBerry::Platform::String& value, BlackBerry::WebKit::WebPagePrivate* webPage, WebCore::HTMLInputElement* element)39 : PagePopup BlackBerryClient(webPage)38 ColorPickerClient::ColorPickerClient(const BlackBerry::Platform::String& value, WebPagePrivate* webPagePrivate, WebCore::HTMLInputElement* element) 39 : PagePopupClient(webPagePrivate) 40 40 , m_element(element) 41 41 { … … 80 80 } 81 81 82 void ColorPickerClient::setValueAndClosePopup( int,const String& value)82 void ColorPickerClient::setValueAndClosePopup(const String& value) 83 83 { 84 ASSERT(m_element); 84 // Popup closed. 85 if (!m_element) 86 return; 85 87 86 88 static const char* cancelValue = "-1"; … … 92 94 void ColorPickerClient::didClosePopup() 93 95 { 94 PagePopup BlackBerryClient::didClosePopup();96 PagePopupClient::didClosePopup(); 95 97 m_element = 0; 96 98 } -
trunk/Source/WebKit/blackberry/WebKitSupport/ColorPickerClient.h
r150755 r150756 20 20 #define ColorPickerClient_h 21 21 22 #include "PagePopup BlackBerryClient.h"22 #include "PagePopupClient.h" 23 23 #include <BlackBerryPlatformInputEvents.h> 24 24 … … 34 34 namespace WebKit { 35 35 36 class ColorPickerClient : public PagePopup BlackBerryClient {36 class ColorPickerClient : public PagePopupClient { 37 37 public: 38 ColorPickerClient(const BlackBerry::Platform::String& value, BlackBerry::WebKit::WebPagePrivate*, WebCore::HTMLInputElement*);38 ColorPickerClient(const BlackBerry::Platform::String& value, WebPagePrivate*, WebCore::HTMLInputElement*); 39 39 40 void setValueAndClosePopup( int,const String&);40 void setValueAndClosePopup(const String&); 41 41 void didClosePopup(); 42 42 -
trunk/Source/WebKit/blackberry/WebKitSupport/DatePickerClient.cpp
r150755 r150756 40 40 DEFINE_STATIC_LOCAL(BlackBerry::Platform::LocalizeResource, s_resource, ()); 41 41 42 DatePickerClient::DatePickerClient(BlackBerry::Platform::BlackBerryInputType type, const BlackBerry::Platform::String& value, const BlackBerry::Platform::String& min, const BlackBerry::Platform::String& max, double step, BlackBerry::WebKit::WebPagePrivate* webPage, WebCore::HTMLInputElement* element)43 : PagePopup BlackBerryClient(webPage)42 DatePickerClient::DatePickerClient(BlackBerry::Platform::BlackBerryInputType type, const BlackBerry::Platform::String& value, const BlackBerry::Platform::String& min, const BlackBerry::Platform::String& max, double step, WebPagePrivate* webPagePrivate, WebCore::HTMLInputElement* element) 43 : PagePopupClient(webPagePrivate) 44 44 , m_type(type) 45 45 , m_element(element) … … 58 58 source.appendLiteral("<style>\n"); 59 59 // Include CSS file. 60 source.append(popupControlBlackBerryCss, 61 sizeof(popupControlBlackBerryCss)); 60 source.append(popupControlBlackBerryCss, sizeof(popupControlBlackBerryCss)); 62 61 source.appendLiteral("</style>\n<style>"); 63 source.append(timeControlBlackBerryCss, 64 sizeof(timeControlBlackBerryCss)); 62 source.append(timeControlBlackBerryCss, sizeof(timeControlBlackBerryCss)); 65 63 source.appendLiteral("</style></head><body>\n"); 66 64 source.appendLiteral("<script>\n"); … … 129 127 source.appendLiteral(" window.removeEventListener('load', showIt); }); \n"); 130 128 source.append(timeControlBlackBerryJs, sizeof(timeControlBlackBerryJs)); 131 source.appendLiteral("</script>\n" 132 "</body> </html>\n"); 129 source.appendLiteral("</script>\n</body> </html>\n"); 133 130 m_source = source.toString(); 134 131 } 135 132 136 void DatePickerClient::setValueAndClosePopup(int, const String& value) 137 { 138 // Return -1 if user cancel the selection. 139 ASSERT(m_element); 133 void DatePickerClient::setValueAndClosePopup(const String& value) 134 { 135 // Popup closed. 136 if (!m_element) 137 return; 140 138 141 139 // We hide caret when we select date input field, restore it when we close date picker. 142 140 m_element->document()->frame()->selection()->setCaretVisible(true); 143 141 142 // Return -1 if user cancel the selection. 144 143 if (value != "-1") 145 144 m_element->setValue(value, DispatchChangeEvent); … … 149 148 void DatePickerClient::didClosePopup() 150 149 { 151 PagePopup BlackBerryClient::didClosePopup();150 PagePopupClient::didClosePopup(); 152 151 m_element = 0; 153 152 } -
trunk/Source/WebKit/blackberry/WebKitSupport/DatePickerClient.h
r150755 r150756 20 20 #define DatePickerClient_h 21 21 22 #include "PagePopup BlackBerryClient.h"22 #include "PagePopupClient.h" 23 23 #include <BlackBerryPlatformInputEvents.h> 24 24 #include <unicode/udat.h> … … 36 36 class WebPagePrivate; 37 37 38 class DatePickerClient : public PagePopup BlackBerryClient {38 class DatePickerClient : public PagePopupClient { 39 39 public: 40 DatePickerClient(BlackBerry::Platform::BlackBerryInputType, const BlackBerry::Platform::String& value, const BlackBerry::Platform::String& min, const BlackBerry::Platform::String& max, double step, BlackBerry::WebKit::WebPagePrivate*, WebCore::HTMLInputElement*);40 DatePickerClient(BlackBerry::Platform::BlackBerryInputType, const BlackBerry::Platform::String& value, const BlackBerry::Platform::String& min, const BlackBerry::Platform::String& max, double step, WebPagePrivate*, WebCore::HTMLInputElement*); 41 41 ~DatePickerClient(); 42 42 43 void setValueAndClosePopup( int,const String&);43 void setValueAndClosePopup(const String&); 44 44 void didClosePopup(); 45 45 -
trunk/Source/WebKit/blackberry/WebKitSupport/PagePopup.cpp
r150755 r150756 1 1 /* 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 17 17 */ 18 18 #include "config.h" 19 #include "PagePopup BlackBerry.h"19 #include "PagePopup.h" 20 20 21 21 #include "DocumentLoader.h" … … 28 28 #include "JSRetainPtr.h" 29 29 #include "KURL.h" 30 #include "PagePopup BlackBerryClient.h"30 #include "PagePopupClient.h" 31 31 #include "Settings.h" 32 32 #include "WebPage.h" 33 33 #include "WebPage_p.h" 34 35 34 #include <JavaScriptCore/API/JSCallbackObject.h> 36 35 #include <JavaScriptCore/JSObjectRef.h> 37 36 #include <JavaScriptCore/JSStringRef.h> 38 37 #include <JavaScriptCore/JSValueRef.h> 39 40 #define PADDING 8041 38 42 39 using namespace WebCore; … … 45 42 namespace WebKit { 46 43 47 PagePopup BlackBerry::PagePopupBlackBerry(WebPagePrivate* webPage, PagePopupBlackBerryClient* client)44 PagePopup::PagePopup(WebPagePrivate* webPage, PagePopupClient* client) 48 45 : m_webPagePrivate(webPage) 49 46 , m_client(adoptPtr(client)) 50 , m_sharedClientPointer(adoptRef(new PagePopupBlackBerry::SharedClientPointer(client)))51 47 { 52 48 } 53 49 54 PagePopup BlackBerry::~PagePopupBlackBerry()50 PagePopup::~PagePopup() 55 51 { 56 ASSERT(!m_sharedClientPointer->get());57 52 } 58 53 59 bool PagePopupBlackBerry::init(WebPage* webpage)54 void PagePopup::initialize(WebPage* webPage) 60 55 { 61 56 // Don't use backing store for the pop-up web page. 62 web page->settings()->setBackingStoreEnabled(false);57 webPage->settings()->setBackingStoreEnabled(false); 63 58 64 web page->d->setLoadState(WebPagePrivate::Committed);59 webPage->d->setLoadState(WebPagePrivate::Committed); 65 60 66 generateHTML(webpage);67 installDOMFunction(web page->d->mainFrame());61 writeDocument(webPage->d->mainFrame()->loader()->activeDocumentLoader()->writer()); 62 installDOMFunction(webPage->d->mainFrame()); 68 63 69 webpage->d->setLoadState(WebPagePrivate::Finished); 70 webpage->client()->notifyLoadFinished(0); 71 72 return true; 64 webPage->d->setLoadState(WebPagePrivate::Finished); 65 webPage->client()->notifyLoadFinished(0); 73 66 } 74 67 75 void PagePopup BlackBerry::generateHTML(WebPage* webpage)68 void PagePopup::writeDocument(DocumentWriter* writer) 76 69 { 77 DocumentWriter* writer = webpage->d->mainFrame()->loader()->activeDocumentLoader()->writer();70 ASSERT(writter); 78 71 writer->setMIMEType("text/html"); 79 72 writer->begin(KURL()); … … 82 75 StringBuilder source; 83 76 // FIXME: the hardcoding padding will be removed soon. 84 int screenWidth = webpage->d->screenSize().width() - PADDING;85 77 source.appendLiteral("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n"); 86 source.append ("<meta name=\"viewport\" content=\"width=" + String::number(screenWidth));87 source.appendLiteral(", user-scalable=no\" />\n");88 writer->addData( source.toString().utf8().data(), source.toString().utf8().length());78 source.appendLiteral("<meta name=\"viewport\" content=\"user-scalable=no, width=device-width\" />\n"); 79 CString utf8Data = source.toString().utf8(); 80 writer->addData(utf8Data.data(), utf8Data.length()); 89 81 90 82 m_client->writeDocument(*writer); … … 92 84 } 93 85 94 static JSValueRefsetValueAndClosePopupCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*)86 JSValueRef PagePopup::setValueAndClosePopupCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*) 95 87 { 96 88 JSValueRef jsRetVal = JSValueMakeUndefined(context); … … 98 90 return jsRetVal; 99 91 100 JSStringRef string = JSValueToStringCopy(context, arguments[0], 0); 101 size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string); 102 Vector<char> strArgs(sizeUTF8 + 1); 103 strArgs[sizeUTF8] = 0; 104 JSStringGetUTF8CString(string, strArgs.data(), sizeUTF8); 105 JSStringRelease(string); 92 JSRetainPtr<JSStringRef> string(Adopt, JSValueToStringCopy(context, arguments[0], 0)); 93 size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string.get()); 94 Vector<char> utf8String(sizeUTF8 + 1); 95 utf8String[sizeUTF8] = 0; 96 JSStringGetUTF8CString(string.get(), utf8String.data(), sizeUTF8); 106 97 JSObjectRef popUpObject = JSValueToObject(context, arguments[argumentCount - 1], 0); 107 PagePopupBlackBerry::SharedClientPointer* client = reinterpret_cast<PagePopupBlackBerry::SharedClientPointer*>(JSObjectGetPrivate(popUpObject)); 108 109 // Check the weak pointer as the owner page may have destroyed the popup. 110 if (client->get()) 111 client->get()->setValueAndClosePopup(0, strArgs.data()); 98 PagePopup* pagePopup = static_cast<PagePopup*>(JSObjectGetPrivate(popUpObject)); 99 pagePopup->m_client->setValueAndClosePopup(String::fromUTF8(utf8String.data())); 112 100 113 101 return jsRetVal; … … 117 105 { 118 106 UNUSED_PARAM(context); 119 UNUSED_PARAM(object); 107 PagePopup* pagePopup = static_cast<PagePopup*>(JSObjectGetPrivate(object)); 108 pagePopup->ref(); 120 109 } 121 110 122 111 static void popUpExtensionFinalize(JSObjectRef object) 123 112 { 124 // Clear the reference. See installDOMFunction(). 125 PagePopupBlackBerry::SharedClientPointer* client = reinterpret_cast<PagePopupBlackBerry::SharedClientPointer*>(JSObjectGetPrivate(object)); 126 client->deref(); 113 PagePopup* pagePopup = static_cast<PagePopup*>(JSObjectGetPrivate(object)); 114 pagePopup->deref(); 127 115 } 128 116 … … 138 126 }; 139 127 140 void PagePopup BlackBerry::installDOMFunction(Frame* frame)128 void PagePopup::installDOMFunction(Frame* frame) 141 129 { 142 130 JSDOMWindow* window = toJSDOMWindow(frame, mainThreadNormalWorld()); … … 161 149 JSClassRef clientClass = JSClassCreate(&definition); 162 150 163 JSObjectRef clientClassObject = JSObjectMake(context, clientClass, 0); 164 165 // Add a reference. See popUpExtensionFinalize. 166 m_sharedClientPointer->ref(); 167 JSObjectSetPrivate(clientClassObject, m_sharedClientPointer.get()); 151 JSObjectRef clientClassObject = JSObjectMake(context, clientClass, this); 168 152 169 153 String name("popUp"); … … 175 159 } 176 160 177 void PagePopup BlackBerry::closePopup()161 void PagePopup::close() 178 162 { 179 // Prevent the popup page from accessing the client.180 m_sharedClientPointer->clear();181 182 163 m_client->didClosePopup(); 183 164 } -
trunk/Source/WebKit/blackberry/WebKitSupport/PagePopup.h
r150755 r150756 1 1 /* 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 17 17 */ 18 18 19 #ifndef PagePopup BlackBerry_h20 #define PagePopup BlackBerry_h19 #ifndef PagePopup_h 20 #define PagePopup_h 21 21 22 22 #include "IntRect.h" … … 24 24 #include <wtf/RefPtr.h> 25 25 26 typedef const struct OpaqueJSContext* JSContextRef; 27 typedef struct OpaqueJSValue* JSObjectRef; 28 typedef const struct OpaqueJSValue* JSValueRef; 29 26 30 namespace WebCore { 31 class DocumentWriter; 27 32 class Frame; 28 33 } … … 32 37 class WebPage; 33 38 class WebPagePrivate; 34 class PagePopup BlackBerryClient;39 class PagePopupClient; 35 40 36 class PagePopup BlackBerry{41 class PagePopup : public RefCounted<PagePopup> { 37 42 public: 38 PagePopupBlackBerry(BlackBerry::WebKit::WebPagePrivate*, PagePopupBlackBerryClient*); 39 ~PagePopupBlackBerry(); 43 static PassRefPtr<PagePopup> create(WebPagePrivate* webPagePrivate, PagePopupClient* client) 44 { 45 return adoptRef(new PagePopup(webPagePrivate, client)); 46 } 47 ~PagePopup(); 40 48 41 bool init(BlackBerry::WebKit::WebPage*); 42 void closePopup(); 43 44 class SharedClientPointer : public RefCounted<SharedClientPointer> { 45 public: 46 explicit SharedClientPointer(PagePopupBlackBerryClient* client) : m_client(client) { } 47 void clear() { m_client = 0; } 48 PagePopupBlackBerryClient* get() const { return m_client; } 49 private: 50 PagePopupBlackBerryClient* m_client; 51 }; 49 void initialize(WebPage*); 50 void close(); 52 51 53 52 private: 54 void generateHTML(BlackBerry::WebKit::WebPage*); 53 PagePopup(WebPagePrivate*, PagePopupClient*); 54 55 void writeDocument(WebCore::DocumentWriter*); 55 56 void installDOMFunction(WebCore::Frame*); 56 57 57 BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate; 58 OwnPtr<PagePopupBlackBerryClient> m_client; 59 RefPtr<SharedClientPointer> m_sharedClientPointer; 58 static JSValueRef setValueAndClosePopupCallback(JSContextRef, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*); 59 60 WebPagePrivate* m_webPagePrivate; 61 OwnPtr<PagePopupClient> m_client; 60 62 }; 61 63 … … 63 65 } 64 66 65 #endif // PagePopup BlackBerry_h67 #endif // PagePopup_h -
trunk/Source/WebKit/blackberry/WebKitSupport/PagePopupClient.cpp
r150755 r150756 18 18 19 19 #include "config.h" 20 #include "PagePopup BlackBerryClient.h"20 #include "PagePopupClient.h" 21 21 22 22 #include "DocumentWriter.h" … … 30 30 namespace WebKit { 31 31 32 PagePopup BlackBerryClient::PagePopupBlackBerryClient(BlackBerry::WebKit::WebPagePrivate* webPage)33 : m_webPage (webPage)32 PagePopupClient::PagePopupClient(WebPagePrivate* webPagePrivate) 33 : m_webPagePrivate(webPagePrivate) 34 34 { 35 35 } 36 36 37 void PagePopup BlackBerryClient::closePopup()37 void PagePopupClient::closePopup() 38 38 { 39 ASSERT(m_webPage );40 m_webPage ->closePagePopup();39 ASSERT(m_webPagePrivate); 40 m_webPagePrivate->closePagePopup(); 41 41 } 42 42 43 void PagePopup BlackBerryClient::didClosePopup()43 void PagePopupClient::didClosePopup() 44 44 { 45 m_webPage = 0;45 m_webPagePrivate = 0; 46 46 } 47 47 48 IntSize PagePopup BlackBerryClient::contentSize()48 IntSize PagePopupClient::contentSize() 49 49 { 50 50 // FIXME: will generate content size dynamically. … … 52 52 } 53 53 54 void PagePopup BlackBerryClient::writeDocument(DocumentWriter& writer)54 void PagePopupClient::writeDocument(DocumentWriter& writer) 55 55 { 56 56 writer.addData(m_source.utf8().data(), m_source.utf8().length()); -
trunk/Source/WebKit/blackberry/WebKitSupport/PagePopupClient.h
r150755 r150756 18 18 19 19 20 #ifndef PagePopup BlackBerryClient_h21 #define PagePopup BlackBerryClient_h20 #ifndef PagePopupClient_h 21 #define PagePopupClient_h 22 22 23 23 #include "DocumentWriter.h" … … 34 34 class WebPagePrivate; 35 35 36 class PagePopup BlackBerryClient {36 class PagePopupClient { 37 37 public: 38 38 virtual WebCore::IntSize contentSize(); … … 46 46 47 47 // This is called by the content HTML of a PagePopup. 48 // An implementation of this function should call ChromeClient::closePagePopup(). 49 virtual void setValueAndClosePopup(int numValue, const String& stringValue) = 0; 48 // An implementation of this function should call closePopup(). 49 virtual void setValueAndClosePopup(const String& stringValue) = 0; 50 51 // This is called whenever a PagePopup was closed. 52 virtual void didClosePopup(); 53 54 virtual ~PagePopupClient() { } 55 56 protected: 57 PagePopupClient(WebPagePrivate*); 50 58 51 59 // This is called by the content HTML of a PagePopup. 52 60 virtual void closePopup(); 53 61 54 // This is called whenever a PagePopup was closed. 55 virtual void didClosePopup(); 56 57 virtual ~PagePopupBlackBerryClient() { } 58 59 protected: 60 PagePopupBlackBerryClient(BlackBerry::WebKit::WebPagePrivate*); 61 62 BlackBerry::WebKit::WebPagePrivate* m_webPage; 62 WebPagePrivate* m_webPagePrivate; 63 63 String m_source; 64 64 }; -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectPopupClient.cpp
r150755 r150756 31 31 #include <wtf/text/StringBuilder.h> 32 32 33 #define CELL_HEIGHT 3034 35 33 using namespace WebCore; 36 34 … … 40 38 DEFINE_STATIC_LOCAL(BlackBerry::Platform::LocalizeResource, s_resource, ()); 41 39 42 SelectPopupClient::SelectPopupClient(bool multiple, int size, const ScopeArray<BlackBerry::Platform::String>& labels, bool* enableds, 43 const int* itemType, bool* selecteds, BlackBerry::WebKit::WebPagePrivate* webPage, HTMLSelectElement* element) 44 : PagePopupBlackBerryClient(webPage) 40 SelectPopupClient::SelectPopupClient(bool multiple, int size, const ScopeArray<BlackBerry::Platform::String>& labels, bool* enableds, const int* itemType, bool* selecteds, WebPagePrivate* webPagePrivate, HTMLSelectElement* element) 41 : PagePopupClient(webPagePrivate) 45 42 , m_multiple(multiple) 46 43 , m_size(size) … … 61 58 source.appendLiteral("<style>\n"); 62 59 // Include CSS file. 63 source.append(popupControlBlackBerryCss, 64 sizeof(popupControlBlackBerryCss)); 60 source.append(popupControlBlackBerryCss, sizeof(popupControlBlackBerryCss)); 65 61 source.appendLiteral("</style>\n<style>"); 66 source.append(selectControlBlackBerryCss, 67 sizeof(selectControlBlackBerryCss)); 62 source.append(selectControlBlackBerryCss, sizeof(selectControlBlackBerryCss)); 68 63 source.appendLiteral("</style></head><body>\n"); 69 64 source.appendLiteral("<script>\n"); … … 130 125 source.appendLiteral(" window.removeEventListener('load', showIt); }); \n"); 131 126 source.append(selectControlBlackBerryJs, sizeof(selectControlBlackBerryJs)); 132 source.appendLiteral("</script>\n" 133 "</body> </html>\n"); 127 source.appendLiteral("</script>\n</body> </html>\n"); 134 128 m_source = source.toString(); 135 129 } 136 130 137 void SelectPopupClient::setValueAndClosePopup( int,const String& stringValue)131 void SelectPopupClient::setValueAndClosePopup(const String& stringValue) 138 132 { 139 ASSERT(m_element); 133 // Popup closed. 134 if (!m_element) 135 return; 140 136 141 137 static const char* cancelValue = "-1"; … … 176 172 void SelectPopupClient::didClosePopup() 177 173 { 178 PagePopup BlackBerryClient::didClosePopup();174 PagePopupClient::didClosePopup(); 179 175 m_element = 0; 180 176 } -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectPopupClient.h
r150755 r150756 21 21 22 22 #include "IntSize.h" 23 #include "PagePopup BlackBerryClient.h"23 #include "PagePopupClient.h" 24 24 #include "ScopePointer.h" 25 25 #include "Timer.h" … … 37 37 namespace WebKit { 38 38 39 class SelectPopupClient : public PagePopup BlackBerryClient {39 class SelectPopupClient : public PagePopupClient { 40 40 public: 41 SelectPopupClient(bool multiple, int size, const ScopeArray<BlackBerry::Platform::String>& labels, bool* enableds, const int* itemType, bool* selecteds, BlackBerry::WebKit::WebPagePrivate*, WebCore::HTMLSelectElement*);41 SelectPopupClient(bool multiple, int size, const ScopeArray<BlackBerry::Platform::String>& labels, bool* enableds, const int* itemType, bool* selecteds, WebPagePrivate*, WebCore::HTMLSelectElement*); 42 42 ~SelectPopupClient(); 43 43 44 virtual void setValueAndClosePopup( int,const String&);44 virtual void setValueAndClosePopup(const String&); 45 45 virtual void didClosePopup(); 46 46
Note: See TracChangeset
for help on using the changeset viewer.