diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/chromium | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/chromium')
19 files changed, 382 insertions, 230 deletions
diff --git a/Source/WebCore/platform/chromium/ChromiumDataObject.cpp b/Source/WebCore/platform/chromium/ChromiumDataObject.cpp index f5732df..c3632e6 100644 --- a/Source/WebCore/platform/chromium/ChromiumDataObject.cpp +++ b/Source/WebCore/platform/chromium/ChromiumDataObject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Google Inc. All rights reserved. + * 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 @@ -31,189 +31,235 @@ #include "config.h" #include "ChromiumDataObject.h" +#include "ClipboardMimeTypes.h" +#include "Pasteboard.h" +#include "PlatformBridge.h" + namespace WebCore { -ChromiumDataObject::ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy> data) - : RefCounted<ChromiumDataObject>() - , m_legacyData(data) -{ -} +// Per RFC 2483, the line separator for "text/..." MIME types is CR-LF. +static char const* const textMIMETypeLineSeparator = "\r\n"; -ChromiumDataObject::ChromiumDataObject(PassRefPtr<ReadableDataObject> data) - : RefCounted<ChromiumDataObject>() - , m_readableData(data) +void ChromiumDataObject::clearData(const String& type) { -} + if (type == mimeTypeTextPlain) { + m_plainText = ""; + return; + } -ChromiumDataObject::ChromiumDataObject(PassRefPtr<WritableDataObject> data) - : RefCounted<ChromiumDataObject>() - , m_writableData(data) -{ -} + if (type == mimeTypeURL || type == mimeTypeTextURIList) { + m_uriList = ""; + m_url = KURL(); + m_urlTitle = ""; + return; + } -PassRefPtr<ChromiumDataObject> ChromiumDataObject::create(PassRefPtr<ChromiumDataObjectLegacy> data) -{ - return adoptRef(new ChromiumDataObject(data)); -} + if (type == mimeTypeTextHTML) { + m_textHtml = ""; + m_htmlBaseUrl = KURL(); + return; + } -PassRefPtr<ChromiumDataObject> ChromiumDataObject::createReadable(const Frame* frame, Clipboard::ClipboardType clipboardType) -{ - return adoptRef(new ChromiumDataObject(ReadableDataObject::create(frame, 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); + if (type == mimeTypeDownloadURL) { + m_downloadMetadata = ""; + return; + } } void ChromiumDataObject::clearAll() { - if (m_legacyData) - m_legacyData->clearAll(); - else - m_writableData->clearAll(); + clearAllExceptFiles(); + m_filenames.clear(); } void ChromiumDataObject::clearAllExceptFiles() { - if (m_legacyData) - m_legacyData->clearAllExceptFiles(); - else - m_writableData->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 ChromiumDataObject::hasData() const { - if (m_legacyData) - return m_legacyData->hasData(); - return m_readableData->hasData(); + 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> ChromiumDataObject::types() const { - if (m_legacyData) - return m_legacyData->types(); - return m_readableData->types(); -} + if (m_clipboardType == Clipboard::CopyAndPaste) { + bool ignoredContainsFilenames; + return PlatformBridge::clipboardReadAvailableTypes(PasteboardPrivate::StandardBuffer, + &ignoredContainsFilenames); + } -String ChromiumDataObject::getData(const String& type, bool& success) -{ - if (m_legacyData) - return m_legacyData->getData(type, success); - return m_readableData->getData(type, success); -} + HashSet<String> results; -bool ChromiumDataObject::setData(const String& type, const String& data) -{ - if (m_legacyData) - return m_legacyData->setData(type, data); - return m_writableData->setData(type, data); -} + if (!m_plainText.isEmpty()) { + results.add(mimeTypeText); + results.add(mimeTypeTextPlain); + } -String ChromiumDataObject::urlTitle() const -{ - if (m_legacyData) - return m_legacyData->urlTitle(); - return m_readableData->urlTitle(); -} + if (m_url.isValid()) + results.add(mimeTypeURL); -void ChromiumDataObject::setUrlTitle(const String& urlTitle) -{ - if (m_legacyData) - m_legacyData->setUrlTitle(urlTitle); - else - m_writableData->setUrlTitle(urlTitle); -} + if (!m_uriList.isEmpty()) + results.add(mimeTypeTextURIList); -KURL ChromiumDataObject::htmlBaseUrl() const -{ - if (m_legacyData) - return m_legacyData->htmlBaseUrl(); - return m_readableData->htmlBaseUrl(); -} + if (!m_textHtml.isEmpty()) + results.add(mimeTypeTextHTML); -void ChromiumDataObject::setHtmlBaseUrl(const KURL& url) -{ - if (m_legacyData) - m_legacyData->setHtmlBaseUrl(url); - else - m_writableData->setHtmlBaseUrl(url); + return results; } -bool ChromiumDataObject::containsFilenames() const +String ChromiumDataObject::getData(const String& type, bool& success) { - if (m_legacyData) - return m_legacyData->containsFilenames(); - return m_readableData->containsFilenames(); -} + if (type == mimeTypeTextPlain) { + if (m_clipboardType == Clipboard::CopyAndPaste) { + PasteboardPrivate::ClipboardBuffer buffer = + Pasteboard::generalPasteboard()->isSelectionMode() ? + PasteboardPrivate::SelectionBuffer : + PasteboardPrivate::StandardBuffer; + String text = PlatformBridge::clipboardReadPlainText(buffer); + success = !text.isEmpty(); + return text; + } + success = !m_plainText.isEmpty(); + return m_plainText; + } -Vector<String> ChromiumDataObject::filenames() const -{ - if (m_legacyData) - return m_legacyData->filenames(); - return m_readableData->filenames(); -} + if (type == mimeTypeURL) { + success = !m_url.isEmpty(); + return m_url.string(); + } -void ChromiumDataObject::setFilenames(const Vector<String>& filenames) -{ - if (m_legacyData) - m_legacyData->setFilenames(filenames); - else - ASSERT_NOT_REACHED(); -} + if (type == mimeTypeTextURIList) { + success = !m_uriList.isEmpty(); + return m_uriList; + } -String ChromiumDataObject::fileExtension() const -{ - if (m_legacyData) - return m_legacyData->fileExtension(); - return m_writableData->fileExtension(); -} + if (type == mimeTypeTextHTML) { + if (m_clipboardType == Clipboard::CopyAndPaste) { + PasteboardPrivate::ClipboardBuffer buffer = + Pasteboard::generalPasteboard()->isSelectionMode() ? + PasteboardPrivate::SelectionBuffer : + PasteboardPrivate::StandardBuffer; + String htmlText; + KURL sourceURL; + PlatformBridge::clipboardReadHTML(buffer, &htmlText, &sourceURL); + success = !htmlText.isEmpty(); + return htmlText; + } + success = !m_textHtml.isEmpty(); + return m_textHtml; + } -void ChromiumDataObject::setFileExtension(const String& fileExtension) -{ - if (m_legacyData) - m_legacyData->setFileExtension(fileExtension); - else - m_writableData->setFileExtension(fileExtension); + if (type == mimeTypeDownloadURL) { + success = !m_downloadMetadata.isEmpty(); + return m_downloadMetadata; + } + + success = false; + return String(); } -String ChromiumDataObject::fileContentFilename() const +bool ChromiumDataObject::setData(const String& type, const String& data) { - if (m_legacyData) - return m_legacyData->fileContentFilename(); - return m_writableData->fileContentFilename(); + 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; } -void ChromiumDataObject::setFileContentFilename(const String& fileContentFilename) +bool ChromiumDataObject::containsFilenames() const { - if (m_legacyData) - m_legacyData->setFileContentFilename(fileContentFilename); - else - m_writableData->setFileContentFilename(fileContentFilename); + bool containsFilenames; + if (m_clipboardType == Clipboard::CopyAndPaste) { + HashSet<String> ignoredResults = + PlatformBridge::clipboardReadAvailableTypes(PasteboardPrivate::StandardBuffer, + &containsFilenames); + } else + containsFilenames = !m_filenames.isEmpty(); + return containsFilenames; } -PassRefPtr<SharedBuffer> ChromiumDataObject::fileContent() const +ChromiumDataObject::ChromiumDataObject(Clipboard::ClipboardType clipboardType) + : m_clipboardType(clipboardType) { - if (m_legacyData) - return m_legacyData->fileContent(); - return m_writableData->fileContent(); } -void ChromiumDataObject::setFileContent(PassRefPtr<SharedBuffer> fileContent) +ChromiumDataObject::ChromiumDataObject(const ChromiumDataObject& other) + : RefCounted<ChromiumDataObject>() + , 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 (m_legacyData) - m_legacyData->setFileContent(fileContent); - else - m_writableData->setFileContent(fileContent); + if (other.m_fileContent.get()) + m_fileContent = other.m_fileContent->copy(); } -} +} // namespace WebCore diff --git a/Source/WebCore/platform/chromium/ChromiumDataObject.h b/Source/WebCore/platform/chromium/ChromiumDataObject.h index 919c269..ee79bfe 100644 --- a/Source/WebCore/platform/chromium/ChromiumDataObject.h +++ b/Source/WebCore/platform/chromium/ChromiumDataObject.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Google Inc. All rights reserved. + * 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 @@ -31,18 +31,31 @@ #ifndef ChromiumDataObject_h #define ChromiumDataObject_h -#include "ChromiumDataObjectLegacy.h" -#include "ReadableDataObject.h" -#include "WritableDataObject.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 ChromiumDataObject : public RefCounted<ChromiumDataObject> { public: - static PassRefPtr<ChromiumDataObject> create(PassRefPtr<ChromiumDataObjectLegacy> data); - static PassRefPtr<ChromiumDataObject> createReadable(const Frame*, Clipboard::ClipboardType); - static PassRefPtr<ChromiumDataObject> createWritable(Clipboard::ClipboardType); + static PassRefPtr<ChromiumDataObject> create(Clipboard::ClipboardType clipboardType) + { + return adoptRef(new ChromiumDataObject(clipboardType)); + } + + PassRefPtr<ChromiumDataObject> copy() const + { + return adoptRef(new ChromiumDataObject(*this)); + } void clearData(const String& type); void clearAll(); @@ -55,34 +68,53 @@ public: 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); + 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; - Vector<String> filenames() const; - void setFilenames(const Vector<String>& filenames); + 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; - void setFileExtension(const String& fileExtension); - String fileContentFilename() const; - void setFileContentFilename(const String& fileContentFilename); - PassRefPtr<SharedBuffer> fileContent() const; - void setFileContent(PassRefPtr<SharedBuffer> fileContent); + 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: - ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy>); - ChromiumDataObject(PassRefPtr<ReadableDataObject>); - ChromiumDataObject(PassRefPtr<WritableDataObject>); + ChromiumDataObject(Clipboard::ClipboardType); + ChromiumDataObject(const ChromiumDataObject&); + + Clipboard::ClipboardType m_clipboardType; + + String m_urlTitle; + + String m_downloadMetadata; + + String m_fileExtension; + Vector<String> m_filenames; - RefPtr<ChromiumDataObjectLegacy> m_legacyData; - RefPtr<ReadableDataObject> m_readableData; - RefPtr<WritableDataObject> m_writableData; + 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/Source/WebCore/platform/chromium/ClipboardChromium.cpp b/Source/WebCore/platform/chromium/ClipboardChromium.cpp index d6ba2d2..7e58f03 100644 --- a/Source/WebCore/platform/chromium/ClipboardChromium.cpp +++ b/Source/WebCore/platform/chromium/ClipboardChromium.cpp @@ -85,16 +85,6 @@ 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(frame, clipboardType); - return adoptRef(new ClipboardChromium(clipboardType, dataObject, policy, frame)); -} - void ClipboardChromium::clearData(const String& type) { if (policy() != ClipboardWritable || !m_dataObject) @@ -142,6 +132,9 @@ HashSet<String> ClipboardChromium::types() const results = m_dataObject->types(); + if (m_dataObject->containsFilenames()) + results.add(mimeTypeFiles); + return results; } diff --git a/Source/WebCore/platform/chromium/ClipboardChromium.h b/Source/WebCore/platform/chromium/ClipboardChromium.h index d5ada14..d30a1c4 100644 --- a/Source/WebCore/platform/chromium/ClipboardChromium.h +++ b/Source/WebCore/platform/chromium/ClipboardChromium.h @@ -49,9 +49,6 @@ 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/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp b/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp index f689e0e..27e68ff 100644 --- a/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp +++ b/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp @@ -40,5 +40,6 @@ const char mimeTypeTextHTML[] = "text/html"; const char mimeTypeURL[] = "url"; const char mimeTypeTextURIList[] = "text/uri-list"; const char mimeTypeDownloadURL[] = "downloadurl"; +const char mimeTypeFiles[] = "Files"; } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/ClipboardMimeTypes.h b/Source/WebCore/platform/chromium/ClipboardMimeTypes.h index 9bdccfe..31e2d3e 100644 --- a/Source/WebCore/platform/chromium/ClipboardMimeTypes.h +++ b/Source/WebCore/platform/chromium/ClipboardMimeTypes.h @@ -40,6 +40,7 @@ extern const char mimeTypeTextHTML[]; extern const char mimeTypeURL[]; extern const char mimeTypeTextURIList[]; extern const char mimeTypeDownloadURL[]; +extern const char mimeTypeFiles[]; } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/CursorChromium.cpp b/Source/WebCore/platform/chromium/CursorChromium.cpp index 0119f07..1f9d7cb 100644 --- a/Source/WebCore/platform/chromium/CursorChromium.cpp +++ b/Source/WebCore/platform/chromium/CursorChromium.cpp @@ -31,6 +31,8 @@ #include "config.h" #include "Cursor.h" +#include <wtf/Assertions.h> + namespace WebCore { Cursor::Cursor(const Cursor& other) @@ -306,12 +308,62 @@ const Cursor& zoomOutCursor() const Cursor& grabCursor() { - return pointerCursor(); + static const Cursor c(PlatformCursor::TypeGrab); + return c; } const Cursor& grabbingCursor() { - return pointerCursor(); + static const Cursor c(PlatformCursor::TypeGrabbing); + return c; } } // namespace WebCore + +#define COMPILE_ASSERT_MATCHING_ENUM(cursor_name, platform_cursor_name) \ + COMPILE_ASSERT(int(WebCore::Cursor::cursor_name) == int(WebCore::PlatformCursor::platform_cursor_name), mismatching_enums) + +COMPILE_ASSERT_MATCHING_ENUM(Pointer, TypePointer); +COMPILE_ASSERT_MATCHING_ENUM(Cross, TypeCross); +COMPILE_ASSERT_MATCHING_ENUM(Hand, TypeHand); +COMPILE_ASSERT_MATCHING_ENUM(IBeam, TypeIBeam); +COMPILE_ASSERT_MATCHING_ENUM(Wait, TypeWait); +COMPILE_ASSERT_MATCHING_ENUM(Help, TypeHelp); +COMPILE_ASSERT_MATCHING_ENUM(EastResize, TypeEastResize); +COMPILE_ASSERT_MATCHING_ENUM(NorthResize, TypeNorthResize); +COMPILE_ASSERT_MATCHING_ENUM(NorthEastResize, TypeNorthEastResize); +COMPILE_ASSERT_MATCHING_ENUM(NorthWestResize, TypeNorthWestResize); +COMPILE_ASSERT_MATCHING_ENUM(SouthResize, TypeSouthResize); +COMPILE_ASSERT_MATCHING_ENUM(SouthEastResize, TypeSouthEastResize); +COMPILE_ASSERT_MATCHING_ENUM(SouthWestResize, TypeSouthWestResize); +COMPILE_ASSERT_MATCHING_ENUM(WestResize, TypeWestResize); +COMPILE_ASSERT_MATCHING_ENUM(NorthSouthResize, TypeNorthSouthResize); +COMPILE_ASSERT_MATCHING_ENUM(EastWestResize, TypeEastWestResize); +COMPILE_ASSERT_MATCHING_ENUM(NorthEastSouthWestResize, TypeNorthEastSouthWestResize); +COMPILE_ASSERT_MATCHING_ENUM(NorthWestSouthEastResize, TypeNorthWestSouthEastResize); +COMPILE_ASSERT_MATCHING_ENUM(ColumnResize, TypeColumnResize); +COMPILE_ASSERT_MATCHING_ENUM(RowResize, TypeRowResize); +COMPILE_ASSERT_MATCHING_ENUM(MiddlePanning, TypeMiddlePanning); +COMPILE_ASSERT_MATCHING_ENUM(EastPanning, TypeEastPanning); +COMPILE_ASSERT_MATCHING_ENUM(NorthPanning, TypeNorthPanning); +COMPILE_ASSERT_MATCHING_ENUM(NorthEastPanning, TypeNorthEastPanning); +COMPILE_ASSERT_MATCHING_ENUM(NorthWestPanning, TypeNorthWestPanning); +COMPILE_ASSERT_MATCHING_ENUM(SouthPanning, TypeSouthPanning); +COMPILE_ASSERT_MATCHING_ENUM(SouthEastPanning, TypeSouthEastPanning); +COMPILE_ASSERT_MATCHING_ENUM(SouthWestPanning, TypeSouthWestPanning); +COMPILE_ASSERT_MATCHING_ENUM(WestPanning, TypeWestPanning); +COMPILE_ASSERT_MATCHING_ENUM(Move, TypeMove); +COMPILE_ASSERT_MATCHING_ENUM(VerticalText, TypeVerticalText); +COMPILE_ASSERT_MATCHING_ENUM(Cell, TypeCell); +COMPILE_ASSERT_MATCHING_ENUM(ContextMenu, TypeContextMenu); +COMPILE_ASSERT_MATCHING_ENUM(Alias, TypeAlias); +COMPILE_ASSERT_MATCHING_ENUM(Progress, TypeProgress); +COMPILE_ASSERT_MATCHING_ENUM(NoDrop, TypeNoDrop); +COMPILE_ASSERT_MATCHING_ENUM(Copy, TypeCopy); +COMPILE_ASSERT_MATCHING_ENUM(None, TypeNone); +COMPILE_ASSERT_MATCHING_ENUM(NotAllowed, TypeNotAllowed); +COMPILE_ASSERT_MATCHING_ENUM(ZoomIn, TypeZoomIn); +COMPILE_ASSERT_MATCHING_ENUM(ZoomOut, TypeZoomOut); +COMPILE_ASSERT_MATCHING_ENUM(Grab, TypeGrab); +COMPILE_ASSERT_MATCHING_ENUM(Grabbing, TypeGrabbing); +COMPILE_ASSERT_MATCHING_ENUM(Custom, TypeCustom); diff --git a/Source/WebCore/platform/chromium/FileChooserChromium.cpp b/Source/WebCore/platform/chromium/FileChooserChromium.cpp index 3d75b42..dcc7eb0 100644 --- a/Source/WebCore/platform/chromium/FileChooserChromium.cpp +++ b/Source/WebCore/platform/chromium/FileChooserChromium.cpp @@ -44,9 +44,9 @@ String FileChooser::basenameForWidth(const Font& font, int width) const else if (m_filenames.size() == 1) string = pathGetDisplayFileName(m_filenames[0]); else - return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false); + return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font); - return StringTruncator::centerTruncate(string, static_cast<float>(width), font, false); + return StringTruncator::centerTruncate(string, static_cast<float>(width), font); } } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/FramelessScrollView.cpp b/Source/WebCore/platform/chromium/FramelessScrollView.cpp index 3fbf2d6..b6a8f53 100644 --- a/Source/WebCore/platform/chromium/FramelessScrollView.cpp +++ b/Source/WebCore/platform/chromium/FramelessScrollView.cpp @@ -32,6 +32,7 @@ #include "FramelessScrollView.h" #include "FramelessScrollViewClient.h" +#include "ScrollbarTheme.h" namespace WebCore { @@ -72,10 +73,16 @@ IntRect FramelessScrollView::windowClipRect(bool clipToContents) const return contentsToWindow(visibleContentRect(!clipToContents)); } -void FramelessScrollView::paintContents(GraphicsContext*, const IntRect& damageRect) +void FramelessScrollView::paintContents(GraphicsContext*, const IntRect&) { } +void FramelessScrollView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect) +{ + // ScrollbarThemeComposite::paintScrollCorner incorrectly assumes that the ScrollView is a FrameView. + ScrollbarTheme::defaultPaintScrollCorner(context, cornerRect); +} + void FramelessScrollView::contentsResized() { } diff --git a/Source/WebCore/platform/chromium/FramelessScrollView.h b/Source/WebCore/platform/chromium/FramelessScrollView.h index 033d953..724829d 100644 --- a/Source/WebCore/platform/chromium/FramelessScrollView.h +++ b/Source/WebCore/platform/chromium/FramelessScrollView.h @@ -74,7 +74,8 @@ namespace WebCore { protected: // ScrollView protected methods: - virtual void paintContents(GraphicsContext*, const IntRect& damageRect); + virtual void paintContents(GraphicsContext*, const IntRect&); + virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect); virtual void contentsResized(); virtual void visibleContentsResized(); diff --git a/Source/WebCore/platform/chromium/PlatformBridge.h b/Source/WebCore/platform/chromium/PlatformBridge.h index 9a09b90..1c3ccbd 100644 --- a/Source/WebCore/platform/chromium/PlatformBridge.h +++ b/Source/WebCore/platform/chromium/PlatformBridge.h @@ -109,9 +109,9 @@ public: static void clipboardWriteData(const String& type, const String& data, const String& metadata); // Interface for handling copy and paste, drag and drop, and selection copy. - static HashSet<String> clipboardReadAvailableTypes(const Frame*, PasteboardPrivate::ClipboardBuffer, bool* containsFilenames); - static bool clipboardReadData(const Frame*, PasteboardPrivate::ClipboardBuffer, const String& type, String& data, String& metadata); - static Vector<String> clipboardReadFilenames(const Frame*, PasteboardPrivate::ClipboardBuffer); + static HashSet<String> clipboardReadAvailableTypes(PasteboardPrivate::ClipboardBuffer, bool* containsFilenames); + static bool clipboardReadData(PasteboardPrivate::ClipboardBuffer, const String& type, String& data, String& metadata); + static Vector<String> clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer); // Cookies ------------------------------------------------------------ static void setCookies(const Document*, const KURL&, const String& value); @@ -150,7 +150,7 @@ public: #endif #if OS(LINUX) || OS(FREEBSD) static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result); - static String getFontFamilyForCharacters(const UChar*, size_t numCharacters); + static String getFontFamilyForCharacters(const UChar*, size_t numCharacters, const char* preferredLocale); #endif #if OS(DARWIN) static bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); @@ -173,6 +173,8 @@ public: static PassRefPtr<IDBFactoryBackendInterface> idbFactory(); // Extracts keyPath from values and returns the corresponding keys. static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys); + // Injects key via keyPath into value. Returns true on success. + static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String& keyPath); // JavaScript --------------------------------------------------------- static void notifyJSOutOfMemory(Frame*); @@ -308,6 +310,7 @@ public: bool checked; bool indeterminate; // Whether the button state is indeterminate. bool isDefault; // Whether the button is default button. + bool hasBorder; unsigned backgroundColor; }; @@ -318,6 +321,8 @@ public: }; struct MenuListExtraParams { + bool hasBorder; + bool hasBorderRadius; int arrowX; int arrowY; unsigned backgroundColor; diff --git a/Source/WebCore/platform/chromium/PlatformCursor.h b/Source/WebCore/platform/chromium/PlatformCursor.h index 692c007..328cdb6 100644 --- a/Source/WebCore/platform/chromium/PlatformCursor.h +++ b/Source/WebCore/platform/chromium/PlatformCursor.h @@ -81,6 +81,8 @@ namespace WebCore { TypeNotAllowed, TypeZoomIn, TypeZoomOut, + TypeGrab, + TypeGrabbing, TypeCustom }; diff --git a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp index 59441d0..e83ebe4 100644 --- a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp +++ b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp @@ -328,7 +328,7 @@ PopupContainer::~PopupContainer() removeChild(m_listBox.get()); } -IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, int popupInitialY) +IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate) { // Reset the max height to its default value, it will be recomputed below // if necessary. @@ -336,8 +336,8 @@ IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, in // Lay everything out to figure out our preferred size, then tell the view's // WidgetClient about it. It should assign us a client. - layout(); - + int rightOffset = layoutAndGetRightOffset(); + // Assume m_listBox size is already calculated. IntSize targetSize(m_listBox->width() + kBorderSize * 2, m_listBox->height() + kBorderSize * 2); @@ -348,9 +348,22 @@ IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, in // If the popup would extend past the bottom of the screen, open upwards // instead. FloatRect screen = screenAvailableRect(m_frameView.get()); - // Use this::x() for location because RTL position is considered - // in layout(). - widgetRect = chromeClient->windowToScreen(IntRect(x(), popupInitialY, targetSize.width(), targetSize.height())); + // Use popupInitialCoordinate.x() + rightOffset because RTL position + // needs to be considered. + widgetRect = chromeClient->windowToScreen(IntRect(popupInitialCoordinate.x() + rightOffset, popupInitialCoordinate.y(), targetSize.width(), targetSize.height())); + + // If we have multiple screens and the browser rect is in one screen, we have + // to clip the window width to the screen width. + FloatRect windowRect = chromeClient->windowRect(); + if (windowRect.x() >= screen.x() && windowRect.maxX() <= screen.maxX()) { + if (m_listBox->m_popupClient->menuStyle().textDirection() == RTL && widgetRect.x() < screen.x()) { + widgetRect.setWidth(widgetRect.maxX() - screen.x()); + widgetRect.setX(screen.x()); + } else if (widgetRect.maxX() > screen.maxX()) + widgetRect.setWidth(screen.maxX() - widgetRect.x()); + } + + // Calculate Y axis size. if (widgetRect.maxY() > static_cast<int>(screen.maxY())) { if (widgetRect.y() - widgetRect.height() - targetControlHeight > 0) { // There is enough room to open upwards. @@ -364,9 +377,13 @@ IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, in m_listBox->setMaxHeight(spaceAbove); else m_listBox->setMaxHeight(spaceBelow); - layout(); - // Our size has changed, recompute the widgetRect. - widgetRect = chromeClient->windowToScreen(frameRect()); + layoutAndGetRightOffset(); + // Our height has changed, so recompute only Y axis of widgetRect. + // We don't have to recompute X axis, so we only replace Y axis + // in widgetRect. + IntRect frameInScreen = chromeClient->windowToScreen(frameRect()); + widgetRect.setY(frameInScreen.y()); + widgetRect.setHeight(frameInScreen.height()); // And move upwards if necessary. if (spaceAbove > spaceBelow) widgetRect.move(0, -(widgetRect.height() + targetControlHeight)); @@ -383,7 +400,7 @@ void PopupContainer::showPopup(FrameView* view) ChromeClientChromium* chromeClient = chromeClientChromium(); if (chromeClient) { IntRect popupRect = frameRect(); - chromeClient->popupOpened(this, layoutAndCalculateWidgetRect(popupRect.height(), popupRect.y()), false); + chromeClient->popupOpened(this, layoutAndCalculateWidgetRect(popupRect.height(), popupRect.location()), false); m_popupOpen = true; } @@ -412,7 +429,7 @@ void PopupContainer::notifyPopupHidden() chromeClientChromium()->popupClosed(this); } -void PopupContainer::layout() +int PopupContainer::layoutAndGetRightOffset() { m_listBox->layout(); @@ -429,12 +446,15 @@ void PopupContainer::layout() // of dropdown box should be aligned with the right edge of <select> element box, // and the dropdown box should be expanded to left if more space needed. PopupMenuClient* popupClient = m_listBox->m_popupClient; + int rightOffset = 0; if (popupClient) { bool rightAligned = m_listBox->m_popupClient->menuStyle().textDirection() == RTL; if (rightAligned) - move(x() + popupWidth - listBoxWidth, y()); + rightOffset = popupWidth - listBoxWidth; } invalidate(); + + return rightOffset; } bool PopupContainer::handleMouseDownEvent(const PlatformMouseEvent& event) @@ -520,7 +540,7 @@ ChromeClientChromium* PopupContainer::chromeClientChromium() return static_cast<ChromeClientChromium*>(m_frameView->frame()->page()->chrome()->client()); } -void PopupContainer::show(const IntRect& r, FrameView* v, int index) +void PopupContainer::showInRect(const IntRect& r, FrameView* v, int index) { // The rect is the size of the select box. It's usually larger than we need. // subtract border size so that usually the container will be displayed @@ -553,7 +573,7 @@ void PopupContainer::refresh(const IntRect& targetControlRect) listBox()->updateFromElement(); // Store the original height to check if we need to request the location. int originalHeight = height(); - IntRect widgetRect = layoutAndCalculateWidgetRect(targetControlRect.height(), location.y()); + IntRect widgetRect = layoutAndCalculateWidgetRect(targetControlRect.height(), location); if (originalHeight != widgetRect.height()) setFrameRect(widgetRect); @@ -1379,7 +1399,7 @@ void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index) { if (!p.popup) p.popup = PopupContainer::create(client(), PopupContainer::Select, dropDownSettings); - p.popup->show(r, v, index); + p.popup->showInRect(r, v, index); } void PopupMenuChromium::hide() diff --git a/Source/WebCore/platform/chromium/PopupMenuChromium.h b/Source/WebCore/platform/chromium/PopupMenuChromium.h index 43b8b0e..3436650 100644 --- a/Source/WebCore/platform/chromium/PopupMenuChromium.h +++ b/Source/WebCore/platform/chromium/PopupMenuChromium.h @@ -133,7 +133,7 @@ public: // so WebViewImpl can create a PopupContainer. This method is used for // displaying auto complete popup menus on Mac Chromium, and for all // popups on other platforms. - void show(const IntRect&, FrameView*, int index); + void showInRect(const IntRect&, FrameView*, int index); // Hides the popup. void hidePopup(); @@ -141,8 +141,8 @@ public: // The popup was hidden. void notifyPopupHidden(); - // Compute size of widget and children. - void layout(); + // Compute size of widget and children. Return right offset for RTL. + int layoutAndGetRightOffset(); PopupListBox* listBox() const { return m_listBox.get(); } @@ -177,7 +177,7 @@ private: void paintBorder(GraphicsContext*, const IntRect&); // Layout and calculate popup widget size and location and returns it as IntRect. - IntRect layoutAndCalculateWidgetRect(int targetControlHeight, int popupInitialY); + IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate); // Returns the ChromeClient of the page this popup is associated with. ChromeClientChromium* chromeClientChromium(); diff --git a/Source/WebCore/platform/chromium/ReadableDataObject.cpp b/Source/WebCore/platform/chromium/ReadableDataObject.cpp index 484a1b3..dbf4739 100644 --- a/Source/WebCore/platform/chromium/ReadableDataObject.cpp +++ b/Source/WebCore/platform/chromium/ReadableDataObject.cpp @@ -43,14 +43,13 @@ static PasteboardPrivate::ClipboardBuffer clipboardBuffer(Clipboard::ClipboardTy return clipboardType == Clipboard::DragAndDrop ? PasteboardPrivate::DragBuffer : PasteboardPrivate::StandardBuffer; } -PassRefPtr<ReadableDataObject> ReadableDataObject::create(const Frame* frame, Clipboard::ClipboardType clipboardType) +PassRefPtr<ReadableDataObject> ReadableDataObject::create(Clipboard::ClipboardType clipboardType) { - return adoptRef(new ReadableDataObject(frame, clipboardType)); + return adoptRef(new ReadableDataObject(clipboardType)); } -ReadableDataObject::ReadableDataObject(const Frame* frame, Clipboard::ClipboardType clipboardType) - : m_frame(frame) - , m_clipboardType(clipboardType) +ReadableDataObject::ReadableDataObject(Clipboard::ClipboardType clipboardType) + : m_clipboardType(clipboardType) , m_containsFilenames(false) , m_isTypeCacheInitialized(false) { @@ -94,7 +93,7 @@ String ReadableDataObject::getData(const String& type, bool& succeeded) const return data; } succeeded = PlatformBridge::clipboardReadData( - m_frame, clipboardBuffer(m_clipboardType), type, data, ignoredMetadata); + clipboardBuffer(m_clipboardType), type, data, ignoredMetadata); return data; } @@ -103,7 +102,7 @@ String ReadableDataObject::urlTitle() const String ignoredData; String urlTitle; PlatformBridge::clipboardReadData( - m_frame, clipboardBuffer(m_clipboardType), mimeTypeTextURIList, ignoredData, urlTitle); + clipboardBuffer(m_clipboardType), mimeTypeTextURIList, ignoredData, urlTitle); return urlTitle; } @@ -112,7 +111,7 @@ KURL ReadableDataObject::htmlBaseUrl() const String ignoredData; String htmlBaseUrl; PlatformBridge::clipboardReadData( - m_frame, clipboardBuffer(m_clipboardType), mimeTypeTextHTML, ignoredData, htmlBaseUrl); + clipboardBuffer(m_clipboardType), mimeTypeTextHTML, ignoredData, htmlBaseUrl); return KURL(ParsedURLString, htmlBaseUrl); } @@ -124,7 +123,7 @@ bool ReadableDataObject::containsFilenames() const Vector<String> ReadableDataObject::filenames() const { - return PlatformBridge::clipboardReadFilenames(m_frame, clipboardBuffer(m_clipboardType)); + return PlatformBridge::clipboardReadFilenames(clipboardBuffer(m_clipboardType)); } void ReadableDataObject::ensureTypeCacheInitialized() const @@ -133,7 +132,7 @@ void ReadableDataObject::ensureTypeCacheInitialized() const return; m_types = PlatformBridge::clipboardReadAvailableTypes( - m_frame, clipboardBuffer(m_clipboardType), &m_containsFilenames); + clipboardBuffer(m_clipboardType), &m_containsFilenames); m_isTypeCacheInitialized = true; } diff --git a/Source/WebCore/platform/chromium/ReadableDataObject.h b/Source/WebCore/platform/chromium/ReadableDataObject.h index c6cc310..027e0ed 100644 --- a/Source/WebCore/platform/chromium/ReadableDataObject.h +++ b/Source/WebCore/platform/chromium/ReadableDataObject.h @@ -44,7 +44,7 @@ namespace WebCore { // browser to the renderer. class ReadableDataObject : public RefCounted<ReadableDataObject> { public: - static PassRefPtr<ReadableDataObject> create(const Frame*, Clipboard::ClipboardType); + static PassRefPtr<ReadableDataObject> create(Clipboard::ClipboardType); bool hasData() const; HashSet<String> types() const; @@ -57,14 +57,11 @@ public: Vector<String> filenames() const; private: - explicit ReadableDataObject(const Frame*, Clipboard::ClipboardType); + explicit ReadableDataObject(Clipboard::ClipboardType); // This isn't always const... but most of the time it is. void ensureTypeCacheInitialized() const; - // The owner frame. Used to send IPCs back to the correspdonging view via WebFrameClient. - const Frame* m_frame; - Clipboard::ClipboardType m_clipboardType; // To avoid making a lot of IPC calls for each drag event, we cache some diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp b/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp index 9e700c2..843fc3c 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp @@ -137,13 +137,4 @@ void ScrollbarThemeChromium::paintTickmarks(GraphicsContext* context, Scrollbar* context->restore(); } -void ScrollbarThemeChromium::paintScrollCorner(ScrollView* view, GraphicsContext* context, const IntRect& cornerRect) -{ - // ScrollbarThemeComposite::paintScrollCorner incorrectly assumes that the - // ScrollView is a FrameView (see FramelessScrollView), so we cannot let - // that code run. For FrameView's this is correct since we don't do custom - // scrollbar corner rendering, which ScrollbarThemeComposite supports. - ScrollbarTheme::paintScrollCorner(view, context, cornerRect); -} - } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromium.h b/Source/WebCore/platform/chromium/ScrollbarThemeChromium.h index b53d4ae..1178125 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromium.h +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromium.h @@ -48,8 +48,6 @@ namespace WebCore { virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false); virtual IntRect trackRect(Scrollbar*, bool painting = false); - virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect&); - virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&); virtual void paintTickmarks(GraphicsContext*, Scrollbar*, const IntRect&); diff --git a/Source/WebCore/platform/chromium/TemporaryLinkStubs.cpp b/Source/WebCore/platform/chromium/TemporaryLinkStubs.cpp index 3c747d0..3a85029 100644 --- a/Source/WebCore/platform/chromium/TemporaryLinkStubs.cpp +++ b/Source/WebCore/platform/chromium/TemporaryLinkStubs.cpp @@ -54,4 +54,14 @@ void setCookieStoragePrivateBrowsingEnabled(bool) notImplemented(); } +void startObservingCookieChanges() +{ + notImplemented(); +} + +void stopObservingCookieChanges() +{ + notImplemented(); +} + } // namespace WebCore |