OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 { | 116 { |
117 } | 117 } |
118 | 118 |
119 const AtomicString& HTMLSelectElement::formControlType() const | 119 const AtomicString& HTMLSelectElement::formControlType() const |
120 { | 120 { |
121 DEFINE_STATIC_LOCAL(const AtomicString, selectMultiple, ("select-multiple"))
; | 121 DEFINE_STATIC_LOCAL(const AtomicString, selectMultiple, ("select-multiple"))
; |
122 DEFINE_STATIC_LOCAL(const AtomicString, selectOne, ("select-one")); | 122 DEFINE_STATIC_LOCAL(const AtomicString, selectOne, ("select-one")); |
123 return m_multiple ? selectMultiple : selectOne; | 123 return m_multiple ? selectMultiple : selectOne; |
124 } | 124 } |
125 | 125 |
126 void HTMLSelectElement::optionSelectedByUser(int optionIndex, bool fireOnChangeN
ow, bool allowMultipleSelection) | 126 void HTMLSelectElement::optionSelectedByUser(int optionIndex, bool fireOnChangeN
ow) |
127 { | 127 { |
128 // User interaction such as mousedown events can cause list box select | 128 // User interaction such as mousedown events can cause list box select |
129 // elements to send change events. This produces that same behavior for | 129 // elements to send change events. This produces that same behavior for |
130 // changes triggered by other code running on behalf of the user. | 130 // changes triggered by other code running on behalf of the user. |
131 if (!usesMenuList()) { | 131 if (!usesMenuList()) { |
132 updateSelectedState(item(optionIndex), allowMultipleSelection, false); | 132 updateSelectedState(item(optionIndex), false, false); |
133 setNeedsValidityCheck(); | 133 setNeedsValidityCheck(); |
134 if (fireOnChangeNow) | 134 if (fireOnChangeNow) |
135 listBoxOnChange(); | 135 listBoxOnChange(); |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 // Bail out if this index is already the selected one, to avoid running | 139 // Bail out if this index is already the selected one, to avoid running |
140 // unnecessary JavaScript that can mess up autofill when there is no actual | 140 // unnecessary JavaScript that can mess up autofill when there is no actual |
141 // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and | 141 // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and |
142 // <rdar://7467917>). The selectOption function does not behave this way, | 142 // <rdar://7467917>). The selectOption function does not behave this way, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return firstSelectionIndex < 0 || (!firstSelectionIndex && hasPlaceholderLab
elOption()); | 201 return firstSelectionIndex < 0 || (!firstSelectionIndex && hasPlaceholderLab
elOption()); |
202 } | 202 } |
203 | 203 |
204 String HTMLSelectElement::defaultToolTip() const | 204 String HTMLSelectElement::defaultToolTip() const |
205 { | 205 { |
206 if (form() && form()->noValidate()) | 206 if (form() && form()->noValidate()) |
207 return String(); | 207 return String(); |
208 return validationMessage(); | 208 return validationMessage(); |
209 } | 209 } |
210 | 210 |
211 void HTMLSelectElement::listBoxSelectItem(int listIndex, bool allowMultiplySelec
tions, bool shift, bool fireOnChangeNow) | 211 void HTMLSelectElement::listBoxSelectItem(int listIndex, bool allowMultiplySelec
tions, bool fireOnChangeNow) |
212 { | 212 { |
213 if (!multiple()) { | 213 if (!multiple()) { |
214 optionSelectedByUser(listToOptionIndex(listIndex), fireOnChangeNow, fals
e); | 214 optionSelectedByUser(listToOptionIndex(listIndex), fireOnChangeNow); |
215 } else { | 215 } else { |
216 HTMLElement* element = listItems()[listIndex]; | 216 HTMLElement* element = listItems()[listIndex]; |
217 if (isHTMLOptionElement(element)) | 217 if (isHTMLOptionElement(element)) |
218 updateSelectedState(toHTMLOptionElement(element), allowMultiplySelec
tions, shift); | 218 updateSelectedState(toHTMLOptionElement(element), allowMultiplySelec
tions, false); |
219 setNeedsValidityCheck(); | 219 setNeedsValidityCheck(); |
220 if (fireOnChangeNow) | 220 if (fireOnChangeNow) |
221 listBoxOnChange(); | 221 listBoxOnChange(); |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 bool HTMLSelectElement::usesMenuList() const | 225 bool HTMLSelectElement::usesMenuList() const |
226 { | 226 { |
227 if (LayoutTheme::theme().delegatesMenuListRendering()) | 227 if (LayoutTheme::theme().delegatesMenuListRendering()) |
228 return true; | 228 return true; |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 } | 2069 } |
2070 | 2070 |
2071 void HTMLSelectElement::didMutateSubtree() | 2071 void HTMLSelectElement::didMutateSubtree() |
2072 { | 2072 { |
2073 DCHECK(popupIsVisible()); | 2073 DCHECK(popupIsVisible()); |
2074 DCHECK(m_popup); | 2074 DCHECK(m_popup); |
2075 m_popup->updateFromElement(PopupMenu::ByDOMChange); | 2075 m_popup->updateFromElement(PopupMenu::ByDOMChange); |
2076 } | 2076 } |
2077 | 2077 |
2078 } // namespace blink | 2078 } // namespace blink |
OLD | NEW |