Changeset 152208 in webkit
- Timestamp:
- Jun 29, 2013 1:18:46 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r152207 r152208 1 2013-06-29 Kangil Han <kangil.han@samsung.com> 2 3 Adopt is/toHTMLOptionElement for code cleanup 4 https://bugs.webkit.org/show_bug.cgi?id=118212 5 6 Reviewed by Andreas Kling. 7 8 To enhance readability, this patch adopts is/toHTMLOptionElement. 9 This also helps out to reduce duplicated use of static_cast. 10 11 * accessibility/AccessibilityListBoxOption.cpp: 12 (WebCore::AccessibilityListBoxOption::isSelected): 13 (WebCore::AccessibilityListBoxOption::canSetSelectedAttribute): 14 (WebCore::AccessibilityListBoxOption::stringValue): 15 (WebCore::AccessibilityListBoxOption::listBoxOptionParentNode): 16 * accessibility/AccessibilityMenuListOption.cpp: 17 (WebCore::AccessibilityMenuListOption::setElement): 18 (WebCore::AccessibilityMenuListOption::isEnabled): 19 (WebCore::AccessibilityMenuListOption::isSelected): 20 (WebCore::AccessibilityMenuListOption::setSelected): 21 (WebCore::AccessibilityMenuListOption::stringValue): 22 * accessibility/AccessibilityMenuListPopup.cpp: 23 (WebCore::AccessibilityMenuListPopup::menuListOptionAccessibilityObject): 24 * accessibility/AccessibilityRenderObject.cpp: 25 (WebCore::AccessibilityRenderObject::accessibilityHitTest): 26 * css/SelectorChecker.cpp: 27 (WebCore::SelectorChecker::checkOne): 28 * css/StyleResolver.cpp: 29 (WebCore::StyleResolver::canShareStyleWithElement): 30 * html/HTMLCollection.cpp: 31 (WebCore::isMatchingElement): 32 * html/HTMLOptionElement.cpp: 33 (WebCore::HTMLOptionElement::index): 34 * html/HTMLOptionElement.h: 35 (WebCore::isHTMLOptionElement): 36 (WebCore::toHTMLOptionElement): 37 * html/HTMLOptionsCollection.cpp: 38 (WebCore::HTMLOptionsCollection::add): 39 * html/HTMLSelectElement.cpp: 40 (WebCore::HTMLSelectElement::hasPlaceholderLabelOption): 41 (WebCore::HTMLSelectElement::value): 42 (WebCore::HTMLSelectElement::setValue): 43 (WebCore::HTMLSelectElement::childShouldCreateRenderer): 44 (WebCore::HTMLSelectElement::nextValidIndex): 45 (WebCore::HTMLSelectElement::saveLastSelection): 46 (WebCore::HTMLSelectElement::setActiveSelectionAnchorIndex): 47 (WebCore::HTMLSelectElement::updateListBoxSelection): 48 (WebCore::HTMLSelectElement::listBoxOnChange): 49 (WebCore::HTMLSelectElement::recalcListItems): 50 (WebCore::HTMLSelectElement::selectedIndex): 51 (WebCore::HTMLSelectElement::selectOption): 52 (WebCore::HTMLSelectElement::optionToListIndex): 53 (WebCore::HTMLSelectElement::listToOptionIndex): 54 (WebCore::HTMLSelectElement::deselectItemsWithoutValidation): 55 (WebCore::HTMLSelectElement::saveFormControlState): 56 (WebCore::HTMLSelectElement::searchOptionsForValue): 57 (WebCore::HTMLSelectElement::restoreFormControlState): 58 (WebCore::HTMLSelectElement::appendFormData): 59 (WebCore::HTMLSelectElement::reset): 60 (WebCore::HTMLSelectElement::updateSelectedState): 61 (WebCore::HTMLSelectElement::lastSelectedListIndex): 62 (WebCore::HTMLSelectElement::optionAtIndex): 63 (WebCore::HTMLSelectElement::accessKeySetSelectedIndex): 64 (WebCore::HTMLSelectElement::length): 65 * html/parser/HTMLConstructionSite.cpp: 66 (WebCore::hasImpliedEndTag): 67 * html/parser/HTMLElementStack.cpp: 68 (WebCore::HTMLNames::isSelectScopeMarker): 69 * html/parser/HTMLTreeBuilder.cpp: 70 (WebCore::HTMLTreeBuilder::processStartTagForInBody): 71 (WebCore::HTMLTreeBuilder::processStartTag): 72 (WebCore::HTMLTreeBuilder::processEndTag): 73 * rendering/RenderListBox.cpp: 74 (WebCore::RenderListBox::updateFromElement): 75 (WebCore::RenderListBox::addFocusRingRects): 76 (WebCore::RenderListBox::paintItemForeground): 77 (WebCore::RenderListBox::paintItemBackground): 78 * rendering/RenderMenuList.cpp: 79 (WebCore::RenderMenuList::updateOptionsWidth): 80 (WebCore::RenderMenuList::setTextFromOption): 81 (WebCore::RenderMenuList::itemText): 82 (WebCore::RenderMenuList::itemIsEnabled): 83 (WebCore::RenderMenuList::itemIsSelected): 84 * rendering/RenderTheme.cpp: 85 (WebCore::RenderTheme::paintSliderTicks): 86 1 87 2013-06-29 Carlos Garcia Campos <cgarcia@igalia.com> 2 88 -
trunk/Source/WebCore/accessibility/AccessibilityListBoxOption.cpp
r147135 r152208 84 84 return false; 85 85 86 if (! m_optionElement->hasTagName(optionTag))87 return false; 88 89 return static_cast<HTMLOptionElement*>(m_optionElement)->selected();86 if (!isHTMLOptionElement(m_optionElement)) 87 return false; 88 89 return toHTMLOptionElement(m_optionElement)->selected(); 90 90 } 91 91 … … 137 137 return false; 138 138 139 if (! m_optionElement->hasTagName(optionTag))139 if (!isHTMLOptionElement(m_optionElement)) 140 140 return false; 141 141 … … 159 159 return ariaLabel; 160 160 161 if ( m_optionElement->hasTagName(optionTag))162 return static_cast<HTMLOptionElement*>(m_optionElement)->text();161 if (isHTMLOptionElement(m_optionElement)) 162 return toHTMLOptionElement(m_optionElement)->text(); 163 163 164 164 if (m_optionElement->hasTagName(optgroupTag)) … … 204 204 if (!m_optionElement) 205 205 return 0; 206 207 if ( m_optionElement->hasTagName(optionTag))208 return static_cast<HTMLOptionElement*>(m_optionElement)->ownerSelectElement();209 206 207 if (isHTMLOptionElement(m_optionElement)) 208 return toHTMLOptionElement(m_optionElement)->ownerSelectElement(); 209 210 210 if (m_optionElement->hasTagName(optgroupTag)) 211 211 return static_cast<HTMLOptGroupElement*>(m_optionElement)->ownerSelectElement(); 212 212 213 213 return 0; 214 214 } -
trunk/Source/WebCore/accessibility/AccessibilityMenuListOption.cpp
r147135 r152208 42 42 void AccessibilityMenuListOption::setElement(HTMLElement* element) 43 43 { 44 ASSERT_ARG(element, element->hasTagName(optionTag));44 ASSERT_ARG(element, isHTMLOptionElement(element)); 45 45 m_element = element; 46 46 } … … 55 55 // isDisabledFormControl() returns true if the parent <select> element is disabled, 56 56 // which we don't want. 57 return ! static_cast<HTMLOptionElement*>(m_element.get())->ownElementDisabled();57 return !toHTMLOptionElement(m_element.get())->ownElementDisabled(); 58 58 } 59 59 … … 76 76 bool AccessibilityMenuListOption::isSelected() const 77 77 { 78 return static_cast<HTMLOptionElement*>(m_element.get())->selected();78 return toHTMLOptionElement(m_element.get())->selected(); 79 79 } 80 80 … … 84 84 return; 85 85 86 static_cast<HTMLOptionElement*>(m_element.get())->setSelected(b);86 toHTMLOptionElement(m_element.get())->setSelected(b); 87 87 } 88 88 … … 115 115 String AccessibilityMenuListOption::stringValue() const 116 116 { 117 return static_cast<HTMLOptionElement*>(m_element.get())->text();117 return toHTMLOptionElement(m_element.get())->text(); 118 118 } 119 119 -
trunk/Source/WebCore/accessibility/AccessibilityMenuListPopup.cpp
r145988 r152208 31 31 #include "AccessibilityMenuListOption.h" 32 32 #include "HTMLNames.h" 33 #include "HTMLOptionElement.h" 33 34 #include "HTMLSelectElement.h" 34 35 #include "RenderMenuList.h" … … 70 71 AccessibilityMenuListOption* AccessibilityMenuListPopup::menuListOptionAccessibilityObject(HTMLElement* element) const 71 72 { 72 if (!element || ! element->hasTagName(optionTag))73 if (!element || !isHTMLOptionElement(element)) 73 74 return 0; 74 75 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r152203 r152208 2209 2209 return accessibilityImageMapHitTest(toHTMLAreaElement(node), point); 2210 2210 2211 if ( node->hasTagName(optionTag))2212 node = static_cast<HTMLOptionElement*>(node)->ownerSelectElement();2211 if (isHTMLOptionElement(node)) 2212 node = toHTMLOptionElement(node)->ownerSelectElement(); 2213 2213 2214 2214 RenderObject* obj = node->renderer(); -
trunk/Source/WebCore/css/SelectorChecker.cpp
r152001 r152208 657 657 break; 658 658 case CSSSelector::PseudoEnabled: 659 if (element->isFormControlElement() || element->hasTagName(optionTag) || element->hasTagName(optgroupTag))659 if (element->isFormControlElement() || isHTMLOptionElement(element) || element->hasTagName(optgroupTag)) 660 660 return !element->isDisabledFormControl(); 661 661 break; … … 666 666 return element->isDefaultButtonForForm(); 667 667 case CSSSelector::PseudoDisabled: 668 if (element->isFormControlElement() || element->hasTagName(optionTag) || element->hasTagName(optgroupTag))668 if (element->isFormControlElement() || isHTMLOptionElement(element) || element->hasTagName(optgroupTag)) 669 669 return element->isDisabledFormControl(); 670 670 break; … … 691 691 if (inputElement && inputElement->shouldAppearChecked() && !inputElement->shouldAppearIndeterminate()) 692 692 return true; 693 if ( element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected())693 if (isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected()) 694 694 return true; 695 695 break; -
trunk/Source/WebCore/css/StyleResolver.cpp
r152149 r152208 660 660 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcListItems 661 661 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cgi?id=88405 662 if ( element->hasTagName(optionTag) || element->hasTagName(optgroupTag))662 if (isHTMLOptionElement(element) || element->hasTagName(optgroupTag)) 663 663 return false; 664 664 -
trunk/Source/WebCore/html/HTMLCollection.cpp
r151947 r152208 226 226 case DataListOptions: 227 227 if (element->hasLocalName(optionTag)) { 228 HTMLOptionElement* option = static_cast<HTMLOptionElement*>(element);228 HTMLOptionElement* option = toHTMLOptionElement(element); 229 229 if (!option->isDisabledFormControl() && !option->value().isEmpty()) 230 230 return true; -
trunk/Source/WebCore/html/HTMLOptionElement.cpp
r151947 r152208 176 176 size_t length = items.size(); 177 177 for (size_t i = 0; i < length; ++i) { 178 if (!i tems[i]->hasTagName(optionTag))178 if (!isHTMLOptionElement(items[i])) 179 179 continue; 180 180 if (items[i] == this) … … 384 384 } 385 385 386 #ifndef NDEBUG387 388 HTMLOptionElement* toHTMLOptionElement(Node* node)389 {390 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(optionTag));391 return static_cast<HTMLOptionElement*>(node);392 }393 394 const HTMLOptionElement* toHTMLOptionElement(const Node* node)395 {396 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(optionTag));397 return static_cast<const HTMLOptionElement*>(node);398 }399 400 #endif401 402 386 } // namespace -
trunk/Source/WebCore/html/HTMLOptionElement.h
r151717 r152208 96 96 }; 97 97 98 HTMLOptionElement* toHTMLOptionElement(Node*); 99 const HTMLOptionElement* toHTMLOptionElement(const Node*); 100 void toHTMLOptionElement(const HTMLOptionElement*); // This overload will catch anyone doing an unnecessary cast. 101 102 #ifdef NDEBUG 103 104 // The debug versions of these, with assertions, are not inlined. 98 inline bool isHTMLOptionElement(Node* node) 99 { 100 return node->hasTagName(HTMLNames::optionTag); 101 } 105 102 106 103 inline HTMLOptionElement* toHTMLOptionElement(Node* node) 107 104 { 105 ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLOptionElement(node)); 108 106 return static_cast<HTMLOptionElement*>(node); 109 107 } 110 111 inline const HTMLOptionElement* toHTMLOptionElement(const Node* node)112 {113 return static_cast<const HTMLOptionElement*>(node);114 }115 116 #endif117 108 118 109 } // namespace -
trunk/Source/WebCore/html/HTMLOptionsCollection.cpp
r142247 r152208 64 64 select->add(newOption, 0, ec); 65 65 else 66 select->add(newOption, static_cast<HTMLOptionElement*>(item(index)), ec);66 select->add(newOption, toHTMLOptionElement(item(index)), ec); 67 67 68 68 ASSERT(!ec); -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r151947 r152208 144 144 if (listIndex < 0) 145 145 return false; 146 HTMLOptionElement* option = static_cast<HTMLOptionElement*>(listItems()[listIndex]);146 HTMLOptionElement* option = toHTMLOptionElement(listItems()[listIndex]); 147 147 return !listIndex && option->value().isEmpty(); 148 148 } … … 242 242 const Vector<HTMLElement*>& items = listItems(); 243 243 for (unsigned i = 0; i < items.size(); i++) { 244 if (items[i]->hasLocalName(optionTag) && static_cast<HTMLOptionElement*>(items[i])->selected()) 245 return static_cast<HTMLOptionElement*>(items[i])->value(); 244 if (items[i]->hasLocalName(optionTag)) { 245 HTMLOptionElement* option = toHTMLOptionElement(items[i]); 246 if (option->selected()) 247 return option->value(); 248 } 246 249 } 247 250 return ""; … … 261 264 for (unsigned i = 0; i < items.size(); i++) { 262 265 if (items[i]->hasLocalName(optionTag)) { 263 if ( static_cast<HTMLOptionElement*>(items[i])->value() == value) {266 if (toHTMLOptionElement(items[i])->value() == value) { 264 267 setSelectedIndex(optionIndex); 265 268 return; … … 348 351 return false; 349 352 if (!usesMenuList()) 350 return childContext.node()->hasTagName(HTMLNames::optionTag) || childContext.node()->hasTagName(HTMLNames::optgroupTag) || validationMessageShadowTreeContains(childContext.node());353 return isHTMLOptionElement(childContext.node()) || childContext.node()->hasTagName(HTMLNames::optgroupTag) || validationMessageShadowTreeContains(childContext.node()); 351 354 return validationMessageShadowTreeContains(childContext.node()); 352 355 } … … 499 502 for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex += direction) { 500 503 --skip; 501 if (!listItems[listIndex]->isDisabledFormControl() && listItems[listIndex]->hasTagName(optionTag)) {504 if (!listItems[listIndex]->isDisabledFormControl() && isHTMLOptionElement(listItems[listIndex])) { 502 505 lastGoodIndex = listIndex; 503 506 if (skip <= 0) … … 581 584 for (unsigned i = 0; i < items.size(); ++i) { 582 585 HTMLElement* element = items[i]; 583 m_lastOnChangeSelection.append( element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected());586 m_lastOnChangeSelection.append(isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected()); 584 587 } 585 588 } … … 596 599 for (unsigned i = 0; i < items.size(); ++i) { 597 600 HTMLElement* element = items[i]; 598 m_cachedStateForActiveSelection.append( element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected());601 m_cachedStateForActiveSelection.append(isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected()); 599 602 } 600 603 } … … 616 619 for (unsigned i = 0; i < items.size(); ++i) { 617 620 HTMLElement* element = items[i]; 618 if (! element->hasTagName(optionTag) || toHTMLOptionElement(element)->isDisabledFormControl())621 if (!isHTMLOptionElement(element) || toHTMLOptionElement(element)->isDisabledFormControl()) 619 622 continue; 620 623 … … 649 652 for (unsigned i = 0; i < items.size(); ++i) { 650 653 HTMLElement* element = items[i]; 651 bool selected = element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected();654 bool selected = isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected(); 652 655 if (selected != m_lastOnChangeSelection[i]) 653 656 fireOnChange = true; … … 757 760 } 758 761 759 if ( current->hasTagName(optionTag)) {762 if (isHTMLOptionElement(current)) { 760 763 m_listItems.append(current); 761 764 … … 799 802 for (size_t i = 0; i < items.size(); ++i) { 800 803 HTMLElement* element = items[i]; 801 if ( element->hasTagName(optionTag)) {804 if (isHTMLOptionElement(element)) { 802 805 if (toHTMLOptionElement(element)->selected()) 803 806 return index; … … 835 838 if (listIndex >= 0) { 836 839 element = items[listIndex]; 837 if ( element->hasTagName(optionTag)) {840 if (isHTMLOptionElement(element)) { 838 841 if (m_activeSelectionAnchorIndex < 0 || shouldDeselect) 839 842 setActiveSelectionAnchorIndex(listIndex); … … 878 881 int optionIndex2 = -1; 879 882 for (int listIndex = 0; listIndex < listSize; ++listIndex) { 880 if (i tems[listIndex]->hasTagName(optionTag)) {883 if (isHTMLOptionElement(items[listIndex])) { 881 884 ++optionIndex2; 882 885 if (optionIndex2 == optionIndex) … … 891 894 { 892 895 const Vector<HTMLElement*>& items = listItems(); 893 if (listIndex < 0 || listIndex >= static_cast<int>(items.size()) || !i tems[listIndex]->hasTagName(optionTag))896 if (listIndex < 0 || listIndex >= static_cast<int>(items.size()) || !isHTMLOptionElement(items[listIndex])) 894 897 return -1; 895 898 … … 897 900 int optionIndex = 0; 898 901 for (int i = 0; i < listIndex; ++i) { 899 if (i tems[i]->hasTagName(optionTag))902 if (isHTMLOptionElement(items[i])) 900 903 ++optionIndex; 901 904 } … … 928 931 for (unsigned i = 0; i < items.size(); ++i) { 929 932 HTMLElement* element = items[i]; 930 if (element != excludeElement && element->hasTagName(optionTag))933 if (element != excludeElement && isHTMLOptionElement(element)) 931 934 toHTMLOptionElement(element)->setSelectedState(false); 932 935 } … … 939 942 FormControlState state; 940 943 for (unsigned i = 0; i < length; ++i) { 941 if (!i tems[i]->hasTagName(optionTag))944 if (!isHTMLOptionElement(items[i])) 942 945 continue; 943 946 HTMLOptionElement* option = toHTMLOptionElement(items[i]); … … 958 961 if (!items[i]->hasLocalName(optionTag)) 959 962 continue; 960 if ( static_cast<HTMLOptionElement*>(items[i])->value() == value)963 if (toHTMLOptionElement(items[i])->value() == value) 961 964 return i; 962 965 } … … 976 979 if (!items[i]->hasLocalName(optionTag)) 977 980 continue; 978 static_cast<HTMLOptionElement*>(items[i])->setSelectedState(false);981 toHTMLOptionElement(items[i])->setSelectedState(false); 979 982 } 980 983 … … 1021 1024 for (unsigned i = 0; i < items.size(); ++i) { 1022 1025 HTMLElement* element = items[i]; 1023 if ( element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected() && !toHTMLOptionElement(element)->isDisabledFormControl()) {1026 if (isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected() && !toHTMLOptionElement(element)->isDisabledFormControl()) { 1024 1027 list.appendData(name, toHTMLOptionElement(element)->value()); 1025 1028 successful = true; … … 1041 1044 for (unsigned i = 0; i < items.size(); ++i) { 1042 1045 HTMLElement* element = items[i]; 1043 if (! element->hasTagName(optionTag))1046 if (!isHTMLOptionElement(element)) 1044 1047 continue; 1045 1048 … … 1258 1261 1259 1262 HTMLElement* clickedElement = listItems()[listIndex]; 1260 if ( clickedElement->hasTagName(optionTag)) {1263 if (isHTMLOptionElement(clickedElement)) { 1261 1264 // Keep track of whether an active selection (like during drag 1262 1265 // selection), should select or deselect. … … 1279 1282 1280 1283 // Set the selection state of the clicked option. 1281 if ( clickedElement->hasTagName(optionTag) && !toHTMLOptionElement(clickedElement)->isDisabledFormControl())1284 if (isHTMLOptionElement(clickedElement) && !toHTMLOptionElement(clickedElement)->isDisabledFormControl()) 1282 1285 toHTMLOptionElement(clickedElement)->setSelectedState(true); 1283 1286 … … 1484 1487 for (size_t i = items.size(); i;) { 1485 1488 HTMLElement* element = items[--i]; 1486 if ( element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected())1489 if (isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected()) 1487 1490 return i; 1488 1491 } … … 1505 1508 1506 1509 HTMLElement* element = items[index]; 1507 if (! element->hasTagName(optionTag) || toHTMLOptionElement(element)->isDisabledFormControl())1510 if (!isHTMLOptionElement(element) || toHTMLOptionElement(element)->isDisabledFormControl()) 1508 1511 return String(); 1509 1512 return toHTMLOptionElement(element)->textIndentedToRespectGroupLabel(); … … 1541 1544 if (listIndex >= 0) { 1542 1545 HTMLElement* element = items[listIndex]; 1543 if ( element->hasTagName(optionTag)) {1546 if (isHTMLOptionElement(element)) { 1544 1547 if (toHTMLOptionElement(element)->selected()) 1545 1548 toHTMLOptionElement(element)->setSelectedState(false); … … 1563 1566 const Vector<HTMLElement*>& items = listItems(); 1564 1567 for (unsigned i = 0; i < items.size(); ++i) { 1565 if (i tems[i]->hasTagName(optionTag))1568 if (isHTMLOptionElement(items[i])) 1566 1569 ++options; 1567 1570 } -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r151949 r152208 40 40 #include "HTMLHtmlElement.h" 41 41 #include "HTMLNames.h" 42 #include "HTMLOptionElement.h" 42 43 #include "HTMLParserIdioms.h" 43 44 #include "HTMLScriptElement.h" … … 64 65 || item->hasTagName(dtTag) 65 66 || item->hasTagName(liTag) 66 || i tem->hasTagName(optionTag)67 || isHTMLOptionElement(item->node()) 67 68 || item->hasTagName(optgroupTag) 68 69 || item->hasTagName(pTag) -
trunk/Source/WebCore/html/parser/HTMLElementStack.cpp
r147441 r152208 31 31 #include "Element.h" 32 32 #include "HTMLNames.h" 33 #include "HTMLOptionElement.h" 33 34 #include "MathMLNames.h" 34 35 #include "SVGNames.h" … … 123 124 inline bool isSelectScopeMarker(HTMLStackItem* item) 124 125 { 125 return !item->hasTagName(optgroupTag) 126 && !item->hasTagName(optionTag); 126 return !item->hasTagName(optgroupTag) && !isHTMLOptionElement(item->node()); 127 127 } 128 128 -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r151949 r152208 34 34 #include "HTMLFormElement.h" 35 35 #include "HTMLNames.h" 36 #include "HTMLOptionElement.h" 36 37 #include "HTMLParserIdioms.h" 37 38 #include "HTMLStackItem.h" … … 896 897 } 897 898 if (token->name() == optgroupTag || token->name() == optionTag) { 898 if ( m_tree.currentStackItem()->hasTagName(optionTag)) {899 if (isHTMLOptionElement(m_tree.currentStackItem()->node())) { 899 900 AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName()); 900 901 processEndTag(&endOption); … … 1375 1376 } 1376 1377 if (token->name() == optionTag) { 1377 if ( m_tree.currentStackItem()->hasTagName(optionTag)) {1378 if (isHTMLOptionElement(m_tree.currentStackItem()->node())) { 1378 1379 AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName()); 1379 1380 processEndTag(&endOption); … … 1383 1384 } 1384 1385 if (token->name() == optgroupTag) { 1385 if ( m_tree.currentStackItem()->hasTagName(optionTag)) {1386 if (isHTMLOptionElement(m_tree.currentStackItem()->node())) { 1386 1387 AtomicHTMLToken endOption(HTMLToken::EndTag, optionTag.localName()); 1387 1388 processEndTag(&endOption); … … 2251 2252 ASSERT(insertionMode() == InSelectMode || insertionMode() == InSelectInTableMode); 2252 2253 if (token->name() == optgroupTag) { 2253 if ( m_tree.currentStackItem()->hasTagName(optionTag) && m_tree.oneBelowTop() && m_tree.oneBelowTop()->hasTagName(optgroupTag))2254 if (isHTMLOptionElement(m_tree.currentStackItem()->node()) && m_tree.oneBelowTop() && m_tree.oneBelowTop()->hasTagName(optgroupTag)) 2254 2255 processFakeEndTag(optionTag); 2255 2256 if (m_tree.currentStackItem()->hasTagName(optgroupTag)) { … … 2261 2262 } 2262 2263 if (token->name() == optionTag) { 2263 if ( m_tree.currentStackItem()->hasTagName(optionTag)) {2264 if (isHTMLOptionElement(m_tree.currentStackItem()->node())) { 2264 2265 m_tree.openElements()->pop(); 2265 2266 return; -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r151799 r152208 125 125 String text; 126 126 Font itemFont = style()->font(); 127 if ( element->hasTagName(optionTag))127 if (isHTMLOptionElement(element)) 128 128 text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel(); 129 129 else if (element->hasTagName(optgroupTag)) { … … 348 348 for (int i = 0; i < size; ++i) { 349 349 HTMLElement* element = listItems[i]; 350 if ( element->hasTagName(optionTag) && !element->isDisabledFormControl()) {350 if (isHTMLOptionElement(element) && !element->isDisabledFormControl()) { 351 351 rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffset, i))); 352 352 return; … … 404 404 405 405 String itemText; 406 bool isOptionElement = element->hasTagName(optionTag);406 bool isOptionElement = isHTMLOptionElement(element); 407 407 if (isOptionElement) 408 408 itemText = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel(); … … 445 445 446 446 Color backColor; 447 if ( element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected()) {447 if (isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected()) { 448 448 if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node()) 449 449 backColor = theme()->activeListBoxSelectionBackgroundColor(); -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r150214 r152208 179 179 for (int i = 0; i < size; ++i) { 180 180 HTMLElement* element = listItems[i]; 181 if (! element->hasTagName(optionTag))181 if (!isHTMLOptionElement(element)) 182 182 continue; 183 183 … … 228 228 if (i >= 0 && i < size) { 229 229 Element* element = listItems[i]; 230 if ( element->hasTagName(optionTag)) {230 if (isHTMLOptionElement(element)) { 231 231 text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel(); 232 232 m_optionStyle = element->renderStyle(); … … 408 408 if (element->hasTagName(optgroupTag)) 409 409 itemString = static_cast<const HTMLOptGroupElement*>(element)->groupLabelText(); 410 else if ( element->hasTagName(optionTag))410 else if (isHTMLOptionElement(element)) 411 411 itemString = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel(); 412 412 … … 448 448 return false; 449 449 HTMLElement* element = listItems[listIndex]; 450 if (! element->hasTagName(optionTag))450 if (!isHTMLOptionElement(element)) 451 451 return false; 452 452 … … 606 606 return false; 607 607 HTMLElement* element = listItems[listIndex]; 608 return element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected();608 return isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected(); 609 609 } 610 610 -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r151783 r152208 1033 1033 paintInfo.context->setFillColor(o->style()->visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); 1034 1034 for (unsigned i = 0; Node* node = options->item(i); i++) { 1035 ASSERT( node->hasTagName(optionTag));1035 ASSERT(isHTMLOptionElement(node)); 1036 1036 HTMLOptionElement* optionElement = toHTMLOptionElement(node); 1037 1037 String value = optionElement->value(); -
trunk/Source/WebKit/blackberry/ChangeLog
r152203 r152208 1 2013-06-29 Kangil Han <kangil.han@samsung.com> 2 3 Adopt is/toHTMLOptionElement for code cleanup 4 https://bugs.webkit.org/show_bug.cgi?id=118212 5 6 Reviewed by Andreas Kling. 7 8 To enhance readability, this patch adopts is/toHTMLOptionElement. 9 This also helps out to reduce duplicated use of static_cast. 10 11 * WebKitSupport/InputHandler.cpp: 12 (BlackBerry::WebKit::InputHandler::willOpenPopupForNode): 13 (BlackBerry::WebKit::InputHandler::didNodeOpenPopup): 14 (BlackBerry::WebKit::InputHandler::openSelectPopup): 15 (BlackBerry::WebKit::InputHandler::setPopupListIndexes): 16 * WebKitSupport/SelectPopupClient.cpp: 17 (BlackBerry::WebKit::SelectPopupClient::setValueAndClosePopup): 18 1 19 2013-06-28 Kangil Han <kangil.han@samsung.com> 2 20 -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
r152149 r152208 1986 1986 ASSERT(!node->isInShadowTree()); 1987 1987 1988 if (node->hasTagName(HTMLNames::selectTag) || node->hasTagName(HTMLNames::optionTag)) {1988 if (node->hasTagName(HTMLNames::selectTag) || isHTMLOptionElement(node)) { 1989 1989 // We open list popups for options and selects. 1990 1990 return true; … … 2011 2011 return openSelectPopup(static_cast<HTMLSelectElement*>(node)); 2012 2012 2013 if ( node->hasTagName(HTMLNames::optionTag)) {2014 HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(node);2013 if (isHTMLOptionElement(node)) { 2014 HTMLOptionElement* optionElement = toHTMLOptionElement(node); 2015 2015 return openSelectPopup(optionElement->ownerSelectElement()); 2016 2016 } … … 2057 2057 selecteds = new bool[size]; 2058 2058 for (int i = 0; i < size; i++) { 2059 if ( listItems[i]->hasTagName(HTMLNames::optionTag)) {2060 HTMLOptionElement* option = static_cast<HTMLOptionElement*>(listItems[i]);2059 if (isHTMLOptionElement(listItems[i])) { 2060 HTMLOptionElement* option = toHTMLOptionElement(listItems[i]); 2061 2061 labels[i] = option->textIndentedToRespectGroupLabel(); 2062 2062 enableds[i] = option->isDisabledFormControl() ? 0 : 1; … … 2123 2123 HTMLOptionElement* option; 2124 2124 for (int i = 0; i < size; i++) { 2125 if (i tems[i]->hasTagName(HTMLNames::optionTag)) {2126 option = static_cast<HTMLOptionElement*>(items[i]);2125 if (isHTMLOptionElement(items[i])) { 2126 option = toHTMLOptionElement(items[i]); 2127 2127 option->setSelectedState(selecteds[i]); 2128 2128 } -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectPopupClient.cpp
r150756 r152208 156 156 HTMLOptionElement* option; 157 157 for (unsigned i = 0; i < m_size; i++) { 158 if (i tems[i]->hasTagName(HTMLNames::optionTag)) {159 option = static_cast<HTMLOptionElement*>(items[i]);158 if (isHTMLOptionElement(items[i])) { 159 option = toHTMLOptionElement(items[i]); 160 160 option->setSelectedState(selecteds[i]); 161 161 } -
trunk/Source/WebKit/win/ChangeLog
r152169 r152208 1 2013-06-29 Kangil Han <kangil.han@samsung.com> 2 3 Adopt is/toHTMLOptionElement for code cleanup 4 https://bugs.webkit.org/show_bug.cgi?id=118212 5 6 Reviewed by Andreas Kling. 7 8 To enhance readability, this patch adopts is/toHTMLOptionElement. 9 This also helps out to reduce duplicated use of static_cast. 10 11 * DOMCoreClasses.cpp: 12 (DOMElement::createInstance): 13 * DOMHTMLClasses.cpp: 14 (DOMHTMLOptionElement::text): 15 (DOMHTMLOptionElement::label): 16 1 17 2013-06-28 peavo@outlook.com <peavo@outlook.com> 2 18 -
trunk/Source/WebKit/win/DOMCoreClasses.cpp
r152149 r152208 1504 1504 DOMHTMLInputElement* newElement = new DOMHTMLInputElement(e); 1505 1505 hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement); 1506 } else if ( e->hasTagName(optionTag)) {1506 } else if (isHTMLOptionElement(e)) { 1507 1507 DOMHTMLOptionElement* newElement = new DOMHTMLOptionElement(e); 1508 1508 hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement); -
trunk/Source/WebKit/win/DOMHTMLClasses.cpp
r152149 r152208 863 863 864 864 ASSERT(m_element); 865 ASSERT( m_element->hasTagName(optionTag));866 HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(m_element);865 ASSERT(isHTMLOptionElement(m_element)); 866 HTMLOptionElement* optionElement = toHTMLOptionElement(m_element); 867 867 868 868 *result = BString(optionElement->text()).release(); … … 900 900 901 901 ASSERT(m_element); 902 ASSERT( m_element->hasTagName(optionTag));903 HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(m_element);902 ASSERT(isHTMLOptionElement(m_element)); 903 HTMLOptionElement* optionElement = toHTMLOptionElement(m_element); 904 904 905 905 *result = BString(optionElement->label()).release();
Note: See TracChangeset
for help on using the changeset viewer.