Changeset 56449 in webkit


Ignore:
Timestamp:
Mar 24, 2010 11:41:39 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-24 Jay Campan <jcampan@google.com>

Reviewed by Darin Fisher.

Making Chromium select popups not steal activation from the browser.
Select popups are now like autocomplete popups, shown in non-activated
windows.
https://bugs.webkit.org/show_bug.cgi?id=36062

  • page/chromium/ChromeClientChromium.h:
  • platform/chromium/PopupMenuChromium.cpp: (WebCore::): (WebCore::PopupListBox::setMaxHeight): (WebCore::PopupListBox::disconnectClient): (WebCore::PopupListBox::PopupListBox): (WebCore::PopupContainer::create): (WebCore::PopupContainer::PopupContainer): (WebCore::PopupContainer::showPopup): (WebCore::PopupContainer::showExternal): (WebCore::PopupContainer::hidePopup): (WebCore::PopupContainer::layout): (WebCore::PopupContainer::chromeClientChromium): (WebCore::PopupListBox::hidePopup): (WebCore::PopupListBox::layout): (WebCore::PopupMenu::~PopupMenu): (WebCore::PopupMenu::show):
  • platform/chromium/PopupMenuChromium.h: (WebCore::PopupItem::): (WebCore::PopupItem::PopupItem): (WebCore::PopupContainerSettings::): (WebCore::PopupContainer::): (WebCore::PopupContainer::listBox): (WebCore::PopupContainer::popupType):

2010-03-24 Jay Campan <jcampan@google.com>

Reviewed by Darin Fisher.

