Commit d75fed72 authored by weinig@apple.com's avatar weinig@apple.com
Browse files

WebCore:

2008-10-24  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21759
        Layering violation: FileChooser should not depend on Document/Frame/Page

        Move file choosing into WebKit ChromeClient.

        * loader/EmptyClients.h:
        (WebCore::EmptyChromeClient::runOpenPanel):
        * page/Chrome.cpp:
        (WebCore::Chrome::runOpenPanel):
        * page/Chrome.h:
        * page/ChromeClient.h:
        * page/mac/ChromeMac.mm:
        * platform/FileChooser.h:
        * platform/mac/FileChooserMac.mm:
        * platform/qt/FileChooserQt.cpp:
        * platform/win/FileChooserWin.cpp:
        * platform/wx/TemporaryLinkStubs.cpp:
        * rendering/RenderFileUploadControl.cpp:
        (WebCore::RenderFileUploadControl::click):

WebKit/gtk:

2008-10-24  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21759
        Layering violation: FileChooser should not depend on Document/Frame/Page

        * WebCoreSupport/ChromeClientGtk.cpp:
        (WebKit::ChromeClient::runOpenPanel):
        * WebCoreSupport/ChromeClientGtk.h:

WebKit/mac:

2008-10-24  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21759
        Layering violation: FileChooser should not depend on Document/Frame/Page

        * WebCoreSupport/WebChromeClient.h:
        * WebCoreSupport/WebChromeClient.mm:
        (WebChromeClient::runOpenPanel):

WebKit/qt:

2008-10-24  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21759
        Layering violation: FileChooser should not depend on Document/Frame/Page

        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::runOpenPanel):
        * WebCoreSupport/ChromeClientQt.h:

WebKit/win:

2008-10-24  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21759
        Layering violation: FileChooser should not depend on Document/Frame/Page

        * WebCoreSupport/WebChromeClient.cpp:
        (WebChromeClient::runOpenPanel):
        * WebCoreSupport/WebChromeClient.h:

WebKit/wx:

2008-10-24  Sam Weinig  <sam@webkit.org>

        Reviewed by Dan Bernstein.

        Fix https://bugs.webkit.org/show_bug.cgi?id=21759
        Layering violation: FileChooser should not depend on Document/Frame/Page

        * WebKitSupport/ChromeClientWx.cpp:
        (WebCore::ChromeClientWx::runOpenPanel):
        * WebKitSupport/ChromeClientWx.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent abe12338
2008-10-24 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein.
Fix https://bugs.webkit.org/show_bug.cgi?id=21759
Layering violation: FileChooser should not depend on Document/Frame/Page
Move file choosing into WebKit ChromeClient.
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::runOpenPanel):
* page/Chrome.cpp:
(WebCore::Chrome::runOpenPanel):
* page/Chrome.h:
* page/ChromeClient.h:
* page/mac/ChromeMac.mm:
* platform/FileChooser.h:
* platform/mac/FileChooserMac.mm:
* platform/qt/FileChooserQt.cpp:
* platform/win/FileChooserWin.cpp:
* platform/wx/TemporaryLinkStubs.cpp:
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::click):
2008-10-24 Kevin Ollivier <kevino@theolliviers.com>
 
