diff options
Diffstat (limited to 'WebCore/platform')
80 files changed, 2157 insertions, 894 deletions
diff --git a/WebCore/platform/ContextMenu.cpp b/WebCore/platform/ContextMenu.cpp index 00bb253..84a2ffc 100644 --- a/WebCore/platform/ContextMenu.cpp +++ b/WebCore/platform/ContextMenu.cpp @@ -815,6 +815,8 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const case ContextMenuItemTagInspectElement: #endif case ContextMenuItemBaseCustomTag: + case ContextMenuItemCustomTagNoAction: + case ContextMenuItemLastCustomTag: case ContextMenuItemBaseApplicationTag: break; } diff --git a/WebCore/platform/ContextMenuItem.h b/WebCore/platform/ContextMenuItem.h index 8c46e10..3731e24 100644 --- a/WebCore/platform/ContextMenuItem.h +++ b/WebCore/platform/ContextMenuItem.h @@ -144,6 +144,8 @@ namespace WebCore { ContextMenuItemTagChangeBack, #endif ContextMenuItemBaseCustomTag = 5000, + ContextMenuItemCustomTagNoAction = 5998, + ContextMenuItemLastCustomTag = 5999, ContextMenuItemBaseApplicationTag = 10000 }; diff --git a/WebCore/platform/DragData.h b/WebCore/platform/DragData.h index 230e344..d90a424 100644 --- a/WebCore/platform/DragData.h +++ b/WebCore/platform/DragData.h @@ -26,7 +26,6 @@ #ifndef DragData_h #define DragData_h -#include "ClipboardAccessPolicy.h" #include "Color.h" #include "DragActions.h" #include "IntPoint.h" @@ -70,7 +69,6 @@ typedef void* DragDataRef; namespace WebCore { - class Clipboard; class Document; class DocumentFragment; class KURL; @@ -97,7 +95,6 @@ namespace WebCore { const IntPoint& globalPosition() const { return m_globalPosition; } DragDataRef platformData() const { return m_platformDragData; } DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; } - PassRefPtr<Clipboard> createClipboard(ClipboardAccessPolicy) const; bool containsURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames) const; bool containsPlainText() const; bool containsCompatibleContent() const; diff --git a/WebCore/platform/LocalizationStrategy.h b/WebCore/platform/LocalizationStrategy.h new file mode 100644 index 0000000..9bde316 --- /dev/null +++ b/WebCore/platform/LocalizationStrategy.h @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2010 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 LocalizationStrategy_h +#define LocalizationStrategy_h + +#if USE(PLATFORM_STRATEGIES) + +namespace WebCore { + +class String; +class IntSize; + +class LocalizationStrategy { +public: + virtual String inputElementAltText() = 0; + virtual String resetButtonDefaultLabel() = 0; + virtual String searchableIndexIntroduction() = 0; + virtual String submitButtonDefaultLabel() = 0; + virtual String fileButtonChooseFileLabel() = 0; + virtual String fileButtonNoFileSelectedLabel() = 0; + virtual String copyImageUnknownFileLabel() = 0; + +#if ENABLE(CONTEXT_MENUS) + virtual String contextMenuItemTagOpenLinkInNewWindow() = 0; + virtual String contextMenuItemTagDownloadLinkToDisk() = 0; + virtual String contextMenuItemTagCopyLinkToClipboard() = 0; + virtual String contextMenuItemTagOpenImageInNewWindow() = 0; + virtual String contextMenuItemTagDownloadImageToDisk() = 0; + virtual String contextMenuItemTagCopyImageToClipboard() = 0; + virtual String contextMenuItemTagOpenFrameInNewWindow() = 0; + virtual String contextMenuItemTagCopy() = 0; + virtual String contextMenuItemTagGoBack() = 0; + virtual String contextMenuItemTagGoForward() = 0; + virtual String contextMenuItemTagStop() = 0; + virtual String contextMenuItemTagReload() = 0; + virtual String contextMenuItemTagCut() = 0; + virtual String contextMenuItemTagPaste() = 0; +#if PLATFORM(GTK) + virtual String contextMenuItemTagDelete() = 0; + virtual String contextMenuItemTagSelectAll() = 0; + virtual String contextMenuItemTagInputMethods() = 0; + virtual String contextMenuItemTagUnicode() = 0; +#endif + virtual String contextMenuItemTagNoGuessesFound() = 0; + virtual String contextMenuItemTagIgnoreSpelling() = 0; + virtual String contextMenuItemTagLearnSpelling() = 0; + virtual String contextMenuItemTagSearchWeb() = 0; + virtual String contextMenuItemTagLookUpInDictionary() = 0; + virtual String contextMenuItemTagOpenLink() = 0; + virtual String contextMenuItemTagIgnoreGrammar() = 0; + virtual String contextMenuItemTagSpellingMenu() = 0; + virtual String contextMenuItemTagShowSpellingPanel(bool show) = 0; + virtual String contextMenuItemTagCheckSpelling() = 0; + virtual String contextMenuItemTagCheckSpellingWhileTyping() = 0; + virtual String contextMenuItemTagCheckGrammarWithSpelling() = 0; + virtual String contextMenuItemTagFontMenu() = 0; + virtual String contextMenuItemTagBold() = 0; + virtual String contextMenuItemTagItalic() = 0; + virtual String contextMenuItemTagUnderline() = 0; + virtual String contextMenuItemTagOutline() = 0; + virtual String contextMenuItemTagWritingDirectionMenu() = 0; + virtual String contextMenuItemTagTextDirectionMenu() = 0; + virtual String contextMenuItemTagDefaultDirection() = 0; + virtual String contextMenuItemTagLeftToRight() = 0; + virtual String contextMenuItemTagRightToLeft() = 0; +#if PLATFORM(MAC) + virtual String contextMenuItemTagSearchInSpotlight() = 0; + virtual String contextMenuItemTagShowFonts() = 0; + virtual String contextMenuItemTagStyles() = 0; + virtual String contextMenuItemTagShowColors() = 0; + virtual String contextMenuItemTagSpeechMenu() = 0; + virtual String contextMenuItemTagStartSpeaking() = 0; + virtual String contextMenuItemTagStopSpeaking() = 0; + virtual String contextMenuItemTagCorrectSpellingAutomatically() = 0; + virtual String contextMenuItemTagSubstitutionsMenu() = 0; + virtual String contextMenuItemTagShowSubstitutions(bool show) = 0; + virtual String contextMenuItemTagSmartCopyPaste() = 0; + virtual String contextMenuItemTagSmartQuotes() = 0; + virtual String contextMenuItemTagSmartDashes() = 0; + virtual String contextMenuItemTagSmartLinks() = 0; + virtual String contextMenuItemTagTextReplacement() = 0; + virtual String contextMenuItemTagTransformationsMenu() = 0; + virtual String contextMenuItemTagMakeUpperCase() = 0; + virtual String contextMenuItemTagMakeLowerCase() = 0; + virtual String contextMenuItemTagCapitalize() = 0; + virtual String contextMenuItemTagChangeBack(const String& replacedString) = 0; +#endif + virtual String contextMenuItemTagInspectElement() = 0; +#endif // ENABLE(CONTEXT_MENUS) + + virtual String searchMenuNoRecentSearchesText() = 0; + virtual String searchMenuRecentSearchesText() = 0; + virtual String searchMenuClearRecentSearchesText() = 0; + + virtual String AXWebAreaText() = 0; + virtual String AXLinkText() = 0; + virtual String AXListMarkerText() = 0; + virtual String AXImageMapText() = 0; + virtual String AXHeadingText() = 0; + virtual String AXDefinitionListTermText() = 0; + virtual String AXDefinitionListDefinitionText() = 0; + virtual String AXARIAContentGroupText(const String& ariaType) = 0; + + virtual String AXButtonActionVerb() = 0; + virtual String AXRadioButtonActionVerb() = 0; + virtual String AXTextFieldActionVerb() = 0; + virtual String AXCheckedCheckBoxActionVerb() = 0; + virtual String AXUncheckedCheckBoxActionVerb() = 0; + virtual String AXMenuListActionVerb() = 0; + virtual String AXMenuListPopupActionVerb() = 0; + virtual String AXLinkActionVerb() = 0; + + virtual String missingPluginText() = 0; + virtual String crashedPluginText() = 0; + virtual String multipleFileUploadText(unsigned numberOfFiles) = 0; + virtual String unknownFileSizeText() = 0; + +#if PLATFORM(WIN) + virtual String uploadFileText() = 0; + virtual String allFilesText() = 0; +#endif + + virtual String imageTitle(const String& filename, const IntSize& size) = 0; + + virtual String mediaElementLoadingStateText() = 0; + virtual String mediaElementLiveBroadcastStateText() = 0; + virtual String localizedMediaControlElementString(const String&) = 0; + virtual String localizedMediaControlElementHelpText(const String&) = 0; + virtual String localizedMediaTimeDescription(float) = 0; + + virtual String validationMessageValueMissingText() = 0; + virtual String validationMessageTypeMismatchText() = 0; + virtual String validationMessagePatternMismatchText() = 0; + virtual String validationMessageTooLongText() = 0; + virtual String validationMessageRangeUnderflowText() = 0; + virtual String validationMessageRangeOverflowText() = 0; + virtual String validationMessageStepMismatchText() = 0; + +protected: + virtual ~LocalizationStrategy() + { + } +}; + +} // namespace WebCore + +#endif // USE(PLATFORM_STRATEGIES) + +#endif // LocalizationStrategy_h diff --git a/WebCore/platform/PlatformStrategies.h b/WebCore/platform/PlatformStrategies.h index 22da3ac..f585202 100644 --- a/WebCore/platform/PlatformStrategies.h +++ b/WebCore/platform/PlatformStrategies.h @@ -31,6 +31,7 @@ namespace WebCore { class PluginStrategy; +class LocalizationStrategy; class PlatformStrategies { public: @@ -38,21 +39,33 @@ public: { if (!m_pluginStrategy) m_pluginStrategy = createPluginStrategy(); - return m_pluginStrategy; } + LocalizationStrategy* localizationStrategy() + { + if (!m_localizationStrategy) + m_localizationStrategy = createLocalizationStrategy(); + return m_localizationStrategy; + } + protected: PlatformStrategies() - : m_pluginStrategy(0) + : m_pluginStrategy(0), + m_localizationStrategy(0) + { + } + + virtual ~PlatformStrategies() { } - virtual ~PlatformStrategies() { } -private: +private: virtual PluginStrategy* createPluginStrategy() = 0; + virtual LocalizationStrategy* createLocalizationStrategy() = 0; PluginStrategy* m_pluginStrategy; + LocalizationStrategy* m_localizationStrategy; }; PlatformStrategies* platformStrategies(); diff --git a/WebCore/platform/PopupMenuClient.h b/WebCore/platform/PopupMenuClient.h index a1396e8..976f28c 100644 --- a/WebCore/platform/PopupMenuClient.h +++ b/WebCore/platform/PopupMenuClient.h @@ -43,6 +43,7 @@ public: virtual String itemText(unsigned listIndex) const = 0; virtual String itemLabel(unsigned listIndex) const = 0; + virtual String itemIcon(unsigned listIndex) const = 0; virtual String itemToolTip(unsigned listIndex) const = 0; virtual String itemAccessibilityText(unsigned listIndex) const = 0; virtual bool itemIsEnabled(unsigned listIndex) const = 0; diff --git a/WebCore/platform/SchemeRegistry.cpp b/WebCore/platform/SchemeRegistry.cpp new file mode 100644 index 0000000..0423236 --- /dev/null +++ b/WebCore/platform/SchemeRegistry.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2010 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``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 APPLE COMPUTER, INC. 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 "SchemeRegistry.h" + +namespace WebCore { + +static URLSchemesMap& localURLSchemes() +{ + DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ()); + + if (localSchemes.isEmpty()) { + localSchemes.add("file"); +#if PLATFORM(MAC) + localSchemes.add("applewebdata"); +#endif +#if PLATFORM(QT) + localSchemes.add("qrc"); +#endif + } + + return localSchemes; +} + +static URLSchemesMap& secureSchemes() +{ + DEFINE_STATIC_LOCAL(URLSchemesMap, secureSchemes, ()); + + if (secureSchemes.isEmpty()) { + secureSchemes.add("https"); + secureSchemes.add("about"); + secureSchemes.add("data"); + } + + return secureSchemes; +} + +static URLSchemesMap& schemesWithUniqueOrigins() +{ + DEFINE_STATIC_LOCAL(URLSchemesMap, schemesWithUniqueOrigins, ()); + + // This is a willful violation of HTML5. + // See https://bugs.webkit.org/show_bug.cgi?id=11885 + if (schemesWithUniqueOrigins.isEmpty()) + schemesWithUniqueOrigins.add("data"); + + return schemesWithUniqueOrigins; +} + +static URLSchemesMap& emptyDocumentSchemes() +{ + DEFINE_STATIC_LOCAL(URLSchemesMap, emptyDocumentSchemes, ()); + + if (emptyDocumentSchemes.isEmpty()) + emptyDocumentSchemes.add("about"); + + return emptyDocumentSchemes; +} + +void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme) +{ + WebCore::localURLSchemes().add(scheme); +} + +void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme) +{ + if (scheme == "file") + return; +#if PLATFORM(MAC) + if (scheme == "applewebdata") + return; +#endif + WebCore::localURLSchemes().remove(scheme); +} + +const URLSchemesMap& SchemeRegistry::localURLSchemes() +{ + return WebCore::localURLSchemes(); +} + +bool SchemeRegistry::shouldTreatURLAsLocal(const String& url) +{ + // This avoids an allocation of another String and the HashSet contains() + // call for the file: and http: schemes. + if (url.length() >= 5) { + const UChar* s = url.characters(); + if (s[0] == 'h' && s[1] == 't' && s[2] == 't' && s[3] == 'p' && s[4] == ':') + return false; + if (s[0] == 'f' && s[1] == 'i' && s[2] == 'l' && s[3] == 'e' && s[4] == ':') + return true; + } + + int loc = url.find(':'); + if (loc == -1) + return false; + + String scheme = url.left(loc); + return WebCore::localURLSchemes().contains(scheme); +} + +bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme) +{ + // This avoids an allocation of another String and the HashSet contains() + // call for the file: and http: schemes. + if (scheme.length() == 4) { + const UChar* s = scheme.characters(); + if (s[0] == 'h' && s[1] == 't' && s[2] == 't' && s[3] == 'p') + return false; + if (s[0] == 'f' && s[1] == 'i' && s[2] == 'l' && s[3] == 'e') + return true; + } + + if (scheme.isEmpty()) + return false; + + return WebCore::localURLSchemes().contains(scheme); +} + +void SchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme) +{ + schemesWithUniqueOrigins().add(scheme); +} + +bool SchemeRegistry::shouldTreatURLSchemeAsNoAccess(const String& scheme) +{ + return schemesWithUniqueOrigins().contains(scheme); +} + +void SchemeRegistry::registerURLSchemeAsSecure(const String& scheme) +{ + secureSchemes().add(scheme); +} + +bool SchemeRegistry::shouldTreatURLSchemeAsSecure(const String& scheme) +{ + return secureSchemes().contains(scheme); +} + +void SchemeRegistry::registerURLSchemeAsEmptyDocument(const String& scheme) +{ + emptyDocumentSchemes().add(scheme); +} + +bool SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(const String& scheme) +{ + return emptyDocumentSchemes().contains(scheme); +} + +} // namespace WebCore diff --git a/WebCore/platform/win/PlatformScrollBar.h b/WebCore/platform/SchemeRegistry.h index 89c6e4a..d92ec4e 100644 --- a/WebCore/platform/win/PlatformScrollBar.h +++ b/WebCore/platform/SchemeRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2010 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +10,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``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 APPLE COMPUTER, INC. OR @@ -21,30 +21,41 @@ * 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 SchemeRegistry_h +#define SchemeRegistry_h -#ifndef PlatformScrollBar_h -#define PlatformScrollBar_h - -#include "Scrollbar.h" -#include "Timer.h" -#include <wtf/PassRefPtr.h> - -typedef struct HDC__* HDC; +#include "PlatformString.h" +#include "StringHash.h" +#include <wtf/HashSet.h> namespace WebCore { -class PlatformScrollbar : public Scrollbar { +typedef HashSet<String, CaseFoldingHash> URLSchemesMap; + +class SchemeRegistry { public: - static PassRefPtr<PlatformScrollbar> create(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size) - { - return adoptRef(new PlatformScrollbar(client, orientation, size)); - } + static void registerURLSchemeAsLocal(const String&); + static void removeURLSchemeRegisteredAsLocal(const String&); + static const URLSchemesMap& localURLSchemes(); + + static bool shouldTreatURLAsLocal(const String&); + static bool shouldTreatURLSchemeAsLocal(const String&); + + // Secure schemes do not trigger mixed content warnings. For example, + // https and data are secure schemes because they cannot be corrupted by + // active network attackers. + static void registerURLSchemeAsSecure(const String&); + static bool shouldTreatURLSchemeAsSecure(const String&); + + static void registerURLSchemeAsNoAccess(const String&); + static bool shouldTreatURLSchemeAsNoAccess(const String&); - PlatformScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0); + static void registerURLSchemeAsEmptyDocument(const String&); + static bool shouldLoadURLSchemeAsEmptyDocument(const String&); }; -} - -#endif // PlatformScrollBar_h +} // namespace WebCore +#endif // SchemeRegistry_h diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp index 615ae5d..ddecf1e 100644 --- a/WebCore/platform/ScrollView.cpp +++ b/WebCore/platform/ScrollView.cpp @@ -322,7 +322,6 @@ void ScrollView::valueChanged(Scrollbar* scrollbar) if (scrollbarsSuppressed()) return; - repaintFixedElementsAfterScrolling(); scrollContents(scrollDelta); } diff --git a/WebCore/platform/android/ClipboardAndroid.cpp b/WebCore/platform/android/ClipboardAndroid.cpp index 375f980..d9b2d68 100644 --- a/WebCore/platform/android/ClipboardAndroid.cpp +++ b/WebCore/platform/android/ClipboardAndroid.cpp @@ -35,6 +35,11 @@ namespace WebCore { +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*) +{ + return 0; +} + ClipboardAndroid::ClipboardAndroid(ClipboardAccessPolicy policy, bool isForDragging) : Clipboard(policy, isForDragging) { diff --git a/WebCore/platform/android/DragDataAndroid.cpp b/WebCore/platform/android/DragDataAndroid.cpp index 756d007..4e99b2c 100644 --- a/WebCore/platform/android/DragDataAndroid.cpp +++ b/WebCore/platform/android/DragDataAndroid.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "DragData.h" -#include "Clipboard.h" #include "Document.h" #include "DocumentFragment.h" @@ -58,11 +57,6 @@ Color DragData::asColor() const return Color(); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const -{ - return 0; -} - bool DragData::containsCompatibleContent() const { return false; diff --git a/WebCore/platform/brew/ClipboardBrew.cpp b/WebCore/platform/brew/ClipboardBrew.cpp index 3fd085a..720d6a6 100644 --- a/WebCore/platform/brew/ClipboardBrew.cpp +++ b/WebCore/platform/brew/ClipboardBrew.cpp @@ -36,6 +36,11 @@ namespace WebCore { +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*) +{ + return 0; +} + ClipboardBrew::ClipboardBrew(ClipboardAccessPolicy policy, bool isForDragging) : Clipboard(policy, isForDragging) { diff --git a/WebCore/platform/brew/DragDataBrew.cpp b/WebCore/platform/brew/DragDataBrew.cpp index eec8bc4..d114fd6 100644 --- a/WebCore/platform/brew/DragDataBrew.cpp +++ b/WebCore/platform/brew/DragDataBrew.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "DragData.h" -#include "Clipboard.h" #include "Document.h" #include "DocumentFragment.h" @@ -58,11 +57,6 @@ Color DragData::asColor() const return Color(); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const -{ - return 0; -} - bool DragData::containsCompatibleContent() const { return false; diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h index 2d9695e..711c728 100644 --- a/WebCore/platform/chromium/ChromiumBridge.h +++ b/WebCore/platform/chromium/ChromiumBridge.h @@ -155,8 +155,7 @@ namespace WebCore { // Geolocation -------------------------------------------------------- static GeolocationServiceBridge* createGeolocationServiceBridge(GeolocationServiceChromium*); - // HTML5 DB ----------------------------------------------------------- -#if ENABLE(DATABASE) + // Databases ---------------------------------------------------------- // Returns a handle to the DB file and ooptionally a handle to its containing directory static PlatformFileHandle databaseOpenFile(const String& vfsFleName, int desiredFlags); // Returns a SQLite code (SQLITE_OK = 0, on success) @@ -165,7 +164,6 @@ namespace WebCore { static long databaseGetFileAttributes(const String& vfsFileName); // Returns the size of the DB file static long long databaseGetFileSize(const String& vfsFileName); -#endif // IndexedDB ---------------------------------------------------------- static PassRefPtr<IndexedDatabase> indexedDatabase(); diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp index 8aad8aa..06244a2 100644 --- a/WebCore/platform/chromium/ClipboardChromium.cpp +++ b/WebCore/platform/chromium/ClipboardChromium.cpp @@ -32,6 +32,7 @@ #include "ChromiumDataObject.h" #include "ClipboardUtilitiesChromium.h" #include "Document.h" +#include "DragData.h" #include "Element.h" #include "FileList.h" #include "Frame.h" @@ -43,6 +44,7 @@ #include "PlatformString.h" #include "Range.h" #include "RenderImage.h" +#include "ScriptExecutionContext.h" #include "StringBuilder.h" #include "markup.h" @@ -89,18 +91,25 @@ static ClipboardDataType clipboardTypeFromMIMEType(const String& type) return ClipboardDataTypeOther; } +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame) +{ + return ClipboardChromium::create(true, dragData->platformData(), policy, frame); +} + ClipboardChromium::ClipboardChromium(bool isForDragging, PassRefPtr<ChromiumDataObject> dataObject, - ClipboardAccessPolicy policy) + ClipboardAccessPolicy policy, + Frame* frame) : Clipboard(policy, isForDragging) , m_dataObject(dataObject) + , m_frame(frame) { } PassRefPtr<ClipboardChromium> ClipboardChromium::create(bool isForDragging, - PassRefPtr<ChromiumDataObject> dataObject, ClipboardAccessPolicy policy) + PassRefPtr<ChromiumDataObject> dataObject, ClipboardAccessPolicy policy, Frame* frame) { - return adoptRef(new ClipboardChromium(isForDragging, dataObject, policy)); + return adoptRef(new ClipboardChromium(isForDragging, dataObject, policy, frame)); } void ClipboardChromium::clearData(const String& type) @@ -355,9 +364,10 @@ PassRefPtr<FileList> ClipboardChromium::files() const if (!m_dataObject || m_dataObject->filenames.isEmpty()) return FileList::create(); + ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext(); 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))); + fileList->append(File::create(scriptExecutionContext, m_dataObject->filenames.at(i))); return fileList.release(); } diff --git a/WebCore/platform/chromium/ClipboardChromium.h b/WebCore/platform/chromium/ClipboardChromium.h index fbebde2..a4150d0 100644 --- a/WebCore/platform/chromium/ClipboardChromium.h +++ b/WebCore/platform/chromium/ClipboardChromium.h @@ -38,6 +38,7 @@ namespace WebCore { class CachedImage; class ChromiumDataObject; + class Frame; class IntPoint; class ClipboardChromium : public Clipboard, public CachedResourceClient { @@ -45,7 +46,7 @@ namespace WebCore { ~ClipboardChromium() {} static PassRefPtr<ClipboardChromium> create( - bool isForDragging, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy); + bool isForDragging, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy, Frame*); // Returns the file name (not including the extension). This removes any // invalid file system characters as well as making sure the @@ -79,11 +80,12 @@ namespace WebCore { virtual bool hasData(); private: - ClipboardChromium(bool, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy); + ClipboardChromium(bool, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy, Frame*); void resetFromClipboard(); void setDragImage(CachedImage*, Node*, const IntPoint&); RefPtr<ChromiumDataObject> m_dataObject; + Frame* m_frame; }; } // namespace WebCore diff --git a/WebCore/platform/chromium/DragDataChromium.cpp b/WebCore/platform/chromium/DragDataChromium.cpp index 2c2151a..674d34d 100644 --- a/WebCore/platform/chromium/DragDataChromium.cpp +++ b/WebCore/platform/chromium/DragDataChromium.cpp @@ -32,8 +32,6 @@ #include "ChromiumBridge.h" #include "ChromiumDataObject.h" -#include "Clipboard.h" -#include "ClipboardChromium.h" #include "DocumentFragment.h" #include "FileSystem.h" #include "KURL.h" @@ -48,14 +46,6 @@ static bool containsHTML(const ChromiumDataObject* dropData) return dropData->textHtml.length() > 0; } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - RefPtr<ClipboardChromium> clipboard = ClipboardChromium::create(true, - m_platformDragData, policy); - - return clipboard.release(); -} - bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const { return !asURL(filenamePolicy).isEmpty(); diff --git a/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp b/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp index 1f74840..6529482 100644 --- a/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp +++ b/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp @@ -180,8 +180,8 @@ void PlatformThemeChromiumGtk::paintArrowButton(GraphicsContext* gc, const IntRe paint.setColor(outlineColor(trackHSV, thumbHSV)); canvas->drawPath(outline, paint); - // If the button is disabled, the arrow is drawn with the outline color. - if (states & EnabledState) + // If the button is disabled or read-only, the arrow is drawn with the outline color. + if (states & EnabledState && !(states & ReadOnlyState)) paint.setColor(SK_ColorBLACK); paint.setAntiAlias(false); diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp index 4701a75..d07ba2e 100644 --- a/WebCore/platform/chromium/PopupMenuChromium.cpp +++ b/WebCore/platform/chromium/PopupMenuChromium.cpp @@ -71,6 +71,7 @@ static const int kMaxVisibleRows = 20; static const int kMaxHeight = 500; static const int kBorderSize = 1; static const int kTextToLabelPadding = 10; +static const int kLabelToIconPadding = 5; static const TimeStamp kTypeAheadTimeoutMs = 1000; // The settings used for the drop down menu. @@ -959,18 +960,30 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd int textY = rowRect.y() + itemFont.ascent() + (rowRect.height() - itemFont.height()) / 2; gc->drawBidiText(itemFont, textRun, IntPoint(textX, textY)); + // We are using the left padding as the right padding includes room for the scroll-bar which + // does not show in this case. + int rightPadding = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft()); + int remainingWidth = rowRect.width() - rightPadding; + + // Draw the icon if applicable. + String itemIcon = m_popupClient->itemIcon(rowIndex); + RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data())); + if (image && !image->isNull()) { + IntRect imageRect = image->rect(); + 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); + } + // Draw the the label if applicable. if (itemLabel.isEmpty()) return; TextRun labelTextRun(itemLabel.characters(), itemLabel.length(), false, 0, 0, rtl); if (rightAligned) textX = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft()); - else { - // We are using the left padding as the right padding includes room for the scroll-bar which - // does not show in this case. - int rightPadding = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft()); - textX = rowRect.width() - rightPadding - itemFont.width(labelTextRun); - } + else + textX = remainingWidth - itemFont.width(labelTextRun); gc->setFillColor(labelColor, DeviceColorSpace); gc->drawBidiText(itemFont, labelTextRun, IntPoint(textX, textY)); @@ -1243,10 +1256,16 @@ void PopupListBox::layout() // Ensure the popup is wide enough to fit this item. String text = m_popupClient->itemText(i); - if (!text.isEmpty()) { - int width = itemFont.width(TextRun(text)); - baseWidth = max(baseWidth, width); + String label = m_popupClient->itemLabel(i); + int width = 0; + if (!text.isEmpty()) + width = itemFont.width(TextRun(text)); + if (!label.isEmpty()) { + if (width > 0) + width += kTextToLabelPadding; + width += itemFont.width(TextRun(label)); } + baseWidth = max(baseWidth, width); // FIXME: http://b/1210481 We should get the padding of individual option elements. paddingWidth = max(paddingWidth, m_popupClient->clientPaddingLeft() + m_popupClient->clientPaddingRight()); diff --git a/WebCore/platform/efl/ClipboardEfl.cpp b/WebCore/platform/efl/ClipboardEfl.cpp index 6ef51cf..1633ccb 100644 --- a/WebCore/platform/efl/ClipboardEfl.cpp +++ b/WebCore/platform/efl/ClipboardEfl.cpp @@ -27,11 +27,16 @@ #include "StringHash.h" namespace WebCore { -PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*) { return new ClipboardEfl(policy, false); } +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*) +{ + return 0; +} + ClipboardEfl::ClipboardEfl(ClipboardAccessPolicy policy, bool forDragging) : Clipboard(policy, forDragging) { diff --git a/WebCore/platform/efl/DragDataEfl.cpp b/WebCore/platform/efl/DragDataEfl.cpp index f6b446c..a8458d6 100644 --- a/WebCore/platform/efl/DragDataEfl.cpp +++ b/WebCore/platform/efl/DragDataEfl.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "DragData.h" -#include "Clipboard.h" #include "Document.h" #include "DocumentFragment.h" @@ -61,11 +60,6 @@ Color DragData::asColor() const return Color(); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const -{ - return 0; -} - bool DragData::containsCompatibleContent() const { return false; diff --git a/WebCore/platform/efl/FileSystemEfl.cpp b/WebCore/platform/efl/FileSystemEfl.cpp index 31b2e22..cb117bc 100644 --- a/WebCore/platform/efl/FileSystemEfl.cpp +++ b/WebCore/platform/efl/FileSystemEfl.cpp @@ -42,7 +42,9 @@ #include <dlfcn.h> #include <errno.h> #include <fnmatch.h> +#if ENABLE(GLIB_SUPPORT) #include <glib.h> // TODO: remove me after following TODO is solved. +#endif #include <limits.h> #include <stdio.h> #include <sys/stat.h> @@ -55,13 +57,13 @@ CString fileSystemRepresentation(const String& path) { // WARNING: this is just used by platform/network/soup, thus must be GLIB!!! // TODO: move this to CString and use it instead in both, being more standard -#if PLATFORM(WIN_OS) - return path.utf8(); -#else +#if !PLATFORM(WIN_OS) && defined(WTF_USE_SOUP) char* filename = g_uri_unescape_string(path.utf8().data(), 0); CString cfilename(filename); g_free(filename); return cfilename; +#else + return path.utf8(); #endif } diff --git a/WebCore/platform/efl/LoggingEfl.cpp b/WebCore/platform/efl/LoggingEfl.cpp index 1829c80..55de765 100644 --- a/WebCore/platform/efl/LoggingEfl.cpp +++ b/WebCore/platform/efl/LoggingEfl.cpp @@ -23,10 +23,41 @@ #include "config.h" #include "Logging.h" +#include "PlatformString.h" +#include <Eina.h> + namespace WebCore { void InitializeLoggingChannelsIfNecessary() { + static bool didInitializeLoggingChannels = false; + if (didInitializeLoggingChannels) + return; + + didInitializeLoggingChannels = true; + + char* logEnv = getenv("WEBKIT_DEBUG"); + if (!logEnv) + return; + +#if defined(NDEBUG) + EINA_LOG_WARN("WEBKIT_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build."); +#endif + + char** logv = eina_str_split(logEnv, ",", -1); + + EINA_SAFETY_ON_NULL_RETURN(logv); + + for (int i = 0; logv[i]; i++) { + if (WTFLogChannel* channel = getChannelFromName(logv[i])) + channel->state = WTFLogChannelOn; + } + + free(*logv); + free(logv); + + // To disable logging notImplemented set the DISABLE_NI_WARNING + // environment variable to 1. LogNotYetImplemented.state = WTFLogChannelOn; } diff --git a/WebCore/platform/efl/WidgetEfl.cpp b/WebCore/platform/efl/WidgetEfl.cpp index 6dbf2c2..d82e99e 100644 --- a/WebCore/platform/efl/WidgetEfl.cpp +++ b/WebCore/platform/efl/WidgetEfl.cpp @@ -222,8 +222,8 @@ void Widget::applyFallbackCursor() return; } #endif - LOG("Ooops, no fallback to set cursor %s!\n", - m_data->m_cursorGroup.utf8().data()); + LOG_ERROR("Ooops, no fallback to set cursor %s!\n", + m_data->m_cursorGroup.utf8().data()); } void Widget::applyCursor() diff --git a/WebCore/platform/graphics/BitmapImage.h b/WebCore/platform/graphics/BitmapImage.h index 2cf30d3..72f3092 100644 --- a/WebCore/platform/graphics/BitmapImage.h +++ b/WebCore/platform/graphics/BitmapImage.h @@ -175,7 +175,7 @@ protected: virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator); #if (OS(WINCE) && !PLATFORM(QT)) - virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, + virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); #endif diff --git a/WebCore/platform/graphics/Font.cpp b/WebCore/platform/graphics/Font.cpp index 61f5707..0e93d4f 100644 --- a/WebCore/platform/graphics/Font.cpp +++ b/WebCore/platform/graphics/Font.cpp @@ -68,7 +68,7 @@ Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing) , m_letterSpacing(letterSpacing) , m_wordSpacing(wordSpacing) , m_isPlatformFont(false) - , m_needsTranscoding(fontTranscoder().needsTranscoding(family().family().string())) + , m_needsTranscoding(fontTranscoder().needsTranscoding(fd)) { } @@ -77,10 +77,10 @@ Font::Font(const FontPlatformData& fontData, bool isPrinterFont, FontSmoothingMo , m_letterSpacing(0) , m_wordSpacing(0) , m_isPlatformFont(true) - , m_needsTranscoding(fontTranscoder().needsTranscoding(family().family().string())) { m_fontDescription.setUsePrinterFont(isPrinterFont); m_fontDescription.setFontSmoothing(fontSmoothingMode); + m_needsTranscoding = fontTranscoder().needsTranscoding(fontDescription()); m_fontList->setPlatformFont(fontData); } @@ -90,7 +90,7 @@ Font::Font(const Font& other) , m_letterSpacing(other.m_letterSpacing) , m_wordSpacing(other.m_wordSpacing) , m_isPlatformFont(other.m_isPlatformFont) - , m_needsTranscoding(fontTranscoder().needsTranscoding(family().family().string())) + , m_needsTranscoding(fontTranscoder().needsTranscoding(other.m_fontDescription)) { } diff --git a/WebCore/platform/graphics/FontDescription.h b/WebCore/platform/graphics/FontDescription.h index fc63db9..86a4349 100644 --- a/WebCore/platform/graphics/FontDescription.h +++ b/WebCore/platform/graphics/FontDescription.h @@ -65,6 +65,7 @@ public: , m_keywordSize(0) , m_fontSmoothing(AutoSmoothing) , m_textRendering(AutoTextRendering) + , m_isSpecifiedFont(false) { } @@ -92,6 +93,7 @@ public: TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); } FontTraitsMask traitsMask() const; + bool isSpecifiedFont() const { return m_isSpecifiedFont; } void setFamily(const FontFamily& family) { m_familyList = family; } void setComputedSize(float s) { m_computedSize = s; } @@ -106,6 +108,7 @@ public: void setKeywordSize(unsigned s) { m_keywordSize = s; } void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; } void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; } + void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; } private: FontFamily m_familyList; // The list of font families to be used. @@ -130,6 +133,7 @@ private: unsigned m_fontSmoothing : 2; // FontSmoothingMode unsigned m_textRendering : 2; // TextRenderingMode + bool m_isSpecifiedFont : 1; // True if a web page specifies a non-generic font family as the first font family. }; inline bool FontDescription::operator==(const FontDescription& other) const @@ -146,7 +150,8 @@ inline bool FontDescription::operator==(const FontDescription& other) const && m_renderingMode == other.m_renderingMode && m_keywordSize == other.m_keywordSize && m_fontSmoothing == other.m_fontSmoothing - && m_textRendering == other.m_textRendering; + && m_textRendering == other.m_textRendering + && m_isSpecifiedFont == other.m_isSpecifiedFont; } } diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h index 457368b..d5df153 100644 --- a/WebCore/platform/graphics/GraphicsContext.h +++ b/WebCore/platform/graphics/GraphicsContext.h @@ -274,7 +274,7 @@ namespace WebCore { void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); void clipPath(WindRule); void clipToImageBuffer(const FloatRect&, const ImageBuffer*); - void clipConvexPolygon(size_t numPoints, const FloatPoint*); + void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); int textDrawingMode(); void setTextDrawingMode(int); @@ -342,16 +342,16 @@ namespace WebCore { #if OS(WINCE) && !PLATFORM(QT) void setBitmap(PassRefPtr<SharedBitmap>); - const TransformationMatrix& affineTransform() const; - TransformationMatrix& affineTransform(); + const AffineTransform& affineTransform() const; + AffineTransform& affineTransform(); void resetAffineTransform(); void fillRect(const FloatRect&, const Gradient*); void drawText(const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point); void drawFrameControl(const IntRect& rect, unsigned type, unsigned state); void drawFocusRect(const IntRect& rect); void paintTextField(const IntRect& rect, unsigned state); - void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, CompositeOperator compositeOp); - void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize); + void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp); + void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize); void drawIcon(HICON icon, const IntRect& dstRect, UINT flags); HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers. void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true); // The passed in HDC should be the one handed back by getWindowsContext. diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h index f2ae2df..86b77f8 100644 --- a/WebCore/platform/graphics/Path.h +++ b/WebCore/platform/graphics/Path.h @@ -59,6 +59,7 @@ typedef BRegion PlatformPath; namespace WebCore { class PlatformPath; } +typedef WebCore::PlatformPath PlatformPath; #else typedef void PlatformPath; #endif diff --git a/WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp b/WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp index 974c195..1f94f5a 100644 --- a/WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp +++ b/WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp @@ -32,7 +32,9 @@ #include <cairo-ft.h> #include <cairo.h> #include <fontconfig/fcfreetype.h> +#if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT) #include <gdk/gdk.h> +#endif namespace WebCore { @@ -109,8 +111,10 @@ FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const cairo_matrix_init_scale(&fontMatrix, fontDescription.computedPixelSize(), fontDescription.computedPixelSize()); cairo_matrix_init_identity(&ctm); +#if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT) if (GdkScreen* screen = gdk_screen_get_default()) options = gdk_screen_get_font_options(screen); +#endif // gdk_screen_get_font_options() returns NULL if no default options are // set, so we always have to check. @@ -149,8 +153,10 @@ FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool static const cairo_font_options_t* defaultOptions = cairo_font_options_create(); const cairo_font_options_t* options = NULL; +#if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT) if (GdkScreen* screen = gdk_screen_get_default()) options = gdk_screen_get_font_options(screen); +#endif // gdk_screen_get_font_options() returns NULL if no default options are // set, so we always have to check. diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp index 6ed8905..96cd4ee 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp +++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp @@ -504,7 +504,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points cairo_restore(cr); } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index a65874c..2de4d14 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -469,16 +469,24 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points CGContextSetShouldAntialias(context, shouldAntialias()); } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias) { if (paintingDisabled()) return; if (numPoints <= 1) return; + + CGContextRef context = platformContext(); + + if (antialias != shouldAntialias()) + CGContextSetShouldAntialias(context, antialias); - addConvexPolygonToContext(platformContext(), numPoints, points); + addConvexPolygonToContext(context, numPoints, points); clipPath(RULE_NONZERO); + + if (antialias != shouldAntialias()) + CGContextSetShouldAntialias(context, shouldAntialias()); } void GraphicsContext::applyStrokePattern() diff --git a/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/WebCore/platform/graphics/cg/ImageBufferCG.cpp index fe7f83a..feb8cec 100644 --- a/WebCore/platform/graphics/cg/ImageBufferCG.cpp +++ b/WebCore/platform/graphics/cg/ImageBufferCG.cpp @@ -80,7 +80,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, ImageColorSpace imageColorSpace, b case GrayScale: colorSpace.adoptCF(CGColorSpaceCreateDeviceGray()); break; -#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) +#if ((PLATFORM(MAC) || PLATFORM(CHROMIUM)) && !defined(BUILDING_ON_TIGER)) case LinearRGB: colorSpace.adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear)); break; diff --git a/WebCore/platform/graphics/chromium/GLES2Canvas.cpp b/WebCore/platform/graphics/chromium/GLES2Canvas.cpp new file mode 100644 index 0000000..ec188c8 --- /dev/null +++ b/WebCore/platform/graphics/chromium/GLES2Canvas.cpp @@ -0,0 +1,523 @@ +/* + * 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 + * 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" + +#if USE(GLES2_RENDERING) + +#include "GLES2Canvas.h" + +#include "FloatRect.h" +#include "GLES2Context.h" +#include "GLES2Texture.h" + +#include <GLES2/gl2.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#include <wtf/OwnArrayPtr.h> + +namespace WebCore { + +static inline void affineTo3x3(const AffineTransform& transform, GLfloat mat[9]) +{ + mat[0] = transform.a(); + mat[1] = transform.b(); + mat[2] = 0.0f; + mat[3] = transform.c(); + mat[4] = transform.d(); + mat[5] = 0.0f; + mat[6] = transform.e(); + mat[7] = transform.f(); + mat[8] = 1.0f; +} + +struct GLES2Canvas::State { + State() + : m_fillColor(0, 0, 0, 255) + , m_alpha(1.0f) + , m_compositeOp(CompositeSourceOver) + { + } + Color m_fillColor; + float m_alpha; + CompositeOperator m_compositeOp; + AffineTransform m_ctm; +}; + +GLES2Canvas::GLES2Canvas(GLES2Context* context, const IntSize& size) + : m_gles2Context(context) + , m_quadVertices(0) + , m_quadIndices(0) + , m_simpleProgram(0) + , m_texProgram(0) + , m_simpleMatrixLocation(-1) + , m_simpleColorLocation(-1) + , m_simplePositionLocation(-1) + , m_texMatrixLocation(-1) + , m_texTexMatrixLocation(-1) + , m_texSamplerLocation(-1) + , m_texAlphaLocation(-1) + , m_texPositionLocation(-1) + , m_state(0) +{ + m_flipMatrix.translate(-1.0f, 1.0f); + m_flipMatrix.scale(2.0f / size.width(), -2.0f / size.height()); + + m_gles2Context->makeCurrent(); + m_gles2Context->resizeOffscreenContent(size); + m_gles2Context->swapBuffers(); + glViewport(0, 0, size.width(), size.height()); + + m_stateStack.append(State()); + m_state = &m_stateStack.last(); +} + +GLES2Canvas::~GLES2Canvas() +{ + m_gles2Context->makeCurrent(); + if (m_simpleProgram) + glDeleteProgram(m_simpleProgram); + if (m_texProgram) + glDeleteProgram(m_texProgram); + if (m_quadVertices) + glDeleteBuffers(1, &m_quadVertices); + if (m_quadIndices) + glDeleteBuffers(1, &m_quadVertices); +} + +void GLES2Canvas::clearRect(const FloatRect& rect) +{ + m_gles2Context->makeCurrent(); + + glScissor(rect.x(), rect.y(), rect.width(), rect.height()); + glEnable(GL_SCISSOR_TEST); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); +} + +void GLES2Canvas::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace) +{ + m_gles2Context->makeCurrent(); + + glBindBuffer(GL_ARRAY_BUFFER, getQuadVertices()); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, getQuadIndices()); + + float rgba[4]; + color.getRGBA(rgba[0], rgba[1], rgba[2], rgba[3]); + glUniform4f(m_simpleColorLocation, rgba[0] * rgba[3], rgba[1] * rgba[3], rgba[2] * rgba[3], rgba[3]); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); +} + +void GLES2Canvas::fillRect(const FloatRect& rect) +{ + m_gles2Context->makeCurrent(); + + applyCompositeOperator(m_state->m_compositeOp); + + glBindBuffer(GL_ARRAY_BUFFER, getQuadVertices()); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, getQuadIndices()); + + glUseProgram(getSimpleProgram()); + + float rgba[4]; + m_state->m_fillColor.getRGBA(rgba[0], rgba[1], rgba[2], rgba[3]); + glUniform4f(m_simpleColorLocation, rgba[0] * rgba[3], rgba[1] * rgba[3], rgba[2] * rgba[3], rgba[3]); + + AffineTransform matrix(m_flipMatrix); + matrix.multLeft(m_state->m_ctm); + matrix.translate(rect.x(), rect.y()); + matrix.scale(rect.width(), rect.height()); + GLfloat mat[9]; + affineTo3x3(matrix, mat); + glUniformMatrix3fv(m_simpleMatrixLocation, 1, GL_FALSE, mat); + + glVertexAttribPointer(m_simplePositionLocation, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(0)); + + glEnableVertexAttribArray(m_simplePositionLocation); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); +} + +void GLES2Canvas::setFillColor(const Color& color, ColorSpace colorSpace) +{ + m_state->m_fillColor = color; +} + +void GLES2Canvas::setAlpha(float alpha) +{ + m_state->m_alpha = alpha; +} + +void GLES2Canvas::translate(float x, float y) +{ + m_state->m_ctm.translate(x, y); +} + +void GLES2Canvas::rotate(float angleInRadians) +{ + m_state->m_ctm.rotate(angleInRadians * (180.0f / M_PI)); +} + +void GLES2Canvas::scale(const FloatSize& size) +{ + m_state->m_ctm.scale(size.width(), size.height()); +} + +void GLES2Canvas::concatCTM(const AffineTransform& affine) +{ + m_state->m_ctm.multLeft(affine); +} + +void GLES2Canvas::save() +{ + m_stateStack.append(State(m_stateStack.last())); + m_state = &m_stateStack.last(); +} + +void GLES2Canvas::restore() +{ + ASSERT(!m_stateStack.isEmpty()); + m_stateStack.removeLast(); + m_state = &m_stateStack.last(); +} + +void GLES2Canvas::drawTexturedRect(GLES2Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp) +{ + drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp); +} + +void GLES2Canvas::drawTexturedRect(GLES2Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp) +{ + m_gles2Context->makeCurrent(); + + applyCompositeOperator(compositeOp); + + glBindBuffer(GL_ARRAY_BUFFER, getQuadVertices()); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, getQuadIndices()); + checkGLError("glBindBuffer"); + + glUseProgram(getTexProgram()); + checkGLError("glUseProgram"); + + glActiveTexture(GL_TEXTURE0); + texture->bind(); + + glUniform1i(m_texSamplerLocation, 0); + checkGLError("glUniform1i"); + + glUniform1f(m_texAlphaLocation, alpha); + checkGLError("glUniform1f for alpha"); + + AffineTransform matrix(m_flipMatrix); + matrix.multLeft(transform); + matrix.translate(dstRect.x(), dstRect.y()); + matrix.scale(dstRect.width(), dstRect.height()); + GLfloat mat[9]; + affineTo3x3(matrix, mat); + glUniformMatrix3fv(m_texMatrixLocation, 1, GL_FALSE, mat); + checkGLError("glUniformMatrix3fv"); + + AffineTransform texMatrix; + texMatrix.scale(1.0f / texture->width(), 1.0f / texture->height()); + texMatrix.translate(srcRect.x(), srcRect.y()); + texMatrix.scale(srcRect.width(), srcRect.height()); + GLfloat texMat[9]; + affineTo3x3(texMatrix, texMat); + glUniformMatrix3fv(m_texTexMatrixLocation, 1, GL_FALSE, texMat); + checkGLError("glUniformMatrix3fv"); + + glVertexAttribPointer(m_texPositionLocation, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(0)); + + glEnableVertexAttribArray(m_texPositionLocation); + + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); + checkGLError("glDrawElements"); +} + +void GLES2Canvas::setCompositeOperation(CompositeOperator op) +{ + m_state->m_compositeOp = op; +} + +void GLES2Canvas::applyCompositeOperator(CompositeOperator op) +{ + if (op == m_lastCompositeOp) + return; + + switch (op) { + case CompositeClear: + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_ZERO); + break; + case CompositeCopy: + glDisable(GL_BLEND); + break; + case CompositeSourceOver: + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + break; + case CompositeSourceIn: + glEnable(GL_BLEND); + glBlendFunc(GL_DST_ALPHA, GL_ZERO); + break; + case CompositeSourceOut: + glEnable(GL_BLEND); + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ZERO); + break; + case CompositeSourceAtop: + glEnable(GL_BLEND); + glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + case CompositeDestinationOver: + glEnable(GL_BLEND); + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); + break; + case CompositeDestinationIn: + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_SRC_ALPHA); + break; + case CompositeDestinationOut: + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); + break; + case CompositeDestinationAtop: + glEnable(GL_BLEND); + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA); + break; + case CompositeXOR: + glEnable(GL_BLEND); + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + case CompositePlusDarker: + case CompositeHighlight: + // unsupported + glDisable(GL_BLEND); + break; + case CompositePlusLighter: + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + break; + } + m_lastCompositeOp = op; +} + +unsigned GLES2Canvas::getQuadVertices() +{ + if (!m_quadVertices) { + GLfloat vertices[] = { 0.0f, 0.0f, 1.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 0.0f, 1.0f, 1.0f }; + glGenBuffers(1, &m_quadVertices); + glBindBuffer(GL_ARRAY_BUFFER, m_quadVertices); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + } + return m_quadVertices; +} + + +unsigned GLES2Canvas::getQuadIndices() +{ + if (!m_quadIndices) { + GLushort indices[] = { 0, 1, 2, 0, 2, 3}; + + glGenBuffers(1, &m_quadIndices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_quadIndices); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); + } + return m_quadIndices; +} + +static GLuint loadShader(GLenum type, const char* shaderSource) +{ + GLuint shader = glCreateShader(type); + if (!shader) + return 0; + + glShaderSource(shader, 1, &shaderSource, 0); + glCompileShader(shader); + GLint compileStatus; + glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus); + if (!compileStatus) { + int length; + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); + OwnArrayPtr<char> log(new char[length]); + glGetShaderInfoLog(shader, length, 0, log.get()); + LOG_ERROR(log.get()); + glDeleteShader(shader); + return 0; + } + return shader; +} + +unsigned GLES2Canvas::getSimpleProgram() +{ + if (!m_simpleProgram) { + GLuint vertexShader = loadShader(GL_VERTEX_SHADER, + "uniform mat3 matrix;\n" + "uniform vec4 color;\n" + "attribute vec3 position;\n" + "void main() {\n" + " gl_Position = vec4(matrix * position, 1.0);\n" + "}\n"); + if (!vertexShader) + return 0; + GLuint fragmentShader = loadShader(GL_FRAGMENT_SHADER, + "precision mediump float;\n" + "uniform mat3 matrix;\n" + "uniform vec4 color;\n" + "void main() {\n" + " gl_FragColor = color;\n" + "}\n"); + if (!fragmentShader) + return 0; + m_simpleProgram = glCreateProgram(); + if (!m_simpleProgram) + return 0; + glAttachShader(m_simpleProgram, vertexShader); + glAttachShader(m_simpleProgram, fragmentShader); + glLinkProgram(m_simpleProgram); + GLint linkStatus; + glGetProgramiv(m_simpleProgram, GL_LINK_STATUS, &linkStatus); + if (!linkStatus) { + glDeleteProgram(m_simpleProgram); + m_simpleProgram = 0; + } + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + m_simplePositionLocation = glGetAttribLocation(m_simpleProgram, "position"); + m_simpleMatrixLocation = glGetUniformLocation(m_simpleProgram, "matrix"); + m_simpleColorLocation = glGetUniformLocation(m_simpleProgram, "color"); + } + return m_simpleProgram; +} + +unsigned GLES2Canvas::getTexProgram() +{ + if (!m_texProgram) { + GLuint vertexShader = loadShader(GL_VERTEX_SHADER, + "uniform mat3 matrix;\n" + "uniform mat3 texMatrix;\n" + "attribute vec3 position;\n" + "varying vec3 texCoord;\n" + "void main() {\n" + " texCoord = texMatrix * position;\n" + " gl_Position = vec4(matrix * position, 1.0);\n" + "}\n"); + if (!vertexShader) + return 0; + GLuint fragmentShader = loadShader(GL_FRAGMENT_SHADER, + "precision mediump float;\n" + "uniform sampler2D sampler;\n" + "uniform float alpha;\n" + "varying vec3 texCoord;\n" + "void main() {\n" + " gl_FragColor = texture2D(sampler, texCoord.xy)* vec4(alpha);\n" + "}\n"); + if (!fragmentShader) + return 0; + m_texProgram = glCreateProgram(); + if (!m_texProgram) + return 0; + glAttachShader(m_texProgram, vertexShader); + glAttachShader(m_texProgram, fragmentShader); + glLinkProgram(m_texProgram); + GLint linkStatus; + glGetProgramiv(m_texProgram, GL_LINK_STATUS, &linkStatus); + if (!linkStatus) { + glDeleteProgram(m_texProgram); + m_texProgram = 0; + } + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + m_texMatrixLocation = glGetUniformLocation(m_texProgram, "matrix"); + m_texSamplerLocation = glGetUniformLocation(m_texProgram, "sampler"); + m_texTexMatrixLocation = glGetUniformLocation(m_texProgram, "texMatrix"); + m_texPositionLocation = glGetAttribLocation(m_texProgram, "position"); + m_texAlphaLocation = glGetUniformLocation(m_texProgram, "alpha"); + } + return m_texProgram; +} + +GLES2Texture* GLES2Canvas::createTexture(NativeImagePtr ptr, GLES2Texture::Format format, int width, int height) +{ + PassRefPtr<GLES2Texture> texture = m_textures.get(ptr); + if (texture) + return texture.get(); + + texture = GLES2Texture::create(format, width, height); + GLES2Texture* t = texture.get(); + m_textures.set(ptr, texture); + return t; +} + +GLES2Texture* GLES2Canvas::getTexture(NativeImagePtr ptr) +{ + PassRefPtr<GLES2Texture> texture = m_textures.get(ptr); + return texture ? texture.get() : 0; +} + +void GLES2Canvas::checkGLError(const char* header) +{ +#ifndef NDEBUG + GLenum err; + while ((err = glGetError()) != GL_NO_ERROR) { + const char* errorStr = "*** UNKNOWN ERROR ***"; + switch (err) { + case GL_INVALID_ENUM: + errorStr = "GL_INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + errorStr = "GL_INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + errorStr = "GL_INVALID_OPERATION"; + break; + case GL_INVALID_FRAMEBUFFER_OPERATION: + errorStr = "GL_INVALID_FRAMEBUFFER_OPERATION"; + break; + case GL_OUT_OF_MEMORY: + errorStr = "GL_OUT_OF_MEMORY"; + break; + } + if (header) + LOG_ERROR("%s: %s", header, errorStr); + else + LOG_ERROR("%s", errorStr); + } +#endif +} + +} + +#endif diff --git a/WebCore/platform/graphics/chromium/GLES2Canvas.h b/WebCore/platform/graphics/chromium/GLES2Canvas.h new file mode 100644 index 0000000..e3a7a3b --- /dev/null +++ b/WebCore/platform/graphics/chromium/GLES2Canvas.h @@ -0,0 +1,115 @@ +/* + * 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 + * 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 GLES2Canvas_h +#define GLES2Canvas_h + +#if USE(GLES2_RENDERING) + +#include "AffineTransform.h" +#include "Color.h" +#include "ColorSpace.h" +#include "GLES2Texture.h" +#include "GraphicsTypes.h" +#include "ImageSource.h" + +#include <wtf/HashMap.h> +#include <wtf/Noncopyable.h> + +namespace WebCore { + +class FloatRect; +class Color; +class GLES2Context; + +typedef HashMap<NativeImagePtr, RefPtr<GLES2Texture> > TextureHashMap; + +class GLES2Canvas : public Noncopyable { +public: + GLES2Canvas(GLES2Context*, const IntSize&); + ~GLES2Canvas(); + + void fillRect(const FloatRect&, const Color&, ColorSpace); + void fillRect(const FloatRect&); + void clearRect(const FloatRect&); + void setFillColor(const Color&, ColorSpace); + void setAlpha(float alpha); + void setCompositeOperation(CompositeOperator); + void translate(float x, float y); + void rotate(float angleInRadians); + void scale(const FloatSize&); + void concatCTM(const AffineTransform&); + + void save(); + void restore(); + + // non-standard functions + // These are not standard GraphicsContext functions, and should be pushed + // down into a PlatformContextGLES2 at some point. + void drawTexturedRect(GLES2Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator); + void drawTexturedRect(GLES2Texture*, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator); + GLES2Context* gles2Context() { return m_gles2Context; } + GLES2Texture* createTexture(NativeImagePtr, GLES2Texture::Format, int width, int height); + GLES2Texture* getTexture(NativeImagePtr); + +private: + void applyCompositeOperator(CompositeOperator); + void checkGLError(const char* header); + unsigned getQuadVertices(); + unsigned getQuadIndices(); + unsigned getSimpleProgram(); + unsigned getTexProgram(); + + GLES2Context* m_gles2Context; + struct State; + WTF::Vector<State> m_stateStack; + State* m_state; + unsigned m_quadVertices; + unsigned m_quadIndices; + unsigned m_simpleProgram; + unsigned m_texProgram; + int m_simpleMatrixLocation; + int m_simpleColorLocation; + int m_simplePositionLocation; + int m_texMatrixLocation; + int m_texTexMatrixLocation; + int m_texSamplerLocation; + int m_texAlphaLocation; + int m_texPositionLocation; + AffineTransform m_flipMatrix; + TextureHashMap m_textures; + CompositeOperator m_lastCompositeOp; // This is the one last set, not necessarily the one in the state stack. +}; + +} + +#endif + +#endif // GLES2Canvas_h diff --git a/WebCore/platform/graphics/chromium/GLES2Texture.cpp b/WebCore/platform/graphics/chromium/GLES2Texture.cpp new file mode 100644 index 0000000..26c8bf7 --- /dev/null +++ b/WebCore/platform/graphics/chromium/GLES2Texture.cpp @@ -0,0 +1,128 @@ +/* + * 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 + * 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" + +#if USE(GLES2_RENDERING) + +#include "GLES2Texture.h" + +#include <GLES2/gl2.h> + +#include <wtf/OwnArrayPtr.h> + +namespace WebCore { + +GLES2Texture::GLES2Texture(unsigned int textureId, Format format, int width, int height) + : m_textureId(textureId) + , m_format(format) + , m_width(width) + , m_height(height) +{ +} + +GLES2Texture::~GLES2Texture() +{ + glDeleteTextures(1, &m_textureId); +} + +PassRefPtr<GLES2Texture> GLES2Texture::create(Format format, int width, int height) +{ + GLuint textureId; + glGenTextures(1, &textureId); + if (!textureId) + return 0; + + glBindTexture(GL_TEXTURE_2D, textureId); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + + int max; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); + if (width > max || height > max) + ASSERT(!"texture too big"); + + return adoptRef(new GLES2Texture(textureId, format, width, height)); +} + +static void convertFormat(GLES2Texture::Format format, unsigned int* glFormat, unsigned int* glType, bool* swizzle) +{ + *swizzle = false; + switch (format) { + case GLES2Texture::RGBA8: + *glFormat = GL_RGBA; + *glType = GL_UNSIGNED_BYTE; + break; + case GLES2Texture::BGRA8: +// FIXME: Once we have support for extensions, we should check for EXT_texture_format_BGRA8888, +// and use that if present. + *glFormat = GL_RGBA; + *glType = GL_UNSIGNED_BYTE; + *swizzle = true; + break; + default: + ASSERT(!"bad format"); + break; + } +} + +void GLES2Texture::load(void* pixels) +{ + unsigned int glFormat, glType; + bool swizzle; + convertFormat(m_format, &glFormat, &glType, &swizzle); + glBindTexture(GL_TEXTURE_2D, m_textureId); + if (swizzle) { + ASSERT(glFormat == GL_RGBA && glType == GL_UNSIGNED_BYTE); + // FIXME: This could use PBO's to save doing an extra copy here. + int size = m_width * m_height; + unsigned* pixels32 = static_cast<unsigned*>(pixels); + OwnArrayPtr<unsigned> buf(new unsigned[size]); + unsigned* bufptr = buf.get(); + for (int i = 0; i < size; ++i) { + unsigned pixel = pixels32[i]; + bufptr[i] = pixel & 0xFF00FF00 | ((pixel & 0x00FF0000) >> 16) | ((pixel & 0x000000FF) << 16); + } + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, glFormat, glType, buf.get()); + } else + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, glFormat, glType, pixels); +} + +void GLES2Texture::bind() +{ + glBindTexture(GL_TEXTURE_2D, m_textureId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +} + +#endif diff --git a/WebCore/platform/graphics/chromium/GLES2Texture.h b/WebCore/platform/graphics/chromium/GLES2Texture.h new file mode 100644 index 0000000..346365a --- /dev/null +++ b/WebCore/platform/graphics/chromium/GLES2Texture.h @@ -0,0 +1,63 @@ +/* + * 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 + * 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 GLES2Texture_h +#define GLES2Texture_h + +#if USE(GLES2_RENDERING) + +#include "RefCounted.h" +#include "RefPtr.h" + +namespace WebCore { + +class GLES2Texture : public RefCounted<GLES2Texture> { +public: + ~GLES2Texture(); + enum Format { RGBA8, BGRA8 }; + static PassRefPtr<GLES2Texture> create(Format, int width, int height); + void bind(); + void load(void* pixels); + Format format() const { return m_format; } + int width() const { return m_width; } + int height() const { return m_height; } +private: + GLES2Texture(unsigned int textureId, Format format, int width, int height); + unsigned int m_textureId; + Format m_format; + int m_width; + int m_height; +}; + +} + +#endif + +#endif // GLES2Texture_h diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 7869c45..7184439 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -1255,6 +1255,7 @@ static HashSet<String> mimeTypeCache() || g_str_equal(name, "audio/x-m4a")) { cache.add(String("video/mp4")); cache.add(String("audio/aac")); + cache.add(String("audio/mp4")); cached = true; } @@ -1270,11 +1271,13 @@ static HashSet<String> mimeTypeCache() if (g_str_equal(name, "audio/x-wav")) { cache.add(String("audio/wav")); + cache.add(String("audio/x-wav")); cached = true; } if (g_str_equal(name, "audio/mpeg")) { cache.add(String(name)); + cache.add(String("audio/x-mpeg")); cached = true; // This is what we are handling: @@ -1289,8 +1292,10 @@ static HashSet<String> mimeTypeCache() cache.add(String("audio/mp1")); if (minLayer <= 2 && 2 <= maxLayer) cache.add(String("audio/mp2")); - if (minLayer <= 3 && 3 <= maxLayer) + if (minLayer <= 3 && 3 <= maxLayer) { + cache.add(String("audio/x-mp3")); cache.add(String("audio/mp3")); + } } } } diff --git a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp index f9e1980..6561c11 100644 --- a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp +++ b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp @@ -152,7 +152,7 @@ void GraphicsContext::drawConvexPolygon(size_t pointsLength, const FloatPoint* p m_data->m_view->StrokePolygon(bPoints, pointsLength, true, getHaikuStrokeStyle()); } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index a828070..e560e15 100644 --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -529,7 +529,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points p->restore(); } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; @@ -793,9 +793,11 @@ void GraphicsContext::beginPath() void GraphicsContext::addPath(const Path& path) { - QPainterPath newPath = m_data->currentPath; - newPath.addPath(path.platformPath()); - m_data->currentPath = newPath; + if (!m_data->currentPath.elementCount()) { + m_data->currentPath = path.platformPath(); + return; + } + m_data->currentPath.addPath(path.platformPath()); } bool GraphicsContext::inTransparencyLayer() const diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp index b4ca617..bc25003 100644 --- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp +++ b/WebCore/platform/graphics/qt/ImageBufferQt.cpp @@ -175,32 +175,53 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i endy = size.height(); int numRows = endy - originy; - QImage image = imageData.m_pixmap.toImage(); - if (multiplied == Unmultiplied) - image = image.convertToFormat(QImage::Format_ARGB32); - else - image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + // NOTE: For unmultiplied data, we undo the premultiplication below. + QImage image = imageData.m_pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); ASSERT(!image.isNull()); - unsigned destBytesPerRow = 4 * rect.width(); - unsigned char* destRows = data + desty * destBytesPerRow + destx * 4; - for (int y = 0; y < numRows; ++y) { + const int bytesPerLine = image.bytesPerLine(); #if QT_VERSION >= 0x040700 - const quint32* scanLine = reinterpret_cast<const quint32*>(image.constScanLine(y + originy)); + const uchar* bits = image.constBits(); #else - quint32* scanLine = reinterpret_cast<quint32*>(image.scanLine(y + originy)); + const uchar* bits = image.bits(); #endif - for (int x = 0; x < numColumns; x++) { - QRgb value = scanLine[x + originx]; - int basex = x * 4; - - destRows[basex] = qRed(value); - destRows[basex + 1] = qGreen(value); - destRows[basex + 2] = qBlue(value); - destRows[basex + 3] = qAlpha(value); + + quint32* destRows = reinterpret_cast<quint32*>(&data[desty * rect.width() + destx]); + + if (multiplied == Unmultiplied) { + for (int y = 0; y < numRows; ++y) { + const quint32* scanLine = reinterpret_cast<const quint32*>(bits + (y + originy) * bytesPerLine); + for (int x = 0; x < numColumns; x++) { + QRgb pixel = scanLine[x + originx]; + int alpha = qAlpha(pixel); + // Un-premultiply and convert RGB to BGR. + if (alpha == 255) + destRows[x] = (0xFF000000 + | (qBlue(pixel) << 16) + | (qGreen(pixel) << 8) + | (qRed(pixel))); + else if (alpha > 0) + destRows[x] = ((alpha << 24) + | (((255 * qBlue(pixel)) / alpha)) << 16) + | (((255 * qGreen(pixel)) / alpha) << 8) + | ((255 * qRed(pixel)) / alpha); + else + destRows[x] = 0; + } + destRows += rect.width(); + } + } else { + for (int y = 0; y < numRows; ++y) { + const quint32* scanLine = reinterpret_cast<const quint32*>(bits + (y + originy) * bytesPerLine); + for (int x = 0; x < numColumns; x++) { + QRgb pixel = scanLine[x + originx]; + // Convert RGB to BGR. + destRows[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); + + } + destRows += rect.width(); } - destRows += destBytesPerRow; } return result; @@ -216,6 +237,22 @@ PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect return getImageData<Premultiplied>(rect, m_data, m_size); } +static inline unsigned int premultiplyABGRtoARGB(unsigned int x) +{ + unsigned int a = x >> 24; + if (a == 255) + return (x << 16) | ((x >> 16) & 0xff) | (x & 0xff00ff00); + unsigned int t = (x & 0xff00ff) * a; + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + t = ((t << 16) | (t >> 16)) & 0xff00ff; + + x = ((x >> 8) & 0xff) * a; + x = (x + ((x >> 8) & 0xff) + 0x80); + x &= 0xff00; + x |= t | (a << 24); + return x; +} + template <Multiply multiplied> void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& data, const IntSize& size) { @@ -247,22 +284,33 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& unsigned srcBytesPerRow = 4 * source->width(); - QRect destRect(destx, desty, endx - destx, endy - desty); - - QImage::Format format = multiplied == Unmultiplied ? QImage::Format_ARGB32 : QImage::Format_ARGB32_Premultiplied; - QImage image(destRect.size(), format); - - unsigned char* srcRows = source->data()->data()->data() + originy * srcBytesPerRow + originx * 4; - for (int y = 0; y < numRows; ++y) { - quint32* scanLine = reinterpret_cast<quint32*>(image.scanLine(y)); - for (int x = 0; x < numColumns; x++) { - // ImageData stores the pixels in RGBA while QImage is ARGB - quint32 pixel = reinterpret_cast<quint32*>(srcRows + 4 * x)[0]; - pixel = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); - scanLine[x] = pixel; + // NOTE: For unmultiplied input data, we do the premultiplication below. + QImage image(numColumns, numRows, QImage::Format_ARGB32_Premultiplied); + uchar* bits = image.bits(); + const int bytesPerLine = image.bytesPerLine(); + + const quint32* srcScanLine = reinterpret_cast<const quint32*>(source->data()->data()->data() + originy * srcBytesPerRow + originx * 4); + + if (multiplied == Unmultiplied) { + for (int y = 0; y < numRows; ++y) { + quint32* destScanLine = reinterpret_cast<quint32*>(bits + y * bytesPerLine); + for (int x = 0; x < numColumns; x++) { + // Premultiply and convert BGR to RGB. + quint32 pixel = srcScanLine[x]; + destScanLine[x] = premultiplyABGRtoARGB(pixel); + } + srcScanLine += source->width(); + } + } else { + for (int y = 0; y < numRows; ++y) { + quint32* destScanLine = reinterpret_cast<quint32*>(bits + y * bytesPerLine); + for (int x = 0; x < numColumns; x++) { + // Convert BGR to RGB. + quint32 pixel = srcScanLine[x]; + destScanLine[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); + } + srcScanLine += source->width(); } - - srcRows += srcBytesPerRow; } bool isPainting = data.m_painter->isActive(); @@ -278,7 +326,7 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& } data.m_painter->setCompositionMode(QPainter::CompositionMode_Source); - data.m_painter->drawImage(destRect, image); + data.m_painter->drawImage(destx, desty, image); if (!isPainting) data.m_painter->end(); diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index 0c1898b..7994244 100644 --- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -54,6 +54,10 @@ #include <wtf/Assertions.h> #include <wtf/MathExtras.h> +#if USE(GLES2_RENDERING) +#include "GLES2Canvas.h" +#endif + using namespace std; namespace WebCore { @@ -243,6 +247,11 @@ void GraphicsContext::savePlatformState() if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->save(); +#endif + // Save our private State. platformContext()->save(); } @@ -252,6 +261,11 @@ void GraphicsContext::restorePlatformState() if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->restore(); +#endif + // Restore our private State. platformContext()->restore(); } @@ -290,6 +304,7 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness if (!isRectSkiaSafe(getCTM(), r)) return; + platformContext()->prepareForSoftwareDraw(); SkPath path; path.addOval(r, SkPath::kCW_Direction); // only perform the inset if we won't invert r @@ -307,6 +322,7 @@ void GraphicsContext::addPath(const Path& path) { if (paintingDisabled()) return; + platformContext()->prepareForSoftwareDraw(); platformContext()->addPath(*path.platformPath()); } @@ -314,6 +330,7 @@ void GraphicsContext::beginPath() { if (paintingDisabled()) return; + platformContext()->prepareForSoftwareDraw(); platformContext()->beginPath(); } @@ -329,6 +346,16 @@ void GraphicsContext::clearRect(const FloatRect& rect) if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) { + platformContext()->prepareForHardwareDraw(); + platformContext()->gpuCanvas()->clearRect(rect); + return; + } +#endif + + platformContext()->prepareForSoftwareDraw(); + SkRect r = rect; if (!isRectSkiaSafe(getCTM(), r)) ClipRectToCanvas(*platformContext()->canvas(), r, &r); @@ -348,6 +375,7 @@ void GraphicsContext::clip(const FloatRect& rect) if (!isRectSkiaSafe(getCTM(), r)) return; + platformContext()->prepareForSoftwareDraw(); platformContext()->canvas()->clipRect(r); } @@ -360,6 +388,7 @@ void GraphicsContext::clip(const Path& path) if (!isPathSkiaSafe(getCTM(), p)) return; + platformContext()->prepareForSoftwareDraw(); platformContext()->clipPathAntiAliased(p); } @@ -441,6 +470,12 @@ void GraphicsContext::concatCTM(const AffineTransform& affine) { if (paintingDisabled()) return; + +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->concatCTM(affine); +#endif + platformContext()->canvas()->concat(affine); } @@ -454,6 +489,8 @@ void GraphicsContext::drawConvexPolygon(size_t numPoints, if (numPoints <= 1) return; + platformContext()->prepareForSoftwareDraw(); + SkPath path; path.incReserve(numPoints); @@ -478,7 +515,7 @@ void GraphicsContext::drawConvexPolygon(size_t numPoints, } } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; @@ -499,6 +536,7 @@ void GraphicsContext::drawEllipse(const IntRect& elipseRect) if (!isRectSkiaSafe(getCTM(), rect)) return; + platformContext()->prepareForSoftwareDraw(); SkPaint paint; platformContext()->setupPaintForFilling(&paint); platformContext()->canvas()->drawOval(rect, paint); @@ -524,6 +562,7 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width * if (!rectCount) return; + platformContext()->prepareForSoftwareDraw(); SkRegion focusRingRegion; const SkScalar focusRingOutset = WebCoreFloatToSkScalar(0.5); for (unsigned i = 0; i < rectCount; i++) { @@ -558,6 +597,8 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) if (!isPointSkiaSafe(getCTM(), point1) || !isPointSkiaSafe(getCTM(), point2)) return; + platformContext()->prepareForSoftwareDraw(); + FloatPoint p1 = point1; FloatPoint p2 = point2; bool isVerticalLine = (p1.x() == p2.x()); @@ -604,6 +645,8 @@ void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& pt, if (paintingDisabled()) return; + platformContext()->prepareForSoftwareDraw(); + // Create the pattern we'll use to draw the underline. static SkBitmap* misspellBitmap = 0; if (!misspellBitmap) { @@ -684,6 +727,8 @@ void GraphicsContext::drawLineForText(const IntPoint& pt, if (width <= 0) return; + platformContext()->prepareForSoftwareDraw(); + int thickness = SkMax32(static_cast<int>(strokeThickness()), 1); SkRect r; r.fLeft = SkIntToScalar(pt.x()); @@ -704,6 +749,8 @@ void GraphicsContext::drawRect(const IntRect& rect) if (paintingDisabled()) return; + platformContext()->prepareForSoftwareDraw(); + SkRect r = rect; if (!isRectSkiaSafe(getCTM(), r)) { // See the fillRect below. @@ -722,6 +769,8 @@ void GraphicsContext::fillPath() if (!isPathSkiaSafe(getCTM(), path)) return; + platformContext()->prepareForSoftwareDraw(); + const GraphicsContextState& state = m_common->state; path.setFillType(state.fillRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType); @@ -745,6 +794,16 @@ void GraphicsContext::fillRect(const FloatRect& rect) ClipRectToCanvas(*platformContext()->canvas(), r, &r); } +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient) { + platformContext()->prepareForHardwareDraw(); + platformContext()->gpuCanvas()->fillRect(rect); + return; + } +#endif + + platformContext()->prepareForSoftwareDraw(); + SkPaint paint; platformContext()->setupPaintForFilling(&paint); platformContext()->canvas()->drawRect(r, paint); @@ -757,6 +816,16 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient) { + platformContext()->prepareForHardwareDraw(); + platformContext()->gpuCanvas()->fillRect(rect, color, colorSpace); + return; + } +#endif + + platformContext()->prepareForSoftwareDraw(); + SkRect r = rect; if (!isRectSkiaSafe(getCTM(), r)) { // Special case when the rectangle overflows fixed point. This is a @@ -789,6 +858,8 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, if (paintingDisabled()) return; + platformContext()->prepareForSoftwareDraw(); + SkRect r = rect; if (!isRectSkiaSafe(getCTM(), r)) // See fillRect(). @@ -872,6 +943,12 @@ void GraphicsContext::scale(const FloatSize& size) { if (paintingDisabled()) return; + +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->scale(size); +#endif + platformContext()->canvas()->scale(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(size.height())); } @@ -880,6 +957,10 @@ void GraphicsContext::setAlpha(float alpha) { if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->setAlpha(alpha); +#endif platformContext()->setAlpha(alpha); } @@ -887,6 +968,10 @@ void GraphicsContext::setCompositeOperation(CompositeOperator op) { if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->setCompositeOperation(op); +#endif platformContext()->setXfermodeMode(WebCoreCompositeToSkiaComposite(op)); } @@ -973,6 +1058,11 @@ void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorS { if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->setFillColor(color, colorSpace); +#endif + platformContext()->setFillColor(color.rgb()); } @@ -1102,6 +1192,8 @@ void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan) if (paintingDisabled()) return; + platformContext()->prepareForSoftwareDraw(); + SkPaint paint; SkRect oval = r; if (strokeStyle() == NoStroke) { @@ -1133,6 +1225,8 @@ void GraphicsContext::strokePath() if (!isPathSkiaSafe(getCTM(), path)) return; + platformContext()->prepareForSoftwareDraw(); + SkPaint paint; platformContext()->setupPaintForStroking(&paint, 0, 0); platformContext()->canvas()->drawPath(path, paint); @@ -1146,6 +1240,8 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth) if (!isRectSkiaSafe(getCTM(), rect)) return; + platformContext()->prepareForSoftwareDraw(); + SkPaint paint; platformContext()->setupPaintForStroking(&paint, 0, 0); paint.setStrokeWidth(WebCoreFloatToSkScalar(lineWidth)); @@ -1157,6 +1253,11 @@ void GraphicsContext::rotate(float angleInRadians) if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->rotate(angleInRadians); +#endif + platformContext()->canvas()->rotate(WebCoreFloatToSkScalar( angleInRadians * (180.0f / 3.14159265f))); } @@ -1166,6 +1267,11 @@ void GraphicsContext::translate(float w, float h) if (paintingDisabled()) return; +#if USE(GLES2_RENDERING) + if (platformContext()->useGPU()) + platformContext()->gpuCanvas()->translate(w, h); +#endif + platformContext()->canvas()->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScalar(h)); } diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index f8192fe..26c44f2 100644 --- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -74,10 +74,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, ImageColorSpace imageColorSpace, b // Make the background transparent. It would be nice if this wasn't // required, but the canvas is currently filled with the magic transparency // color. Can we have another way to manage this? - // - // Avoid drawing on a zero-sized canvas. Skia can't handle it. - if (!size.isZero()) - m_data.m_canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); + m_data.m_canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); success = true; } @@ -131,6 +128,13 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap, const IntSize& size) { RefPtr<ImageData> result = ImageData::create(rect.width(), rect.height()); + + if (bitmap.config() == SkBitmap::kNo_Config) { + // This is an empty SkBitmap that could not be configured. + ASSERT(size.width() == 0 || size.height() == 0); + return result; + } + unsigned char* data = result->data()->data()->data(); if (rect.x() < 0 || rect.y() < 0 || diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp index 15bd9b4..65c6e95 100644 --- a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp +++ b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp @@ -44,7 +44,15 @@ #include "SkShader.h" #include "SkDashPathEffect.h" +#if USE(GLES2_RENDERING) +#include "GLES2Canvas.h" +#include "GLES2Context.h" +#include "GLES2Texture.h" +#include <GLES2/gl2.h> +#endif + #include <wtf/MathExtras.h> +#include <wtf/OwnArrayPtr.h> #include <wtf/Vector.h> namespace WebCore @@ -199,6 +207,11 @@ PlatformContextSkia::PlatformContextSkia(skia::PlatformCanvas* canvas) #if OS(WINDOWS) , m_drawingToImageBuffer(false) #endif +#if USE(GLES2_RENDERING) + , m_useGPU(false) + , m_gpuCanvas(0) + , m_backingStoreState(None) +#endif { m_stateStack.append(State()); m_state = &m_stateStack.last(); @@ -661,3 +674,117 @@ void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths) m_canvas->restore(); } + +#if USE(GLES2_RENDERING) +void PlatformContextSkia::setGLES2Context(WebCore::GLES2Context* context, const WebCore::IntSize& size) +{ + m_useGPU = true; + m_gpuCanvas = new WebCore::GLES2Canvas(context, size); +} + +void PlatformContextSkia::prepareForSoftwareDraw() const +{ + if (!m_useGPU) + return; + + if (m_backingStoreState == Hardware) { + // Depending on the blend mode we need to do one of a few things: + + // * For associative blend modes, we can draw into an initially empty + // canvas and then composite the results on top of the hardware drawn + // results before the next hardware draw or swapBuffers(). + + // * For non-associative blend modes we have to do a readback and then + // software draw. When we re-upload in this mode we have to blow + // away whatever is in the hardware backing store (do a copy instead + // of a compositing operation). + + if (m_state->m_xferMode == SkXfermode::kSrcOver_Mode) { + // Last drawn on hardware; clear out the canvas. + m_canvas->save(); + SkRect bounds = {0, 0, m_canvas->getDevice()->width(), m_canvas->getDevice()->height()}; + m_canvas->clipRect(bounds, SkRegion::kReplace_Op); + m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); + m_canvas->restore(); + // Start compositing into the empty canvas. + m_backingStoreState = Mixed; + } else { + readbackHardwareToSoftware(); + // When we switch back to hardware copy the results, don't composite. + m_backingStoreState = Software; + } + } else if (m_backingStoreState == Mixed) { + if (m_state->m_xferMode != SkXfermode::kSrcOver_Mode) { + // Have to composite our currently software drawn data... + uploadSoftwareToHardware(WebCore::CompositeSourceOver); + // then do a readback so we can hardware draw stuff. + readbackHardwareToSoftware(); + m_backingStoreState = Software; + } + } +} + +void PlatformContextSkia::prepareForHardwareDraw() const +{ + if (!m_useGPU) + return; + + if (m_backingStoreState == Software) { + // Last drawn in software; upload everything we've drawn. + uploadSoftwareToHardware(WebCore::CompositeCopy); + } else if (m_backingStoreState == Mixed) { + // Stuff in software/hardware, composite the software stuff on top of + // the hardware stuff. + uploadSoftwareToHardware(WebCore::CompositeSourceOver); + } + m_backingStoreState = Hardware; +} + +void PlatformContextSkia::syncSoftwareCanvas() const +{ + if (!m_useGPU) + return; + + if (m_backingStoreState == Hardware) + readbackHardwareToSoftware(); + else if (m_backingStoreState == Mixed) { + // Have to composite our currently software drawn data.. + uploadSoftwareToHardware(WebCore::CompositeSourceOver); + // then do a readback. + readbackHardwareToSoftware(); + m_backingStoreState = Software; + } + m_backingStoreState = Software; +} + +void PlatformContextSkia::uploadSoftwareToHardware(WebCore::CompositeOperator op) const +{ + const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(false); + SkAutoLockPixels lock(bitmap); + m_gpuCanvas->gles2Context()->makeCurrent(); + // FIXME: Keep a texture around for this rather than constantly creating/destroying one. + RefPtr<WebCore::GLES2Texture> texture = WebCore::GLES2Texture::create(WebCore::GLES2Texture::BGRA8, bitmap.width(), bitmap.height()); + texture->load(bitmap.getPixels()); + WebCore::IntRect rect(0, 0, bitmap.width(), bitmap.height()); + gpuCanvas()->drawTexturedRect(texture.get(), rect, rect, WebCore::DeviceColorSpace, op); +} + +void PlatformContextSkia::readbackHardwareToSoftware() const +{ + const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(true); + SkAutoLockPixels lock(bitmap); + m_gpuCanvas->gles2Context()->makeCurrent(); + int width = bitmap.width(), height = bitmap.height(); + OwnArrayPtr<uint32_t> buf(new uint32_t[width]); + // Flips the image vertically. + for (int y = 0; y < height; ++y) { + uint32_t* pixels = bitmap.getAddr32(0, y); + glReadPixels(0, height - 1 - y, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + for (int i = 0; i < width; ++i) { + uint32_t pixel = pixels[i]; + // Swizzles from RGBA -> BGRA. + pixels[i] = pixel & 0xFF00FF00 | ((pixel & 0x00FF0000) >> 16) | ((pixel & 0x000000FF) << 16); + } + } +} +#endif diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.h b/WebCore/platform/graphics/skia/PlatformContextSkia.h index 88a8ec7..2099dd0 100644 --- a/WebCore/platform/graphics/skia/PlatformContextSkia.h +++ b/WebCore/platform/graphics/skia/PlatformContextSkia.h @@ -41,6 +41,14 @@ #include "SkPaint.h" #include "SkPath.h" +#if USE(GLES2_RENDERING) +namespace WebCore { +enum CompositeOperator; +class GLES2Canvas; +class GLES2Context; +} +#endif + #include <wtf/Vector.h> // This class holds the platform-specific state for GraphicsContext. We put @@ -174,6 +182,24 @@ public: void setImageResamplingHint(const WebCore::IntSize& srcSize, const WebCore::FloatSize& dstSize); void clearImageResamplingHint(); bool hasImageResamplingHint() const; +#if USE(GLES2_RENDERING) + bool useGPU() { return m_useGPU; } + void setGLES2Context(WebCore::GLES2Context*, const WebCore::IntSize&); + WebCore::GLES2Canvas* gpuCanvas() const { return m_gpuCanvas.get(); } +#endif + +#if USE(GLES2_RENDERING) + // Call these before making a call that manipulates the underlying + // skia::PlatformCanvas or WebCore::GLES2Canvas + void prepareForSoftwareDraw() const; + void prepareForHardwareDraw() const; + // Call to force the skia::PlatformCanvas to contain all rendering results. + void syncSoftwareCanvas() const; +#else + void prepareForSoftwareDraw() const {} + void prepareForHardwareDraw() const {} + void syncSoftwareCanvas() const {} +#endif private: #if OS(LINUX) || OS(WINDOWS) @@ -183,6 +209,11 @@ private: #endif void applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths); +#if USE(GLES2_RENDERING) + void uploadSoftwareToHardware(WebCore::CompositeOperator) const; + void readbackHardwareToSoftware() const; +#endif + // Defines drawing style. struct State; @@ -206,6 +237,11 @@ private: #if OS(WINDOWS) bool m_drawingToImageBuffer; #endif +#if USE(GLES2_RENDERING) + bool m_useGPU; + OwnPtr<WebCore::GLES2Canvas> m_gpuCanvas; + mutable enum { None, Software, Mixed, Hardware } m_backingStoreState; +#endif }; -#endif // PlatformContextSkia_h +#endif // PlatformContextSkia_h diff --git a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp index 5292b82..e4466c8 100644 --- a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp +++ b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp @@ -948,7 +948,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points } } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; @@ -1160,12 +1160,12 @@ void GraphicsContext::concatCTM(const AffineTransform& transform) m_data->concatCTM(transform); } -TransformationMatrix& GraphicsContext::affineTransform() +AffineTransform& GraphicsContext::affineTransform() { return m_data->m_transform; } -const TransformationMatrix& GraphicsContext::affineTransform() const +const AffineTransform& GraphicsContext::affineTransform() const { return m_data->m_transform; } @@ -1268,8 +1268,8 @@ void GraphicsContext::fillRoundedRect(const IntRect& fillRect, const IntSize& to IntRect dstRect = fillRect; - dstRect.move(shadowSize); - dstRect.inflate(shadowBlur); + dstRect.move(stableRound(shadowSize.width()), stableRound(shadowSize.height())); + dstRect.inflate(stableRound(shadowBlur)); dstRect = m_data->mapRect(dstRect); FloatSize newTopLeft(m_data->mapSize(topLeft)); @@ -1513,7 +1513,7 @@ void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient) int width = rect.width(); int height = rect.height(); FloatSize d = gradient->p1() - gradient->p0(); - bool vertical = abs(d.height()) > abs(d.width()); + bool vertical = fabs(d.height()) > fabs(d.width()); for (size_t i = 0; i < numStops; ++i) { const Gradient::ColorStop& stop = stops[i]; int iTv = i ? 2 * i - 1 : 0; @@ -1868,7 +1868,7 @@ void GraphicsContext::paintTextField(const IntRect& rect, unsigned state) FillRect(dc, &rectWin, reinterpret_cast<HBRUSH>(((state & DFCS_INACTIVE) ? COLOR_BTNFACE : COLOR_WINDOW) + 1)); } -void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, const IntRect& srcRect, CompositeOperator compositeOp) +void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp) { if (!m_data->m_opacity) return; @@ -1891,7 +1891,7 @@ void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, co } void GraphicsContext::drawBitmapPattern(SharedBitmap* bmp, const FloatRect& tileRectIn, const AffineTransform& patternTransform, - const FloatPoint& phase, CompositeOperator op, const FloatRect& destRectIn, const IntSize& origSourceSize) + const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRectIn, const IntSize& origSourceSize) { if (!m_data->m_opacity) return; @@ -1912,7 +1912,7 @@ void GraphicsContext::drawBitmapPattern(SharedBitmap* bmp, const FloatRect& tile AffineTransform transform = m_data->m_transform; transform.translate(moved.width(), moved.height()); - bmp->drawPattern(dc, transform, tileRectIn, patternTransform, phase, op, destRectIn, origSourceSize); + bmp->drawPattern(dc, transform, tileRectIn, patternTransform, phase, styleColorSpace, op, destRectIn, origSourceSize); if (!bmp->hasAlpha()) transparentDC.fillAlphaChannel(); diff --git a/WebCore/platform/graphics/wince/ImageBufferWince.cpp b/WebCore/platform/graphics/wince/ImageBufferWince.cpp index 4b739c8..1a25f4f 100644 --- a/WebCore/platform/graphics/wince/ImageBufferWince.cpp +++ b/WebCore/platform/graphics/wince/ImageBufferWince.cpp @@ -26,8 +26,10 @@ #include "Image.h" #include "ImageData.h" #include "JPEGEncoder.h" +#include "NotImplemented.h" #include "PNGEncoder.h" #include "SharedBitmap.h" +#include "UnusedParam.h" #include <wtf/UnusedParam.h> namespace WebCore { @@ -43,24 +45,24 @@ public: virtual IntSize size() const { return IntSize(m_data->m_bitmap->width(), m_data->m_bitmap->height()); } virtual void destroyDecodedData(bool destroyAll = true) {} virtual unsigned decodedSize() const { return 0; } - virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator); + virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator); virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, - const FloatPoint& phase, CompositeOperator, const FloatRect& destRect); + const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); const ImageBufferData* m_data; }; -void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp) +void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp) { IntRect intDstRect = enclosingIntRect(dstRect); IntRect intSrcRect(srcRect); - m_data->m_bitmap->draw(ctxt, intDstRect, intSrcRect, compositeOp); + m_data->m_bitmap->draw(ctxt, intDstRect, intSrcRect, styleColorSpace, compositeOp); } void BufferedImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform, - const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect) + const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect) { - m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, phase, op, destRect, size()); + m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, phase, styleColorSpace, op, destRect, size()); } ImageBufferData::ImageBufferData(const IntSize& size) @@ -216,6 +218,12 @@ void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& so putImageData<true>(source, sourceRect, destPoint, m_data.m_bitmap.get()); } +void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable) +{ + UNUSED_PARAM(lookUpTable); + notImplemented(); +} + String ImageBuffer::toDataURL(const String& mimeType, const double*) const { if (!m_data.m_bitmap->bytes()) diff --git a/WebCore/platform/graphics/wince/PlatformPathWince.cpp b/WebCore/platform/graphics/wince/PlatformPathWince.cpp index cde5461..b42b52c 100644 --- a/WebCore/platform/graphics/wince/PlatformPathWince.cpp +++ b/WebCore/platform/graphics/wince/PlatformPathWince.cpp @@ -671,7 +671,7 @@ void PlatformPath::addArcTo(const FloatPoint& fp1, const FloatPoint& fp2, float double d01 = v01.length(); double d21 = v21.length(); - double angle = (piDouble - abs(asin(cross / (d01 * d21)))) * 0.5; + double angle = (piDouble - fabs(asin(cross / (d01 * d21)))) * 0.5; double span = radius * tan(angle); double rate = span / d01; PathPoint startPoint; diff --git a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp index 2951223..b77a03b 100644 --- a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp +++ b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp @@ -81,23 +81,23 @@ FontPlatformData::FontPlatformData(const FontDescription& desc, const AtomicStri // this is a moot issue on Linux and Mac as they only accept the point argument. So, // we use the pixel size constructor on Windows, but we use point size on Linux and Mac. #if __WXMSW__ - m_font = new FontHolder(new wxFont( wxSize(0, -desc.computedPixelSize()), + m_font = adoptRef(new FontHolder(new wxFont( wxSize(0, -desc.computedPixelSize()), fontFamilyToWxFontFamily(desc.genericFamily()), italicToWxFontStyle(desc.italic()), fontWeightToWxFontWeight(desc.weight()), false, family.string() ) - ); + )); #else - m_font = new FontHolder(new wxFont( desc.computedPixelSize(), + m_font = adoptRef(new FontHolder(new wxFont( desc.computedPixelSize(), fontFamilyToWxFontFamily(desc.genericFamily()), italicToWxFontStyle(desc.italic()), fontWeightToWxFontWeight(desc.weight()), false, family.string() ) - ); + )); #endif #if OS(DARWIN) && !defined(wxOSX_USE_CORE_TEXT) #if wxCHECK_VERSION(2,9,0) diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp index 01dce9e..4d5afd7 100644 --- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -256,7 +256,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points delete [] polygon; } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp index 924fabc..c08b03f 100644 --- a/WebCore/platform/gtk/ClipboardGtk.cpp +++ b/WebCore/platform/gtk/ClipboardGtk.cpp @@ -18,6 +18,7 @@ #include "ClipboardGtk.h" #include "CachedImage.h" +#include "DragData.h" #include "Editor.h" #include "Element.h" #include "FileList.h" @@ -27,6 +28,7 @@ #include "Pasteboard.h" #include "PasteboardHelper.h" #include "RenderImage.h" +#include "ScriptExecutionContext.h" #include "StringHash.h" #include "markup.h" #include <wtf/text/CString.h> @@ -43,24 +45,31 @@ enum ClipboardType { ClipboardTypeUnknown }; -PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame) { - return ClipboardGtk::create(policy, gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD), false); + return ClipboardGtk::create(policy, gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD), false, frame); } -ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, GtkClipboard* clipboard) +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame) +{ + return ClipboardGtk::create(policy, dragData->platformData(), true, frame); +} + +ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, GtkClipboard* clipboard, Frame* frame) : Clipboard(policy, false) , m_dataObject(DataObjectGtk::forClipboard(clipboard)) , m_clipboard(clipboard) , m_helper(Pasteboard::generalPasteboard()->helper()) + , m_frame(frame) { } -ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, bool forDragging) +ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, bool forDragging, Frame* frame) : Clipboard(policy, forDragging) , m_dataObject(dataObject) , m_clipboard(0) , m_helper(Pasteboard::generalPasteboard()->helper()) + , m_frame(frame) { } @@ -255,8 +264,9 @@ PassRefPtr<FileList> ClipboardGtk::files() const RefPtr<FileList> fileList = FileList::create(); Vector<String> fileVector(m_dataObject->files()); + ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext(); for (size_t i = 0; i < fileVector.size(); i++) - fileList->append(File::create(fileVector[i])); + fileList->append(File::create(scriptExecutionContext, fileVector[i])); return fileList.release(); } diff --git a/WebCore/platform/gtk/ClipboardGtk.h b/WebCore/platform/gtk/ClipboardGtk.h index c3438c4..5b42ac6 100644 --- a/WebCore/platform/gtk/ClipboardGtk.h +++ b/WebCore/platform/gtk/ClipboardGtk.h @@ -34,20 +34,21 @@ typedef struct _GtkClipboard GtkClipboard; namespace WebCore { class CachedImage; + class Frame; class PasteboardHelper; // State available during IE's events for drag and drop and copy/paste // Created from the EventHandlerGtk to be used by the dom class ClipboardGtk : public Clipboard { public: - static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, GtkClipboard* clipboard, bool isForDragging) + static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, GtkClipboard* clipboard, bool isForDragging, Frame* frame) { - return adoptRef(new ClipboardGtk(policy, clipboard)); + return adoptRef(new ClipboardGtk(policy, clipboard, frame)); } - static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, bool isForDragging) + static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, bool isForDragging, Frame* frame) { - return adoptRef(new ClipboardGtk(policy, dataObject, isForDragging)); + return adoptRef(new ClipboardGtk(policy, dataObject, isForDragging, frame)); } virtual ~ClipboardGtk(); @@ -77,12 +78,13 @@ namespace WebCore { PassRefPtr<DataObjectGtk> dataObject() { return m_dataObject; } private: - ClipboardGtk(ClipboardAccessPolicy, GtkClipboard*); - ClipboardGtk(ClipboardAccessPolicy, PassRefPtr<DataObjectGtk>, bool); + ClipboardGtk(ClipboardAccessPolicy, GtkClipboard*, Frame*); + ClipboardGtk(ClipboardAccessPolicy, PassRefPtr<DataObjectGtk>, bool, Frame*); RefPtr<DataObjectGtk> m_dataObject; GtkClipboard* m_clipboard; PasteboardHelper* m_helper; + Frame* m_frame; }; } diff --git a/WebCore/platform/gtk/DragDataGtk.cpp b/WebCore/platform/gtk/DragDataGtk.cpp index 68f7ffc..69966aa 100644 --- a/WebCore/platform/gtk/DragDataGtk.cpp +++ b/WebCore/platform/gtk/DragDataGtk.cpp @@ -62,11 +62,6 @@ Color DragData::asColor() const return Color(); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardGtk::create(policy, m_platformDragData, true); -} - bool DragData::containsCompatibleContent() const { return containsPlainText() || containsURL() || m_platformDragData->hasMarkup() || containsColor() || containsFiles(); diff --git a/WebCore/platform/haiku/ClipboardHaiku.cpp b/WebCore/platform/haiku/ClipboardHaiku.cpp index f73be01..9931131 100644 --- a/WebCore/platform/haiku/ClipboardHaiku.cpp +++ b/WebCore/platform/haiku/ClipboardHaiku.cpp @@ -42,6 +42,11 @@ namespace WebCore { +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData*, Frame*) +{ + return ClipboardHaiku::create(policy, true); +} + ClipboardHaiku::ClipboardHaiku(ClipboardAccessPolicy policy, bool forDragging) : Clipboard(policy, forDragging) { diff --git a/WebCore/platform/haiku/DragDataHaiku.cpp b/WebCore/platform/haiku/DragDataHaiku.cpp index 7f40b8a..7c2dc9c 100644 --- a/WebCore/platform/haiku/DragDataHaiku.cpp +++ b/WebCore/platform/haiku/DragDataHaiku.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "DragData.h" -#include "ClipboardHaiku.h" #include "Document.h" #include "DocumentFragment.h" #include "NotImplemented.h" @@ -76,11 +75,6 @@ Color DragData::asColor() const return Color(); } -WTF::PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardHaiku::create(policy, true); -} - bool DragData::containsCompatibleContent() const { return containsColor() || containsURL() || containsPlainText(); diff --git a/WebCore/platform/mac/ClipboardMac.mm b/WebCore/platform/mac/ClipboardMac.mm index ddfa0d5..0cbb3f6 100644 --- a/WebCore/platform/mac/ClipboardMac.mm +++ b/WebCore/platform/mac/ClipboardMac.mm @@ -29,6 +29,7 @@ #import "DOMElementInternal.h" #import "DragClient.h" #import "DragController.h" +#import "DragData.h" #import "Editor.h" #import "FoundationExtras.h" #import "FileList.h" @@ -37,6 +38,7 @@ #import "Page.h" #import "Pasteboard.h" #import "RenderImage.h" +#import "ScriptExecutionContext.h" #import "SecurityOrigin.h" #import "WebCoreSystemInterface.h" @@ -46,6 +48,11 @@ typedef unsigned NSUInteger; namespace WebCore { +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame) +{ + return ClipboardMac::create(true, [dragData->platformData() draggingPasteboard], policy, frame); +} + ClipboardMac::ClipboardMac(bool forDragging, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame *frame) : Clipboard(policy, forDragging) , m_pasteboard(pasteboard) @@ -306,11 +313,12 @@ PassRefPtr<FileList> ClipboardMac::files() const NSArray *absoluteURLs = absoluteURLsFromPasteboardFilenames(m_pasteboard.get()); NSUInteger count = [absoluteURLs count]; + ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext(); RefPtr<FileList> fileList = FileList::create(); for (NSUInteger x = 0; x < count; x++) { NSURL *absoluteURL = [NSURL URLWithString:[absoluteURLs objectAtIndex:x]]; ASSERT([absoluteURL isFileURL]); - fileList->append(File::create([absoluteURL path])); + fileList->append(File::create(scriptExecutionContext, [absoluteURL path])); } return fileList.release(); // We will always return a FileList, sometimes empty } diff --git a/WebCore/platform/mac/DragDataMac.mm b/WebCore/platform/mac/DragDataMac.mm index fa416ed..9cb4836 100644 --- a/WebCore/platform/mac/DragDataMac.mm +++ b/WebCore/platform/mac/DragDataMac.mm @@ -27,8 +27,6 @@ #import "DragData.h" #if ENABLE(DRAG_SUPPORT) -#import "ClipboardMac.h" -#import "ClipboardAccessPolicy.h" #import "Document.h" #import "DocumentFragment.h" #import "DOMDocumentFragment.h" @@ -100,11 +98,6 @@ Color DragData::asColor() const (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5)); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardMac::create(true, [m_platformDragData draggingPasteboard], policy, 0); -} - bool DragData::containsCompatibleContent() const { NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard]; diff --git a/WebCore/platform/mac/LocalizedStringsMac.mm b/WebCore/platform/mac/LocalizedStringsMac.mm index 510249a..8b7df04 100644 --- a/WebCore/platform/mac/LocalizedStringsMac.mm +++ b/WebCore/platform/mac/LocalizedStringsMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2006, 2009 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2006, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,813 +26,514 @@ #import "config.h" #import "LocalizedStrings.h" -#import "BlockExceptions.h" #import "IntSize.h" +#import "LocalizationStrategy.h" +#import "PlatformStrategies.h" #import "PlatformString.h" -#import "WebCoreViewFactory.h" namespace WebCore { String inputElementAltText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] inputElementAltText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->inputElementAltText(); } String resetButtonDefaultLabel() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] resetButtonDefaultLabel]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->resetButtonDefaultLabel(); } String searchableIndexIntroduction() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] searchableIndexIntroduction]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->searchableIndexIntroduction(); } String submitButtonDefaultLabel() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] submitButtonDefaultLabel]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->submitButtonDefaultLabel(); } String fileButtonChooseFileLabel() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] fileButtonChooseFileLabel]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->fileButtonChooseFileLabel(); } String fileButtonNoFileSelectedLabel() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] fileButtonNoFileSelectedLabel]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->fileButtonNoFileSelectedLabel(); } String copyImageUnknownFileLabel() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] copyImageUnknownFileLabel]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->copyImageUnknownFileLabel(); } #if ENABLE(CONTEXT_MENUS) String contextMenuItemTagOpenLinkInNewWindow() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenLinkInNewWindow]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagOpenLinkInNewWindow(); } String contextMenuItemTagDownloadLinkToDisk() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagDownloadLinkToDisk]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagDownloadLinkToDisk(); } String contextMenuItemTagCopyLinkToClipboard() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCopyLinkToClipboard]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCopyLinkToClipboard(); } String contextMenuItemTagOpenImageInNewWindow() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenImageInNewWindow]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagOpenImageInNewWindow(); } String contextMenuItemTagDownloadImageToDisk() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagDownloadImageToDisk]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagDownloadImageToDisk(); } String contextMenuItemTagCopyImageToClipboard() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCopyImageToClipboard]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCopyImageToClipboard(); } String contextMenuItemTagOpenFrameInNewWindow() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenFrameInNewWindow]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagOpenFrameInNewWindow(); } String contextMenuItemTagCopy() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCopy]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCopy(); } String contextMenuItemTagGoBack() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagGoBack]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagGoBack(); } String contextMenuItemTagGoForward() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagGoForward]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagGoForward(); } String contextMenuItemTagStop() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStop]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagStop(); } String contextMenuItemTagReload() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagReload]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagReload(); } String contextMenuItemTagCut() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCut]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCut(); } String contextMenuItemTagPaste() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagPaste]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagPaste(); } String contextMenuItemTagNoGuessesFound() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagNoGuessesFound]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagNoGuessesFound(); } String contextMenuItemTagIgnoreSpelling() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagIgnoreSpelling]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagIgnoreSpelling(); } String contextMenuItemTagLearnSpelling() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagLearnSpelling]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagLearnSpelling(); } String contextMenuItemTagSearchInSpotlight() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSearchInSpotlight]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSearchInSpotlight(); } String contextMenuItemTagSearchWeb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSearchWeb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSearchWeb(); } String contextMenuItemTagLookUpInDictionary() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagLookUpInDictionary]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagLookUpInDictionary(); } String contextMenuItemTagOpenLink() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenLink]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagOpenLink(); } String contextMenuItemTagIgnoreGrammar() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagIgnoreGrammar]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagIgnoreGrammar(); } String contextMenuItemTagSpellingMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSpellingMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSpellingMenu(); } String contextMenuItemTagShowSpellingPanel(bool show) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowSpellingPanel:show]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagShowSpellingPanel(show); } String contextMenuItemTagCheckSpelling() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCheckSpelling]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCheckSpelling(); } String contextMenuItemTagCheckSpellingWhileTyping() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCheckSpellingWhileTyping]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCheckSpellingWhileTyping(); } String contextMenuItemTagCheckGrammarWithSpelling() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCheckGrammarWithSpelling]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCheckGrammarWithSpelling(); } String contextMenuItemTagFontMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagFontMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagFontMenu(); } String contextMenuItemTagShowFonts() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowFonts]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagShowFonts(); } String contextMenuItemTagBold() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagBold]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagBold(); } String contextMenuItemTagItalic() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagItalic]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagItalic(); } String contextMenuItemTagUnderline() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagUnderline]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagUnderline(); } String contextMenuItemTagOutline() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOutline]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagOutline(); } String contextMenuItemTagStyles() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStyles]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagStyles(); } String contextMenuItemTagShowColors() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowColors]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagShowColors(); } String contextMenuItemTagSpeechMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSpeechMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSpeechMenu(); } String contextMenuItemTagStartSpeaking() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStartSpeaking]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagStartSpeaking(); } String contextMenuItemTagStopSpeaking() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStopSpeaking]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagStopSpeaking(); } String contextMenuItemTagWritingDirectionMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagWritingDirectionMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagWritingDirectionMenu(); } String contextMenuItemTagTextDirectionMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagTextDirectionMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagTextDirectionMenu(); } String contextMenuItemTagDefaultDirection() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagDefaultDirection]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagDefaultDirection(); } String contextMenuItemTagLeftToRight() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagLeftToRight]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagLeftToRight(); } String contextMenuItemTagRightToLeft() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagRightToLeft]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagRightToLeft(); } String contextMenuItemTagCorrectSpellingAutomatically() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCorrectSpellingAutomatically]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCorrectSpellingAutomatically(); } String contextMenuItemTagSubstitutionsMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSubstitutionsMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSubstitutionsMenu(); } String contextMenuItemTagShowSubstitutions(bool show) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowSubstitutions:show]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagShowSubstitutions(show); } String contextMenuItemTagSmartCopyPaste() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartCopyPaste]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSmartCopyPaste(); } String contextMenuItemTagSmartQuotes() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartQuotes]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSmartQuotes(); } String contextMenuItemTagSmartDashes() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartDashes]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSmartDashes(); } String contextMenuItemTagSmartLinks() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartLinks]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagSmartLinks(); } String contextMenuItemTagTextReplacement() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagTextReplacement]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagTextReplacement(); } String contextMenuItemTagTransformationsMenu() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagTransformationsMenu]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagTransformationsMenu(); } String contextMenuItemTagMakeUpperCase() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagMakeUpperCase]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagMakeUpperCase(); } String contextMenuItemTagMakeLowerCase() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagMakeLowerCase]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagMakeLowerCase(); } String contextMenuItemTagCapitalize() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCapitalize]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagCapitalize(); } String contextMenuItemTagChangeBack(const String& replacedString) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagChangeBack:replacedString]; - END_BLOCK_OBJC_EXCEPTIONS; - return replacedString; + return platformStrategies()->localizationStrategy()->contextMenuItemTagChangeBack(replacedString); } String contextMenuItemTagInspectElement() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] contextMenuItemTagInspectElement]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->contextMenuItemTagInspectElement(); } + #endif // ENABLE(CONTEXT_MENUS) String searchMenuNoRecentSearchesText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] searchMenuNoRecentSearchesText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->searchMenuNoRecentSearchesText(); } String searchMenuRecentSearchesText () { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] searchMenuRecentSearchesText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->searchMenuRecentSearchesText (); } String searchMenuClearRecentSearchesText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] searchMenuClearRecentSearchesText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->searchMenuClearRecentSearchesText(); } String AXWebAreaText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXWebAreaText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXWebAreaText(); } String AXLinkText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXLinkText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXLinkText(); } String AXListMarkerText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXListMarkerText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXListMarkerText(); } String AXImageMapText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXImageMapText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXImageMapText(); } String AXHeadingText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXHeadingText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXHeadingText(); } String AXDefinitionListTermText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXDefinitionListTermText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXDefinitionListTermText(); } - + String AXDefinitionListDefinitionText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXDefinitionListDefinitionText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXDefinitionListDefinitionText(); } - + String AXARIAContentGroupText(const String& ariaType) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXARIAContentGroupText:ariaType]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXARIAContentGroupText(ariaType); } String AXButtonActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXButtonActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXButtonActionVerb(); } String AXRadioButtonActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXRadioButtonActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXRadioButtonActionVerb(); } String AXTextFieldActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXTextFieldActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXTextFieldActionVerb(); } String AXCheckedCheckBoxActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXCheckedCheckBoxActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXCheckedCheckBoxActionVerb(); } String AXUncheckedCheckBoxActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXUncheckedCheckBoxActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXUncheckedCheckBoxActionVerb(); } String AXLinkActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXLinkActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXLinkActionVerb(); } String AXMenuListPopupActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXMenuListPopupActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXMenuListPopupActionVerb(); } String AXMenuListActionVerb() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] AXMenuListActionVerb]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->AXMenuListActionVerb(); } String missingPluginText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] missingPluginText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->missingPluginText(); } String crashedPluginText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] crashedPluginText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->crashedPluginText(); } String multipleFileUploadText(unsigned numberOfFiles) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] multipleFileUploadTextForNumberOfFiles:numberOfFiles]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->multipleFileUploadText(numberOfFiles); } String unknownFileSizeText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] unknownFileSizeText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->unknownFileSizeText(); } String imageTitle(const String& filename, const IntSize& size) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] imageTitleForFilename:filename width:size.width() height:size.height()]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->imageTitle(filename, size); } String mediaElementLoadingStateText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] mediaElementLoadingStateText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->mediaElementLoadingStateText(); } String mediaElementLiveBroadcastStateText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] mediaElementLiveBroadcastStateText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->mediaElementLiveBroadcastStateText(); } String localizedMediaControlElementString(const String& controlName) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] localizedMediaControlElementString:controlName]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->localizedMediaControlElementString(controlName); } String localizedMediaControlElementHelpText(const String& controlName) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] localizedMediaControlElementHelpText:controlName]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->localizedMediaControlElementHelpText(controlName); } String localizedMediaTimeDescription(float time) { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] localizedMediaTimeDescription:time]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->localizedMediaTimeDescription(time); } String validationMessageValueMissingText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessageValueMissingText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); } String validationMessageTypeMismatchText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessageTypeMismatchText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessageTypeMismatchText(); } String validationMessagePatternMismatchText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessagePatternMismatchText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessagePatternMismatchText(); } String validationMessageTooLongText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessageTooLongText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessageTooLongText(); } String validationMessageRangeUnderflowText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessageRangeUnderflowText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessageRangeUnderflowText(); } String validationMessageRangeOverflowText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessageRangeOverflowText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessageRangeOverflowText(); } String validationMessageStepMismatchText() { - BEGIN_BLOCK_OBJC_EXCEPTIONS; - return [[WebCoreViewFactory sharedFactory] validationMessageStepMismatchText]; - END_BLOCK_OBJC_EXCEPTIONS; - return String(); + return platformStrategies()->localizationStrategy()->validationMessageStepMismatchText(); } -} +} // namespace WebCore diff --git a/WebCore/platform/network/FormDataBuilder.cpp b/WebCore/platform/network/FormDataBuilder.cpp index fb78b08..da28fc2 100644 --- a/WebCore/platform/network/FormDataBuilder.cpp +++ b/WebCore/platform/network/FormDataBuilder.cpp @@ -25,7 +25,6 @@ #include "config.h" #include "FormDataBuilder.h" -#include "CSSHelper.h" #include "Document.h" #include "Frame.h" #include "FrameLoader.h" @@ -38,67 +37,6 @@ namespace WebCore { -FormDataBuilder::FormDataBuilder() - : m_isPostMethod(false) - , m_isMultiPartForm(false) - , m_encodingType("application/x-www-form-urlencoded") -{ -} - -FormDataBuilder::~FormDataBuilder() -{ -} - -void FormDataBuilder::parseAction(const String& action) -{ - // FIXME: Can we parse into a KURL? - m_action = deprecatedParseURL(action); -} - -void FormDataBuilder::parseEncodingType(const String& type) -{ - if (type.contains("multipart", false) || type.contains("form-data", false)) { - m_encodingType = "multipart/form-data"; - m_isMultiPartForm = true; - } else if (type.contains("text", false) || type.contains("plain", false)) { - m_encodingType = "text/plain"; - m_isMultiPartForm = false; - } else { - m_encodingType = "application/x-www-form-urlencoded"; - m_isMultiPartForm = false; - } -} - -void FormDataBuilder::parseMethodType(const String& type) -{ - if (equalIgnoringCase(type, "post")) - m_isPostMethod = true; - else if (equalIgnoringCase(type, "get")) - m_isPostMethod = false; -} - -TextEncoding FormDataBuilder::dataEncoding(Document* document) const -{ - String acceptCharset = m_acceptCharset; - acceptCharset.replace(',', ' '); - - Vector<String> charsets; - acceptCharset.split(' ', charsets); - - TextEncoding encoding; - - Vector<String>::const_iterator end = charsets.end(); - for (Vector<String>::const_iterator it = charsets.begin(); it != end; ++it) { - if ((encoding = TextEncoding(*it)).isValid()) - return encoding; - } - - if (Frame* frame = document->frame()) - return frame->loader()->writer()->encoding(); - - return Latin1Encoding(); -} - // Helper functions static inline void append(Vector<char>& buffer, char string) { @@ -140,6 +78,28 @@ static void appendQuotedString(Vector<char>& buffer, const CString& string) } } +TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptCharset, Document* document) +{ + String normalizedAcceptCharset = acceptCharset; + normalizedAcceptCharset.replace(',', ' '); + + Vector<String> charsets; + normalizedAcceptCharset.split(' ', charsets); + + TextEncoding encoding; + + Vector<String>::const_iterator end = charsets.end(); + for (Vector<String>::const_iterator it = charsets.begin(); it != end; ++it) { + if ((encoding = TextEncoding(*it)).isValid()) + return encoding; + } + + if (Frame* frame = document->frame()) + return frame->loader()->writer()->encoding(); + + return Latin1Encoding(); +} + Vector<char> FormDataBuilder::generateUniqueBoundaryString() { Vector<char> boundary; diff --git a/WebCore/platform/network/FormDataBuilder.h b/WebCore/platform/network/FormDataBuilder.h index 559906e..26b90af 100644 --- a/WebCore/platform/network/FormDataBuilder.h +++ b/WebCore/platform/network/FormDataBuilder.h @@ -36,31 +36,7 @@ class TextEncoding; class FormDataBuilder : public Noncopyable { public: - FormDataBuilder(); - ~FormDataBuilder(); - - bool isPostMethod() const { return m_isPostMethod; } - void setIsPostMethod(bool value) { m_isPostMethod = value; } - - bool isMultiPartForm() const { return m_isMultiPartForm; } - void setIsMultiPartForm(bool value) { m_isMultiPartForm = value; } - - const String& action() const { return m_action; } - - const String& target() const { return m_target; } - void setTarget(const String& target) { m_target = target; } - - String encodingType() const { return m_encodingType; } - void setEncodingType(const String& value) { m_encodingType = value; } - - String acceptCharset() const { return m_acceptCharset; } - void setAcceptCharset(const String& value) { m_acceptCharset = value; } - - void parseAction(const String&); - void parseEncodingType(const String&); - void parseMethodType(const String&); - - TextEncoding dataEncoding(Document*) const; + static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document* document); // Helper functions used by HTMLFormElement/WMLGoElement for multi-part form data static Vector<char> generateUniqueBoundaryString(); @@ -75,13 +51,7 @@ public: static void encodeStringAsFormData(Vector<char>&, const WTF::CString&); private: - bool m_isPostMethod; - bool m_isMultiPartForm; - - String m_action; - String m_target; - String m_encodingType; - String m_acceptCharset; + FormDataBuilder() {} }; } diff --git a/WebCore/platform/qt/ClipboardQt.cpp b/WebCore/platform/qt/ClipboardQt.cpp index 7d22349..6ca4830 100644 --- a/WebCore/platform/qt/ClipboardQt.cpp +++ b/WebCore/platform/qt/ClipboardQt.cpp @@ -31,6 +31,7 @@ #include "CSSHelper.h" #include "CachedImage.h" #include "Document.h" +#include "DragData.h" #include "Element.h" #include "FileList.h" #include "Frame.h" @@ -68,6 +69,11 @@ static bool isHtmlMimeType(const String& type) return type == "text/html" || type.startsWith("text/html;"); } +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame*) +{ + return ClipboardQt::create(policy, dragData->platformData()); +} + ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, const QMimeData* readableClipboard) : Clipboard(policy, true) , m_readableData(readableClipboard) diff --git a/WebCore/platform/qt/DragDataQt.cpp b/WebCore/platform/qt/DragDataQt.cpp index 808606d..4033123 100644 --- a/WebCore/platform/qt/DragDataQt.cpp +++ b/WebCore/platform/qt/DragDataQt.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "DragData.h" -#include "ClipboardQt.h" #include "Document.h" #include "DocumentFragment.h" #include "markup.h" @@ -100,11 +99,6 @@ Color DragData::asColor() const return qvariant_cast<QColor>(m_platformDragData->colorData()); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardQt::create(policy, m_platformDragData); -} - bool DragData::containsCompatibleContent() const { if (!m_platformDragData) diff --git a/WebCore/platform/text/transcoder/FontTranscoder.cpp b/WebCore/platform/text/transcoder/FontTranscoder.cpp index 12678e8..8e2f33f 100644 --- a/WebCore/platform/text/transcoder/FontTranscoder.cpp +++ b/WebCore/platform/text/transcoder/FontTranscoder.cpp @@ -32,6 +32,7 @@ #include "FontTranscoder.h" #include "CharacterNames.h" +#include "FontDescription.h" #include "TextEncoding.h" namespace WebCore { @@ -59,8 +60,9 @@ FontTranscoder::FontTranscoder() m_converterTypes.add(AtomicString(unicodeNameMeiryo, sizeof(unicodeNameMeiryo) / sizeof(UChar)), BackslashToYenSign); } -FontTranscoder::ConverterType FontTranscoder::converterType(const AtomicString& fontFamily, const TextEncoding* encoding) const +FontTranscoder::ConverterType FontTranscoder::converterType(const FontDescription& fontDescription, const TextEncoding* encoding) const { + const AtomicString& fontFamily = fontDescription.family().family().string(); if (!fontFamily.isNull()) { HashMap<AtomicString, ConverterType>::const_iterator found = m_converterTypes.find(fontFamily); if (found != m_converterTypes.end()) @@ -68,17 +70,16 @@ FontTranscoder::ConverterType FontTranscoder::converterType(const AtomicString& } // IE's default fonts for Japanese encodings change backslashes into yen signs. - // FIXME: We don't need transcoding when the document explicitly - // specifies a font which doesn't change backslashes into yen signs. - if (encoding && encoding->backslashAsCurrencySymbol() != '\\') + // We emulate this behavior only when no font is explicitly specified. + if (encoding && encoding->backslashAsCurrencySymbol() != '\\' && !fontDescription.isSpecifiedFont()) return BackslashToYenSign; return NoConversion; } -void FontTranscoder::convert(String& text, const AtomicString& fontFamily, const TextEncoding* encoding) const +void FontTranscoder::convert(String& text, const FontDescription& fontDescription, const TextEncoding* encoding) const { - switch (converterType(fontFamily, encoding)) { + switch (converterType(fontDescription, encoding)) { case BackslashToYenSign: { // FIXME: TextEncoding.h has similar code. We need to factor them out. text.replace('\\', yenSign); @@ -90,9 +91,9 @@ void FontTranscoder::convert(String& text, const AtomicString& fontFamily, const } } -bool FontTranscoder::needsTranscoding(const AtomicString& fontFamily, const TextEncoding* encoding) const +bool FontTranscoder::needsTranscoding(const FontDescription& fontDescription, const TextEncoding* encoding) const { - ConverterType type = converterType(fontFamily, encoding); + ConverterType type = converterType(fontDescription, encoding); return type != NoConversion; } diff --git a/WebCore/platform/text/transcoder/FontTranscoder.h b/WebCore/platform/text/transcoder/FontTranscoder.h index f013453..1fdc936 100644 --- a/WebCore/platform/text/transcoder/FontTranscoder.h +++ b/WebCore/platform/text/transcoder/FontTranscoder.h @@ -37,12 +37,13 @@ namespace WebCore { +class FontDescription; class TextEncoding; class FontTranscoder : public Noncopyable { public: - void convert(String& text, const AtomicString& fontFamily, const TextEncoding* = 0) const; - bool needsTranscoding(const AtomicString& fontFamily, const TextEncoding* = 0) const; + void convert(String& text, const FontDescription&, const TextEncoding* = 0) const; + bool needsTranscoding(const FontDescription&, const TextEncoding* = 0) const; private: FontTranscoder(); @@ -52,7 +53,7 @@ private: NoConversion, BackslashToYenSign, }; - ConverterType converterType(const AtomicString& fontFamily, const TextEncoding*) const; + ConverterType converterType(const FontDescription&, const TextEncoding*) const; HashMap<AtomicString, ConverterType> m_converterTypes; diff --git a/WebCore/platform/win/BitmapInfo.cpp b/WebCore/platform/win/BitmapInfo.cpp index 9a2312c..514f722 100644 --- a/WebCore/platform/win/BitmapInfo.cpp +++ b/WebCore/platform/win/BitmapInfo.cpp @@ -1,6 +1,8 @@ /* * Copyright (C) 2009 Apple Inc. All Rights Reserved. * Copyright (C) 2009 Brent Fulgham + * Copyright (C) 2007-2009 Torch Mobile, Inc. All Rights Reserved. + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,16 +29,19 @@ #include "config.h" #include "BitmapInfo.h" +#include <wtf/Assertions.h> + namespace WebCore { -BitmapInfo bitmapInfoForSize(int width, int height) +BitmapInfo bitmapInfoForSize(int width, int height, WORD bitCount) { + ASSERT_ARG(bitCount, bitCount == 16 || bitCount == 32); + BitmapInfo bitmapInfo; - bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = width; + bitmapInfo.bmiHeader.biWidth = width; bitmapInfo.bmiHeader.biHeight = height; bitmapInfo.bmiHeader.biPlanes = 1; - bitmapInfo.bmiHeader.biBitCount = 32; + bitmapInfo.bmiHeader.biBitCount = bitCount; bitmapInfo.bmiHeader.biCompression = BI_RGB; bitmapInfo.bmiHeader.biSizeImage = 0; bitmapInfo.bmiHeader.biXPelsPerMeter = 0; @@ -53,14 +58,14 @@ BitmapInfo::BitmapInfo() bmiHeader.biSize = sizeof(BITMAPINFOHEADER); } -BitmapInfo BitmapInfo::create(const IntSize& size) +BitmapInfo BitmapInfo::create(const IntSize& size, WORD bitCount) { - return bitmapInfoForSize(size.width(), size.height()); + return bitmapInfoForSize(size.width(), size.height(), bitCount); } -BitmapInfo BitmapInfo::createBottomUp(const IntSize& size) +BitmapInfo BitmapInfo::createBottomUp(const IntSize& size, WORD bitCount) { - return bitmapInfoForSize(size.width(), -size.height()); + return bitmapInfoForSize(size.width(), -size.height(), bitCount); } } // namespace WebCore diff --git a/WebCore/platform/win/BitmapInfo.h b/WebCore/platform/win/BitmapInfo.h index 0127fdb..d1c3319 100644 --- a/WebCore/platform/win/BitmapInfo.h +++ b/WebCore/platform/win/BitmapInfo.h @@ -1,6 +1,8 @@ /* * Copyright (C) 2009 Apple Inc. All Rights Reserved. * Copyright (C) 2009 Brent Fulgham + * Copyright (C) 2007-2009 Torch Mobile, Inc. All Rights Reserved. + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,17 +29,25 @@ #ifndef BitmapInfo_h #define BitmapInfo_h -#include <windows.h> #include "IntSize.h" +#include <windows.h> namespace WebCore { struct BitmapInfo : public BITMAPINFO { - BitmapInfo (); - static BitmapInfo create(const IntSize&); - static BitmapInfo createBottomUp(const IntSize&); -}; + BitmapInfo(); + static BitmapInfo create(const IntSize&, WORD bitCount = 32); + static BitmapInfo createBottomUp(const IntSize&, WORD bitCount = 32); + bool is16bit() const { return bmiHeader.biBitCount == 16; } + bool is32bit() const { return bmiHeader.biBitCount == 32; } + unsigned width() const { return abs(bmiHeader.biWidth); } + unsigned height() const { return abs(bmiHeader.biHeight); } + IntSize size() const { return IntSize(width(), height()); } + unsigned paddedWidth() const { return is16bit() ? (width() + 1) & ~0x1 : width(); } + unsigned numPixels() const { return paddedWidth() * height(); } + unsigned paddedBytesPerLine() const { return is16bit() ? paddedWidth() * 2 : width() * 4; } + unsigned bytesPerLine() const { return width() * bmiHeader.biBitCount / 8; }}; } // namespace WebCore #endif // BitmapInfo_h diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/WebCore/platform/win/ClipboardUtilitiesWin.cpp index e6af7ef..0130a70 100644 --- a/WebCore/platform/win/ClipboardUtilitiesWin.cpp +++ b/WebCore/platform/win/ClipboardUtilitiesWin.cpp @@ -31,23 +31,47 @@ #include "PlatformString.h" #include "TextEncoding.h" #include "markup.h" -#include <CoreFoundation/CoreFoundation.h> #include <shlwapi.h> #include <wininet.h> // for INTERNET_MAX_URL_LENGTH -#include <wtf/RetainPtr.h> #include <wtf/text/CString.h> +#if PLATFORM(CF) +#include <CoreFoundation/CoreFoundation.h> +#include <wtf/RetainPtr.h> +#endif + namespace WebCore { +#if PLATFORM(CF) FORMATETC* cfHDropFormat() { static FORMATETC urlFormat = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; return &urlFormat; } +static bool urlFromPath(CFStringRef path, String& url) +{ + if (!path) + return false; + + RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false)); + if (!cfURL) + return false; + + url = CFURLGetString(cfURL.get()); + + // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost". + if (url.startsWith("file://localhost/")) + url.remove(7, 9); + + return true; +} +#endif + static bool getWebLocData(IDataObject* dataObject, String& url, String* title) { bool succeeded = false; +#if PLATFORM(CF) WCHAR filename[MAX_PATH]; WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH]; @@ -55,8 +79,8 @@ static bool getWebLocData(IDataObject* dataObject, String& url, String* title) if (FAILED(dataObject->GetData(cfHDropFormat(), &medium))) return false; - HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal); - + HDROP hdrop = static_cast<HDROP>(GlobalLock(medium.hGlobal)); + if (!hdrop) return false; @@ -81,6 +105,7 @@ exit: // Free up memory. DragFinish(hdrop); GlobalUnlock(medium.hGlobal); +#endif return succeeded; } @@ -113,9 +138,9 @@ HGLOBAL createGlobalData(const KURL& url, const String& title) HGLOBAL cbData = ::GlobalAlloc(GPTR, size * sizeof(UChar)); if (cbData) { - PWSTR buffer = (PWSTR)::GlobalLock(cbData); - swprintf_s(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination()); - ::GlobalUnlock(cbData); + PWSTR buffer = static_cast<PWSTR>(GlobalLock(cbData)); + _snwprintf(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination()); + GlobalUnlock(cbData); } return cbData; } @@ -125,10 +150,10 @@ HGLOBAL createGlobalData(const String& str) HGLOBAL globalData = ::GlobalAlloc(GPTR, (str.length() + 1) * sizeof(UChar)); if (!globalData) return 0; - UChar* buffer = static_cast<UChar*>(::GlobalLock(globalData)); + UChar* buffer = static_cast<UChar*>(GlobalLock(globalData)); memcpy(buffer, str.characters(), str.length() * sizeof(UChar)); buffer[str.length()] = 0; - ::GlobalUnlock(globalData); + GlobalUnlock(globalData); return globalData; } @@ -137,13 +162,30 @@ HGLOBAL createGlobalData(const Vector<char>& vector) HGLOBAL globalData = ::GlobalAlloc(GPTR, vector.size() + 1); if (!globalData) return 0; - char* buffer = static_cast<char*>(::GlobalLock(globalData)); + char* buffer = static_cast<char*>(GlobalLock(globalData)); memcpy(buffer, vector.data(), vector.size()); buffer[vector.size()] = 0; - ::GlobalUnlock(globalData); + GlobalUnlock(globalData); return globalData; } +static String getFullCFHTML(IDataObject* data, bool& success) +{ + STGMEDIUM store; + if (SUCCEEDED(data->GetData(htmlFormat(), &store))) { + // MS HTML Format parsing + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); + SIZE_T dataSize = ::GlobalSize(store.hGlobal); + String cfhtml(UTF8Encoding().decode(data, dataSize)); + GlobalUnlock(store.hGlobal); + ReleaseStgMedium(&store); + success = true; + return cfhtml; + } + success = false; + return String(); +} + static void append(Vector<char>& vector, const char* string) { vector.append(string, strlen(string)); @@ -154,6 +196,17 @@ static void append(Vector<char>& vector, const CString& string) vector.append(string.data(), string.length()); } +// Find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks. +static String extractMarkupFromCFHTML(const String& cfhtml) +{ + unsigned markupStart = cfhtml.find("<html", 0, false); + unsigned tagStart = cfhtml.find("startfragment", markupStart, false); + unsigned fragmentStart = cfhtml.find('>', tagStart) + 1; + unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false); + unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd); + return cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace(); +} + // Documentation for the CF_HTML format is available at http://msdn.microsoft.com/workshop/networking/clipboard/htmlclipboard.asp void markupToCFHTML(const String& markup, const String& srcURL, Vector<char>& result) { @@ -271,24 +324,6 @@ FORMATETC* smartPasteFormat() return &htmlFormat; } -static bool urlFromPath(CFStringRef path, String& url) -{ - if (!path) - return false; - - RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false)); - if (!cfURL) - return false; - - url = CFURLGetString(cfURL.get()); - - // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost". - if (url.startsWith("file://localhost/")) - url.remove(7, 9); - - return true; -} - String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, bool& success, String* title) { STGMEDIUM store; @@ -298,22 +333,24 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena success = true; else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { // URL using Unicode - UChar* data = (UChar*)GlobalLock(store.hGlobal); + UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); - GlobalUnlock(store.hGlobal); + GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { // URL using ASCII - char* data = (char*)GlobalLock(store.hGlobal); + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); - GlobalUnlock(store.hGlobal); + GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; - } else if (filenamePolicy == DragData::ConvertFilenames) { + } +#if PLATFORM(CF) + else if (filenamePolicy == DragData::ConvertFilenames) { if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { // file using unicode - wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal); + wchar_t* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); if (urlFromPath(pathAsCFString.get(), url)) { @@ -326,7 +363,7 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena ReleaseStgMedium(&store); } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { // filename using ascii - char* data = (char*)GlobalLock(store.hGlobal); + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); if (urlFromPath(pathAsCFString.get(), url)) { @@ -339,6 +376,7 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena ReleaseStgMedium(&store); } } +#endif return url; } @@ -349,14 +387,14 @@ String getPlainText(IDataObject* dataObject, bool& success) success = false; if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) { // Unicode text - UChar* data = (UChar*)GlobalLock(store.hGlobal); + UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); text = String(data); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(plainTextFormat(), &store))) { // ASCII text - char* data = (char*)GlobalLock(store.hGlobal); + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); text = String(data); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); @@ -386,6 +424,14 @@ String getTextHTML(IDataObject* data, bool& success) return html; } +String getCFHTML(IDataObject* data, bool& success) +{ + String cfhtml = getFullCFHTML(data, success); + if (success) + return extractMarkupFromCFHTML(cfhtml); + return String(); +} + PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*) { // FIXME: We should be able to create fragments from files @@ -400,7 +446,7 @@ bool containsFilenames(const IDataObject*) // Convert a String containing CF_HTML formatted text to a DocumentFragment PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfhtml) -{ +{ // obtain baseURL if present String srcURLStr("sourceURL:"); String srcURL; @@ -413,38 +459,24 @@ PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfh srcURL = rawSrcURL.stripWhiteSpace(); } - // find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks - unsigned markupStart = cfhtml.find("<html", 0, false); - unsigned tagStart = cfhtml.find("startfragment", markupStart, false); - unsigned fragmentStart = cfhtml.find('>', tagStart) + 1; - unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false); - unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd); - String markup = cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace(); - + String markup = extractMarkupFromCFHTML(cfhtml); return createFragmentFromMarkup(doc, markup, srcURL, FragmentScriptingNotAllowed); } - PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data) { if (!doc || !data) return 0; - STGMEDIUM store; - String html; - String srcURL; - if (SUCCEEDED(data->GetData(htmlFormat(), &store))) { - // MS HTML Format parsing - char* data = (char*)GlobalLock(store.hGlobal); - SIZE_T dataSize = ::GlobalSize(store.hGlobal); - String cfhtml(UTF8Encoding().decode(data, dataSize)); - GlobalUnlock(store.hGlobal); - ReleaseStgMedium(&store); + bool success = false; + String cfhtml = getFullCFHTML(data, success); + if (success) { if (PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml)) return fragment; - } - bool success = false; - html = getTextHTML(data, success); + } + + String html = getTextHTML(data, success); + String srcURL; if (success) return createFragmentFromMarkup(doc, html, srcURL, FragmentScriptingNotAllowed); diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.h b/WebCore/platform/win/ClipboardUtilitiesWin.h index 4ca46f9..fe01499 100644 --- a/WebCore/platform/win/ClipboardUtilitiesWin.h +++ b/WebCore/platform/win/ClipboardUtilitiesWin.h @@ -64,6 +64,7 @@ PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml) String getURL(IDataObject*, DragData::FilenameConversionPolicy, bool& success, String* title = 0); String getPlainText(IDataObject*, bool& success); String getTextHTML(IDataObject*, bool& success); +String getCFHTML(IDataObject*, bool& success); } // namespace WebCore diff --git a/WebCore/platform/win/ClipboardWin.cpp b/WebCore/platform/win/ClipboardWin.cpp index 2cd6feb..6e026d6 100644 --- a/WebCore/platform/win/ClipboardWin.cpp +++ b/WebCore/platform/win/ClipboardWin.cpp @@ -70,7 +70,7 @@ static const char szShellDotUrlTemplate[] = "[InternetShortcut]\r\nURL=%s\r\n"; // 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, ClipboardDataTypeText }; +enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText, ClipboardDataTypeTextHTML }; static ClipboardDataType clipboardTypeFromMIMEType(const String& type) { @@ -81,6 +81,8 @@ static ClipboardDataType clipboardTypeFromMIMEType(const String& type) return ClipboardDataTypeText; if (qType == "url" || qType == "text/uri-list") return ClipboardDataTypeURL; + if (qType == "text/html") + return ClipboardDataTypeTextHTML; return ClipboardDataTypeNone; } @@ -393,17 +395,24 @@ exit: return hr; } -ClipboardWin::ClipboardWin(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame) +{ + return ClipboardWin::create(true, dragData->platformData(), policy, frame); +} + +ClipboardWin::ClipboardWin(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) : Clipboard(policy, isForDragging) , m_dataObject(dataObject) , m_writableDataObject(0) + , m_frame(frame) { } -ClipboardWin::ClipboardWin(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy) +ClipboardWin::ClipboardWin(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) : Clipboard(policy, isForDragging) , m_dataObject(dataObject) , m_writableDataObject(dataObject) + , m_frame(frame) { } @@ -498,6 +507,12 @@ String ClipboardWin::getData(const String& type, bool& success) const return getPlainText(m_dataObject.get(), success); if (dataType == ClipboardDataTypeURL) return getURL(m_dataObject.get(), DragData::DoNotConvertFilenames, success); + else if (dataType == ClipboardDataTypeTextHTML) { + String data = getTextHTML(m_dataObject.get(), success); + if (success) + return data; + return getCFHTML(m_dataObject.get(), success); + } return ""; } @@ -589,12 +604,13 @@ PassRefPtr<FileList> ClipboardWin::files() const if (!hdrop) return files.release(); + ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext(); WCHAR filename[MAX_PATH]; UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0); for (UINT i = 0; i < fileCount; i++) { if (!DragQueryFileW(hdrop, i, filename, ARRAYSIZE(filename))) continue; - files->append(File::create(reinterpret_cast<UChar*>(filename))); + files->append(File::create(scriptExecutionContext, reinterpret_cast<UChar*>(filename))); } GlobalUnlock(medium.hGlobal); diff --git a/WebCore/platform/win/ClipboardWin.h b/WebCore/platform/win/ClipboardWin.h index 1b139ed..6a08087 100644 --- a/WebCore/platform/win/ClipboardWin.h +++ b/WebCore/platform/win/ClipboardWin.h @@ -35,19 +35,20 @@ struct IDataObject; namespace WebCore { class CachedImage; +class Frame; class IntPoint; class WCDataObject; // State available during IE's events for drag and drop and copy/paste class ClipboardWin : public Clipboard, public CachedResourceClient { public: - static PassRefPtr<ClipboardWin> create(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy) + static PassRefPtr<ClipboardWin> create(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) { - return adoptRef(new ClipboardWin(isForDragging, dataObject, policy)); + return adoptRef(new ClipboardWin(isForDragging, dataObject, policy, frame)); } - static PassRefPtr<ClipboardWin> create(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy) + static PassRefPtr<ClipboardWin> create(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) { - return adoptRef(new ClipboardWin(isForDragging, dataObject, policy)); + return adoptRef(new ClipboardWin(isForDragging, dataObject, policy, frame)); } ~ClipboardWin(); @@ -76,8 +77,8 @@ public: void setExternalDataObject(IDataObject *dataObject); private: - ClipboardWin(bool isForDragging, IDataObject*, ClipboardAccessPolicy); - ClipboardWin(bool isForDragging, WCDataObject*, ClipboardAccessPolicy); + ClipboardWin(bool isForDragging, IDataObject*, ClipboardAccessPolicy, Frame*); + ClipboardWin(bool isForDragging, WCDataObject*, ClipboardAccessPolicy, Frame*); void resetFromClipboard(); void setDragImage(CachedImage*, Node*, const IntPoint&); diff --git a/WebCore/platform/win/DragDataWin.cpp b/WebCore/platform/win/DragDataWin.cpp index 82e537e..05f9103 100644 --- a/WebCore/platform/win/DragDataWin.cpp +++ b/WebCore/platform/win/DragDataWin.cpp @@ -26,9 +26,7 @@ #include "config.h" #include "DragData.h" -#include "ClipboardWin.h" #include "ClipboardUtilitiesWin.h" -#include "ClipboardAccessPolicy.h" #include "DocumentFragment.h" #include "PlatformString.h" #include "Markup.h" @@ -39,11 +37,6 @@ namespace WebCore { -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardWin::create(true, m_platformDragData, policy); -} - bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const { return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat())) diff --git a/WebCore/platform/win/EditorWin.cpp b/WebCore/platform/win/EditorWin.cpp index 09abdbd..075827d 100644 --- a/WebCore/platform/win/EditorWin.cpp +++ b/WebCore/platform/win/EditorWin.cpp @@ -30,6 +30,7 @@ #include "ClipboardWin.h" #include "Document.h" #include "Element.h" +#include "Frame.h" #include "htmlediting.h" #include "TextIterator.h" #include "visible_units.h" @@ -38,13 +39,13 @@ namespace WebCore { -PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame) { COMPtr<IDataObject> clipboardData; if (!SUCCEEDED(OleGetClipboard(&clipboardData))) clipboardData = 0; - return ClipboardWin::create(false, clipboardData.get(), policy); + return ClipboardWin::create(false, clipboardData.get(), policy, frame); } } // namespace WebCore diff --git a/WebCore/platform/win/PasteboardWin.cpp b/WebCore/platform/win/PasteboardWin.cpp index 808c863..03ecd36 100644 --- a/WebCore/platform/win/PasteboardWin.cpp +++ b/WebCore/platform/win/PasteboardWin.cpp @@ -52,7 +52,6 @@ static UINT WebSmartPasteFormat = 0; static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lresult = 0; - LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0); switch (message) { case WM_RENDERFORMAT: @@ -64,12 +63,14 @@ static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM w // and now this application is about to quit, so it must put data on // the clipboard before it exits. break; - case WM_DRAWCLIPBOARD: - break; case WM_DESTROY: break; +#if !OS(WINCE) + case WM_DRAWCLIPBOARD: + break; case WM_CHANGECBCHAIN: break; +#endif default: lresult = DefWindowProc(hWnd, message, wParam, lParam); break; @@ -84,17 +85,21 @@ Pasteboard* Pasteboard::generalPasteboard() } Pasteboard::Pasteboard() -{ - // make a dummy HWND to be the Windows clipboard's owner - WNDCLASSEX wcex = {0}; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.lpfnWndProc = PasteboardOwnerWndProc; - wcex.hInstance = WebCore::instanceHandle(); - wcex.lpszClassName = L"PasteboardOwnerWindowClass"; - ::RegisterClassEx(&wcex); +{ + HWND hWndParent = 0; +#if !OS(WINCE) + hWndParent = HWND_MESSAGE; +#endif + + WNDCLASS wc; + memset(&wc, 0, sizeof(WNDCLASS)); + wc.lpfnWndProc = PasteboardOwnerWndProc; + wc.hInstance = WebCore::instanceHandle(); + wc.lpszClassName = L"PasteboardOwnerWindowClass"; + RegisterClass(&wc); m_owner = ::CreateWindow(L"PasteboardOwnerWindowClass", L"PasteboardOwnerWindow", 0, 0, 0, 0, 0, - HWND_MESSAGE, 0, 0, 0); + hWndParent, 0, 0, 0); HTMLClipboardFormat = ::RegisterClipboardFormat(L"HTML Format"); BookmarkClipboardFormat = ::RegisterClipboardFormat(L"UniformResourceLocatorW"); @@ -216,31 +221,34 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&) HDC dc = GetDC(0); HDC compatibleDC = CreateCompatibleDC(0); HDC sourceDC = CreateCompatibleDC(0); - HBITMAP resultBitmap = CreateCompatibleBitmap(dc, image->width(), image->height()); - HBITMAP oldBitmap = (HBITMAP)SelectObject(compatibleDC, resultBitmap); + OwnPtr<HBITMAP> resultBitmap(CreateCompatibleBitmap(dc, image->width(), image->height())); + HGDIOBJ oldBitmap = SelectObject(compatibleDC, resultBitmap.get()); BitmapInfo bmInfo = BitmapInfo::create(image->size()); HBITMAP coreBitmap = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0); - HBITMAP oldSource = (HBITMAP)SelectObject(sourceDC, coreBitmap); + HGDIOBJ oldSource = SelectObject(sourceDC, coreBitmap); image->getHBITMAP(coreBitmap); +#if !defined(NO_ALPHABLEND) BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; AlphaBlend(compatibleDC, 0, 0, image->width(), image->height(), sourceDC, 0, 0, image->width(), image->height(), bf); +#else + StretchBlt(compatibleDC, 0, 0, image->width(), image->height(), + sourceDC, 0, 0, image->width(), image->height(), SRCCOPY); +#endif - SelectObject(compatibleDC, oldBitmap); SelectObject(sourceDC, oldSource); - - DeleteObject(oldBitmap); - DeleteObject(oldSource); DeleteObject(coreBitmap); - ReleaseDC(0, dc); - DeleteDC(compatibleDC); + + SelectObject(compatibleDC, oldBitmap); DeleteDC(sourceDC); + DeleteDC(compatibleDC); + ReleaseDC(0, dc); if (::OpenClipboard(m_owner)) { - ::SetClipboardData(CF_BITMAP, resultBitmap); + ::SetClipboardData(CF_BITMAP, resultBitmap.leakPtr()); ::CloseClipboard(); } } @@ -255,9 +263,9 @@ String Pasteboard::plainText(Frame* frame) if (::IsClipboardFormatAvailable(CF_UNICODETEXT) && ::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT); if (cbData) { - UChar* buffer = (UChar*)::GlobalLock(cbData); + UChar* buffer = static_cast<UChar*>(GlobalLock(cbData)); String fromClipboard(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); return fromClipboard; } @@ -267,9 +275,9 @@ String Pasteboard::plainText(Frame* frame) if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_TEXT); if (cbData) { - char* buffer = (char*)::GlobalLock(cbData); + char* buffer = static_cast<char*>(GlobalLock(cbData)); String fromClipboard(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); return fromClipboard; } @@ -288,8 +296,8 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP HANDLE cbData = ::GetClipboardData(HTMLClipboardFormat); if (cbData) { SIZE_T dataSize = ::GlobalSize(cbData); - String cfhtml(UTF8Encoding().decode((char*)::GlobalLock(cbData), dataSize)); - ::GlobalUnlock(cbData); + String cfhtml(UTF8Encoding().decode(static_cast<char*>(GlobalLock(cbData)), dataSize)); + GlobalUnlock(cbData); ::CloseClipboard(); PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame->document(), cfhtml); @@ -304,9 +312,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP if (::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT); if (cbData) { - UChar* buffer = (UChar*)GlobalLock(cbData); + UChar* buffer = static_cast<UChar*>(GlobalLock(cbData)); String str(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str); if (fragment) @@ -321,9 +329,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP if (::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_TEXT); if (cbData) { - char* buffer = (char*)GlobalLock(cbData); + char* buffer = static_cast<char*>(GlobalLock(cbData)); String str(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str); if (fragment) diff --git a/WebCore/platform/win/PlatformScrollBarWin.cpp b/WebCore/platform/win/PlatformScrollBarWin.cpp deleted file mode 100644 index aa5333b..0000000 --- a/WebCore/platform/win/PlatformScrollBarWin.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008 Brent Fulgham - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "PlatformScrollBar.h" - -#include "FrameView.h" -#include "ScrollbarClient.h" -#include "ScrollbarTheme.h" - -namespace WebCore { - -PlatformScrollbar::PlatformScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size, - ScrollbarTheme* theme) - : Scrollbar(client, orientation, size, theme) -{ -} - -} - diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp index 44141f2..4bc6dc7 100644 --- a/WebCore/platform/win/PopupMenuWin.cpp +++ b/WebCore/platform/win/PopupMenuWin.cpp @@ -199,6 +199,7 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) break; // Steal mouse messages. +#if !OS(WINCE) case WM_NCMOUSEMOVE: case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: @@ -209,6 +210,7 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) case WM_NCMBUTTONDOWN: case WM_NCMBUTTONUP: case WM_NCMBUTTONDBLCLK: +#endif case WM_MOUSEWHEEL: msg.hwnd = m_popup; break; @@ -578,7 +580,7 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc) } if (!m_bmp) { #if OS(WINCE) - BitmapInfo bitmapInfo(true, clientRect().width(), clientRect().height()); + BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size(), 16); #else BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size()); #endif @@ -774,9 +776,10 @@ LRESULT PopupMenu::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam LRESULT lResult = 0; switch (message) { +#if !OS(WINCE) case WM_MOUSEACTIVATE: return MA_NOACTIVATE; - +#endif case WM_SIZE: { if (!scrollbar()) break; diff --git a/WebCore/platform/wince/DragDataWince.cpp b/WebCore/platform/wince/DragDataWince.cpp index 5f2a7ba..73dd8a2 100644 --- a/WebCore/platform/wince/DragDataWince.cpp +++ b/WebCore/platform/wince/DragDataWince.cpp @@ -21,17 +21,11 @@ #include "config.h" #include "DragData.h" -#include "Clipboard.h" #include "DocumentFragment.h" #include "PlatformString.h" namespace WebCore { -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return 0; -} - bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const { return false; diff --git a/WebCore/platform/wince/EditorWince.cpp b/WebCore/platform/wince/EditorWince.cpp index 02af780..71f4db9 100644 --- a/WebCore/platform/wince/EditorWince.cpp +++ b/WebCore/platform/wince/EditorWince.cpp @@ -35,7 +35,7 @@ namespace WebCore { -PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*) { return adoptRef(new ClipboardWince(policy, false)); } diff --git a/WebCore/platform/wx/ClipboardWx.cpp b/WebCore/platform/wx/ClipboardWx.cpp index 6100831..25bef55 100644 --- a/WebCore/platform/wx/ClipboardWx.cpp +++ b/WebCore/platform/wx/ClipboardWx.cpp @@ -37,6 +37,11 @@ namespace WebCore { +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*) +{ + return 0; +} + ClipboardWx::ClipboardWx(ClipboardAccessPolicy policy, bool forDragging) : Clipboard(policy, forDragging) { diff --git a/WebCore/platform/wx/DragDataWx.cpp b/WebCore/platform/wx/DragDataWx.cpp index 278f123..35e3753 100644 --- a/WebCore/platform/wx/DragDataWx.cpp +++ b/WebCore/platform/wx/DragDataWx.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "DragData.h" -#include "Clipboard.h" #include "Document.h" #include "DocumentFragment.h" @@ -66,11 +65,6 @@ Color DragData::asColor() const return Color(); } -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const -{ - return 0; -} - bool DragData::containsCompatibleContent() const { return false; diff --git a/WebCore/platform/wx/MouseEventWx.cpp b/WebCore/platform/wx/MouseEventWx.cpp index 4f39598..8591ef5 100644 --- a/WebCore/platform/wx/MouseEventWx.cpp +++ b/WebCore/platform/wx/MouseEventWx.cpp @@ -37,7 +37,7 @@ PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& : m_position(event.GetPosition()) , m_globalPosition(globalPoint) , m_shiftKey(event.ShiftDown()) - , m_ctrlKey(event.CmdDown()) + , m_ctrlKey(event.CmdDown() || event.ControlDown()) , m_altKey(event.AltDown()) , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers { |