| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef PopupContainer_h | 31 #ifndef PopupContainer_h |
| 32 #define PopupContainer_h | 32 #define PopupContainer_h |
| 33 | 33 |
| 34 #include "platform/PopupMenuStyle.h" | 34 #include "platform/PopupMenuStyle.h" |
| 35 #include "platform/geometry/FloatQuad.h" | 35 #include "platform/geometry/FloatQuad.h" |
| 36 #include "platform/scroll/FramelessScrollView.h" | 36 #include "platform/scroll/FramelessScrollView.h" |
| 37 #include "web/PopupListBox.h" | 37 #include "web/PopupListBox.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace blink { |
| 40 class ChromeClient; | 40 class ChromeClient; |
| 41 class FrameView; | 41 class FrameView; |
| 42 class PopupMenuClient; | 42 class PopupMenuClient; |
| 43 } | 43 } |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 struct WebPopupMenuInfo; | 47 struct WebPopupMenuInfo; |
| 48 | 48 |
| 49 class PopupContainer FINAL : public WebCore::FramelessScrollView { | 49 class PopupContainer FINAL : public blink::FramelessScrollView { |
| 50 public: | 50 public: |
| 51 static PassRefPtr<PopupContainer> create(WebCore::PopupMenuClient*, bool dev
iceSupportsTouch); | 51 static PassRefPtr<PopupContainer> create(blink::PopupMenuClient*, bool devic
eSupportsTouch); |
| 52 | 52 |
| 53 // Whether a key event should be sent to this popup. | 53 // Whether a key event should be sent to this popup. |
| 54 bool isInterestedInEventForKey(int keyCode); | 54 bool isInterestedInEventForKey(int keyCode); |
| 55 | 55 |
| 56 // FramelessScrollView | 56 // FramelessScrollView |
| 57 virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&) OVERR
IDE; | 57 virtual void paint(blink::GraphicsContext*, const blink::IntRect&) OVERRIDE; |
| 58 virtual void hide() OVERRIDE; | 58 virtual void hide() OVERRIDE; |
| 59 virtual bool handleMouseDownEvent(const WebCore::PlatformMouseEvent&) OVERRI
DE; | 59 virtual bool handleMouseDownEvent(const blink::PlatformMouseEvent&) OVERRIDE
; |
| 60 virtual bool handleMouseMoveEvent(const WebCore::PlatformMouseEvent&) OVERRI
DE; | 60 virtual bool handleMouseMoveEvent(const blink::PlatformMouseEvent&) OVERRIDE
; |
| 61 virtual bool handleMouseReleaseEvent(const WebCore::PlatformMouseEvent&) OVE
RRIDE; | 61 virtual bool handleMouseReleaseEvent(const blink::PlatformMouseEvent&) OVERR
IDE; |
| 62 virtual bool handleWheelEvent(const WebCore::PlatformWheelEvent&) OVERRIDE; | 62 virtual bool handleWheelEvent(const blink::PlatformWheelEvent&) OVERRIDE; |
| 63 virtual bool handleKeyEvent(const WebCore::PlatformKeyboardEvent&) OVERRIDE; | 63 virtual bool handleKeyEvent(const blink::PlatformKeyboardEvent&) OVERRIDE; |
| 64 virtual bool handleTouchEvent(const WebCore::PlatformTouchEvent&) OVERRIDE; | 64 virtual bool handleTouchEvent(const blink::PlatformTouchEvent&) OVERRIDE; |
| 65 virtual bool handleGestureEvent(const WebCore::PlatformGestureEvent&) OVERRI
DE; | 65 virtual bool handleGestureEvent(const blink::PlatformGestureEvent&) OVERRIDE
; |
| 66 | 66 |
| 67 // PopupContainer methods | 67 // PopupContainer methods |
| 68 | 68 |
| 69 // Show the popup | 69 // Show the popup |
| 70 void showPopup(WebCore::FrameView*); | 70 void showPopup(blink::FrameView*); |
| 71 | 71 |
| 72 // Show the popup in the specified rect for the specified frame. | 72 // Show the popup in the specified rect for the specified frame. |
| 73 // Note: this code was somehow arbitrarily factored-out of the Popup class | 73 // Note: this code was somehow arbitrarily factored-out of the Popup class |
| 74 // so WebViewImpl can create a PopupContainer. This method is used for | 74 // so WebViewImpl can create a PopupContainer. This method is used for |
| 75 // displaying auto complete popup menus on Mac Chromium, and for all | 75 // displaying auto complete popup menus on Mac Chromium, and for all |
| 76 // popups on other platforms. | 76 // popups on other platforms. |
| 77 void showInRect(const WebCore::FloatQuad& controlPosition, const WebCore::In
tSize& controlSize, WebCore::FrameView*, int index); | 77 void showInRect(const blink::FloatQuad& controlPosition, const blink::IntSiz
e& controlSize, blink::FrameView*, int index); |
| 78 | 78 |
| 79 // Hides the popup. | 79 // Hides the popup. |
| 80 void hidePopup(); | 80 void hidePopup(); |
| 81 | 81 |
| 82 // The popup was hidden. | 82 // The popup was hidden. |
| 83 void notifyPopupHidden(); | 83 void notifyPopupHidden(); |
| 84 | 84 |
| 85 PopupListBox* listBox() const { return m_listBox.get(); } | 85 PopupListBox* listBox() const { return m_listBox.get(); } |
| 86 | 86 |
| 87 bool isRTL() const; | 87 bool isRTL() const; |
| 88 | 88 |
| 89 // Gets the index of the item that the user is currently moused-over or | 89 // Gets the index of the item that the user is currently moused-over or |
| 90 // has selected with the keyboard up/down arrows. | 90 // has selected with the keyboard up/down arrows. |
| 91 int selectedIndex() const; | 91 int selectedIndex() const; |
| 92 | 92 |
| 93 // Refresh the popup values from the PopupMenuClient. | 93 // Refresh the popup values from the PopupMenuClient. |
| 94 WebCore::IntRect refresh(const WebCore::IntRect& targetControlRect); | 94 blink::IntRect refresh(const blink::IntRect& targetControlRect); |
| 95 | 95 |
| 96 // The menu per-item data. | 96 // The menu per-item data. |
| 97 const Vector<PopupItem*>& popupData() const; | 97 const Vector<PopupItem*>& popupData() const; |
| 98 | 98 |
| 99 // The height of a row in the menu. | 99 // The height of a row in the menu. |
| 100 int menuItemHeight() const; | 100 int menuItemHeight() const; |
| 101 | 101 |
| 102 // The size of the font being used. | 102 // The size of the font being used. |
| 103 int menuItemFontSize() const; | 103 int menuItemFontSize() const; |
| 104 | 104 |
| 105 // The style of the menu being used. | 105 // The style of the menu being used. |
| 106 WebCore::PopupMenuStyle menuStyle() const; | 106 blink::PopupMenuStyle menuStyle() const; |
| 107 | 107 |
| 108 // While hovering popup menu window, we want to show tool tip message. | 108 // While hovering popup menu window, we want to show tool tip message. |
| 109 String getSelectedItemToolTip(); | 109 String getSelectedItemToolTip(); |
| 110 | 110 |
| 111 // This is public for testing. | 111 // This is public for testing. |
| 112 static WebCore::IntRect layoutAndCalculateWidgetRectInternal(WebCore::IntRec
t widgetRectInScreen, int targetControlHeight, const WebCore::FloatRect& windowR
ect, const WebCore::FloatRect& screen, bool isRTL, const int rtlOffset, const in
t verticalOffset, const WebCore::IntSize& transformOffset, PopupContent*, bool&
needToResizeView); | 112 static blink::IntRect layoutAndCalculateWidgetRectInternal(blink::IntRect wi
dgetRectInScreen, int targetControlHeight, const blink::FloatRect& windowRect, c
onst blink::FloatRect& screen, bool isRTL, const int rtlOffset, const int vertic
alOffset, const blink::IntSize& transformOffset, PopupContent*, bool& needToResi
zeView); |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 friend class WTF::RefCounted<PopupContainer>; | 115 friend class WTF::RefCounted<PopupContainer>; |
| 116 | 116 |
| 117 PopupContainer(WebCore::PopupMenuClient*, bool deviceSupportsTouch); | 117 PopupContainer(blink::PopupMenuClient*, bool deviceSupportsTouch); |
| 118 virtual ~PopupContainer(); | 118 virtual ~PopupContainer(); |
| 119 | 119 |
| 120 // Paint the border. | 120 // Paint the border. |
| 121 void paintBorder(WebCore::GraphicsContext*, const WebCore::IntRect&); | 121 void paintBorder(blink::GraphicsContext*, const blink::IntRect&); |
| 122 | 122 |
| 123 // Layout and calculate popup widget size and location and returns it as Int
Rect. | 123 // Layout and calculate popup widget size and location and returns it as Int
Rect. |
| 124 WebCore::IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const
WebCore::IntSize& transformOffset, const WebCore::IntPoint& popupInitialCoordin
ate); | 124 blink::IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const b
link::IntSize& transformOffset, const blink::IntPoint& popupInitialCoordinate); |
| 125 | 125 |
| 126 void fitToListBox(); | 126 void fitToListBox(); |
| 127 | 127 |
| 128 void popupOpened(const WebCore::IntRect& bounds); | 128 void popupOpened(const blink::IntRect& bounds); |
| 129 void getPopupMenuInfo(WebPopupMenuInfo*); | 129 void getPopupMenuInfo(WebPopupMenuInfo*); |
| 130 | 130 |
| 131 // Returns the ChromeClient of the page this popup is associated with. | 131 // Returns the ChromeClient of the page this popup is associated with. |
| 132 WebCore::ChromeClient& chromeClient(); | 132 blink::ChromeClient& chromeClient(); |
| 133 | 133 |
| 134 RefPtr<PopupListBox> m_listBox; | 134 RefPtr<PopupListBox> m_listBox; |
| 135 RefPtr<WebCore::FrameView> m_frameView; | 135 RefPtr<blink::FrameView> m_frameView; |
| 136 | 136 |
| 137 // m_controlPosition contains the transformed position of the | 137 // m_controlPosition contains the transformed position of the |
| 138 // <select>/<input> associated with this popup. m_controlSize is the size | 138 // <select>/<input> associated with this popup. m_controlSize is the size |
| 139 // of the <select>/<input> without transform. | 139 // of the <select>/<input> without transform. |
| 140 // The popup menu will be positioned as follows: | 140 // The popup menu will be positioned as follows: |
| 141 // LTR : If the popup is positioned down it will align with the bottom left | 141 // LTR : If the popup is positioned down it will align with the bottom left |
| 142 // of m_controlPosition (p4) | 142 // of m_controlPosition (p4) |
| 143 // If the popup is positioned up it will align with the top left of | 143 // If the popup is positioned up it will align with the top left of |
| 144 // m_controlPosition (p1) | 144 // m_controlPosition (p1) |
| 145 // RTL : If the popup is positioned down it will align with the bottom right | 145 // RTL : If the popup is positioned down it will align with the bottom right |
| 146 // of m_controlPosition (p3) | 146 // of m_controlPosition (p3) |
| 147 // If the popup is positioned up it will align with the top right of | 147 // If the popup is positioned up it will align with the top right of |
| 148 // m_controlPosition (p2) | 148 // m_controlPosition (p2) |
| 149 WebCore::FloatQuad m_controlPosition; | 149 blink::FloatQuad m_controlPosition; |
| 150 WebCore::IntSize m_controlSize; | 150 blink::IntSize m_controlSize; |
| 151 | 151 |
| 152 // Whether the popup is currently open. | 152 // Whether the popup is currently open. |
| 153 bool m_popupOpen; | 153 bool m_popupOpen; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 } // namespace WebCore | 156 } // namespace blink |
| 157 | 157 |
| 158 #endif | 158 #endif |
| OLD | NEW |