Adopt toHTMLTextAreaElement for code cleanup
authorkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jul 2013 10:43:48 +0000 (10:43 +0000)
committerkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Jul 2013 10:43:48 +0000 (10:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118226

Reviewed by Andreas Kling.

To enhance readability, this patch adopts toHTMLTextAreaElement.
This also helps out to reduce duplicated use of static_cast.

Source/WebCore:

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRole):
(WebCore::AccessibilityNodeObject::isNativeTextControl):
(WebCore::AccessibilityNodeObject::isReadOnly):
(WebCore::AccessibilityNodeObject::text):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::setValue):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendText):
* html/HTMLFormControlElement.cpp:
(WebCore::shouldAutofocus):
* html/HTMLTextAreaElement.h:
(WebCore::toHTMLTextAreaElement):
* page/FocusController.cpp:
(WebCore::clearSelectionIfNeeded):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::isContentEditable):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::sizesLogicalWidthToFitContent):
* rendering/RenderTextControlMultiLine.cpp:
(WebCore::RenderTextControlMultiLine::~RenderTextControlMultiLine):
(WebCore::RenderTextControlMultiLine::preferredContentLogicalWidth):
(WebCore::RenderTextControlMultiLine::computeControlLogicalHeight):
* testing/Internals.cpp:
(WebCore::Internals::wasLastChangeUserEdit):

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::blockZoomRectForNode):
* WebKitSupport/DOMSupport.cpp:
(BlackBerry::WebKit::DOMSupport::isTextInputElement):
(BlackBerry::WebKit::DOMSupport::inputElementText):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::elementType):
(BlackBerry::WebKit::InputHandler::boundingBoxForInputField):

Source/WebKit/mac:

* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::textDidChangeInTextArea):

Source/WebKit/win:

* DOMCoreClasses.cpp:
(DOMElement::createInstance):
* DOMHTMLClasses.cpp:
(DOMHTMLTextAreaElement::form):
(DOMHTMLTextAreaElement::value):
(DOMHTMLTextAreaElement::setValue):
(DOMHTMLTextAreaElement::select):
(DOMHTMLTextAreaElement::isUserEdited):

Source/WebKit2:

* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit):
* WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
(WebKit::PDFPluginTextAnnotation::createAnnotationElement):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::textDidChangeInTextArea):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::containsAnyFormControls):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@152218 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/editing/markup.cpp
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLTextAreaElement.h
Source/WebCore/page/FocusController.cpp
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderTextControlMultiLine.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCoreClasses.cpp
Source/WebKit/win/DOMHTMLClasses.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp

index 78b23fe..e17a1c0 100644 (file)
@@ -1,3 +1,41 @@
+2013-07-01  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt toHTMLTextAreaElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118226
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts toHTMLTextAreaElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::determineAccessibilityRole):
+        (WebCore::AccessibilityNodeObject::isNativeTextControl):
+        (WebCore::AccessibilityNodeObject::isReadOnly):
+        (WebCore::AccessibilityNodeObject::text):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::setValue):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::adjustRenderStyle):
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::appendText):
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::shouldAutofocus):
+        * html/HTMLTextAreaElement.h:
+        (WebCore::toHTMLTextAreaElement):
+        * page/FocusController.cpp:
+        (WebCore::clearSelectionIfNeeded):
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::isContentEditable):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::sizesLogicalWidthToFitContent):
+        * rendering/RenderTextControlMultiLine.cpp:
+        (WebCore::RenderTextControlMultiLine::~RenderTextControlMultiLine):
+        (WebCore::RenderTextControlMultiLine::preferredContentLogicalWidth):
+        (WebCore::RenderTextControlMultiLine::computeControlLogicalHeight):
+        * testing/Internals.cpp:
+        (WebCore::Internals::wasLastChangeUserEdit):
+
 2013-07-01  Kwang Yul Seo  <skyul@company100.net>
 
         Add missing string headers that are used when LOG_DISABLED is 0.