wx build fix - add newIconForFiles stub.
......
......@@ -126,6 +126,8 @@ public:
virtual void print(Frame*) { }
virtual void exceededDatabaseQuota(Frame*, const String&) { }
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) { }
};
class EmptyFrameLoaderClient : public FrameLoaderClient {
......
......@@ -24,6 +24,7 @@
#include "ChromeClient.h"
#include "DNS.h"
#include "Document.h"
#include "FileChooser.h"
#include "FileList.h"
#include "FloatRect.h"
#include "Frame.h"
......@@ -395,6 +396,10 @@ void Chrome::enableSuddenTermination()
m_client->enableSuddenTermination();
}
void Chrome::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
{
m_client->runOpenPanel(frame, fileChooser);
}
// --------
#if ENABLE(DASHBOARD_SUPPORT)
......
......@@ -35,13 +35,14 @@ namespace WebCore {
class ChromeClient;
class ContextMenu;
class FileChooser;
class FloatRect;
class Frame;
class HitTestResult;
class IntRect;
class Page;
class String;
struct FrameLoadRequest;
struct WindowFeatures;
......@@ -100,7 +101,7 @@ namespace WebCore {
void runJavaScriptAlert(Frame*, const String&);
bool runJavaScriptConfirm(Frame*, const String&);
bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
void setStatusbarText(Frame*, const String&);
bool shouldInterruptJavaScript();
......@@ -115,6 +116,8 @@ namespace WebCore {
void enableSuddenTermination();
void disableSuddenTermination();
void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
#if PLATFORM(MAC)
void focusNSView(NSView*);
#endif
......
......@@ -103,7 +103,6 @@ namespace WebCore {
virtual void runJavaScriptAlert(Frame*, const String&) = 0;
virtual bool runJavaScriptConfirm(Frame*, const String&) = 0;
virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0;
virtual void setStatusbarText(const String&) = 0;
virtual bool shouldInterruptJavaScript() = 0;
virtual bool tabsToLinks() const = 0;
......@@ -147,9 +146,9 @@ namespace WebCore {
float value, float proportion, ScrollbarControlPartMask);
virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&);
#if PLATFORM(MAC)
virtual void runOpenPanel(PassRefPtr<FileChooser>);
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
#if PLATFORM(MAC)
virtual KeyboardUIMode keyboardUIMode() { return KeyboardAccessDefault; }
virtual NSResponder *firstResponder() { return 0; }
......
......@@ -22,7 +22,6 @@
#import "BlockExceptions.h"
#import "ChromeClient.h"
#import "FileChooser.h"
namespace WebCore {
......@@ -49,8 +48,4 @@ void Chrome::focusNSView(NSView* view)
END_BLOCK_OBJC_EXCEPTIONS;
}
void ChromeClient::runOpenPanel(PassRefPtr<FileChooser>)
{
}
} // namespace WebCore
......@@ -35,7 +35,6 @@
namespace WebCore {
class Document;
class Font;
class Icon;
......@@ -54,13 +53,6 @@ public:
void disconnectClient() { m_client = 0; }
bool disconnected() { return !m_client; }
// FIXME: It's a layering violation that we pass a Document in here.
// The platform directory is underneath the DOM, so it can't use the DOM.
// Because of UI delegates, it's not clear that the FileChooser class
// belongs in the platform layer at all. It might need to go alongside
// the Chrome class instead.
void openFileChooser(Document*);
const Vector<String>& filenames() const { return m_filenames; }
String basenameForWidth(const Font&, int width) const;
......@@ -83,6 +75,6 @@ private:
RefPtr<Icon> m_icon;
};
}
} // namespace WebCore
#endif
#endif // FileChooser_h
......@@ -28,10 +28,7 @@
#include "FileChooser.h"
#include "CString.h"
#include "Document.h"
#include "FileSystem.h"
#include "FrameView.h"
#include "HostWindow.h"
#include "Icon.h"
#include "LocalizedStrings.h"
#include "StringTruncator.h"
......@@ -53,30 +50,6 @@ static bool stringByAdoptingFileSystemRepresentation(gchar* systemFilename, Stri
return true;
}
void FileChooser::openFileChooser(Document* document)
{
FrameView* view = document->view();
if (!view)
return;
GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view->hostWindow()->platformWindow()))),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
// We need this protector because otherwise we can be deleted if the file upload control is detached while
// we're within the gtk_run_dialog call.
RefPtr<FileChooser> protector(this);
String result;
const bool acceptedDialog = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
if (acceptedDialog && stringByAdoptingFileSystemRepresentation(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)), result))
chooseFile(result);
gtk_widget_destroy(dialog);
}
String FileChooser::basenameForWidth(const Font& font, int width) const
{
if (width <= 0)
......
......@@ -30,28 +30,12 @@
#import "config.h"
#import "FileChooser.h"
#import "ChromeClient.h"
#import "Document.h"
#import "Frame.h"
#import "Icon.h"
#import "LocalizedStrings.h"
#import "Page.h"
#import "SimpleFontData.h"
#import "StringTruncator.h"
namespace WebCore {
void FileChooser::openFileChooser(Document* document)
{
Frame* frame = document->frame();
if (!frame)
return;
Page* page = frame->page();
if (!page)
return;
page->chrome()->client()->runOpenPanel(this);
}
String FileChooser::basenameForWidth(const Font& font, int width) const
{
if (width <= 0)
......
......@@ -21,32 +21,10 @@
#include "config.h"
#include "FileChooser.h"
#include "Document.h"
#include "Frame.h"
#include "FrameLoaderClientQt.h"
#include "Icon.h"
#include "Page.h"
#include <QFontMetrics>
namespace WebCore {
void FileChooser::openFileChooser(Document* doc)
{
Page *page = doc->page();
Frame *frame = doc->frame();
if (!page || !frame)
return;
FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(frame->loader()->client());
if (!fl)
return;
QString f = fl->chooseFile(m_filenames[0]);
if (!f.isEmpty())
chooseFile(f);
}
String FileChooser::basenameForWidth(const Font& f, int width) const
{
QFontMetrics fm(f.font());
......
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -26,14 +26,7 @@
#include "config.h"
#include "FileChooser.h"
#include "Document.h"
#include "FrameView.h"
#include "HostWindow.h"
#include "Icon.h"
#include "LocalizedStrings.h"
#include "RenderObject.h"
#include "RenderThemeWin.h"
#include "RenderView.h"
#include "StringTruncator.h"
#include <shlwapi.h>
#include <tchar.h>
......@@ -41,39 +34,6 @@
namespace WebCore {
void FileChooser::openFileChooser(Document* document)
{
FrameView* view = document->view();
if (!view)
return;
TCHAR fileBuf[MAX_PATH];
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
// Need to zero out the first char of fileBuf so GetOpenFileName doesn't think it's an initialization string
fileBuf[0] = '\0';
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = view->hostWindow()->platformWindow();
String allFiles = allFilesText();
allFiles.append(TEXT("\0*.*\0\0"), 6);
ofn.lpstrFilter = allFiles.charactersWithNullTermination();
ofn.lpstrFile = fileBuf;
ofn.nMaxFile = sizeof(fileBuf);
String dialogTitle = uploadFileText();
ofn.lpstrTitle = dialogTitle.charactersWithNullTermination();
ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
// We need this protector because otherwise we can be deleted if the file upload control is detached while
// we're within the GetOpenFileName call.
RefPtr<FileChooser> protector(this);
if (GetOpenFileName(&ofn))
chooseFile(String(fileBuf));
}
String FileChooser::basenameForWidth(const Font& font, int width) const
{
if (width <= 0)
......@@ -92,4 +52,4 @@ String FileChooser::basenameForWidth(const Font& font, int width) const
return StringTruncator::centerTruncate(string, width, font, false);
}
}
\ No newline at end of file
} // namespace WebCore
......@@ -129,7 +129,6 @@ void Image::drawPattern(GraphicsContext*, const FloatRect& srcRect, const Affine
ScrollbarTheme* ScrollbarTheme::nativeTheme() { notImplemented(); static ScrollbarTheme theme; return &theme; }
void FileChooser::openFileChooser(Document*) { notImplemented(); }
String FileChooser::basenameForWidth(const Font&, int width) const { notImplemented(); return String(); }
Icon::~Icon() { }
......
......@@ -28,6 +28,7 @@
#include "HTMLNames.h"
#include "Icon.h"
#include "LocalizedStrings.h"
#include "Page.h"
#include "RenderButton.h"
#include "RenderText.h"
#include "RenderTheme.h"
......@@ -103,7 +104,13 @@ bool RenderFileUploadControl::allowsMultipleFiles()
void RenderFileUploadControl::click()
{
m_fileChooser->openFileChooser(node()->document());
Frame* frame = node()->document()->frame();
if (!frame)
return;
Page* page = frame->page();
if (!page)
return;
page->chrome()->runOpenPanel(frame, m_fileChooser);
}
void RenderFileUploadControl::updateFromElement()
......
2008-10-24 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein.
Fix https://bugs.webkit.org/show_bug.cgi?id=21759
Layering violation: FileChooser should not depend on Document/Frame/Page
* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::ChromeClient::runOpenPanel):
* WebCoreSupport/ChromeClientGtk.h:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Stub out new InspectorClient methods.
......
......@@ -21,6 +21,7 @@
#include "config.h"
#include "ChromeClientGtk.h"
#include "FileSystem.h"
#include "FloatRect.h"
#include "IntRect.h"
#include "PlatformString.h"
......@@ -372,4 +373,26 @@ void ChromeClient::exceededDatabaseQuota(Frame* frame, const String&)
#endif
}
void ChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser)
{
// FIXME: Support multiple files.
RefPtr<FileChooser> fileChooser = prpFileChooser;
GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(platformWindow()))),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
if (filename)
fileChooser->chooseFile(filenameToString(filename));
g_free(filename);
}
gtk_widget_destroy(dialog);
}
}
......@@ -98,6 +98,8 @@ namespace WebKit {
virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String&);
virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
private:
WebKitWebView* m_webView;
WebCore::KURL m_hoveredLinkURL;
......
2008-10-24 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein.
Fix https://bugs.webkit.org/show_bug.cgi?id=21759
Layering violation: FileChooser should not depend on Document/Frame/Page
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::runOpenPanel):
2008-10-24 Anders Carlsson <andersca@apple.com>
Fix Tiger build.
......
......@@ -111,7 +111,7 @@ public:
virtual void dashboardRegionsChanged();
#endif
virtual void runOpenPanel(PassRefPtr<WebCore::FileChooser>);
virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WebCore::AtomicString& type,
const WebCore::FloatRect& lineRect);
......
......@@ -544,7 +544,7 @@ void WebChromeClient::paintCustomHighlight(Node* node, const AtomicString& type,
END_BLOCK_OBJC_EXCEPTIONS;
}
void WebChromeClient::runOpenPanel(PassRefPtr<FileChooser> chooser)
void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
BOOL allowMultipleFiles = chooser->allowsMultipleFiles();
......
2008-10-24 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein.
Fix https://bugs.webkit.org/show_bug.cgi?id=21759
Layering violation: FileChooser should not depend on Document/Frame/Page
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::runOpenPanel):
* WebCoreSupport/ChromeClientQt.h:
2008-10-24 Timothy Hatcher <timothy@apple.com>
Stub out new InspectorClient methods.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment