Changeset 150756 in webkit


Ignore:
Timestamp:
May 27, 2013 8:35:15 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Move PagePopup implementation to WebKitSupport
https://bugs.webkit.org/show_bug.cgi?id=116824

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2013-05-27
Reviewed by Rob Buis.

Source/WebKit:

  • PlatformBlackBerry.cmake: Update new file paths and names.

Source/WebKit/blackberry:

After r150434 PagePopup implementation in BlackBerry port is
independent from WebCore. The classes are now in the
BlackBerry::WebKit namespace so they can be moved from
WebCoresupport to WebKitSupport and renamed to remove the
BlackBerry suffix which is now redundant. Also, now that the
implementation is not shared, it can be simplified a bit more.

  • Api/WebPage.cpp:

(BlackBerry::WebKit::WebPagePrivate::WebPagePrivate): Update to
API changes.
(BlackBerry::WebKit::WebPage::initPopupWebView): Ditto.
(BlackBerry::WebKit::WebPagePrivate::openPagePopup): Ditto.
(BlackBerry::WebKit::WebPagePrivate::closePagePopup): Ditto.
(BlackBerry::WebKit::WebPagePrivate::hasOpenedPopup): Ditto.

  • Api/WebPage.h:

(WebKit): Ditto.

  • Api/WebPage_p.h:

(WebKit): Ditto.
(WebPagePrivate): Rename m_selectPopup as m_pagePopup, since it
can also point to a color picker or date picker page popup. Also
use RefPtr instead of raw pointer.

  • WebKitSupport/ColorPickerClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/ColorPickerClient.cpp.

(BlackBerry::WebKit::ColorPickerClient::ColorPickerClient):
(BlackBerry::WebKit::ColorPickerClient::generateHTML):
(BlackBerry::WebKit::ColorPickerClient::setValueAndClosePopup):
Return early if popup has been closed already.
(BlackBerry::WebKit::ColorPickerClient::didClosePopup):

  • WebKitSupport/ColorPickerClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/ColorPickerClient.h.
  • WebKitSupport/DatePickerClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.cpp.

(BlackBerry::WebKit::DatePickerClient::DatePickerClient):
(BlackBerry::WebKit::DatePickerClient::~DatePickerClient):
(BlackBerry::WebKit::DatePickerClient::generateHTML):
(BlackBerry::WebKit::DatePickerClient::setValueAndClosePopup):
Return early if popup has been closed already.
(BlackBerry::WebKit::DatePickerClient::didClosePopup):
(BlackBerry::WebKit::DatePickerClient::generateDateLabels):

  • WebKitSupport/DatePickerClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.h.
  • WebKitSupport/PagePopup.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerry.cpp.

(BlackBerry::WebKit::PagePopup::PagePopup):
(BlackBerry::WebKit::PagePopup::~PagePopup):
(BlackBerry::WebKit::PagePopup::initialize): Renamed as initialize
and made void, since it always returned true and the callers
ignored the return value.
(BlackBerry::WebKit::PagePopup::writeDocument): Renamed from
generateHTML for consistency with PagePopupClient::writeDocument()
and to avoid confusion with generateHTML method in the clients
that create the HTML contents but they don't write the document.
(BlackBerry::WebKit::PagePopup::setValueAndClosePopupCallback):
Make it static member of PagePopup since the JS object now holds a
reference of PagePopup instance as private data.
(BlackBerry::WebKit::popUpExtensionInitialize): Take a reference
of the PagePopup instance saved as private data of the JS object.
(BlackBerry::WebKit::popUpExtensionFinalize): Unref the PagePopup
instance saved as private data of the JS object.
(BlackBerry::WebKit::PagePopup::installDOMFunction): Instead of
saving the client as private data of the JS object using a wrapper
refcounted object, save the PagePopup instance that is now
refcounted and access the client from the PagePopup instance in
the callback.
(BlackBerry::WebKit::PagePopup::close): Renamed from closePagePopup
since PagePopup::closePagePopup was a bit redundant.

  • WebKitSupport/PagePopup.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerry.h.

(BlackBerry::WebKit::PagePopup::create): Static member to create
instances of PagePopup now that it's refcounted.

  • WebKitSupport/PagePopupClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerryClient.cpp.

