summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderFileUploadControl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/RenderFileUploadControl.cpp')
-rw-r--r--WebCore/rendering/RenderFileUploadControl.cpp59
1 files changed, 34 insertions, 25 deletions
diff --git a/WebCore/rendering/RenderFileUploadControl.cpp b/WebCore/rendering/RenderFileUploadControl.cpp
index 59cbacf..f31ca20 100644
--- a/WebCore/rendering/RenderFileUploadControl.cpp
+++ b/WebCore/rendering/RenderFileUploadControl.cpp
@@ -28,6 +28,7 @@
#include "GraphicsContext.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
+#include "ShadowElement.h"
#include "Icon.h"
#include "LocalizedStrings.h"
#include "Page.h"
@@ -50,20 +51,8 @@ const int iconFilenameSpacing = 2;
const int defaultWidthNumChars = 34;
const int buttonShadowHeight = 2;
-class HTMLFileUploadInnerButtonElement : public HTMLInputElement {
-public:
- HTMLFileUploadInnerButtonElement(Document*, Node* shadowParent);
-
- virtual bool isShadowNode() const { return true; }
- virtual Node* shadowParentNode() { return m_shadowParent; }
-
-private:
- Node* m_shadowParent;
-};
-
RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement* input)
: RenderBlock(input)
- , m_button(0)
{
FileList* list = input->files();
Vector<String> filenames;
@@ -105,24 +94,49 @@ void RenderFileUploadControl::valueChanged()
bool RenderFileUploadControl::allowsMultipleFiles()
{
+#if ENABLE(DIRECTORY_UPLOAD)
+ if (allowsDirectoryUpload())
+ return true;
+#endif
+
HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
return !input->getAttribute(multipleAttr).isNull();
}
+#if ENABLE(DIRECTORY_UPLOAD)
+bool RenderFileUploadControl::allowsDirectoryUpload()
+{
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+ return !input->getAttribute(webkitdirectoryAttr).isNull();
+}
+#endif
+
String RenderFileUploadControl::acceptTypes()
{
return static_cast<HTMLInputElement*>(node())->accept();
}
+void RenderFileUploadControl::chooseIconForFiles(FileChooser* chooser, const Vector<String>& filenames)
+{
+ if (Chrome* chromePointer = chrome())
+ chromePointer->chooseIconForFiles(filenames, chooser);
+}
+
void RenderFileUploadControl::click()
{
+ if (Chrome* chromePointer = chrome())
+ chromePointer->runOpenPanel(node()->document()->frame(), m_fileChooser);
+}
+
+Chrome* RenderFileUploadControl::chrome() const
+{
Frame* frame = node()->document()->frame();
if (!frame)
- return;
+ return 0;
Page* page = frame->page();
if (!page)
- return;
- page->chrome()->runOpenPanel(frame, m_fileChooser);
+ return 0;
+ return page->chrome();
}
void RenderFileUploadControl::updateFromElement()
@@ -131,7 +145,7 @@ void RenderFileUploadControl::updateFromElement()
ASSERT(inputElement->inputType() == HTMLInputElement::FILE);
if (!m_button) {
- m_button = new HTMLFileUploadInnerButtonElement(document(), inputElement);
+ m_button = ShadowInputElement::create(inputElement);
m_button->setInputType("button");
m_button->setValue(fileButtonChooseFileLabel());
RefPtr<RenderStyle> buttonStyle = createButtonStyle(style());
@@ -140,7 +154,7 @@ void RenderFileUploadControl::updateFromElement()
renderer->setStyle(buttonStyle.release());
renderer->updateFromElement();
m_button->setAttached();
- m_button->setInDocument(true);
+ m_button->setInDocument();
addChild(renderer);
}
@@ -183,6 +197,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, int tx, int ty)
{
if (style()->visibility() != VISIBLE)
return;
+ ASSERT(m_fileChooser);
// Push a clip.
if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseChildBlockBackgrounds) {
@@ -215,7 +230,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, int tx, int ty)
+ buttonRenderer->marginTop() + buttonRenderer->borderTop() + buttonRenderer->paddingTop()
+ buttonRenderer->baselinePosition(true, false);
- paintInfo.context->setFillColor(style()->color(), style()->colorSpace());
+ paintInfo.context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
// Draw the filename
paintInfo.context->drawBidiText(style()->font(), textRun, IntPoint(textX, textY));
@@ -272,7 +287,7 @@ void RenderFileUploadControl::calcPrefWidths()
m_minPrefWidth = min(m_minPrefWidth, calcContentBoxWidth(style()->maxWidth().value()));
}
- int toAdd = paddingLeft() + paddingRight() + borderLeft() + borderRight();
+ int toAdd = borderAndPaddingWidth();
m_minPrefWidth += toAdd;
m_maxPrefWidth += toAdd;
@@ -300,10 +315,4 @@ String RenderFileUploadControl::fileTextValue() const
return m_fileChooser->basenameForWidth(style()->font(), maxFilenameWidth());
}
-HTMLFileUploadInnerButtonElement::HTMLFileUploadInnerButtonElement(Document* doc, Node* shadowParent)
- : HTMLInputElement(inputTag, doc)
- , m_shadowParent(shadowParent)
-{
-}
-
} // namespace WebCore