initial import
[vuplus_webkit] / Source / WebCore / platform / efl / PopupMenuEfl.cpp
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 "Frame.h"
31 #include "FrameView.h"
32 #include "NotImplemented.h"
33 #include "Page.h"
34 #include "PopupMenuClient.h"
35
36 namespace WebCore {
37
38 PopupMenuEfl::PopupMenuEfl(PopupMenuClient* client)
39     : m_popupClient(client)
40     , m_view(0)
41 {
42 }
43
44 PopupMenuEfl::~PopupMenuEfl()
45 {
46     // Tell client to destroy data related to this popup since this object is
47     // going away.
48     if (m_view)
49         hide();
50 }
51
52 void PopupMenuEfl::show(const IntRect& rect, FrameView* view, int index)
53 {
54     ASSERT(m_popupClient);
55     ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(view->frame()->page()->chrome()->client());
56     ASSERT(chromeClient);
57
58     m_view = view;
59     chromeClient->createSelectPopup(m_popupClient, index, rect);
60 }
61
62 void PopupMenuEfl::hide()
63 {
64     ASSERT(m_view);
65     ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(m_view->frame()->page()->chrome()->client());
66     ASSERT(chromeClient);
67
68     chromeClient->destroySelectPopup();
69 }
70
71 void PopupMenuEfl::updateFromElement()
72 {
73     client()->setTextFromItem(client()->selectedIndex());
74 }
75
76 void PopupMenuEfl::disconnectClient()
77 {
78     m_popupClient = 0;
79 }
80
81 }