Title: [157694] trunk/Source/WebCore
Revision
157694
Author
[email protected]
Date
2013-10-19 21:55:32 -0700 (Sat, 19 Oct 2013)

Log Message

CTTE: Tighten up type usage around InputType::innerTextElement()
https://bugs.webkit.org/show_bug.cgi?id=123078

Reviewed by Anders Carlsson.

* editing/TextIterator.cpp:
(WebCore::TextIterator::handleReplacedElement):
* html/HTMLElement.h:
(WebCore::HTMLElement::isTextControlInnerTextElement):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::innerTextElement):
* html/HTMLInputElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::innerTextElement):
* html/HTMLTextAreaElement.h:
* html/HTMLTextFormControlElement.cpp:
(WebCore::hasVisibleTextArea):
(WebCore::HTMLTextFormControlElement::selection):
(WebCore::HTMLTextFormControlElement::innerTextValue):
(WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks):
* html/HTMLTextFormControlElement.h:
* html/InputType.h:
(WebCore::InputType::innerTextElement):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent):
(WebCore::TextFieldInputType::innerTextElement):
* html/TextFieldInputType.h:
* html/shadow/TextControlInnerElements.cpp:
(WebCore::TextControlInnerTextElement::renderer):
* html/shadow/TextControlInnerElements.h:
(WebCore::isTextControlInnerTextElement):
* rendering/RenderObject.h:
(WebCore::RenderObject::isTextControlInnerBlock):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::innerTextElement):
(WebCore::RenderTextControl::styleDidChange):
(WebCore::RenderTextControl::textBlockLogicalWidth):
(WebCore::RenderTextControl::updateFromElement):
(WebCore::RenderTextControl::computeLogicalHeight):
(WebCore::RenderTextControl::hitInnerTextElement):
* rendering/RenderTextControl.h:
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::layout):
(WebCore::RenderTextControlSingleLine::styleDidChange):
(WebCore::RenderTextControlSingleLine::autoscroll):
(WebCore::RenderTextControlSingleLine::scroll):
(WebCore::RenderTextControlSingleLine::logicalScroll):
* rendering/RenderTextControlSingleLine.h:
(WebCore::toRenderTextControlInnerBlock):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (157693 => 157694)


--- trunk/Source/WebCore/ChangeLog	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/ChangeLog	2013-10-20 04:55:32 UTC (rev 157694)
@@ -1,5 +1,57 @@
 2013-10-19  Sam Weinig  <[email protected]>
 
+        CTTE: Tighten up type usage around InputType::innerTextElement()
+        https://bugs.webkit.org/show_bug.cgi?id=123078
+
+        Reviewed by Anders Carlsson.
+
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::handleReplacedElement):
+        * html/HTMLElement.h:
+        (WebCore::HTMLElement::isTextControlInnerTextElement):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::innerTextElement):
+        * html/HTMLInputElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::innerTextElement):
+        * html/HTMLTextAreaElement.h:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::hasVisibleTextArea):
+        (WebCore::HTMLTextFormControlElement::selection):
+        (WebCore::HTMLTextFormControlElement::innerTextValue):
+        (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks):
+        * html/HTMLTextFormControlElement.h:
+        * html/InputType.h:
+        (WebCore::InputType::innerTextElement):
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::forwardEvent):
+        (WebCore::TextFieldInputType::innerTextElement):
+        * html/TextFieldInputType.h:
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::TextControlInnerTextElement::renderer):
+        * html/shadow/TextControlInnerElements.h:
+        (WebCore::isTextControlInnerTextElement):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::isTextControlInnerBlock):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::innerTextElement):
+        (WebCore::RenderTextControl::styleDidChange):
+        (WebCore::RenderTextControl::textBlockLogicalWidth):
+        (WebCore::RenderTextControl::updateFromElement):
+        (WebCore::RenderTextControl::computeLogicalHeight):
+        (WebCore::RenderTextControl::hitInnerTextElement):
+        * rendering/RenderTextControl.h:
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::layout):
+        (WebCore::RenderTextControlSingleLine::styleDidChange):
+        (WebCore::RenderTextControlSingleLine::autoscroll):
+        (WebCore::RenderTextControlSingleLine::scroll):
+        (WebCore::RenderTextControlSingleLine::logicalScroll):
+        * rendering/RenderTextControlSingleLine.h:
+        (WebCore::toRenderTextControlInnerBlock):
+
+2013-10-19  Sam Weinig  <[email protected]>
+
         Move m_lineBoxes from RenderBlock to RenderBlockFlow (Part 4)
         https://bugs.webkit.org/show_bug.cgi?id=122969
 

