Changeset 66929 in webkit
- Timestamp:
- Sep 7, 2010 4:33:59 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r66928 r66929 1 2010-09-03 Joseph Pecoraro <joepeck@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Provide a way to trigger a <select multiple> onchange event on changes 6 https://bugs.webkit.org/show_bug.cgi?id=45192 7 8 Test: LayoutTests/platform/mac/fast/objc/dom-html-select-activate.html 9 10 This provides a way for a WebKit client using the Obj-C DOM bindings to 11 trigger the "change" on a listbox select (<select multiple> or <select> 12 with size > 1). This is because when a select is rendered as a listbox 13 "change" events are triggered by mouse down events. 14 15 This adds -[DOMHTMLSelectElement _activateItemAtIndex:allowMultipleSelection:] 16 to allow for handling multiple selections if the select element is a 17 multi-select. 18 19 * bindings/objc/DOMHTML.mm: 20 (-[DOMHTMLSelectElement _activateItemAtIndex:allowMultipleSelection:]): 21 * bindings/objc/DOMPrivate.h: unified the Category name. Was "FormsAutocomplete" now all are "FormAutocomplete". 22 * dom/SelectElement.h: 23 * html/HTMLSelectElement.cpp: 24 (WebCore::HTMLSelectElement::setSelectedIndexByUser): listboxs need to be treated specially to fire their "change" event. 25 * html/HTMLSelectElement.h: 26 * wml/WMLSelectElement.cpp: 27 (WebCore::WMLSelectElement::setSelectedIndexByUser): 28 1 29 2010-09-07 Simon Fraser <simon.fraser@apple.com> 2 30 -
trunk/WebCore/bindings/objc/DOMHTML.mm
r65021 r66929 167 167 } 168 168 169 - (void)_activateItemAtIndex:(int)index allowMultipleSelection:(BOOL)allowMultipleSelection 170 { 171 // Use the setSelectedIndexByUser function so a change event will be fired. <rdar://problem/6760590> 172 // If this is a <select multiple> the allowMultipleSelection flag will allow setting multiple 173 // selections without clearing the other selections. 174 if (WebCore::HTMLSelectElement* select = core(self)) 175 select->setSelectedIndexByUser(index, true, true, allowMultipleSelection); 176 } 177 169 178 @end 170 179 -
trunk/WebCore/bindings/objc/DOMPrivate.h
r51850 r66929 70 70 // Each one should eventually be replaced by public DOM API, and when that happens Safari will switch to implementations 71 71 // using that public API, and these will be deleted. 72 @interface DOMHTMLInputElement (Form sAutoFillTransition)72 @interface DOMHTMLInputElement (FormAutoFillTransition) 73 73 - (BOOL)_isAutofilled; 74 74 - (BOOL)_isTextField; … … 93 93 // replaceable by public DOM API, and when that happens Safari will switch to implementations using that public API, 94 94 // and these will be deleted. 95 @interface DOMHTMLSelectElement (Form sAutoFillTransition)95 @interface DOMHTMLSelectElement (FormAutoFillTransition) 96 96 - (void)_activateItemAtIndex:(int)index; 97 - (void)_activateItemAtIndex:(int)index allowMultipleSelection:(BOOL)allowMultipleSelection; 97 98 @end -
trunk/WebCore/dom/SelectElement.h
r65021 r66929 60 60 virtual int selectedIndex() const = 0; 61 61 virtual void setSelectedIndex(int index, bool deselect = true) = 0; 62 virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false ) = 0;62 virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false, bool allowMultipleSelection = false) = 0; 63 63 64 64 virtual void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true) = 0; -
trunk/WebCore/html/HTMLSelectElement.cpp
r65986 r66929 86 86 } 87 87 88 void HTMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow) 89 { 88 void HTMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow, bool allowMultipleSelection) 89 { 90 // List box selects can fire onchange events through user interaction, such as 91 // mousedown events. This allows that same behavior programmatically. 92 if (!m_data.usesMenuList()) { 93 updateSelectedState(m_data, this, optionIndex, allowMultipleSelection, false); 94 if (fireOnChangeNow) 95 listBoxOnChange(); 96 return; 97 } 98 90 99 // Bail out if this index is already the selected one, to avoid running unnecessary JavaScript that can mess up 91 100 // autofill, when there is no actual change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and rdar://7467917 ). -
trunk/WebCore/html/HTMLSelectElement.h
r65986 r66929 42 42 virtual int selectedIndex() const; 43 43 virtual void setSelectedIndex(int index, bool deselect = true); 44 virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false );44 virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false, bool allowMultipleSelection = false); 45 45 46 46 unsigned length() const; -
trunk/WebCore/wml/WMLSelectElement.cpp
r66498 r66929 115 115 } 116 116 117 void WMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow) 118 { 117 void WMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow, bool allowMultipleSelection) 118 { 119 UNUSED_PARAM(allowMultipleSelection); 119 120 SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, fireOnChangeNow, true); 120 121 }
Note: See TracChangeset
for help on using the changeset viewer.