Have is<>(T*) function do a null check on the pointer argument
[WebKit-https.git] / Source / WebCore / rendering / RenderFileUploadControl.cpp
index 47e470c..4b3cb8b 100644 (file)
@@ -59,7 +59,7 @@ const int defaultWidthNumChars = 38;
 const int buttonShadowHeight = 2;
 
 RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement& input, PassRef<RenderStyle> style)
-    : RenderBlockFlow(input, std::move(style))
+    : RenderBlockFlow(input, WTF::move(style))
     , m_canReceiveDroppedFiles(input.canReceiveDroppedFiles())
 {
 }
@@ -70,12 +70,7 @@ RenderFileUploadControl::~RenderFileUploadControl()
 
 HTMLInputElement& RenderFileUploadControl::inputElement() const
 {
-    return toHTMLInputElement(nodeForNonAnonymous());
-}
-
-bool RenderFileUploadControl::canBeReplacedWithInlineRunIn() const
-{
-    return false;
+    return downcast<HTMLInputElement>(nodeForNonAnonymous());
 }
 
 void RenderFileUploadControl::updateFromElement()
@@ -100,13 +95,13 @@ void RenderFileUploadControl::updateFromElement()
 
 static int nodeWidth(Node* node)
 {
-    return (node && node->renderBox()) ? node->renderBox()->pixelSnappedWidth() : 0;
+    return (node && node->renderBox()) ? node->renderBox()->pixelSnappedSize().width() : 0;
 }
 
 #if PLATFORM(IOS)
 static int nodeHeight(Node* node)
 {
-    return (node && node->renderBox()) ? node->renderBox()->pixelSnappedHeight() : 0;
+    return (node && node->renderBox()) ? node->renderBox()->pixelSnappedSize().height() : 0;
 }
 #endif
 
@@ -115,7 +110,7 @@ int RenderFileUploadControl::maxFilenameWidth() const
 #if PLATFORM(IOS)
     int iconWidth = nodeHeight(uploadButton());
 #endif
-    return std::max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton()) - afterButtonSpacing
+    return std::max(0, contentBoxRect().pixelSnappedSize().width() - nodeWidth(uploadButton()) - afterButtonSpacing
         - (inputElement().icon() ? iconWidth + iconFilenameSpacing : 0));
 }
 
@@ -187,7 +182,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
                 // Draw the file icon and decorations.
                 IntRect iconRect(iconX, iconY, iconWidth, iconHeight);
                 RenderTheme::FileUploadDecorations decorationsType = inputElement().files()->length() == 1 ? RenderTheme::SingleFile : RenderTheme::MultipleFiles;
-                theme()->paintFileUploadIconDecorations(this, buttonRenderer, paintInfo, iconRect, inputElement().icon(), decorationsType);
+                theme().paintFileUploadIconDecorations(*this, *buttonRenderer, paintInfo, iconRect, inputElement().icon(), decorationsType);
             }
 #else
             // Draw the file icon
@@ -244,14 +239,14 @@ void RenderFileUploadControl::computePreferredLogicalWidths()
         m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style().maxWidth().value()));
     }
 
-    int toAdd = borderAndPaddingWidth();
+    int toAdd = horizontalBorderAndPaddingExtent();
     m_minPreferredLogicalWidth += toAdd;
     m_maxPreferredLogicalWidth += toAdd;
 
     setPreferredLogicalWidthsDirty(false);
 }
 
-VisiblePosition RenderFileUploadControl::positionForPoint(const LayoutPoint&)
+VisiblePosition RenderFileUploadControl::positionForPoint(const LayoutPoint&, const RenderRegion*)
 {
     return VisiblePosition();
 }
@@ -260,7 +255,7 @@ HTMLInputElement* RenderFileUploadControl::uploadButton() const
 {
     ASSERT(inputElement().shadowRoot());
     Node* buttonNode = inputElement().shadowRoot()->firstChild();
-    return buttonNode && buttonNode->isHTMLElement() && isHTMLInputElement(buttonNode) ? toHTMLInputElement(buttonNode) : 0;
+    return is<HTMLInputElement>(buttonNode) ? downcast<HTMLInputElement>(buttonNode) : nullptr;
 }
 
 String RenderFileUploadControl::buttonValue()