Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1285)

Unified Diff: third_party/WebKit/WebCore/platform/chromium/PopupMenuChromium.cpp

Issue 20076: WebKit merge 40500:40539 [WebKit side] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/WebCore/platform/chromium/PopupMenuChromium.cpp
===================================================================
--- third_party/WebKit/WebCore/platform/chromium/PopupMenuChromium.cpp (revision 9118)
+++ third_party/WebKit/WebCore/platform/chromium/PopupMenuChromium.cpp (working copy)
@@ -82,6 +82,11 @@
// box ("combobox" on Windows).
class PopupListBox : public FramelessScrollView, public RefCounted<PopupListBox> {
public:
+ static PassRefPtr<PopupListBox> create(PopupMenuClient* client, const PopupContainerSettings& settings)
+ {
+ return adoptRef(new PopupListBox(client, settings));
+ }
+
// FramelessScrollView
virtual void paint(GraphicsContext*, const IntRect&);
virtual bool handleMouseDownEvent(const PlatformMouseEvent&);
@@ -309,13 +314,9 @@
}
PopupContainer::PopupContainer(PopupMenuClient* client, const PopupContainerSettings& settings)
- : m_listBox(new PopupListBox(client, settings))
+ : m_listBox(PopupListBox::create(client, settings))
, m_settings(settings)
{
- // FrameViews are created with a refcount of 1 so it needs releasing after we
- // assign it to a RefPtr.
- m_listBox->deref();
-
setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
}
@@ -347,11 +348,11 @@
chromeClient->popupOpened(this, widgetRect, m_settings.focusOnShow);
}
- // Must get called after we have a client and containingWindow.
- addChild(m_listBox.get());
+ if (!m_listBox->parent())
+ addChild(m_listBox.get());
- // Enable scrollbars after the listbox is inserted into the hierarchy, so
- // it has a proper WidgetClient.
+ // Enable scrollbars after the listbox is inserted into the hierarchy,
+ // so it has a proper WidgetClient.
m_listBox->setVerticalScrollbarMode(ScrollbarAuto);
m_listBox->scrollToRevealSelection();
@@ -361,12 +362,6 @@
void PopupContainer::hidePopup()
{
- invalidate();
-
- m_listBox->disconnectClient();
- removeChild(m_listBox.get());
- m_listBox = 0;
-
if (client())
client()->popupClosed(this);
}
@@ -828,12 +823,10 @@
m_selectedIndex = m_originalIndex;
+ m_popupClient->hidePopup();
+
if (m_willAcceptOnAbandon)
m_popupClient->valueChanged(m_selectedIndex);
-
- // valueChanged may have torn down the popup!
- if (m_popupClient)
- m_popupClient->hidePopup();
}
int PopupListBox::pointToRowIndex(const IntPoint& point)
@@ -865,12 +858,11 @@
if (isSelectableItem(index)) {
RefPtr<PopupListBox> keepAlive(this);
- // Tell the <select> PopupMenuClient what index was selected, and hide ourself.
- m_popupClient->valueChanged(index);
+ // Hide ourselves first since valueChanged may have numerous side-effects.
+ m_popupClient->hidePopup();
- // valueChanged may have torn down the popup!
- if (m_popupClient)
- m_popupClient->hidePopup();
+ // Tell the <select> PopupMenuClient what index was selected.
+ m_popupClient->valueChanged(index);
}
}
@@ -1130,16 +1122,15 @@
void PopupMenu::show(const IntRect& r, FrameView* v, int index)
{
- p.popup = PopupContainer::create(client(), dropDownSettings);
+ if (!p.popup)
+ p.popup = PopupContainer::create(client(), dropDownSettings);
p.popup->show(r, v, index);
}
void PopupMenu::hide()
{
- if (p.popup) {
+ if (p.popup)
p.popup->hidePopup();
- p.popup = 0;
- }
}
void PopupMenu::updateFromElement()

Powered by Google App Engine
This is Rietveld 408576698