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 26 matching lines...) Expand all Loading... |
37 #include "platform/geometry/FloatQuad.h" | 37 #include "platform/geometry/FloatQuad.h" |
38 #include "platform/geometry/IntPoint.h" | 38 #include "platform/geometry/IntPoint.h" |
39 #include "platform/text/TextDirection.h" | 39 #include "platform/text/TextDirection.h" |
40 #include "public/platform/WebVector.h" | 40 #include "public/platform/WebVector.h" |
41 #include "public/web/WebExternalPopupMenu.h" | 41 #include "public/web/WebExternalPopupMenu.h" |
42 #include "public/web/WebMenuItemInfo.h" | 42 #include "public/web/WebMenuItemInfo.h" |
43 #include "public/web/WebPopupMenuInfo.h" | 43 #include "public/web/WebPopupMenuInfo.h" |
44 #include "public/web/WebViewClient.h" | 44 #include "public/web/WebViewClient.h" |
45 #include "web/WebViewImpl.h" | 45 #include "web/WebViewImpl.h" |
46 | 46 |
47 using namespace blink; | |
48 | |
49 namespace blink { | 47 namespace blink { |
50 | 48 |
51 ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame, PopupMenuClient* popupMe
nuClient, WebViewImpl& webView) | 49 ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame, PopupMenuClient* popupMe
nuClient, WebViewImpl& webView) |
52 : m_popupMenuClient(popupMenuClient) | 50 : m_popupMenuClient(popupMenuClient) |
53 , m_frameView(frame.view()) | 51 , m_frameView(frame.view()) |
54 , m_webView(webView) | 52 , m_webView(webView) |
55 , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent) | 53 , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent) |
56 , m_webExternalPopupMenu(0) | 54 , m_webExternalPopupMenu(0) |
57 { | 55 { |
58 } | 56 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 popupItem.label = m_popupMenuClient->itemText(i); | 193 popupItem.label = m_popupMenuClient->itemText(i); |
196 popupItem.toolTip = m_popupMenuClient->itemToolTip(i); | 194 popupItem.toolTip = m_popupMenuClient->itemToolTip(i); |
197 if (m_popupMenuClient->itemIsSeparator(i)) | 195 if (m_popupMenuClient->itemIsSeparator(i)) |
198 popupItem.type = WebMenuItemInfo::Separator; | 196 popupItem.type = WebMenuItemInfo::Separator; |
199 else if (m_popupMenuClient->itemIsLabel(i)) | 197 else if (m_popupMenuClient->itemIsLabel(i)) |
200 popupItem.type = WebMenuItemInfo::Group; | 198 popupItem.type = WebMenuItemInfo::Group; |
201 else | 199 else |
202 popupItem.type = WebMenuItemInfo::Option; | 200 popupItem.type = WebMenuItemInfo::Option; |
203 popupItem.enabled = m_popupMenuClient->itemIsEnabled(i); | 201 popupItem.enabled = m_popupMenuClient->itemIsEnabled(i); |
204 popupItem.checked = m_popupMenuClient->itemIsSelected(i); | 202 popupItem.checked = m_popupMenuClient->itemIsSelected(i); |
205 if (style.textDirection() == blink::RTL) | 203 if (style.textDirection() == RTL) |
206 popupItem.textDirection = WebTextDirectionRightToLeft; | 204 popupItem.textDirection = WebTextDirectionRightToLeft; |
207 else | 205 else |
208 popupItem.textDirection = WebTextDirectionLeftToRight; | 206 popupItem.textDirection = WebTextDirectionLeftToRight; |
209 popupItem.hasTextDirectionOverride = style.hasTextDirectionOverride(); | 207 popupItem.hasTextDirectionOverride = style.hasTextDirectionOverride(); |
210 } | 208 } |
211 | 209 |
212 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().heigh
t(); | 210 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().heigh
t(); |
213 info->itemFontSize = static_cast<int>(m_popupMenuClient->menuStyle().font().
fontDescription().computedSize()); | 211 info->itemFontSize = static_cast<int>(m_popupMenuClient->menuStyle().font().
fontDescription().computedSize()); |
214 info->selectedIndex = toExternalPopupMenuItemIndex(m_popupMenuClient->select
edIndex()); | 212 info->selectedIndex = toExternalPopupMenuItemIndex(m_popupMenuClient->select
edIndex()); |
215 info->rightAligned = m_popupMenuClient->menuStyle().textDirection() == blink
::RTL; | 213 info->rightAligned = m_popupMenuClient->menuStyle().textDirection() == RTL; |
216 info->allowMultipleSelection = m_popupMenuClient->multiple(); | 214 info->allowMultipleSelection = m_popupMenuClient->multiple(); |
217 info->items = items; | 215 info->items = items; |
218 } | 216 } |
219 | 217 |
220 int ExternalPopupMenu::toPopupMenuItemIndex(int externalPopupMenuItemIndex) | 218 int ExternalPopupMenu::toPopupMenuItemIndex(int externalPopupMenuItemIndex) |
221 { | 219 { |
222 ASSERT(m_popupMenuClient); | 220 ASSERT(m_popupMenuClient); |
223 if (externalPopupMenuItemIndex < 0) | 221 if (externalPopupMenuItemIndex < 0) |
224 return externalPopupMenuItemIndex; | 222 return externalPopupMenuItemIndex; |
225 | 223 |
(...skipping 19 matching lines...) Expand all Loading... |
245 for (int i = 0; i < itemCount; ++i) { | 243 for (int i = 0; i < itemCount; ++i) { |
246 if (m_popupMenuClient->itemStyle(i).isDisplayNone()) | 244 if (m_popupMenuClient->itemStyle(i).isDisplayNone()) |
247 continue; | 245 continue; |
248 if (popupMenuItemIndex == i) | 246 if (popupMenuItemIndex == i) |
249 return indexTracker; | 247 return indexTracker; |
250 ++indexTracker; | 248 ++indexTracker; |
251 } | 249 } |
252 return -1; | 250 return -1; |
253 } | 251 } |
254 | 252 |
255 } | 253 } // namespace blink |
OLD | NEW |