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

Unified Diff: Source/core/html/HTMLSelectElement.cpp

Issue 783983005: Fix regression caused by r178354 where options in optgroup not indented (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reverted change to Element.cpp 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLSelectElement.cpp
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index 1c1dc110fdc428bdd5f5ab7fa0d90137499f579e..eaa89a3f1b4943f4b5921966de0e6c168ded3cab 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -84,6 +84,7 @@ HTMLSelectElement::HTMLSelectElement(Document& document, HTMLFormElement* form)
, m_shouldRecalcListItems(false)
, m_suggestedIndex(-1)
, m_isAutofilledByPreview(false)
+ , m_scrollToSelectionLater(false)
{
}
@@ -418,6 +419,11 @@ void HTMLSelectElement::childrenChanged(const ChildrenChange& change)
m_lastOnChangeSelection.clear();
HTMLFormControlElementWithState::childrenChanged(change);
+
+ if (m_scrollToSelectionLater) {
+ m_scrollToSelectionLater = false;
+ scrollToSelection();
+ }
}
void HTMLSelectElement::optionElementChildrenChanged()
@@ -918,6 +924,13 @@ void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b
selectOption(nextSelectableListIndex(-1));
}
+void HTMLSelectElement::optionInserted(const HTMLOptionElement& option, bool optionIsSelected)
+{
+ ASSERT(option.ownerSelectElement() == this);
+ if (optionIsSelected)
+ selectOption(option.index(), DelayScrollToSelection);
+}
+
void HTMLSelectElement::optionRemoved(const HTMLOptionElement& option)
{
if (m_activeSelectionAnchorIndex < 0 && m_activeSelectionEndIndex < 0)
@@ -960,7 +973,10 @@ void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
if (RenderObject* renderer = this->renderer())
renderer->updateFromElement();
- scrollToSelection();
+ if (flags & DelayScrollToSelection)
+ m_scrollToSelectionLater = true;
+ else
+ scrollToSelection();
setNeedsValidityCheck();
@@ -1655,7 +1671,7 @@ String HTMLSelectElement::optionAtIndex(int index) const
HTMLElement* element = items[index];
if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl())
return String();
- return toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
+ return toHTMLOptionElement(element)->text();
}
void HTMLSelectElement::typeAheadFind(KeyboardEvent* event)
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698