(BlackBerry::WebKit::PagePopupClient::PagePopupClient):
(BlackBerry::WebKit::PagePopupClient::closePopup):
(BlackBerry::WebKit::PagePopupClient::didClosePopup):
(BlackBerry::WebKit::PagePopupClient::contentSize):
(BlackBerry::WebKit::PagePopupClient::writeDocument):

  • WebKitSupport/PagePopupClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/PagePopupBlackBerryClient.h.
  • WebKitSupport/SelectPopupClient.cpp: Renamed from Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.cpp.

(BlackBerry::WebKit::SelectPopupClient::SelectPopupClient):
(BlackBerry::WebKit::SelectPopupClient::~SelectPopupClient):
(BlackBerry::WebKit::SelectPopupClient::generateHTML):
(BlackBerry::WebKit::SelectPopupClient::setValueAndClosePopup):
Return early if popup has been closed already.
(BlackBerry::WebKit::SelectPopupClient::didClosePopup):
(BlackBerry::WebKit::SelectPopupClient::notifySelectionChange):

  • WebKitSupport/SelectPopupClient.h: Renamed from Source/WebKit/blackberry/WebCoreSupport/SelectPopupClient.h.
Location:
trunk/Source/WebKit
Files:
6 edited
10 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r150670 r150756  
     12013-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
    1102013-05-24  Brent Fulgham  <bfulgham@apple.com>
    211
  • trunk/Source/WebKit/PlatformBlackBerry.cmake

    r150434 r150756  
    102102    blackberry/WebCoreSupport/NetworkInfoClientBlackBerry.cpp
    103103    blackberry/WebCoreSupport/NotificationClientBlackBerry.cpp
    104     blackberry/WebCoreSupport/PagePopupBlackBerry.cpp
    105     blackberry/WebCoreSupport/PagePopupBlackBerryClient.cpp
    106104    blackberry/WebCoreSupport/PlatformStrategiesBlackBerry.cpp
    107105    blackberry/WebCoreSupport/NavigatorContentUtilsClientBlackBerry.cpp
    108     blackberry/WebCoreSupport/SelectPopupClient.cpp
    109106    blackberry/WebCoreSupport/SuggestionBoxHandler.cpp
    110107    blackberry/WebCoreSupport/SuggestionBoxElement.cpp
    111108    blackberry/WebCoreSupport/VibrationClientBlackBerry.cpp
    112     blackberry/WebCoreSupport/DatePickerClient.cpp
    113     blackberry/WebCoreSupport/ColorPickerClient.cpp
    114109    blackberry/WebKitSupport/AboutData.cpp
    115110    blackberry/WebKitSupport/BackingStoreTile.cpp
    116111    blackberry/WebKitSupport/BackingStoreClient.cpp
    117112    blackberry/WebKitSupport/BackingStoreVisualizationViewportAccessor.cpp
     113    blackberry/WebKitSupport/ColorPickerClient.cpp
     114    blackberry/WebKitSupport/DatePickerClient.cpp
    118115    blackberry/WebKitSupport/DefaultTapHighlight.cpp
    119116    blackberry/WebKitSupport/DOMSupport.cpp
     
    124121    blackberry/WebKitSupport/InspectorOverlayBlackBerry.cpp
    125122    blackberry/WebKitSupport/NotificationManager.cpp
     123    blackberry/WebKitSupport/PagePopup.cpp
     124    blackberry/WebKitSupport/PagePopupClient.cpp
    126125    blackberry/WebKitSupport/ProximityDetector.cpp
    127126    blackberry/WebKitSupport/RenderQueue.cpp
     127    blackberry/WebKitSupport/SelectPopupClient.cpp
    128128    blackberry/WebKitSupport/SelectionHandler.cpp
    129129    blackberry/WebKitSupport/SelectionOverlay.cpp
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r150735 r150756  
    101101#include "PageCache.h"
    102102#include "PageGroup.h"
    103 #include "PagePopupBlackBerry.h"
    104 #include "PagePopupBlackBerryClient.h"
     103#include "PagePopup.h"
     104#include "PagePopupClient.h"
    105105#include "PlatformTouchEvent.h"
    106106#include "PlatformWheelEvent.h"
     
    417417    , m_updateDelegatedOverlaysDispatched(false)
    418418    , m_deferredTasksTimer(this, &WebPagePrivate::deferredTasksTimerFired)
    419     , m_selectPopup(0)
     419    , m_pagePopup(0)
    420420    , m_autofillManager(AutofillManager::create(this))
    421421    , m_documentStyleRecalcPostponed(false)
     
    49424942void WebPage::initPopupWebView(BlackBerry::WebKit::WebPage* webPage)
    49434943{
    4944     d->m_selectPopup->init(webPage);
     4944    d->m_pagePopup->initialize(webPage);
    49454945}
    49464946
     
    60636063}
    60646064
    6065 bool WebPagePrivate::openPagePopup(PagePopupBlackBerryClient* popupClient, const WebCore::IntRect& originBoundsInRootView)
     6065bool WebPagePrivate::openPagePopup(PagePopupClient* popupClient, const WebCore::IntRect& originBoundsInRootView)
    60666066{
    60676067    closePagePopup();
    6068     m_selectPopup = new PagePopupBlackBerry(this, popupClient);
     6068    m_pagePopup = PagePopup::create(this, popupClient);
    60696069
    60706070    WebCore::IntRect popupRect = m_page->chrome().client()->rootViewToScreen(originBoundsInRootView);
     
    60806080void WebPagePrivate::closePagePopup()
    60816081{
    6082     if (!m_selectPopup)
    6083         return;
    6084 
    6085     m_selectPopup->closePopup();
     6082    if (!m_pagePopup)
     6083        return;
     6084
     6085    m_pagePopup->close();
    60866086    m_client->closePopupWebView();
    6087     delete m_selectPopup;
    6088     m_selectPopup = 0;
     6087    m_pagePopup = 0;
    60896088}
    60906089
    60916090bool WebPagePrivate::hasOpenedPopup() const
    60926091{
    6093     return m_selectPopup;
     6092    return m_pagePopup;
    60946093}
    60956094
  • trunk/Source/WebKit/blackberry/Api/WebPage.h

    r150434 r150756  
    6262class BackingStorePrivate;
    6363class InRegionScroller;
    64 class PagePopupBlackBerry;
     64class PagePopup;
    6565class RenderQueue;
    6666class WebCookieJar;
     
    390390    friend class WebKit::BackingStoreClient;
    391391    friend class WebKit::BackingStorePrivate;
    392     friend class WebKit::PagePopupBlackBerry;
     392    friend class WebKit::PagePopup;
    393393    friend class WebKit::RenderQueue;
    394394    friend class WebKit::WebPageCompositor;
  • trunk/Source/WebKit/blackberry/Api/WebPage_p.h

    r150434 r150756  
    8080class InPageSearchManager;
    8181class InputHandler;
    82 class PagePopupBlackBerry;
    83 class PagePopupBlackBerryClient;
     82class PagePopup;
     83class PagePopupClient;
    8484class SelectionHandler;
    8585class TouchEventHandler;
     
    414414    BackingStoreClient* backingStoreClient() const;
    415415
    416     bool openPagePopup(PagePopupBlackBerryClient*, const WebCore::IntRect& originBoundsInRootView);
     416    bool openPagePopup(PagePopupClient*, const WebCore::IntRect& originBoundsInRootView);
    417417    void closePagePopup();
    418418    bool hasOpenedPopup() const;
     
    639639
    640640    // The popup that opened in this webpage
    641     PagePopupBlackBerry* m_selectPopup;
     641    RefPtr<PagePopup> m_pagePopup;
    642642
    643643    RefPtr<WebCore::AutofillManager> m_autofillManager;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r150735 r150756  
     12013-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
    1892013-05-26  Jakob Petsovits  <jpetsovits@blackberry.com>
    290
  • trunk/Source/WebKit/blackberry/WebKitSupport/ColorPickerClient.cpp

    r150755 r150756  
    3636DEFINE_STATIC_LOCAL(BlackBerry::Platform::LocalizeResource, s_resource, ());
    3737
    38 ColorPickerClient::ColorPickerClient(const BlackBerry::Platform::String& value, BlackBerry::WebKit::WebPagePrivate* webPage, WebCore::HTMLInputElement* element)
    39     : PagePopupBlackBerryClient(webPage)
     38ColorPickerClient::ColorPickerClient(const BlackBerry::Platform::String& value, WebPagePrivate* webPagePrivate, WebCore::HTMLInputElement* element)
     39    : PagePopupClient(webPagePrivate)
    4040    , m_element(element)
    4141{
     
    8080}
    8181
    82 void ColorPickerClient::setValueAndClosePopup(int, const String& value)
     82void ColorPickerClient::setValueAndClosePopup(const String& value)
    8383{
    84     ASSERT(m_element);
     84    // Popup closed.
     85    if (!m_element)
     86        return;
    8587
    8688    static const char* cancelValue = "-1";
     
    9294void ColorPickerClient::didClosePopup()
    9395{
    94     PagePopupBlackBerryClient::didClosePopup();
     96    PagePopupClient::didClosePopup();
    9597    m_element = 0;
    9698}
  • trunk/Source/WebKit/blackberry/WebKitSupport/ColorPickerClient.h

    r150755 r150756  
    2020#define ColorPickerClient_h
    2121
    22 #include "PagePopupBlackBerryClient.h"
     22#include "PagePopupClient.h"
    2323#include <BlackBerryPlatformInputEvents.h>
    2424
     
    3434namespace WebKit {
    3535
    36 class ColorPickerClient : public PagePopupBlackBerryClient {
     36class ColorPickerClient : public PagePopupClient {
    3737public:
    38     ColorPickerClient(const BlackBerry::Platform::String& value, BlackBerry::WebKit::WebPagePrivate*, WebCore::HTMLInputElement*);
     38    ColorPickerClient(const BlackBerry::Platform::String& value, WebPagePrivate*, WebCore::HTMLInputElement*);
    3939
    40     void setValueAndClosePopup(int, const String&);
     40    void setValueAndClosePopup(const String&);
    4141    void didClosePopup();
    4242
  • trunk/Source/WebKit/blackberry/WebKitSupport/DatePickerClient.cpp

    r150755 r150756  
    4040DEFINE_STATIC_LOCAL(BlackBerry::Platform::LocalizeResource, s_resource, ());
    4141
    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     : PagePopupBlackBerryClient(webPage)
     42DatePickerClient::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)
    4444    , m_type(type)
    4545    , m_element(element)
     
    5858    source.appendLiteral("<style>\n");
    5959    // Include CSS file.
    60     source.append(popupControlBlackBerryCss,
    61             sizeof(popupControlBlackBerryCss));
     60    source.append(popupControlBlackBerryCss, sizeof(popupControlBlackBerryCss));
    6261    source.appendLiteral("</style>\n<style>");
    63     source.append(timeControlBlackBerryCss,
    64             sizeof(timeControlBlackBerryCss));
     62    source.append(timeControlBlackBerryCss, sizeof(timeControlBlackBerryCss));
    6563    source.appendLiteral("</style></head><body>\n");
    6664    source.appendLiteral("<script>\n");
     
    129127    source.appendLiteral(" window.removeEventListener('load', showIt); }); \n");
    130128    source.append(timeControlBlackBerryJs, sizeof(timeControlBlackBerryJs));
    131     source.appendLiteral("</script>\n"
    132                          "</body> </html>\n");
     129    source.appendLiteral("</script>\n</body> </html>\n");
    133130    m_source = source.toString();
    134131}
    135132
    136 void DatePickerClient::setValueAndClosePopup(int, const String& value)
    137 {
    138     // Return -1 if user cancel the selection.
    139     ASSERT(m_element);
     133void DatePickerClient::setValueAndClosePopup(const String& value)
     134{
     135    // Popup closed.
     136    if (!m_element)
     137        return;
    140138
    141139    // We hide caret when we select date input field, restore it when we close date picker.
    142140    m_element->document()->frame()->selection()->setCaretVisible(true);
    143141
     142    // Return -1 if user cancel the selection.
    144143    if (value != "-1")
    145144        m_element->setValue(value, DispatchChangeEvent);
     
    149148void DatePickerClient::didClosePopup()
    150149{
    151     PagePopupBlackBerryClient::didClosePopup();
     150    PagePopupClient::didClosePopup();
    152151    m_element = 0;
    153152}
  • trunk/Source/WebKit/blackberry/WebKitSupport/DatePickerClient.h

    r150755 r150756  
    2020#define DatePickerClient_h
    2121
    22 #include "PagePopupBlackBerryClient.h"
     22#include "PagePopupClient.h"
    2323#include <BlackBerryPlatformInputEvents.h>
    2424#include <unicode/udat.h>
     
    3636class WebPagePrivate;
    3737
    38 class DatePickerClient : public PagePopupBlackBerryClient {
     38class DatePickerClient : public PagePopupClient {
    3939public:
    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*);
    4141    ~DatePickerClient();
    4242
    43     void setValueAndClosePopup(int, const String&);
     43    void setValueAndClosePopup(const String&);
    4444    void didClosePopup();
    4545
  • trunk/Source/WebKit/blackberry/WebKitSupport/PagePopup.cpp

    r150755 r150756  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    1717 */
    1818#include "config.h"
    19 #include "PagePopupBlackBerry.h"
     19#include "PagePopup.h"
    2020
    2121#include "DocumentLoader.h"
     
    2828#include "JSRetainPtr.h"
    2929#include "KURL.h"
    30 #include "PagePopupBlackBerryClient.h"
     30#include "PagePopupClient.h"
    3131#include "Settings.h"
    3232#include "WebPage.h"
    3333#include "WebPage_p.h"
    34 
    3534#include <JavaScriptCore/API/JSCallbackObject.h>
    3635#include <JavaScriptCore/JSObjectRef.h>
    3736#include <JavaScriptCore/JSStringRef.h>
    3837#include <JavaScriptCore/JSValueRef.h>
    39 
    40 #define PADDING 80
    4138
    4239using namespace WebCore;
     
    4542namespace WebKit {
    4643
    47 PagePopupBlackBerry::PagePopupBlackBerry(WebPagePrivate* webPage, PagePopupBlackBerryClient* client)
     44PagePopup::PagePopup(WebPagePrivate* webPage, PagePopupClient* client)
    4845    : m_webPagePrivate(webPage)
    4946    , m_client(adoptPtr(client))
    50     , m_sharedClientPointer(adoptRef(new PagePopupBlackBerry::SharedClientPointer(client)))
    5147{
    5248}
    5349
    54 PagePopupBlackBerry::~PagePopupBlackBerry()
     50PagePopup::~PagePopup()
    5551{
    56     ASSERT(!m_sharedClientPointer->get());
    5752}
    5853
    59 bool PagePopupBlackBerry::init(WebPage* webpage)
     54void PagePopup::initialize(WebPage* webPage)
    6055{
    6156    // Don't use backing store for the pop-up web page.
    62     webpage->settings()->setBackingStoreEnabled(false);
     57    webPage->settings()->setBackingStoreEnabled(false);
    6358
    64     webpage->d->setLoadState(WebPagePrivate::Committed);
     59    webPage->d->setLoadState(WebPagePrivate::Committed);
    6560
    66     generateHTML(webpage);
    67     installDOMFunction(webpage->d->mainFrame());
     61    writeDocument(webPage->d->mainFrame()->loader()->activeDocumentLoader()->writer());
     62    installDOMFunction(webPage->d->mainFrame());
    6863
    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);
    7366}
    7467
    75 void PagePopupBlackBerry::generateHTML(WebPage* webpage)
     68void PagePopup::writeDocument(DocumentWriter* writer)
    7669{
    77     DocumentWriter* writer = webpage->d->mainFrame()->loader()->activeDocumentLoader()->writer();
     70    ASSERT(writter);
    7871    writer->setMIMEType("text/html");
    7972    writer->begin(KURL());
     
    8275    StringBuilder source;
    8376    // FIXME: the hardcoding padding will be removed soon.
    84     int screenWidth = webpage->d->screenSize().width() - PADDING;
    8577    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());
    8981
    9082    m_client->writeDocument(*writer);
     
    9284}
    9385
    94 static JSValueRef setValueAndClosePopupCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*)
     86JSValueRef PagePopup::setValueAndClosePopupCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*)
    9587{
    9688    JSValueRef jsRetVal = JSValueMakeUndefined(context);
     
    9890        return jsRetVal;
    9991
    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);
    10697    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()));
    112100
    113101    return jsRetVal;
     
    117105{
    118106    UNUSED_PARAM(context);
    119     UNUSED_PARAM(object);
     107    PagePopup* pagePopup = static_cast<PagePopup*>(JSObjectGetPrivate(object));
     108    pagePopup->ref();
    120109}
    121110
    122111static void popUpExtensionFinalize(JSObjectRef object)
    123112{
    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();
    127115}
    128116
     
    138126};
    139127
    140 void PagePopupBlackBerry::installDOMFunction(Frame* frame)
     128void PagePopup::installDOMFunction(Frame* frame)
    141129{
    142130    JSDOMWindow* window = toJSDOMWindow(frame, mainThreadNormalWorld());
     
    161149    JSClassRef clientClass = JSClassCreate(&definition);
    162150
    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);
    168152
    169153    String name("popUp");
     
    175159}
    176160
    177 void PagePopupBlackBerry::closePopup()
     161void PagePopup::close()
    178162{
    179     // Prevent the popup page from accessing the client.
    180     m_sharedClientPointer->clear();
    181 
    182163    m_client->didClosePopup();
    183164}
  • trunk/Source/WebKit/blackberry/WebKitSupport/PagePopup.h

    r150755 r150756  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    1717 */
    1818
    19 #ifndef PagePopupBlackBerry_h
    20 #define PagePopupBlackBerry_h
     19#ifndef PagePopup_h
     20#define PagePopup_h
    2121
    2222#include "IntRect.h"
     
    2424#include <wtf/RefPtr.h>
    2525
     26typedef const struct OpaqueJSContext* JSContextRef;
     27typedef struct OpaqueJSValue* JSObjectRef;
     28typedef const struct OpaqueJSValue* JSValueRef;
     29
    2630namespace WebCore {
     31class DocumentWriter;
    2732class Frame;
    2833}
     
    3237class WebPage;
    3338class WebPagePrivate;
    34 class PagePopupBlackBerryClient;
     39class PagePopupClient;
    3540
    36 class PagePopupBlackBerry {
     41class PagePopup : public RefCounted<PagePopup> {
    3742public:
    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();
    4048
    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();
    5251
    5352private:
    54     void generateHTML(BlackBerry::WebKit::WebPage*);
     53    PagePopup(WebPagePrivate*, PagePopupClient*);
     54
     55    void writeDocument(WebCore::DocumentWriter*);
    5556    void installDOMFunction(WebCore::Frame*);
    5657
    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;
    6062};
    6163
     
    6365}
    6466
    65 #endif // PagePopupBlackBerry_h
     67#endif // PagePopup_h
  • trunk/Source/WebKit/blackberry/WebKitSupport/PagePopupClient.cpp

    r150755 r150756  
    1818
    1919#include "config.h"
    20 #include "PagePopupBlackBerryClient.h"
     20#include "PagePopupClient.h"
    2121
    2222#include "DocumentWriter.h"
     
    3030namespace WebKit {
    3131
    32 PagePopupBlackBerryClient::PagePopupBlackBerryClient(BlackBerry::WebKit::WebPagePrivate* webPage)
    33     : m_webPage(webPage)
     32PagePopupClient::PagePopupClient(WebPagePrivate* webPagePrivate)
     33    : m_webPagePrivate(webPagePrivate)
    3434{
    3535}
    3636
    37 void PagePopupBlackBerryClient::closePopup()
     37void PagePopupClient::closePopup()
    3838{
    39     ASSERT(m_webPage);
    40     m_webPage->closePagePopup();
     39    ASSERT(m_webPagePrivate);
     40    m_webPagePrivate->closePagePopup();
    4141}
    4242
    43 void PagePopupBlackBerryClient::didClosePopup()
     43void PagePopupClient::didClosePopup()
    4444{
    45     m_webPage = 0;
     45    m_webPagePrivate = 0;
    4646}
    4747
    48 IntSize PagePopupBlackBerryClient::contentSize()
     48IntSize PagePopupClient::contentSize()
    4949{
    5050    // FIXME: will generate content size dynamically.
     
    5252}
    5353
    54 void PagePopupBlackBerryClient::writeDocument(DocumentWriter& writer)
     54void PagePopupClient::writeDocument(DocumentWriter& writer)
    5555{
    5656    writer.addData(m_source.utf8().data(), m_source.utf8().length());
  • trunk/Source/WebKit/blackberry/WebKitSupport/PagePopupClient.h

    r150755 r150756  
    1818
    1919
    20 #ifndef PagePopupBlackBerryClient_h
    21 #define PagePopupBlackBerryClient_h
     20#ifndef PagePopupClient_h
     21#define PagePopupClient_h
    2222
    2323#include "DocumentWriter.h"
     
    3434class WebPagePrivate;
    3535
    36 class PagePopupBlackBerryClient {
     36class PagePopupClient {
    3737public:
    3838    virtual WebCore::IntSize contentSize();
     
    4646
    4747    // 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
     56protected:
     57    PagePopupClient(WebPagePrivate*);
    5058
    5159    // This is called by the content HTML of a PagePopup.
    5260    virtual void closePopup();
    5361
    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;
    6363    String m_source;
    6464};
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectPopupClient.cpp

    r150755 r150756  
    3131#include <wtf/text/StringBuilder.h>
    3232
    33 #define CELL_HEIGHT 30
    34 
    3533using namespace WebCore;
    3634
     
    4038DEFINE_STATIC_LOCAL(BlackBerry::Platform::LocalizeResource, s_resource, ());
    4139
    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)
     40SelectPopupClient::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)
    4542    , m_multiple(multiple)
    4643    , m_size(size)
     
    6158    source.appendLiteral("<style>\n");
    6259    // Include CSS file.
    63     source.append(popupControlBlackBerryCss,
    64             sizeof(popupControlBlackBerryCss));
     60    source.append(popupControlBlackBerryCss, sizeof(popupControlBlackBerryCss));
    6561    source.appendLiteral("</style>\n<style>");
    66     source.append(selectControlBlackBerryCss,
    67             sizeof(selectControlBlackBerryCss));
     62    source.append(selectControlBlackBerryCss, sizeof(selectControlBlackBerryCss));
    6863    source.appendLiteral("</style></head><body>\n");
    6964    source.appendLiteral("<script>\n");
     
    130125    source.appendLiteral(" window.removeEventListener('load', showIt); }); \n");
    131126    source.append(selectControlBlackBerryJs, sizeof(selectControlBlackBerryJs));
    132     source.appendLiteral("</script>\n"
    133                          "</body> </html>\n");
     127    source.appendLiteral("</script>\n</body> </html>\n");
    134128    m_source = source.toString();
    135129}
    136130
    137 void SelectPopupClient::setValueAndClosePopup(int, const String& stringValue)
     131void SelectPopupClient::setValueAndClosePopup(const String& stringValue)
    138132{
    139     ASSERT(m_element);
     133    // Popup closed.
     134    if (!m_element)
     135        return;
    140136
    141137    static const char* cancelValue = "-1";
     
    176172void SelectPopupClient::didClosePopup()
    177173{
    178     PagePopupBlackBerryClient::didClosePopup();
     174    PagePopupClient::didClosePopup();
    179175    m_element = 0;
    180176}
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectPopupClient.h

    r150755 r150756  
    2121
    2222#include "IntSize.h"
    23 #include "PagePopupBlackBerryClient.h"
     23#include "PagePopupClient.h"
    2424#include "ScopePointer.h"
    2525#include "Timer.h"
     
    3737namespace WebKit {
    3838
    39 class SelectPopupClient : public PagePopupBlackBerryClient {
     39class SelectPopupClient : public PagePopupClient {
    4040public:
    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*);
    4242    ~SelectPopupClient();
    4343
    44     virtual void setValueAndClosePopup(int, const String&);
     44    virtual void setValueAndClosePopup(const String&);
    4545    virtual void didClosePopup();
    4646
Note: See TracChangeset for help on using the changeset viewer.