Commit 7a7015f1 authored by rniwa@webkit.org's avatar rniwa@webkit.org
Browse files

Get rid of toInputElement()

https://bugs.webkit.org/show_bug.cgi?id=67175

Reviewed by Darin Adler.

Source/WebCore: 

Got rid of Node::toInputElement and HTMLInputElement::toInputElement and replaced them by
a global toHTMLInputElement.

* WebCore.order:
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::textMarkerDataForVisiblePosition):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isPasswordField):
(WebCore::AccessibilityRenderObject::isIndeterminate):
(WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio):
(WebCore::AccessibilityRenderObject::isChecked):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::canShareStyleWithControl):
(WebCore::CSSStyleSelector::adjustRenderStyle):
(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
(WebCore::CSSStyleSelector::applyProperty):
* dom/CheckedRadioButtons.cpp:
(WebCore::CheckedRadioButtons::addButton):
(WebCore::CheckedRadioButtons::removeButton):
* dom/Node.cpp:
* dom/Node.h:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::isInPasswordField):
* html/HTMLInputElement.h:
(WebCore::toHTMLInputElement):
* html/shadow/SliderThumbElement.cpp:
(WebCore::sliderThumbElementOf):
(WebCore::RenderSliderThumb::layout):
(WebCore::RenderSliderContainer::layout):
(WebCore::SliderThumbElement::hostInput):
(WebCore::trackLimiterElementOf):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldResultsButtonElement::shadowPseudoId):
(WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
(WebCore::SpinButtonElement::defaultEventHandler):
(WebCore::SpinButtonElement::repeatingTimerFired):
(WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
(WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
* page/DragController.cpp:
(WebCore::asFileInput):
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::paintThemePart):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::inputElement):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isChecked):
(WebCore::RenderTheme::isIndeterminate):

Source/WebKit/chromium: 

* src/WebInputElement.cpp:
(WebKit::toWebInputElement):

Source/WebKit/qt: 

* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::setAutofilled):
(DumpRenderTreeSupportQt::setValueForUser):
(DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94142 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 05b6fb69
2011-08-30 Ryosuke Niwa <rniwa@webkit.org>
Get rid of toInputElement()
https://bugs.webkit.org/show_bug.cgi?id=67175
Reviewed by Darin Adler.
Got rid of Node::toInputElement and HTMLInputElement::toInputElement and replaced them by
a global toHTMLInputElement.
* WebCore.order:
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::textMarkerDataForVisiblePosition):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isPasswordField):
(WebCore::AccessibilityRenderObject::isIndeterminate):
(WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio):
(WebCore::AccessibilityRenderObject::isChecked):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::canShareStyleWithControl):
(WebCore::CSSStyleSelector::adjustRenderStyle):
(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
(WebCore::CSSStyleSelector::applyProperty):
* dom/CheckedRadioButtons.cpp:
(WebCore::CheckedRadioButtons::addButton):
(WebCore::CheckedRadioButtons::removeButton):
* dom/Node.cpp:
* dom/Node.h:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::isInPasswordField):
* html/HTMLInputElement.h:
(WebCore::toHTMLInputElement):
* html/shadow/SliderThumbElement.cpp:
(WebCore::sliderThumbElementOf):
(WebCore::RenderSliderThumb::layout):
(WebCore::RenderSliderContainer::layout):
(WebCore::SliderThumbElement::hostInput):
(WebCore::trackLimiterElementOf):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldResultsButtonElement::shadowPseudoId):
(WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
(WebCore::SpinButtonElement::defaultEventHandler):
(WebCore::SpinButtonElement::repeatingTimerFired):
(WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
(WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
* page/DragController.cpp:
(WebCore::asFileInput):
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::paintThemePart):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::inputElement):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isChecked):
(WebCore::RenderTheme::isIndeterminate):
2011-08-30 Ryosuke Niwa <rniwa@webkit.org>
 
