1/* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 3 * Copyright (C) 2010 Apple Inc. All rights reserved. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 * 20 */ 21 22#ifndef WebPopupMenu_h 23#define WebPopupMenu_h 24 25#include "WebPopupItem.h" 26#include <WebCore/PopupMenu.h> 27#include <wtf/Forward.h> 28#include <wtf/Vector.h> 29 30namespace WebCore { 31class PopupMenuClient; 32} 33 34namespace WebKit { 35 36class WebPage; 37struct PlatformPopupMenuData; 38struct WebPopupItem; 39 40class WebPopupMenu : public WebCore::PopupMenu { 41public: 42 static PassRefPtr<WebPopupMenu> create(WebPage*, WebCore::PopupMenuClient*); 43 ~WebPopupMenu(); 44 45 WebPage* page() { return m_page; } 46 47 void disconnectFromPage() { m_page = 0; } 48 void didChangeSelectedIndex(int newIndex); 49 void setTextForIndex(int newIndex); 50#if PLATFORM(GTK) 51 WebCore::PopupMenuClient* client() const { return m_popupClient; } 52#endif 53 54 virtual void show(const WebCore::IntRect&, WebCore::FrameView*, int index) override; 55 virtual void hide() override; 56 virtual void updateFromElement() override; 57 virtual void disconnectClient() override; 58 59private: 60 WebPopupMenu(WebPage*, WebCore::PopupMenuClient*); 61 62 Vector<WebPopupItem> populateItems(); 63 void setUpPlatformData(const WebCore::IntRect& pageCoordinates, PlatformPopupMenuData&); 64 65 WebCore::PopupMenuClient* m_popupClient; 66 WebPage* m_page; 67}; 68 69} // namespace WebKit 70 71#endif // WebPopupMenu_h 72