index c2b24d8..2c7392a 100644 (file)
@@ -305,7 +305,7 @@ AccessibilityRole AccessibilityNodeObject::determineAccessibilityRole()
         HTMLSelectElement* selectElement = toHTMLSelectElement(node());
         return selectElement->multiple() ? ListBoxRole : PopUpButtonRole;
     }
-    if (node()->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(node()))
         return TextAreaRole;
     if (headingLevel())
         return HeadingRole;
@@ -441,7 +441,7 @@ bool AccessibilityNodeObject::isNativeTextControl() const
     if (!node)
         return false;
 
-    if (node->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(node))
         return true;
 
     if (isHTMLInputElement(node)) {
@@ -694,7 +694,7 @@ bool AccessibilityNodeObject::isReadOnly() const
     if (!node)
         return true;
 
-    if (node->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(node))
         return toHTMLFormControlElement(node)->isReadOnly();
 
     if (isHTMLInputElement(node)) {
@@ -1643,7 +1643,7 @@ String AccessibilityNodeObject::text() const
     if (!node)
         return String();
 
-    if (isNativeTextControl() && (node->hasTagName(textareaTag) || isHTMLInputElement(node)))
+    if (isNativeTextControl() && (isHTMLTextAreaElement(node) || isHTMLInputElement(node)))
         return toHTMLTextFormControlElement(node)->value();
 
     if (!node->isElementNode())
index 797ac46..6e164f1 100644 (file)
@@ -1644,7 +1644,7 @@ void AccessibilityRenderObject::setValue(const String& string)
         toHTMLInputElement(element)->setValue(string);
     } else if (renderer->isTextArea()) {
         // FIXME: This is not safe!  Other elements could have a TextArea renderer.
-        static_cast<HTMLTextAreaElement*>(element)->setValue(string);
+        toHTMLTextAreaElement(element)->setValue(string);
     }
 }
 
index bfa5619..a07ac3a 100644 (file)
@@ -1481,7 +1481,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
         style->setZIndex(0);
 
     // Textarea considers overflow visible as auto.
-    if (e && e->hasTagName(textareaTag)) {
+    if (e && isHTMLTextAreaElement(e)) {
         style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX());
         style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY());
     }
index b5e8981..6b30f53 100644 (file)
@@ -47,6 +47,7 @@
 #include "HTMLBodyElement.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
+#include "HTMLTextAreaElement.h"
 #include "HTMLTextFormControlElement.h"
 #include "KURL.h"
 #include "MarkupAccumulator.h"
@@ -215,7 +216,7 @@ String StyledMarkupAccumulator::takeResults()
 
 void StyledMarkupAccumulator::appendText(StringBuilder& out, Text* text)
 {    
-    const bool parentIsTextarea = text->parentElement() && text->parentElement()->tagQName() == textareaTag;
+    const bool parentIsTextarea = text->parentElement() && isHTMLTextAreaElement(text->parentElement());
     const bool wrappingSpan = shouldApplyWrappingStyle(text) && !parentIsTextarea;
     if (wrappingSpan) {
         RefPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy();
index e172b51..86d7053 100644 (file)
@@ -36,6 +36,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLLegendElement.h"
+#include "HTMLTextAreaElement.h"
 #include "RenderBox.h"
 #include "RenderTheme.h"
 #include "ScriptEventListener.h"
@@ -196,7 +197,7 @@ static bool shouldAutofocus(HTMLFormControlElement* element)
         return true;
     if (element->hasTagName(buttonTag))
         return true;
-    if (element->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(element))
         return true;
 
     return false;
index 7a17f75..02fb9f9 100644 (file)
@@ -132,6 +132,12 @@ inline bool isHTMLTextAreaElement(Node* node)
     return node->hasTagName(HTMLNames::textareaTag);
 }
 
+inline HTMLTextAreaElement* toHTMLTextAreaElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLTextAreaElement(node));
+    return static_cast<HTMLTextAreaElement*>(node);
+}
+
 } //namespace
 
 #endif
index 3aa9c9b..bc83e7f 100644 (file)
@@ -46,6 +46,7 @@
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
+#include "HTMLTextAreaElement.h"
 #include "HitTestResult.h"
 #include "KeyboardEvent.h"
 #include "NodeRenderingTraversal.h"
