1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
4 * Copyright (C) 2009-2010 ProFUSION embedded systems
5 * Copyright (C) 2009-2010 Samsung Electronics
6 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25 #include "config.h"
26 #include "PopupMenuEfl.h"
27
28 #include "Chrome.h"
29 #include "ChromeClientEfl.h"
30 #include "FrameView.h"
31 #include "NotImplemented.h"
32 #include "PopupMenuClient.h"
33
34 namespace WebCore {
35
PopupMenuEfl(PopupMenuClient * client)36 PopupMenuEfl::PopupMenuEfl(PopupMenuClient* client)
37 : m_popupClient(client)
38 , m_view(0)
39 {
40 }
41
~PopupMenuEfl()42 PopupMenuEfl::~PopupMenuEfl()
43 {
44 // Tell client to destroy data related to this popup since this object is
45 // going away.
46 if (m_view)
47 hide();
48 }
49
show(const IntRect & rect,FrameView * view,int index)50 void PopupMenuEfl::show(const IntRect& rect, FrameView* view, int index)
51 {
52 ASSERT(m_popupClient);
53 ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(view->frame()->page()->chrome()->client());
54 ASSERT(chromeClient);
55
56 m_view = view;
57 chromeClient->createSelectPopup(m_popupClient, index, rect);
58 }
59
hide()60 void PopupMenuEfl::hide()
61 {
62 ASSERT(m_view);
63 ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(m_view->frame()->page()->chrome()->client());
64 ASSERT(chromeClient);
65
66 chromeClient->destroySelectPopup();
67 }
68
updateFromElement()69 void PopupMenuEfl::updateFromElement()
70 {
71 client()->setTextFromItem(client()->selectedIndex());
72 }
73
disconnectClient()74 void PopupMenuEfl::disconnectClient()
75 {
76 m_popupClient = 0;
77 }
78
79 }
80