~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/chromium/PopupContainer.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2011, Google Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are
 
6
 * met:
 
7
 *
 
8
 *     * Redistributions of source code must retain the above copyright
 
9
 * notice, this list of conditions and the following disclaimer.
 
10
 *     * Redistributions in binary form must reproduce the above
 
11
 * copyright notice, this list of conditions and the following disclaimer
 
12
 * in the documentation and/or other materials provided with the
 
13
 * distribution.
 
14
 *     * Neither the name of Google Inc. nor the names of its
 
15
 * contributors may be used to endorse or promote products derived from
 
16
 * this software without specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 */
 
30
 
 
31
#ifndef PopupContainer_h
 
32
#define PopupContainer_h
 
33
 
 
34
#include "FramelessScrollView.h"
 
35
#include "PopupListBox.h"
 
36
#include "PopupMenuStyle.h"
 
37
 
 
38
namespace WebCore {
 
39
 
 
40
class ChromeClientChromium;
 
41
class FrameView;
 
42
class PopupMenuClient;
 
43
 
 
44
class PopupContainer : public FramelessScrollView {
 
45
public:
 
46
    enum PopupType {
 
47
        Select, // HTML select popup.
 
48
        Suggestion, // Autocomplete/autofill popup.
 
49
    };
 
50
 
 
51
    static PassRefPtr<PopupContainer> create(PopupMenuClient*, PopupType,
 
52
                                             const PopupContainerSettings&);
 
53
 
 
54
    // Whether a key event should be sent to this popup.
 
55
    virtual bool isInterestedInEventForKey(int keyCode);
 
56
 
 
57
    // FramelessScrollView
 
58
    virtual void paint(GraphicsContext*, const IntRect&);
 
59
    virtual void hide();
 
60
    virtual bool handleMouseDownEvent(const PlatformMouseEvent&);
 
61
    virtual bool handleMouseMoveEvent(const PlatformMouseEvent&);
 
62
    virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&);
 
63
    virtual bool handleWheelEvent(const PlatformWheelEvent&);
 
64
    virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
 
65
#if ENABLE(TOUCH_EVENTS)
 
66
    virtual bool handleTouchEvent(const PlatformTouchEvent&);
 
67
#endif
 
68
#if ENABLE(GESTURE_EVENTS)
 
69
    virtual bool handleGestureEvent(const PlatformGestureEvent&);
 
70
#endif
 
71
 
 
72
    // PopupContainer methods
 
73
 
 
74
    // Show the popup
 
75
    void showPopup(FrameView*);
 
76
 
 
77
    // Show the popup in the specified rect for the specified frame.
 
78
    // Note: this code was somehow arbitrarily factored-out of the Popup class
 
79
    // so WebViewImpl can create a PopupContainer. This method is used for
 
80
    // displaying auto complete popup menus on Mac Chromium, and for all
 
81
    // popups on other platforms.
 
82
    void showInRect(const IntRect&, FrameView*, int index);
 
83
 
 
84
    // Hides the popup.
 
85
    void hidePopup();
 
86
 
 
87
    // The popup was hidden.
 
88
    void notifyPopupHidden();
 
89
 
 
90
    // Compute size of widget and children. Return right offset for the popup right alignment.
 
91
    int layoutAndGetRTLOffset();
 
92
 
 
93
    PopupListBox* listBox() const { return m_listBox.get(); }
 
94
 
 
95
    bool isRTL() const;
 
96
 
 
97
    // Gets the index of the item that the user is currently moused-over or
 
98
    // has selected with the keyboard up/down arrows.
 
99
    int selectedIndex() const;
 
100
 
 
101
    // Refresh the popup values from the PopupMenuClient.
 
102
    IntRect refresh(const IntRect& targetControlRect);
 
103
 
 
104
    // The menu per-item data.
 
105
    const WTF::Vector<PopupItem*>& popupData() const;
 
106
 
 
107
    // The height of a row in the menu.
 
108
    int menuItemHeight() const;
 
109
 
 
110
    // The size of the font being used.
 
111
    int menuItemFontSize() const;
 
112
 
 
113
    // The style of the menu being used.
 
114
    PopupMenuStyle menuStyle() const;
 
115
 
 
116
    PopupType popupType() const { return m_popupType; }
 
117
 
 
118
    // While hovering popup menu window, we want to show tool tip message.
 
119
    String getSelectedItemToolTip();
 
120
 
 
121
    // This is public for testing.
 
122
    static IntRect layoutAndCalculateWidgetRectInternal(IntRect widgetRectInScreen, int targetControlHeight, const FloatRect& windowRect, const FloatRect& screen, bool isRTL, const int rtlOffset, PopupContent*, bool& needToResizeView);
 
123
 
 
124
 
 
125
private:
 
126
    friend class WTF::RefCounted<PopupContainer>;
 
127
 
 
128
    PopupContainer(PopupMenuClient*, PopupType, const PopupContainerSettings&);
 
129
    ~PopupContainer();
 
130
 
 
131
    // Paint the border.
 
132
    void paintBorder(GraphicsContext*, const IntRect&);
 
133
 
 
134
    // Layout and calculate popup widget size and location and returns it as IntRect.
 
135
    IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate);
 
136
 
 
137
    void fitToListBox();
 
138
 
 
139
    // Returns the ChromeClient of the page this popup is associated with.
 
140
    ChromeClientChromium* chromeClientChromium();
 
141
 
 
142
    RefPtr<PopupListBox> m_listBox;
 
143
    RefPtr<FrameView> m_frameView;
 
144
 
 
145
    PopupContainerSettings m_settings;
 
146
    PopupType m_popupType;
 
147
 
 
148
    // This contains the "ideal" dimensions and position for the popup
 
149
    // (PopupContainer's frameRect() location should always be (0, 0), since
 
150
    // it is rendered inside (and relative to) a WebWidget, which should get
 
151
    // the actual popup position through chromeClientChromium()).
 
152
    IntRect m_originalFrameRect;
 
153
 
 
154
    // Whether the popup is currently open.
 
155
    bool m_popupOpen;
 
156
};
 
157
 
 
158
} // namespace WebCore
 
159
 
 
160
#endif