@@ -584,7 +585,7 @@ static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFram
                 return;
 
             if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode()) {
-                if (!isHTMLInputElement(shadowAncestorNode) && !shadowAncestorNode->hasTagName(textareaTag))
+                if (!isHTMLInputElement(shadowAncestorNode) && !isHTMLTextAreaElement(shadowAncestorNode))
                     return;
             }
         }
index b551733..de8d4ce 100644 (file)
@@ -37,6 +37,7 @@
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "HTMLPlugInImageElement.h"
+#include "HTMLTextAreaElement.h"
 #include "HTMLVideoElement.h"
 #include "HitTestLocation.h"
 #include "RenderBlock.h"
@@ -568,7 +569,7 @@ bool HitTestResult::isContentEditable() const
     if (!m_innerNonSharedNode)
         return false;
 
-    if (m_innerNonSharedNode->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(m_innerNonSharedNode.get()))
         return true;
 
     if (isHTMLInputElement(m_innerNonSharedNode.get()))
index 77b1089..1a0828f 100644 (file)
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "Document.h"
+#include "FloatQuad.h"
+#include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
-#include "HitTestResult.h"
-#include "htmlediting.h"
 #include "HTMLElement.h"
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
-#include "FloatQuad.h"
-#include "Frame.h"
+#include "HTMLTextAreaElement.h"
+#include "HitTestResult.h"
 #include "Page.h"
 #include "PaintInfo.h"
 #include "RenderArena.h"
@@ -52,6 +52,7 @@
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "TransformState.h"
+#include "htmlediting.h"
 #include <algorithm>
 #include <math.h>
 #include <wtf/StackStats.h>
@@ -2305,7 +2306,7 @@ bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const
     // stretching column flexbox.
     // FIXME: Think about block-flow here.
     // https://bugs.webkit.org/show_bug.cgi?id=46473
-    if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && node() && (isHTMLInputElement(node()) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)))
+    if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && node() && (isHTMLInputElement(node()) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || isHTMLTextAreaElement(node()) || node()->hasTagName(legendTag)))
         return true;
 
     if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode())
index 153a95c..9a121c6 100644 (file)
@@ -40,7 +40,7 @@ RenderTextControlMultiLine::RenderTextControlMultiLine(Element* element)
 RenderTextControlMultiLine::~RenderTextControlMultiLine()
 {
     if (node() && node()->inDocument())
-        static_cast<HTMLTextAreaElement*>(node())->rendererWillBeDestroyed();
+        toHTMLTextAreaElement(node())->rendererWillBeDestroyed();
 }
 
 bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
@@ -67,13 +67,13 @@ float RenderTextControlMultiLine::getAvgCharWidth(AtomicString family)
 
 LayoutUnit RenderTextControlMultiLine::preferredContentLogicalWidth(float charWidth) const
 {
-    int factor = static_cast<HTMLTextAreaElement*>(node())->cols();
+    int factor = toHTMLTextAreaElement(node())->cols();
     return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickness();
 }
 
 LayoutUnit RenderTextControlMultiLine::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
 {
-    return lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows() + nonContentHeight;
+    return lineHeight * toHTMLTextAreaElement(node())->rows() + nonContentHeight;
 }
 
 int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
index 0ade466..a96fde0 100644 (file)
@@ -934,7 +934,7 @@ bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec)
 
     // FIXME: We should be using hasTagName instead but Windows port doesn't link QualifiedNames properly.
     if (textField->tagName() == "TEXTAREA")
-        return static_cast<HTMLTextAreaElement*>(textField)->lastChangeWasUserEdit();
+        return toHTMLTextAreaElement(textField)->lastChangeWasUserEdit();
 
     ec = INVALID_NODE_TYPE_ERR;
     return false;
index 211a60e..97f2a8b 100644 (file)
@@ -68,6 +68,7 @@
 #include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "HTMLTextAreaElement.h"
 #include "HTTPParsers.h"
 #include "HistoryItem.h"
 #include "IconDatabaseClientBlackBerry.h"
