Index: Source/core/rendering/RenderFileUploadControl.cpp |
diff --git a/Source/core/rendering/RenderFileUploadControl.cpp b/Source/core/rendering/RenderFileUploadControl.cpp |
index 4b2b657bb54fdffb6e8df7d3e0901a4d2e9be5c5..eb8e1b317d8e23a331dafc149aebbd244c803668 100644 |
--- a/Source/core/rendering/RenderFileUploadControl.cpp |
+++ b/Source/core/rendering/RenderFileUploadControl.cpp |
@@ -51,8 +51,8 @@ const int iconFilenameSpacing = 2; |
const int defaultWidthNumChars = 34; |
const int buttonShadowHeight = 2; |
-RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement* input) |
- : RenderBlock(input) |
+RenderFileUploadControl::RenderFileUploadControl(Handle<HTMLInputElement> input) |
+ : RenderBlock(input.raw()) |
, m_canReceiveDroppedFiles(input->canReceiveDroppedFiles()) |
{ |
} |
@@ -68,10 +68,10 @@ bool RenderFileUploadControl::canBeReplacedWithInlineRunIn() const |
void RenderFileUploadControl::updateFromElement() |
{ |
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
+ Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node())); |
ASSERT(input->isFileUpload()); |
- if (HTMLInputElement* button = uploadButton()) { |
+ if (Handle<HTMLInputElement> button = uploadButton()) { |
bool newCanReceiveDroppedFilesState = input->canReceiveDroppedFiles(); |
if (m_canReceiveDroppedFiles != newCanReceiveDroppedFilesState) { |
m_canReceiveDroppedFiles = newCanReceiveDroppedFilesState; |
@@ -87,14 +87,14 @@ void RenderFileUploadControl::updateFromElement() |
repaint(); |
} |
-static int nodeWidth(Node* node) |
+static int nodeWidth(Handle<Node> node) |
{ |
return (node && node->renderBox()) ? node->renderBox()->pixelSnappedWidth() : 0; |
} |
int RenderFileUploadControl::maxFilenameWidth() const |
{ |
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
+ Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node())); |
return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton()) - afterButtonSpacing |
- (input->icon() ? iconWidth + iconFilenameSpacing : 0)); |
} |
@@ -123,11 +123,11 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin |
// Determine where the filename should be placed |
LayoutUnit contentLeft = paintOffset.x() + borderLeft() + paddingLeft(); |
- HTMLInputElement* button = uploadButton(); |
+ Handle<HTMLInputElement> button = uploadButton(); |
if (!button) |
return; |
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
+ Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node())); |
LayoutUnit buttonWidth = nodeWidth(button); |
LayoutUnit buttonAndIconWidth = buttonWidth + afterButtonSpacing |
+ (input->icon() ? iconWidth + iconFilenameSpacing : 0); |
@@ -181,7 +181,7 @@ void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogic |
const String label = theme()->fileListDefaultLabel(node()->toInputElement()->multiple()); |
float defaultLabelWidth = font.width(constructTextRun(renderer, font, label, style(), TextRun::AllowTrailingExpansion)); |
- if (HTMLInputElement* button = uploadButton()) |
+ if (Handle<HTMLInputElement> button = uploadButton()) |
if (RenderObject* buttonRenderer = button->renderer()) |
defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + afterButtonSpacing; |
maxLogicalWidth = static_cast<int>(ceilf(max(minDefaultLabelWidth, defaultLabelWidth))); |
@@ -224,19 +224,19 @@ VisiblePosition RenderFileUploadControl::positionForPoint(const LayoutPoint&) |
return VisiblePosition(); |
} |
-HTMLInputElement* RenderFileUploadControl::uploadButton() const |
+Result<HTMLInputElement> RenderFileUploadControl::uploadButton() const |
{ |
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
+ Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node())); |
ASSERT(input->shadow()); |
Node* buttonNode = input->shadow()->oldestShadowRoot()->firstChild(); |
- return buttonNode && buttonNode->isHTMLElement() && buttonNode->hasTagName(inputTag) ? static_cast<HTMLInputElement*>(buttonNode) : 0; |
+ return buttonNode && buttonNode->isHTMLElement() && buttonNode->hasTagName(inputTag) ? Handle<HTMLInputElement>(static_cast<HTMLInputElement*>(buttonNode)) : nullptr; |
} |
String RenderFileUploadControl::buttonValue() |
{ |
- if (HTMLInputElement* button = uploadButton()) |
+ if (Handle<HTMLInputElement> button = uploadButton()) |
return button->value(); |
return String(); |
@@ -244,7 +244,7 @@ String RenderFileUploadControl::buttonValue() |
String RenderFileUploadControl::fileTextValue() const |
{ |
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
+ Handle<HTMLInputElement> input(static_cast<HTMLInputElement*>(node())); |
ASSERT(input->files()); |
return theme()->fileListNameForWidth(input->files(), style()->font(), maxFilenameWidth(), input->multiple()); |
} |