| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 String label; | 78 String label; |
| 79 Type type; | 79 Type type; |
| 80 int yOffset; // y offset of this item, relative to the top of the popup. | 80 int yOffset; // y offset of this item, relative to the top of the popup. |
| 81 TextDirection textDirection; | 81 TextDirection textDirection; |
| 82 bool hasTextDirectionOverride; | 82 bool hasTextDirectionOverride; |
| 83 bool enabled; | 83 bool enabled; |
| 84 bool displayNone; | 84 bool displayNone; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 // This class manages the scrollable content inside a <select> popup. | 87 // This class manages the scrollable content inside a <select> popup. |
| 88 class PopupListBox FINAL : public Widget, public ScrollableArea, public PopupCon
tent { | 88 class PopupListBox final : public Widget, public ScrollableArea, public PopupCon
tent { |
| 89 public: | 89 public: |
| 90 static PassRefPtr<PopupListBox> create(PopupMenuClient* client, bool deviceS
upportsTouch, PopupContainer* container) | 90 static PassRefPtr<PopupListBox> create(PopupMenuClient* client, bool deviceS
upportsTouch, PopupContainer* container) |
| 91 { | 91 { |
| 92 return adoptRef(new PopupListBox(client, deviceSupportsTouch, container)
); | 92 return adoptRef(new PopupListBox(client, deviceSupportsTouch, container)
); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Widget | 95 // Widget |
| 96 virtual void invalidateRect(const IntRect&) OVERRIDE; | 96 virtual void invalidateRect(const IntRect&) override; |
| 97 virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE; | 97 virtual void paint(GraphicsContext*, const IntRect&) override; |
| 98 virtual HostWindow* hostWindow() const OVERRIDE; | 98 virtual HostWindow* hostWindow() const override; |
| 99 virtual void setFrameRect(const IntRect&) OVERRIDE; | 99 virtual void setFrameRect(const IntRect&) override; |
| 100 virtual IntPoint convertChildToSelf(const Widget* child, const IntPoint&) co
nst OVERRIDE; | 100 virtual IntPoint convertChildToSelf(const Widget* child, const IntPoint&) co
nst override; |
| 101 virtual IntPoint convertSelfToChild(const Widget* child, const IntPoint&) co
nst OVERRIDE; | 101 virtual IntPoint convertSelfToChild(const Widget* child, const IntPoint&) co
nst override; |
| 102 | 102 |
| 103 // ScrollableArea | 103 // ScrollableArea |
| 104 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE; | 104 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; |
| 105 virtual bool isActive() const OVERRIDE; | 105 virtual bool isActive() const override; |
| 106 virtual bool scrollbarsCanBeActive() const OVERRIDE; | 106 virtual bool scrollbarsCanBeActive() const override; |
| 107 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; | 107 virtual IntRect scrollableAreaBoundingBox() const override; |
| 108 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE; | 108 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override; |
| 109 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE; | 109 virtual int scrollSize(ScrollbarOrientation) const override; |
| 110 virtual void setScrollOffset(const IntPoint&) OVERRIDE; | 110 virtual void setScrollOffset(const IntPoint&) override; |
| 111 virtual bool isScrollCornerVisible() const OVERRIDE { return false; } | 111 virtual bool isScrollCornerVisible() const override { return false; } |
| 112 virtual bool userInputScrollable(ScrollbarOrientation orientation) const OVE
RRIDE { return orientation == VerticalScrollbar; } | 112 virtual bool userInputScrollable(ScrollbarOrientation orientation) const ove
rride { return orientation == VerticalScrollbar; } |
| 113 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_verticalScr
ollbar.get(); } | 113 virtual Scrollbar* verticalScrollbar() const override { return m_verticalScr
ollbar.get(); } |
| 114 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba
rs) const OVERRIDE; | 114 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba
rs) const override; |
| 115 virtual IntSize contentsSize() const OVERRIDE { return m_contentsSize; } | 115 virtual IntSize contentsSize() const override { return m_contentsSize; } |
| 116 virtual IntPoint scrollPosition() const OVERRIDE { return visibleContentRect
().location(); } | 116 virtual IntPoint scrollPosition() const override { return visibleContentRect
().location(); } |
| 117 virtual IntPoint maximumScrollPosition() const OVERRIDE; // The maximum posi
tion we can be scrolled to. | 117 virtual IntPoint maximumScrollPosition() const override; // The maximum posi
tion we can be scrolled to. |
| 118 virtual IntPoint minimumScrollPosition() const OVERRIDE; // The minimum posi
tion we can be scrolled to. | 118 virtual IntPoint minimumScrollPosition() const override; // The minimum posi
tion we can be scrolled to. |
| 119 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); } | 119 virtual IntRect scrollCornerRect() const override { return IntRect(); } |
| 120 | 120 |
| 121 // PopupListBox methods | 121 // PopupListBox methods |
| 122 | 122 |
| 123 bool handleMouseDownEvent(const PlatformMouseEvent&); | 123 bool handleMouseDownEvent(const PlatformMouseEvent&); |
| 124 bool handleMouseMoveEvent(const PlatformMouseEvent&); | 124 bool handleMouseMoveEvent(const PlatformMouseEvent&); |
| 125 bool handleMouseReleaseEvent(const PlatformMouseEvent&); | 125 bool handleMouseReleaseEvent(const PlatformMouseEvent&); |
| 126 bool handleWheelEvent(const PlatformWheelEvent&); | 126 bool handleWheelEvent(const PlatformWheelEvent&); |
| 127 bool handleKeyEvent(const PlatformKeyboardEvent&); | 127 bool handleKeyEvent(const PlatformKeyboardEvent&); |
| 128 bool handleTouchEvent(const PlatformTouchEvent&); | 128 bool handleTouchEvent(const PlatformTouchEvent&); |
| 129 bool handleGestureEvent(const PlatformGestureEvent&); | 129 bool handleGestureEvent(const PlatformGestureEvent&); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 149 // Positive is down. The resulting index will be clamped to the range | 149 // Positive is down. The resulting index will be clamped to the range |
| 150 // [0, numItems), and non-option items will be skipped. | 150 // [0, numItems), and non-option items will be skipped. |
| 151 void adjustSelectedIndex(int delta); | 151 void adjustSelectedIndex(int delta); |
| 152 | 152 |
| 153 // Returns the number of items in the list. | 153 // Returns the number of items in the list. |
| 154 int numItems() const { return static_cast<int>(m_items.size()); } | 154 int numItems() const { return static_cast<int>(m_items.size()); } |
| 155 | 155 |
| 156 void setBaseWidth(int width) { m_baseWidth = std::min(m_maxWindowWidth, widt
h); } | 156 void setBaseWidth(int width) { m_baseWidth = std::min(m_maxWindowWidth, widt
h); } |
| 157 | 157 |
| 158 // Computes the size of widget and children. | 158 // Computes the size of widget and children. |
| 159 virtual void layout() OVERRIDE; | 159 virtual void layout() override; |
| 160 | 160 |
| 161 // Returns whether the popup wants to process events for the passed key. | 161 // Returns whether the popup wants to process events for the passed key. |
| 162 bool isInterestedInEventForKey(int keyCode); | 162 bool isInterestedInEventForKey(int keyCode); |
| 163 | 163 |
| 164 // Gets the height of a row. | 164 // Gets the height of a row. |
| 165 int getRowHeight(int index) const; | 165 int getRowHeight(int index) const; |
| 166 | 166 |
| 167 int getRowBaseWidth(int index); | 167 int getRowBaseWidth(int index); |
| 168 | 168 |
| 169 virtual void setMaxHeight(int maxHeight) OVERRIDE { m_maxHeight = maxHeight;
} | 169 virtual void setMaxHeight(int maxHeight) override { m_maxHeight = maxHeight;
} |
| 170 | 170 |
| 171 void setMaxWidth(int maxWidth) { m_maxWindowWidth = maxWidth; } | 171 void setMaxWidth(int maxWidth) { m_maxWindowWidth = maxWidth; } |
| 172 | 172 |
| 173 virtual void setMaxWidthAndLayout(int) OVERRIDE; | 173 virtual void setMaxWidthAndLayout(int) override; |
| 174 | 174 |
| 175 void disconnectClient() { m_popupClient = 0; } | 175 void disconnectClient() { m_popupClient = 0; } |
| 176 | 176 |
| 177 const Vector<PopupItem*>& items() const { return m_items; } | 177 const Vector<PopupItem*>& items() const { return m_items; } |
| 178 | 178 |
| 179 virtual int popupContentHeight() const OVERRIDE; | 179 virtual int popupContentHeight() const override; |
| 180 | 180 |
| 181 static const int defaultMaxHeight; | 181 static const int defaultMaxHeight; |
| 182 | 182 |
| 183 protected: | 183 protected: |
| 184 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { } | 184 virtual void invalidateScrollCornerRect(const IntRect&) override { } |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 friend class PopupContainer; | 187 friend class PopupContainer; |
| 188 friend class RefCounted<PopupListBox>; | 188 friend class RefCounted<PopupListBox>; |
| 189 | 189 |
| 190 PopupListBox(PopupMenuClient*, bool deviceSupportsTouch, PopupContainer*); | 190 PopupListBox(PopupMenuClient*, bool deviceSupportsTouch, PopupContainer*); |
| 191 virtual ~PopupListBox(); | 191 virtual ~PopupListBox(); |
| 192 | 192 |
| 193 // Hides the popup. Other classes should not call this. Use abandon instead. | 193 // Hides the popup. Other classes should not call this. Use abandon instead. |
| 194 void hidePopup(); | 194 void hidePopup(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 PopupContainer* m_container; | 310 PopupContainer* m_container; |
| 311 | 311 |
| 312 RefPtr<Scrollbar> m_verticalScrollbar; | 312 RefPtr<Scrollbar> m_verticalScrollbar; |
| 313 IntSize m_contentsSize; | 313 IntSize m_contentsSize; |
| 314 IntPoint m_scrollOffset; | 314 IntPoint m_scrollOffset; |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 } // namespace blink | 317 } // namespace blink |
| 318 | 318 |
| 319 #endif | 319 #endif |
| OLD | NEW |