@@ -2831,7 +2832,7 @@ IntRect WebPagePrivate::blockZoomRectForNode(Node* node)
     double blockToPageRatio = static_cast<double>(pageArea - originalArea) / pageArea;
     double blockExpansionRatio = 5.0 * blockToPageRatio * blockToPageRatio;
 
-    if (!isHTMLImageElement(tnode) && !isHTMLInputElement(tnode) && !tnode->hasTagName(HTMLNames::textareaTag)) {
+    if (!isHTMLImageElement(tnode) && !isHTMLInputElement(tnode) && !isHTMLTextAreaElement(tnode)) {
         while ((tnode = tnode->parentNode())) {
             ASSERT(tnode);
             IntRect tRect = rectForNode(tnode);
index ca0455c..03d440c 100644 (file)
@@ -1,3 +1,22 @@
+2013-07-01  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt toHTMLTextAreaElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118226
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts toHTMLTextAreaElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::blockZoomRectForNode):
+        * WebKitSupport/DOMSupport.cpp:
+        (BlackBerry::WebKit::DOMSupport::isTextInputElement):
+        (BlackBerry::WebKit::DOMSupport::inputElementText):
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::elementType):
+        (BlackBerry::WebKit::InputHandler::boundingBoxForInputField):
+
 2013-06-29  Kangil Han  <kangil.han@samsung.com>
 
         Adopt is/toHTMLOptGroupElement for code cleanup
index 752adff..312229d 100644 (file)
@@ -103,7 +103,7 @@ bool isShadowHostTextInputElement(Node* node)
 bool isTextInputElement(Element* element)
 {
     return element->isTextFormControl()
-        || element->hasTagName(HTMLNames::textareaTag)
+        || isHTMLTextAreaElement(element)
         || element->isContentEditable();
 }
 
@@ -122,8 +122,8 @@ WTF::String inputElementText(Element* element)
     if (isHTMLInputElement(element)) {
         const HTMLInputElement* inputElement = toHTMLInputElement(element);
         elementText = inputElement->value();
-    } else if (element->hasTagName(HTMLNames::textareaTag)) {
-        const HTMLTextAreaElement* inputElement = static_cast<const HTMLTextAreaElement*>(element);
+    } else if (isHTMLTextAreaElement(element)) {
+        const HTMLTextAreaElement* inputElement = toHTMLTextAreaElement(element);
         elementText = inputElement->value();
     } else if (element->isContentEditable()) {
         RefPtr<Range> rangeForNode = rangeOfContents(element);
index 0fc8c2b..e12c0f3 100644 (file)
@@ -413,7 +413,7 @@ BlackBerryInputType InputHandler::elementType(Element* element) const
     if (const HTMLInputElement* inputElement = toHTMLInputElement(element))
         return convertInputType(inputElement);
 
-    if (element->hasTagName(HTMLNames::textareaTag))
+    if (isHTMLTextAreaElement(element))
         return InputTypeTextArea;
 
     // Default to InputTypeTextArea for content editable fields.
@@ -1354,7 +1354,7 @@ WebCore::IntRect InputHandler::boundingBoxForInputField()
         return m_currentFocusElement->renderer()->absoluteBoundingBoxRect();
     }
 
-    if (m_currentFocusElement->hasTagName(HTMLNames::textareaTag))
+    if (isHTMLTextAreaElement(m_currentFocusElement))
         return m_currentFocusElement->renderer()->absoluteBoundingBoxRect();
 
     // Content Editable can't rely on the bounding box since it isn't fixed.
index 6182d38..50ffcd9 100644 (file)
@@ -1,3 +1,16 @@
+2013-07-01  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt toHTMLTextAreaElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118226
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts toHTMLTextAreaElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::textDidChangeInTextArea):
+
 2013-06-27  Kangil Han  <kangil.han@samsung.com>
 
         Adopt is/toHTMLInputElement for code cleanup
