Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (98218 => 98219)
--- trunk/Source/WebCore/CMakeLists.txt 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-10-24 06:59:15 UTC (rev 98219)
@@ -576,7 +576,6 @@
dom/NodeIterator.cpp
dom/NodeRenderingContext.cpp
dom/Notation.cpp
- dom/OptionElement.cpp
dom/OverflowEvent.cpp
dom/PageTransitionEvent.cpp
dom/PendingScript.cpp
Modified: trunk/Source/WebCore/ChangeLog (98218 => 98219)
--- trunk/Source/WebCore/ChangeLog 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/ChangeLog 2011-10-24 06:59:15 UTC (rev 98219)
@@ -1,3 +1,44 @@
+2011-10-23 Darin Adler <da...@apple.com>
+
+ Eliminate OptionElement (second and final part)
+ https://bugs.webkit.org/show_bug.cgi?id=70710
+
+ Reviewed by Kent Tamura.
+
+ * CMakeLists.txt: Removed OptionElement.h and OptionElement.cpp.
+ * GNUmakefile.list.am: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.pro: Ditto.
+ * WebCore.vcproj/WebCore.vcproj: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * dom/DOMAllInOne.cpp: Ditto.
+
+ * dom/OptionElement.cpp: Removed.
+ * dom/OptionElement.h: Removed.
+
+ * html/HTMLSelectElement.cpp:
+ (WebCore::HTMLSelectElement::saveLastSelection): Eliminate use of the
+ toOptionElement function. Use hasTagName and toHTMLOptionElement instead.
+ (WebCore::HTMLSelectElement::setActiveSelectionAnchorIndex): Ditto.
+ (WebCore::HTMLSelectElement::updateListBoxSelection): Ditto.
+ (WebCore::HTMLSelectElement::listBoxOnChange): Ditto.
+ (WebCore::HTMLSelectElement::recalcListItems): Ditto.
+ (WebCore::HTMLSelectElement::selectedIndex): Ditto.
+ (WebCore::HTMLSelectElement::setSelectedIndex): Ditto.
+ (WebCore::HTMLSelectElement::deselectItemsWithoutValidation): Ditto.
+ (WebCore::HTMLSelectElement::saveFormControlState): Ditto.
+ (WebCore::HTMLSelectElement::restoreFormControlState): Ditto.
+ (WebCore::HTMLSelectElement::appendFormData): Ditto.
+ (WebCore::HTMLSelectElement::reset): Ditto.
+ (WebCore::HTMLSelectElement::updateSelectedState): Ditto.
+ (WebCore::HTMLSelectElement::lastSelectedListIndex): Ditto.
+ (WebCore::HTMLSelectElement::typeAheadFind): Ditto.
+ (WebCore::HTMLSelectElement::accessKeySetSelectedIndex): Ditto.
+
+ * html/HTMLSelectElement.h: Changed the argument type of the
+ deselectItemsWithoutValidation function to HTMLElement* since that's
+ the type of an item in our items vector now.
+
2011-10-23 Yuzo Fujishima <y...@google.com>
[chromium] Attempt to fix compilation error for Chromium OS.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (98218 => 98219)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-10-24 06:59:15 UTC (rev 98219)
@@ -1276,8 +1276,6 @@
Source/WebCore/dom/NodeWithIndex.h \
Source/WebCore/dom/Notation.cpp \
Source/WebCore/dom/Notation.h \
- Source/WebCore/dom/OptionElement.cpp \
- Source/WebCore/dom/OptionElement.h \
Source/WebCore/dom/OverflowEvent.cpp \
Source/WebCore/dom/OverflowEvent.h \
Source/WebCore/dom/PageTransitionEvent.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (98218 => 98219)
--- trunk/Source/WebCore/WebCore.gypi 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/WebCore.gypi 2011-10-24 06:59:15 UTC (rev 98219)
@@ -5255,8 +5255,6 @@
'dom/NodeWithIndex.h',
'dom/Notation.cpp',
'dom/Notation.h',
- 'dom/OptionElement.cpp',
- 'dom/OptionElement.h',
'dom/OverflowEvent.cpp',
'dom/OverflowEvent.h',
'dom/PageTransitionEvent.cpp',
Modified: trunk/Source/WebCore/WebCore.pro (98218 => 98219)
--- trunk/Source/WebCore/WebCore.pro 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/WebCore.pro 2011-10-24 06:59:15 UTC (rev 98219)
@@ -529,7 +529,6 @@
dom/NodeIterator.cpp \
dom/NodeRenderingContext.cpp \
dom/Notation.cpp \
- dom/OptionElement.cpp \
dom/StaticHashSetNodeList.cpp \
dom/OverflowEvent.cpp \
dom/PageTransitionEvent.cpp \
@@ -1579,7 +1578,6 @@
dom/NodeIterator.h \
dom/NodeRenderingContext.h \
dom/Notation.h \
- dom/OptionElement.h \
dom/StaticHashSetNodeList.h \
dom/OverflowEvent.h \
dom/PageTransitionEvent.h \
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (98218 => 98219)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-10-24 06:59:15 UTC (rev 98219)
@@ -46950,62 +46950,6 @@
>
</File>
<File
- RelativePath="..\dom\OptionElement.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug_Cairo_CFLite|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release_Cairo_CFLite|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug_All|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Production|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\dom\OptionElement.h"
- >
- </File>
- <File
RelativePath="..\dom\OverflowEvent.cpp"
>
<FileConfiguration
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (98218 => 98219)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-24 06:59:15 UTC (rev 98219)
@@ -144,8 +144,6 @@
08641D4712142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */; };
08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
086BBD0F136039C2008B15D8 /* Glyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 086BBD0E136039C2008B15D8 /* Glyph.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 087281550F26B9B600AFC596 /* OptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087281510F26B9B600AFC596 /* OptionElement.cpp */; };
- 087281560F26B9B600AFC596 /* OptionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 087281520F26B9B600AFC596 /* OptionElement.h */; };
0873B86B136064EA00A522C2 /* GlyphPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0873B86A136064EA00A522C2 /* GlyphPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087558C313B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp */; };
087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 087558C413B4A57D00F49307 /* SurrogatePairAwareTextIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7142,8 +7140,6 @@
08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImageResourceStyleImage.cpp; sourceTree = "<group>"; };
08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderImageResourceStyleImage.h; sourceTree = "<group>"; };
086BBD0E136039C2008B15D8 /* Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Glyph.h; sourceTree = "<group>"; };
- 087281510F26B9B600AFC596 /* OptionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionElement.cpp; sourceTree = "<group>"; };
- 087281520F26B9B600AFC596 /* OptionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionElement.h; sourceTree = "<group>"; };
0873B86A136064EA00A522C2 /* GlyphPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphPage.h; sourceTree = "<group>"; };
087558C313B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurrogatePairAwareTextIterator.cpp; sourceTree = "<group>"; };
087558C413B4A57D00F49307 /* SurrogatePairAwareTextIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurrogatePairAwareTextIterator.h; sourceTree = "<group>"; };
@@ -21048,8 +21044,6 @@
A8EA7EB70A1945D000A8EF5F /* Notation.cpp */,
A8EA7EB60A1945D000A8EF5F /* Notation.h */,
93EEC1F409C2877700C515D1 /* Notation.idl */,
- 087281510F26B9B600AFC596 /* OptionElement.cpp */,
- 087281520F26B9B600AFC596 /* OptionElement.h */,
1A0D57340A5C77FE007EDD4C /* OverflowEvent.cpp */,
1A0D57350A5C77FE007EDD4C /* OverflowEvent.h */,
1A0D57380A5C7812007EDD4C /* OverflowEvent.idl */,
@@ -23547,7 +23541,6 @@
FDA3E95C134A49EF008D4B5A /* OfflineAudioDestinationNode.h in Headers */,
F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */,
2E2445F71395893A004B6C19 /* OperationNotAllowedException.h in Headers */,
- 087281560F26B9B600AFC596 /* OptionElement.h in Headers */,
0014628B103CD1DE000B20DB /* OriginAccessEntry.h in Headers */,
51A9267D0D53F0570063ECC2 /* OriginQuotaManager.h in Headers */,
51A9267F0D53F0570063ECC2 /* OriginUsageRecord.h in Headers */,
@@ -26584,7 +26577,6 @@
FDA3E959134A49EF008D4B5A /* OfflineAudioCompletionEvent.cpp in Sources */,
FDA3E95B134A49EF008D4B5A /* OfflineAudioDestinationNode.cpp in Sources */,
F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */,
- 087281550F26B9B600AFC596 /* OptionElement.cpp in Sources */,
0014628A103CD1DE000B20DB /* OriginAccessEntry.cpp in Sources */,
51A9267C0D53F0570063ECC2 /* OriginQuotaManager.cpp in Sources */,
51A9267E0D53F0570063ECC2 /* OriginUsageRecord.cpp in Sources */,
Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (98218 => 98219)
--- trunk/Source/WebCore/dom/DOMAllInOne.cpp 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp 2011-10-24 06:59:15 UTC (rev 98219)
@@ -93,7 +93,6 @@
#include "NodeIterator.cpp"
#include "NodeRenderingContext.cpp"
#include "Notation.cpp"
-#include "OptionElement.cpp"
#include "OverflowEvent.cpp"
#include "PageTransitionEvent.cpp"
#include "PendingScript.cpp"
Deleted: trunk/Source/WebCore/dom/OptionElement.cpp (98218 => 98219)
--- trunk/Source/WebCore/dom/OptionElement.cpp 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/dom/OptionElement.cpp 2011-10-24 06:59:15 UTC (rev 98219)
@@ -1 +0,0 @@
-// FIXME: Delete this file after updating all the project files.
Deleted: trunk/Source/WebCore/dom/OptionElement.h (98218 => 98219)
--- trunk/Source/WebCore/dom/OptionElement.h 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/dom/OptionElement.h 2011-10-24 06:59:15 UTC (rev 98219)
@@ -1,2 +0,0 @@
-// FIXME: Delete this file after updating all the project files.
-#error
Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (98218 => 98219)
--- trunk/Source/WebCore/html/HTMLSelectElement.cpp 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp 2011-10-24 06:59:15 UTC (rev 98219)
@@ -75,12 +75,6 @@
static const DOMTimeStamp typeAheadTimeout = 1000;
-// FIXME: Change all the call sites to use hasTagName and toHTMLOptionElement instead.
-static inline HTMLOptionElement* toOptionElement(Element* element)
-{
- return element->hasTagName(optionTag) ? toHTMLOptionElement(element) : 0;
-}
-
HTMLSelectElement::HTMLSelectElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
: HTMLFormControlElementWithState(tagName, document, form)
, m_lastCharTime(0)
@@ -532,8 +526,8 @@
m_lastOnChangeSelection.clear();
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- m_lastOnChangeSelection.append(optionElement && optionElement->selected());
+ HTMLElement* element = items[i];
+ m_lastOnChangeSelection.append(element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected());
}
}
@@ -547,8 +541,8 @@
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- m_cachedStateForActiveSelection.append(optionElement && optionElement->selected());
+ HTMLElement* element = items[i];
+ m_cachedStateForActiveSelection.append(element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected());
}
}
@@ -567,16 +561,16 @@
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- if (!optionElement || items[i]->disabled())
+ HTMLElement* element = items[i];
+ if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->disabled())
continue;
if (i >= start && i <= end)
- optionElement->setSelectedState(m_activeSelectionState);
+ toHTMLOptionElement(element)->setSelectedState(m_activeSelectionState);
else if (deselectOtherOptions || i >= m_cachedStateForActiveSelection.size())
- optionElement->setSelectedState(false);
+ toHTMLOptionElement(element)->setSelectedState(false);
else
- optionElement->setSelectedState(m_cachedStateForActiveSelection[i]);
+ toHTMLOptionElement(element)->setSelectedState(m_cachedStateForActiveSelection[i]);
}
scrollToSelection();
@@ -599,8 +593,8 @@
// Update m_lastOnChangeSelection and fire dispatchFormControlChangeEvent.
bool fireOnChange = false;
for (unsigned i = 0; i < items.size(); ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- bool selected = optionElement && optionElement->selected();
+ HTMLElement* element = items[i];
+ bool selected = element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected();
if (selected != m_lastOnChangeSelection[i])
fireOnChange = true;
m_lastOnChangeSelection[i] = selected;
@@ -693,16 +687,16 @@
}
}
- if (HTMLOptionElement* optionElement = toOptionElement(current)) {
+ if (current->hasTagName(optionTag)) {
m_listItems.append(current);
if (updateSelectedStates && !m_multiple) {
- if (!foundSelected && (m_size <= 1 || optionElement->selected())) {
- foundSelected = optionElement;
+ if (!foundSelected && (m_size <= 1 || toHTMLOptionElement(current)->selected())) {
+ foundSelected = toHTMLOptionElement(current);
foundSelected->setSelectedState(true);
- } else if (foundSelected && optionElement->selected()) {
+ } else if (foundSelected && toHTMLOptionElement(current)->selected()) {
foundSelected->setSelectedState(false);
- foundSelected = optionElement;
+ foundSelected = toHTMLOptionElement(current);
}
}
}
@@ -727,8 +721,9 @@
// Return the number of the first option selected.
const Vector<HTMLElement*>& items = listItems();
for (size_t i = 0; i < items.size(); ++i) {
- if (HTMLOptionElement* optionElement = toOptionElement(items[i])) {
- if (optionElement->selected())
+ HTMLElement* element = items[i];
+ if (element->hasTagName(optionTag)) {
+ if (toHTMLOptionElement(element)->selected())
return index;
++index;
}
@@ -747,18 +742,20 @@
const Vector<HTMLElement*>& items = listItems();
int listIndex = optionToListIndex(optionIndex);
- Element* excludeElement = 0;
- if (HTMLOptionElement* optionElement = (listIndex >= 0 ? toOptionElement(items[listIndex]) : 0)) {
- excludeElement = items[listIndex];
- if (m_activeSelectionAnchorIndex < 0 || deselect)
- setActiveSelectionAnchorIndex(listIndex);
- if (m_activeSelectionEndIndex < 0 || deselect)
- setActiveSelectionEndIndex(listIndex);
- optionElement->setSelectedState(true);
+ HTMLElement* element = 0;
+ if (listIndex >= 0) {
+ element = items[listIndex];
+ if (element->hasTagName(optionTag)) {
+ if (m_activeSelectionAnchorIndex < 0 || deselect)
+ setActiveSelectionAnchorIndex(listIndex);
+ if (m_activeSelectionEndIndex < 0 || deselect)
+ setActiveSelectionEndIndex(listIndex);
+ toHTMLOptionElement(element)->setSelectedState(true);
+ }
}
if (deselect)
- deselectItemsWithoutValidation(excludeElement);
+ deselectItemsWithoutValidation(element);
// For the menu list case, this is what makes the selected element appear.
if (RenderObject* renderer = this->renderer())
@@ -839,15 +836,13 @@
HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode);
}
-void HTMLSelectElement::deselectItemsWithoutValidation(Element* excludeElement)
+void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeElement)
{
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
- if (items[i] == excludeElement)
- continue;
-
- if (HTMLOptionElement* optionElement = toOptionElement(items[i]))
- optionElement->setSelectedState(false);
+ HTMLElement* element = items[i];
+ if (element != excludeElement && element->hasTagName(optionTag))
+ toHTMLOptionElement(element)->setSelectedState(false);
}
}
@@ -858,8 +853,8 @@
StringBuilder builder;
builder.reserveCapacity(length);
for (unsigned i = 0; i < length; ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- bool selected = optionElement && optionElement->selected();
+ HTMLElement* element = items[i];
+ bool selected = element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected();
builder.append(selected ? 'X' : '.');
}
value = builder.toString();
@@ -873,9 +868,10 @@
const Vector<HTMLElement*>& items = listItems();
size_t length = items.size();
- for (unsigned i = 0; i < length; ++i) {
- if (HTMLOptionElement* optionElement = toOptionElement(items[i]))
- optionElement->setSelectedState(state[i] == 'X');
+ for (size_t i = 0; i < length; ++i) {
+ HTMLElement* element = items[i];
+ if (element->hasTagName(optionTag))
+ toHTMLOptionElement(element)->setSelectedState(state[i] == 'X');
}
setOptionsChangedOnRenderer();
@@ -901,9 +897,9 @@
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- if (optionElement && optionElement->selected() && !optionElement->disabled()) {
- list.appendData(name, optionElement->value());
+ HTMLElement* element = items[i];
+ if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected() && !toHTMLOptionElement(element)->disabled()) {
+ list.appendData(name, toHTMLOptionElement(element)->value());
successful = true;
}
}
@@ -921,20 +917,20 @@
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
- HTMLOptionElement* optionElement = toOptionElement(items[i]);
- if (!optionElement)
+ HTMLElement* element = items[i];
+ if (!element->hasTagName(optionTag))
continue;
if (items[i]->fastHasAttribute(selectedAttr)) {
if (selectedOption && !m_multiple)
selectedOption->setSelectedState(false);
- optionElement->setSelectedState(true);
- selectedOption = optionElement;
+ toHTMLOptionElement(element)->setSelectedState(true);
+ selectedOption = toHTMLOptionElement(element);
} else
- optionElement->setSelectedState(false);
+ toHTMLOptionElement(element)->setSelectedState(false);
if (!firstOption)
- firstOption = optionElement;
+ firstOption = toHTMLOptionElement(element);
}
if (!selectedOption && firstOption && !m_multiple && m_size <= 1)
@@ -1121,16 +1117,14 @@
bool shiftSelect = m_multiple && shift;
bool multiSelect = m_multiple && multi && !shift;
- Element* clickedElement = listItems()[listIndex];
- HTMLOptionElement* option = toOptionElement(clickedElement);
- if (option) {
+ HTMLElement* clickedElement = listItems()[listIndex];
+ if (clickedElement->hasTagName(optionTag)) {
// Keep track of whether an active selection (like during drag
// selection), should select or deselect.
- if (option->selected() && multi)
+ if (toHTMLOptionElement(clickedElement)->selected() && multi)
m_activeSelectionState = false;
-
if (!m_activeSelectionState)
- option->setSelectedState(false);
+ toHTMLOptionElement(clickedElement)->setSelectedState(false);
}
// If we're not in any special multiple selection mode, then deselect all
@@ -1145,8 +1139,8 @@
setActiveSelectionAnchorIndex(selectedIndex());
// Set the selection state of the clicked option.
- if (option && !clickedElement->disabled())
- option->setSelectedState(true);
+ if (clickedElement->hasTagName(optionTag) && !toHTMLOptionElement(clickedElement)->disabled())
+ toHTMLOptionElement(clickedElement)->setSelectedState(true);
// If there was no selectedIndex() for the previous initialization, or If
// we're doing a single selection, or a multiple selection (using cmd or
@@ -1318,10 +1312,9 @@
{
const Vector<HTMLElement*>& items = listItems();
for (size_t i = items.size(); i;) {
- if (HTMLOptionElement* optionElement = toOptionElement(items[--i])) {
- if (optionElement->selected())
- return i;
- }
+ HTMLElement* element = items[--i];
+ if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected())
+ return i;
}
return -1;
}
@@ -1384,12 +1377,12 @@
// to use startWith once that is fixed.
String prefixWithCaseFolded(prefix.foldCase());
for (int i = 0; i < itemCount; ++i, index = (index + 1) % itemCount) {
- HTMLOptionElement* optionElement = toOptionElement(items[index]);
- if (!optionElement || items[index]->disabled())
+ HTMLElement* element = items[index];
+ if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->disabled())
continue;
// Fold the option string and check if its prefix is equal to the folded prefix.
- String text = optionElement->textIndentedToRespectGroupLabel();
+ String text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
if (stripLeadingWhiteSpace(text).foldCase().startsWith(prefixWithCaseFolded)) {
setSelectedIndex(listToOptionIndex(index), true, false, true);
if (!usesMenuList())
@@ -1420,11 +1413,14 @@
// If this index is already selected, unselect. otherwise update the selected index.
const Vector<HTMLElement*>& items = listItems();
int listIndex = optionToListIndex(index);
- if (HTMLOptionElement* optionElement = (listIndex >= 0 ? toOptionElement(items[listIndex]) : 0)) {
- if (optionElement->selected())
- optionElement->setSelectedState(false);
- else
- setSelectedIndex(index, false, true, true);
+ if (listIndex >= 0) {
+ HTMLElement* element = items[listIndex];
+ if (element->hasTagName(optionTag)) {
+ if (toHTMLOptionElement(element)->selected())
+ toHTMLOptionElement(element)->setSelectedState(false);
+ else
+ setSelectedIndex(index, false, true, true);
+ }
}
if (usesMenuList())
Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (98218 => 98219)
--- trunk/Source/WebCore/html/HTMLSelectElement.h 2011-10-24 06:54:11 UTC (rev 98218)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h 2011-10-24 06:59:15 UTC (rev 98219)
@@ -140,7 +140,7 @@
bool hasPlaceholderLabelOption() const;
void setSelectedIndex(int optionIndex, bool deselect, bool fireOnChangeNow, bool userDrivenChange);
- void deselectItemsWithoutValidation(Element* excludeElement = 0);
+ void deselectItemsWithoutValidation(HTMLElement* excludeElement = 0);
void parseMultipleAttribute(const Attribute*);
int lastSelectedListIndex() const;
void updateSelectedState(int listIndex, bool multi, bool shift);