Title: [152218] trunk/Source
Revision
152218
Author
[email protected]
Date
2013-07-01 03:43:48 -0700 (Mon, 01 Jul 2013)

Log Message

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.

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152217 => 152218)


--- trunk/Source/WebCore/ChangeLog	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/ChangeLog	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1,3 +1,41 @@
+2013-07-01  Kangil Han  <[email protected]>
+
+        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  <[email protected]>
 
         Add missing string headers that are used when LOG_DISABLED is 0.

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (152217 => 152218)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -305,7 +305,7 @@
         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 @@
     if (!node)
         return false;
 
-    if (node->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(node))
         return true;
 
     if (isHTMLInputElement(node)) {
@@ -694,7 +694,7 @@
     if (!node)
         return true;
 
-    if (node->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(node))
         return toHTMLFormControlElement(node)->isReadOnly();
 
     if (isHTMLInputElement(node)) {
@@ -1643,7 +1643,7 @@
     if (!node)
         return String();
 
-    if (isNativeTextControl() && (node->hasTagName(textareaTag) || isHTMLInputElement(node)))
+    if (isNativeTextControl() && (isHTMLTextAreaElement(node) || isHTMLInputElement(node)))
         return toHTMLTextFormControlElement(node)->value();
 
     if (!node->isElementNode())

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (152217 => 152218)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1644,7 +1644,7 @@
         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);
     }
 }
 

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (152217 => 152218)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1481,7 +1481,7 @@
         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());
     }

Modified: trunk/Source/WebCore/editing/markup.cpp (152217 => 152218)


--- trunk/Source/WebCore/editing/markup.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/editing/markup.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -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 @@
 
 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();

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (152217 => 152218)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -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 @@
         return true;
     if (element->hasTagName(buttonTag))
         return true;
-    if (element->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(element))
         return true;
 
     return false;

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (152217 => 152218)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2013-07-01 10:43:48 UTC (rev 152218)
@@ -132,6 +132,12 @@
     return node->hasTagName(HTMLNames::textareaTag);
 }
 
+inline HTMLTextAreaElement* toHTMLTextAreaElement(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLTextAreaElement(node));
+    return static_cast<HTMLTextAreaElement*>(node);
+}
+
 } //namespace
 
 #endif

Modified: trunk/Source/WebCore/page/FocusController.cpp (152217 => 152218)


--- trunk/Source/WebCore/page/FocusController.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/page/FocusController.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -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 @@
                 return;
 
             if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode()) {
-                if (!isHTMLInputElement(shadowAncestorNode) && !shadowAncestorNode->hasTagName(textareaTag))
+                if (!isHTMLInputElement(shadowAncestorNode) && !isHTMLTextAreaElement(shadowAncestorNode))
                     return;
             }
         }

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (152217 => 152218)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -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 @@
     if (!m_innerNonSharedNode)
         return false;
 
-    if (m_innerNonSharedNode->hasTagName(textareaTag))
+    if (isHTMLTextAreaElement(m_innerNonSharedNode.get()))
         return true;
 
     if (isHTMLInputElement(m_innerNonSharedNode.get()))

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (152217 => 152218)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -28,16 +28,16 @@
 #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 @@
     // 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())

Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp (152217 => 152218)


--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -40,7 +40,7 @@
 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 @@
 
 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

Modified: trunk/Source/WebCore/testing/Internals.cpp (152217 => 152218)


--- trunk/Source/WebCore/testing/Internals.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebCore/testing/Internals.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -934,7 +934,7 @@
 
     // 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;

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (152217 => 152218)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -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 @@
     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);

Modified: trunk/Source/WebKit/blackberry/ChangeLog (152217 => 152218)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1,3 +1,22 @@
+2013-07-01  Kangil Han  <[email protected]>
+
+        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  <[email protected]>
 
         Adopt is/toHTMLOptGroupElement for code cleanup

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp (152217 => 152218)


--- trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -103,7 +103,7 @@
 bool isTextInputElement(Element* element)
 {
     return element->isTextFormControl()
-        || element->hasTagName(HTMLNames::textareaTag)
+        || isHTMLTextAreaElement(element)
         || element->isContentEditable();
 }
 
@@ -122,8 +122,8 @@
     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);

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (152217 => 152218)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -413,7 +413,7 @@
     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 @@
         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.

Modified: trunk/Source/WebKit/mac/ChangeLog (152217 => 152218)


--- trunk/Source/WebKit/mac/ChangeLog	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1,3 +1,16 @@
+2013-07-01  Kangil Han  <[email protected]>
+
+        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  <[email protected]>
 
         Adopt is/toHTMLInputElement for code cleanup

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (152217 => 152218)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2013-07-01 10:43:48 UTC (rev 152218)
@@ -711,10 +711,10 @@
 
 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()));
 }

Modified: trunk/Source/WebKit/win/ChangeLog (152217 => 152218)


--- trunk/Source/WebKit/win/ChangeLog	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/win/ChangeLog	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1,3 +1,22 @@
+2013-07-01  Kangil Han  <[email protected]>
+
+        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  <[email protected]>
 
         Adopt is/toHTMLOptionElement for code cleanup

Modified: trunk/Source/WebKit/win/DOMCoreClasses.cpp (152217 => 152218)


--- trunk/Source/WebKit/win/DOMCoreClasses.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/win/DOMCoreClasses.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1509,7 +1509,7 @@
     } 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()) {

Modified: trunk/Source/WebKit/win/DOMHTMLClasses.cpp (152217 => 152218)


--- trunk/Source/WebKit/win/DOMHTMLClasses.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit/win/DOMHTMLClasses.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1430,8 +1430,8 @@
     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::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::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 @@
         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;
 }

Modified: trunk/Source/WebKit2/ChangeLog (152217 => 152218)


--- trunk/Source/WebKit2/ChangeLog	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit2/ChangeLog	2013-07-01 10:43:48 UTC (rev 152218)
@@ -1,3 +1,22 @@
+2013-07-01  Kangil Han  <[email protected]>
+
+        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  <[email protected]>
 
         Fix Windows builds after deprecatedCharactersWithNullTermination() removal.

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (152217 => 152218)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -212,10 +212,10 @@
 
 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()

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm (152217 => 152218)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm	2013-07-01 10:43:48 UTC (rev 152218)
@@ -105,7 +105,7 @@
     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);
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (152217 => 152218)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -355,14 +355,14 @@
 
 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)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (152217 => 152218)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp	2013-07-01 08:44:44 UTC (rev 152217)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp	2013-07-01 10:43:48 UTC (rev 152218)
@@ -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 @@
     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;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to