Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: Source/core/rendering/RenderMenuList.cpp

Issue 197283025: Use new is*Element() helper functions more in rendering code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderListItem.cpp ('k') | Source/core/rendering/RenderMeter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderMenuList.cpp
diff --git a/Source/core/rendering/RenderMenuList.cpp b/Source/core/rendering/RenderMenuList.cpp
index e64583ce17ad58d11a657ae8ed62be9ec6af7d13..5b28b71bb3d84b4cd73f0abdc16aae52d9144f0c 100644
--- a/Source/core/rendering/RenderMenuList.cpp
+++ b/Source/core/rendering/RenderMenuList.cpp
@@ -61,9 +61,7 @@ RenderMenuList::RenderMenuList(Element* element)
, m_lastActiveIndex(-1)
, m_popupIsVisible(false)
{
- ASSERT(element);
- ASSERT(element->isHTMLElement());
- ASSERT(element->hasTagName(HTMLNames::selectTag));
+ ASSERT(isHTMLSelectElement(element));
}
RenderMenuList::~RenderMenuList()
@@ -170,7 +168,7 @@ void RenderMenuList::updateOptionsWidth()
for (int i = 0; i < size; ++i) {
HTMLElement* element = listItems[i];
- if (!element->hasTagName(optionTag))
+ if (!isHTMLOptionElement(*element))
continue;
String text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
@@ -219,7 +217,7 @@ void RenderMenuList::setTextFromOption(int optionIndex)
String text = emptyString();
if (i >= 0 && i < size) {
Element* element = listItems[i];
- if (element->hasTagName(optionTag)) {
+ if (isHTMLOptionElement(*element)) {
text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
m_optionStyle = element->renderStyle();
}
@@ -395,10 +393,10 @@ String RenderMenuList::itemText(unsigned listIndex) const
String itemString;
Element* element = listItems[listIndex];
- if (element->hasTagName(optgroupTag))
- itemString = toHTMLOptGroupElement(element)->groupLabelText();
- else if (element->hasTagName(optionTag))
- itemString = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
+ if (isHTMLOptGroupElement(*element))
+ itemString = toHTMLOptGroupElement(*element).groupLabelText();
+ else if (isHTMLOptionElement(*element))
+ itemString = toHTMLOptionElement(*element).textIndentedToRespectGroupLabel();
applyTextTransform(style(), itemString, ' ');
return itemString;
@@ -427,12 +425,12 @@ bool RenderMenuList::itemIsEnabled(unsigned listIndex) const
if (listIndex >= listItems.size())
return false;
HTMLElement* element = listItems[listIndex];
- if (!element->hasTagName(optionTag))
+ if (!isHTMLOptionElement(*element))
return false;
bool groupEnabled = true;
if (Element* parentElement = element->parentElement()) {
- if (parentElement->hasTagName(optgroupTag))
+ if (isHTMLOptGroupElement(*parentElement))
groupEnabled = !parentElement->isDisabledFormControl();
}
if (!groupEnabled)
@@ -545,13 +543,13 @@ void RenderMenuList::popupDidHide()
bool RenderMenuList::itemIsSeparator(unsigned listIndex) const
{
const Vector<HTMLElement*>& listItems = selectElement()->listItems();
- return listIndex < listItems.size() && listItems[listIndex]->hasTagName(hrTag);
+ return listIndex < listItems.size() && isHTMLHRElement(*listItems[listIndex]);
}
bool RenderMenuList::itemIsLabel(unsigned listIndex) const
{
const Vector<HTMLElement*>& listItems = selectElement()->listItems();
- return listIndex < listItems.size() && listItems[listIndex]->hasTagName(optgroupTag);
+ return listIndex < listItems.size() && isHTMLOptGroupElement(*listItems[listIndex]);
}
bool RenderMenuList::itemIsSelected(unsigned listIndex) const
@@ -560,7 +558,7 @@ bool RenderMenuList::itemIsSelected(unsigned listIndex) const
if (listIndex >= listItems.size())
return false;
HTMLElement* element = listItems[listIndex];
- return element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected();
+ return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).selected();
}
void RenderMenuList::setTextFromItem(unsigned listIndex)
« no previous file with comments | « Source/core/rendering/RenderListItem.cpp ('k') | Source/core/rendering/RenderMeter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698