summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/chromium
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/chromium')
-rw-r--r--WebCore/platform/chromium/ChromiumBridge.h42
-rw-r--r--WebCore/platform/chromium/ChromiumDataObject.cpp215
-rw-r--r--WebCore/platform/chromium/ChromiumDataObject.h127
-rw-r--r--WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp249
-rw-r--r--WebCore/platform/chromium/ChromiumDataObjectLegacy.h119
-rw-r--r--WebCore/platform/chromium/ClipboardChromium.cpp302
-rw-r--r--WebCore/platform/chromium/ClipboardChromium.h3
-rw-r--r--WebCore/platform/chromium/ClipboardChromiumWin.cpp10
-rw-r--r--WebCore/platform/chromium/ClipboardMimeTypes.cpp10
-rw-r--r--WebCore/platform/chromium/ClipboardMimeTypes.h10
-rw-r--r--WebCore/platform/chromium/DragDataChromium.cpp44
-rw-r--r--WebCore/platform/chromium/GeolocationServiceChromium.cpp4
-rw-r--r--WebCore/platform/chromium/LanguageChromium.cpp (renamed from WebCore/platform/chromium/Language.cpp)2
-rw-r--r--WebCore/platform/chromium/PasteboardChromium.cpp3
-rw-r--r--WebCore/platform/chromium/PopupMenuChromium.cpp16
-rw-r--r--WebCore/platform/chromium/ReadableDataObject.cpp67
-rw-r--r--WebCore/platform/chromium/ReadableDataObject.h22
-rw-r--r--WebCore/platform/chromium/ScrollbarThemeChromium.cpp2
-rw-r--r--WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp188
-rw-r--r--WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm6
-rw-r--r--WebCore/platform/chromium/ThemeChromiumMac.mm2
-rw-r--r--WebCore/platform/chromium/WritableDataObject.cpp82
-rw-r--r--WebCore/platform/chromium/WritableDataObject.h37
23 files changed, 898 insertions, 664 deletions
diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h
index 121ec4b..74bad04 100644
--- a/WebCore/platform/chromium/ChromiumBridge.h
+++ b/WebCore/platform/chromium/ChromiumBridge.h
@@ -154,9 +154,10 @@ namespace WebCore {
// Forms --------------------------------------------------------------
static void notifyFormStateChanged(const Document*);
+#if !ENABLE(CLIENT_BASED_GEOLOCATION)
// Geolocation --------------------------------------------------------
static GeolocationServiceBridge* createGeolocationServiceBridge(GeolocationServiceChromium*);
-
+#endif
// Databases ----------------------------------------------------------
// Returns a handle to the DB file and ooptionally a handle to its containing directory
static PlatformFileHandle databaseOpenFile(const String& vfsFleName, int desiredFlags);
@@ -254,6 +255,45 @@ namespace WebCore {
GraphicsContext*, int part, int state, int classicState, const IntRect&);
static void paintProgressBar(
GraphicsContext*, const IntRect& barRect, const IntRect& valueRect, bool determinate, double animatedSeconds);
+#elif OS(LINUX)
+ // The UI part which is being accessed.
+ enum ThemePart {
+ PartScrollbarDownArrow,
+ PartScrollbarLeftArrow,
+ PartScrollbarRightArrow,
+ PartScrollbarUpArrow,
+ PartScrollbarHorizontalThumb,
+ PartScrollbarVerticalThumb,
+ PartScrollbarHoriztonalTrack,
+ PartScrollbarVerticalTrack,
+ };
+
+ // The current state of the associated Part.
+ enum ThemePaintState {
+ StateDisabled,
+ StateHover,
+ StateNormal,
+ StatePressed,
+ };
+
+ struct ScrollbarTrackExtraParams {
+ // The bounds of the entire track, as opposed to the part being painted.
+ int trackX;
+ int trackY;
+ int trackWidth;
+ int trackHeight;
+ };
+
+ union ThemePaintExtraParams {
+ ScrollbarTrackExtraParams scrollbarTrack;
+ };
+
+ // Gets the size of the given theme part. For variable sized items
+ // like vertical scrollbar thumbs, the width will be the required width of
+ // the track while the height will be the minimum height.
+ static IntSize getThemePartSize(ThemePart);
+ // Paint the given the given theme part.
+ static void paintThemePart(GraphicsContext*, ThemePart, ThemePaintState, const IntRect&, const ThemePaintExtraParams*);
#endif
// Trace Event --------------------------------------------------------
diff --git a/WebCore/platform/chromium/ChromiumDataObject.cpp b/WebCore/platform/chromium/ChromiumDataObject.cpp
index 8352669..78b794b 100644
--- a/WebCore/platform/chromium/ChromiumDataObject.cpp
+++ b/WebCore/platform/chromium/ChromiumDataObject.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2010, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,54 +33,187 @@
namespace WebCore {
-void ChromiumDataObject::clear()
+ChromiumDataObject::ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy> data)
+ : RefCounted<ChromiumDataObject>()
+ , m_legacyData(data)
+{
+}
+
+ChromiumDataObject::ChromiumDataObject(PassRefPtr<ReadableDataObject> data)
+ : RefCounted<ChromiumDataObject>()
+ , m_readableData(data)
+{
+}
+
+ChromiumDataObject::ChromiumDataObject(PassRefPtr<WritableDataObject> data)
+ : RefCounted<ChromiumDataObject>()
+ , m_writableData(data)
+{
+}
+
+PassRefPtr<ChromiumDataObject> ChromiumDataObject::create(PassRefPtr<ChromiumDataObjectLegacy> data)
+{
+ return adoptRef(new ChromiumDataObject(data));
+}
+
+PassRefPtr<ChromiumDataObject> ChromiumDataObject::createReadable(Clipboard::ClipboardType clipboardType)
+{
+ return adoptRef(new ChromiumDataObject(ReadableDataObject::create(clipboardType)));
+}
+
+PassRefPtr<ChromiumDataObject> ChromiumDataObject::createWritable(Clipboard::ClipboardType clipboardType)
+{
+ return adoptRef(new ChromiumDataObject(WritableDataObject::create(clipboardType)));
+}
+
+void ChromiumDataObject::clearData(const String& type)
+{
+ if (m_legacyData)
+ m_legacyData->clearData(type);
+ else
+ m_writableData->clearData(type);
+}
+
+void ChromiumDataObject::clearAll()
{
- clearAllExceptFiles();
- filenames.clear();
+ if (m_legacyData)
+ m_legacyData->clearAll();
+ else
+ m_writableData->clearAll();
}
void ChromiumDataObject::clearAllExceptFiles()
{
- url = KURL();
- urlTitle = "";
- uriList.clear();
- downloadMetadata = "";
- fileExtension = "";
- plainText = "";
- textHtml = "";
- htmlBaseUrl = KURL();
- fileContentFilename = "";
- if (fileContent)
- fileContent->clear();
+ if (m_legacyData)
+ m_legacyData->clearAllExceptFiles();
+ else
+ m_writableData->clearAllExceptFiles();
}
bool ChromiumDataObject::hasData() const
{
- return !url.isEmpty()
- || !uriList.isEmpty()
- || !downloadMetadata.isEmpty()
- || !fileExtension.isEmpty()
- || !filenames.isEmpty()
- || !plainText.isEmpty()
- || !textHtml.isEmpty()
- || fileContent;
+ if (m_legacyData)
+ return m_legacyData->hasData();
+ return m_readableData->hasData();
+}
+
+HashSet<String> ChromiumDataObject::types() const
+{
+ if (m_legacyData)
+ return m_legacyData->types();
+ return m_readableData->types();
+}
+
+String ChromiumDataObject::getData(const String& type, bool& success)
+{
+ if (m_legacyData)
+ return m_legacyData->getData(type, success);
+ return m_readableData->getData(type, success);
+}
+
+bool ChromiumDataObject::setData(const String& type, const String& data)
+{
+ if (m_legacyData)
+ return m_legacyData->setData(type, data);
+ return m_writableData->setData(type, data);
+}
+
+String ChromiumDataObject::urlTitle() const
+{
+ if (m_legacyData)
+ return m_legacyData->urlTitle();
+ return m_readableData->urlTitle();
+}
+
+void ChromiumDataObject::setUrlTitle(const String& urlTitle)
+{
+ if (m_legacyData)
+ m_legacyData->setUrlTitle(urlTitle);
+ else
+ m_writableData->setUrlTitle(urlTitle);
+}
+
+KURL ChromiumDataObject::htmlBaseUrl() const
+{
+ if (m_legacyData)
+ return m_legacyData->htmlBaseUrl();
+ return m_readableData->htmlBaseUrl();
+}
+
+void ChromiumDataObject::setHtmlBaseUrl(const KURL& url)
+{
+ if (m_legacyData)
+ m_legacyData->setHtmlBaseUrl(url);
+ else
+ m_writableData->setHtmlBaseUrl(url);
+}
+
+bool ChromiumDataObject::containsFilenames() const
+{
+ if (m_legacyData)
+ return m_legacyData->containsFilenames();
+ return m_readableData->containsFilenames();
+}
+
+Vector<String> ChromiumDataObject::filenames() const
+{
+ if (m_legacyData)
+ return m_legacyData->filenames();
+ return m_readableData->filenames();
+}
+
+void ChromiumDataObject::setFilenames(const Vector<String>& filenames)
+{
+ if (m_legacyData)
+ m_legacyData->setFilenames(filenames);
+ else
+ ASSERT_NOT_REACHED();
+}
+
+String ChromiumDataObject::fileExtension() const
+{
+ if (m_legacyData)
+ return m_legacyData->fileExtension();
+ return m_writableData->fileExtension();
+}
+
+void ChromiumDataObject::setFileExtension(const String& fileExtension)
+{
+ if (m_legacyData)
+ m_legacyData->setFileExtension(fileExtension);
+ else
+ m_writableData->setFileExtension(fileExtension);
+}
+
+String ChromiumDataObject::fileContentFilename() const
+{
+ if (m_legacyData)
+ return m_legacyData->fileContentFilename();
+ return m_writableData->fileContentFilename();
+}
+
+void ChromiumDataObject::setFileContentFilename(const String& fileContentFilename)
+{
+ if (m_legacyData)
+ m_legacyData->setFileContentFilename(fileContentFilename);
+ else
+ m_writableData->setFileContentFilename(fileContentFilename);
+}
+
+PassRefPtr<SharedBuffer> ChromiumDataObject::fileContent() const
+{
+ if (m_legacyData)
+ return m_legacyData->fileContent();
+ return m_writableData->fileContent();
+}
+
+void ChromiumDataObject::setFileContent(PassRefPtr<SharedBuffer> fileContent)
+{
+ if (m_legacyData)
+ m_legacyData->setFileContent(fileContent);
+ else
+ m_writableData->setFileContent(fileContent);
+}
+
}
-ChromiumDataObject::ChromiumDataObject(const ChromiumDataObject& other)
- : RefCounted<ChromiumDataObject>()
- , urlTitle(other.urlTitle)
- , downloadMetadata(other.downloadMetadata)
- , fileExtension(other.fileExtension)
- , filenames(other.filenames)
- , plainText(other.plainText)
- , textHtml(other.textHtml)
- , htmlBaseUrl(other.htmlBaseUrl)
- , fileContentFilename(other.fileContentFilename)
- , url(other.url)
- , uriList(other.uriList)
-{
- if (other.fileContent.get())
- fileContent = other.fileContent->copy();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/chromium/ChromiumDataObject.h b/WebCore/platform/chromium/ChromiumDataObject.h
index af0a3fa..4aac5c9 100644
--- a/WebCore/platform/chromium/ChromiumDataObject.h
+++ b/WebCore/platform/chromium/ChromiumDataObject.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2010, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,85 +31,58 @@
#ifndef ChromiumDataObject_h
#define ChromiumDataObject_h
-#include "KURL.h"
-#include "PlatformString.h"
-#include "SharedBuffer.h"
+#include "ChromiumDataObjectLegacy.h"
+#include "ReadableDataObject.h"
+#include "WritableDataObject.h"
#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
namespace WebCore {
- // A data object for holding data that would be in a clipboard or moved
- // during a drag-n-drop operation. This is the data that WebCore is aware
- // of and is not specific to a platform.
- class ChromiumDataObject : public RefCounted<ChromiumDataObject> {
- public:
- static PassRefPtr<ChromiumDataObject> create()
- {
- return adoptRef(new ChromiumDataObject);
- }
-
- PassRefPtr<ChromiumDataObject> copy() const
- {
- return adoptRef(new ChromiumDataObject(*this));
- }
-
- void clear();
- void clearAllExceptFiles();
- bool hasData() const;
-
- void clearURL()
- {
- url = KURL();
- uriList.clear();
- urlTitle = "";
- }
-
- bool hasValidURL() const
- {
- return url.isValid();
- }
-
- KURL getURL() const
- {
- return url;
- }
-
- void setURL(const KURL& newURL)
- {
- url = newURL;
- uriList.clear();
- if (newURL.isEmpty())
- return;
- uriList.append(newURL.string());
- }
-
- String urlTitle;
-
- String downloadMetadata;
-
- String fileExtension;
- Vector<String> filenames;
-
- String plainText;
-
- String textHtml;
- KURL htmlBaseUrl;
-
- String fileContentFilename;
- RefPtr<SharedBuffer> fileContent;
-
- private:
- // URL and uri-list are linked, so they should not be accessed individually.
- KURL url;
- Vector<String> uriList;
-
- ChromiumDataObject() {}
- ChromiumDataObject(const ChromiumDataObject&);
-
- friend class ClipboardChromium;
- };
-
-} // namespace WebCore
+class ChromiumDataObject : public RefCounted<ChromiumDataObject> {
+public:
+ static PassRefPtr<ChromiumDataObject> create(PassRefPtr<ChromiumDataObjectLegacy> data);
+ static PassRefPtr<ChromiumDataObject> createReadable(Clipboard::ClipboardType);
+ static PassRefPtr<ChromiumDataObject> createWritable(Clipboard::ClipboardType);
+
+ void clearData(const String& type);
+ void clearAll();
+ void clearAllExceptFiles();
+
+ bool hasData() const;
+
+ HashSet<String> types() const;
+ String getData(const String& type, bool& success);
+ bool setData(const String& type, const String& data);
+
+ // Special handlers for URL/HTML metadata.
+ String urlTitle() const;
+ void setUrlTitle(const String& urlTitle);
+ KURL htmlBaseUrl() const;
+ void setHtmlBaseUrl(const KURL& url);
+
+ // Used to handle files being dragged in.
+ bool containsFilenames() const;
+ Vector<String> filenames() const;
+ void setFilenames(const Vector<String>& filenames);
+
+ // Used to handle files (images) being dragged out.
+ String fileExtension() const;
+ void setFileExtension(const String& fileExtension);
+ String fileContentFilename() const;
+ void setFileContentFilename(const String& fileContentFilename);
+ PassRefPtr<SharedBuffer> fileContent() const;
+ void setFileContent(PassRefPtr<SharedBuffer> fileContent);
+
+private:
+ ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy>);
+ ChromiumDataObject(PassRefPtr<ReadableDataObject>);
+ ChromiumDataObject(PassRefPtr<WritableDataObject>);
+
+ RefPtr<ChromiumDataObjectLegacy> m_legacyData;
+ RefPtr<ReadableDataObject> m_readableData;
+ RefPtr<WritableDataObject> m_writableData;
+};
+
+}
#endif
diff --git a/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp b/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp
new file mode 100644
index 0000000..a2952c0
--- /dev/null
+++ b/WebCore/platform/chromium/ChromiumDataObjectLegacy.cpp
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ChromiumDataObjectLegacy.h"
+
+#include "ChromiumBridge.h"
+#include "ClipboardMimeTypes.h"
+#include "Pasteboard.h"
+
+namespace WebCore {
+
+// Per RFC 2483, the line separator for "text/..." MIME types is CR-LF.
+static char const* const textMIMETypeLineSeparator = "\r\n";
+
+void ChromiumDataObjectLegacy::clearData(const String& type)
+{
+ if (type == mimeTypeTextPlain) {
+ m_plainText = "";
+ return;
+ }
+
+ if (type == mimeTypeURL || type == mimeTypeTextURIList) {
+ m_uriList = "";
+ m_url = KURL();
+ m_urlTitle = "";
+ return;
+ }
+
+ if (type == mimeTypeTextHTML) {
+ m_textHtml = "";
+ m_htmlBaseUrl = KURL();
+ return;
+ }
+
+ if (type == mimeTypeDownloadURL) {
+ m_downloadMetadata = "";
+ return;
+ }
+}
+
+void ChromiumDataObjectLegacy::clearAll()
+{
+ clearAllExceptFiles();
+ m_filenames.clear();
+}
+
+void ChromiumDataObjectLegacy::clearAllExceptFiles()
+{
+ m_urlTitle = "";
+ m_url = KURL();
+ m_uriList = "";
+ m_downloadMetadata = "";
+ m_fileExtension = "";
+ m_plainText = "";
+ m_textHtml = "";
+ m_htmlBaseUrl = KURL();
+ m_fileContentFilename = "";
+ if (m_fileContent)
+ m_fileContent->clear();
+}
+
+bool ChromiumDataObjectLegacy::hasData() const
+{
+ return !m_url.isEmpty()
+ || !m_uriList.isEmpty()
+ || !m_downloadMetadata.isEmpty()
+ || !m_fileExtension.isEmpty()
+ || !m_filenames.isEmpty()
+ || !m_plainText.isEmpty()
+ || !m_textHtml.isEmpty()
+ || m_fileContent;
+}
+
+HashSet<String> ChromiumDataObjectLegacy::types() const
+{
+ // This is currently broken for pasteboard events, and always has been.
+ HashSet<String> results;
+
+ if (!m_plainText.isEmpty()) {
+ results.add(mimeTypeText);
+ results.add(mimeTypeTextPlain);
+ }
+
+ if (m_url.isValid())
+ results.add(mimeTypeURL);
+
+ if (!m_uriList.isEmpty())
+ results.add(mimeTypeTextURIList);
+
+ if (!m_textHtml.isEmpty())
+ results.add(mimeTypeTextHTML);
+
+ if (!m_filenames.isEmpty())
+ results.add("Files");
+
+ return results;
+}
+
+String ChromiumDataObjectLegacy::getData(const String& type, bool& success)
+{
+ if (type == mimeTypeTextPlain) {
+ if (m_clipboardType == Clipboard::CopyAndPaste) {
+ PasteboardPrivate::ClipboardBuffer buffer =
+ Pasteboard::generalPasteboard()->isSelectionMode() ?
+ PasteboardPrivate::SelectionBuffer :
+ PasteboardPrivate::StandardBuffer;
+ String text = ChromiumBridge::clipboardReadPlainText(buffer);
+ success = !text.isEmpty();
+ return text;
+ }
+ success = !m_plainText.isEmpty();
+ return m_plainText;
+ }
+
+ if (type == mimeTypeURL) {
+ success = !m_url.isEmpty();
+ return m_url.string();
+ }
+
+ if (type == mimeTypeTextURIList) {
+ success = !m_uriList.isEmpty();
+ return m_uriList;
+ }
+
+ if (type == mimeTypeTextHTML) {
+ if (m_clipboardType == Clipboard::CopyAndPaste) {
+ PasteboardPrivate::ClipboardBuffer buffer =
+ Pasteboard::generalPasteboard()->isSelectionMode() ?
+ PasteboardPrivate::SelectionBuffer :
+ PasteboardPrivate::StandardBuffer;
+ String htmlText;
+ KURL sourceURL;
+ ChromiumBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL);
+ success = !htmlText.isEmpty();
+ return htmlText;
+ }
+ success = !m_textHtml.isEmpty();
+ return m_textHtml;
+ }
+
+ if (type == mimeTypeDownloadURL) {
+ success = !m_downloadMetadata.isEmpty();
+ return m_downloadMetadata;
+ }
+
+ success = false;
+ return String();
+}
+
+bool ChromiumDataObjectLegacy::setData(const String& type, const String& data)
+{
+ if (type == mimeTypeTextPlain) {
+ m_plainText = data;
+ return true;
+ }
+
+ if (type == mimeTypeURL || type == mimeTypeTextURIList) {
+ m_url = KURL();
+ Vector<String> uriList;
+ // Line separator is \r\n per RFC 2483 - however, for compatibility
+ // reasons we also allow just \n here.
+ data.split('\n', uriList);
+ // Process the input and copy the first valid URL into the url member.
+ // In case no URLs can be found, subsequent calls to getData("URL")
+ // will get an empty string. This is in line with the HTML5 spec (see
+ // "The DragEvent and DataTransfer interfaces").
+ for (size_t i = 0; i < uriList.size(); ++i) {
+ String& line = uriList[i];
+ line = line.stripWhiteSpace();
+ if (line.isEmpty())
+ continue;
+ if (line[0] == '#')
+ continue;
+ KURL url = KURL(ParsedURLString, line);
+ if (url.isValid()) {
+ m_url = url;
+ break;
+ }
+ }
+ m_uriList = data;
+ return true;
+ }
+
+ if (type == mimeTypeTextHTML) {
+ m_textHtml = data;
+ m_htmlBaseUrl = KURL();
+ return true;
+ }
+
+ if (type == mimeTypeDownloadURL) {
+ m_downloadMetadata = data;
+ return true;
+ }
+
+ return false;
+}
+
+ChromiumDataObjectLegacy::ChromiumDataObjectLegacy(Clipboard::ClipboardType clipboardType)
+ : m_clipboardType(clipboardType)
+{
+}
+
+ChromiumDataObjectLegacy::ChromiumDataObjectLegacy(const ChromiumDataObjectLegacy& other)
+ : RefCounted<ChromiumDataObjectLegacy>()
+ , m_clipboardType(other.m_clipboardType)
+ , m_urlTitle(other.m_urlTitle)
+ , m_downloadMetadata(other.m_downloadMetadata)
+ , m_fileExtension(other.m_fileExtension)
+ , m_filenames(other.m_filenames)
+ , m_plainText(other.m_plainText)
+ , m_textHtml(other.m_textHtml)
+ , m_htmlBaseUrl(other.m_htmlBaseUrl)
+ , m_fileContentFilename(other.m_fileContentFilename)
+ , m_url(other.m_url)
+ , m_uriList(other.m_uriList)
+{
+ if (other.m_fileContent.get())
+ m_fileContent = other.m_fileContent->copy();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/chromium/ChromiumDataObjectLegacy.h b/WebCore/platform/chromium/ChromiumDataObjectLegacy.h
new file mode 100644
index 0000000..55be7aa
--- /dev/null
+++ b/WebCore/platform/chromium/ChromiumDataObjectLegacy.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ChromiumDataObjectLegacy_h
+#define ChromiumDataObjectLegacy_h
+
+#include "Clipboard.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "SharedBuffer.h"
+#include <wtf/HashSet.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+// A data object for holding data that would be in a clipboard or moved
+// during a drag-n-drop operation. This is the data that WebCore is aware
+// of and is not specific to a platform.
+class ChromiumDataObjectLegacy : public RefCounted<ChromiumDataObjectLegacy> {
+public:
+ static PassRefPtr<ChromiumDataObjectLegacy> create(Clipboard::ClipboardType clipboardType)
+ {
+ return adoptRef(new ChromiumDataObjectLegacy(clipboardType));
+ }
+
+ PassRefPtr<ChromiumDataObjectLegacy> copy() const
+ {
+ return adoptRef(new ChromiumDataObjectLegacy(*this));
+ }
+
+ void clearData(const String& type);
+ void clearAll();
+ void clearAllExceptFiles();
+
+ bool hasData() const;
+
+ HashSet<String> types() const;
+ String getData(const String& type, bool& success);
+ bool setData(const String& type, const String& data);
+
+ // Special handlers for URL/HTML metadata.
+ String urlTitle() const { return m_urlTitle; }
+ void setUrlTitle(const String& urlTitle) { m_urlTitle = urlTitle; }
+ KURL htmlBaseUrl() const { return m_htmlBaseUrl; }
+ void setHtmlBaseUrl(const KURL& url) { m_htmlBaseUrl = url; }
+
+ // Used to handle files being dragged in.
+ bool containsFilenames() const { return !m_filenames.isEmpty(); }
+ Vector<String> filenames() const { return m_filenames; }
+ void setFilenames(const Vector<String>& filenames) { m_filenames = filenames; }
+
+ // Used to handle files (images) being dragged out.
+ String fileExtension() const { return m_fileExtension; }
+ void setFileExtension(const String& fileExtension) { m_fileExtension = fileExtension; }
+ String fileContentFilename() const { return m_fileContentFilename; }
+ void setFileContentFilename(const String& fileContentFilename) { m_fileContentFilename = fileContentFilename; }
+ PassRefPtr<SharedBuffer> fileContent() const { return m_fileContent; }
+ void setFileContent(PassRefPtr<SharedBuffer> fileContent) { m_fileContent = fileContent; }
+
+private:
+ ChromiumDataObjectLegacy(Clipboard::ClipboardType);
+ ChromiumDataObjectLegacy(const ChromiumDataObjectLegacy&);
+
+ Clipboard::ClipboardType m_clipboardType;
+
+ String m_urlTitle;
+
+ String m_downloadMetadata;
+
+ String m_fileExtension;
+ Vector<String> m_filenames;
+
+ String m_plainText;
+
+ String m_textHtml;
+ KURL m_htmlBaseUrl;
+
+ String m_fileContentFilename;
+ RefPtr<SharedBuffer> m_fileContent;
+
+ // These two are linked. Setting m_url will set m_uriList to the same
+ // string value; setting m_uriList will cause its contents to be parsed
+ // according to RFC 2483 and the first URL found will be set in m_url.
+ KURL m_url;
+ String m_uriList;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp
index c2ec80c..46b4339 100644
--- a/WebCore/platform/chromium/ClipboardChromium.cpp
+++ b/WebCore/platform/chromium/ClipboardChromium.cpp
@@ -28,8 +28,8 @@
#include "ClipboardChromium.h"
#include "CachedImage.h"
-#include "ChromiumBridge.h"
#include "ChromiumDataObject.h"
+#include "ClipboardMimeTypes.h"
#include "ClipboardUtilitiesChromium.h"
#include "Document.h"
#include "DragData.h"
@@ -37,17 +37,18 @@
#include "FileList.h"
#include "Frame.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "Image.h"
#include "MIMETypeRegistry.h"
#include "NamedNodeMap.h"
-#include "Pasteboard.h"
-#include "PlatformString.h"
#include "Range.h"
#include "RenderImage.h"
#include "ScriptExecutionContext.h"
-#include "StringBuilder.h"
#include "markup.h"
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
namespace WebCore {
using namespace HTMLNames;
@@ -55,40 +56,12 @@ using namespace HTMLNames;
// We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft
// see http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3
-enum ClipboardDataType {
- ClipboardDataTypeNone,
-
- ClipboardDataTypeURL,
- ClipboardDataTypeURIList,
- ClipboardDataTypeDownloadURL,
- ClipboardDataTypePlainText,
- ClipboardDataTypeHTML,
-
- ClipboardDataTypeOther,
-};
-
-// Per RFC 2483, the line separator for "text/..." MIME types is CR-LF.
-static char const* const textMIMETypeLineSeparator = "\r\n";
-
-static ClipboardDataType clipboardTypeFromMIMEType(const String& type)
+static String normalizeType(const String& type)
{
String cleanType = type.stripWhiteSpace().lower();
- if (cleanType.isEmpty())
- return ClipboardDataTypeNone;
-
- // Includes two special cases for IE compatibility.
- if (cleanType == "text" || cleanType == "text/plain" || cleanType.startsWith("text/plain;"))
- return ClipboardDataTypePlainText;
- if (cleanType == "url")
- return ClipboardDataTypeURL;
- if (cleanType == "text/uri-list")
- return ClipboardDataTypeURIList;
- if (cleanType == "downloadurl")
- return ClipboardDataTypeDownloadURL;
- if (cleanType == "text/html")
- return ClipboardDataTypeHTML;
-
- return ClipboardDataTypeOther;
+ if (cleanType == mimeTypeText || cleanType.startsWith(mimeTypeTextPlainEtc))
+ return mimeTypeTextPlain;
+ return cleanType;
}
PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame)
@@ -112,41 +85,22 @@ PassRefPtr<ClipboardChromium> ClipboardChromium::create(ClipboardType clipboardT
return adoptRef(new ClipboardChromium(clipboardType, dataObject, policy, frame));
}
+PassRefPtr<ClipboardChromium> ClipboardChromium::create(ClipboardType clipboardType,
+ ClipboardAccessPolicy policy, Frame* frame)
+{
+ RefPtr<ChromiumDataObject> dataObject =
+ policy == ClipboardWritable ?
+ ChromiumDataObject::createWritable(clipboardType) :
+ ChromiumDataObject::createReadable(clipboardType);
+ return adoptRef(new ClipboardChromium(clipboardType, dataObject, policy, frame));
+}
+
void ClipboardChromium::clearData(const String& type)
{
if (policy() != ClipboardWritable || !m_dataObject)
return;
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
- switch (dataType) {
- case ClipboardDataTypeNone:
- // If called with no arguments, everything except the file list must be cleared.
- // (See HTML5 spec, "The DragEvent and DataTransfer interfaces")
- m_dataObject->clearAllExceptFiles();
- return;
-
- case ClipboardDataTypeURL:
- case ClipboardDataTypeURIList:
- m_dataObject->clearURL();
- return;
-
- case ClipboardDataTypeDownloadURL:
- m_dataObject->downloadMetadata = "";
- return;
-
- case ClipboardDataTypePlainText:
- m_dataObject->plainText = "";
- return;
-
- case ClipboardDataTypeHTML:
- m_dataObject->textHtml = "";
- m_dataObject->htmlBaseUrl = KURL();
- return;
-
- case ClipboardDataTypeOther:
- // Not yet implemented, see https://bugs.webkit.org/show_bug.cgi?id=34410
- return;
- }
+ m_dataObject->clearData(normalizeType(type));
ASSERT_NOT_REACHED();
}
@@ -156,7 +110,7 @@ void ClipboardChromium::clearAllData()
if (policy() != ClipboardWritable)
return;
- m_dataObject->clear();
+ m_dataObject->clearAll();
}
String ClipboardChromium::getData(const String& type, bool& success) const
@@ -165,80 +119,7 @@ String ClipboardChromium::getData(const String& type, bool& success) const
if (policy() != ClipboardReadable || !m_dataObject)
return String();
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
- switch (dataType) {
- case ClipboardDataTypeNone:
- return String();
-
- // Hack for URLs. file URLs are used internally for drop's default action, but we don't want
- // to expose them to the page, so we filter them out here.
- case ClipboardDataTypeURIList:
- {
- String text;
- for (size_t i = 0; i < m_dataObject->uriList.size(); ++i) {
- const String& uri = m_dataObject->uriList[i];
- if (protocolIs(uri, "file"))
- continue;
- ASSERT(!uri.isEmpty());
- if (!text.isEmpty())
- text.append(textMIMETypeLineSeparator);
- // URIs have already been canonicalized, so copy everything verbatim.
- text.append(uri);
- }
- success = !text.isEmpty();
- return text;
- }
-
- case ClipboardDataTypeURL:
- // In case of a previous setData('text/uri-list'), setData() has already
- // prepared the 'url' member, so we can just retrieve it here.
- if (!m_dataObject->url.isEmpty() && !m_dataObject->url.isLocalFile()) {
- success = true;
- return m_dataObject->url.string();
- }
- return String();
-
- case ClipboardDataTypeDownloadURL:
- success = !m_dataObject->downloadMetadata.isEmpty();
- return m_dataObject->downloadMetadata;
-
- case ClipboardDataTypePlainText:
- if (isForCopyAndPaste()) {
- PasteboardPrivate::ClipboardBuffer buffer =
- Pasteboard::generalPasteboard()->isSelectionMode() ?
- PasteboardPrivate::SelectionBuffer :
- PasteboardPrivate::StandardBuffer;
- String text = ChromiumBridge::clipboardReadPlainText(buffer);
- success = !text.isEmpty();
- return text;
- }
- // Otherwise return whatever is stored in plainText.
- success = !m_dataObject->plainText.isEmpty();
- return m_dataObject->plainText;
-
- case ClipboardDataTypeHTML:
- if (isForCopyAndPaste()) {
- PasteboardPrivate::ClipboardBuffer buffer =
- Pasteboard::generalPasteboard()->isSelectionMode() ?
- PasteboardPrivate::SelectionBuffer :
- PasteboardPrivate::StandardBuffer;
- String htmlText;
- KURL sourceURL;
- ChromiumBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL);
- success = !htmlText.isEmpty();
- return htmlText;
- }
- // Otherwise return whatever is stored in textHtml.
- success = !m_dataObject->textHtml.isEmpty();
- return m_dataObject->textHtml;
-
- case ClipboardDataTypeOther:
- // not yet implemented, see https://bugs.webkit.org/show_bug.cgi?id=34410
- return String();
- }
-
- ASSERT_NOT_REACHED();
- return String();
+ return m_dataObject->getData(normalizeType(type), success);
}
bool ClipboardChromium::setData(const String& type, const String& data)
@@ -246,69 +127,7 @@ bool ClipboardChromium::setData(const String& type, const String& data)
if (policy() != ClipboardWritable)
return false;
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
- switch (dataType) {
- case ClipboardDataTypeNone:
- return false;
-
- case ClipboardDataTypeURL:
- // For setData(), "URL" must be treated as "text/uri-list".
- // (See HTML5 spec, "The DragEvent and DataTransfer interfaces")
- case ClipboardDataTypeURIList:
- m_dataObject->url = KURL();
- // Line separator is \r\n per RFC 2483 - however, for compatibility reasons
- // we also allow just \n here.
- data.split('\n', m_dataObject->uriList);
- // Strip white space on all lines, including trailing \r from above split.
- // If this leaves a line empty, remove it completely.
- //
- // Also, copy the first valid URL into the 'url' member as well.
- // In case no entry is a valid URL (i.e., remarks only), then we leave 'url' empty.
- // I.e., in that case subsequent calls to getData("URL") will get an empty string.
- // This is in line with the HTML5 spec (see "The DragEvent and DataTransfer interfaces").
- for (size_t i = 0; i < m_dataObject->uriList.size(); /**/) {
- String& line = m_dataObject->uriList[i];
- line = line.stripWhiteSpace();
- if (line.isEmpty()) {
- m_dataObject->uriList.remove(i);
- continue;
- }
- ++i;
- // Only copy the first valid URL.
- if (m_dataObject->url.isValid())
- continue;
- // Skip remarks.
- if (line[0] == '#')
- continue;
- KURL url = KURL(ParsedURLString, line);
- if (url.isValid())
- m_dataObject->url = url;
- }
- if (m_dataObject->uriList.isEmpty()) {
- ASSERT(m_dataObject->url.isEmpty());
- return data.isEmpty();
- }
- return true;
-
- case ClipboardDataTypeDownloadURL:
- m_dataObject->downloadMetadata = data;
- return true;
-
- case ClipboardDataTypePlainText:
- m_dataObject->plainText = data;
- return true;
-
- case ClipboardDataTypeHTML:
- m_dataObject->textHtml = data;
- return true;
-
- case ClipboardDataTypeOther:
- // Not yet implemented, see https://bugs.webkit.org/show_bug.cgi?id=34410
- return false;
- }
-
- ASSERT_NOT_REACHED();
- return false;
+ return m_dataObject->setData(normalizeType(type), data);
}
// extensions beyond IE's API
@@ -321,33 +140,7 @@ HashSet<String> ClipboardChromium::types() const
if (!m_dataObject)
return results;
- if (!m_dataObject->filenames.isEmpty())
- results.add("Files");
-
- // Hack for URLs. file URLs are used internally for drop's default action, but we don't want
- // to expose them to the page, so we filter them out here.
- if (m_dataObject->url.isValid() && !m_dataObject->url.isLocalFile()) {
- ASSERT(!m_dataObject->uriList.isEmpty());
- results.add("URL");
- }
-
- if (!m_dataObject->uriList.isEmpty()) {
- // Verify that the URI list contains at least one non-file URL.
- for (Vector<String>::const_iterator it = m_dataObject->uriList.begin();
- it != m_dataObject->uriList.end(); ++it) {
- if (!protocolIs(*it, "file")) {
- // Note that even if the URI list is not empty, it may not actually
- // contain a valid URL, so we can't return "URL" here.
- results.add("text/uri-list");
- break;
- }
- }
- }
-
- if (!m_dataObject->plainText.isEmpty()) {
- results.add("Text");
- results.add("text/plain");
- }
+ results = m_dataObject->types();
return results;
}
@@ -357,12 +150,13 @@ PassRefPtr<FileList> ClipboardChromium::files() const
if (policy() != ClipboardReadable)
return FileList::create();
- if (!m_dataObject || m_dataObject->filenames.isEmpty())
+ if (!m_dataObject)
return FileList::create();
+ const Vector<String>& filenames = m_dataObject->filenames();
RefPtr<FileList> fileList = FileList::create();
- for (size_t i = 0; i < m_dataObject->filenames.size(); ++i)
- fileList->append(File::create(m_dataObject->filenames.at(i)));
+ for (size_t i = 0; i < filenames.size(); ++i)
+ fileList->append(File::create(filenames.at(i)));
return fileList.release();
}
@@ -412,7 +206,7 @@ static String imageToMarkup(const String& url, Element* element)
StringBuilder markup;
markup.append("<img src=\"");
markup.append(url);
- markup.append("\"");
+ markup.append('"');
// Copy over attributes. If we are dragging an image, we expect things like
// the id to be copied as well.
NamedNodeMap* attrs = element->attributes();
@@ -421,13 +215,13 @@ static String imageToMarkup(const String& url, Element* element)
Attribute* attr = attrs->attributeItem(i);
if (attr->localName() == "src")
continue;
- markup.append(" ");
+ markup.append(' ');
markup.append(attr->localName());
markup.append("=\"");
String escapedAttr = attr->value();
escapedAttr.replace("\"", "&quot;");
markup.append(escapedAttr);
- markup.append("\"");
+ markup.append('"');
}
markup.append("/>");
@@ -461,7 +255,7 @@ static void writeImageToDataObject(ChromiumDataObject* dataObject, Element* elem
if (!imageBuffer || !imageBuffer->size())
return;
- dataObject->fileContent = imageBuffer;
+ dataObject->setFileContent(imageBuffer);
// Determine the filename for the file contents of the image. We try to
// use the alt tag if one exists, otherwise we fall back on the suggested
@@ -469,13 +263,13 @@ static void writeImageToDataObject(ChromiumDataObject* dataObject, Element* elem
// in the URL.
String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
cachedImage->response().mimeType());
- dataObject->fileExtension = extension.isEmpty() ? "" : "." + extension;
+ dataObject->setFileExtension(extension.isEmpty() ? "" : "." + extension);
String title = element->getAttribute(altAttr);
if (title.isEmpty())
title = cachedImage->response().suggestedFilename();
title = ClipboardChromium::validateFileName(title, dataObject);
- dataObject->fileContentFilename = title + dataObject->fileExtension;
+ dataObject->setFileContentFilename(title + dataObject->fileExtension());
}
void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
@@ -483,8 +277,8 @@ void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& u
if (!m_dataObject)
return;
- m_dataObject->url = url;
- m_dataObject->urlTitle = title;
+ m_dataObject->setData(mimeTypeURL, url);
+ m_dataObject->setUrlTitle(title);
// Write the bytes in the image to the file format.
writeImageToDataObject(m_dataObject.get(), element, url);
@@ -493,12 +287,12 @@ void ClipboardChromium::declareAndWriteDragImage(Element* element, const KURL& u
if (imageURL.isEmpty())
return;
- String fullURL = frame->document()->completeURL(deprecatedParseURL(imageURL));
+ String fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL));
if (fullURL.isEmpty())
return;
// Put img tag on the clipboard referencing the image
- m_dataObject->textHtml = imageToMarkup(fullURL, element);
+ m_dataObject->setData(mimeTypeTextHTML, imageToMarkup(fullURL, element));
}
void ClipboardChromium::writeURL(const KURL& url, const String& title, Frame*)
@@ -506,17 +300,15 @@ void ClipboardChromium::writeURL(const KURL& url, const String& title, Frame*)
if (!m_dataObject)
return;
ASSERT(!url.isEmpty());
- m_dataObject->url = url;
- m_dataObject->urlTitle = title;
- m_dataObject->uriList.clear();
- m_dataObject->uriList.append(url);
+ m_dataObject->setData(mimeTypeURL, url);
+ m_dataObject->setUrlTitle(title);
// The URL can also be used as plain text.
- m_dataObject->plainText = url.string();
+ m_dataObject->setData(mimeTypeTextPlain, url.string());
// The URL can also be used as an HTML fragment.
- m_dataObject->textHtml = urlToMarkup(url, title);
- m_dataObject->htmlBaseUrl = url;
+ m_dataObject->setData(mimeTypeTextHTML, urlToMarkup(url, title));
+ m_dataObject->setHtmlBaseUrl(url);
}
void ClipboardChromium::writeRange(Range* selectedRange, Frame* frame)
@@ -525,15 +317,15 @@ void ClipboardChromium::writeRange(Range* selectedRange, Frame* frame)
if (!m_dataObject)
return;
- m_dataObject->textHtml = createMarkup(selectedRange, 0, AnnotateForInterchange, false, AbsoluteURLs);
- m_dataObject->htmlBaseUrl = frame->document()->url();
+ m_dataObject->setData(mimeTypeTextHTML, createMarkup(selectedRange, 0, AnnotateForInterchange, false, AbsoluteURLs));
+ m_dataObject->setHtmlBaseUrl(frame->document()->url());
String str = frame->editor()->selectedText();
#if OS(WINDOWS)
replaceNewlinesWithWindowsStyleNewlines(str);
#endif
replaceNBSPWithSpace(str);
- m_dataObject->plainText = str;
+ m_dataObject->setData(mimeTypeTextPlain, str);
}
void ClipboardChromium::writePlainText(const String& text)
@@ -546,7 +338,7 @@ void ClipboardChromium::writePlainText(const String& text)
replaceNewlinesWithWindowsStyleNewlines(str);
#endif
replaceNBSPWithSpace(str);
- m_dataObject->plainText = str;
+ m_dataObject->setData(mimeTypeTextPlain, str);
}
bool ClipboardChromium::hasData()
diff --git a/WebCore/platform/chromium/ClipboardChromium.h b/WebCore/platform/chromium/ClipboardChromium.h
index 14f59e9..1d69921 100644
--- a/WebCore/platform/chromium/ClipboardChromium.h
+++ b/WebCore/platform/chromium/ClipboardChromium.h
@@ -48,6 +48,9 @@ namespace WebCore {
static PassRefPtr<ClipboardChromium> create(
ClipboardType, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy, Frame*);
+ static PassRefPtr<ClipboardChromium> create(
+ ClipboardType, ClipboardAccessPolicy, Frame*);
+
// Returns the file name (not including the extension). This removes any
// invalid file system characters as well as making sure the
// path + extension is not bigger than allowed by the file system.
diff --git a/WebCore/platform/chromium/ClipboardChromiumWin.cpp b/WebCore/platform/chromium/ClipboardChromiumWin.cpp
index b4a2c21..d9bbeb5 100644
--- a/WebCore/platform/chromium/ClipboardChromiumWin.cpp
+++ b/WebCore/platform/chromium/ClipboardChromiumWin.cpp
@@ -44,11 +44,11 @@ String ClipboardChromium::validateFileName(const String& title, ChromiumDataObje
{
// Remove any invalid file system characters.
String result = title.removeCharacters(&isInvalidFileCharacter);
- if (result.length() + dataObject->fileExtension.length() + 1 >= MAX_PATH) {
- if (dataObject->fileExtension.length() + 1 >= MAX_PATH)
- dataObject->fileExtension = "";
- if (result.length() + dataObject->fileExtension.length() + 1 >= MAX_PATH)
- result = result.substring(0, MAX_PATH - dataObject->fileExtension.length() - 1);
+ if (result.length() + dataObject->fileExtension().length() + 1 >= MAX_PATH) {
+ if (dataObject->fileExtension().length() + 1 >= MAX_PATH)
+ dataObject->setFileExtension("");
+ if (result.length() + dataObject->fileExtension().length() + 1 >= MAX_PATH)
+ result = result.substring(0, MAX_PATH - dataObject->fileExtension().length() - 1);
}
return result;
}
diff --git a/WebCore/platform/chromium/ClipboardMimeTypes.cpp b/WebCore/platform/chromium/ClipboardMimeTypes.cpp
index b95744f8..f689e0e 100644
--- a/WebCore/platform/chromium/ClipboardMimeTypes.cpp
+++ b/WebCore/platform/chromium/ClipboardMimeTypes.cpp
@@ -33,8 +33,12 @@
namespace WebCore {
-const char textPlainType[] = "text/plain";
-const char textHtmlType[] = "text/html";
-const char textUriListType[] = "text/uri-list";
+const char mimeTypeText[] = "text";
+const char mimeTypeTextPlain[] = "text/plain";
+const char mimeTypeTextPlainEtc[] = "text/plain;";
+const char mimeTypeTextHTML[] = "text/html";
+const char mimeTypeURL[] = "url";
+const char mimeTypeTextURIList[] = "text/uri-list";
+const char mimeTypeDownloadURL[] = "downloadurl";
} // namespace WebCore
diff --git a/WebCore/platform/chromium/ClipboardMimeTypes.h b/WebCore/platform/chromium/ClipboardMimeTypes.h
index d7468f2..9bdccfe 100644
--- a/WebCore/platform/chromium/ClipboardMimeTypes.h
+++ b/WebCore/platform/chromium/ClipboardMimeTypes.h
@@ -33,9 +33,13 @@
namespace WebCore {
-extern const char textPlainType[];
-extern const char textHtmlType[];
-extern const char textUriListType[];
+extern const char mimeTypeText[];
+extern const char mimeTypeTextPlain[];
+extern const char mimeTypeTextPlainEtc[];
+extern const char mimeTypeTextHTML[];
+extern const char mimeTypeURL[];
+extern const char mimeTypeTextURIList[];
+extern const char mimeTypeDownloadURL[];
} // namespace WebCore
diff --git a/WebCore/platform/chromium/DragDataChromium.cpp b/WebCore/platform/chromium/DragDataChromium.cpp
index 674d34d..2b04523 100644
--- a/WebCore/platform/chromium/DragDataChromium.cpp
+++ b/WebCore/platform/chromium/DragDataChromium.cpp
@@ -32,6 +32,7 @@
#include "ChromiumBridge.h"
#include "ChromiumDataObject.h"
+#include "ClipboardMimeTypes.h"
#include "DocumentFragment.h"
#include "FileSystem.h"
#include "KURL.h"
@@ -43,50 +44,50 @@ namespace WebCore {
static bool containsHTML(const ChromiumDataObject* dropData)
{
- return dropData->textHtml.length() > 0;
+ return dropData->types().contains(mimeTypeTextHTML);
}
bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
{
- return !asURL(filenamePolicy).isEmpty();
+ return m_platformDragData->types().contains(mimeTypeURL)
+ || (filenamePolicy == ConvertFilenames && m_platformDragData->containsFilenames());
}
String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
{
String url;
- if (m_platformDragData->hasValidURL())
- url = m_platformDragData->getURL().string();
- else if (filenamePolicy == ConvertFilenames && !m_platformDragData->filenames.isEmpty()) {
- String fileName = m_platformDragData->filenames[0];
- fileName = ChromiumBridge::getAbsolutePath(fileName);
- url = ChromiumBridge::filePathToURL(fileName).string();
+ if (m_platformDragData->types().contains(mimeTypeURL)) {
+ bool ignoredSuccess;
+ url = m_platformDragData->getData(mimeTypeURL, ignoredSuccess);
+ if (title)
+ *title = m_platformDragData->urlTitle();
+ } else if (filenamePolicy == ConvertFilenames && containsFiles()) {
+ url = ChromiumBridge::filePathToURL(ChromiumBridge::getAbsolutePath(m_platformDragData->filenames()[0]));
}
-
- // |title| can be NULL
- if (title)
- *title = m_platformDragData->urlTitle;
return url;
}
bool DragData::containsFiles() const
{
- return !m_platformDragData->filenames.isEmpty();
+ return m_platformDragData->containsFilenames();
}
void DragData::asFilenames(Vector<String>& result) const
{
- for (size_t i = 0; i < m_platformDragData->filenames.size(); ++i)
- result.append(m_platformDragData->filenames[i]);
+ const Vector<String>& filenames = m_platformDragData->filenames();
+ for (size_t i = 0; i < filenames.size(); ++i)
+ result.append(filenames[i]);
}
bool DragData::containsPlainText() const
{
- return !m_platformDragData->plainText.isEmpty();
+ return m_platformDragData->types().contains(mimeTypeTextPlain);
}
String DragData::asPlainText() const
{
- return m_platformDragData->plainText;
+ bool ignoredSuccess;
+ return m_platformDragData->getData(mimeTypeTextPlain, ignoredSuccess);
}
bool DragData::containsColor() const
@@ -101,8 +102,8 @@ bool DragData::canSmartReplace() const
// This is allowed whenever the drag data contains a 'range' (ie.,
// ClipboardWin::writeRange is called). For example, dragging a link
// should not result in a space being added.
- return !m_platformDragData->plainText.isEmpty()
- && !m_platformDragData->hasValidURL();
+ return m_platformDragData->types().contains(mimeTypeTextPlain)
+ && !m_platformDragData->types().contains(mimeTypeURL);
}
bool DragData::containsCompatibleContent() const
@@ -134,9 +135,10 @@ PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
// return fragment;
}
- if (!m_platformDragData->textHtml.isEmpty()) {
+ if (m_platformDragData->types().contains(mimeTypeTextHTML)) {
+ bool ignoredSuccess;
RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(doc,
- m_platformDragData->textHtml, m_platformDragData->htmlBaseUrl, FragmentScriptingNotAllowed);
+ m_platformDragData->getData(mimeTypeTextHTML, ignoredSuccess), m_platformDragData->htmlBaseUrl(), FragmentScriptingNotAllowed);
return fragment.release();
}
diff --git a/WebCore/platform/chromium/GeolocationServiceChromium.cpp b/WebCore/platform/chromium/GeolocationServiceChromium.cpp
index b64f5eb..c5e73ae 100644
--- a/WebCore/platform/chromium/GeolocationServiceChromium.cpp
+++ b/WebCore/platform/chromium/GeolocationServiceChromium.cpp
@@ -33,6 +33,10 @@
#include "ChromiumBridge.h"
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+#error "This file should not be compiled when ENABLE(CLIENT_BASED_GEOLOCATION)"
+#endif // ENABLE(CLIENT_BASED_GEOLOCATION)
+
namespace WebCore {
GeolocationServiceBridge::~GeolocationServiceBridge()
diff --git a/WebCore/platform/chromium/Language.cpp b/WebCore/platform/chromium/LanguageChromium.cpp
index 2612af4..69fe372 100644
--- a/WebCore/platform/chromium/Language.cpp
+++ b/WebCore/platform/chromium/LanguageChromium.cpp
@@ -36,7 +36,7 @@
namespace WebCore {
-String defaultLanguage()
+String platformDefaultLanguage()
{
static String computedDefaultLanguage;
if (computedDefaultLanguage.isEmpty())
diff --git a/WebCore/platform/chromium/PasteboardChromium.cpp b/WebCore/platform/chromium/PasteboardChromium.cpp
index ba69b00..907a4b9 100644
--- a/WebCore/platform/chromium/PasteboardChromium.cpp
+++ b/WebCore/platform/chromium/PasteboardChromium.cpp
@@ -38,6 +38,7 @@
#include "Element.h"
#include "Frame.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "Image.h"
#include "KURL.h"
#include "markup.h"
@@ -147,7 +148,7 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String& title)
Element* element = static_cast<Element*>(node);
urlString = element->getAttribute(element->imageSourceAttributeName());
}
- KURL url = urlString.isEmpty() ? KURL() : node->document()->completeURL(deprecatedParseURL(urlString));
+ KURL url = urlString.isEmpty() ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
ChromiumBridge::clipboardWriteImage(bitmap, url, title);
}
diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp
index 9c73a9c..3c807ba 100644
--- a/WebCore/platform/chromium/PopupMenuChromium.cpp
+++ b/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -513,7 +513,7 @@ void PopupContainer::paintBorder(GraphicsContext* gc, const IntRect& rect)
Color borderColor(127, 157, 185);
gc->setStrokeStyle(NoStroke);
- gc->setFillColor(borderColor, DeviceColorSpace);
+ gc->setFillColor(borderColor, ColorSpaceDeviceRGB);
int tx = x();
int ty = y();
@@ -857,7 +857,7 @@ void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
// Special case for an empty popup.
if (numItems() == 0)
- gc->fillRect(r, Color::white, DeviceColorSpace);
+ gc->fillRect(r, Color::white, ColorSpaceDeviceRGB);
gc->restore();
@@ -894,23 +894,23 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
// If we have a transparent background, make sure it has a color to blend
// against.
if (backColor.hasAlpha())
- gc->fillRect(rowRect, Color::white, DeviceColorSpace);
+ gc->fillRect(rowRect, Color::white, ColorSpaceDeviceRGB);
- gc->fillRect(rowRect, backColor, DeviceColorSpace);
+ gc->fillRect(rowRect, backColor, ColorSpaceDeviceRGB);
if (m_popupClient->itemIsSeparator(rowIndex)) {
IntRect separatorRect(
rowRect.x() + separatorPadding,
rowRect.y() + (rowRect.height() - separatorHeight) / 2,
rowRect.width() - 2 * separatorPadding, separatorHeight);
- gc->fillRect(separatorRect, textColor, DeviceColorSpace);
+ gc->fillRect(separatorRect, textColor, ColorSpaceDeviceRGB);
return;
}
if (!style.isVisible())
return;
- gc->setFillColor(textColor, DeviceColorSpace);
+ gc->setFillColor(textColor, ColorSpaceDeviceRGB);
Font itemFont = getRowFont(rowIndex);
// FIXME: http://crbug.com/19872 We should get the padding of individual option
@@ -973,7 +973,7 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
remainingWidth -= (imageRect.width() + kLabelToIconPadding);
imageRect.setX(rowRect.width() - rightPadding - imageRect.width());
imageRect.setY(rowRect.y() + (rowRect.height() - imageRect.height()) / 2);
- gc->drawImage(image.get(), DeviceColorSpace, imageRect);
+ gc->drawImage(image.get(), ColorSpaceDeviceRGB, imageRect);
}
// Draw the the label if applicable.
@@ -985,7 +985,7 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
else
textX = remainingWidth - itemFont.width(labelTextRun);
- gc->setFillColor(labelColor, DeviceColorSpace);
+ gc->setFillColor(labelColor, ColorSpaceDeviceRGB);
gc->drawBidiText(itemFont, labelTextRun, IntPoint(textX, textY));
}
diff --git a/WebCore/platform/chromium/ReadableDataObject.cpp b/WebCore/platform/chromium/ReadableDataObject.cpp
index 1a333bb..97c481b 100644
--- a/WebCore/platform/chromium/ReadableDataObject.cpp
+++ b/WebCore/platform/chromium/ReadableDataObject.cpp
@@ -33,21 +33,23 @@
#include "ChromiumBridge.h"
#include "ClipboardMimeTypes.h"
+#include "Pasteboard.h"
+#include "PasteboardPrivate.h"
namespace WebCore {
-static PasteboardPrivate::ClipboardBuffer clipboardBuffer(bool isForDragging)
+static PasteboardPrivate::ClipboardBuffer clipboardBuffer(Clipboard::ClipboardType clipboardType)
{
- return isForDragging ? PasteboardPrivate::DragBuffer : PasteboardPrivate::StandardBuffer;
+ return clipboardType == Clipboard::DragAndDrop ? PasteboardPrivate::DragBuffer : PasteboardPrivate::StandardBuffer;
}
-PassRefPtr<ReadableDataObject> ReadableDataObject::create(bool isForDragging)
+PassRefPtr<ReadableDataObject> ReadableDataObject::create(Clipboard::ClipboardType clipboardType)
{
- return adoptRef(new ReadableDataObject(isForDragging));
+ return adoptRef(new ReadableDataObject(clipboardType));
}
-ReadableDataObject::ReadableDataObject(bool isForDragging)
- : m_isForDragging(isForDragging)
+ReadableDataObject::ReadableDataObject(Clipboard::ClipboardType clipboardType)
+ : m_clipboardType(clipboardType)
, m_containsFilenames(false)
, m_isTypeCacheInitialized(false)
{
@@ -69,34 +71,51 @@ String ReadableDataObject::getData(const String& type, bool& succeeded) const
{
String data;
String ignoredMetadata;
+ // Since the Chromium-side bridge isn't complete yet, we special case this
+ // for copy-and-paste, since that code path no longer uses
+ // ChromiumDataObjectLegacy.
+ if (m_clipboardType == Clipboard::CopyAndPaste) {
+ if (type == mimeTypeTextPlain) {
+ PasteboardPrivate::ClipboardBuffer buffer =
+ Pasteboard::generalPasteboard()->isSelectionMode() ?
+ PasteboardPrivate::SelectionBuffer :
+ PasteboardPrivate::StandardBuffer;
+ data = ChromiumBridge::clipboardReadPlainText(buffer);
+ } else if (type == mimeTypeTextHTML) {
+ PasteboardPrivate::ClipboardBuffer buffer =
+ Pasteboard::generalPasteboard()->isSelectionMode() ?
+ PasteboardPrivate::SelectionBuffer :
+ PasteboardPrivate::StandardBuffer;
+ KURL ignoredSourceURL;
+ ChromiumBridge::clipboardReadHTML(buffer, &data, &ignoredSourceURL);
+ }
+ succeeded = !data.isEmpty();
+ return data;
+ }
succeeded = ChromiumBridge::clipboardReadData(
- clipboardBuffer(m_isForDragging), type, data, ignoredMetadata);
+ clipboardBuffer(m_clipboardType), type, data, ignoredMetadata);
return data;
}
-String ReadableDataObject::getURL(String* title) const
+String ReadableDataObject::urlTitle() const
{
- String url;
- String ignoredTitle;
- if (!title)
- title = &ignoredTitle;
+ String ignoredData;
+ String urlTitle;
ChromiumBridge::clipboardReadData(
- clipboardBuffer(m_isForDragging), textUriListType, url, *title);
- return url;
+ clipboardBuffer(m_clipboardType), mimeTypeTextURIList, ignoredData, urlTitle);
+ return urlTitle;
}
-String ReadableDataObject::getHTML(String* baseURL) const
+KURL ReadableDataObject::htmlBaseUrl() const
{
- String html;
- String ignoredBaseURL;
- if (!baseURL)
- baseURL = &ignoredBaseURL;
+ String ignoredData;
+ String htmlBaseUrl;
ChromiumBridge::clipboardReadData(
- clipboardBuffer(m_isForDragging), textHtmlType, html, *baseURL);
- return html;
+ clipboardBuffer(m_clipboardType), mimeTypeTextHTML, ignoredData, htmlBaseUrl);
+ return KURL(ParsedURLString, htmlBaseUrl);
}
-bool ReadableDataObject::hasFilenames() const
+bool ReadableDataObject::containsFilenames() const
{
ensureTypeCacheInitialized();
return m_containsFilenames;
@@ -104,7 +123,7 @@ bool ReadableDataObject::hasFilenames() const
Vector<String> ReadableDataObject::filenames() const
{
- return ChromiumBridge::clipboardReadFilenames(clipboardBuffer(m_isForDragging));
+ return ChromiumBridge::clipboardReadFilenames(clipboardBuffer(m_clipboardType));
}
void ReadableDataObject::ensureTypeCacheInitialized() const
@@ -113,7 +132,7 @@ void ReadableDataObject::ensureTypeCacheInitialized() const
return;
m_types = ChromiumBridge::clipboardReadAvailableTypes(
- clipboardBuffer(m_isForDragging), &m_containsFilenames);
+ clipboardBuffer(m_clipboardType), &m_containsFilenames);
m_isTypeCacheInitialized = true;
}
diff --git a/WebCore/platform/chromium/ReadableDataObject.h b/WebCore/platform/chromium/ReadableDataObject.h
index 60f6d45..027e0ed 100644
--- a/WebCore/platform/chromium/ReadableDataObject.h
+++ b/WebCore/platform/chromium/ReadableDataObject.h
@@ -31,6 +31,7 @@
#ifndef ReadableDataObject_h
#define ReadableDataObject_h
+#include "Clipboard.h"
#include "PlatformString.h"
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
@@ -43,26 +44,25 @@ namespace WebCore {
// browser to the renderer.
class ReadableDataObject : public RefCounted<ReadableDataObject> {
public:
- static PassRefPtr<ReadableDataObject> create(bool isForDragging);
+ static PassRefPtr<ReadableDataObject> create(Clipboard::ClipboardType);
- virtual bool hasData() const;
- virtual HashSet<String> types() const;
- virtual String getData(const String& type, bool& succeeded) const;
+ bool hasData() const;
+ HashSet<String> types() const;
+ String getData(const String& type, bool& succeeded) const;
- virtual String getURL(String* title) const;
- virtual String getHTML(String* baseURL) const;
+ String urlTitle() const;
+ KURL htmlBaseUrl() const;
- virtual bool hasFilenames() const;
- virtual Vector<String> filenames() const;
+ bool containsFilenames() const;
+ Vector<String> filenames() const;
private:
- explicit ReadableDataObject(bool isForDragging);
+ explicit ReadableDataObject(Clipboard::ClipboardType);
// This isn't always const... but most of the time it is.
void ensureTypeCacheInitialized() const;
-
- bool m_isForDragging;
+ Clipboard::ClipboardType m_clipboardType;
// To avoid making a lot of IPC calls for each drag event, we cache some
// values in the renderer.
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromium.cpp b/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
index cf3ca6f..234d0ee 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
+++ b/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
@@ -131,7 +131,7 @@ void ScrollbarThemeChromium::paintTickmarks(GraphicsContext* context, Scrollbar*
const int yPos = rect.topLeft().y() + (rect.height() * percent);
IntPoint tick(scrollbar->x(), yPos);
- context->drawImage(dash.get(), DeviceColorSpace, tick);
+ context->drawImage(dash.get(), ColorSpaceDeviceRGB, tick);
}
context->restore();
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
index d8f2c79..46e6993 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
+++ b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
@@ -31,17 +31,12 @@
#include "config.h"
#include "ScrollbarThemeChromiumLinux.h"
-#include "PlatformContextSkia.h"
+#include "ChromiumBridge.h"
#include "PlatformMouseEvent.h"
-#include "PlatformThemeChromiumGtk.h"
#include "Scrollbar.h"
-#include "TransformationMatrix.h"
namespace WebCore {
-static const int scrollbarThicknessValue = 15;
-static const int buttonLength = 14;
-
ScrollbarTheme* ScrollbarTheme::nativeTheme()
{
static ScrollbarThemeChromiumLinux theme;
@@ -50,136 +45,79 @@ ScrollbarTheme* ScrollbarTheme::nativeTheme()
int ScrollbarThemeChromiumLinux::scrollbarThickness(ScrollbarControlSize controlSize)
{
- return scrollbarThicknessValue;
-}
-
-static void drawVertLine(SkCanvas* canvas, int x, int y1, int y2, const SkPaint& paint)
-{
- SkIRect skrect;
- skrect.set(x, y1, x + 1, y2 + 1);
- canvas->drawIRect(skrect, paint);
-}
-
-static void drawHorizLine(SkCanvas* canvas, int x1, int x2, int y, const SkPaint& paint)
-{
- SkIRect skrect;
- skrect.set(x1, y, x2 + 1, y + 1);
- canvas->drawIRect(skrect, paint);
-}
-
-static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint)
-{
- const int right = rect.x() + rect.width() - 1;
- const int bottom = rect.y() + rect.height() - 1;
- drawHorizLine(canvas, rect.x(), right, rect.y(), paint);
- drawVertLine(canvas, right, rect.y(), bottom, paint);
- drawHorizLine(canvas, rect.x(), right, bottom, paint);
- drawVertLine(canvas, rect.x(), rect.y(), bottom, paint);
+ // Horiz and Vert scrollbars are the same thickness.
+ IntSize scrollbarSize = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarVerticalTrack);
+ return scrollbarSize.width();
}
void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType)
{
- SkCanvas* const canvas = gc->platformContext()->canvas();
- SkPaint paint;
- SkIRect skrect;
-
- skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
- SkScalar trackHSV[3];
- SkColorToHSV(PlatformThemeChromiumGtk::trackColor(), trackHSV);
- paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(trackHSV, 0, 0));
- canvas->drawIRect(skrect, paint);
-
- SkScalar thumbHSV[3];
- SkColorToHSV(PlatformThemeChromiumGtk::thumbInactiveColor(),
- thumbHSV);
-
- paint.setColor(PlatformThemeChromiumGtk::outlineColor(trackHSV, thumbHSV));
- drawBox(canvas, rect, paint);
+ ChromiumBridge::ThemePaintState state = scrollbar->hoveredPart() == partType ? ChromiumBridge::StateHover : ChromiumBridge::StateNormal;
+ IntRect alignRect = trackRect(scrollbar, false);
+ ChromiumBridge::ThemePaintExtraParams extraParams;
+ extraParams.scrollbarTrack.trackX = alignRect.x();
+ extraParams.scrollbarTrack.trackY = alignRect.y();
+ extraParams.scrollbarTrack.trackWidth = alignRect.width();
+ extraParams.scrollbarTrack.trackHeight = alignRect.height();
+ ChromiumBridge::paintThemePart(
+ gc,
+ scrollbar->orientation() == HorizontalScrollbar ? ChromiumBridge::PartScrollbarHoriztonalTrack : ChromiumBridge::PartScrollbarVerticalTrack,
+ state,
+ rect,
+ &extraParams);
}
void ScrollbarThemeChromiumLinux::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
{
- PlatformThemeChromiumGtk::ArrowDirection direction;
+ ChromiumBridge::ThemePart paintPart;
+ ChromiumBridge::ThemePaintState state = ChromiumBridge::StateNormal;
+ bool checkMin = false;
+ bool checkMax = false;
if (scrollbar->orientation() == HorizontalScrollbar) {
- if (part == BackButtonStartPart)
- direction = PlatformThemeChromiumGtk::West;
- else
- direction = PlatformThemeChromiumGtk::East;
+ if (part == BackButtonStartPart) {
+ paintPart = ChromiumBridge::PartScrollbarLeftArrow;
+ checkMin = true;
+ } else {
+ paintPart = ChromiumBridge::PartScrollbarRightArrow;
+ checkMax = true;
+ }
} else {
- if (part == BackButtonStartPart)
- direction = PlatformThemeChromiumGtk::North;
- else
- direction = PlatformThemeChromiumGtk::South;
+ if (part == BackButtonStartPart) {
+ paintPart = ChromiumBridge::PartScrollbarUpArrow;
+ checkMin = true;
+ } else {
+ paintPart = ChromiumBridge::PartScrollbarDownArrow;
+ checkMax = true;
+ }
}
-
- ControlStates states = 0;
- // Determine if the button can be pressed.
- if (((direction == PlatformThemeChromiumGtk::West || direction == PlatformThemeChromiumGtk::North) && scrollbar->currentPos())
- || ((direction == PlatformThemeChromiumGtk::East || direction == PlatformThemeChromiumGtk::South) && scrollbar->currentPos() != scrollbar->maximum()))
- states |= EnabledState;
-
- if (states & EnabledState) {
+ if ((checkMin && (scrollbar->currentPos() <= 0))
+ || (checkMax && scrollbar->currentPos() == scrollbar->maximum())) {
+ state = ChromiumBridge::StateDisabled;
+ } else {
if (part == scrollbar->pressedPart())
- states |= PressedState;
+ state = ChromiumBridge::StatePressed;
else if (part == scrollbar->hoveredPart())
- states |= HoverState;
+ state = ChromiumBridge::StateHover;
}
-
- PlatformThemeChromiumGtk::paintArrowButton(gc, rect, direction, states);
+ ChromiumBridge::paintThemePart(gc, paintPart, state, rect, 0);
}
void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect)
{
- const bool hovered = scrollbar->hoveredPart() == ThumbPart;
- const int midx = rect.x() + rect.width() / 2;
- const int midy = rect.y() + rect.height() / 2;
- const bool vertical = scrollbar->orientation() == VerticalScrollbar;
- SkCanvas* const canvas = gc->platformContext()->canvas();
-
- SkScalar thumb[3];
- SkColorToHSV(hovered
- ? PlatformThemeChromiumGtk::thumbActiveColor()
- : PlatformThemeChromiumGtk::thumbInactiveColor(),
- thumb);
-
- SkPaint paint;
- paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, 0.02));
-
- SkIRect skrect;
- if (vertical)
- skrect.set(rect.x(), rect.y(), midx + 1, rect.y() + rect.height());
- else
- skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), midy + 1);
-
- canvas->drawIRect(skrect, paint);
-
- paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, -0.02));
+ ChromiumBridge::ThemePaintState state;
- if (vertical)
- skrect.set(midx + 1, rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
+ if (scrollbar->pressedPart() == ThumbPart)
+ state = ChromiumBridge::StatePressed;
+ else if (scrollbar->hoveredPart() == ThumbPart)
+ state = ChromiumBridge::StateHover;
else
- skrect.set(rect.x(), midy + 1, rect.x() + rect.width(), rect.y() + rect.height());
-
- canvas->drawIRect(skrect, paint);
-
- SkScalar track[3];
- SkColorToHSV(PlatformThemeChromiumGtk::trackColor(), track);
- paint.setColor(PlatformThemeChromiumGtk::outlineColor(track, thumb));
- drawBox(canvas, rect, paint);
-
- if (rect.height() > 10 && rect.width() > 10) {
- const int grippyHalfWidth = 2;
- const int interGrippyOffset = 3;
- if (vertical) {
- drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy - interGrippyOffset, paint);
- drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy, paint);
- drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy + interGrippyOffset, paint);
- } else {
- drawVertLine(canvas, midx - interGrippyOffset, midy - grippyHalfWidth, midy + grippyHalfWidth, paint);
- drawVertLine(canvas, midx, midy - grippyHalfWidth, midy + grippyHalfWidth, paint);
- drawVertLine(canvas, midx + interGrippyOffset, midy - grippyHalfWidth, midy + grippyHalfWidth, paint);
- }
- }
+ state = ChromiumBridge::StateNormal;
+ ChromiumBridge::paintThemePart(
+ gc,
+ scrollbar->orientation() == HorizontalScrollbar ? ChromiumBridge::PartScrollbarHorizontalThumb : ChromiumBridge::PartScrollbarVerticalThumb,
+ state,
+ rect,
+ 0);
}
bool ScrollbarThemeChromiumLinux::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
@@ -189,17 +127,25 @@ bool ScrollbarThemeChromiumLinux::shouldCenterOnThumb(Scrollbar*, const Platform
IntSize ScrollbarThemeChromiumLinux::buttonSize(Scrollbar* scrollbar)
{
- if (scrollbar->orientation() == VerticalScrollbar)
- return IntSize(scrollbarThicknessValue, buttonLength);
+ if (scrollbar->orientation() == VerticalScrollbar) {
+ IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarUpArrow);
+ return IntSize(size.width(), scrollbar->height() < 2 * size.height() ? scrollbar->height() / 2 : size.height());
+ }
// HorizontalScrollbar
- return IntSize(buttonLength, scrollbarThicknessValue);
+ IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarLeftArrow);
+ return IntSize(scrollbar->width() < 2 * size.width() ? scrollbar->width() / 2 : size.width(), size.height());
}
int ScrollbarThemeChromiumLinux::minimumThumbLength(Scrollbar* scrollbar)
{
- // This matches Firefox on Linux.
- return 2 * scrollbarThickness(scrollbar->controlSize());
+ if (scrollbar->orientation() == VerticalScrollbar) {
+ IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarVerticalThumb);
+ return size.height();
+ }
+
+ IntSize size = ChromiumBridge::getThemePartSize(ChromiumBridge::PartScrollbarHorizontalThumb);
+ return size.width();
}
} // namespace WebCore
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm b/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
index bafc96e..b47e998 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
+++ b/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
@@ -417,8 +417,8 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
if (scrollbar->orientation() == VerticalScrollbar && tickmarks.size()) {
drawingContext->save();
drawingContext->setShouldAntialias(false);
- drawingContext->setStrokeColor(Color(0xCC, 0xAA, 0x00, 0xFF), DeviceColorSpace);
- drawingContext->setFillColor(Color(0xFF, 0xDD, 0x00, 0xFF), DeviceColorSpace);
+ drawingContext->setStrokeColor(Color(0xCC, 0xAA, 0x00, 0xFF), ColorSpaceDeviceRGB);
+ drawingContext->setFillColor(Color(0xFF, 0xDD, 0x00, 0xFF), ColorSpaceDeviceRGB);
IntRect thumbArea = trackRect(scrollbar, false);
if (!canDrawDirectly) {
@@ -453,7 +453,7 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con
}
if (!canDrawDirectly)
- context->drawImageBuffer(imageBuffer.get(), DeviceColorSpace, scrollbar->frameRect().location());
+ context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, scrollbar->frameRect().location());
return true;
}
diff --git a/WebCore/platform/chromium/ThemeChromiumMac.mm b/WebCore/platform/chromium/ThemeChromiumMac.mm
index 68fd7b7..5e457f3 100644
--- a/WebCore/platform/chromium/ThemeChromiumMac.mm
+++ b/WebCore/platform/chromium/ThemeChromiumMac.mm
@@ -376,6 +376,7 @@ static void paintCheckbox(ControlStates states, GraphicsContext* context, const
// Determine the width and height needed for the control and prepare the cell for painting.
NSButtonCell *checkboxCell = checkbox(states, zoomedRect, zoomFactor);
+ LocalCurrentGraphicsContext localContext(context);
context->save();
@@ -456,6 +457,7 @@ static void paintRadio(ControlStates states, GraphicsContext* context, const Int
{
// Determine the width and height needed for the control and prepare the cell for painting.
NSButtonCell *radioCell = radio(states, zoomedRect, zoomFactor);
+ LocalCurrentGraphicsContext localContext(context);
context->save();
diff --git a/WebCore/platform/chromium/WritableDataObject.cpp b/WebCore/platform/chromium/WritableDataObject.cpp
index 6e7c283..7cbf42c 100644
--- a/WebCore/platform/chromium/WritableDataObject.cpp
+++ b/WebCore/platform/chromium/WritableDataObject.cpp
@@ -36,22 +36,22 @@
namespace WebCore {
-PassRefPtr<WritableDataObject> WritableDataObject::create(bool isForDragging)
+PassRefPtr<WritableDataObject> WritableDataObject::create(Clipboard::ClipboardType clipboardType)
{
- return adoptRef(new WritableDataObject(isForDragging));
+ return adoptRef(new WritableDataObject(clipboardType));
}
-WritableDataObject::WritableDataObject(bool isForDragging)
- : m_isForDragging(isForDragging)
+WritableDataObject::WritableDataObject(Clipboard::ClipboardType clipboardType)
+ : m_clipboardType(clipboardType)
{
}
void WritableDataObject::clearData(const String& type)
{
m_dataMap.remove(type);
- if (type == textUriListType)
+ if (type == mimeTypeTextURIList)
m_urlTitle = "";
- else if (type == textHtmlType)
+ else if (type == mimeTypeTextHTML)
m_htmlBaseURL = KURL();
}
@@ -76,77 +76,19 @@ void WritableDataObject::clearAll()
bool WritableDataObject::setData(const String& type, const String& data)
{
- if (!m_isForDragging) {
+ if (m_clipboardType == Clipboard::CopyAndPaste) {
+ // FIXME: This is currently unimplemented on the Chromium-side. This is
+ // "okay" for now since the original implementation didn't support it
+ // anyway. Going forward, this is something we'll need to fix though.
ChromiumBridge::clipboardWriteData(type, data, "");
return true;
}
m_dataMap.set(type, data);
- if (type == textUriListType)
+ if (type == mimeTypeTextURIList)
m_urlTitle = "";
- else if (type == textHtmlType)
+ else if (type == mimeTypeTextHTML)
m_htmlBaseURL = KURL();
return true;
}
-void WritableDataObject::setURL(const String& url, const String& title)
-{
- setData(textUriListType, url);
- m_urlTitle = title;
-}
-
-void WritableDataObject::setHTML(const String& html, const KURL& baseURL)
-{
- setData(textHtmlType, html);
- m_htmlBaseURL = baseURL;
-}
-
-// Accessors used when transferring drag data from the renderer to the
-// browser.
-HashMap<String, String> WritableDataObject::dataMap() const
-{
- return m_dataMap;
-}
-
-String WritableDataObject::urlTitle() const
-{
- return m_urlTitle;
-}
-
-KURL WritableDataObject::htmlBaseURL() const
-{
- return m_htmlBaseURL;
-}
-
-// Used for transferring file data from the renderer to the browser.
-String WritableDataObject::fileExtension() const
-{
- return m_fileExtension;
-}
-
-String WritableDataObject::fileContentFilename() const
-{
- return m_fileContentFilename;
-}
-
-PassRefPtr<SharedBuffer> WritableDataObject::fileContent() const
-{
- return m_fileContent;
-}
-
-void WritableDataObject::setFileExtension(const String& fileExtension)
-{
- m_fileExtension = fileExtension;
-}
-
-void WritableDataObject::setFileContentFilename(const String& fileContentFilename)
-{
- m_fileContentFilename = fileContentFilename;
-}
-
-void WritableDataObject::setFileContent(PassRefPtr<SharedBuffer> fileContent)
-{
- m_fileContent = fileContent;
-}
-
-
} // namespace WebCore
diff --git a/WebCore/platform/chromium/WritableDataObject.h b/WebCore/platform/chromium/WritableDataObject.h
index 71e2e26..c475d15 100644
--- a/WebCore/platform/chromium/WritableDataObject.h
+++ b/WebCore/platform/chromium/WritableDataObject.h
@@ -31,6 +31,7 @@
#ifndef WritableDataObject_h
#define WritableDataObject_h
+#include "Clipboard.h"
#include "KURL.h"
#include "PlatformString.h"
#include "SharedBuffer.h"
@@ -47,32 +48,32 @@ namespace WebCore {
// atomically.
class WritableDataObject : public RefCounted<WritableDataObject> {
public:
- static PassRefPtr<WritableDataObject> create(bool isForDragging);
+ static PassRefPtr<WritableDataObject> create(Clipboard::ClipboardType);
- virtual void clearData(const String& type);
- virtual void clearAllExceptFiles();
- virtual void clearAll();
- virtual bool setData(const String& type, const String& data);
+ void clearData(const String& type);
+ void clearAllExceptFiles();
+ void clearAll();
+ bool setData(const String& type, const String& data);
- virtual void setURL(const String& url, const String& title);
- virtual void setHTML(const String& html, const KURL& baseURL);
+ void setUrlTitle(const String& title) { m_urlTitle = title; }
+ void setHtmlBaseUrl(const KURL& baseURL) { m_htmlBaseURL = baseURL; }
// Used for transferring drag data from the renderer to the browser.
- virtual HashMap<String, String> dataMap() const;
- virtual String urlTitle() const;
- virtual KURL htmlBaseURL() const;
+ HashMap<String, String> dataMap() const { return m_dataMap; }
+ String urlTitle() const { return m_urlTitle; }
+ KURL htmlBaseURL() const { return m_htmlBaseURL; }
- virtual String fileExtension() const;
- virtual String fileContentFilename() const;
- virtual PassRefPtr<SharedBuffer> fileContent() const;
- virtual void setFileExtension(const String&);
- virtual void setFileContentFilename(const String&);
- virtual void setFileContent(PassRefPtr<SharedBuffer>);
+ String fileExtension() const { return m_fileExtension; }
+ String fileContentFilename() const { return m_fileContentFilename; }
+ PassRefPtr<SharedBuffer> fileContent() const { return m_fileContent; }
+ void setFileExtension(const String& fileExtension) { m_fileExtension = fileExtension; }
+ void setFileContentFilename(const String& fileContentFilename) { m_fileContentFilename = fileContentFilename; }
+ void setFileContent(PassRefPtr<SharedBuffer> fileContent) { m_fileContent = fileContent; }
private:
- explicit WritableDataObject(bool isForDragging);
+ explicit WritableDataObject(Clipboard::ClipboardType);
- bool m_isForDragging;
+ Clipboard::ClipboardType m_clipboardType;
HashMap<String, String> m_dataMap;
String m_urlTitle;