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