index 17c2d31..17020e8 100644 (file)
@@ -711,10 +711,10 @@ void WebEditorClient::textWillBeDeletedInTextField(Element* element)
 
 void WebEditorClient::textDidChangeInTextArea(Element* element)
 {
-    if (!element->hasTagName(textareaTag))
+    if (!isHTMLTextAreaElement(element))
         return;
 
-    DOMHTMLTextAreaElement* textAreaElement = kit(static_cast<HTMLTextAreaElement*>(element));
+    DOMHTMLTextAreaElement* textAreaElement = kit(toHTMLTextAreaElement(element));
     FormDelegateLog(textAreaElement);
     CallFormDelegate(m_webView, @selector(textDidChangeInTextArea:inFrame:), textAreaElement, kit(element->document()->frame()));
 }
index de061c0..686362b 100644 (file)
@@ -1,3 +1,22 @@
+2013-07-01  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt toHTMLTextAreaElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118226
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts toHTMLTextAreaElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * DOMCoreClasses.cpp:
+        (DOMElement::createInstance):
+        * DOMHTMLClasses.cpp:
+        (DOMHTMLTextAreaElement::form):
+        (DOMHTMLTextAreaElement::value):
+        (DOMHTMLTextAreaElement::setValue):
+        (DOMHTMLTextAreaElement::select):
+        (DOMHTMLTextAreaElement::isUserEdited):
+
 2013-06-29  Kangil Han  <kangil.han@samsung.com>
 
         Adopt is/toHTMLOptionElement for code cleanup