Modified: trunk/Source/WebCore/editing/TextIterator.cpp (157693 => 157694)


--- trunk/Source/WebCore/editing/TextIterator.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/editing/TextIterator.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -32,9 +32,8 @@
 #include "Font.h"
 #include "Frame.h"
 #include "HTMLElement.h"
+#include "HTMLNames.h"
 #include "HTMLTextFormControlElement.h"
-#include "HTMLNames.h"
-#include "htmlediting.h"
 #include "InlineTextBox.h"
 #include "NodeTraversal.h"
 #include "Range.h"
@@ -46,8 +45,10 @@
 #include "ShadowRoot.h"
 #include "TextBoundaries.h"
 #include "TextBreakIterator.h"
+#include "TextControlInnerElements.h"
 #include "VisiblePosition.h"
 #include "VisibleUnits.h"
+#include "htmlediting.h"
 #include <wtf/text/CString.h>
 #include <wtf/unicode/CharacterNames.h>
 
@@ -681,7 +682,7 @@
     }
 
     if (m_entersTextControls && renderer->isTextControl()) {
-        if (HTMLElement* innerTextElement = toRenderTextControl(renderer)->textFormControlElement().innerTextElement()) {
+        if (TextControlInnerTextElement* innerTextElement = toRenderTextControl(renderer)->textFormControlElement().innerTextElement()) {
             m_node = innerTextElement->containingShadowRoot();
             pushFullyClippedState(m_fullyClippedStack, m_node);
             m_offset = 0;

Modified: trunk/Source/WebCore/html/HTMLElement.h (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLElement.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLElement.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -90,6 +90,7 @@
     TextDirection directionalityIfhasDirAutoAttribute(bool& isAuto) const;
 
     virtual bool isHTMLUnknownElement() const { return false; }
+    virtual bool isTextControlInnerTextElement() const { return false; }
 
     virtual bool isLabelable() const { return false; }
     virtual FormNamedItem* asFormNamedItem() { return 0; }

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -190,7 +190,7 @@
     return m_inputType->containerElement();
 }
 
-HTMLElement* HTMLInputElement::innerTextElement() const
+TextControlInnerTextElement* HTMLInputElement::innerTextElement() const
 {
     return m_inputType->innerTextElement();
 }

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -39,8 +39,9 @@
 class HTMLOptionElement;
 class Icon;
 class InputType;
+class ListAttributeTargetObserver;
+class TextControlInnerTextElement;
 class URL;
-class ListAttributeTargetObserver;
 struct DateTimeChooserParameters;
 
 struct InputElementClickState {
@@ -138,7 +139,7 @@
 #endif
 
     HTMLElement* containerElement() const;
-    virtual HTMLElement* innerTextElement() const OVERRIDE;
+    virtual TextControlInnerTextElement* innerTextElement() const OVERRIDE;
     HTMLElement* innerBlockElement() const;
     HTMLElement* innerSpinButtonElement() const;
     HTMLElement* resultsButtonElement() const;

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -322,11 +322,10 @@
     return proposedValue.left(numCharactersInGraphemeClusters(proposedValue, maxLength));
 }
 
-HTMLElement* HTMLTextAreaElement::innerTextElement() const
+TextControlInnerTextElement* HTMLTextAreaElement::innerTextElement() const
 {
     Node* node = userAgentShadowRoot()->firstChild();
-    ASSERT(!node || node->hasTagName(divTag));
-    return toHTMLElement(node);
+    return toTextControlInnerTextElement(node);
 }
 
 void HTMLTextAreaElement::rendererWillBeDestroyed()

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -53,7 +53,7 @@
     virtual bool tooLong() const OVERRIDE;
     bool isValidValue(const String&) const;
     
-    virtual HTMLElement* innerTextElement() const OVERRIDE;
+    virtual TextControlInnerTextElement* innerTextElement() const OVERRIDE;
 
     void rendererWillBeDestroyed();
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -39,10 +39,12 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "NodeTraversal.h"
-#include "RenderBlock.h"
+#include "RenderBlockFlow.h"
+#include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
 #include "ShadowRoot.h"
 #include "Text.h"
+#include "TextControlInnerElements.h"
 #include "htmlediting.h"
 #include <wtf/text/StringBuilder.h>
 
@@ -203,7 +205,7 @@
     setChangedSinceLastFormControlChangeEvent(false);
 }
 
-static inline bool hasVisibleTextArea(RenderElement& textControl, HTMLElement* innerText)
+static inline bool hasVisibleTextArea(RenderElement& textControl, TextControlInnerTextElement* innerText)
 {
     return textControl.style()->visibility() != HIDDEN && innerText && innerText->renderer() && innerText->renderBox()->height();
 }
@@ -428,7 +430,7 @@
     int end = m_cachedSelectionEnd;
 
     ASSERT(start <= end);
-    HTMLElement* innerText = innerTextElement();
+    TextControlInnerTextElement* innerText = innerTextElement();
     if (!innerText)
         return 0;
 
@@ -526,10 +528,13 @@
 
 String HTMLTextFormControlElement::innerTextValue() const
 {
-    HTMLElement* innerText = innerTextElement();
-    if (!innerText || !isTextFormControl())
+    if (!isTextFormControl())
         return emptyString();
 
+    TextControlInnerTextElement* innerText = innerTextElement();
+    if (!innerText)
+        return emptyString();
+
     StringBuilder result;
     for (Node* node = innerText; node; node = NodeTraversal::next(node, innerText)) {
         if (node->hasTagName(brTag))
@@ -561,11 +566,14 @@
 {
     // FIXME: It's not acceptable to ignore the HardWrap setting when there is no renderer.
     // While we have no evidence this has ever been a practical problem, it would be best to fix it some day.
-    HTMLElement* innerText = innerTextElement();
-    if (!innerText || !isTextFormControl())
+    if (!isTextFormControl())
         return value();
 
-    RenderBlock* renderer = toRenderBlock(innerText->renderer());
+    TextControlInnerTextElement* innerText = innerTextElement();
+    if (!innerText)
+        return value();
+
+    RenderTextControlInnerBlock* renderer = innerText->renderer();
     if (!renderer)
         return value();
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (157693 => 157694)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -31,6 +31,7 @@
 
 class Position;
 class RenderTextControl;
+class TextControlInnerTextElement;
 class VisiblePosition;
 
 enum TextFieldSelectionDirection { SelectionHasNoDirection, SelectionHasForwardDirection, SelectionHasBackwardDirection };
@@ -75,7 +76,7 @@
     virtual int maxLength() const = 0;
     virtual String value() const = 0;
 
-    virtual HTMLElement* innerTextElement() const = 0;
+    virtual TextControlInnerTextElement* innerTextElement() const = 0;
 
     void selectionChanged(bool userTriggered);
     bool lastChangeWasUserEdit() const;

Modified: trunk/Source/WebCore/html/InputType.h (157693 => 157694)


--- trunk/Source/WebCore/html/InputType.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/InputType.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -60,6 +60,7 @@
 class RenderArena;
 class RenderStyle;
 class TouchEvent;
+class TextControlInnerTextElement;
 
 struct InputElementClickState;
 
@@ -217,7 +218,7 @@
 
     virtual HTMLElement* containerElement() const { return nullptr; }
     virtual HTMLElement* innerBlockElement() const { return nullptr; }
-    virtual HTMLElement* innerTextElement() const { return nullptr; }
+    virtual TextControlInnerTextElement* innerTextElement() const { return nullptr; }
     virtual HTMLElement* innerSpinButtonElement() const { return nullptr; }
     virtual HTMLElement* resultsButtonElement() const { return nullptr; }
     virtual HTMLElement* cancelButtonElement() const { return nullptr; }

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (157693 => 157694)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -175,7 +175,7 @@
     if (element().renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)) {
         RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(element().renderer());
         if (event->type() == eventNames().blurEvent) {
-            if (RenderBox* innerTextRenderer = innerTextElement()->renderBox()) {
+            if (RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer()) {
                 if (RenderLayer* innerLayer = innerTextRenderer->layer()) {
                     IntSize scrollOffset(!renderTextControl->style()->isLeftToRightDirection() ? innerLayer->scrollWidth() : 0, 0);
                     innerLayer->scrollToOffset(scrollOffset, RenderLayer::ScrollOffsetClamped);
@@ -273,7 +273,7 @@
     return m_innerBlock.get();
 }
 
-HTMLElement* TextFieldInputType::innerTextElement() const
+TextControlInnerTextElement* TextFieldInputType::innerTextElement() const
 {
     ASSERT(m_innerText);
     return m_innerText.get();

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (157693 => 157694)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -36,7 +36,8 @@
 
 namespace WebCore {
 
-class FormDataList; 
+class FormDataList;
+class TextControlInnerTextElement;
 
 // The class represents types of which UI contain text fields.
 // It supports not only the types for BaseTextInputType but also type=number.
@@ -50,7 +51,7 @@
 
     virtual HTMLElement* containerElement() const OVERRIDE;
     virtual HTMLElement* innerBlockElement() const OVERRIDE;
-    virtual HTMLElement* innerTextElement() const OVERRIDE;
+    virtual TextControlInnerTextElement* innerTextElement() const OVERRIDE;
     virtual HTMLElement* innerSpinButtonElement() const OVERRIDE;
 #if ENABLE(INPUT_SPEECH)
     virtual HTMLElement* speechButtonElement() const OVERRIDE;
@@ -102,7 +103,7 @@
 
     RefPtr<HTMLElement> m_container;
     RefPtr<HTMLElement> m_innerBlock;
-    RefPtr<HTMLElement> m_innerText;
+    RefPtr<TextControlInnerTextElement> m_innerText;
     RefPtr<HTMLElement> m_placeholder;
     RefPtr<SpinButtonElement> m_innerSpinButton;
 #if ENABLE(INPUT_SPEECH)

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (157693 => 157694)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -117,6 +117,11 @@
     return new RenderTextControlInnerBlock(*this);
 }
 
+RenderTextControlInnerBlock* TextControlInnerTextElement::renderer() const
+{
+    return toRenderTextControlInnerBlock(HTMLDivElement::renderer());
+}
+
 PassRefPtr<RenderStyle> TextControlInnerTextElement::customStyleForRenderer()
 {
     RenderTextControl* parentRenderer = toRenderTextControl(shadowHost()->renderer());

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (157693 => 157694)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -33,6 +33,7 @@
 
 namespace WebCore {
 
+class RenderTextControlInnerBlock;
 class SpeechInput;
 
 class TextControlInnerContainer FINAL : public HTMLDivElement {
@@ -61,13 +62,20 @@
 
     virtual void defaultEventHandler(Event*) OVERRIDE;
 
+    RenderTextControlInnerBlock* renderer() const;
+
 private:
     TextControlInnerTextElement(Document&);
     virtual RenderElement* createRenderer(RenderStyle&) OVERRIDE;
     virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
     virtual bool isMouseFocusable() const OVERRIDE { return false; }
+    virtual bool isTextControlInnerTextElement() const OVERRIDE { return true; }
 };
 
+inline bool isTextControlInnerTextElement(const HTMLElement& element) { return element.isTextControlInnerTextElement(); }
+inline bool isTextControlInnerTextElement(const Node& node) { return node.isHTMLElement() && isTextControlInnerTextElement(toHTMLElement(node)); }
+NODE_TYPE_CASTS(TextControlInnerTextElement)
+
 class SearchFieldResultsButtonElement FINAL : public HTMLDivElement {
 public:
     static PassRefPtr<SearchFieldResultsButtonElement> create(Document&);

Modified: trunk/Source/WebCore/rendering/RenderObject.h (157693 => 157694)


--- trunk/Source/WebCore/rendering/RenderObject.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -348,6 +348,7 @@
     virtual bool isTextControl() const { return false; }
     virtual bool isTextArea() const { return false; }
     virtual bool isTextField() const { return false; }
+    virtual bool isTextControlInnerBlock() const { return false; }
     virtual bool isVideo() const { return false; }
     virtual bool isWidget() const { return false; }
     virtual bool isCanvas() const { return false; }

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (157693 => 157694)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -25,9 +25,11 @@
 #include "HTMLTextFormControlElement.h"
 #include "HitTestResult.h"
 #include "RenderText.h"
+#include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
 #include "ScrollbarTheme.h"
 #include "StyleInheritedData.h"
+#include "TextControlInnerElements.h"
 #include "TextIterator.h"
 #include "VisiblePosition.h"
 #include <wtf/unicode/CharacterNames.h>
@@ -50,7 +52,7 @@
     return toHTMLTextFormControlElement(nodeForNonAnonymous());
 }
 
-HTMLElement* RenderTextControl::innerTextElement() const
+TextControlInnerTextElement* RenderTextControl::innerTextElement() const
 {
     return textFormControlElement().innerTextElement();
 }
@@ -58,10 +60,10 @@
 void RenderTextControl::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
     RenderBlockFlow::styleDidChange(diff, oldStyle);
-    Element* innerText = innerTextElement();
+    TextControlInnerTextElement* innerText = innerTextElement();
     if (!innerText)
         return;
-    RenderBlock* innerTextRenderer = toRenderBlock(innerText->renderer());
+    RenderTextControlInnerBlock* innerTextRenderer = innerText->renderer();
     if (innerTextRenderer) {
         // We may have set the width and the height in the old style in layout().
         // Reset them now to avoid getting a spurious layout hint.
@@ -101,7 +103,7 @@
 
 int RenderTextControl::textBlockLogicalWidth() const
 {
-    Element* innerText = innerTextElement();
+    TextControlInnerTextElement* innerText = innerTextElement();
     ASSERT(innerText);
 
     LayoutUnit unitWidth = logicalWidth() - borderAndPaddingLogicalWidth();
@@ -113,7 +115,7 @@
 
 void RenderTextControl::updateFromElement()
 {
-    Element* innerText = innerTextElement();
+    TextControlInnerTextElement* innerText = innerTextElement();
     if (innerText && innerText->renderer())
         updateUserModifyProperty(textFormControlElement(), innerText->renderer()->style());
 }
@@ -126,7 +128,7 @@
 
 void RenderTextControl::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
 {
-    HTMLElement* innerText = innerTextElement();
+    TextControlInnerTextElement* innerText = innerTextElement();
     ASSERT(innerText);
     if (RenderBox* innerTextBox = innerText->renderBox()) {
         LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight();
@@ -143,7 +145,7 @@
 
 void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset)
 {
-    HTMLElement* innerText = innerTextElement();
+    TextControlInnerTextElement* innerText = innerTextElement();
     if (!innerText->renderer())
         return;
 

Modified: trunk/Source/WebCore/rendering/RenderTextControl.h (157693 => 157694)


--- trunk/Source/WebCore/rendering/RenderTextControl.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/rendering/RenderTextControl.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -27,6 +27,7 @@
 
 namespace WebCore {
 
+class TextControlInnerTextElement;
 class HTMLTextFormControlElement;
 
 class RenderTextControl : public RenderBlockFlow {
@@ -40,7 +41,7 @@
     explicit RenderTextControl(HTMLTextFormControlElement&);
 
     // This convenience function should not be made public because innerTextElement may outlive the render tree.
-    HTMLElement* innerTextElement() const;
+    TextControlInnerTextElement* innerTextElement() const;
 
     int scrollbarThickness() const;
     void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const;

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (157693 => 157694)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2013-10-20 04:55:32 UTC (rev 157694)
@@ -121,7 +121,7 @@
     // and type=search if the text height is taller than the contentHeight()
     // because of compability.
 
-    RenderBox* innerTextRenderer = innerTextElement()->renderBox();
+    RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer();
     RenderBox* innerBlockRenderer = innerBlockElement() ? innerBlockElement()->renderBox() : 0;
 
     // To ensure consistency between layouts, we need to reset any conditionally overriden height.
@@ -261,7 +261,7 @@
         containerRenderer->style()->setHeight(Length());
         containerRenderer->style()->setWidth(Length());
     }
-    RenderObject* innerTextRenderer = innerTextElement()->renderer();
+    RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer();
     if (innerTextRenderer && diff == StyleDifferenceLayout)
         innerTextRenderer->setNeedsLayout(MarkContainingBlockChain);
     if (HTMLElement* placeholder = inputElement().placeholderElement())
@@ -399,7 +399,7 @@
 
 void RenderTextControlSingleLine::autoscroll(const IntPoint& position)
 {
-    RenderBox* renderer = innerTextElement()->renderBox();
+    RenderTextControlInnerBlock* renderer = innerTextElement()->renderer();
     if (!renderer)
         return;
     RenderLayer* layer = renderer->layer();
@@ -449,7 +449,7 @@
 
 bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
 {
-    RenderBox* renderer = innerTextElement()->renderBox();
+    RenderTextControlInnerBlock* renderer = innerTextElement()->renderer();
     if (!renderer)
         return false;
     RenderLayer* layer = renderer->layer();
@@ -460,7 +460,7 @@
 
 bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
 {
-    RenderLayer* layer = innerTextElement()->renderBox()->layer();
+    RenderLayer* layer = innerTextElement()->renderer()->layer();
     if (layer && layer->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier))
         return true;
     return RenderBlockFlow::logicalScroll(direction, granularity, multiplier, stopElement);

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (157693 => 157694)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2013-10-20 04:12:16 UTC (rev 157693)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2013-10-20 04:55:32 UTC (rev 157694)
@@ -109,7 +109,7 @@
 
 // ----------------------------
 
-class RenderTextControlInnerBlock : public RenderBlockFlow {
+class RenderTextControlInnerBlock FINAL : public RenderBlockFlow {
 public:
     RenderTextControlInnerBlock(Element& element)
         : RenderBlockFlow(element)
@@ -118,8 +118,18 @@
 
 private:
     virtual bool hasLineIfEmpty() const OVERRIDE { return true; }
+    virtual bool isTextControlInnerBlock() const OVERRIDE { return true; }
 };
 
+inline RenderTextControlInnerBlock* toRenderTextControlInnerBlock(RenderObject* object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isTextControlInnerBlock());
+    return static_cast<RenderTextControlInnerBlock*>(object);
 }
 
+// This will catch anyone doing an unnecessary cast.
+void toRenderTextControlInnerBlock(const RenderTextControlInnerBlock*);
+
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to