diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/WebCoreSupport')
14 files changed, 415 insertions, 1138 deletions
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index d4c357d..becf48f 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -34,6 +34,7 @@ #include "WebCoreArgumentCoders.h" #include "WebFrame.h" #include "WebFrameLoaderClient.h" +#include "WebFullScreenManager.h" #include "WebOpenPanelParameters.h" #include "WebOpenPanelResultListener.h" #include "WebPage.h" @@ -51,6 +52,7 @@ #include <WebCore/FrameView.h> #include <WebCore/HTMLNames.h> #include <WebCore/HTMLPlugInImageElement.h> +#include <WebCore/Icon.h> #include <WebCore/NotImplemented.h> #include <WebCore/Page.h> #include <WebCore/SecurityOrigin.h> @@ -115,18 +117,17 @@ FloatRect WebChromeClient::pageRect() float WebChromeClient::scaleFactor() { - notImplemented(); - return 1.0; + return m_page->userSpaceScaleFactor(); } void WebChromeClient::focus() { - notImplemented(); + m_page->send(Messages::WebPageProxy::SetFocus(true)); } void WebChromeClient::unfocus() { - notImplemented(); + m_page->send(Messages::WebPageProxy::SetFocus(false)); } bool WebChromeClient::canTakeFocus(FocusDirection) @@ -373,7 +374,7 @@ void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollR } #if ENABLE(TILED_BACKING_STORE) -void WebChromeClient::delegatedScrollRequested(const IntSize& scrollOffset) +void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset) { m_page->pageDidRequestScroll(scrollOffset); } @@ -385,10 +386,9 @@ IntPoint WebChromeClient::screenToWindow(const IntPoint&) const return IntPoint(); } -IntRect WebChromeClient::windowToScreen(const IntRect&) const +IntRect WebChromeClient::windowToScreen(const IntRect& rect) const { - notImplemented(); - return IntRect(); + return m_page->windowToScreen(rect); } PlatformPageClient WebChromeClient::platformPageClient() const @@ -545,14 +545,13 @@ void WebChromeClient::paintCustomHighlight(Node*, const AtomicString& type, cons bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) { - notImplemented(); - return false; + generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path); + return !generatedFilename.isNull(); } String WebChromeClient::generateReplacementFile(const String& path) { - notImplemented(); - return String(); + return m_page->injectedBundleUIClient().generateFileForUpload(m_page, path); } bool WebChromeClient::paintCustomScrollbar(GraphicsContext*, const FloatRect&, ScrollbarControlSize, @@ -610,9 +609,9 @@ void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFile m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), parameters)); } -void WebChromeClient::chooseIconForFiles(const Vector<String>&, FileChooser*) +void WebChromeClient::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser) { - notImplemented(); + chooser->iconLoaded(Icon::createIconForFiles(filenames)); } void WebChromeClient::setCursor(const WebCore::Cursor& cursor) @@ -639,12 +638,20 @@ void WebChromeClient::formDidBlur(const Node*) bool WebChromeClient::selectItemWritingDirectionIsNatural() { +#if PLATFORM(WIN) + return true; +#else return false; +#endif } bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection() { +#if PLATFORM(WIN) + return false; +#else return true; +#endif } PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const @@ -705,6 +712,29 @@ void WebChromeClient::setLastSetCursorToCurrentCursor() } #endif +#if ENABLE(FULLSCREEN_API) +bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard) +{ + return m_page->fullScreenManager()->supportsFullScreen(withKeyboard); +} + +void WebChromeClient::enterFullScreenForElement(WebCore::Element* element) +{ + m_page->fullScreenManager()->enterFullScreenForElement(element); +} + +void WebChromeClient::exitFullScreenForElement(WebCore::Element* element) +{ + m_page->fullScreenManager()->exitFullScreenForElement(element); +} + +void WebChromeClient::setRootFullScreenLayer(GraphicsLayer* layer) +{ + m_page->fullScreenManager()->setRootFullScreenLayer(layer); +} + +#endif + void WebChromeClient::dispatchViewportDataDidChange(const ViewportArguments& args) const { m_page->send(Messages::WebPageProxy::DidChangeViewportData(args)); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h index 96da752..57e98c5 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -113,7 +113,7 @@ private: virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); virtual void scroll(const WebCore::IntSize& scrollOffset, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); #if ENABLE(TILED_BACKING_STORE) - virtual void delegatedScrollRequested(const WebCore::IntSize& scrollOffset); + virtual void delegatedScrollRequested(const WebCore::IntPoint& scrollOffset); #endif virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; @@ -205,6 +205,13 @@ private: virtual void setLastSetCursorToCurrentCursor(); #endif +#if ENABLE(FULLSCREEN_API) + virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard); + virtual void enterFullScreenForElement(WebCore::Element*); + virtual void exitFullScreenForElement(WebCore::Element*); + virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*); +#endif + virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments&) const; virtual void didCompleteRubberBandForMainFrame(const WebCore::IntSize&) const; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp index caa6eda..825a448 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp @@ -105,6 +105,7 @@ void WebDatabaseManager::getDatabasesByOrigin(uint64_t callbackID) const } WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabasesByOrigin(originAndDatabasesVector, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const @@ -118,6 +119,7 @@ void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const for (size_t i = 0; i < numOrigins; ++i) identifiers[i] = origins[i]->databaseIdentifier(); WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabaseOrigins(identifiers, callbackID), 0); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, const String& originIdentifier) const @@ -127,6 +129,7 @@ void WebDatabaseManager::deleteDatabaseWithNameForOrigin(const String& databaseI return; DatabaseTracker::tracker().deleteDatabase(origin.get(), databaseIdentifier); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteDatabasesForOrigin(const String& originIdentifier) const @@ -136,11 +139,13 @@ void WebDatabaseManager::deleteDatabasesForOrigin(const String& originIdentifier return; DatabaseTracker::tracker().deleteOrigin(origin.get()); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteAllDatabases() const { DatabaseTracker::tracker().deleteAllDatabases(); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const @@ -154,6 +159,7 @@ void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsig return; DatabaseTracker::tracker().setQuota(origin.get(), quota); + WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::dispatchDidModifyOrigin(SecurityOrigin* origin) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h index fa8426a..9200af0 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h @@ -141,11 +141,11 @@ private: virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&); -#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*); +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) + virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); - virtual bool isShowingCorrectionPanel(); - virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const WTF::String& replacedString, const WTF::String& replacementString); + virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel); + virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const String& replacedString, const String& replacementString); #endif WebPage* m_page; }; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 3770ca6..fa3cdce 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -386,8 +386,10 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() WebPage* webPage = m_frame->page(); if (!webPage) return; + webPage->findController().hideFindUI(); - + webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); + DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader(); const String& url = provisionalLoader->url().string(); RefPtr<APIObject> userData; @@ -395,12 +397,10 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() // Notify the bundle client. webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData); - bool loadingSubstituteDataForUnreachableURL = !provisionalLoader->unreachableURL().isNull(); - - webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); + String unreachableURL = provisionalLoader->unreachableURL().string(); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, loadingSubstituteDataForUnreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); } void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) @@ -653,7 +653,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFu (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse); return; } - + uint64_t listenerID = m_frame->setUpPolicyListener(function); bool receivedPolicyAction; uint64_t policyAction; @@ -1086,6 +1086,11 @@ void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*) void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) { + WebPage* webPage = m_frame->page(); + bool isMainFrame = webPage->mainFrame() == m_frame; + + const String& mimeType = m_frame->coreFrame()->loader()->documentLoader()->response().mimeType(); + m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForMIMEType(mimeType); } void WebFrameLoaderClient::transitionToCommittedForNewPage() @@ -1217,6 +1222,19 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn parameters.names[i] = paramNames[i].lower(); } +#if PLUGIN_ARCHITECTURE(X11) + if (equalIgnoringCase(mimeType, "application/x-shockwave-flash")) { + // Currently we don't support transparency and windowed mode. + // Inject wmode=opaque to make Flash work in these conditions. + size_t wmodeIndex = parameters.names.find("wmode"); + if (wmodeIndex == -1) { + parameters.names.append("wmode"); + parameters.values.append("opaque"); + } else if (equalIgnoringCase(parameters.values[wmodeIndex], "window")) + parameters.values[wmodeIndex] = "opaque"; + } +#endif + RefPtr<Plugin> plugin = webPage->createPlugin(parameters); if (!plugin) return 0; @@ -1237,27 +1255,58 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& p return createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, "application/x-java-applet", false); } -ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn) +static bool pluginSupportsExtension(PluginData* pluginData, const String& extension) +{ + ASSERT(extension.lower() == extension); + + for (size_t i = 0; i < pluginData->mimes().size(); ++i) { + const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i]; + + if (mimeClassInfo.extensions.contains(extension)) + return true; + } + return false; +} + +ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages) { // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code // is consolidated. String mimeType = mimeTypeIn; - if (mimeType.isEmpty()) - mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); + if (mimeType.isEmpty()) { + String extension = url.path().substring(url.path().reverseFind('.') + 1).lower(); + + // Try to guess the MIME type from the extension. + mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); + + if (mimeType.isEmpty()) { + // Check if there's a plug-in around that can handle the extension. + if (WebPage* webPage = m_frame->page()) { + if (PluginData* pluginData = webPage->corePage()->pluginData()) { + if (pluginSupportsExtension(pluginData, extension)) + return ObjectContentNetscapePlugin; + } + } + } + } if (mimeType.isEmpty()) return ObjectContentFrame; - if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) - return WebCore::ObjectContentImage; - + bool plugInSupportsMIMEType = false; if (WebPage* webPage = m_frame->page()) { if (PluginData* pluginData = webPage->corePage()->pluginData()) { if (pluginData->supportsMimeType(mimeType)) - return ObjectContentNetscapePlugin; + plugInSupportsMIMEType = true; } } + + if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) + return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? ObjectContentNetscapePlugin : ObjectContentImage; + + if (plugInSupportsMIMEType) + return ObjectContentNetscapePlugin; if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) return ObjectContentFrame; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h index 9ca9a75..1948541 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -191,7 +191,7 @@ private: virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues); - virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const String& mimeType); + virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL&, const String& mimeType, bool shouldPreferPlugInsForImages); virtual String overrideMediaType() const; virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp index 7e14701..9cb6bec 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp @@ -33,60 +33,16 @@ #include "WebCookieManager.h" #include "WebCoreArgumentCoders.h" #include "WebProcess.h" -#include <WebCore/LocalizedStrings.h> -#include <WebCore/NotImplemented.h> #include <WebCore/Page.h> -#include <WebCore/PageGroup.h> -#include <wtf/MathExtras.h> -#include <wtf/text/CString.h> #if USE(CF) #include <wtf/RetainPtr.h> #endif -#if PLATFORM(MAC) - -#define UI_STRING(string, description) localizedString(string) -#define UI_STRING_KEY(string, key, description) localizedString(key) - -#else - -#define UI_STRING(string, description) String::fromUTF8(string, strlen(string)) -#define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string)) - -#endif - using namespace WebCore; namespace WebKit { -// We can't use String::format for two reasons: -// 1) It doesn't handle non-ASCII characters in the format string. -// 2) It doesn't handle the %2$d syntax. -// Note that because |format| is used as the second parameter to va_start, it cannot be a reference -// type according to section 18.7/3 of the C++ N1905 standard. -static String formatLocalizedString(String format, ...) -{ -#if USE(CF) - va_list arguments; - va_start(arguments, format); - RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString()); - RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); - va_end(arguments); - return result.get(); -#elif PLATFORM(QT) - va_list arguments; - va_start(arguments, format); - QString result; - result.vsprintf(format.latin1().data(), arguments); - va_end(arguments); - return result; -#else - notImplemented(); - return format; -#endif -} - void WebPlatformStrategies::initialize() { DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ()); @@ -109,11 +65,6 @@ PluginStrategy* WebPlatformStrategies::createPluginStrategy() return this; } -LocalizationStrategy* WebPlatformStrategies::createLocalizationStrategy() -{ - return this; -} - VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy() { return this; @@ -128,25 +79,6 @@ void WebPlatformStrategies::notifyCookiesChanged() // PluginStrategy -void WebPlatformStrategies::populatePluginCache() -{ - if (m_pluginCacheIsPopulated) - return; - - ASSERT(m_cachedPlugins.isEmpty()); - - Vector<PluginInfo> plugins; - - // FIXME: Should we do something in case of error here? - WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPlugins(m_shouldRefreshPlugins), - Messages::WebContext::GetPlugins::Reply(plugins), 0); - - m_cachedPlugins.swap(plugins); - - m_shouldRefreshPlugins = false; - m_pluginCacheIsPopulated = true; -} - void WebPlatformStrategies::refreshPlugins() { m_cachedPlugins.clear(); @@ -162,777 +94,27 @@ void WebPlatformStrategies::getPluginInfo(const WebCore::Page*, Vector<WebCore:: plugins = m_cachedPlugins; } -// LocalizationStrategy - -String WebPlatformStrategies::inputElementAltText() -{ - return UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value"); -} - -String WebPlatformStrategies::resetButtonDefaultLabel() -{ - return UI_STRING("Reset", "default label for Reset buttons in forms on web pages"); -} - -String WebPlatformStrategies::searchableIndexIntroduction() -{ - return UI_STRING("This is a searchable index. Enter search keywords: ", - "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'"); -} - -String WebPlatformStrategies::submitButtonDefaultLabel() -{ - return UI_STRING("Submit", "default label for Submit buttons in forms on web pages"); -} - -String WebPlatformStrategies::fileButtonChooseFileLabel() -{ - return UI_STRING("Choose File", "title for file button used in HTML forms"); -} - -String WebPlatformStrategies::fileButtonNoFileSelectedLabel() -{ - return UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected"); -} - -String WebPlatformStrategies::defaultDetailsSummaryText() -{ - return UI_STRING("Details", "text to display in <details> tag when it has no <summary> child"); -} - -#if PLATFORM(MAC) -String WebPlatformStrategies::copyImageUnknownFileLabel() -{ - return UI_STRING("unknown", "Unknown filename"); -} -#endif - -#if ENABLE(CONTEXT_MENUS) - -String WebPlatformStrategies::contextMenuItemTagOpenLinkInNewWindow() -{ - return UI_STRING("Open Link in New Window", "Open in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagDownloadLinkToDisk() -{ - return UI_STRING("Download Linked File", "Download Linked File context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyLinkToClipboard() -{ - return UI_STRING("Copy Link", "Copy Link context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenImageInNewWindow() -{ - return UI_STRING("Open Image in New Window", "Open Image in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagDownloadImageToDisk() -{ - return UI_STRING("Download Image", "Download Image context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard() -{ - return UI_STRING("Copy Image", "Copy Image context menu item"); -} - -#if PLATFORM(QT) -String WebPlatformStrategies::contextMenuItemTagCopyImageUrlToClipboard() -{ - return UI_STRING("Copy Image Address", "Copy Image Address menu item"); -} -#endif - -String WebPlatformStrategies::contextMenuItemTagOpenVideoInNewWindow() -{ - return UI_STRING("Open Video in New Window", "Open Video in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenAudioInNewWindow() -{ - return UI_STRING("Open Audio in New Window", "Open Audio in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyVideoLinkToClipboard() -{ - return UI_STRING("Copy Video Address", "Copy Video Address Location context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopyAudioLinkToClipboard() -{ - return UI_STRING("Copy Audio Address", "Copy Audio Address Location context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagToggleMediaControls() -{ - return UI_STRING("Controls", "Media Controls context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagToggleMediaLoop() -{ - return UI_STRING("Loop", "Media Loop context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagEnterVideoFullscreen() -{ - return UI_STRING("Enter Fullscreen", "Video Enter Fullscreen context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMediaPlay() -{ - return UI_STRING("Play", "Media Play context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMediaPause() -{ - return UI_STRING("Pause", "Media Pause context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMediaMute() -{ - return UI_STRING("Mute", "Media Mute context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow() -{ - return UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCopy() -{ - return UI_STRING("Copy", "Copy context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagGoBack() -{ - return UI_STRING("Back", "Back context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagGoForward() -{ - return UI_STRING("Forward", "Forward context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStop() -{ - return UI_STRING("Stop", "Stop context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagReload() -{ - return UI_STRING("Reload", "Reload context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCut() -{ - return UI_STRING("Cut", "Cut context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagPaste() -{ - return UI_STRING("Paste", "Paste context menu item"); -} - -#if PLATFORM(GTK) - -String WebPlatformStrategies::contextMenuItemTagDelete() -{ - notImplemented(); - return "Delete"; -} - -String WebPlatformStrategies::contextMenuItemTagInputMethods() -{ - notImplemented(); - return "Input Methods"; -} - -String WebPlatformStrategies::contextMenuItemTagUnicode() -{ - notImplemented(); - return "Unicode"; -} - -#endif - -#if PLATFORM(GTK) || PLATFORM(QT) - -String WebPlatformStrategies::contextMenuItemTagSelectAll() -{ - notImplemented(); - return "Select All"; -} - -#endif - -String WebPlatformStrategies::contextMenuItemTagNoGuessesFound() -{ - return UI_STRING("No Guesses Found", "No Guesses Found context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagIgnoreSpelling() -{ - return UI_STRING("Ignore Spelling", "Ignore Spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagLearnSpelling() -{ - return UI_STRING("Learn Spelling", "Learn Spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSearchWeb() -{ - return UI_STRING("Search in Google", "Search in Google context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary() -{ - return UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOpenLink() -{ - return UI_STRING("Open Link", "Open Link context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagIgnoreGrammar() -{ - return UI_STRING("Ignore Grammar", "Ignore Grammar context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSpellingMenu() -{ - return UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowSpellingPanel(bool show) -{ - if (show) - return UI_STRING("Show Spelling and Grammar", "menu item title"); - return UI_STRING("Hide Spelling and Grammar", "menu item title"); -} - -String WebPlatformStrategies::contextMenuItemTagCheckSpelling() -{ - return UI_STRING("Check Document Now", "Check spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping() -{ - return UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCheckGrammarWithSpelling() -{ - return UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagFontMenu() -{ - return UI_STRING("Font", "Font context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagBold() -{ - return UI_STRING("Bold", "Bold context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagItalic() -{ - return UI_STRING("Italic", "Italic context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagUnderline() -{ - return UI_STRING("Underline", "Underline context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagOutline() -{ - return UI_STRING("Outline", "Outline context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagWritingDirectionMenu() -{ - return UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagTextDirectionMenu() -{ - return UI_STRING("Selection Direction", "Selection direction context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagDefaultDirection() -{ - return UI_STRING("Default", "Default writing direction context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagLeftToRight() -{ - return UI_STRING("Left to Right", "Left to Right context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagRightToLeft() -{ - return UI_STRING("Right to Left", "Right to Left context menu item"); -} - -#if PLATFORM(MAC) - -String WebPlatformStrategies::contextMenuItemTagSearchInSpotlight() -{ - return UI_STRING("Search in Spotlight", "Search in Spotlight context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowFonts() -{ - return UI_STRING("Show Fonts", "Show fonts context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStyles() -{ - return UI_STRING("Styles...", "Styles context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowColors() -{ - return UI_STRING("Show Colors", "Show colors context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSpeechMenu() -{ - return UI_STRING("Speech", "Speech context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStartSpeaking() -{ - return UI_STRING("Start Speaking", "Start speaking context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagStopSpeaking() -{ - return UI_STRING("Stop Speaking", "Stop speaking context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCorrectSpellingAutomatically() -{ - return UI_STRING("Correct Spelling Automatically", "Correct Spelling Automatically context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSubstitutionsMenu() -{ - return UI_STRING("Substitutions", "Substitutions context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagShowSubstitutions(bool show) -{ - if (show) - return UI_STRING("Show Substitutions", "menu item title"); - return UI_STRING("Hide Substitutions", "menu item title"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartCopyPaste() -{ - return UI_STRING("Smart Copy/Paste", "Smart Copy/Paste context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartQuotes() -{ - return UI_STRING("Smart Quotes", "Smart Quotes context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartDashes() -{ - return UI_STRING("Smart Dashes", "Smart Dashes context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagSmartLinks() -{ - return UI_STRING("Smart Links", "Smart Links context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagTextReplacement() -{ - return UI_STRING("Text Replacement", "Text Replacement context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagTransformationsMenu() -{ - return UI_STRING("Transformations", "Transformations context sub-menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMakeUpperCase() -{ - return UI_STRING("Make Upper Case", "Make Upper Case context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagMakeLowerCase() -{ - return UI_STRING("Make Lower Case", "Make Lower Case context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagCapitalize() -{ - return UI_STRING("Capitalize", "Capitalize context menu item"); -} - -String WebPlatformStrategies::contextMenuItemTagChangeBack(const String& replacedString) -{ - notImplemented(); - return replacedString; -} - -#endif - -String WebPlatformStrategies::contextMenuItemTagInspectElement() -{ - return UI_STRING("Inspect Element", "Inspect Element context menu item"); -} - -#endif // ENABLE(CONTEXT_MENUS) - -String WebPlatformStrategies::searchMenuNoRecentSearchesText() -{ - return UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed"); -} - -String WebPlatformStrategies::searchMenuRecentSearchesText() -{ - return UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title"); -} - -String WebPlatformStrategies::searchMenuClearRecentSearchesText() -{ - return UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents"); -} - -String WebPlatformStrategies::AXWebAreaText() -{ - return UI_STRING("HTML content", "accessibility role description for web area"); -} - -String WebPlatformStrategies::AXLinkText() -{ - return UI_STRING("link", "accessibility role description for link"); -} - -String WebPlatformStrategies::AXListMarkerText() -{ - return UI_STRING("list marker", "accessibility role description for list marker"); -} - -String WebPlatformStrategies::AXImageMapText() -{ - return UI_STRING("image map", "accessibility role description for image map"); -} - -String WebPlatformStrategies::AXHeadingText() -{ - return UI_STRING("heading", "accessibility role description for headings"); -} - -String WebPlatformStrategies::AXDefinitionListTermText() -{ - return UI_STRING("term", "term word of a definition"); -} - -String WebPlatformStrategies::AXDefinitionListDefinitionText() -{ - return UI_STRING("definition", "definition phrase"); -} - -#if PLATFORM(MAC) -String WebPlatformStrategies::AXARIAContentGroupText(const String& ariaType) -{ - if (ariaType == "ARIAApplicationAlert") - return UI_STRING("alert", "An ARIA accessibility group that acts as an alert."); - if (ariaType == "ARIAApplicationAlertDialog") - return UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog."); - if (ariaType == "ARIAApplicationDialog") - return UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog."); - if (ariaType == "ARIAApplicationLog") - return UI_STRING("log", "An ARIA accessibility group that acts as a console log."); - if (ariaType == "ARIAApplicationMarquee") - return UI_STRING("marquee", "An ARIA accessibility group that acts as a marquee."); - if (ariaType == "ARIAApplicationStatus") - return UI_STRING("application status", "An ARIA accessibility group that acts as a status update."); - if (ariaType == "ARIAApplicationTimer") - return UI_STRING("timer", "An ARIA accessibility group that acts as an updating timer."); - if (ariaType == "ARIADocument") - return UI_STRING("document", "An ARIA accessibility group that acts as a document."); - if (ariaType == "ARIADocumentArticle") - return UI_STRING("article", "An ARIA accessibility group that acts as an article."); - if (ariaType == "ARIADocumentNote") - return UI_STRING("note", "An ARIA accessibility group that acts as a note in a document."); - if (ariaType == "ARIADocumentRegion") - return UI_STRING("region", "An ARIA accessibility group that acts as a distinct region in a document."); - if (ariaType == "ARIALandmarkApplication") - return UI_STRING("application", "An ARIA accessibility group that acts as an application."); - if (ariaType == "ARIALandmarkBanner") - return UI_STRING("banner", "An ARIA accessibility group that acts as a banner."); - if (ariaType == "ARIALandmarkComplementary") - return UI_STRING("complementary", "An ARIA accessibility group that acts as a region of complementary information."); - if (ariaType == "ARIALandmarkContentInfo") - return UI_STRING("content", "An ARIA accessibility group that contains content."); - if (ariaType == "ARIALandmarkMain") - return UI_STRING("main", "An ARIA accessibility group that is the main portion of the website."); - if (ariaType == "ARIALandmarkNavigation") - return UI_STRING("navigation", "An ARIA accessibility group that contains the main navigation elements of a website."); - if (ariaType == "ARIALandmarkSearch") - return UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website."); - if (ariaType == "ARIAUserInterfaceTooltip") - return UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip."); - if (ariaType == "ARIATabPanel") - return UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab."); - if (ariaType == "ARIADocumentMath") - return UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols."); - return String(); -} -#endif - -String WebPlatformStrategies::AXButtonActionVerb() -{ - return UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility"); -} - -String WebPlatformStrategies::AXRadioButtonActionVerb() -{ - return UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::AXTextFieldActionVerb() -{ - return UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility"); -} - -String WebPlatformStrategies::AXCheckedCheckBoxActionVerb() -{ - return UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::AXUncheckedCheckBoxActionVerb() -{ - return UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::AXMenuListActionVerb() -{ - notImplemented(); - return "select"; -} - -String WebPlatformStrategies::AXMenuListPopupActionVerb() -{ - notImplemented(); - return "select"; -} - -String WebPlatformStrategies::AXLinkActionVerb() -{ - return UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility"); -} - -String WebPlatformStrategies::missingPluginText() -{ - return UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing"); -} - -String WebPlatformStrategies::crashedPluginText() -{ - return UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed"); -} - -String WebPlatformStrategies::multipleFileUploadText(unsigned numberOfFiles) -{ - return formatLocalizedString(UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles); -} - -String WebPlatformStrategies::unknownFileSizeText() -{ - return UI_STRING("Unknown", "Unknown filesize FTP directory listing item"); -} - -#if PLATFORM(WIN) - -String WebPlatformStrategies::uploadFileText() -{ - notImplemented(); - return "upload"; -} - -String WebPlatformStrategies::allFilesText() -{ - notImplemented(); - return "all files"; -} - -#endif - -String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size) -{ - // FIXME: This should format the numbers correctly. In Mac WebKit, we used +[NSNumberFormatter localizedStringFromNumber:numberStyle:]. - return formatLocalizedString(UI_STRING("<filename> %d×%d pixels", "window title suffix for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()).replace("<filename>", filename); -} - -String WebPlatformStrategies::mediaElementLoadingStateText() -{ - return UI_STRING("Loading...", "Media controller status message when the media is loading"); -} - -String WebPlatformStrategies::mediaElementLiveBroadcastStateText() -{ - return UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast"); -} - -String WebPlatformStrategies::localizedMediaControlElementString(const String& name) -{ - if (name == "AudioElement") - return UI_STRING("audio element controller", "accessibility role description for audio element controller"); - if (name == "VideoElement") - return UI_STRING("video element controller", "accessibility role description for video element controller"); - if (name == "MuteButton") - return UI_STRING("mute", "accessibility role description for mute button"); - if (name == "UnMuteButton") - return UI_STRING("unmute", "accessibility role description for turn mute off button"); - if (name == "PlayButton") - return UI_STRING("play", "accessibility role description for play button"); - if (name == "PauseButton") - return UI_STRING("pause", "accessibility role description for pause button"); - if (name == "Slider") - return UI_STRING("movie time", "accessibility role description for timeline slider"); - if (name == "SliderThumb") - return UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb"); - if (name == "RewindButton") - return UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button"); - if (name == "ReturnToRealtimeButton") - return UI_STRING("return to realtime", "accessibility role description for return to real time button"); - if (name == "CurrentTimeDisplay") - return UI_STRING("elapsed time", "accessibility role description for elapsed time display"); - if (name == "TimeRemainingDisplay") - return UI_STRING("remaining time", "accessibility role description for time remaining display"); - if (name == "StatusDisplay") - return UI_STRING("status", "accessibility role description for movie status"); - if (name == "FullscreenButton") - return UI_STRING("fullscreen", "accessibility role description for enter fullscreen button"); - if (name == "SeekForwardButton") - return UI_STRING("fast forward", "accessibility role description for fast forward button"); - if (name == "SeekBackButton") - return UI_STRING("fast reverse", "accessibility role description for fast reverse button"); - if (name == "ShowClosedCaptionsButton") - return UI_STRING("show closed captions", "accessibility role description for show closed captions button"); - if (name == "HideClosedCaptionsButton") - return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"); - - // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy. - if (name == "ControlsPanel") - return String(); - - ASSERT_NOT_REACHED(); - return String(); -} - -String WebPlatformStrategies::localizedMediaControlElementHelpText(const String& name) -{ - if (name == "AudioElement") - return UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller"); - if (name == "VideoElement") - return UI_STRING("video element playback controls and status display", "accessibility role description for video element controller"); - if (name == "MuteButton") - return UI_STRING("mute audio tracks", "accessibility help text for mute button"); - if (name == "UnMuteButton") - return UI_STRING("unmute audio tracks", "accessibility help text for un mute button"); - if (name == "PlayButton") - return UI_STRING("begin playback", "accessibility help text for play button"); - if (name == "PauseButton") - return UI_STRING("pause playback", "accessibility help text for pause button"); - if (name == "Slider") - return UI_STRING("movie time scrubber", "accessibility help text for timeline slider"); - if (name == "SliderThumb") - return UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb"); - if (name == "RewindButton") - return UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button"); - if (name == "ReturnToRealtimeButton") - return UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button"); - if (name == "CurrentTimeDisplay") - return UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display"); - if (name == "TimeRemainingDisplay") - return UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display"); - if (name == "StatusDisplay") - return UI_STRING("current movie status", "accessibility help text for movie status display"); - if (name == "SeekBackButton") - return UI_STRING("seek quickly back", "accessibility help text for fast rewind button"); - if (name == "SeekForwardButton") - return UI_STRING("seek quickly forward", "accessibility help text for fast forward button"); - if (name == "FullscreenButton") - return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"); - if (name == "ShowClosedCaptionsButton") - return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"); - if (name == "HideClosedCaptionsButton") - return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"); - - ASSERT_NOT_REACHED(); - return String(); -} - -String WebPlatformStrategies::localizedMediaTimeDescription(float time) -{ - if (!isfinite(time)) - return UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value"); - - int seconds = static_cast<int>(fabsf(time)); - int days = seconds / (60 * 60 * 24); - int hours = seconds / (60 * 60); - int minutes = (seconds / 60) % 60; - seconds %= 60; - - if (days) - return formatLocalizedString(UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds); - if (hours) - return formatLocalizedString(UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds); - if (minutes) - return formatLocalizedString(UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds); - return formatLocalizedString(UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds); -} - -String WebPlatformStrategies::validationMessageValueMissingText() -{ - return UI_STRING("value missing", "Validation message for required form control elements that have no value"); -} - -String WebPlatformStrategies::validationMessageTypeMismatchText() -{ - return UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type"); -} - -String WebPlatformStrategies::validationMessagePatternMismatchText() -{ - return UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern"); -} - -String WebPlatformStrategies::validationMessageTooLongText() -{ - return UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length"); -} - -String WebPlatformStrategies::validationMessageRangeUnderflowText() +void WebPlatformStrategies::populatePluginCache() { - return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum"); -} + if (m_pluginCacheIsPopulated) + return; -String WebPlatformStrategies::validationMessageRangeOverflowText() -{ - return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum"); -} + ASSERT(m_cachedPlugins.isEmpty()); + + Vector<PluginInfo> plugins; + + // FIXME: Should we do something in case of error here? + WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPlugins(m_shouldRefreshPlugins), + Messages::WebContext::GetPlugins::Reply(plugins), 0); -String WebPlatformStrategies::validationMessageStepMismatchText() -{ - return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute"); + m_cachedPlugins.swap(plugins); + + m_shouldRefreshPlugins = false; + m_pluginCacheIsPopulated = true; } // VisitedLinkStrategy + bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash linkHash) { return WebProcess::shared().isLinkVisited(linkHash); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h index 92f8236..55285de 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h @@ -31,12 +31,11 @@ #include <WebCore/CookiesStrategy.h> #include <WebCore/PlatformStrategies.h> #include <WebCore/PluginStrategy.h> -#include <WebCore/LocalizationStrategy.h> #include <WebCore/VisitedLinkStrategy.h> namespace WebKit { -class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::PluginStrategy, private WebCore::LocalizationStrategy, private WebCore::VisitedLinkStrategy { +class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::CookiesStrategy, private WebCore::PluginStrategy, private WebCore::VisitedLinkStrategy { public: static void initialize(); @@ -46,7 +45,6 @@ private: // WebCore::PlatformStrategies virtual WebCore::CookiesStrategy* createCookiesStrategy(); virtual WebCore::PluginStrategy* createPluginStrategy(); - virtual WebCore::LocalizationStrategy* createLocalizationStrategy(); virtual WebCore::VisitedLinkStrategy* createVisitedLinkStrategy(); // WebCore::CookiesStrategy @@ -55,152 +53,15 @@ private: // WebCore::PluginStrategy virtual void refreshPlugins(); virtual void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&); - - // WebCore::LocalizationStrategy - virtual String inputElementAltText(); - virtual String resetButtonDefaultLabel(); - virtual String searchableIndexIntroduction(); - virtual String submitButtonDefaultLabel(); - virtual String fileButtonChooseFileLabel(); - virtual String fileButtonNoFileSelectedLabel(); - virtual String defaultDetailsSummaryText(); -#if PLATFORM(MAC) - virtual String copyImageUnknownFileLabel(); -#endif -#if ENABLE(CONTEXT_MENUS) - virtual String contextMenuItemTagOpenLinkInNewWindow(); - virtual String contextMenuItemTagDownloadLinkToDisk(); - virtual String contextMenuItemTagCopyLinkToClipboard(); - virtual String contextMenuItemTagOpenImageInNewWindow(); - virtual String contextMenuItemTagDownloadImageToDisk(); - virtual String contextMenuItemTagCopyImageToClipboard(); -#if PLATFORM(QT) - virtual String contextMenuItemTagCopyImageUrlToClipboard(); -#endif - virtual String contextMenuItemTagOpenFrameInNewWindow(); - virtual String contextMenuItemTagCopy(); - virtual String contextMenuItemTagGoBack(); - virtual String contextMenuItemTagGoForward(); - virtual String contextMenuItemTagStop(); - virtual String contextMenuItemTagReload(); - virtual String contextMenuItemTagCut(); - virtual String contextMenuItemTagPaste(); -#if PLATFORM(GTK) - virtual String contextMenuItemTagDelete(); - virtual String contextMenuItemTagInputMethods(); - virtual String contextMenuItemTagUnicode(); -#endif -#if PLATFORM(GTK) || PLATFORM(QT) - virtual String contextMenuItemTagSelectAll(); -#endif - virtual String contextMenuItemTagNoGuessesFound(); - virtual String contextMenuItemTagIgnoreSpelling(); - virtual String contextMenuItemTagLearnSpelling(); - virtual String contextMenuItemTagSearchWeb(); - virtual String contextMenuItemTagLookUpInDictionary(); - virtual String contextMenuItemTagOpenLink(); - virtual String contextMenuItemTagIgnoreGrammar(); - virtual String contextMenuItemTagSpellingMenu(); - virtual String contextMenuItemTagShowSpellingPanel(bool show); - virtual String contextMenuItemTagCheckSpelling(); - virtual String contextMenuItemTagCheckSpellingWhileTyping(); - virtual String contextMenuItemTagCheckGrammarWithSpelling(); - virtual String contextMenuItemTagFontMenu(); - virtual String contextMenuItemTagBold(); - virtual String contextMenuItemTagItalic(); - virtual String contextMenuItemTagUnderline(); - virtual String contextMenuItemTagOutline(); - virtual String contextMenuItemTagWritingDirectionMenu(); - virtual String contextMenuItemTagTextDirectionMenu(); - virtual String contextMenuItemTagDefaultDirection(); - virtual String contextMenuItemTagLeftToRight(); - virtual String contextMenuItemTagRightToLeft(); -#if PLATFORM(MAC) - virtual String contextMenuItemTagSearchInSpotlight(); - virtual String contextMenuItemTagShowFonts(); - virtual String contextMenuItemTagStyles(); - virtual String contextMenuItemTagShowColors(); - virtual String contextMenuItemTagSpeechMenu(); - virtual String contextMenuItemTagStartSpeaking(); - virtual String contextMenuItemTagStopSpeaking(); - virtual String contextMenuItemTagCorrectSpellingAutomatically(); - virtual String contextMenuItemTagSubstitutionsMenu(); - virtual String contextMenuItemTagShowSubstitutions(bool show); - virtual String contextMenuItemTagSmartCopyPaste(); - virtual String contextMenuItemTagSmartQuotes(); - virtual String contextMenuItemTagSmartDashes(); - virtual String contextMenuItemTagSmartLinks(); - virtual String contextMenuItemTagTextReplacement(); - virtual String contextMenuItemTagTransformationsMenu(); - virtual String contextMenuItemTagMakeUpperCase(); - virtual String contextMenuItemTagMakeLowerCase(); - virtual String contextMenuItemTagCapitalize(); - virtual String contextMenuItemTagChangeBack(const String& replacedString); -#endif - virtual String contextMenuItemTagInspectElement(); - virtual String contextMenuItemTagOpenVideoInNewWindow(); - virtual String contextMenuItemTagOpenAudioInNewWindow(); - virtual String contextMenuItemTagCopyVideoLinkToClipboard(); - virtual String contextMenuItemTagCopyAudioLinkToClipboard(); - virtual String contextMenuItemTagToggleMediaControls(); - virtual String contextMenuItemTagToggleMediaLoop(); - virtual String contextMenuItemTagEnterVideoFullscreen(); - virtual String contextMenuItemTagMediaPlay(); - virtual String contextMenuItemTagMediaPause(); - virtual String contextMenuItemTagMediaMute(); -#endif // ENABLE(CONTEXT_MENUS) - virtual String searchMenuNoRecentSearchesText(); - virtual String searchMenuRecentSearchesText(); - virtual String searchMenuClearRecentSearchesText(); - virtual String AXWebAreaText(); - virtual String AXLinkText(); - virtual String AXListMarkerText(); - virtual String AXImageMapText(); - virtual String AXHeadingText(); - virtual String AXDefinitionListTermText(); - virtual String AXDefinitionListDefinitionText(); -#if PLATFORM(MAC) - virtual String AXARIAContentGroupText(const String& ariaType); -#endif - virtual String AXButtonActionVerb(); - virtual String AXRadioButtonActionVerb(); - virtual String AXTextFieldActionVerb(); - virtual String AXCheckedCheckBoxActionVerb(); - virtual String AXUncheckedCheckBoxActionVerb(); - virtual String AXMenuListActionVerb(); - virtual String AXMenuListPopupActionVerb(); - virtual String AXLinkActionVerb(); - virtual String missingPluginText(); - virtual String crashedPluginText(); - virtual String multipleFileUploadText(unsigned numberOfFiles); - virtual String unknownFileSizeText(); -#if PLATFORM(WIN) - virtual String uploadFileText(); - virtual String allFilesText(); -#endif - virtual String imageTitle(const String& filename, const WebCore::IntSize& size); - virtual String mediaElementLoadingStateText(); - virtual String mediaElementLiveBroadcastStateText(); - virtual String localizedMediaControlElementString(const String&); - virtual String localizedMediaControlElementHelpText(const String&); - virtual String localizedMediaTimeDescription(float); - virtual String validationMessageValueMissingText(); - virtual String validationMessageTypeMismatchText(); - virtual String validationMessagePatternMismatchText(); - virtual String validationMessageTooLongText(); - virtual String validationMessageRangeUnderflowText(); - virtual String validationMessageRangeOverflowText(); - virtual String validationMessageStepMismatchText(); - void populatePluginCache(); - bool m_pluginCacheIsPopulated; - bool m_shouldRefreshPlugins; - Vector<WebCore::PluginInfo> m_cachedPlugins; - // WebCore::VisitedLinkStrategy virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash); virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash); + + bool m_pluginCacheIsPopulated; + bool m_shouldRefreshPlugins; + Vector<WebCore::PluginInfo> m_cachedPlugins; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm index 7d91c56..6aa83f8 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm @@ -41,11 +41,7 @@ namespace WebKit { void WebContextMenuClient::lookUpInDictionary(Frame* frame) { - RefPtr<Range> selectedRange = frame->selection()->selection().toNormalizedRange(); - if (!selectedRange) - return; - - m_page->performDictionaryLookupForRange(DictionaryPopupInfo::ContextMenu, frame, selectedRange.get()); + m_page->performDictionaryLookupForSelection(DictionaryPopupInfo::ContextMenu, frame, frame->selection()->selection()); } bool WebContextMenuClient::isSpeaking() diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm index ae9cec3..75d92e2 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm @@ -32,134 +32,273 @@ #import "WebPage.h" #import "WebPageProxyMessages.h" #import <WebCore/CachedImage.h> -#import <WebCore/DOMPrivate.h> #import <WebCore/DOMElementInternal.h> +#import <WebCore/DOMPrivate.h> +#import <WebCore/DragController.h> #import <WebCore/FrameView.h> #import <WebCore/GraphicsContext.h> #import <WebCore/LegacyWebArchive.h> #import <WebCore/RenderImage.h> +#import <WebCore/ResourceHandle.h> #import <WebCore/StringTruncator.h> -#import <wtf/StdLibExtras.h> +#import <WebKit/WebArchive.h> #import <WebKit/WebKitNSStringExtras.h> +#import <WebKit/WebNSFileManagerExtras.h> +#import <WebKit/WebNSPasteboardExtras.h> #import <WebKit/WebNSURLExtras.h> +#import <WebKitSystemInterface.h> +#import <wtf/StdLibExtras.h> using namespace WebCore; +using namespace WebKit; + +// Internal AppKit class. If the pasteboard handling was in the same process +// that called the dragImage method, this would be created automatically. +// Create it explicitly because dragImage is called in the UI process. +@interface NSFilePromiseDragSource : NSObject +{ + char _unknownFields[256]; +} +- (id)initWithSource:(id)dragSource; +- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pasteboard; +@end + +@interface WKPasteboardFilePromiseOwner : NSFilePromiseDragSource +@end + +@interface WKPasteboardOwner : NSObject +{ + CachedResourceHandle<CachedImage> _image; +} +- (id)initWithImage:(CachedImage*)image; +@end namespace WebKit { -using namespace WebCore; - -void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) +static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image) { - if (!frame) - return; - ASSERT(clipboard); - - NSImage *dragNSImage = dragImage.get(); - RefPtr<ShareableBitmap> dragShareableImage = ShareableBitmap::createShareable(IntSize([dragNSImage size])); - OwnPtr<GraphicsContext> graphicsContext = dragShareableImage->createGraphicsContext(); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize([image size]), ShareableBitmap::SupportsAlpha); + OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); - [NSGraphicsContext saveGraphicsState]; - NSGraphicsContext* bitmapContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]; - [NSGraphicsContext setCurrentContext: bitmapContext]; - - [dragNSImage drawInRect:NSMakeRect(0, 0, [dragNSImage size].width , [dragNSImage size].height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil]; - [NSGraphicsContext restoreGraphicsState]; - - SharedMemory::Handle handle; - if (!dragShareableImage->createHandle(handle)) + RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext]; + + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]]; + [image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil]; + + [NSGraphicsContext setCurrentContext:savedContext.get()]; + + return bitmap.release(); +} + +void WebDragClient::startDrag(RetainPtr<NSImage> image, const IntPoint& point, const IntPoint&, Clipboard*, Frame* frame, bool linkDrag) +{ + RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get()); + ShareableBitmap::Handle handle; + if (!bitmap->createHandle(handle)) return; - IntPoint clientPoint(at); - m_page->send(Messages::WebPageProxy::SetDragImage(clientPoint, IntSize([dragNSImage size]), handle, linkDrag)); + + // FIXME: Seems this message should be named StartDrag, not SetDragImage. + m_page->send(Messages::WebPageProxy::SetDragImage(frame->view()->contentsToWindow(point), handle, linkDrag)); } -static void writeURL(NSPasteboard* pasteboard, NSURL* URL, NSString* title, NSArray* types) +static CachedImage* cachedImage(Element* element) { - ASSERT(URL); - + RenderObject* renderer = element->renderer(); + if (!renderer) + return 0; + if (!renderer->isRenderImage()) + return 0; + CachedImage* image = toRenderImage(renderer)->cachedImage(); + if (!image || image->errorOccurred()) + return 0; + return image; +} + +static NSArray *arrayForURLsWithTitles(NSURL *URL, NSString *title) +{ + return [NSArray arrayWithObjects:[NSArray arrayWithObject:[URL _web_originalDataAsString]], + [NSArray arrayWithObject:[title _webkit_stringByTrimmingWhitespace]], nil]; +} + +void WebDragClient::declareAndWriteDragImage(NSPasteboard *pasteboard, DOMElement *element, NSURL *URL, NSString *title, WebCore::Frame*) +{ + ASSERT(element); + ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]); + + Element* coreElement = core(element); + + CachedImage* image = cachedImage(coreElement); + + NSString *extension = @""; + if (image) { + extension = image->image()->filenameExtension(); + if (![extension length]) + return; + } + if (![title length]) { title = [[URL path] lastPathComponent]; if (![title length]) title = [URL _web_userVisibleString]; } - - if ([types containsObject:NSURLPboardType]) - [URL writeToPasteboard:pasteboard]; - if ([types containsObject:PasteboardTypes::WebURLPboardType]) - [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType]; - if ([types containsObject:PasteboardTypes::WebURLNamePboardType]) - [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType]; - if ([types containsObject:NSStringPboardType]) - [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType]; - if ([types containsObject:PasteboardTypes::WebURLsWithTitlesPboardType]) { - NSArray* URLs = [NSArray arrayWithObject:URL]; - unsigned count = [URLs count]; - - if (!count || [pasteboard availableTypeFromArray:[NSArray arrayWithObject:PasteboardTypes::WebURLsWithTitlesPboardType]] == nil) - return; - NSArray* titles = [NSArray arrayWithObject:title]; - - if (count != [titles count]) - titles = nil; - - NSMutableArray* URLStrings = [NSMutableArray arrayWithCapacity:count]; - NSMutableArray* titlesOrEmptyStrings = [NSMutableArray arrayWithCapacity:count]; - for (unsigned index = 0; index < count; ++index) { - [URLStrings addObject:[[URLs objectAtIndex:index] _web_originalDataAsString]]; - [titlesOrEmptyStrings addObject:(titles == nil) ? @"" : [[titles objectAtIndex:index] _webkit_stringByTrimmingWhitespace]]; + RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreElement); + + RetainPtr<NSMutableArray> types(AdoptNS, [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]); + [types.get() addObjectsFromArray:archive ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; + + RetainPtr<WKPasteboardOwner> pasteboardOwner(AdoptNS, [[WKPasteboardOwner alloc] initWithImage:image]); + + RetainPtr<WKPasteboardFilePromiseOwner> filePromiseOwner(AdoptNS, [(WKPasteboardFilePromiseOwner *)[WKPasteboardFilePromiseOwner alloc] initWithSource:pasteboardOwner.get()]); + m_page->setDragSource(filePromiseOwner.get()); + + [pasteboard declareTypes:types.get() owner:pasteboardOwner.get()]; + + [pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType]; + + [filePromiseOwner.get() setTypes:[pasteboard propertyListForType:NSFilesPromisePboardType] onPasteboard:pasteboard]; + + [URL writeToPasteboard:pasteboard]; + + [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType]; + + [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType]; + + [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType]; + + [pasteboard setPropertyList:arrayForURLsWithTitles(URL, title) forType:PasteboardTypes::WebURLsWithTitlesPboardType]; + + if (archive) + [pasteboard setData:(NSData *)archive->rawDataRepresentation().get() forType:PasteboardTypes::WebArchivePboardType]; +} + +} // namespace WebKit + +@implementation WKPasteboardFilePromiseOwner + +// The AppKit implementation of copyDropDirectory gets the current pasteboard in +// a way that only works in the process where the drag is initiated. We supply +// an implementation that gets the pasteboard by name instead. +- (CFURLRef)copyDropDirectory +{ + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate((CFStringRef)NSDragPboard, &pasteboard); + if (status != noErr || !pasteboard) + return 0; + CFURLRef location = 0; + status = PasteboardCopyPasteLocation(pasteboard, &location); + CFRelease(pasteboard); + if (status != noErr || !location) + return 0; + CFMakeCollectable(location); + return location; +} + +@end + +@implementation WKPasteboardOwner + +static CachedResourceClient* promisedDataClient() +{ + static CachedResourceClient* client = new CachedResourceClient; + return client; +} + +- (void)clearImage +{ + if (!_image) + return; + _image->removeClient(promisedDataClient()); + _image = 0; +} + +- (id)initWithImage:(CachedImage*)image +{ + self = [super init]; + if (!self) + return nil; + + _image = image; + if (image) + image->addClient(promisedDataClient()); + return self; +} + +- (void)dealloc +{ + [self clearImage]; + [super dealloc]; +} + +- (void)finalize +{ + [self clearImage]; + [super finalize]; +} + +- (void)pasteboard:(NSPasteboard *)pasteboard provideDataForType:(NSString *)type +{ + if ([type isEqual:NSTIFFPboardType]) { + if (_image) { + if (Image* image = _image->image()) + [pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType]; + [self clearImage]; } - - [pasteboard setPropertyList:[NSArray arrayWithObjects:URLStrings, titlesOrEmptyStrings, nil] - forType:PasteboardTypes::WebURLsWithTitlesPboardType]; + return; } + // FIXME: Handle RTFD here. } - -static void writeImage(NSPasteboard* pasteboard, NSImage *image, DOMElement* element, NSURL* URL, NSString* title, LegacyWebArchive* archive, NSArray* types) + +- (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard { - ASSERT(image || element); - ASSERT(URL); - - writeURL(pasteboard, URL, title, types); - - if ([types containsObject:NSTIFFPboardType]) { - // FIXME: we should add handling of promised types. - if (image) - [pasteboard setData:[image TIFFRepresentation] forType:NSTIFFPboardType]; - else if (element) - [pasteboard setData:[element _imageTIFFRepresentation] forType:NSTIFFPboardType]; - } - - if (archive && [types containsObject:PasteboardTypes::WebArchivePboardType]) - [pasteboard setData:[[(NSData *)archive->rawDataRepresentation().get() retain] autorelease] forType:PasteboardTypes::WebArchivePboardType]; + [self clearImage]; } - -void WebDragClient::declareAndWriteDragImage(NSPasteboard* pasteboard, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame*) + +static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension) { - ASSERT(element); - ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]); + NSString *extensionAsSuffix = [@"." stringByAppendingString:extension]; + return [filename _webkit_hasCaseInsensitiveSuffix:extensionAsSuffix] + || ([extension _webkit_isCaseInsensitiveEqualToString:@"jpeg"] + && [filename _webkit_hasCaseInsensitiveSuffix:@".jpg"]); +} + +- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination +{ + NSFileWrapper *wrapper = nil; + NSURL *draggingImageURL = nil; - NSString *extension = @""; - if (RenderObject* renderer = core(element)->renderer()) { - if (renderer->isImage()) { - if (CachedImage* image = toRenderImage(renderer)->cachedImage()) { - extension = image->image()->filenameExtension(); - if (![extension length]) - return; - } + if (_image) { + if (SharedBuffer* buffer = _image->CachedResource::data()) { + NSData *data = buffer->createNSData(); + NSURLResponse *response = _image->response().nsURLResponse(); + draggingImageURL = [response URL]; + wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease]; + NSString* filename = [response suggestedFilename]; + NSString* trueExtension(_image->image()->filenameExtension()); + if (!matchesExtensionOrEquivalent(filename, trueExtension)) + filename = [[filename stringByAppendingString:@"."] stringByAppendingString:trueExtension]; + [wrapper setPreferredFilename:filename]; } } + + // FIXME: Do we need to handle the case where we do not have a CachedImage? + // WebKit1 had code for this case. - RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(core(element)); - NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; - [types addObjectsFromArray:(archive) ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; - [pasteboard declareTypes:types owner:nil]; - writeImage(pasteboard, nil, element, URL, title, archive.get(), types); - [types release]; - - NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil]; - [pasteboard setPropertyList:extensions forType:NSFilesPromisePboardType]; - [extensions release]; + if (!wrapper) { + LOG_ERROR("Failed to create image file."); + return nil; + } + + // FIXME: Report an error if we fail to create a file. + NSString *path = [[dropDestination path] stringByAppendingPathComponent:[wrapper preferredFilename]]; + path = [[NSFileManager defaultManager] _webkit_pathWithUniqueFilenameForPath:path]; + if (![wrapper writeToFile:path atomically:NO updateFilenames:YES]) + LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToFile:atomically:updateFilenames:] at path %@", path); + + if (draggingImageURL) + [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingImageURL absoluteString] referrer:nil atPath:path]; + + return [NSArray arrayWithObject:[path lastPathComponent]]; } -} // namespace WebKit +@end diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm index 8af0438..7a95a72 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm @@ -46,7 +46,7 @@ #import <WebCore/Page.h> #import <WebKit/WebResource.h> #import <WebKit/WebNSURLExtras.h> -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if !defined(BUILDING_ON_SNOW_LEOPARD) #import <AppKit/NSTextChecker.h> #endif @@ -246,26 +246,27 @@ void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64 m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results)); } -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) -void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*) +#if !defined(BUILDING_ON_SNOW_LEOPARD) +void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) { - notImplemented(); + m_page->send(Messages::WebPageProxy::ShowCorrectionPanel(type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings)); } -void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) +void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel reason) { - notImplemented(); + m_page->send(Messages::WebPageProxy::DismissCorrectionPanel(reason)); } -bool WebEditorClient::isShowingCorrectionPanel() +String WebEditorClient::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel reason) { - notImplemented(); - return false; + String result; + m_page->sendSync(Messages::WebPageProxy::DismissCorrectionPanelSoon(reason), Messages::WebPageProxy::DismissCorrectionPanelSoon::Reply(result)); + return result; } void WebEditorClient::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString) { - notImplemented(); + m_page->send(Messages::WebPageProxy::RecordAutocorrectionResponse(responseType, replacedString, replacementString)); } #endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm index 677c537..70e7607 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm @@ -28,6 +28,7 @@ #import "WKError.h" #import "WebError.h" +#import <WebCore/LocalizedStrings.h> #import <WebCore/ResourceRequest.h> #import <WebCore/ResourceResponse.h> #import <pthread.h> @@ -41,9 +42,6 @@ static NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIME static NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey"; static NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey"; -// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized -#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] - // Policy errors #define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description") #define WebKitErrorDescriptionCannotShowURL UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description") @@ -119,17 +117,17 @@ static void registerErrors() NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: // Policy errors - WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: kWKErrorCodeCannotShowMIMEType], - WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: kWKErrorCodeCannotShowURL], - WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: kWKErrorCodeFrameLoadInterruptedByPolicyChange], - WebKitErrorDescriptionCannotUseRestrictedPort, [NSNumber numberWithInt: kWKErrorCodeCannotUseRestrictedPort], + (NSString *)WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: kWKErrorCodeCannotShowMIMEType], + (NSString *)WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: kWKErrorCodeCannotShowURL], + (NSString *)WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: kWKErrorCodeFrameLoadInterruptedByPolicyChange], + (NSString *)WebKitErrorDescriptionCannotUseRestrictedPort, [NSNumber numberWithInt: kWKErrorCodeCannotUseRestrictedPort], // Plug-in and java errors - WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotFindPlugIn], - WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotLoadPlugIn], - WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: kWKErrorCodeJavaUnavailable], - WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: kWKErrorCodePlugInCancelledConnection], - WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: kWKErrorCodePlugInWillHandleLoad], + (NSString *)WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotFindPlugIn], + (NSString *)WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotLoadPlugIn], + (NSString *)WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: kWKErrorCodeJavaUnavailable], + (NSString *)WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: kWKErrorCodePlugInCancelledConnection], + (NSString *)WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: kWKErrorCodePlugInWillHandleLoad], nil]; [NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebError::webKitErrorDomain()]; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 2c8649e..06faa2f 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -59,6 +59,7 @@ void InitWebCoreSystemInterface(void) INIT(GetHTTPPipeliningPriority); INIT(GetMIMETypeForExtension); INIT(GetNSURLResponseLastModifiedDate); + INIT(SignedPublicKeyAndChallengeString); INIT(GetPreferredExtensionForMIMEType); INIT(GetUserToBaseCTM); INIT(GetWheelEventDeltas); @@ -95,7 +96,7 @@ void InitWebCoreSystemInterface(void) INIT(SignalCFReadStreamHasBytes); INIT(CreatePrivateStorageSession); INIT(CopyRequestWithStorageSession); - INIT(CreatePrivateInMemoryHTTPCookieStorage); + INIT(CopyHTTPCookieStorage); INIT(GetHTTPCookieAcceptPolicy); INIT(HTTPCookiesForURL); INIT(SetHTTPCookiesForURL); @@ -108,6 +109,7 @@ void InitWebCoreSystemInterface(void) INIT(MakeScrollbarPainter); INIT(ScrollbarPainterSetDelegate); INIT(ScrollbarPainterPaint); + INIT(ScrollbarPainterForceFlashScrollers); INIT(ScrollbarThickness); INIT(ScrollbarMinimumThumbLength); INIT(ScrollbarMinimumTotalLengthNeededForThumb); @@ -148,5 +150,11 @@ void InitWebCoreSystemInterface(void) INIT(AccessibilityHandleFocusChanged); INIT(CreateAXUIElementRef); INIT(UnregisterUniqueIdForElement); + + INIT(GetCFURLResponseMIMEType); + INIT(GetCFURLResponseURL); + INIT(GetCFURLResponseHTTPResponse); + INIT(CopyCFURLResponseSuggestedFilename); + INIT(SetCFURLResponseMIMEType); }); } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp index b4db406..851203c 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp @@ -78,9 +78,9 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl // The backing stores should be drawn at least as wide as the control on the page to match the width of the popup window we'll create. int backingStoreWidth = max(pageCoordinates.width() - m_popupClient->clientInsetLeft() - m_popupClient->clientInsetRight(), popupWidth); - data.m_backingStoreSize = IntSize(backingStoreWidth, (itemCount * data.m_itemHeight)); - data.m_notSelectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize); - data.m_selectedBackingStore = ShareableBitmap::createShareable(data.m_backingStoreSize); + IntSize backingStoreSize(backingStoreWidth, (itemCount * data.m_itemHeight)); + data.m_notSelectedBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); + data.m_selectedBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); OwnPtr<GraphicsContext> notSelectedBackingStoreContext = data.m_notSelectedBackingStore->createGraphicsContext(); OwnPtr<GraphicsContext> selectedBackingStoreContext = data.m_selectedBackingStore->createGraphicsContext(); @@ -88,7 +88,7 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl Color activeOptionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor(); Color activeOptionTextColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor(); - for (int y = 0; y < data.m_backingStoreSize.height(); y += data.m_itemHeight) { + for (int y = 0; y < backingStoreSize.height(); y += data.m_itemHeight) { int index = y / data.m_itemHeight; PopupMenuStyle itemStyle = m_popupClient->itemStyle(index); |