#define PopupListBox_h
#include "core/dom/Element.h"
-#include "platform/scroll/FramelessScrollView.h"
+#include "platform/scroll/ScrollTypes.h"
+#include "platform/scroll/ScrollView.h"
#include "platform/text/TextDirection.h"
#include "wtf/text/WTFString.h"
class PlatformGestureEvent;
class PlatformTouchEvent;
class PlatformWheelEvent;
+class PopupContainer;
class PopupMenuClient;
typedef unsigned long long TimeStamp;
bool displayNone;
};
-// This class uses WebCore code to paint and handle events for a drop-down list
-// box ("combobox" on Windows).
-class PopupListBox FINAL : public FramelessScrollView, public PopupContent {
+// This class manages the scrollable content inside a <select> popup.
+class PopupListBox FINAL : public Widget, public ScrollableArea, public PopupContent {
public:
- static PassRefPtr<PopupListBox> create(PopupMenuClient* client, bool deviceSupportsTouch)
+ static PassRefPtr<PopupListBox> create(PopupMenuClient* client, bool deviceSupportsTouch, PopupContainer* container)
{
- return adoptRef(new PopupListBox(client, deviceSupportsTouch));
+ return adoptRef(new PopupListBox(client, deviceSupportsTouch, container));
}
- // FramelessScrollView
+ // Widget
+ virtual void invalidateRect(const IntRect&) OVERRIDE;
virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
- virtual bool handleMouseDownEvent(const PlatformMouseEvent&) OVERRIDE;
- virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) OVERRIDE;
- virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) OVERRIDE;
- virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
- virtual bool handleKeyEvent(const PlatformKeyboardEvent&) OVERRIDE;
- virtual bool handleTouchEvent(const PlatformTouchEvent&) OVERRIDE;
- virtual bool handleGestureEvent(const PlatformGestureEvent&) OVERRIDE;
-
- // ScrollView
virtual HostWindow* hostWindow() const OVERRIDE;
+ virtual void setFrameRect(const IntRect&) OVERRIDE;
+ virtual IntPoint convertChildToSelf(const Widget* child, const IntPoint&) const OVERRIDE;
+ virtual IntPoint convertSelfToChild(const Widget* child, const IntPoint&) const OVERRIDE;
+
+ // ScrollableArea
+ virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
+ virtual bool isActive() const OVERRIDE;
+ virtual bool scrollbarsCanBeActive() const OVERRIDE;
+ virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE;
+ virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
+ virtual void setScrollOffset(const IntPoint&) OVERRIDE;
+ virtual bool isScrollCornerVisible() const OVERRIDE { return false; }
+ virtual bool userInputScrollable(ScrollbarOrientation orientation) const OVERRIDE { return orientation == VerticalScrollbar; }
+ virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_verticalScrollbar.get(); }
+ virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) const OVERRIDE;
+ virtual IntSize contentsSize() const OVERRIDE { return m_contentsSize; }
+ virtual IntPoint scrollPosition() const OVERRIDE { return visibleContentRect().location(); }
+ virtual IntPoint maximumScrollPosition() const OVERRIDE; // The maximum position we can be scrolled to.
+ virtual IntPoint minimumScrollPosition() const OVERRIDE; // The minimum position we can be scrolled to.
+ virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); }
// PopupListBox methods
+ bool handleMouseDownEvent(const PlatformMouseEvent&);
+ bool handleMouseMoveEvent(const PlatformMouseEvent&);
+ bool handleMouseReleaseEvent(const PlatformMouseEvent&);
+ bool handleWheelEvent(const PlatformWheelEvent&);
+ bool handleKeyEvent(const PlatformKeyboardEvent&);
+ bool handleTouchEvent(const PlatformTouchEvent&);
+ bool handleGestureEvent(const PlatformGestureEvent&);
+
// Closes the popup
void abandon();
bool isInterestedInEventForKey(int keyCode);
// Gets the height of a row.
- int getRowHeight(int index);
+ int getRowHeight(int index) const;
int getRowBaseWidth(int index);
static const int defaultMaxHeight;
+protected:
+ virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { }
+
private:
friend class PopupContainer;
friend class RefCounted<PopupListBox>;
- PopupListBox(PopupMenuClient*, bool deviceSupportsTouch);
-
- virtual ~PopupListBox()
- {
- clear();
- }
+ PopupListBox(PopupMenuClient*, bool deviceSupportsTouch, PopupContainer*);
+ virtual ~PopupListBox();
// Hides the popup. Other classes should not call this. Use abandon instead.
void hidePopup();
void typeAheadFind(const PlatformKeyboardEvent&);
// Returns the font to use for the given row
- Font getRowFont(int index);
+ Font getRowFont(int index) const;
// Moves the selection down/up one item, taking care of looping back to the
// first/last element if m_loopSelectionNavigation is true.
void selectPreviousRow();
void selectNextRow();
+ int scrollX() const { return scrollPosition().x(); }
+ int scrollY() const { return scrollPosition().y(); }
+ void updateScrollbars(const IntPoint& desiredOffset);
+ void setHasVerticalScrollbar(bool);
+ Scrollbar* scrollbarAtWindowPoint(const IntPoint& windowPoint);
+ IntRect contentsToWindow(const IntRect&) const;
+ void setContentsSize(const IntSize&);
+ void adjustScrollbarExistence();
+ void updateScrollbarGeometry();
+ IntRect windowClipRect() const;
+
// If the device is a touch screen we increase the height of menu items
// to make it easier to unambiguously touch them.
bool m_deviceSupportsTouch;
// To forward last mouse release event.
RefPtrWillBePersistent<Element> m_focusedElement;
+
+ PopupContainer* m_container;
+
+ RefPtr<Scrollbar> m_verticalScrollbar;
+ IntSize m_contentsSize;
+ IntPoint m_scrollOffset;
};
} // namespace blink