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

Side by Side Diff: Source/core/layout/LayoutMenuList.cpp

Issue 1013303004: Fix issue on <select> style change when popup is visible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test expectation Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutMenuList.h ('k') | Source/web/ExternalPopupMenuTest.cpp » ('j') | 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 * This file is part of the select element renderer in WebCore. 2 * This file is part of the select element renderer in WebCore.
3 * 3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 using namespace HTMLNames; 52 using namespace HTMLNames;
53 53
54 LayoutMenuList::LayoutMenuList(Element* element) 54 LayoutMenuList::LayoutMenuList(Element* element)
55 : LayoutFlexibleBox(element) 55 : LayoutFlexibleBox(element)
56 , m_buttonText(nullptr) 56 , m_buttonText(nullptr)
57 , m_innerBlock(nullptr) 57 , m_innerBlock(nullptr)
58 , m_optionsChanged(true) 58 , m_optionsChanged(true)
59 , m_optionsWidth(0) 59 , m_optionsWidth(0)
60 , m_lastActiveIndex(-1) 60 , m_lastActiveIndex(-1)
61 , m_popupIsVisible(false) 61 , m_popupIsVisible(false)
62 , m_indexToSelectOnCancel(-1)
62 { 63 {
63 ASSERT(isHTMLSelectElement(element)); 64 ASSERT(isHTMLSelectElement(element));
64 } 65 }
65 66
66 LayoutMenuList::~LayoutMenuList() 67 LayoutMenuList::~LayoutMenuList()
67 { 68 {
68 ASSERT(!m_popup); 69 ASSERT(!m_popup);
69 } 70 }
70 71
71 void LayoutMenuList::destroy() 72 void LayoutMenuList::destroy()
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void LayoutMenuList::updateFromElement() 204 void LayoutMenuList::updateFromElement()
204 { 205 {
205 if (m_optionsChanged) { 206 if (m_optionsChanged) {
206 updateOptionsWidth(); 207 updateOptionsWidth();
207 m_optionsChanged = false; 208 m_optionsChanged = false;
208 } 209 }
209 210
210 if (m_popupIsVisible) 211 if (m_popupIsVisible)
211 m_popup->updateFromElement(); 212 m_popup->updateFromElement();
212 213
213 if (selectElement()->suggestedIndex() >= 0) 214 if (m_indexToSelectOnCancel >= 0)
215 setTextFromOption(selectElement()->listToOptionIndex(m_indexToSelectOnCa ncel));
216 else if (selectElement()->suggestedIndex() >= 0)
214 setTextFromOption(selectElement()->suggestedIndex()); 217 setTextFromOption(selectElement()->suggestedIndex());
215 else 218 else
216 setTextFromOption(selectElement()->selectedIndex()); 219 setTextFromOption(selectElement()->selectedIndex());
217 } 220 }
218 221
219 void LayoutMenuList::setTextFromOption(int optionIndex) 222 void LayoutMenuList::setTextFromOption(int optionIndex)
220 { 223 {
221 HTMLSelectElement* select = selectElement(); 224 HTMLSelectElement* select = selectElement();
222 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = select- >listItems(); 225 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = select- >listItems();
223 const int size = listItems.size(); 226 const int size = listItems.size();
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 return select->optionToListIndex(select->selectedIndex()); 575 return select->optionToListIndex(select->selectedIndex());
573 } 576 }
574 577
575 void LayoutMenuList::popupDidHide() 578 void LayoutMenuList::popupDidHide()
576 { 579 {
577 m_popupIsVisible = false; 580 m_popupIsVisible = false;
578 if (AXObjectCache* cache = document().existingAXObjectCache()) 581 if (AXObjectCache* cache = document().existingAXObjectCache())
579 cache->didHideMenuListPopup(this); 582 cache->didHideMenuListPopup(this);
580 } 583 }
581 584
585 void LayoutMenuList::popupDidCancel()
586 {
587 if (m_indexToSelectOnCancel >= 0) {
588 valueChanged(m_indexToSelectOnCancel);
589 m_indexToSelectOnCancel = -1;
590 }
591 }
592
582 bool LayoutMenuList::itemIsSeparator(unsigned listIndex) const 593 bool LayoutMenuList::itemIsSeparator(unsigned listIndex) const
583 { 594 {
584 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems(); 595 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems();
585 return listIndex < listItems.size() && isHTMLHRElement(*listItems[listIndex] ); 596 return listIndex < listItems.size() && isHTMLHRElement(*listItems[listIndex] );
586 } 597 }
587 598
588 bool LayoutMenuList::itemIsLabel(unsigned listIndex) const 599 bool LayoutMenuList::itemIsLabel(unsigned listIndex) const
589 { 600 {
590 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems(); 601 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems();
591 return listIndex < listItems.size() && isHTMLOptGroupElement(*listItems[list Index]); 602 return listIndex < listItems.size() && isHTMLOptGroupElement(*listItems[list Index]);
592 } 603 }
593 604
594 bool LayoutMenuList::itemIsSelected(unsigned listIndex) const 605 bool LayoutMenuList::itemIsSelected(unsigned listIndex) const
595 { 606 {
596 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems(); 607 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems();
597 if (listIndex >= listItems.size()) 608 if (listIndex >= listItems.size())
598 return false; 609 return false;
599 HTMLElement* element = listItems[listIndex]; 610 HTMLElement* element = listItems[listIndex];
600 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select ed(); 611 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select ed();
601 } 612 }
602 613
603 void LayoutMenuList::setTextFromItem(unsigned listIndex) 614 void LayoutMenuList::provisionalSelectionChanged(unsigned listIndex)
604 { 615 {
605 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); 616 m_indexToSelectOnCancel = listIndex;
617 setTextFromOption(selectElement()->listToOptionIndex(m_indexToSelectOnCancel ));
606 } 618 }
607 619
608 } // namespace blink 620 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutMenuList.h ('k') | Source/web/ExternalPopupMenuTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698