index 05e1e71..ba371f3 100644 (file)
@@ -1509,7 +1509,7 @@ IDOMElement* DOMElement::createInstance(WebCore::Element* e)
     } else if (e->hasTagName(selectTag)) {
         DOMHTMLSelectElement* newElement = new DOMHTMLSelectElement(e);
         hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
-    } else if (e->hasTagName(textareaTag)) {
+    } else if (isHTMLTextAreaElement(e)) {
         DOMHTMLTextAreaElement* newElement = new DOMHTMLTextAreaElement(e);
         hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
     } else if (e->isHTMLElement()) {
index 61205c7..b03ae11 100644 (file)
@@ -1430,8 +1430,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::form(
     if (!result)
         return E_POINTER;
     *result = 0;
-    ASSERT(m_element && m_element->hasTagName(textareaTag));
-    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
+    ASSERT(m_element && isHTMLTextAreaElement(m_element));
+    HTMLTextAreaElement* textareaElement = toHTMLTextAreaElement(m_element);
     COMPtr<IDOMElement> domElement;
     domElement.adoptRef(DOMHTMLElement::createInstance(textareaElement->form()));
     if (domElement)
@@ -1547,8 +1547,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::type(
 HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value( 
         /* [retval][out] */ BSTR* result)
 {
-    ASSERT(m_element && m_element->hasTagName(textareaTag));
-    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
+    ASSERT(m_element && isHTMLTextAreaElement(m_element));
+    HTMLTextAreaElement* textareaElement = toHTMLTextAreaElement(m_element);
     WTF::String valueString = textareaElement->value();
     *result = BString(valueString.characters(), valueString.length()).release();
     if (valueString.length() && !*result)
@@ -1559,16 +1559,16 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value(
 HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::setValue( 
         /* [in] */ BSTR value)
 {
-    ASSERT(m_element && m_element->hasTagName(textareaTag));
-    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
+    ASSERT(m_element && isHTMLTextAreaElement(m_element));
+    HTMLTextAreaElement* textareaElement = toHTMLTextAreaElement(m_element);
     textareaElement->setValue(String((UChar*) value, SysStringLen(value)));
     return S_OK;
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::select( void)
 {
-    ASSERT(m_element && m_element->hasTagName(textareaTag));
-    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
+    ASSERT(m_element && isHTMLTextAreaElement(m_element));
+    HTMLTextAreaElement* textareaElement = toHTMLTextAreaElement(m_element);
     textareaElement->select();
     return S_OK;
 }
@@ -1582,8 +1582,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::isUserEdited(
         return E_POINTER;
 
     *result = FALSE;
-    ASSERT(m_element && m_element->hasTagName(textareaTag));
-    if (static_cast<HTMLTextAreaElement*>(m_element)->lastChangeWasUserEdit())
+    ASSERT(m_element && isHTMLTextAreaElement(m_element));
+    if (toHTMLTextAreaElement(m_element)->lastChangeWasUserEdit())
         *result = TRUE;
     return S_OK;
 }
index 96f4cbc..7b1246a 100644 (file)
@@ -1,3 +1,22 @@
+2013-07-01  Kangil Han  <kangil.han@samsung.com>
+
+        Adopt toHTMLTextAreaElement for code cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=118226
+
+        Reviewed by Andreas Kling.
+
+        To enhance readability, this patch adopts toHTMLTextAreaElement.
+        This also helps out to reduce duplicated use of static_cast.
+
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit):
+        * WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
+        (WebKit::PDFPluginTextAnnotation::createAnnotationElement):
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::textDidChangeInTextArea):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::containsAnyFormControls):
+
 2013-06-28  Andreas Kling  <akling@apple.com>
 
         Fix Windows builds after deprecatedCharactersWithNullTermination() removal.
index 296bf25..5c217f3 100644 (file)
@@ -212,10 +212,10 @@ bool InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit()
 
 bool InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit()
 {
-    if (!m_node->hasTagName(textareaTag))
+    if (!isHTMLTextAreaElement(m_node.get()))
         return false;
 
-    return static_cast<HTMLTextAreaElement*>(m_node.get())->lastChangeWasUserEdit();
+    return toHTMLTextAreaElement(m_node.get())->lastChangeWasUserEdit();
 }
 
 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove()
index 5af6ec6..d124cc6 100644 (file)
@@ -105,7 +105,7 @@ PassRefPtr<Element> PDFPluginTextAnnotation::createAnnotationElement()
     styledElement->setInlineStyleProperty(CSSPropertyTextAlign, cssAlignmentValueForNSTextAlignment(textAnnotation.alignment));
 
     if (isMultiline)
-        static_cast<HTMLTextAreaElement*>(styledElement)->setValue(textAnnotation.stringValue);
+        toHTMLTextAreaElement(styledElement)->setValue(textAnnotation.stringValue);
     else
         toHTMLInputElement(styledElement)->setValue(textAnnotation.stringValue);
 
index c913a61..b1b0543 100644 (file)
@@ -355,14 +355,14 @@ void WebEditorClient::textDidChangeInTextField(Element* element)
 
 void WebEditorClient::textDidChangeInTextArea(Element* element)
 {
-    if (!element->hasTagName(textareaTag))
+    if (!isHTMLTextAreaElement(element))
         return;
 
     WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     ASSERT(webFrame);
 
-    m_page->injectedBundleFormClient().textDidChangeInTextArea(m_page, static_cast<HTMLTextAreaElement*>(element), webFrame);
+    m_page->injectedBundleFormClient().textDidChangeInTextArea(m_page, toHTMLTextAreaElement(element), webFrame);
 }
 
 static bool getActionTypeForKeyEvent(KeyboardEvent* event, WKInputFieldActionType& type)
index 1b4de0d..9a948f6 100644 (file)
@@ -52,6 +52,7 @@
 #include <WebCore/HTMLFrameOwnerElement.h>
 #include <WebCore/HTMLInputElement.h>
 #include <WebCore/HTMLNames.h>
+#include <WebCore/HTMLTextAreaElement.h>
 #include <WebCore/JSCSSStyleDeclaration.h>
 #include <WebCore/JSElement.h>
 #include <WebCore/JSRange.h>
@@ -617,7 +618,7 @@ bool WebFrame::containsAnyFormControls() const
     for (Node* node = document->documentElement(); node; node = NodeTraversal::next(node)) {
         if (!node->isElementNode())
             continue;
-        if (isHTMLInputElement(node) || toElement(node)->hasTagName(HTMLNames::selectTag) || toElement(node)->hasTagName(HTMLNames::textareaTag))
+        if (isHTMLInputElement(node) || toElement(node)->hasTagName(HTMLNames::selectTag) || isHTMLTextAreaElement(node))
             return true;
     }
     return false;