Changeset 97238 in webkit
- Timestamp:
- Oct 12, 2011 12:14:12 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r97227 r97238 581 581 dom/ScriptExecutionContext.cpp 582 582 dom/ScriptRunner.cpp 583 dom/SelectElement.cpp584 583 dom/SelectorQuery.cpp 585 584 dom/ShadowContentElement.cpp -
trunk/Source/WebCore/ChangeLog
r97237 r97238 1 2011-10-12 Kent Tamura <tkent@chromium.org> 2 3 Move the content of SelectElementData into HTMLSelectElement, and remove SelectElement.{cpp,h} 4 https://bugs.webkit.org/show_bug.cgi?id=69828 5 6 Reviewed by Darin Adler. 7 8 - Move all of the data members of SelectElementData to 9 HTMLSelectElement, and their accessor functions are not needed 10 anymore. 11 - Move SelectElementData::useMenuList() to HTMLSelectElement. 12 13 No new tests, just a refactoring. 14 15 * CMakeLists.txt: Remove SelectElement.cpp. 16 * WebCore.gypi: Remove SelectElement.{cpp,h}. 17 * WebCore.pro: ditto. 18 * WebCore.vcproj/WebCore.vcproj: ditto. 19 * WebCore.xcodeproj/project.pbxproj: ditto. 20 * dom/OptionElement.cpp: Remove a reference to SelectElement.h. 21 * dom/SelectElement.cpp: Removed. 22 * dom/SelectElement.h: Removed. 23 * html/HTMLSelectElement.cpp: 24 (WebCore::HTMLSelectElement::HTMLSelectElement): 25 Initializes the moved data members. 26 (WebCore::HTMLSelectElement::formControlType): 27 (WebCore::HTMLSelectElement::setSelectedIndexByUser): 28 (WebCore::HTMLSelectElement::activeSelectionStartListIndex): 29 (WebCore::HTMLSelectElement::activeSelectionEndListIndex): 30 (WebCore::HTMLSelectElement::parseMappedAttribute): 31 (WebCore::HTMLSelectElement::canSelectAll): 32 (WebCore::HTMLSelectElement::createRenderer): 33 (WebCore::HTMLSelectElement::setOption): 34 (WebCore::HTMLSelectElement::selectAll): 35 (WebCore::HTMLSelectElement::saveLastSelection): 36 (WebCore::HTMLSelectElement::setActiveSelectionAnchorIndex): 37 (WebCore::HTMLSelectElement::setActiveSelectionEndIndex): 38 (WebCore::HTMLSelectElement::updateListBoxSelection): 39 (WebCore::HTMLSelectElement::listBoxOnChange): 40 (WebCore::HTMLSelectElement::menuListOnChange): 41 (WebCore::HTMLSelectElement::scrollToSelection): 42 (WebCore::HTMLSelectElement::setOptionsChangedOnRenderer): 43 (WebCore::HTMLSelectElement::setRecalcListItems): 44 (WebCore::HTMLSelectElement::recalcListItemsInternal): 45 (WebCore::HTMLSelectElement::setSelectedIndexInternal): 46 (WebCore::HTMLSelectElement::dispatchFocusEvent): 47 (WebCore::HTMLSelectElement::dispatchBlurEvent): 48 (WebCore::HTMLSelectElement::parseMultipleAttribute): 49 (WebCore::HTMLSelectElement::reset): 50 (WebCore::HTMLSelectElement::menuListDefaultEventHandler): 51 (WebCore::HTMLSelectElement::updateSelectedState): 52 (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): 53 (WebCore::HTMLSelectElement::defaultEventHandler): 54 (WebCore::HTMLSelectElement::typeAheadFind): 55 (WebCore::HTMLSelectElement::accessKeySetSelectedIndex): 56 * html/HTMLSelectElement.h: 57 (WebCore::HTMLSelectElement::size): 58 (WebCore::HTMLSelectElement::multiple): 59 (WebCore::HTMLSelectElement::usesMenuList): 60 1 61 2011-10-12 Ryosuke Niwa <rniwa@webkit.org> 2 62 -
trunk/Source/WebCore/WebCore.gypi
r97227 r97238 5288 5288 'dom/ScriptedAnimationController.cpp', 5289 5289 'dom/ScriptedAnimationController.h', 5290 'dom/SelectElement.cpp',5291 'dom/SelectElement.h',5292 5290 'dom/SelectorQuery.cpp', 5293 5291 'dom/SelectorQuery.h', -
trunk/Source/WebCore/WebCore.pro
r97227 r97238 549 549 dom/ScriptExecutionContext.cpp \ 550 550 dom/ScriptRunner.cpp \ 551 dom/SelectElement.cpp \552 551 dom/SelectorQuery.cpp \ 553 552 dom/ShadowContentElement.cpp \ … … 1565 1564 dom/ScriptElement.h \ 1566 1565 dom/ScriptExecutionContext.h \ 1567 dom/SelectElement.h \1568 1566 dom/SelectorQuery.h \ 1569 1567 dom/ShadowContentElement.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r97227 r97238 48771 48771 </File> 48772 48772 <File 48773 RelativePath="..\dom\SelectElement.cpp"48774 >48775 <FileConfiguration48776 Name="Debug|Win32"48777 ExcludedFromBuild="true"48778 >48779 <Tool48780 Name="VCCLCompilerTool"48781 />48782 </FileConfiguration>48783 <FileConfiguration48784 Name="Release|Win32"48785 ExcludedFromBuild="true"48786 >48787 <Tool48788 Name="VCCLCompilerTool"48789 />48790 </FileConfiguration>48791 <FileConfiguration48792 Name="Debug_Cairo_CFLite|Win32"48793 ExcludedFromBuild="true"48794 >48795 <Tool48796 Name="VCCLCompilerTool"48797 />48798 </FileConfiguration>48799 <FileConfiguration48800 Name="Release_Cairo_CFLite|Win32"48801 ExcludedFromBuild="true"48802 >48803 <Tool48804 Name="VCCLCompilerTool"48805 />48806 </FileConfiguration>48807 <FileConfiguration48808 Name="Debug_All|Win32"48809 ExcludedFromBuild="true"48810 >48811 <Tool48812 Name="VCCLCompilerTool"48813 />48814 </FileConfiguration>48815 <FileConfiguration48816 Name="Production|Win32"48817 ExcludedFromBuild="true"48818 >48819 <Tool48820 Name="VCCLCompilerTool"48821 />48822 </FileConfiguration>48823 </File>48824 <File48825 RelativePath="..\dom\SelectElement.h"48826 >48827 </File>48828 <File48829 48773 RelativePath="..\dom\SelectorQuery.cpp" 48830 48774 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r97227 r97238 110 110 0845680812B90DA600960A9F /* FontMetrics.h in Headers */ = {isa = PBXBuildFile; fileRef = 0845680712B90DA600960A9F /* FontMetrics.h */; settings = {ATTRIBUTES = (Private, ); }; }; 111 111 084A0829128D7867002DB1F1 /* SVGPathSegListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 084A0828128D7867002DB1F1 /* SVGPathSegListPropertyTearOff.h */; }; 112 084AEBE40FB505FA0038483E /* SelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 084AEBE20FB505FA0038483E /* SelectElement.cpp */; };113 084AEBE50FB505FA0038483E /* SelectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 084AEBE30FB505FA0038483E /* SelectElement.h */; };114 112 084DB59B128008CC002A6D64 /* SVGAnimatedString.h in Headers */ = {isa = PBXBuildFile; fileRef = 084DB59A128008CC002A6D64 /* SVGAnimatedString.h */; settings = {ATTRIBUTES = (Private, ); }; }; 115 113 08525E631278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 7122 7120 0845680712B90DA600960A9F /* FontMetrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontMetrics.h; sourceTree = "<group>"; }; 7123 7121 084A0828128D7867002DB1F1 /* SVGPathSegListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegListPropertyTearOff.h; sourceTree = "<group>"; }; 7124 084AEBE20FB505FA0038483E /* SelectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectElement.cpp; sourceTree = "<group>"; };7125 084AEBE30FB505FA0038483E /* SelectElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectElement.h; sourceTree = "<group>"; };7126 7122 084DB59A128008CC002A6D64 /* SVGAnimatedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedString.h; sourceTree = "<group>"; }; 7127 7123 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedStaticPropertyTearOff.h; sourceTree = "<group>"; }; … … 21201 21197 8A413ADF1207BBA50082016E /* ScriptRunner.cpp */, 21202 21198 8A413ADE1207BBA50082016E /* ScriptRunner.h */, 21203 084AEBE20FB505FA0038483E /* SelectElement.cpp */,21204 084AEBE30FB505FA0038483E /* SelectElement.h */,21205 21199 E45322A9140CE267005A0F92 /* SelectorQuery.cpp */, 21206 21200 E45322AA140CE267005A0F92 /* SelectorQuery.h */, … … 23990 23984 371F4FFC0D25E7F300ECE0D5 /* SegmentedFontData.h in Headers */, 23991 23985 B2C3DA2F0D006C1D00EF6F26 /* SegmentedString.h in Headers */, 23992 084AEBE50FB505FA0038483E /* SelectElement.h in Headers */,23993 23986 A75E497610752ACB00C9B896 /* SerializedScriptValue.h in Headers */, 23994 23987 93309E10099E64920056E581 /* SetNodeAttributeCommand.h in Headers */, … … 26975 26968 371F4FFD0D25E7F300ECE0D5 /* SegmentedFontData.cpp in Sources */, 26976 26969 B2C3DA2E0D006C1D00EF6F26 /* SegmentedString.cpp in Sources */, 26977 084AEBE40FB505FA0038483E /* SelectElement.cpp in Sources */,26978 26970 A75E497710752ACB00C9B896 /* SerializedScriptValue.cpp in Sources */, 26979 26971 93309E0F099E64920056E581 /* SetNodeAttributeCommand.cpp in Sources */, -
trunk/Source/WebCore/dom/OptionElement.cpp
r96907 r97238 30 30 #include "OptionGroupElement.h" 31 31 #include "ScriptElement.h" 32 #include "SelectElement.h"33 32 #include <wtf/Assertions.h> 34 33 -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r97135 r97238 77 77 HTMLSelectElement::HTMLSelectElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) 78 78 : HTMLFormControlElementWithState(tagName, document, form) 79 , m_lastCharTime(0) 80 , m_size(0) 81 , m_lastOnChangeIndex(-1) 82 , m_activeSelectionAnchorIndex(-1) 83 , m_activeSelectionEndIndex(-1) 84 , m_repeatingChar(0) 85 , m_userDrivenChange(false) 86 , m_multiple(false) 87 , m_activeSelectionState(false) 79 88 , m_recalcListItems(false) 80 89 { … … 92 101 DEFINE_STATIC_LOCAL(const AtomicString, selectMultiple, ("select-multiple")); 93 102 DEFINE_STATIC_LOCAL(const AtomicString, selectOne, ("select-one")); 94 return m_ data.multiple()? selectMultiple : selectOne;103 return m_multiple ? selectMultiple : selectOne; 95 104 } 96 105 … … 110 119 // List box selects can fire onchange events through user interaction, such as 111 120 // mousedown events. This allows that same behavior programmatically. 112 if (! m_data.usesMenuList()) {121 if (!usesMenuList()) { 113 122 updateSelectedState(optionIndex, allowMultipleSelection, false); 114 123 setNeedsValidityCheck(); … … 177 186 int HTMLSelectElement::activeSelectionStartListIndex() const 178 187 { 179 if (m_ data.activeSelectionAnchorIndex()>= 0)180 return m_ data.activeSelectionAnchorIndex();188 if (m_activeSelectionAnchorIndex >= 0) 189 return m_activeSelectionAnchorIndex; 181 190 return optionToListIndex(selectedIndex()); 182 191 } … … 184 193 int HTMLSelectElement::activeSelectionEndListIndex() const 185 194 { 186 if (m_ data.activeSelectionEndIndex()>= 0)187 return m_ data.activeSelectionEndIndex();195 if (m_activeSelectionEndIndex >= 0) 196 return m_activeSelectionEndIndex; 188 197 return lastSelectedListIndex(); 189 198 } … … 251 260 { 252 261 if (attr->name() == sizeAttr) { 253 int oldSize = m_ data.size();262 int oldSize = m_size; 254 263 // Set the attribute value to a number. 255 264 // This is important since the style rules for this attribute can determine the appearance property. … … 264 273 recalcListItemsIfNeeded(); 265 274 266 m_ data.setSize(size);275 m_size = size; 267 276 setNeedsValidityCheck(); 268 if (m_ data.size()!= oldSize && attached()) {277 if (m_size != oldSize && attached()) { 269 278 reattach(); 270 279 setRecalcListItems(); … … 299 308 bool HTMLSelectElement::canSelectAll() const 300 309 { 301 return ! m_data.usesMenuList();310 return !usesMenuList(); 302 311 } 303 312 304 313 RenderObject* HTMLSelectElement::createRenderer(RenderArena* arena, RenderStyle*) 305 314 { 306 if ( m_data.usesMenuList())315 if (usesMenuList()) 307 316 return new (arena) RenderMenuList(this); 308 317 return new (arena) RenderListBox(this); … … 387 396 add(option, before, ec); 388 397 if (diff >= 0 && option->selected()) 389 setSelectedIndex(index, !m_ data.multiple());398 setSelectedIndex(index, !m_multiple); 390 399 } 391 400 } … … 501 510 void HTMLSelectElement::selectAll() 502 511 { 503 ASSERT(! m_data.usesMenuList());504 if (!renderer() || !m_ data.multiple())512 ASSERT(!usesMenuList()); 513 if (!renderer() || !m_multiple) 505 514 return; 506 515 … … 509 518 saveLastSelection(); 510 519 511 m_ data.setActiveSelectionState(true);520 m_activeSelectionState = true; 512 521 setActiveSelectionAnchorIndex(nextSelectableListIndex(-1)); 513 522 setActiveSelectionEndIndex(previousSelectableListIndex(-1)); … … 520 529 void HTMLSelectElement::saveLastSelection() 521 530 { 522 if ( m_data.usesMenuList()) {523 m_ data.setLastOnChangeIndex(selectedIndex());531 if (usesMenuList()) { 532 m_lastOnChangeIndex = selectedIndex(); 524 533 return; 525 534 } 526 535 527 Vector<bool>& lastOnChangeSelection = m_data.lastOnChangeSelection(); 528 lastOnChangeSelection.clear(); 529 536 m_lastOnChangeSelection.clear(); 530 537 const Vector<Element*>& items = listItems(); 531 538 for (unsigned i = 0; i < items.size(); ++i) { 532 539 OptionElement* optionElement = toOptionElement(items[i]); 533 lastOnChangeSelection.append(optionElement && optionElement->selected());540 m_lastOnChangeSelection.append(optionElement && optionElement->selected()); 534 541 } 535 542 } … … 537 544 void HTMLSelectElement::setActiveSelectionAnchorIndex(int index) 538 545 { 539 m_ data.setActiveSelectionAnchorIndex(index);546 m_activeSelectionAnchorIndex = index; 540 547 541 548 // Cache the selection state so we can restore the old selection as the new 542 549 // selection pivots around this anchor index 543 Vector<bool>& cachedStateForActiveSelection = m_data.cachedStateForActiveSelection(); 544 cachedStateForActiveSelection.clear(); 550 m_cachedStateForActiveSelection.clear(); 545 551 546 552 const Vector<Element*>& items = listItems(); 547 553 for (unsigned i = 0; i < items.size(); ++i) { 548 554 OptionElement* optionElement = toOptionElement(items[i]); 549 cachedStateForActiveSelection.append(optionElement && optionElement->selected());555 m_cachedStateForActiveSelection.append(optionElement && optionElement->selected()); 550 556 } 551 557 } … … 553 559 void HTMLSelectElement::setActiveSelectionEndIndex(int index) 554 560 { 555 m_ data.setActiveSelectionEndIndex(index);561 m_activeSelectionEndIndex = index; 556 562 } 557 563 558 564 void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions) 559 565 { 560 ASSERT(renderer() && (renderer()->isListBox() || m_data.multiple())); 561 ASSERT(!listItems().size() || m_data.activeSelectionAnchorIndex() >= 0); 562 563 unsigned start = min(m_data.activeSelectionAnchorIndex(), m_data.activeSelectionEndIndex()); 564 unsigned end = max(m_data.activeSelectionAnchorIndex(), m_data.activeSelectionEndIndex()); 565 Vector<bool>& cachedStateForActiveSelection = m_data.cachedStateForActiveSelection(); 566 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); 567 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); 568 569 unsigned start = min(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex); 570 unsigned end = max(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex); 566 571 567 572 const Vector<Element*>& items = listItems(); … … 572 577 573 578 if (i >= start && i <= end) 574 optionElement->setSelectedState(m_ data.activeSelectionState());575 else if (deselectOtherOptions || i >= cachedStateForActiveSelection.size())579 optionElement->setSelectedState(m_activeSelectionState); 580 else if (deselectOtherOptions || i >= m_cachedStateForActiveSelection.size()) 576 581 optionElement->setSelectedState(false); 577 582 else 578 optionElement->setSelectedState( cachedStateForActiveSelection[i]);583 optionElement->setSelectedState(m_cachedStateForActiveSelection[i]); 579 584 } 580 585 … … 585 590 void HTMLSelectElement::listBoxOnChange() 586 591 { 587 ASSERT(!m_data.usesMenuList() || m_data.multiple()); 588 589 Vector<bool>& lastOnChangeSelection = m_data.lastOnChangeSelection(); 592 ASSERT(!usesMenuList() || m_multiple); 593 590 594 const Vector<Element*>& items = listItems(); 591 595 592 596 // If the cached selection list is empty, or the size has changed, then fire 593 597 // dispatchFormControlChangeEvent, and return early. 594 if ( lastOnChangeSelection.isEmpty() ||lastOnChangeSelection.size() != items.size()) {598 if (m_lastOnChangeSelection.isEmpty() || m_lastOnChangeSelection.size() != items.size()) { 595 599 dispatchFormControlChangeEvent(); 596 600 return; … … 602 606 OptionElement* optionElement = toOptionElement(items[i]); 603 607 bool selected = optionElement && optionElement->selected(); 604 if (selected != lastOnChangeSelection[i])608 if (selected != m_lastOnChangeSelection[i]) 605 609 fireOnChange = true; 606 lastOnChangeSelection[i] = selected;610 m_lastOnChangeSelection[i] = selected; 607 611 } 608 612 … … 613 617 void HTMLSelectElement::menuListOnChange() 614 618 { 615 ASSERT( m_data.usesMenuList());619 ASSERT(usesMenuList()); 616 620 617 621 int selected = selectedIndex(); 618 if (m_ data.lastOnChangeIndex() != selected && m_data.userDrivenChange()) {619 m_ data.setLastOnChangeIndex(selected);620 m_ data.setUserDrivenChange(false);622 if (m_lastOnChangeIndex != selected && m_userDrivenChange) { 623 m_lastOnChangeIndex = selected; 624 m_userDrivenChange = false; 621 625 dispatchFormControlChangeEvent(); 622 626 } … … 625 629 void HTMLSelectElement::scrollToSelection() 626 630 { 627 if ( m_data.usesMenuList())631 if (usesMenuList()) 628 632 return; 629 633 … … 635 639 { 636 640 if (RenderObject* renderer = this->renderer()) { 637 if ( m_data.usesMenuList())641 if (usesMenuList()) 638 642 toRenderMenuList(renderer)->setOptionsChanged(true); 639 643 else … … 665 669 m_recalcListItems = true; 666 670 // Manual selection anchor is reset when manipulating the select programmatically. 667 m_ data.setActiveSelectionAnchorIndex(-1);671 m_activeSelectionAnchorIndex = -1; 668 672 setOptionsChangedOnRenderer(); 669 673 setNeedsStyleRecalc(); … … 701 705 m_listItems.append(current); 702 706 703 if (updateSelectedStates && !m_ data.multiple()) {704 if (!foundSelected && (m_ data.size()<= 1 || optionElement->selected())) {707 if (updateSelectedStates && !m_multiple) { 708 if (!foundSelected && (m_size <= 1 || optionElement->selected())) { 705 709 foundSelected = optionElement; 706 710 foundSelected->setSelectedState(true); … … 744 748 void HTMLSelectElement::setSelectedIndexInternal(int optionIndex, bool deselect, bool fireOnChangeNow, bool userDrivenChange) 745 749 { 746 if (optionIndex == -1 && !deselect && !m_ data.multiple())750 if (optionIndex == -1 && !deselect && !m_multiple) 747 751 optionIndex = nextSelectableListIndex(-1); 748 if (!m_ data.multiple())752 if (!m_multiple) 749 753 deselect = true; 750 754 … … 755 759 if (OptionElement* optionElement = (listIndex >= 0 ? toOptionElement(items[listIndex]) : 0)) { 756 760 excludeElement = items[listIndex]; 757 if (m_ data.activeSelectionAnchorIndex()< 0 || deselect)761 if (m_activeSelectionAnchorIndex < 0 || deselect) 758 762 setActiveSelectionAnchorIndex(listIndex); 759 if (m_ data.activeSelectionEndIndex()< 0 || deselect)763 if (m_activeSelectionEndIndex < 0 || deselect) 760 764 setActiveSelectionEndIndex(listIndex); 761 765 optionElement->setSelectedState(true); … … 772 776 773 777 // This only gets called with fireOnChangeNow for menu lists. 774 if ( m_data.usesMenuList()) {775 m_ data.setUserDrivenChange(userDrivenChange);778 if (usesMenuList()) { 779 m_userDrivenChange = userDrivenChange; 776 780 if (fireOnChangeNow) 777 781 menuListOnChange(); 778 782 RenderObject* renderer = this->renderer(); 779 783 if (renderer) { 780 if ( m_data.usesMenuList())784 if (usesMenuList()) 781 785 toRenderMenuList(renderer)->didSetSelectedIndex(listIndex); 782 786 else if (renderer->isListBox()) … … 829 833 // Save the selection so it can be compared to the new selection when 830 834 // dispatching change events during blur event dispatchal 831 if ( m_data.usesMenuList())835 if (usesMenuList()) 832 836 saveLastSelection(); 833 837 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedNode); … … 839 843 // change events for list boxes whenever the selection change is actually made. 840 844 // This matches other browsers' behavior. 841 if ( m_data.usesMenuList())845 if (usesMenuList()) 842 846 menuListOnChange(); 843 847 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode); … … 891 895 void HTMLSelectElement::parseMultipleAttribute(const Attribute* attribute) 892 896 { 893 bool oldUsesMenuList = m_data.usesMenuList();894 m_ data.setMultiple(!attribute->isNull());897 bool oldUsesMenuList = usesMenuList(); 898 m_multiple = !attribute->isNull(); 895 899 updateValidity(); 896 if (oldUsesMenuList != m_data.usesMenuList())900 if (oldUsesMenuList != usesMenuList()) 897 901 reattachIfAttached(); 898 902 } … … 933 937 934 938 if (items[i]->fastHasAttribute(selectedAttr)) { 935 if (selectedOption && !m_ data.multiple())939 if (selectedOption && !m_multiple) 936 940 selectedOption->setSelectedState(false); 937 941 optionElement->setSelectedState(true); … … 944 948 } 945 949 946 if (!selectedOption && firstOption && !m_ data.multiple() && m_data.size()<= 1)950 if (!selectedOption && firstOption && !m_multiple && m_size <= 1) 947 951 firstOption->setSelectedState(true); 948 952 … … 994 998 // instead of changing the selection. 995 999 if (isSpatialNavigationEnabled(document()->frame())) { 996 if (!m_ data.activeSelectionState())1000 if (!m_activeSelectionState) 997 1001 return; 998 1002 } … … 1036 1040 if (keyCode == ' ' && isSpatialNavigationEnabled(document()->frame())) { 1037 1041 // Use space to toggle arrow key handling for selection change or spatial navigation. 1038 m_ data.setActiveSelectionState(!m_data.activeSelectionState());1042 m_activeSelectionState = !m_activeSelectionState; 1039 1043 event->setDefaultHandled(); 1040 1044 return; … … 1123 1127 saveLastSelection(); 1124 1128 1125 m_ data.setActiveSelectionState(true);1126 1127 bool shiftSelect = m_ data.multiple()&& shift;1128 bool multiSelect = m_ data.multiple()&& multi && !shift;1129 m_activeSelectionState = true; 1130 1131 bool shiftSelect = m_multiple && shift; 1132 bool multiSelect = m_multiple && multi && !shift; 1129 1133 1130 1134 Element* clickedElement = listItems()[listIndex]; … … 1134 1138 // selection), should select or deselect 1135 1139 if (option->selected() && multi) 1136 m_ data.setActiveSelectionState(false);1137 1138 if (!m_ data.activeSelectionState())1140 m_activeSelectionState = false; 1141 1142 if (!m_activeSelectionState) 1139 1143 option->setSelectedState(false); 1140 1144 } … … 1148 1152 // If the anchor hasn't been set, and we're doing a single selection or a 1149 1153 // shift selection, then initialize the anchor to the first selected index. 1150 if (m_ data.activeSelectionAnchorIndex()< 0 && !multiSelect)1154 if (m_activeSelectionAnchorIndex < 0 && !multiSelect) 1151 1155 setActiveSelectionAnchorIndex(selectedIndex()); 1152 1156 … … 1159 1163 // ctrl), then initialize the anchor index to the listIndex that just got 1160 1164 // clicked. 1161 if (m_ data.activeSelectionAnchorIndex()< 0 || !shiftSelect)1165 if (m_activeSelectionAnchorIndex < 0 || !shiftSelect) 1162 1166 setActiveSelectionAnchorIndex(listIndex); 1163 1167 … … 1203 1207 bool handled = false; 1204 1208 int endIndex = 0; 1205 if (m_ data.activeSelectionEndIndex()< 0) {1209 if (m_activeSelectionEndIndex < 0) { 1206 1210 // Initialize the end index 1207 1211 if (keyIdentifier == "Down" || keyIdentifier == "PageDown") { … … 1223 1227 // Set the end index based on the current end index 1224 1228 if (keyIdentifier == "Down") { 1225 endIndex = nextSelectableListIndex(m_ data.activeSelectionEndIndex());1229 endIndex = nextSelectableListIndex(m_activeSelectionEndIndex); 1226 1230 handled = true; 1227 1231 } else if (keyIdentifier == "Up") { 1228 endIndex = previousSelectableListIndex(m_ data.activeSelectionEndIndex());1232 endIndex = previousSelectableListIndex(m_activeSelectionEndIndex); 1229 1233 handled = true; 1230 1234 } else if (keyIdentifier == "PageDown") { 1231 endIndex = nextSelectableListIndexPageAway(m_ data.activeSelectionEndIndex(), SkipForwards);1235 endIndex = nextSelectableListIndexPageAway(m_activeSelectionEndIndex, SkipForwards); 1232 1236 handled = true; 1233 1237 } else if (keyIdentifier == "PageUp") { 1234 endIndex = nextSelectableListIndexPageAway(m_ data.activeSelectionEndIndex(), SkipBackwards);1238 endIndex = nextSelectableListIndexPageAway(m_activeSelectionEndIndex, SkipBackwards); 1235 1239 handled = true; 1236 1240 } … … 1246 1250 if (isSpatialNavigationEnabled(document()->frame())) 1247 1251 // Check if the selection moves to the boundary. 1248 if (keyIdentifier == "Left" || keyIdentifier == "Right" || ((keyIdentifier == "Down" || keyIdentifier == "Up") && endIndex == m_ data.activeSelectionEndIndex()))1252 if (keyIdentifier == "Left" || keyIdentifier == "Right" || ((keyIdentifier == "Down" || keyIdentifier == "Up") && endIndex == m_activeSelectionEndIndex)) 1249 1253 return; 1250 1254 … … 1258 1262 setActiveSelectionEndIndex(endIndex); 1259 1263 1260 bool selectNewItem = !m_ data.multiple()|| static_cast<KeyboardEvent*>(event)->shiftKey() || !isSpatialNavigationEnabled(document()->frame());1264 bool selectNewItem = !m_multiple || static_cast<KeyboardEvent*>(event)->shiftKey() || !isSpatialNavigationEnabled(document()->frame()); 1261 1265 if (selectNewItem) 1262 m_ data.setActiveSelectionState(true);1266 m_activeSelectionState = true; 1263 1267 // If the anchor is unitialized, or if we're going to deselect all 1264 1268 // other options, then set the anchor index equal to the end index. 1265 bool deselectOthers = !m_ data.multiple()|| (!static_cast<KeyboardEvent*>(event)->shiftKey() && selectNewItem);1266 if (m_ data.activeSelectionAnchorIndex()< 0 || deselectOthers) {1269 bool deselectOthers = !m_multiple || (!static_cast<KeyboardEvent*>(event)->shiftKey() && selectNewItem); 1270 if (m_activeSelectionAnchorIndex < 0 || deselectOthers) { 1267 1271 if (deselectOthers) 1268 1272 deselectItemsWithoutValidation(); 1269 setActiveSelectionAnchorIndex(m_ data.activeSelectionEndIndex());1273 setActiveSelectionAnchorIndex(m_activeSelectionEndIndex); 1270 1274 } 1271 1275 … … 1288 1292 form()->submitImplicitly(event, false); 1289 1293 event->setDefaultHandled(); 1290 } else if (m_ data.multiple()&& keyCode == ' ' && isSpatialNavigationEnabled(document()->frame())) {1294 } else if (m_multiple && keyCode == ' ' && isSpatialNavigationEnabled(document()->frame())) { 1291 1295 // Use space to toggle selection change. 1292 m_ data.setActiveSelectionState(!m_data.activeSelectionState());1293 updateSelectedState(listToOptionIndex(m_ data.activeSelectionEndIndex()), true /*multi*/, false /*shift*/);1296 m_activeSelectionState = !m_activeSelectionState; 1297 updateSelectedState(listToOptionIndex(m_activeSelectionEndIndex), true /*multi*/, false /*shift*/); 1294 1298 listBoxOnChange(); 1295 1299 event->setDefaultHandled(); … … 1303 1307 return; 1304 1308 1305 if ( m_data.usesMenuList())1309 if (usesMenuList()) 1306 1310 menuListDefaultEventHandler(event); 1307 1311 else … … 1354 1358 void HTMLSelectElement::typeAheadFind(KeyboardEvent* event) 1355 1359 { 1356 if (event->timeStamp() < m_ data.lastCharTime())1360 if (event->timeStamp() < m_lastCharTime) 1357 1361 return; 1358 1362 1359 DOMTimeStamp delta = event->timeStamp() - m_ data.lastCharTime();1360 m_ data.setLastCharTime(event->timeStamp());1363 DOMTimeStamp delta = event->timeStamp() - m_lastCharTime; 1364 m_lastCharTime = event->timeStamp(); 1361 1365 1362 1366 UChar c = event->charCode(); … … 1366 1370 if (delta > typeAheadTimeout) { 1367 1371 prefix = String(&c, 1); 1368 m_ data.setTypedString(prefix);1369 m_ data.setRepeatingChar(c);1372 m_typedString = prefix; 1373 m_repeatingChar = c; 1370 1374 } else { 1371 m_ data.typedString().append(c);1372 1373 if (c == m_ data.repeatingChar()) {1375 m_typedString.append(c); 1376 1377 if (c == m_repeatingChar) { 1374 1378 // The user is likely trying to cycle through all the items starting 1375 1379 // with this character, so just search on the character 1376 1380 prefix = String(&c, 1); 1377 1381 } else { 1378 m_ data.setRepeatingChar(0);1379 prefix = m_ data.typedString();1382 m_repeatingChar = 0; 1383 prefix = m_typedString; 1380 1384 searchStartOffset = 0; 1381 1385 } … … 1405 1409 if (stripLeadingWhiteSpace(text).foldCase().startsWith(prefixWithCaseFolded)) { 1406 1410 setSelectedIndexInternal(listToOptionIndex(index)); 1407 if (! m_data.usesMenuList())1411 if (!usesMenuList()) 1408 1412 listBoxOnChange(); 1409 1413 … … 1440 1444 } 1441 1445 1442 if ( m_data.usesMenuList())1446 if (usesMenuList()) 1443 1447 menuListOnChange(); 1444 1448 else -
trunk/Source/WebCore/html/HTMLSelectElement.h
r97135 r97238 30 30 #include "Event.h" 31 31 #include "HTMLFormControlElement.h" 32 #include "SelectElement.h"33 32 #include <wtf/Vector.h> 34 33 … … 51 50 unsigned length() const; 52 51 53 int size() const { return m_ data.size(); }54 bool multiple() const { return m_ data.multiple(); }52 int size() const { return m_size; } 53 bool multiple() const { return m_multiple; } 55 54 56 55 void add(HTMLElement*, HTMLElement* beforeElement, ExceptionCode&); … … 156 155 void listBoxDefaultEventHandler(Event*); 157 156 void setOptionsChangedOnRenderer(); 157 bool usesMenuList() const; 158 158 159 159 enum SkipDirection { … … 168 168 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; 169 169 170 SelectElementData m_data;171 170 CollectionCache m_collectionInfo; 172 171 Vector<Element*> m_listItems; 172 Vector<bool> m_lastOnChangeSelection; 173 Vector<bool> m_cachedStateForActiveSelection; 174 DOMTimeStamp m_lastCharTime; 175 String m_typedString; 176 int m_size; 177 int m_lastOnChangeIndex; 178 int m_activeSelectionAnchorIndex; 179 int m_activeSelectionEndIndex; 180 UChar m_repeatingChar; 181 bool m_userDrivenChange; 182 bool m_multiple; 183 bool m_activeSelectionState; 173 184 bool m_recalcListItems; 174 185 }; … … 176 187 HTMLSelectElement* toSelectElement(Element*); 177 188 189 inline bool HTMLSelectElement::usesMenuList() const 190 { 191 #if ENABLE(NO_LISTBOX_RENDERING) 192 return true; 193 #else 194 return !m_multiple && m_size <= 1; 195 #endif 196 } 197 178 198 } // namespace 179 199
Note: See TracChangeset
for help on using the changeset viewer.