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

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: Created 5 years, 9 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
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_popupTemporarySelectedIndex(-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_popupTemporarySelectedIndex >= 0)
215 setTextFromOption(selectElement()->listToOptionIndex(m_popupTemporarySel ectedIndex));
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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 567
565 int LayoutMenuList::selectedIndex() const 568 int LayoutMenuList::selectedIndex() const
566 { 569 {
567 HTMLSelectElement* select = selectElement(); 570 HTMLSelectElement* select = selectElement();
568 return select->optionToListIndex(select->selectedIndex()); 571 return select->optionToListIndex(select->selectedIndex());
569 } 572 }
570 573
571 void LayoutMenuList::popupDidHide() 574 void LayoutMenuList::popupDidHide()
572 { 575 {
573 m_popupIsVisible = false; 576 m_popupIsVisible = false;
577 if (m_popupTemporarySelectedIndex >= 0) {
578 valueChanged(m_popupTemporarySelectedIndex);
579 m_popupTemporarySelectedIndex = -1;
580 }
574 } 581 }
575 582
576 bool LayoutMenuList::itemIsSeparator(unsigned listIndex) const 583 bool LayoutMenuList::itemIsSeparator(unsigned listIndex) const
577 { 584 {
578 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems(); 585 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems();
579 return listIndex < listItems.size() && isHTMLHRElement(*listItems[listIndex] ); 586 return listIndex < listItems.size() && isHTMLHRElement(*listItems[listIndex] );
580 } 587 }
581 588
582 bool LayoutMenuList::itemIsLabel(unsigned listIndex) const 589 bool LayoutMenuList::itemIsLabel(unsigned listIndex) const
583 { 590 {
584 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems(); 591 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems();
585 return listIndex < listItems.size() && isHTMLOptGroupElement(*listItems[list Index]); 592 return listIndex < listItems.size() && isHTMLOptGroupElement(*listItems[list Index]);
586 } 593 }
587 594
588 bool LayoutMenuList::itemIsSelected(unsigned listIndex) const 595 bool LayoutMenuList::itemIsSelected(unsigned listIndex) const
589 { 596 {
590 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems(); 597 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectE lement()->listItems();
591 if (listIndex >= listItems.size()) 598 if (listIndex >= listItems.size())
592 return false; 599 return false;
593 HTMLElement* element = listItems[listIndex]; 600 HTMLElement* element = listItems[listIndex];
594 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select ed(); 601 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select ed();
595 } 602 }
596 603
597 void LayoutMenuList::setTextFromItem(unsigned listIndex) 604 void LayoutMenuList::setProvisionallySelectedListIndex(unsigned listIndex)
598 { 605 {
599 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); 606 m_popupTemporarySelectedIndex = listIndex;
607 setTextFromOption(selectElement()->listToOptionIndex(m_popupTemporarySelecte dIndex));
600 } 608 }
601 609
602 } // namespace blink 610 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698