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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 , m_webView(webView) | 53 , m_webView(webView) |
54 , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent) | 54 , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent) |
55 , m_webExternalPopupMenu(0) | 55 , m_webExternalPopupMenu(0) |
56 { | 56 { |
57 } | 57 } |
58 | 58 |
59 ExternalPopupMenu::~ExternalPopupMenu() | 59 ExternalPopupMenu::~ExternalPopupMenu() |
60 { | 60 { |
61 } | 61 } |
62 | 62 |
| 63 void ExternalPopupMenu::trace(Visitor* visitor) |
| 64 { |
| 65 visitor->trace(m_localFrame); |
| 66 PopupMenu::trace(visitor); |
| 67 } |
| 68 |
63 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i
nt index) | 69 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i
nt index) |
64 { | 70 { |
65 IntRect rect(controlPosition.enclosingBoundingBox()); | 71 IntRect rect(controlPosition.enclosingBoundingBox()); |
66 // WebCore reuses the PopupMenu of an element. | 72 // WebCore reuses the PopupMenu of an element. |
67 // For simplicity, we do recreate the actual external popup everytime. | 73 // For simplicity, we do recreate the actual external popup everytime. |
68 if (m_webExternalPopupMenu) { | 74 if (m_webExternalPopupMenu) { |
69 m_webExternalPopupMenu->close(); | 75 m_webExternalPopupMenu->close(); |
70 m_webExternalPopupMenu = 0; | 76 m_webExternalPopupMenu = 0; |
71 } | 77 } |
72 | 78 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (m_popupMenuClient) | 134 if (m_popupMenuClient) |
129 m_popupMenuClient->selectionChanged(toPopupMenuItemIndex(index, *m_popup
MenuClient)); | 135 m_popupMenuClient->selectionChanged(toPopupMenuItemIndex(index, *m_popup
MenuClient)); |
130 } | 136 } |
131 | 137 |
132 void ExternalPopupMenu::didAcceptIndex(int index) | 138 void ExternalPopupMenu::didAcceptIndex(int index) |
133 { | 139 { |
134 // Calling methods on the PopupMenuClient might lead to this object being | 140 // Calling methods on the PopupMenuClient might lead to this object being |
135 // derefed. This ensures it does not get deleted while we are running this | 141 // derefed. This ensures it does not get deleted while we are running this |
136 // method. | 142 // method. |
137 int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_popupMenuClient); | 143 int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_popupMenuClient); |
138 RefPtr<ExternalPopupMenu> guard(this); | 144 RefPtrWillBeRawPtr<ExternalPopupMenu> guard(this); |
139 | 145 |
140 if (m_popupMenuClient) { | 146 if (m_popupMenuClient) { |
141 m_popupMenuClient->popupDidHide(); | 147 m_popupMenuClient->popupDidHide(); |
142 m_popupMenuClient->valueChanged(popupMenuItemIndex); | 148 m_popupMenuClient->valueChanged(popupMenuItemIndex); |
143 } | 149 } |
144 m_webExternalPopupMenu = 0; | 150 m_webExternalPopupMenu = 0; |
145 } | 151 } |
146 | 152 |
147 void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices) | 153 void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices) |
148 { | 154 { |
149 if (!m_popupMenuClient) { | 155 if (!m_popupMenuClient) { |
150 m_webExternalPopupMenu = 0; | 156 m_webExternalPopupMenu = 0; |
151 return; | 157 return; |
152 } | 158 } |
153 | 159 |
154 // Calling methods on the PopupMenuClient might lead to this object being | 160 // Calling methods on the PopupMenuClient might lead to this object being |
155 // derefed. This ensures it does not get deleted while we are running this | 161 // derefed. This ensures it does not get deleted while we are running this |
156 // method. | 162 // method. |
157 RefPtr<ExternalPopupMenu> protect(this); | 163 RefPtrWillBeRawPtr<ExternalPopupMenu> protect(this); |
158 | 164 |
159 if (!indices.size()) | 165 if (!indices.size()) |
160 m_popupMenuClient->valueChanged(static_cast<unsigned>(-1), true); | 166 m_popupMenuClient->valueChanged(static_cast<unsigned>(-1), true); |
161 else { | 167 else { |
162 for (size_t i = 0; i < indices.size(); ++i) | 168 for (size_t i = 0; i < indices.size(); ++i) |
163 m_popupMenuClient->listBoxSelectItem(toPopupMenuItemIndex(indices[i]
, *m_popupMenuClient), (i > 0), false, (i == indices.size() - 1)); | 169 m_popupMenuClient->listBoxSelectItem(toPopupMenuItemIndex(indices[i]
, *m_popupMenuClient), (i > 0), false, (i == indices.size() - 1)); |
164 } | 170 } |
165 | 171 |
166 // The call to valueChanged above might have lead to a call to | 172 // The call to valueChanged above might have lead to a call to |
167 // disconnectClient, so we might not have a PopupMenuClient anymore. | 173 // disconnectClient, so we might not have a PopupMenuClient anymore. |
168 if (m_popupMenuClient) | 174 if (m_popupMenuClient) |
169 m_popupMenuClient->popupDidHide(); | 175 m_popupMenuClient->popupDidHide(); |
170 | 176 |
171 m_webExternalPopupMenu = 0; | 177 m_webExternalPopupMenu = 0; |
172 } | 178 } |
173 | 179 |
174 void ExternalPopupMenu::didCancel() | 180 void ExternalPopupMenu::didCancel() |
175 { | 181 { |
176 // See comment in didAcceptIndex on why we need this. | 182 // See comment in didAcceptIndex on why we need this. |
177 RefPtr<ExternalPopupMenu> guard(this); | 183 RefPtrWillBeRawPtr<ExternalPopupMenu> guard(this); |
178 | 184 |
179 if (m_popupMenuClient) | 185 if (m_popupMenuClient) |
180 m_popupMenuClient->popupDidHide(); | 186 m_popupMenuClient->popupDidHide(); |
181 m_webExternalPopupMenu = 0; | 187 m_webExternalPopupMenu = 0; |
182 } | 188 } |
183 | 189 |
184 void ExternalPopupMenu::getPopupMenuInfo(WebPopupMenuInfo& info, PopupMenuClient
& popupMenuClient) | 190 void ExternalPopupMenu::getPopupMenuInfo(WebPopupMenuInfo& info, PopupMenuClient
& popupMenuClient) |
185 { | 191 { |
186 int itemCount = popupMenuClient.listSize(); | 192 int itemCount = popupMenuClient.listSize(); |
187 int count = 0; | 193 int count = 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (popupMenuClient.itemStyle(i).isDisplayNone()) | 250 if (popupMenuClient.itemStyle(i).isDisplayNone()) |
245 continue; | 251 continue; |
246 if (popupMenuItemIndex == i) | 252 if (popupMenuItemIndex == i) |
247 return indexTracker; | 253 return indexTracker; |
248 ++indexTracker; | 254 ++indexTracker; |
249 } | 255 } |
250 return -1; | 256 return -1; |
251 } | 257 } |
252 | 258 |
253 } // namespace blink | 259 } // namespace blink |
OLD | NEW |