Making Chromium select popups not steal activation from the browser.
Select popups are now like autocomplete popups, shown in non-activated
windows.
https://bugs.webkit.org/show_bug.cgi?id=36062

  • public/WebViewClient.h: (WebKit::WebViewClient::createPopupMenu):
  • src/ChromeClientImpl.cpp: (WebKit::ChromeClientImpl::popupOpened): (WebKit::ChromeClientImpl::popupClosed):
  • src/ChromeClientImpl.h:
  • src/WebViewImpl.cpp: (WebKit::): (WebKit::WebViewImpl::mouseDown): (WebKit::WebViewImpl::keyEvent): (WebKit::WebViewImpl::selectPopupHandleKeyEvent): (WebKit::WebViewImpl::hideSelectPopup): (WebKit::WebViewImpl::popupOpened): (WebKit::WebViewImpl::popupClosed): (WebKit::WebViewImpl::setFocus): (WebKit::WebViewImpl::applyAutoFillSuggestions): (WebKit::WebViewImpl::applyAutocompleteSuggestions):
  • src/WebViewImpl.h:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56447 r56449  
     12010-03-24  Jay Campan  <jcampan@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Making Chromium select popups not steal activation from the browser.
     6        Select popups are now like autocomplete popups, shown in non-activated
     7        windows.
     8        https://bugs.webkit.org/show_bug.cgi?id=36062
     9
     10        * page/chromium/ChromeClientChromium.h:
     11        * platform/chromium/PopupMenuChromium.cpp:
     12        (WebCore::):
     13        (WebCore::PopupListBox::setMaxHeight):
     14        (WebCore::PopupListBox::disconnectClient):
     15        (WebCore::PopupListBox::PopupListBox):
     16        (WebCore::PopupContainer::create):
     17        (WebCore::PopupContainer::PopupContainer):
     18        (WebCore::PopupContainer::showPopup):
     19        (WebCore::PopupContainer::showExternal):
     20        (WebCore::PopupContainer::hidePopup):
     21        (WebCore::PopupContainer::layout):
     22        (WebCore::PopupContainer::chromeClientChromium):
     23        (WebCore::PopupListBox::hidePopup):
     24        (WebCore::PopupListBox::layout):
     25        (WebCore::PopupMenu::~PopupMenu):
     26        (WebCore::PopupMenu::show):
     27        * platform/chromium/PopupMenuChromium.h:
     28        (WebCore::PopupItem::):
     29        (WebCore::PopupItem::PopupItem):
     30        (WebCore::PopupContainerSettings::):
     31        (WebCore::PopupContainer::):
     32        (WebCore::PopupContainer::listBox):
     33        (WebCore::PopupContainer::popupType):
     34
    1352010-03-10  David Levin  <levin@chromium.org>
    236
  • trunk/WebCore/page/chromium/ChromeClientChromium.h

    r56416 r56449  
    4949    // popup will be handled by the external embedder.
    5050    virtual void popupOpened(PopupContainer* popupContainer, const IntRect& bounds,
    51                              bool focusOnShow, bool handleExternal) = 0;
     51                             bool handleExternal) = 0;
     52                             
     53    // Notifies the client a popup was closed.
     54    virtual void popupClosed(PopupContainer* popupContainer) = 0;
    5255
    5356    // Notifies embedder that the state of an accessibility object has changed.
  • trunk/WebCore/platform/chromium/PopupMenuChromium.cpp

    r56416 r56449  
    7575// This is the delegate used if none is provided.
    7676static const PopupContainerSettings dropDownSettings = {
    77     true,   // focusOnShow
    7877    true,   // setTextOnIndexChange
    7978    true,   // acceptOnAbandon
     
    142141    int getRowHeight(int index);
    143142
     143    void setMaxHeight(int maxHeight) { m_maxHeight = maxHeight; }
     144
     145    void disconnectClient() { m_popupClient = 0; }
     146
    144147    const Vector<PopupItem*>& items() const { return m_items; }
    145148
     
    155158        , m_visibleRows(0)
    156159        , m_baseWidth(0)
     160        , m_maxHeight(kMaxHeight)
    157161        , m_popupClient(client)
    158162        , m_repeatingChar(0)
     
    167171    }
    168172
    169     void disconnectClient() { m_popupClient = 0; }
    170 
    171173    // Closes the popup
    172174    void abandon();
     
    241243    // Our suggested width, not including scrollbar.
    242244    int m_baseWidth;
     245
     246    // The maximum height we can be without being off-screen.
     247    int m_maxHeight;
    243248
    244249    // A list of the options contained within the <select>
     
    298303// static
    299304PassRefPtr<PopupContainer> PopupContainer::create(PopupMenuClient* client,
     305                                                  PopupType popupType,
    300306                                                  const PopupContainerSettings& settings)
    301307{
    302     return adoptRef(new PopupContainer(client, settings));
     308    return adoptRef(new PopupContainer(client, popupType, settings));
    303309}
    304310
    305311PopupContainer::PopupContainer(PopupMenuClient* client,
     312                               PopupType popupType,
    306313                               const PopupContainerSettings& settings)
    307314    : m_listBox(PopupListBox::create(client, settings))
     315    , m_popupType(popupType) 
    308316    , m_settings(settings)
    309317{
     
    321329    // Pre-layout, our size matches the <select> dropdown control.
    322330    int selectHeight = frameRect().height();
     331
     332    // Reset the max height to its default value, it will be recomputed below
     333    // if necessary.
     334    m_listBox->setMaxHeight(kMaxHeight);
    323335
    324336    // Lay everything out to figure out our preferred size, then tell the view's
     
    326338    layout();
    327339
    328     ChromeClientChromium* chromeClient = static_cast<ChromeClientChromium*>(
    329         view->frame()->page()->chrome()->client());
     340    m_frameView = view;
     341    ChromeClientChromium* chromeClient = chromeClientChromium();
    330342    if (chromeClient) {
    331343        // If the popup would extend past the bottom of the screen, open upwards
     
    333345        FloatRect screen = screenAvailableRect(view);
    334346        IntRect widgetRect = chromeClient->windowToScreen(frameRect());
    335         if (widgetRect.bottom() > static_cast<int>(screen.bottom()))
    336             widgetRect.move(0, -(widgetRect.height() + selectHeight));
    337 
    338         chromeClient->popupOpened(this, widgetRect, m_settings.focusOnShow, false);
     347
     348        if (widgetRect.bottom() > static_cast<int>(screen.bottom())) {
     349            if (widgetRect.y() - widgetRect.height() - selectHeight > 0) {
     350                // There is enough room to open upwards.
     351                widgetRect.move(0, -(widgetRect.height() + selectHeight));
     352            } else {
     353                // Figure whether upwards or downwards has more room and set the
     354                // maximum number of items.
     355                int spaceAbove = widgetRect.y() - selectHeight;
     356                int spaceBelow = screen.bottom() - widgetRect.y();
     357                if (spaceAbove > spaceBelow)
     358                    m_listBox->setMaxHeight(spaceAbove);
     359                else
     360                    m_listBox->setMaxHeight(spaceBelow);
     361                layout();
     362                // Our size has changed, recompute the widgetRect.
     363                widgetRect = chromeClient->windowToScreen(frameRect());
     364                // And move upwards if necessary.
     365                if (spaceAbove > spaceBelow)
     366                    widgetRect.move(0, -(widgetRect.height() + selectHeight));
     367            }
     368        }
     369        chromeClient->popupOpened(this, widgetRect, false);
    339370    }
    340371
     
    369400
    370401    // Get the ChromeClient and pass it the popup menu's listbox data.
    371     ChromeClientChromium* client = static_cast<ChromeClientChromium*>(
    372          v->frame()->page()->chrome()->client());
    373     client->popupOpened(this, popupRect, true, true);
     402    m_frameView = v;
     403    chromeClientChromium()->popupOpened(this, popupRect, true);
    374404
    375405    // The popup sends its "closed" notification through its parent. Set the
     
    383413{
    384414    listBox()->hidePopup();
     415    chromeClientChromium()->popupClosed(this);
    385416}
    386417
     
    393424
    394425    // Size ourselves to contain listbox + border.
     426    int height = m_listBox->height() + kBorderSize * 2;
     427
    395428    resize(m_listBox->width() + kBorderSize * 2, m_listBox->height() + kBorderSize * 2);
    396429
     
    469502{
    470503    return m_listBox->isInterestedInEventForKey(keyCode);
     504}
     505
     506ChromeClientChromium* PopupContainer::chromeClientChromium()
     507{
     508    return static_cast<ChromeClientChromium*>(m_frameView->frame()->page()->chrome()->client());
    471509}
    472510
     
    10901128    }
    10911129
    1092     m_popupClient->popupDidHide();
     1130    if (m_popupClient)
     1131        m_popupClient->popupDidHide();
    10931132}
    10941133
     
    11571196#if !OS(DARWIN)
    11581197        // Only clip the window height for non-Mac platforms.
    1159         if (windowHeight + rowHeight > kMaxHeight) {
     1198        if (windowHeight + rowHeight > m_maxHeight) {
    11601199            m_visibleRows = i;
    11611200            break;
     
    12221261PopupMenu::~PopupMenu()
    12231262{
     1263    // When the PopupMenu is destroyed, the client could already have been
     1264    // deleted.
     1265    p.popup->listBox()->disconnectClient();
    12241266    hide();
    12251267}
     
    12321274{
    12331275    if (!p.popup)
    1234         p.popup = PopupContainer::create(client(), dropDownSettings);
     1276        p.popup = PopupContainer::create(client(), PopupContainer::Select, dropDownSettings);
    12351277#if OS(DARWIN)
    12361278    p.popup->showExternal(r, v, index);
  • trunk/WebCore/platform/chromium/PopupMenuChromium.h

    r56416 r56449  
    4040namespace WebCore {
    4141
    42     class FrameView;
    43     class PopupListBox;
     42class ChromeClientChromium;
     43class FrameView;
     44class PopupListBox;
    4445
    45     // A container for the data for each menu item (e.g. represented by <option>
    46     // or <optgroup> in a <select> widget) and is used by PopupListBox.
    47     struct PopupItem {
    48         enum Type {
    49             TypeOption,
    50             TypeGroup,
    51             TypeSeparator
    52         };
    53 
    54         PopupItem(const String& label, Type type)
    55             : label(label)
    56             , type(type)
    57             , yOffset(0)
    58         {
    59         }
    60         String label;
    61         Type type;
    62         int yOffset;  // y offset of this item, relative to the top of the popup.
    63         bool enabled;
     46// A container for the data for each menu item (e.g. represented by <option>
     47// or <optgroup> in a <select> widget) and is used by PopupListBox.
     48struct PopupItem {
     49    enum Type {
     50        TypeOption,
     51        TypeGroup,
     52        TypeSeparator
    6453    };
    6554
    66     // FIXME: Our FramelessScrollView classes should probably implement HostWindow!
     55    PopupItem(const String& label, Type type)
     56        : label(label)
     57        , type(type)
     58        , yOffset(0)
     59    {
     60    }
     61    String label;
     62    Type type;
     63    int yOffset; // y offset of this item, relative to the top of the popup.
     64    bool enabled;
     65};
    6766
    68     // The PopupContainer class holds a PopupListBox (see cpp file).  Its sole purpose is to be
    69     // able to draw a border around its child.  All its paint/event handling is
    70     // just forwarded to the child listBox (with the appropriate transforms).
    71     // NOTE: this class is exposed so it can be instantiated direcly for the
    72     // autofill popup.  We cannot use the Popup class directly in that case as the
    73     // autofill popup should not be focused when shown and we want to forward the
    74     // key events to it (through handleKeyEvent).
     67// FIXME: Our FramelessScrollView classes should probably implement HostWindow!
    7568
    76     struct PopupContainerSettings {
    77         // Whether the popup should get the focus when displayed.
    78         bool focusOnShow;
     69// The PopupContainer class holds a PopupListBox (see cpp file).  Its sole purpose is to be
     70// able to draw a border around its child.  All its paint/event handling is
     71// just forwarded to the child listBox (with the appropriate transforms).
     72// NOTE: this class is exposed so it can be instantiated direcly for the
     73// autofill popup.  We cannot use the Popup class directly in that case as the
     74// autofill popup should not be focused when shown and we want to forward the
     75// key events to it (through handleKeyEvent).
    7976
    80         // Whether the PopupMenuClient should be told to change its text when a
    81         // new item is selected by using the arrow keys.
    82         bool setTextOnIndexChange;
     77struct PopupContainerSettings {
     78    // Whether the PopupMenuClient should be told to change its text when a
     79    // new item is selected by using the arrow keys.
     80    bool setTextOnIndexChange;
    8381
    84         // Whether the selection should be accepted when the popup menu is
    85         // closed (through ESC being pressed or the focus going away).
    86         // Note that when TAB is pressed, the selection is always accepted
    87         // regardless of this setting.
    88         bool acceptOnAbandon;
     82    // Whether the selection should be accepted when the popup menu is
     83    // closed (through ESC being pressed or the focus going away).
     84    // Note that when TAB is pressed, the selection is always accepted
     85    // regardless of this setting.
     86    bool acceptOnAbandon;
    8987
    90         // Whether we should move the selection to the first/last item when
    91         // the user presses down/up arrow keys and the last/first item is
    92         // selected.
    93         bool loopSelectionNavigation;
     88    // Whether we should move the selection to the first/last item when
     89    // the user presses down/up arrow keys and the last/first item is
     90    // selected.
     91    bool loopSelectionNavigation;
    9492
    95         // Whether we should restrict the width of the PopupListBox or not.
    96         // Autocomplete popups are restricted, combo-boxes (select tags) aren't.
    97         bool restrictWidthOfListBox;
     93    // Whether we should restrict the width of the PopupListBox or not.
     94    // Autocomplete popups are restricted, combo-boxes (select tags) aren't.
     95    bool restrictWidthOfListBox;
    9896
    99         // A hint on the display directionality of the item text in popup menu.
    100         //
    101         // We could either display the items in the drop-down using its DOM element's
    102         // directionality, or we could display the items in the drop-down using heuristics:
    103         // such as in its first strong directionality character's direction.
    104         // Please refer to the discussion (especially comment #7 and #10) in
    105         // https://bugs.webkit.org/show_bug.cgi?id=27889 for details.
    106         enum DirectionalityHint {
    107             // Use the DOM element's directionality to display the item text in popup menu.
    108             DOMElementDirection,
    109             // Use the item text's first strong-directional character's directionality
    110             // to display the item text in popup menu.
    111             FirstStrongDirectionalCharacterDirection,
    112         };
    113         DirectionalityHint itemTextDirectionalityHint;
     97    // A hint on the display directionality of the item text in popup menu.
     98    //
     99    // We could either display the items in the drop-down using its DOM element's
     100    // directionality, or we could display the items in the drop-down using heuristics:
     101    // such as in its first strong directionality character's direction.
     102    // Please refer to the discussion (especially comment #7 and #10) in
     103    // https://bugs.webkit.org/show_bug.cgi?id=27889 for details.
     104    enum DirectionalityHint {
     105        // Use the DOM element's directionality to display the item text in popup menu.
     106        DOMElementDirection,
     107        // Use the item text's first strong-directional character's directionality
     108        // to display the item text in popup menu.
     109        FirstStrongDirectionalCharacterDirection,
     110    };
     111    DirectionalityHint itemTextDirectionalityHint;
     112};
     113
     114class PopupContainer : public FramelessScrollView {
     115public:
     116    enum PopupType {
     117        Select, // HTML select popup.
     118        Suggestion, // Autocomplete/autofill popup.
    114119    };
    115120
    116     class PopupContainer : public FramelessScrollView {
    117     public:
    118         static PassRefPtr<PopupContainer> create(PopupMenuClient*,
    119                                                  const PopupContainerSettings&);
     121    static PassRefPtr<PopupContainer> create(PopupMenuClient*, PopupType,
     122                                             const PopupContainerSettings&);
    120123
    121         // Whether a key event should be sent to this popup.
    122         virtual bool isInterestedInEventForKey(int keyCode);
     124    // Whether a key event should be sent to this popup.
     125    virtual bool isInterestedInEventForKey(int keyCode);
    123126
    124         // FramelessScrollView
    125         virtual void paint(GraphicsContext*, const IntRect&);
    126         virtual void hide();
    127         virtual bool handleMouseDownEvent(const PlatformMouseEvent&);
    128         virtual bool handleMouseMoveEvent(const PlatformMouseEvent&);
    129         virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&);
    130         virtual bool handleWheelEvent(const PlatformWheelEvent&);
    131         virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
     127    // FramelessScrollView
     128    virtual void paint(GraphicsContext*, const IntRect&);
     129    virtual void hide();
     130    virtual bool handleMouseDownEvent(const PlatformMouseEvent&);
     131    virtual bool handleMouseMoveEvent(const PlatformMouseEvent&);
     132    virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&);
     133    virtual bool handleWheelEvent(const PlatformWheelEvent&);
     134    virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
    132135
    133         // PopupContainer methods
     136    // PopupContainer methods
    134137
    135         // Show the popup
    136         void showPopup(FrameView*);
     138    // Show the popup
     139    void showPopup(FrameView*);
    137140
    138         // Used on Mac Chromium for HTML select popup menus.
    139         void showExternal(const IntRect&, FrameView*, int index);
     141    // Used on Mac Chromium for HTML select popup menus.
     142    void showExternal(const IntRect&, FrameView*, int index);
    140143
    141         // Show the popup in the specified rect for the specified frame.
    142         // Note: this code was somehow arbitrarily factored-out of the Popup class
    143         // so WebViewImpl can create a PopupContainer. This method is used for
    144         // displaying auto complete popup menus on Mac Chromium, and for all
    145         // popups on other platforms.
    146         void show(const IntRect&, FrameView*, int index);
     144    // Show the popup in the specified rect for the specified frame.
     145    // Note: this code was somehow arbitrarily factored-out of the Popup class
     146    // so WebViewImpl can create a PopupContainer. This method is used for
     147    // displaying auto complete popup menus on Mac Chromium, and for all
     148    // popups on other platforms.
     149    void show(const IntRect&, FrameView*, int index);
    147150
    148         // Hide the popup.
    149         void hidePopup();
     151    // Hide the popup.
     152    void hidePopup();
    150153
    151         // Compute size of widget and children.
    152         void layout();
     154    // Compute size of widget and children.
     155    void layout();
    153156
    154         PopupListBox* listBox() const { return m_listBox.get(); }
     157    PopupListBox* listBox() const { return m_listBox.get(); }
    155158
    156         // Gets the index of the item that the user is currently moused-over or
    157         // has selected with the keyboard up/down arrows.
    158         int selectedIndex() const;
     159    // Gets the index of the item that the user is currently moused-over or
     160    // has selected with the keyboard up/down arrows.
     161    int selectedIndex() const;
    159162
    160         // Refresh the popup values from the PopupMenuClient.
    161         void refresh();
     163    // Refresh the popup values from the PopupMenuClient.
     164    void refresh();
    162165
    163         // The menu per-item data.
    164         const WTF::Vector<PopupItem*>& popupData() const;
     166    // The menu per-item data.
     167    const WTF::Vector<PopupItem*>& popupData() const;
    165168
    166         // The height of a row in the menu.
    167         int menuItemHeight() const;
     169    // The height of a row in the menu.
     170    int menuItemHeight() const;
    168171
    169         // The size of the font being used.
    170         int menuItemFontSize() const;
     172    // The size of the font being used.
     173    int menuItemFontSize() const;
    171174
    172     private:
    173         friend class WTF::RefCounted<PopupContainer>;
     175    PopupType popupType() const { return m_popupType; }
    174176
    175         PopupContainer(PopupMenuClient*, const PopupContainerSettings&);
    176         ~PopupContainer();
     177private:
     178    friend class WTF::RefCounted<PopupContainer>;
    177179
    178         // Paint the border.
    179         void paintBorder(GraphicsContext*, const IntRect&);
     180    PopupContainer(PopupMenuClient*, PopupType popupType, const PopupContainerSettings&);
     181    ~PopupContainer();
    180182
    181         RefPtr<PopupListBox> m_listBox;
     183    // Paint the border.
     184    void paintBorder(GraphicsContext*, const IntRect&);
    182185
    183         PopupContainerSettings m_settings;
    184     };
     186    // Returns the ChromeClient of the page this popup is associated with.
     187    ChromeClientChromium* chromeClientChromium();
     188
     189    RefPtr<PopupListBox> m_listBox;
     190    RefPtr<FrameView> m_frameView;
     191
     192    PopupContainerSettings m_settings;
     193    PopupType m_popupType;
     194};
    185195
    186196} // namespace WebCore
  • trunk/WebKit/chromium/ChangeLog

    r56448 r56449  
     12010-03-24  Jay Campan  <jcampan@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Making Chromium select popups not steal activation from the browser.
     6        Select popups are now like autocomplete popups, shown in non-activated
     7        windows.
     8        https://bugs.webkit.org/show_bug.cgi?id=36062
     9
     10        * public/WebViewClient.h:
     11        (WebKit::WebViewClient::createPopupMenu):
     12        * src/ChromeClientImpl.cpp:
     13        (WebKit::ChromeClientImpl::popupOpened):
     14        (WebKit::ChromeClientImpl::popupClosed):
     15        * src/ChromeClientImpl.h:
     16        * src/WebViewImpl.cpp:
     17        (WebKit::):
     18        (WebKit::WebViewImpl::mouseDown):
     19        (WebKit::WebViewImpl::keyEvent):
     20        (WebKit::WebViewImpl::selectPopupHandleKeyEvent):
     21        (WebKit::WebViewImpl::hideSelectPopup):
     22        (WebKit::WebViewImpl::popupOpened):
     23        (WebKit::WebViewImpl::popupClosed):
     24        (WebKit::WebViewImpl::setFocus):
     25        (WebKit::WebViewImpl::applyAutoFillSuggestions):
     26        (WebKit::WebViewImpl::applyAutocompleteSuggestions):
     27        * src/WebViewImpl.h:
     28
    1292010-03-24  Alexander Pavlov  <apavlov@chromium.org>
    230
  • trunk/WebKit/chromium/public/WebViewClient.h

    r56416 r56449  
    7474    // Create a new WebPopupMenu.  In the second form, the client is
    7575    // responsible for rendering the contents of the popup menu.
     76    virtual WebWidget* createPopupMenu() { return 0; }
     77    virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; }
     78    // Deprecated method.
    7679    virtual WebWidget* createPopupMenu(bool activatable) { return 0; }
    77     virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; }
     80
    7881
    7982    // Create a session storage namespace object associated with this WebView.
  • trunk/WebKit/chromium/src/ChromeClientImpl.cpp

    r56439 r56449  
    596596void ChromeClientImpl::popupOpened(PopupContainer* popupContainer,
    597597                                   const IntRect& bounds,
    598                                    bool activatable,
    599598                                   bool handleExternally)
    600599{
     
    607606        getPopupMenuInfo(popupContainer, &popupInfo);
    608607        webwidget = m_webView->client()->createPopupMenu(popupInfo);
    609     } else
    610         webwidget = m_webView->client()->createPopupMenu(activatable);
    611 
     608    } else {
     609        webwidget = m_webView->client()->createPopupMenu();
     610        if (!webwidget) {
     611            // Try the deprecated method.
     612            webwidget = m_webView->client()->createPopupMenu(false);
     613        }   
     614    }
     615    m_webView->popupOpened(popupContainer);
    612616    static_cast<WebPopupMenuImpl*>(webwidget)->Init(popupContainer, bounds);
     617}
     618
     619void ChromeClientImpl::popupClosed(WebCore::PopupContainer* popupContainer)
     620{
     621    m_webView->popupClosed(popupContainer);
    613622}
    614623
  • trunk/WebKit/chromium/src/ChromeClientImpl.h

    r56439 r56449  
    149149    virtual void popupOpened(WebCore::PopupContainer* popupContainer,
    150150                             const WebCore::IntRect& bounds,
    151                              bool activatable,
    152151                             bool handleExternally);
     152    virtual void popupClosed(WebCore::PopupContainer* popupContainer);
    153153    virtual void didChangeAccessibilityObjectState(WebCore::AccessibilityObject*);
    154154
  • trunk/WebKit/chromium/src/WebViewImpl.cpp

    r56416 r56449  
    150150COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
    151151
    152 // Note that focusOnShow is false so that the suggestions popup is shown not
    153 // activated.  We need the page to still have focus so the user can keep typing
    154 // while the popup is showing.
    155152static const PopupContainerSettings suggestionsPopupSettings = {
    156     false,  // focusOnShow
    157153    false,  // setTextOnIndexChange
    158154    false,  // acceptOnAbandon
     
    331327    if (!mainFrameImpl() || !mainFrameImpl()->frameView())
    332328        return;
     329
     330    // If there is a select popup opened, close it as the user is clicking on
     331    // the page (outside of the popup).
     332    hideSelectPopup();
    333333
    334334    m_lastMouseDownPoint = WebPoint(event.x, event.y);
     
    479479    m_suppressNextKeypressEvent = false;
    480480
     481    // Give any select popup a chance at consuming the key event.
     482    if (selectPopupHandleKeyEvent(event))
     483        return true;
     484
    481485    // Give Autocomplete a chance to consume the key events it is interested in.
    482486    if (autocompleteHandleKeyEvent(event))
     
    526530
    527531    return keyEventDefault(event);
     532}
     533
     534bool WebViewImpl::selectPopupHandleKeyEvent(const WebKeyboardEvent& event)
     535{
     536    if (!m_selectPopup)
     537        return false;
     538   
     539    return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
    528540}
    529541
     
    798810}
    799811
     812void WebViewImpl::hideSelectPopup()
     813{
     814    if (m_selectPopup.get())
     815        m_selectPopup->hidePopup();
     816}
     817
    800818bool WebViewImpl::propagateScroll(ScrollDirection scrollDirection,
    801819                                  ScrollGranularity scrollGranularity)
     
    815833    }
    816834    return scrollHandled;
     835}
     836
     837void  WebViewImpl::popupOpened(WebCore::PopupContainer* popupContainer)
     838{
     839    if (popupContainer->popupType() == WebCore::PopupContainer::Select) {
     840        ASSERT(!m_selectPopup);
     841        m_selectPopup = popupContainer;
     842    }
     843}
     844
     845void  WebViewImpl::popupClosed(WebCore::PopupContainer* popupContainer)
     846{
     847    if (popupContainer->popupType() == WebCore::PopupContainer::Select) {
     848        ASSERT(m_selectPopup.get());
     849        m_selectPopup = 0;
     850    }
    817851}
    818852
     
    10691103    } else {
    10701104        hideSuggestionsPopup();
     1105        hideSelectPopup();
    10711106
    10721107        // Clear focus on the currently focused frame if any.
     
    16971732    if (!m_autoFillPopup.get()) {
    16981733        m_autoFillPopup = PopupContainer::create(m_suggestionsPopupClient,
     1734                                                 PopupContainer::Suggestion,
    16991735                                                 suggestionsPopupSettings);
    17001736    }
     
    17521788    if (!m_autocompletePopup.get()) {
    17531789        m_autocompletePopup = PopupContainer::create(m_suggestionsPopupClient,
     1790                                                     PopupContainer::Suggestion,
    17541791                                                     suggestionsPopupSettings);
    17551792    }
  • trunk/WebKit/chromium/src/WebViewImpl.h

    r56416 r56449  
    293293    bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
    294294
     295    // Notification that a popup was opened/closed.
     296    void popupOpened(WebCore::PopupContainer* popupContainer);
     297    void popupClosed(WebCore::PopupContainer* popupContainer);
     298
    295299    // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can
    296300    // fix WebKit to pass enough information up into ChromeClient::show() so we
     
    316320    bool keyEventDefault(const WebKeyboardEvent&);
    317321
     322    // Returns true if the select popup has consumed the event.
     323    bool selectPopupHandleKeyEvent(const WebKeyboardEvent&);
     324
    318325    // Returns true if the autocomple has consumed the event.
    319326    bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
     
    326333    // Returns true if the view was scrolled.
    327334    bool scrollViewWithKeyboard(int keyCode, int modifiers);
     335
     336    // Hides the select popup if one is opened.
     337    void hideSelectPopup();
    328338
    329339    // Converts |pos| from window coordinates to contents coordinates and gets
     
    440450    WebCore::PopupContainer* m_suggestionsPopup;
    441451
     452    // The popup associated with a select element.
     453    RefPtr<WebCore::PopupContainer> m_selectPopup;
     454
    442455    // The AutoFill suggestions popup.
    443456    RefPtr<WebCore::PopupContainer> m_autoFillPopup;
Note: See TracChangeset for help on using the changeset viewer.