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

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

Issue 736883002: Implement <select> Popup Menu using PagePopup (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
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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 // the event as handled. 1197 // the event as handled.
1198 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) 1198 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl())
1199 return; 1199 return;
1200 // Save the selection so it can be compared to the new selection 1200 // Save the selection so it can be compared to the new selection
1201 // when dispatching change events during selectOption, which 1201 // when dispatching change events during selectOption, which
1202 // gets called from RenderMenuList::valueChanged, which gets called 1202 // gets called from RenderMenuList::valueChanged, which gets called
1203 // after the user makes a selection from the menu. 1203 // after the user makes a selection from the menu.
1204 saveLastSelection(); 1204 saveLastSelection();
1205 if (RenderMenuList* menuList = toRenderMenuList(renderer())) 1205 if (RenderMenuList* menuList = toRenderMenuList(renderer()))
1206 menuList->showPopup(); 1206 menuList->showPopup();
1207 int index = selectedIndex();
1208 ASSERT(index >= 0);
1209 ASSERT_WITH_SECURITY_IMPLICATION(index < static_cast<int>(listItems().size() ));
1210 setSelectedIndex(index);
1211 event->setDefaultHandled(); 1207 event->setDefaultHandled();
1212 return; 1208 return;
1213 } 1209 }
1214 1210
1215 bool HTMLSelectElement::shouldOpenPopupForKeyDownEvent(KeyboardEvent* keyEvent) 1211 bool HTMLSelectElement::shouldOpenPopupForKeyDownEvent(KeyboardEvent* keyEvent)
1216 { 1212 {
1217 const String& keyIdentifier = keyEvent->keyIdentifier(); 1213 const String& keyIdentifier = keyEvent->keyIdentifier();
1218 RenderTheme& renderTheme = RenderTheme::theme(); 1214 RenderTheme& renderTheme = RenderTheme::theme();
1219 1215
1220 if (isSpatialNavigationEnabled(document().frame())) 1216 if (isSpatialNavigationEnabled(document().frame()))
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 { 1751 {
1756 #if ENABLE(OILPAN) 1752 #if ENABLE(OILPAN)
1757 visitor->trace(m_listItems); 1753 visitor->trace(m_listItems);
1758 #endif 1754 #endif
1759 HTMLFormControlElementWithState::trace(visitor); 1755 HTMLFormControlElementWithState::trace(visitor);
1760 } 1756 }
1761 1757
1762 void HTMLSelectElement::didAddUserAgentShadowRoot(ShadowRoot& root) 1758 void HTMLSelectElement::didAddUserAgentShadowRoot(ShadowRoot& root)
1763 { 1759 {
1764 RefPtrWillBeRawPtr<HTMLContentElement> content = HTMLContentElement::create( document()); 1760 RefPtrWillBeRawPtr<HTMLContentElement> content = HTMLContentElement::create( document());
1765 content->setAttribute(selectAttr, "option,optgroup"); 1761 content->setAttribute(selectAttr, "option,optgroup,hr");
1766 root.appendChild(content); 1762 root.appendChild(content);
1767 } 1763 }
1768 1764
1769 HTMLOptionElement* HTMLSelectElement::spatialNavigationFocusedOption() 1765 HTMLOptionElement* HTMLSelectElement::spatialNavigationFocusedOption()
1770 { 1766 {
1771 if (!isSpatialNavigationEnabled(document().frame())) 1767 if (!isSpatialNavigationEnabled(document().frame()))
1772 return nullptr; 1768 return nullptr;
1773 int focusedIndex = activeSelectionEndListIndex(); 1769 int focusedIndex = activeSelectionEndListIndex();
1774 if (focusedIndex < 0) 1770 if (focusedIndex < 0)
1775 focusedIndex = firstSelectableListIndex(); 1771 focusedIndex = firstSelectableListIndex();
1776 if (focusedIndex < 0) 1772 if (focusedIndex < 0)
1777 return nullptr; 1773 return nullptr;
1778 HTMLElement* focused = listItems()[focusedIndex]; 1774 HTMLElement* focused = listItems()[focusedIndex];
1779 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ; 1775 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ;
1780 } 1776 }
1781 1777
1782 } // namespace 1778 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698