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

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

Issue 65303008: Have ElementTraversal::firstWithin() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 1 month 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
« no previous file with comments | « Source/core/html/HTMLObjectElement.cpp ('k') | Source/core/page/FocusController.h » ('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 * 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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 } 727 }
728 728
729 void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const 729 void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
730 { 730 {
731 m_listItems.clear(); 731 m_listItems.clear();
732 732
733 m_shouldRecalcListItems = false; 733 m_shouldRecalcListItems = false;
734 734
735 HTMLOptionElement* foundSelected = 0; 735 HTMLOptionElement* foundSelected = 0;
736 HTMLOptionElement* firstOption = 0; 736 HTMLOptionElement* firstOption = 0;
737 for (Element* currentElement = ElementTraversal::firstWithin(this); currentE lement; ) { 737 for (Element* currentElement = ElementTraversal::firstWithin(*this); current Element; ) {
738 if (!currentElement->isHTMLElement()) { 738 if (!currentElement->isHTMLElement()) {
739 currentElement = ElementTraversal::nextSkippingChildren(*currentElem ent, this); 739 currentElement = ElementTraversal::nextSkippingChildren(*currentElem ent, this);
740 continue; 740 continue;
741 } 741 }
742 HTMLElement* current = toHTMLElement(currentElement); 742 HTMLElement& current = toHTMLElement(*currentElement);
743 743
744 // optgroup tags may not nest. However, both FireFox and IE will 744 // optgroup tags may not nest. However, both FireFox and IE will
745 // flatten the tree automatically, so we follow suit. 745 // flatten the tree automatically, so we follow suit.
746 // (http://www.w3.org/TR/html401/interact/forms.html#h-17.6) 746 // (http://www.w3.org/TR/html401/interact/forms.html#h-17.6)
747 if (isHTMLOptGroupElement(current)) { 747 if (isHTMLOptGroupElement(current)) {
748 m_listItems.append(current); 748 m_listItems.append(&current);
749 if (Element* nextElement = ElementTraversal::firstWithin(current)) { 749 if (Element* nextElement = ElementTraversal::firstWithin(current)) {
750 currentElement = nextElement; 750 currentElement = nextElement;
751 continue; 751 continue;
752 } 752 }
753 } 753 }
754 754
755 if (current->hasTagName(optionTag)) { 755 if (current.hasTagName(optionTag)) {
756 m_listItems.append(current); 756 m_listItems.append(&current);
757 757
758 if (updateSelectedStates && !m_multiple) { 758 if (updateSelectedStates && !m_multiple) {
759 HTMLOptionElement* option = toHTMLOptionElement(current); 759 HTMLOptionElement& option = toHTMLOptionElement(current);
760 if (!firstOption) 760 if (!firstOption)
761 firstOption = option; 761 firstOption = &option;
762 if (option->selected()) { 762 if (option.selected()) {
763 if (foundSelected) 763 if (foundSelected)
764 foundSelected->setSelectedState(false); 764 foundSelected->setSelectedState(false);
765 foundSelected = option; 765 foundSelected = &option;
766 } else if (m_size <= 1 && !foundSelected && !option->isDisabledF ormControl()) { 766 } else if (m_size <= 1 && !foundSelected && !option.isDisabledFo rmControl()) {
767 foundSelected = option; 767 foundSelected = &option;
768 foundSelected->setSelectedState(true); 768 foundSelected->setSelectedState(true);
769 } 769 }
770 } 770 }
771 } 771 }
772 772
773 if (current->hasTagName(hrTag)) 773 if (current.hasTagName(hrTag))
774 m_listItems.append(current); 774 m_listItems.append(&current);
775 775
776 // In conforming HTML code, only <optgroup> and <option> will be found 776 // In conforming HTML code, only <optgroup> and <option> will be found
777 // within a <select>. We call NodeTraversal::nextSkippingChildren so tha t we only step 777 // within a <select>. We call NodeTraversal::nextSkippingChildren so tha t we only step
778 // into those tags that we choose to. For web-compat, we should cope 778 // into those tags that we choose to. For web-compat, we should cope
779 // with the case where odd tags like a <div> have been added but we 779 // with the case where odd tags like a <div> have been added but we
780 // handle this because such tags have already been removed from the 780 // handle this because such tags have already been removed from the
781 // <select>'s subtree at this point. 781 // <select>'s subtree at this point.
782 currentElement = ElementTraversal::nextSkippingChildren(*currentElement, this); 782 currentElement = ElementTraversal::nextSkippingChildren(*currentElement, this);
783 } 783 }
784 784
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 remove(index); 1578 remove(index);
1579 return true; 1579 return true;
1580 } 1580 }
1581 1581
1582 bool HTMLSelectElement::isInteractiveContent() const 1582 bool HTMLSelectElement::isInteractiveContent() const
1583 { 1583 {
1584 return true; 1584 return true;
1585 } 1585 }
1586 1586
1587 } // namespace 1587 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLObjectElement.cpp ('k') | Source/core/page/FocusController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698