Diff
Modified: trunk/Source/WebCore/ChangeLog (173943 => 173944)
--- trunk/Source/WebCore/ChangeLog 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/ChangeLog 2014-09-25 03:50:40 UTC (rev 173944)
@@ -1,3 +1,107 @@
+2014-09-24 Christophe Dumez <cdu...@apple.com>
+
+ Add initial is<>() / downcast<>() support for any type of Nodes
+ https://bugs.webkit.org/show_bug.cgi?id=137056
+
+ Reviewed by Benjamin Poulain.
+
+ Add initial is<>() / downcast<>() support for any type of Nodes, not
+ just Elements by:
+ - Moving the is<>() / downcast<>() declarations from Element.h to
+ Node.h
+ - Introducing a SPECIALIZE_TYPE_TRAITS_*() macro that generates the
+ needed template specializations for is<>() / downcast<>() to work.
+ This macro will replace NODE_TYPE_CASTS() entirely once the code base
+ is fully ported.
+
+ This patch makes use of SPECIALIZE_TYPE_TRAITS_*() macro for
+ HTMLFormControlElement, that is an HTMLElement for which the template
+ specializations cannot be automatically generated because it requires
+ special handling.
+
+ This patch also makes use of SPECIALIZE_TYPE_TRAITS_*() macro for
+ DocumentFragment to show that it can be used for non-Element Nodes.
+
+ No new tests, no behavior change.
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::isReadOnly):
+ (WebCore::AccessibilityNodeObject::isRequired):
+ (WebCore::AccessibilityNodeObject::isControl):
+ * css/SelectorCheckerTestFunctions.h:
+ (WebCore::isAutofilled):
+ (WebCore::isDisabled):
+ (WebCore::isEnabled):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::canShareStyleWithElement):
+ (WebCore::StyleResolver::adjustRenderStyle):
+ * dom/Document.cpp:
+ (WebCore::Document::importNode):
+ (WebCore::Document::setFocusedElement):
+ * dom/DocumentFragment.h:
+ (WebCore::isDocumentFragment):
+ * dom/Element.cpp:
+ (WebCore::Element::focus):
+ * dom/Element.h:
+ (WebCore::is): Deleted.
+ (WebCore::downcast): Deleted.
+ * dom/Node.h:
+ (WebCore::is):
+ (WebCore::downcast):
+ * dom/make_names.pl:
+ (printTypeHelpers):
+ * editing/FrameSelection.cpp:
+ (WebCore::scanForForm):
+ * editing/TextIterator.cpp:
+ (WebCore::isRendererReplacedElement):
+ * html/FormAssociatedElement.h:
+ * html/HTMLElement.h:
+ * html/HTMLFieldSetElement.cpp:
+ (WebCore::updateFromControlElementsAncestorDisabledStateUnder):
+ (WebCore::HTMLFieldSetElement::refreshElementsIfNeeded):
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::enclosingFormControlElement):
+ * html/HTMLFormControlElement.h:
+ (WebCore::isHTMLFormControlElement):
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::submitImplicitly):
+ (WebCore::submitElementFromEvent):
+ (WebCore::HTMLFormElement::validateInteractively):
+ (WebCore::HTMLFormElement::submit):
+ (WebCore::HTMLFormElement::reset):
+ (WebCore::HTMLFormElement::formElementIndex):
+ (WebCore::HTMLFormElement::defaultButton):
+ (WebCore::HTMLFormElement::checkInvalidControlsAndCollectUnhandled):
+ (WebCore::HTMLFormElement::documentDidResumeFromPageCache):
+ * html/HTMLMediaElement.h:
+ * html/HTMLPlugInImageElement.h:
+ * html/HTMLSummaryElement.cpp:
+ (WebCore::isClickableControl):
+ * html/LabelableElement.h:
+ * html/RadioNodeList.cpp:
+ (WebCore::RadioNodeList::checkElementMatchesRadioNodeListFilter):
+ (WebCore::RadioNodeList::elementMatches):
+ * html/parser/HTMLConstructionSite.cpp:
+ (WebCore::HTMLConstructionSite::findFosterSite):
+ * html/parser/HTMLTreeBuilder.cpp:
+ (WebCore::disallowTelephoneNumberParsing):
+ * loader/FormSubmission.cpp:
+ (WebCore::FormSubmission::create):
+ * mathml/MathMLElement.h:
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::populate):
+ * page/Frame.cpp:
+ (WebCore::Frame::searchForLabelsBeforeElement):
+ * rendering/RenderButton.cpp:
+ (WebCore::RenderButton::formControlElement):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::resize):
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::isReadOnlyControl):
+ * svg/SVGElement.h:
+ * svg/SVGFilterPrimitiveStandardAttributes.h:
+ * svg/animation/SVGSMILElement.h:
+
2014-09-24 Darin Adler <da...@apple.com>
Old Turkic characters behave as left-to-right instead of right-to-left, because they are encoded as surrogate pairs.
Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (173943 => 173944)
--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -739,7 +739,7 @@
return true;
if (is<HTMLTextAreaElement>(node))
- return toHTMLFormControlElement(node)->isReadOnly();
+ return downcast<HTMLTextAreaElement>(node)->isReadOnly();
if (is<HTMLInputElement>(node)) {
HTMLInputElement& input = downcast<HTMLInputElement>(*node);
@@ -760,8 +760,8 @@
return false;
Node* n = this->node();
- if (n && (n->isElementNode() && toElement(n)->isFormControlElement()))
- return toHTMLFormControlElement(n)->isRequired();
+ if (n && is<HTMLFormControlElement>(n))
+ return downcast<HTMLFormControlElement>(n)->isRequired();
return false;
}
@@ -898,8 +898,7 @@
if (!node)
return false;
- return ((node->isElementNode() && toElement(node)->isFormControlElement())
- || AccessibilityObject::isARIAControl(ariaRoleAttribute()));
+ return is<HTMLFormControlElement>(node) || AccessibilityObject::isARIAControl(ariaRoleAttribute());
}
bool AccessibilityNodeObject::isFieldset() const
Modified: trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h (173943 => 173944)
--- trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -44,7 +44,7 @@
ALWAYS_INLINE bool isAutofilled(const Element* element)
{
- if (element->isFormControlElement()) {
+ if (is<HTMLFormControlElement>(element)) {
if (const HTMLInputElement* inputElement = element->toInputElement())
return inputElement->isAutofilled();
}
@@ -58,7 +58,7 @@
ALWAYS_INLINE bool isDisabled(const Element* element)
{
- if (element->isFormControlElement() || is<HTMLOptionElement>(element) || is<HTMLOptGroupElement>(element))
+ if (is<HTMLFormControlElement>(element) || is<HTMLOptionElement>(element) || is<HTMLOptGroupElement>(element))
return element->isDisabledFormControl();
return false;
}
@@ -66,7 +66,7 @@
ALWAYS_INLINE bool isEnabled(const Element* element)
{
bool isEnabled = false;
- if (element->isFormControlElement() || is<HTMLOptionElement>(element) || is<HTMLOptGroupElement>(element))
+ if (is<HTMLFormControlElement>(element) || is<HTMLOptionElement>(element) || is<HTMLOptGroupElement>(element))
isEnabled = !element->isDisabledFormControl();
else if (element->isLink())
isEnabled = is<HTMLAnchorElement>(element) || is<HTMLAreaElement>(element);
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (173943 => 173944)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -626,9 +626,9 @@
if (element->hasID() && m_ruleSets.features().idsInRules.contains(element->idForStyleResolution().impl()))
return false;
- bool isControl = element->isFormControlElement();
+ bool isControl = is<HTMLFormControlElement>(element);
- if (isControl != state.element()->isFormControlElement())
+ if (isControl != is<HTMLFormControlElement>(state.element()))
return false;
if (isControl && !canShareStyleWithControl(element))
@@ -1335,7 +1335,7 @@
// Important: Intrinsic margins get added to controls before the theme has adjusted the style, since the theme will
// alter fonts and heights/widths.
- if (e && e->isFormControlElement() && style.fontSize() >= 11) {
+ if (e && is<HTMLFormControlElement>(e) && 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 (!is<HTMLInputElement>(e) || !downcast<HTMLInputElement>(*e).isImageButton())
Modified: trunk/Source/WebCore/dom/Document.cpp (173943 => 173944)
--- trunk/Source/WebCore/dom/Document.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/dom/Document.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -973,7 +973,7 @@
// Either they are imported along with their host node, or created implicitly.
break;
}
- DocumentFragment& oldFragment = toDocumentFragment(*importedNode);
+ DocumentFragment& oldFragment = downcast<DocumentFragment>(*importedNode);
RefPtr<DocumentFragment> newFragment = createDocumentFragment();
if (deep) {
for (Node* oldChild = oldFragment.firstChild(); oldChild; oldChild = oldChild->nextSibling()) {
@@ -3410,10 +3410,10 @@
oldFocusedElement->setFocus(false);
// Dispatch a change event for form control elements that have been edited.
- if (oldFocusedElement->isFormControlElement()) {
- HTMLFormControlElement* formControlElement = toHTMLFormControlElement(oldFocusedElement.get());
- if (formControlElement->wasChangedSinceLastFormControlChangeEvent())
- formControlElement->dispatchFormControlChangeEvent();
+ if (is<HTMLFormControlElement>(*oldFocusedElement)) {
+ HTMLFormControlElement& formControlElement = downcast<HTMLFormControlElement>(*oldFocusedElement);
+ if (formControlElement.wasChangedSinceLastFormControlChangeEvent())
+ formControlElement.dispatchFormControlChangeEvent();
}
// Dispatch the blur event and let the node do any other blur related activities (important for text fields)
Modified: trunk/Source/WebCore/dom/DocumentFragment.h (173943 => 173944)
--- trunk/Source/WebCore/dom/DocumentFragment.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/dom/DocumentFragment.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -52,11 +52,10 @@
virtual bool childTypeAllowed(NodeType) const override;
};
-inline bool isDocumentFragment(const Node& node) { return node.isDocumentFragment(); }
-void isDocumentFragment(const DocumentFragment&); // Catch unnecessary runtime check of type known at compile time.
+SPECIALIZE_TYPE_TRAITS_BEGIN(DocumentFragment)
+ static bool isDocumentFragment(const Node& node) { return node.isDocumentFragment(); }
+SPECIALIZE_TYPE_TRAITS_END()
-NODE_TYPE_CASTS(DocumentFragment)
-
} //namespace
#endif
Modified: trunk/Source/WebCore/dom/Element.cpp (173943 => 173944)
--- trunk/Source/WebCore/dom/Element.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -1928,7 +1928,7 @@
// Calling updateFocusAppearance() would generate an unnecessary call to ScrollView::setScrollPosition(),
// which would jump us around during this animation. See <rdar://problem/6699741>.
FrameView* view = document().view();
- bool isFormControl = view && isFormControlElement();
+ bool isFormControl = view && is<HTMLFormControlElement>(*this);
if (isFormControl)
view->setProhibitsScrolling(true);
#endif
Modified: trunk/Source/WebCore/dom/Element.h (173943 => 173944)
--- trunk/Source/WebCore/dom/Element.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/dom/Element.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -670,52 +670,11 @@
NODE_TYPE_CASTS(Element)
-template <typename ExpectedType, typename ArgType>
-struct ElementTypeCastTraits {
- static bool is(ArgType&);
-};
-
-// Type checking function for Elements, to use before casting with downcast<>().
-template <typename ExpectedType, typename ArgType>
-inline bool is(ArgType& node)
-{
- static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
- return ElementTypeCastTraits<const ExpectedType, const ArgType>::is(node);
-}
-
-template <typename ExpectedType, typename ArgType>
-inline bool is(ArgType* node)
-{
- ASSERT(node);
- static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
- return ElementTypeCastTraits<const ExpectedType, const ArgType>::is(*node);
-}
-
template <>
-struct ElementTypeCastTraits<const Element, const Node> {
+struct NodeTypeCastTraits<const Element, const Node> {
static bool is(const Node& node) { return node.isElementNode(); }
};
-template <typename ExpectedType>
-struct ElementTypeCastTraits<ExpectedType, ExpectedType> {
- static bool is(ExpectedType&) { return true; }
-};
-
-// Downcasting functions for Element types.
-template<typename Target, typename Source>
-inline typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type downcast(Source& source)
-{
- static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
- ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
- return static_cast<typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type>(source);
-}
-template<typename Target, typename Source> inline typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type downcast(Source* source)
-{
- static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
- ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
- return static_cast<typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type>(source);
-}
-
inline bool Node::hasAttributes() const
{
return isElementNode() && toElement(this)->hasAttributes();
Modified: trunk/Source/WebCore/dom/Node.h (173943 => 173944)
--- trunk/Source/WebCore/dom/Node.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/dom/Node.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -739,6 +739,59 @@
return parentNode();
}
+template <typename ExpectedType, typename ArgType>
+struct NodeTypeCastTraits {
+ static bool is(ArgType&);
+};
+
+template <typename ExpectedType>
+struct NodeTypeCastTraits<ExpectedType, ExpectedType> {
+ static bool is(ExpectedType&) { return true; }
+};
+
+// Type checking function for Nodes, to use before casting with downcast<>().
+template <typename ExpectedType, typename ArgType>
+inline bool is(ArgType& node)
+{
+ static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
+ return NodeTypeCastTraits<const ExpectedType, const ArgType>::is(node);
+}
+
+template <typename ExpectedType, typename ArgType>
+inline bool is(ArgType* node)
+{
+ ASSERT(node);
+ static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
+ return NodeTypeCastTraits<const ExpectedType, const ArgType>::is(*node);
+}
+
+// Downcasting functions for Node types.
+template<typename Target, typename Source>
+inline typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type downcast(Source& source)
+{
+ static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
+ ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
+ return static_cast<typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type>(source);
+}
+template<typename Target, typename Source> inline typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type downcast(Source* source)
+{
+ static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
+ ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
+ return static_cast<typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type>(source);
+}
+
+// Add support for type checking / casting using is<>() / downcast<>() helpers for a specific class.
+#define SPECIALIZE_TYPE_TRAITS_BEGIN(ClassName) \
+ template <typename ArgType> \
+ class NodeTypeCastTraits<const ClassName, ArgType> { \
+ public: \
+ static bool is(ArgType& node) { return is##ClassName(node); } \
+ private:
+
+#define SPECIALIZE_TYPE_TRAITS_END() \
+ };
+
+// FIXME: This should be removed and all uses should be replaced with SPECIALIZE_TYPE_TRAITS_*().
#define NODE_TYPE_CASTS(ToClassName) \
TYPE_CASTS_BASE(ToClassName, Node, node, WebCore::is##ToClassName(*node), WebCore::is##ToClassName(node))
Modified: trunk/Source/WebCore/dom/make_names.pl (173943 => 173944)
--- trunk/Source/WebCore/dom/make_names.pl 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/dom/make_names.pl 2014-09-25 03:50:40 UTC (rev 173944)
@@ -636,7 +636,7 @@
print F <<END
class $class;
template <typename ArgType>
-class ElementTypeCastTraits<const $class, ArgType> {
+class NodeTypeCastTraits<const $class, ArgType> {
public:
static bool is(ArgType& node) { return checkTagName(node); }
private:
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (173943 => 173944)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -2025,8 +2025,8 @@
HTMLElement& element = *it;
if (isHTMLFormElement(&element))
return downcast<HTMLFormElement>(&element);
- if (isHTMLFormControlElement(element))
- return toHTMLFormControlElement(element).form();
+ if (is<HTMLFormControlElement>(element))
+ return downcast<HTMLFormControlElement>(element).form();
if (isHTMLFrameElementBase(element)) {
Document* contentDocument = toHTMLFrameElementBase(element).contentDocument();
if (!contentDocument)
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (173943 => 173944)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -256,7 +256,7 @@
if (renderer->node() && renderer->node()->isElementNode()) {
Element& element = toElement(*renderer->node());
- if (element.isFormControlElement() || element.hasTagName(legendTag) || element.hasTagName(meterTag) || element.hasTagName(progressTag))
+ if (is<HTMLFormControlElement>(element) || is<HTMLLegendElement>(element) || is<HTMLMeterElement>(element) || is<HTMLProgressElement>(element))
return true;
if (equalIgnoringCase(element.fastGetAttribute(roleAttr), "img"))
return true;
Modified: trunk/Source/WebCore/html/FormAssociatedElement.h (173943 => 173944)
--- trunk/Source/WebCore/html/FormAssociatedElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/FormAssociatedElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -118,9 +118,6 @@
String m_customValidationMessage;
};
-#define FORM_ASSOCIATED_ELEMENT_TYPE_CASTS(ToClassName, predicate) \
- TYPE_CASTS_BASE(ToClassName, FormAssociatedElement, element, element->predicate, element.predicate)
-
} // namespace
#endif // FormAssociatedElement_h
Modified: trunk/Source/WebCore/html/HTMLElement.h (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -150,7 +150,7 @@
inline bool isHTMLElement(const Node& node) { return node.isHTMLElement(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const HTMLElement, ArgType> {
+struct NodeTypeCastTraits<const HTMLElement, ArgType> {
static bool is(ArgType& node) { return isHTMLElement(node); }
};
Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLFieldSetElement.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -58,8 +58,8 @@
static void updateFromControlElementsAncestorDisabledStateUnder(HTMLElement& startNode, bool isDisabled)
{
HTMLFormControlElement* control;
- if (isHTMLFormControlElement(startNode))
- control = &toHTMLFormControlElement(startNode);
+ if (is<HTMLFormControlElement>(startNode))
+ control = &downcast<HTMLFormControlElement>(startNode);
else
control = Traversal<HTMLFormControlElement>::firstWithin(&startNode);
while (control) {
@@ -167,8 +167,8 @@
for (auto& element : descendantsOfType<Element>(const_cast<HTMLFieldSetElement&>(*this))) {
if (element.hasTagName(objectTag))
m_associatedElements.append(&downcast<HTMLObjectElement>(element));
- else if (element.isFormControlElement())
- m_associatedElements.append(&toHTMLFormControlElement(element));
+ else if (is<HTMLFormControlElement>(element))
+ m_associatedElements.append(&downcast<HTMLFormControlElement>(element));
}
}
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -508,10 +508,10 @@
HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node* node)
{
for (; node; node = node->parentNode()) {
- if (node->isElementNode() && toElement(node)->isFormControlElement())
- return toHTMLFormControlElement(node);
+ if (is<HTMLFormControlElement>(node))
+ return downcast<HTMLFormControlElement>(node);
}
- return 0;
+ return nullptr;
}
} // namespace Webcore
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -190,19 +190,12 @@
bool m_hasAutofocused : 1;
};
-void isHTMLFormControlElement(const HTMLFormControlElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLFormControlElement(const Element& element) { return element.isFormControlElement(); }
-inline bool isHTMLFormControlElement(const Node& node) { return node.isElementNode() && toElement(node).isFormControlElement(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLFormControlElement)
+ static bool isHTMLFormControlElement(const Element& element) { return element.isFormControlElement(); }
+ static bool isHTMLFormControlElement(const Node& node) { return node.isElementNode() && toElement(node).isFormControlElement(); }
+ static bool isHTMLFormControlElement(const FormAssociatedElement& element) { return element.isFormControlElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
-template <typename ArgType>
-struct ElementTypeCastTraits<const HTMLFormControlElement, ArgType> {
- static bool is(ArgType& node) { return isHTMLFormControlElement(node); }
-};
-
-NODE_TYPE_CASTS(HTMLFormControlElement)
-
-FORM_ASSOCIATED_ELEMENT_TYPE_CASTS(HTMLFormControlElement, isFormControlElement())
-
} // namespace
#endif
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -182,15 +182,15 @@
unsigned submissionTriggerCount = 0;
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
FormAssociatedElement* formAssociatedElement = m_associatedElements[i];
- if (!formAssociatedElement->isFormControlElement())
+ if (!is<HTMLFormControlElement>(formAssociatedElement))
continue;
- HTMLFormControlElement* formElement = toHTMLFormControlElement(formAssociatedElement);
- if (formElement->isSuccessfulSubmitButton()) {
- if (formElement->renderer()) {
- formElement->dispatchSimulatedClick(event);
+ HTMLFormControlElement& formElement = downcast<HTMLFormControlElement>(*formAssociatedElement);
+ if (formElement.isSuccessfulSubmitButton()) {
+ if (formElement.renderer()) {
+ formElement.dispatchSimulatedClick(event);
return;
}
- } else if (formElement->canTriggerImplicitSubmission())
+ } else if (formElement.canTriggerImplicitSubmission())
++submissionTriggerCount;
}
@@ -206,10 +206,10 @@
static inline HTMLFormControlElement* submitElementFromEvent(const Event* event)
{
for (Node* node = event->target()->toNode(); node; node = node->parentNode()) {
- if (node->isElementNode() && toElement(node)->isFormControlElement())
- return toHTMLFormControlElement(node);
+ if (is<HTMLFormControlElement>(node))
+ return downcast<HTMLFormControlElement>(node);
}
- return 0;
+ return nullptr;
}
bool HTMLFormElement::validateInteractively(Event* event)
@@ -223,8 +223,8 @@
return true;
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
- if (m_associatedElements[i]->isFormControlElement())
- toHTMLFormControlElement(m_associatedElements[i])->hideVisibleValidationMessage();
+ if (is<HTMLFormControlElement>(m_associatedElements[i]))
+ downcast<HTMLFormControlElement>(*m_associatedElements[i]).hideVisibleValidationMessage();
}
Vector<RefPtr<FormAssociatedElement>> unhandledInvalidControls;
@@ -245,8 +245,8 @@
if (element.inDocument() && element.isFocusable()) {
element.scrollIntoViewIfNeeded(false);
element.focus();
- if (element.isFormControlElement())
- toHTMLFormControlElement(element).updateVisibleValidationMessage();
+ if (is<HTMLFormControlElement>(element))
+ downcast<HTMLFormControlElement>(element).updateVisibleValidationMessage();
break;
}
}
@@ -345,14 +345,14 @@
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
FormAssociatedElement* associatedElement = m_associatedElements[i];
- if (!associatedElement->isFormControlElement())
+ if (!is<HTMLFormControlElement>(associatedElement))
continue;
if (needButtonActivation) {
- HTMLFormControlElement* control = toHTMLFormControlElement(associatedElement);
- if (control->isActivatedSubmit())
+ HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*associatedElement);
+ if (control.isActivatedSubmit())
needButtonActivation = false;
- else if (firstSuccessfulSubmitButton == 0 && control->isSuccessfulSubmitButton())
- firstSuccessfulSubmitButton = control;
+ else if (!firstSuccessfulSubmitButton && control.isSuccessfulSubmitButton())
+ firstSuccessfulSubmitButton = &control;
}
}
@@ -384,8 +384,8 @@
}
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
- if (m_associatedElements[i]->isFormControlElement())
- toHTMLFormControlElement(m_associatedElements[i])->reset();
+ if (is<HTMLFormControlElement>(m_associatedElements[i]))
+ downcast<HTMLFormControlElement>(*m_associatedElements[i]).reset();
}
m_isInResetFunction = false;
@@ -592,7 +592,7 @@
for (auto& element : descendants) {
if (&element == &associatedHTMLElement)
return i;
- if (!isHTMLFormControlElement(element) && !is<HTMLObjectElement>(element))
+ if (!is<HTMLFormControlElement>(element) && !is<HTMLObjectElement>(element))
continue;
if (element.form() != this)
continue;
@@ -696,14 +696,14 @@
HTMLFormControlElement* HTMLFormElement::defaultButton() const
{
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
- if (!m_associatedElements[i]->isFormControlElement())
+ if (!is<HTMLFormControlElement>(m_associatedElements[i]))
continue;
- HTMLFormControlElement* control = toHTMLFormControlElement(m_associatedElements[i]);
- if (control->isSuccessfulSubmitButton())
- return control;
+ HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*m_associatedElements[i]);
+ if (control.isSuccessfulSubmitButton())
+ return &control;
}
- return 0;
+ return nullptr;
}
bool HTMLFormElement::checkValidity()
@@ -723,9 +723,9 @@
elements.append(m_associatedElements[i]);
bool hasInvalidControls = false;
for (unsigned i = 0; i < elements.size(); ++i) {
- if (elements[i]->form() == this && elements[i]->isFormControlElement()) {
- HTMLFormControlElement* control = toHTMLFormControlElement(elements[i].get());
- if (!control->checkValidity(&unhandledInvalidControls) && control->form() == this)
+ if (elements[i]->form() == this && is<HTMLFormControlElement>(*elements[i])) {
+ HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*elements[i]);
+ if (!control.checkValidity(&unhandledInvalidControls) && control.form() == this)
hasInvalidControls = true;
}
}
@@ -810,8 +810,8 @@
ASSERT(!shouldAutocomplete());
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
- if (m_associatedElements[i]->isFormControlElement())
- toHTMLFormControlElement(m_associatedElements[i])->reset();
+ if (is<HTMLFormControlElement>(m_associatedElements[i]))
+ downcast<HTMLFormControlElement>(*m_associatedElements[i]).reset();
}
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -915,7 +915,7 @@
inline bool isHTMLMediaElement(const Node& node) { return node.isElementNode() && toElement(node).isMediaElement(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const HTMLMediaElement, ArgType> {
+struct NodeTypeCastTraits<const HTMLMediaElement, ArgType> {
static bool is(ArgType& node) { return isHTMLMediaElement(node); }
};
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -162,7 +162,7 @@
inline bool isHTMLPlugInImageElement(const Node& node) { return node.isPluginElement() && toHTMLPlugInElement(node).isPlugInImageElement(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const HTMLPlugInImageElement, ArgType> {
+struct NodeTypeCastTraits<const HTMLPlugInImageElement, ArgType> {
static bool is(ArgType& node) { return isHTMLPlugInImageElement(node); }
};
Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -24,6 +24,7 @@
#if ENABLE(DETAILS_ELEMENT)
#include "DetailsMarkerControl.h"
#include "HTMLDetailsElement.h"
+#include "HTMLFormControlElement.h"
#include "InsertionPoint.h"
#include "KeyboardEvent.h"
#include "MouseEvent.h"
@@ -104,10 +105,10 @@
if (!node->isElementNode())
return false;
Element* element = toElement(node);
- if (element->isFormControlElement())
+ if (is<HTMLFormControlElement>(element))
return true;
Element* host = element->shadowHost();
- return host && host->isFormControlElement();
+ return host && is<HTMLFormControlElement>(host);
}
bool HTMLSummaryElement::supportsFocus() const
Modified: trunk/Source/WebCore/html/LabelableElement.h (173943 => 173944)
--- trunk/Source/WebCore/html/LabelableElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/LabelableElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -55,7 +55,7 @@
inline bool isLabelableElement(const Node& node) { return node.isHTMLElement() && toHTMLElement(node).isLabelable(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const LabelableElement, ArgType> {
+struct NodeTypeCastTraits<const LabelableElement, ArgType> {
static bool is(ArgType& node) { return isLabelableElement(node); }
};
Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/RadioNodeList.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -85,13 +85,13 @@
bool RadioNodeList::checkElementMatchesRadioNodeListFilter(const Element& testElement) const
{
- ASSERT(testElement.hasTagName(objectTag) || testElement.isFormControlElement());
+ ASSERT(is<HTMLObjectElement>(testElement) || is<HTMLFormControlElement>(testElement));
if (isHTMLFormElement(ownerNode())) {
HTMLFormElement* formElement = nullptr;
if (testElement.hasTagName(objectTag))
formElement = downcast<HTMLObjectElement>(testElement).form();
else
- formElement = toHTMLFormControlElement(testElement).form();
+ formElement = downcast<HTMLFormControlElement>(testElement).form();
if (!formElement || formElement != &ownerNode())
return false;
}
@@ -101,7 +101,7 @@
bool RadioNodeList::elementMatches(Element& testElement) const
{
- if (!testElement.hasTagName(objectTag) && !testElement.isFormControlElement())
+ if (!is<HTMLObjectElement>(testElement) && !is<HTMLFormControlElement>(testElement))
return false;
if (HTMLInputElement* inputElement = testElement.toInputElement()) {
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -727,7 +727,7 @@
// and instead use the DocumentFragment as a root node. So we must treat the root node (DocumentFragment) as if it is a html element here.
bool parentCanBeFosterParent = parent && (parent->isElementNode() || (m_isParsingFragment && parent == m_openElements.rootNode()));
#if ENABLE(TEMPLATE_ELEMENT)
- parentCanBeFosterParent = parentCanBeFosterParent || (parent && parent->isDocumentFragment() && toDocumentFragment(parent)->isTemplateContent());
+ parentCanBeFosterParent = parentCanBeFosterParent || (parent && is<DocumentFragment>(parent) && downcast<DocumentFragment>(parent)->isTemplateContent());
#endif
if (parentCanBeFosterParent) {
task.parent = parent;
Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (173943 => 173944)
--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -2381,7 +2381,7 @@
return node.isLink()
|| node.nodeType() == Node::COMMENT_NODE
|| node.hasTagName(scriptTag)
- || (node.isHTMLElement() && toHTMLElement(node).isFormControlElement())
+ || is<HTMLFormControlElement>(node)
|| node.hasTagName(styleTag)
|| node.hasTagName(ttTag)
|| node.hasTagName(preTag)
Modified: trunk/Source/WebCore/loader/FormSubmission.cpp (173943 => 173944)
--- trunk/Source/WebCore/loader/FormSubmission.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/loader/FormSubmission.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -144,8 +144,8 @@
HTMLFormControlElement* submitButton = 0;
if (event && event->target()) {
for (Node* node = event->target()->toNode(); node; node = node->parentNode()) {
- if (node->isElementNode() && toElement(node)->isFormControlElement()) {
- submitButton = toHTMLFormControlElement(node);
+ if (is<HTMLFormControlElement>(node)) {
+ submitButton = downcast<HTMLFormControlElement>(node);
break;
}
}
Modified: trunk/Source/WebCore/mathml/MathMLElement.h (173943 => 173944)
--- trunk/Source/WebCore/mathml/MathMLElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/mathml/MathMLElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -77,7 +77,7 @@
inline bool isMathMLElement(const Node& node) { return node.isMathMLElement(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const MathMLElement, ArgType> {
+struct NodeTypeCastTraits<const MathMLElement, ArgType> {
static bool is(ArgType& node) { return isMathMLElement(node); }
};
Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (173943 => 173944)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -836,7 +836,7 @@
if (!node)
return;
#if PLATFORM(GTK)
- if (!m_context.hitTestResult().isContentEditable() && (node->isElementNode() && toElement(node)->isFormControlElement()))
+ if (!m_context.hitTestResult().isContentEditable() && is<HTMLFormControlElement>(node))
return;
#endif
Frame* frame = node->document().frame();
Modified: trunk/Source/WebCore/page/Frame.cpp (173943 => 173944)
--- trunk/Source/WebCore/page/Frame.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/page/Frame.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -389,7 +389,7 @@
Node* n;
for (n = NodeTraversal::previous(element); n && lengthSearched < charsSearchedThreshold; n = NodeTraversal::previous(n)) {
// We hit another form element or the start of the form - bail out
- if (isHTMLFormElement(n) || (n->isHTMLElement() && toElement(n)->isFormControlElement()))
+ if (is<HTMLFormElement>(n) || is<HTMLFormControlElement>(n))
break;
if (n->hasTagName(tdTag) && !startingTableCell) {
Modified: trunk/Source/WebCore/rendering/RenderButton.cpp (173943 => 173944)
--- trunk/Source/WebCore/rendering/RenderButton.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/rendering/RenderButton.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -51,7 +51,7 @@
HTMLFormControlElement& RenderButton::formControlElement() const
{
- return toHTMLFormControlElement(nodeForNonAnonymous());
+ return downcast<HTMLFormControlElement>(nodeForNonAnonymous());
}
bool RenderButton::canBeSelectionLeaf() const
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (173943 => 173944)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -69,6 +69,7 @@
#include "FrameView.h"
#include "Gradient.h"
#include "GraphicsContext.h"
+#include "HTMLFormControlElement.h"
#include "HTMLFrameElement.h"
#include "HTMLFrameOwnerElement.h"
#include "HTMLNames.h"
@@ -2573,7 +2574,7 @@
EResize resize = renderer->style().resize();
if (resize != RESIZE_VERTICAL && difference.width()) {
- if (element->isFormControlElement()) {
+ if (is<HTMLFormControlElement>(element)) {
// Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
styledElement->setInlineStyleProperty(CSSPropertyMarginLeft, renderer->marginLeft() / zoomFactor, CSSPrimitiveValue::CSS_PX);
styledElement->setInlineStyleProperty(CSSPropertyMarginRight, renderer->marginRight() / zoomFactor, CSSPrimitiveValue::CSS_PX);
@@ -2584,7 +2585,7 @@
}
if (resize != RESIZE_HORIZONTAL && difference.height()) {
- if (element->isFormControlElement()) {
+ if (is<HTMLFormControlElement>(element)) {
// Make implicit margins from the theme explicit (see <http://bugs.webkit.org/show_bug.cgi?id=9547>).
styledElement->setInlineStyleProperty(CSSPropertyMarginTop, renderer->marginTop() / zoomFactor, CSSPrimitiveValue::CSS_PX);
styledElement->setInlineStyleProperty(CSSPropertyMarginBottom, renderer->marginBottom() / zoomFactor, CSSPrimitiveValue::CSS_PX);
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (173943 => 173944)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -843,9 +843,9 @@
bool RenderTheme::isReadOnlyControl(const RenderObject& o) const
{
Node* node = o.node();
- if (!node || !node->isElementNode() || !toElement(node)->isFormControlElement())
+ if (!node || !is<HTMLFormControlElement>(node))
return false;
- return !toElement(node)->matchesReadWritePseudoClass();
+ return !toElement(*node).matchesReadWritePseudoClass();
}
bool RenderTheme::isHovered(const RenderObject& o) const
Modified: trunk/Source/WebCore/svg/SVGElement.h (173943 => 173944)
--- trunk/Source/WebCore/svg/SVGElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/svg/SVGElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -225,7 +225,7 @@
inline bool isSVGElement(const Node& node) { return node.isSVGElement(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const SVGElement, ArgType> {
+struct NodeTypeCastTraits<const SVGElement, ArgType> {
static bool is(ArgType& node) { return isSVGElement(node); }
};
Modified: trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h (173943 => 173944)
--- trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -87,7 +87,7 @@
inline bool isSVGFilterPrimitiveStandardAttributes(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isFilterEffect(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const SVGFilterPrimitiveStandardAttributes, ArgType> {
+struct NodeTypeCastTraits<const SVGFilterPrimitiveStandardAttributes, ArgType> {
static bool is(ArgType& node) { return isSVGFilterPrimitiveStandardAttributes(node); }
};
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (173943 => 173944)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2014-09-25 03:50:40 UTC (rev 173944)
@@ -242,7 +242,7 @@
inline bool isSVGSMILElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isSMILElement(); }
template <typename ArgType>
-struct ElementTypeCastTraits<const SVGSMILElement, ArgType> {
+struct NodeTypeCastTraits<const SVGSMILElement, ArgType> {
static bool is(ArgType& node) { return isSVGSMILElement(node); }
};
Modified: trunk/Source/WebKit/mac/ChangeLog (173943 => 173944)
--- trunk/Source/WebKit/mac/ChangeLog 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebKit/mac/ChangeLog 2014-09-25 03:50:40 UTC (rev 173944)
@@ -1,5 +1,18 @@
2014-09-24 Christophe Dumez <cdu...@apple.com>
+ Add initial is<>() / downcast<>() support for any type of Nodes
+ https://bugs.webkit.org/show_bug.cgi?id=137056
+
+ Reviewed by Benjamin Poulain.
+
+ Use is<HTMLFormControlElement>() / downcast<HTMLFormControlElement>()
+ instead of isFormControlElement() / toHTMLFormControlElement().
+
+ * WebView/WebHTMLRepresentation.mm:
+ (searchForLabelsBeforeElement):
+
+2014-09-24 Christophe Dumez <cdu...@apple.com>
+
Use is<HTML*Element>() instead of isHTML*Element() - Part 1
https://bugs.webkit.org/show_bug.cgi?id=137068
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm (173943 => 173944)
--- trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm 2014-09-25 03:50:40 UTC (rev 173944)
@@ -445,15 +445,13 @@
unsigned lengthSearched = 0;
Node* n;
for (n = NodeTraversal::previous(element);
- n && lengthSearched < charsSearchedThreshold;
- n = NodeTraversal::previous(n))
- {
- if (n->hasTagName(formTag)
- || (n->isHTMLElement() && toElement(n)->isFormControlElement()))
- {
+ n && lengthSearched < charsSearchedThreshold;
+ n = NodeTraversal::previous(n)) {
+ if (is<HTMLFormElement>(n) || is<HTMLFormControlElement>(n)) {
// We hit another form element or the start of the form - bail out
break;
- } else if (n->hasTagName(tdTag) && !startingTableCell) {
+ }
+ if (n->hasTagName(tdTag) && !startingTableCell) {
startingTableCell = static_cast<HTMLTableCellElement*>(n);
} else if (n->hasTagName(trTag) && startingTableCell) {
NSString* result = frame->searchForLabelsAboveCell(*regExp, startingTableCell, resultDistance);
Modified: trunk/Source/WebKit/win/ChangeLog (173943 => 173944)
--- trunk/Source/WebKit/win/ChangeLog 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebKit/win/ChangeLog 2014-09-25 03:50:40 UTC (rev 173944)
@@ -1,5 +1,18 @@
2014-09-24 Christophe Dumez <cdu...@apple.com>
+ Add initial is<>() / downcast<>() support for any type of Nodes
+ https://bugs.webkit.org/show_bug.cgi?id=137056
+
+ Reviewed by Benjamin Poulain.
+
+ Use is<HTMLFormControlElement>() / downcast<HTMLFormControlElement>()
+ instead of isFormControlElement() / toHTMLFormControlElement().
+
+ * WebFrame.cpp:
+ (WebFrame::elementWithName):
+
+2014-09-24 Christophe Dumez <cdu...@apple.com>
+
Unreviewed build fix after r173932.
Unreviewed build fix after r173932 for Windows. Use WebCore:: namespace
Modified: trunk/Source/WebKit/win/WebFrame.cpp (173943 => 173944)
--- trunk/Source/WebKit/win/WebFrame.cpp 2014-09-25 02:53:48 UTC (rev 173943)
+++ trunk/Source/WebKit/win/WebFrame.cpp 2014-09-25 03:50:40 UTC (rev 173944)
@@ -1101,12 +1101,12 @@
const Vector<FormAssociatedElement*>& elements = formElement->associatedElements();
AtomicString targetName((UChar*)name, SysStringLen(name));
for (unsigned int i = 0; i < elements.size(); i++) {
- if (!elements[i]->isFormControlElement())
+ if (!is<HTMLFormControlElement>(elements[i]))
continue;
- HTMLFormControlElement* elt = toHTMLFormControlElement(elements[i]);
+ HTMLFormControlElement& elt = downcast<HTMLFormControlElement>(*elements[i]);
// Skip option elements, other duds
- if (elt->name() == targetName) {
- *element = DOMElement::createInstance(elt);
+ if (elt.name() == targetName) {
+ *element = DOMElement::createInstance(&elt);
return S_OK;
}
}