OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 { | 57 { |
58 } | 58 } |
59 | 59 |
60 ExternalPopupMenu::~ExternalPopupMenu() | 60 ExternalPopupMenu::~ExternalPopupMenu() |
61 { | 61 { |
62 } | 62 } |
63 | 63 |
64 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i
nt index) | 64 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i
nt index) |
65 { | 65 { |
66 IntRect rect(controlPosition.enclosingBoundingBox()); | 66 IntRect rect(controlPosition.enclosingBoundingBox()); |
67 // WebCore reuses the PopupMenu of a page. | 67 // WebCore reuses the PopupMenu of an element. |
68 // For simplicity, we do recreate the actual external popup everytime. | 68 // For simplicity, we do recreate the actual external popup everytime. |
69 hide(); | 69 if (m_webExternalPopupMenu) { |
| 70 m_webExternalPopupMenu->close(); |
| 71 m_webExternalPopupMenu = 0; |
| 72 } |
70 | 73 |
71 WebPopupMenuInfo info; | 74 WebPopupMenuInfo info; |
72 getPopupMenuInfo(&info); | 75 getPopupMenuInfo(&info); |
73 if (info.items.isEmpty()) | 76 if (info.items.isEmpty()) |
74 return; | 77 return; |
75 m_webExternalPopupMenu = m_webView.client()->createExternalPopupMenu(info, t
his); | 78 m_webExternalPopupMenu = m_webView.client()->createExternalPopupMenu(info, t
his); |
76 if (m_webExternalPopupMenu) { | 79 if (m_webExternalPopupMenu) { |
77 m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect)); | 80 m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect)); |
78 #if OS(MACOSX) | 81 #if OS(MACOSX) |
79 const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent(); | 82 const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 209 |
207 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().heigh
t(); | 210 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().heigh
t(); |
208 info->itemFontSize = static_cast<int>(m_popupMenuClient->menuStyle().font().
fontDescription().computedSize()); | 211 info->itemFontSize = static_cast<int>(m_popupMenuClient->menuStyle().font().
fontDescription().computedSize()); |
209 info->selectedIndex = m_popupMenuClient->selectedIndex(); | 212 info->selectedIndex = m_popupMenuClient->selectedIndex(); |
210 info->rightAligned = m_popupMenuClient->menuStyle().textDirection() == WebCo
re::RTL; | 213 info->rightAligned = m_popupMenuClient->menuStyle().textDirection() == WebCo
re::RTL; |
211 info->allowMultipleSelection = m_popupMenuClient->multiple(); | 214 info->allowMultipleSelection = m_popupMenuClient->multiple(); |
212 info->items.swap(items); | 215 info->items.swap(items); |
213 } | 216 } |
214 | 217 |
215 } | 218 } |
OLD | NEW |