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

Side by Side Diff: Source/core/html/HTMLSelectElement.cpp

Issue 799343002: Fix hitting assert when opening a select menu with no options (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * 10 *
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 // the event as handled. 1198 // the event as handled.
1199 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) 1199 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl())
1200 return; 1200 return;
1201 // Save the selection so it can be compared to the new selection 1201 // Save the selection so it can be compared to the new selection
1202 // when dispatching change events during selectOption, which 1202 // when dispatching change events during selectOption, which
1203 // gets called from RenderMenuList::valueChanged, which gets called 1203 // gets called from RenderMenuList::valueChanged, which gets called
1204 // after the user makes a selection from the menu. 1204 // after the user makes a selection from the menu.
1205 saveLastSelection(); 1205 saveLastSelection();
1206 if (RenderMenuList* menuList = toRenderMenuList(renderer())) 1206 if (RenderMenuList* menuList = toRenderMenuList(renderer()))
1207 menuList->showPopup(); 1207 menuList->showPopup();
1208 int index = selectedIndex();
1209 ASSERT(index >= 0);
1210 ASSERT_WITH_SECURITY_IMPLICATION(index < static_cast<int>(listItems().size() ));
1211 setSelectedIndex(index);
tkent 2014/12/15 08:56:25 Hmm, setSelectedIndex(selectedIndex()) looks to do
keishi 2014/12/15 09:01:21 Yup
1212 event->setDefaultHandled(); 1208 event->setDefaultHandled();
1213 return; 1209 return;
1214 } 1210 }
1215 1211
1216 bool HTMLSelectElement::shouldOpenPopupForKeyDownEvent(KeyboardEvent* keyEvent) 1212 bool HTMLSelectElement::shouldOpenPopupForKeyDownEvent(KeyboardEvent* keyEvent)
1217 { 1213 {
1218 const String& keyIdentifier = keyEvent->keyIdentifier(); 1214 const String& keyIdentifier = keyEvent->keyIdentifier();
1219 RenderTheme& renderTheme = RenderTheme::theme(); 1215 RenderTheme& renderTheme = RenderTheme::theme();
1220 1216
1221 if (isSpatialNavigationEnabled(document().frame())) 1217 if (isSpatialNavigationEnabled(document().frame()))
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 int focusedIndex = activeSelectionEndListIndex(); 1770 int focusedIndex = activeSelectionEndListIndex();
1775 if (focusedIndex < 0) 1771 if (focusedIndex < 0)
1776 focusedIndex = firstSelectableListIndex(); 1772 focusedIndex = firstSelectableListIndex();
1777 if (focusedIndex < 0) 1773 if (focusedIndex < 0)
1778 return nullptr; 1774 return nullptr;
1779 HTMLElement* focused = listItems()[focusedIndex]; 1775 HTMLElement* focused = listItems()[focusedIndex];
1780 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ; 1776 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ;
1781 } 1777 }
1782 1778
1783 } // namespace 1779 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698