Speculative WinCairo build fix after r94093.
......@@ -3223,7 +3223,6 @@ __ZN3WTF9HashTableIPNS_16AtomicStringImplES2_NS_17IdentityExtractorIS2_EENS_7Ptr
__ZN3WTF9HashTableIPNS_16AtomicStringImplES2_NS_17IdentityExtractorIS2_EENS_7PtrHashIS2_EENS_10HashTraitsIS2_EES8_E4findIS2_NS_22IdentityHashTranslatorIS2_S2_S6_EEEENS_17HashTableIteratorIS2_S2_S4_S6_S8_S8_EERKT_
__ZN7WebCore11CSSSelector8pseudoIdENS0_10PseudoTypeE
__ZNK7WebCore22HTMLFormControlElement20isFormControlElementEv
__ZN7WebCore16HTMLInputElement14toInputElementEv
__ZNK7WebCore22HTMLFormControlElement20isEnabledFormControlEv
__ZNK7WebCore22HTMLFormControlElement8disabledEv
__ZNK7WebCore4Node15rareDataFocusedEv
......@@ -4242,7 +4241,6 @@ __ZN3WTF9HashTableINS_6StringESt4pairIS1_N7WebCore17AccessibilityRoleEENS_18Pair
__ZN3WTF9HashTableINS_6StringESt4pairIS1_N7WebCore17AccessibilityRoleEENS_18PairFirstExtractorIS5_EENS_15CaseFoldingHashENS_14PairHashTraitsINS_10HashTraitsIS1_EENSA_IS4_EEEESB_E3addIS1_S4_NS_17HashMapTranslatorIS5_SD_S8_EEEES2_INS_17HashTableIteratorIS1_S5_S7_S8_SD_SB_EEbERKT_RKT0_
__ZN3WTF9HashTableINS_6StringESt4pairIS1_N7WebCore17AccessibilityRoleEENS_18PairFirstExtractorIS5_EENS_15CaseFoldingHashENS_14PairHashTraitsINS_10HashTraitsIS1_EENSA_IS4_EEEESB_E6lookupIS1_NS_22IdentityHashTranslatorIS1_S5_S8_EEEEPS5_RKT_
__ZN3WTF9HashTableINS_6StringESt4pairIS1_N7WebCore17AccessibilityRoleEENS_18PairFirstExtractorIS5_EENS_15CaseFoldingHashENS_14PairHashTraitsINS_10HashTraitsIS1_EENSA_IS4_EEEESB_E6rehashEi
__ZN7WebCore4Node14toInputElementEv
__ZNK7WebCore13RootInlineBox19lineBreakBidiStatusEv
__ZNK7WebCore13InlineFlowBox13lastLeafChildEv
__ZNK7WebCore9InlineBox6isLeafEv
......@@ -615,11 +615,8 @@ void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerD
if (!domNode)
return;
if (domNode->isHTMLElement()) {
HTMLInputElement* inputElement = domNode->toInputElement();
if (inputElement && inputElement->isPasswordField())
return;
}
if (domNode->isHTMLElement() && domNode->hasTagName(inputTag) && toHTMLInputElement(domNode)->isPasswordField())
return;
// locate the renderer, which must exist for a visible dom node
RenderObject* renderer = domNode->renderer();
......
......@@ -494,16 +494,12 @@ bool AccessibilityRenderObject::isAttachment() const
bool AccessibilityRenderObject::isPasswordField() const
{
ASSERT(m_renderer);
if (!m_renderer->node() || !m_renderer->node()->isHTMLElement())
if (!m_renderer->node() || !m_renderer->node()->hasTagName(inputTag))
return false;
if (ariaRoleAttribute() != UnknownRole)
return false;
HTMLInputElement* inputElement = m_renderer->node()->toInputElement();
if (!inputElement)
return false;
return inputElement->isPasswordField();
return toHTMLInputElement(m_renderer->node())->isPasswordField();
}
bool AccessibilityRenderObject::isFileUploadButton() const
......@@ -589,26 +585,20 @@ bool AccessibilityRenderObject::isPressed() const
bool AccessibilityRenderObject::isIndeterminate() const
{
ASSERT(m_renderer);
if (!m_renderer->node())
if (!m_renderer->node() || !m_renderer->node()->hasTagName(inputTag))
return false;
HTMLInputElement* inputElement = m_renderer->node()->toInputElement();
if (!inputElement)
return false;
return inputElement->isIndeterminate();
return toHTMLInputElement(m_renderer->node())->isIndeterminate();
}
bool AccessibilityRenderObject::isNativeCheckboxOrRadio() const
{
Node* elementNode = node();
if (elementNode) {
HTMLInputElement* input = elementNode->toInputElement();
if (input)
return input->isCheckbox() || input->isRadioButton();
}
return false;
ASSERT(m_renderer);
if (!m_renderer->node() || !m_renderer->node()->hasTagName(inputTag))
return false;
HTMLInputElement* input = toHTMLInputElement(m_renderer->node());
return input->isCheckbox() || input->isRadioButton();
}
bool AccessibilityRenderObject::isChecked() const
......@@ -618,9 +608,8 @@ bool AccessibilityRenderObject::isChecked() const
return false;
// First test for native checkedness semantics
HTMLInputElement* inputElement = m_renderer->node()->toInputElement();
if (inputElement)
return inputElement->shouldAppearChecked();
if (m_renderer->node()->hasTagName(inputTag))
return toHTMLInputElement(m_renderer->node())->shouldAppearChecked();
// Else, if this is an ARIA checkbox or radio, respect the aria-checked attribute
AccessibilityRole ariaRole = ariaRoleAttribute();
......
......@@ -959,13 +959,15 @@ bool CSSStyleSelector::canShareStyleWithControl(StyledElement* element) const
return true;
}
#endif
HTMLInputElement* thisInputElement = element->toInputElement();
HTMLInputElement* otherInputElement = m_element->toInputElement();
if (!thisInputElement || !otherInputElement)
ASSERT(element);
ASSERT(m_element);
if (!element->hasTagName(inputTag) || !m_element->hasTagName(inputTag))
return false;
HTMLInputElement* thisInputElement = toHTMLInputElement(element);
HTMLInputElement* otherInputElement = toHTMLInputElement(m_element);
if (thisInputElement->isAutofilled() != otherInputElement->isAutofilled())
return false;
if (thisInputElement->shouldAppearChecked() != otherInputElement->shouldAppearChecked())
......@@ -1893,7 +1895,7 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, RenderStyle* parent
if (e && e->isFormControlElement() && style->fontSize() >= 11) {
// Don't apply intrinsic margins to image buttons. The designer knows how big the images are,
// so we have to treat all image buttons as though they were explicitly sized.
if (!e->hasTagName(inputTag) || !static_cast<HTMLInputElement*>(e)->isImageButton())
if (!e->hasTagName(inputTag) || !toHTMLInputElement(e)->isImageButton())
addIntrinsicMargins(style);
}
......@@ -2757,10 +2759,9 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
return true;
break;
case CSSSelector::PseudoAutofill: {
if (!e || !e->isFormControlElement())
if (!e || !e->isFormControlElement() || !e->hasTagName(inputTag))
break;
if (HTMLInputElement* inputElement = e->toInputElement())
return inputElement->isAutofilled();
return toHTMLInputElement(e)->isAutofilled();
break;
}
case CSSSelector::PseudoLink:
......@@ -2847,20 +2848,20 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
e->document()->setContainsValidityStyleRules();
return (e->willValidate() && !e->isValidFormControlElement()) || e->hasUnacceptableValue();
} case CSSSelector::PseudoChecked: {
if (!e || !e->isFormControlElement())
if (!e || !e->isFormControlElement() || !e->hasTagName(inputTag))
break;
// Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that
// you can't be both checked and indeterminate. We will behave like WinIE behind the scenes and just
// obey the CSS spec here in the test for matching the pseudo.
HTMLInputElement* inputElement = e->toInputElement();
if (inputElement && inputElement->shouldAppearChecked() && !inputElement->isIndeterminate())
HTMLInputElement* inputElement = toHTMLInputElement(e);
if (inputElement->shouldAppearChecked() && !inputElement->isIndeterminate())
return true;
break;
}
case CSSSelector::PseudoIndeterminate: {
if (!e || !e->isFormControlElement())
break;
#if ENABLE(PROGRESS_TAG)
if (e->hasTagName(progressTag)) {
HTMLProgressElement* progress = static_cast<HTMLProgressElement*>(e);
......@@ -2869,9 +2870,8 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
break;
}
#endif
HTMLInputElement* inputElement = e->toInputElement();
if (inputElement && inputElement->isIndeterminate())
if (e->hasTagName(inputTag) && toHTMLInputElement(e)->isIndeterminate())
return true;
break;
}
......@@ -4844,7 +4844,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
case CSSPropertyWapInputFormat:
if (primitiveValue && m_element->hasTagName(WebCore::inputTag)) {
String mask = primitiveValue->getStringValue();
static_cast<HTMLInputElement*>(m_element)->setWapInputFormat(mask);
toHTMLInputElement(m_element)->setWapInputFormat(mask);
}
return;
......
......@@ -35,7 +35,7 @@ void CheckedRadioButtons::addButton(HTMLFormControlElement* element)
if (element->name().isEmpty())
return;
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
HTMLInputElement* inputElement = toHTMLInputElement(element);
// We only track checked buttons.
if (!inputElement->checked())
......@@ -77,7 +77,7 @@ void CheckedRadioButtons::removeButton(HTMLFormControlElement* element)
if (it == m_nameToCheckedRadioButtonMap->end() || it->second != element)
return;
HTMLInputElement* inputElement = element->toInputElement();
HTMLInputElement* inputElement = toHTMLInputElement(element);
ASSERT_UNUSED(inputElement, inputElement);
ASSERT(inputElement->shouldAppearChecked());
ASSERT(element->isRadioButton());
......
......@@ -577,15 +577,6 @@ void Node::setShadowHost(Element* host)
setParent(host);
}
HTMLInputElement* Node::toInputElement()
{
// If one of the below ASSERTs trigger, you are calling this function
// directly or indirectly from a constructor or destructor of this object.
// Don't do this!
ASSERT(!(isHTMLElement() && hasTagName(inputTag)));
return 0;
}
short Node::tabIndex() const
{
return hasRareData() ? rareData()->tabIndex() : 0;
......
......@@ -533,8 +533,6 @@ public:
virtual Node* toNode() { return this; }
virtual HTMLInputElement* toInputElement();
virtual ScriptExecutionContext* scriptExecutionContext() const;
virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
......
......@@ -1522,7 +1522,7 @@ bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool clo
bool FrameSelection::isInPasswordField() const
{
HTMLTextFormControlElement* textControl = enclosingTextFormControl(start());
return textControl && textControl->hasTagName(inputTag) && static_cast<HTMLInputElement*>(textControl)->isPasswordField();
return textControl && textControl->hasTagName(inputTag) && toHTMLInputElement(textControl)->isPasswordField();
}
void FrameSelection::focusedOrActiveStateChanged()
......
......@@ -24,6 +24,7 @@
#ifndef HTMLInputElement_h
#define HTMLInputElement_h
#include "HTMLNames.h"
#include "HTMLTextFormControlElement.h"
namespace WebCore {
......@@ -42,8 +43,6 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitspeechchange);
virtual HTMLInputElement* toInputElement() { return this; }
virtual bool shouldAutocomplete() const;
// For ValidityState
......@@ -357,6 +356,12 @@ private:
OwnPtr<InputType> m_inputType;
};
inline HTMLInputElement* toHTMLInputElement(Node* node)
{
ASSERT(!node || node->hasTagName(HTMLNames::inputTag));
return static_cast<HTMLInputElement*>(node);
}
} //namespace
#endif
......@@ -37,6 +37,7 @@
#include "Event.h"
#include "Frame.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "MouseEvent.h"
#include "RenderDeprecatedFlexibleBox.h"
......@@ -66,7 +67,8 @@ inline static bool hasVerticalAppearance(HTMLInputElement* input)
SliderThumbElement* sliderThumbElementOf(Node* node)
{
ASSERT(node);
ShadowRoot* shadow = node->toInputElement()->shadowRoot();
ASSERT(node->hasTagName(HTMLNames::inputTag));
ShadowRoot* shadow = toHTMLInputElement(node)->shadowRoot();
ASSERT(shadow);
Node* thumb = shadow->firstChild()->firstChild()->firstChild();
ASSERT(thumb);
......@@ -103,7 +105,8 @@ void RenderSliderThumb::layout()
{
// Do not cast node() to SliderThumbElement. This renderer is used for
// TrackLimitElement too.
HTMLInputElement* input = node()->shadowAncestorNode()->toInputElement();
ASSERT(node()->shadowAncestorNode()->hasTagName(HTMLNames::inputTag));
HTMLInputElement* input = toHTMLInputElement(node()->shadowAncestorNode());
bool isVertical = style()->appearance() == SliderThumbVerticalPart || style()->appearance() == MediaVolumeSliderThumbPart;
double fraction = sliderPosition(input) * 100;
......@@ -132,7 +135,8 @@ private:
void RenderSliderContainer::layout()
{
HTMLInputElement* input = node()->shadowAncestorNode()->toInputElement();
ASSERT(node()->shadowAncestorNode()->hasTagName(HTMLNames::inputTag));
HTMLInputElement* input = toHTMLInputElement(node()->shadowAncestorNode());
bool isVertical = hasVerticalAppearance(input);
style()->setBoxOrient(isVertical ? VERTICAL : HORIZONTAL);
// Sets the concrete height if the height of the <input> is not fixed or a
......@@ -313,7 +317,8 @@ HTMLInputElement* SliderThumbElement::hostInput() const
{
// Only HTMLInputElement creates SliderThumbElement instances as its shadow nodes.
// So, shadowAncestorNode() must be an HTMLInputElement.
return shadowAncestorNode()->toInputElement();
ASSERT(shadowAncestorNode()->hasTagName(HTMLNames::inputTag));
return toHTMLInputElement(shadowAncestorNode());
}
const AtomicString& SliderThumbElement::shadowPseudoId() const
......@@ -351,7 +356,8 @@ const AtomicString& TrackLimiterElement::shadowPseudoId() const
TrackLimiterElement* trackLimiterElementOf(Node* node)
{
ASSERT(node);
ShadowRoot* shadow = node->toInputElement()->shadowRoot();
ASSERT(node->hasTagName(HTMLNames::inputTag));
ShadowRoot* shadow = toHTMLInputElement(node)->shadowRoot();
ASSERT(shadow);
Node* limiter = shadow->firstChild()->lastChild();
ASSERT(limiter);
......
......@@ -128,22 +128,21 @@ const AtomicString& SearchFieldResultsButtonElement::shadowPseudoId() const
DEFINE_STATIC_LOCAL(AtomicString, resultsDecorationId, ("-webkit-search-results-decoration"));
DEFINE_STATIC_LOCAL(AtomicString, decorationId, ("-webkit-search-decoration"));
Node* host = shadowAncestorNode();
if (!host)
if (!host || !host->hasTagName(inputTag))
return resultsId;
if (HTMLInputElement* input = host->toInputElement()) {
if (input->maxResults() < 0)
return decorationId;
if (input->maxResults() > 0)
return resultsId;
return resultsDecorationId;
}
return resultsId;
int maxResults = toHTMLInputElement(host)->maxResults();
if (maxResults < 0)
return decorationId;
if (maxResults > 0)
return resultsId;
return resultsDecorationId;
}
void SearchFieldResultsButtonElement::defaultEventHandler(Event* event)
{
// On mousedown, bring up a menu, if needed
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
HTMLInputElement* input = toHTMLInputElement(shadowAncestorNode());
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
input->focus();
input->select();
......@@ -191,7 +190,7 @@ void SearchFieldCancelButtonElement::detach()
void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
{
// If the element is visible, on mouseup, clear the value, and set selection
RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowAncestorNode()));
if (input->disabled() || input->isReadOnlyFormControl()) {
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
......@@ -271,7 +270,7 @@ void SpinButtonElement::defaultEventHandler(Event* event)
return;
}
RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowAncestorNode()));
if (input->disabled() || input->isReadOnlyFormControl()) {
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
......@@ -342,7 +341,7 @@ void SpinButtonElement::stopRepeatingTimer()
void SpinButtonElement::repeatingTimerFired(Timer<SpinButtonElement>*)
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
HTMLInputElement* input = toHTMLInputElement(shadowAncestorNode());
if (input->disabled() || input->isReadOnlyFormControl())
return;
// On Mac OS, NSStepper updates the value for the button under the mouse
......@@ -401,7 +400,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
// The call to focus() below dispatches a focus event, and an event handler in the page might
// remove the input element from DOM. To make sure it remains valid until we finish our work
// here, we take a temporary reference.
RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowAncestorNode()));
if (input->disabled() || input->isReadOnlyFormControl()) {
if (!event->defaultHandled())
......@@ -486,7 +485,7 @@ void InputFieldSpeechButtonElement::setRecognitionResult(int, const SpeechInputR
// The call to setValue() below dispatches an event, and an event handler in the page might
// remove the input element from DOM. To make sure it remains valid until we finish our work
// here, we take a temporary reference.
RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
RefPtr<HTMLInputElement> input(toHTMLInputElement(shadowAncestorNode()));
if (input->disabled() || input->isReadOnlyFormControl())
return;
......
......@@ -254,14 +254,21 @@ DragOperation DragController::dragEnteredOrUpdated(DragData* dragData)
static HTMLInputElement* asFileInput(Node* node)
{
ASSERT(node);
if (!node->hasTagName(HTMLNames::inputTag))
return 0;
HTMLInputElement* inputElement = node->toInputElement();
HTMLInputElement* inputElement = toHTMLInputElement(node);
// If this is a button inside of the a file input, move up to the file input.
if (inputElement && inputElement->isTextButton() && inputElement->treeScope()->isShadowRoot())
inputElement = inputElement->treeScope()->shadowHost()->toInputElement();
if (inputElement->isTextButton() && inputElement->treeScope()->isShadowRoot()) {
node = inputElement->treeScope()->shadowHost();
if (!node->hasTagName(HTMLNames::inputTag))
return 0;
inputElement = toHTMLInputElement(node);
}
return inputElement && inputElement->isFileUpload() ? inputElement : 0;
return inputElement->isFileUpload() ? inputElement : 0;
}
// This can return null if an empty document is loaded.
......
......@@ -32,6 +32,7 @@
#include "FrameView.h"
#include "GraphicsContext.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "NotImplemented.h"
#include "Page.h"
#include "PaintInfo.h"
......@@ -310,7 +311,7 @@ bool RenderThemeEfl::paintThemePart(RenderObject* object, FormType type, const P
// treatment, move them to special functions.
if (type == SliderVertical || type == SliderHorizontal) {
RenderSlider* renderSlider = toRenderSlider(object);
HTMLInputElement* input = renderSlider->node()->toInputElement();
HTMLInputElement* input = renderSlider->node()->hasTagName(HTMLNames::inputTag) ? toHTMLInputElement(renderSlider->node()) : 0;
Edje_Message_Float_Set* msg;
double valueRange = input->maximum() - input->minimum();
......
......@@ -75,7 +75,7 @@ RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node)
, m_searchPopup(0)
{
ASSERT(node->isHTMLElement());
ASSERT(node->toInputElement());
ASSERT(node->hasTagName(inputTag));
}
RenderTextControlSingleLine::~RenderTextControlSingleLine()
......@@ -788,7 +788,7 @@ PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollableAre
HTMLInputElement* RenderTextControlSingleLine::inputElement() const
{
return node()->toInputElement();
return toHTMLInputElement(node());
}
}
......@@ -738,26 +738,18 @@ bool RenderTheme::isActive(const RenderObject* o) const
bool RenderTheme::isChecked(const RenderObject* o) const
{
if (!o->node())
return false;
HTMLInputElement* inputElement = o->node()->toInputElement();
if (!inputElement)
if (!o->node() || !o->node()->hasTagName(inputTag))
return false;
return inputElement->shouldAppearChecked();
return toHTMLInputElement(o->node())->shouldAppearChecked();
}
bool RenderTheme::isIndeterminate(const RenderObject* o) const
{
if (!o->node())
return false;
HTMLInputElement* inputElement = o->node()->toInputElement();
if (!inputElement)
if (!o->node() || !o->node()->hasTagName(inputTag))
return false;
return inputElement->isIndeterminate();
return toHTMLInputElement(o->node())->isIndeterminate();
}
bool RenderTheme::isEnabled(const RenderObject* o) const
......
2011-08-30 Ryosuke Niwa <rniwa@webkit.org>
Get rid of toInputElement()
https://bugs.webkit.org/show_bug.cgi?id=67175
Reviewed by Darin Adler.
* src/WebInputElement.cpp:
(WebKit::toWebInputElement):
2011-08-30 Nat Duca <nduca@chromium.org>
Unreviewed, fix WebGL layout tests due to missing WebView pointer.
......
......@@ -173,8 +173,8 @@ WebInputElement::operator PassRefPtr<HTMLInputElement>() const
WebInputElement* toWebInputElement(WebElement* webElement)
{
HTMLInputElement* inputElement = webElement->unwrap<Element>()->toInputElement();
if (!inputElement)
Element* element = webElement->unwrap<Element>();
if (!element->hasTagName(HTMLNames::inputTag))
return 0;
return static_cast<WebInputElement*>(webElement);
......
......@@ -37,6 +37,7 @@
#include "GCController.h"
#include "GraphicsContext.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "JSDOMWindow.h"
#include "JSDocument.h"
#include "JSElement.h"
......@@ -755,29 +756,23 @@ void DumpRenderTreeSupportGtk::setAutofilled(JSContextRef context, JSValueRef no<