diff options
Diffstat (limited to 'WebKit/mac/WebCoreSupport')
36 files changed, 2579 insertions, 1106 deletions
diff --git a/WebKit/mac/WebCoreSupport/WebApplicationCache.h b/WebKit/mac/WebCoreSupport/WebApplicationCache.h index 282157f..976ce18 100644 --- a/WebKit/mac/WebCoreSupport/WebApplicationCache.h +++ b/WebKit/mac/WebCoreSupport/WebApplicationCache.h @@ -25,8 +25,14 @@ #import <Foundation/Foundation.h> -@interface WebApplicationCache: NSObject { -} +@interface WebApplicationCache: NSObject + ++ (long long)maximumSize; ++ (void)setMaximumSize:(long long)size; + ++ (long long)defaultOriginQuota; ++ (void)setDefaultOriginQuota:(long long)size; + ++ (void)deleteAllApplicationCaches; -+ (void)setMaximumSize:(unsigned long long)size; @end diff --git a/WebKit/mac/WebCoreSupport/WebApplicationCache.mm b/WebKit/mac/WebCoreSupport/WebApplicationCache.mm index 4ca749c..45f0703 100644 --- a/WebKit/mac/WebCoreSupport/WebApplicationCache.mm +++ b/WebKit/mac/WebCoreSupport/WebApplicationCache.mm @@ -32,11 +32,31 @@ using namespace WebCore; @implementation WebApplicationCache -+ (void)setMaximumSize:(unsigned long long)size ++ (long long)maximumSize +{ + return cacheStorage().maximumSize(); +} + ++ (void)setMaximumSize:(long long)size +{ + [WebApplicationCache deleteAllApplicationCaches]; + cacheStorage().setMaximumSize(size); +} + ++ (long long)defaultOriginQuota +{ + return cacheStorage().defaultOriginQuota(); +} + ++ (void)setDefaultOriginQuota:(long long)size +{ + cacheStorage().setDefaultOriginQuota(size); +} + ++ (void)deleteAllApplicationCaches { cacheStorage().empty(); cacheStorage().vacuumDatabaseFile(); - cacheStorage().setMaximumSize(size); } @end diff --git a/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.h b/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.h new file mode 100644 index 0000000..6d30148 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.h @@ -0,0 +1,32 @@ +/* + * 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. + */ + +#import "WebQuotaManager.h" + +@interface WebApplicationCacheQuotaManager : NSObject <WebQuotaManager> { + WebSecurityOrigin *_origin; +} + +@end diff --git a/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.mm b/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.mm new file mode 100644 index 0000000..562bb29 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.mm @@ -0,0 +1,81 @@ +/* + * 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. + */ + +#import "WebApplicationCacheQuotaManager.h" + +#import "WebSecurityOriginInternal.h" +#import <WebCore/ApplicationCacheStorage.h> + +using namespace WebCore; + +@implementation WebApplicationCacheQuotaManager + +- (id)initWithOrigin:(WebSecurityOrigin *)origin +{ + self = [super init]; + if (!self) + return nil; + + _origin = origin; + return self; +} + +- (WebSecurityOrigin *)origin +{ + return _origin; +} + +- (unsigned long long)usage +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + long long usage; + if (cacheStorage().usageForOrigin([_origin _core], usage)) + return usage; + return 0; +#else + return 0; +#endif +} + +- (unsigned long long)quota +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + long long quota; + if (cacheStorage().quotaForOrigin([_origin _core], quota)) + return quota; + return 0; +#else + return 0; +#endif +} + +- (void)setQuota:(unsigned long long)quota +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + cacheStorage().storeUpdatedQuotaForOrigin([_origin _core], quota); +#endif +} + +@end diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.h b/WebKit/mac/WebCoreSupport/WebChromeClient.h index 8e8b51a..a5f49e3 100644 --- a/WebKit/mac/WebCoreSupport/WebChromeClient.h +++ b/WebKit/mac/WebCoreSupport/WebChromeClient.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,7 +36,7 @@ class WebChromeClient : public WebCore::ChromeClient { public: WebChromeClient(WebView *webView); - WebView *webView() { return m_webView; } + WebView *webView() const { return m_webView; } virtual void chromeDestroyed(); @@ -54,8 +54,9 @@ public: virtual void takeFocus(WebCore::FocusDirection); virtual void focusedNodeChanged(WebCore::Node*); + virtual void focusedFrameChanged(WebCore::Frame*); - virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&); + virtual WebCore::Page* createWindow(WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&); virtual void show(); virtual bool canRunModal(); @@ -75,43 +76,49 @@ public: virtual void setResizable(bool); - virtual void addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceURL); + virtual void addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceURL); virtual bool canRunBeforeUnloadConfirmPanel(); - virtual bool runBeforeUnloadConfirmPanel(const WebCore::String& message, WebCore::Frame* frame); + virtual bool runBeforeUnloadConfirmPanel(const WTF::String& message, WebCore::Frame* frame); virtual void closeWindowSoon(); - virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&); - virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&); - virtual bool runJavaScriptPrompt(WebCore::Frame*, const WebCore::String& message, const WebCore::String& defaultValue, WebCore::String& result); + virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&); + virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&); + virtual bool runJavaScriptPrompt(WebCore::Frame*, const WTF::String& message, const WTF::String& defaultValue, WTF::String& result); virtual bool shouldInterruptJavaScript(); virtual bool tabsToLinks() const; virtual WebCore::IntRect windowResizerRect() const; - virtual void repaint(const WebCore::IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false); + virtual void invalidateWindow(const WebCore::IntRect&, bool); + virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); + virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect); + virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; virtual PlatformPageClient platformPageClient() const; virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; - virtual void setStatusbarText(const WebCore::String&); + virtual void setStatusbarText(const WTF::String&); virtual void scrollbarsModeDidChange() const { } + virtual bool shouldMissingPluginMessageBeButton() const; + virtual void missingPluginButtonClicked(WebCore::Element*) const; virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); - virtual void setToolTip(const WebCore::String&, WebCore::TextDirection); + virtual void setToolTip(const WTF::String&, WebCore::TextDirection); virtual void print(WebCore::Frame*); #if ENABLE(DATABASE) - virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String& databaseName); + virtual void exceededDatabaseQuota(WebCore::Frame*, const WTF::String& databaseName); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) virtual void reachedMaxAppCacheSize(int64_t spaceNeeded); + virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*); #endif virtual void populateVisitedLinks(); @@ -120,12 +127,13 @@ public: #endif virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); + virtual void chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*); - virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; } + virtual void setCursor(const WebCore::Cursor&); - virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WebCore::AtomicString& type, + virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& lineRect); - virtual void paintCustomHighlight(WebCore::Node*, const WebCore::AtomicString& type, + virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect, bool behindText, bool entireLine); @@ -136,10 +144,10 @@ public: virtual void willPopUpMenu(NSMenu *); - virtual bool shouldReplaceWithGeneratedFileForUpload(const WebCore::String& path, WebCore::String &generatedFilename); - virtual WebCore::String generateReplacementFile(const WebCore::String& path); + virtual bool shouldReplaceWithGeneratedFileForUpload(const WTF::String& path, WTF::String &generatedFilename); + virtual WTF::String generateReplacementFile(const WTF::String& path); - virtual void formStateDidChange(const WebCore::Node*); + virtual void formStateDidChange(const WebCore::Node*) { } virtual void formDidFocus(const WebCore::Node*); virtual void formDidBlur(const WebCore::Node*); @@ -157,10 +165,23 @@ public: virtual void enterFullscreenForNode(WebCore::Node*); virtual void exitFullscreenForNode(WebCore::Node*); #endif + +#if ENABLE(FULLSCREEN_API) + virtual bool supportsFullScreenForElement(const WebCore::Element*); + virtual void enterFullScreenForElement(WebCore::Element*); + virtual void exitFullScreenForElement(WebCore::Element*); +#endif virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*); - virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*) { } + virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { } + virtual bool selectItemWritingDirectionIsNatural(); + virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const; + virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const; + +#if ENABLE(CONTEXT_MENUS) + virtual void showContextMenu() { } +#endif private: WebView *m_webView; }; diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.mm b/WebKit/mac/WebCoreSupport/WebChromeClient.mm index c4e9671..fe95989 100644 --- a/WebKit/mac/WebCoreSupport/WebChromeClient.mm +++ b/WebKit/mac/WebCoreSupport/WebChromeClient.mm @@ -1,6 +1,6 @@ /* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,6 +41,7 @@ #import "WebKitSystemInterface.h" #import "WebNSURLRequestExtras.h" #import "WebPlugin.h" +#import "WebQuotaManager.h" #import "WebSecurityOriginInternal.h" #import "WebUIDelegatePrivate.h" #import "WebView.h" @@ -48,20 +49,24 @@ #import <Foundation/Foundation.h> #import <WebCore/BlockExceptions.h> #import <WebCore/Console.h> +#import <WebCore/Cursor.h> #import <WebCore/Element.h> #import <WebCore/FileChooser.h> #import <WebCore/FloatRect.h> #import <WebCore/Frame.h> #import <WebCore/FrameLoadRequest.h> #import <WebCore/Geolocation.h> -#import <WebCore/HitTestResult.h> #import <WebCore/HTMLNames.h> +#import <WebCore/HitTestResult.h> +#import <WebCore/Icon.h> #import <WebCore/IntRect.h> +#import <WebCore/NavigationAction.h> #import <WebCore/Page.h> #import <WebCore/PlatformScreen.h> #import <WebCore/PlatformString.h> +#import <WebCore/PopupMenuMac.h> #import <WebCore/ResourceRequest.h> -#import <WebCore/ScrollView.h> +#import <WebCore/SearchPopupMenuMac.h> #import <WebCore/Widget.h> #import <WebCore/WindowFeatures.h> #import <wtf/PassRefPtr.h> @@ -71,7 +76,7 @@ #import <WebCore/GraphicsLayer.h> #endif -#if USE(PLUGIN_HOST_PROCESS) +#if USE(PLUGIN_HOST_PROCESS) && ENABLE(NETSCAPE_PLUGIN_API) #import "NetscapePluginHostManager.h" #endif @@ -104,6 +109,18 @@ using namespace WebCore; - (id)initWithGeolocation:(Geolocation*)geolocation; @end +#if ENABLE(FULLSCREEN_API) + +@interface WebKitFullScreenListener : NSObject <WebKitFullScreenListener> +{ + RefPtr<Element> _element; +} + +- (id)initWithElement:(Element*)element; +@end + +#endif + WebChromeClient::WebChromeClient(WebView *webView) : m_webView(webView) { @@ -183,7 +200,11 @@ void WebChromeClient::focusedNodeChanged(Node*) { } -Page* WebChromeClient::createWindow(Frame* frame, const FrameLoadRequest& request, const WindowFeatures& features) +void WebChromeClient::focusedFrameChanged(Frame*) +{ +} + +Page* WebChromeClient::createWindow(Frame* frame, const FrameLoadRequest& request, const WindowFeatures& features, const NavigationAction&) { NSURLRequest *URLRequest = nil; if (!request.isEmpty()) @@ -244,7 +265,7 @@ Page* WebChromeClient::createWindow(Frame* frame, const FrameLoadRequest& reques newWebView = CallUIDelegate(m_webView, @selector(webView:createWebViewWithRequest:), URLRequest); } -#if USE(PLUGIN_HOST_PROCESS) +#if USE(PLUGIN_HOST_PROCESS) && ENABLE(NETSCAPE_PLUGIN_API) if (newWebView) WebKit::NetscapePluginHostManager::shared().didCreateWindow(); #endif @@ -439,20 +460,32 @@ IntRect WebChromeClient::windowResizerRect() const return enclosingIntRect([m_webView convertRect:rect fromView:nil]); } -void WebChromeClient::repaint(const IntRect& rect, bool contentChanged, bool immediate, bool repaintContentOnly) +void WebChromeClient::invalidateWindow(const IntRect&, bool immediate) +{ + if (immediate) { + [[m_webView window] displayIfNeeded]; + [[m_webView window] flushWindowIfNeeded]; + } +} + +void WebChromeClient::invalidateContentsAndWindow(const IntRect& rect, bool immediate) { if ([m_webView _usesDocumentViews]) return; - - if (contentChanged) - [m_webView setNeedsDisplayInRect:rect]; - + + [m_webView setNeedsDisplayInRect:rect]; + if (immediate) { [[m_webView window] displayIfNeeded]; [[m_webView window] flushWindowIfNeeded]; } } +void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool immediate) +{ + invalidateContentsAndWindow(rect, immediate); +} + void WebChromeClient::scroll(const IntSize&, const IntRect&, const IntRect&) { } @@ -486,23 +519,34 @@ void WebChromeClient::contentsSizeChanged(Frame*, const IntSize&) const { } -void WebChromeClient::scrollRectIntoView(const IntRect& r, const ScrollView* scrollView) const +void WebChromeClient::scrollRectIntoView(const IntRect& r, const ScrollView*) const { - // FIXME: This scrolling behavior should be under the control of the embedding client (rather than something - // we just do ourselves). - + // FIXME: This scrolling behavior should be under the control of the embedding client, + // perhaps in a delegate method, rather than something WebKit does unconditionally. + NSView *coordinateView = [m_webView _usesDocumentViews] + ? [[[m_webView mainFrame] frameView] documentView] : m_webView; NSRect rect = r; for (NSView *view = m_webView; view; view = [view superview]) { if ([view isKindOfClass:[NSClipView class]]) { NSClipView *clipView = (NSClipView *)view; NSView *documentView = [clipView documentView]; - [documentView scrollRectToVisible:[documentView convertRect:rect fromView:m_webView]]; + [documentView scrollRectToVisible:[documentView convertRect:rect fromView:coordinateView]]; } } } // End host window methods. +bool WebChromeClient::shouldMissingPluginMessageBeButton() const +{ + return [[m_webView UIDelegate] respondsToSelector:@selector(webView:didPressMissingPluginButton:)]; +} + +void WebChromeClient::missingPluginButtonClicked(Element* element) const +{ + CallUIDelegate(m_webView, @selector(webView:didPressMissingPluginButton:), kit(element)); +} + void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& result, unsigned modifierFlags) { WebElementDictionary *element = [[WebElementDictionary alloc] initWithHitTestResult:result]; @@ -525,6 +569,7 @@ void WebChromeClient::print(Frame* frame) } #if ENABLE(DATABASE) + void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName) { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -533,20 +578,34 @@ void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& database // FIXME: remove this workaround once shipping Safari has the necessary delegate implemented. if (WKAppVersionCheckLessThan(@"com.apple.Safari", -1, 3.1)) { const unsigned long long defaultQuota = 5 * 1024 * 1024; // 5 megabytes should hopefully be enough to test storage support. - [webOrigin setQuota:defaultQuota]; + [[webOrigin databaseQuotaManager] setQuota:defaultQuota]; } else CallUIDelegate(m_webView, @selector(webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:), kit(frame), webOrigin, (NSString *)databaseName); [webOrigin release]; END_BLOCK_OBJC_EXCEPTIONS; } + #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) + void WebChromeClient::reachedMaxAppCacheSize(int64_t spaceNeeded) { // FIXME: Free some space. } + +void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin* origin) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin]; + CallUIDelegate(m_webView, @selector(webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:), webOrigin); + [webOrigin release]; + + END_BLOCK_OBJC_EXCEPTIONS; +} + #endif void WebChromeClient::populateVisitedLinks() @@ -566,17 +625,14 @@ void WebChromeClient::populateVisitedLinks() } #if ENABLE(DASHBOARD_SUPPORT) + void WebChromeClient::dashboardRegionsChanged() { BEGIN_BLOCK_OBJC_EXCEPTIONS; - - NSMutableDictionary *regions = core([m_webView mainFrame])->dashboardRegionsDictionary(); - [m_webView _addScrollerDashboardRegions:regions]; - - CallUIDelegate(m_webView, @selector(webView:dashboardRegionsChanged:), regions); - + CallUIDelegate(m_webView, @selector(webView:dashboardRegionsChanged:), [m_webView _dashboardRegions]); END_BLOCK_OBJC_EXCEPTIONS; } + #endif FloatRect WebChromeClient::customHighlightRect(Node* node, const AtomicString& type, const FloatRect& lineRect) @@ -589,9 +645,7 @@ FloatRect WebChromeClient::customHighlightRect(Node* node, const AtomicString& t WebHTMLView *webHTMLView = (WebHTMLView *)documentView; id<WebHTMLHighlighter> highlighter = [webHTMLView _highlighterForType:type]; - if ([(NSObject *)highlighter respondsToSelector:@selector(highlightRectForLine:representedNode:)]) - return [highlighter highlightRectForLine:lineRect representedNode:kit(node)]; - return [highlighter highlightRectForLine:lineRect]; + return [highlighter highlightRectForLine:lineRect representedNode:kit(node)]; END_BLOCK_OBJC_EXCEPTIONS; @@ -609,10 +663,7 @@ void WebChromeClient::paintCustomHighlight(Node* node, const AtomicString& type, WebHTMLView *webHTMLView = (WebHTMLView *)documentView; id<WebHTMLHighlighter> highlighter = [webHTMLView _highlighterForType:type]; - if ([(NSObject *)highlighter respondsToSelector:@selector(paintHighlightForBox:onLine:behindText:entireLine:representedNode:)]) - [highlighter paintHighlightForBox:boxRect onLine:lineRect behindText:behindText entireLine:entireLine representedNode:kit(node)]; - else - [highlighter paintHighlightForBox:boxRect onLine:lineRect behindText:behindText entireLine:entireLine]; + [highlighter paintHighlightForBox:boxRect onLine:lineRect behindText:behindText entireLine:entireLine representedNode:kit(node)]; END_BLOCK_OBJC_EXCEPTIONS; } @@ -631,6 +682,19 @@ void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser) END_BLOCK_OBJC_EXCEPTIONS; } +void WebChromeClient::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser) +{ + chooser->iconLoaded(Icon::createIconForFiles(filenames)); +} + +void WebChromeClient::setCursor(const WebCore::Cursor& cursor) +{ + NSCursor *platformCursor = cursor.platformCursor(); + if ([NSCursor currentCursor] == platformCursor) + return; + [platformCursor set]; +} + KeyboardUIMode WebChromeClient::keyboardUIMode() { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -677,11 +741,6 @@ String WebChromeClient::generateReplacementFile(const String& path) return [[m_webView _UIDelegateForwarder] webView:m_webView generateReplacementFile:path]; } -void WebChromeClient::formStateDidChange(const WebCore::Node* node) -{ - CallUIDelegate(m_webView, @selector(webView:formStateDidChangeForNode:), kit(const_cast<WebCore::Node*>(node))); -} - void WebChromeClient::formDidFocus(const WebCore::Node* node) { CallUIDelegate(m_webView, @selector(webView:formDidFocusNode:), kit(const_cast<WebCore::Node*>(node))); @@ -692,6 +751,21 @@ void WebChromeClient::formDidBlur(const WebCore::Node* node) CallUIDelegate(m_webView, @selector(webView:formDidBlurNode:), kit(const_cast<WebCore::Node*>(node))); } +bool WebChromeClient::selectItemWritingDirectionIsNatural() +{ + return true; +} + +PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const +{ + return adoptRef(new PopupMenuMac(client)); +} + +PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const +{ + return adoptRef(new SearchPopupMenuMac(client)); +} + #if USE(ACCELERATED_COMPOSITING) void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer) @@ -752,6 +826,29 @@ void WebChromeClient::exitFullscreenForNode(Node*) #endif +#if ENABLE(FULLSCREEN_API) + +bool WebChromeClient::supportsFullScreenForElement(const Element* element) +{ + return CallUIDelegateReturningBoolean(false, m_webView, @selector(webView:supportsFullScreenForElement:), kit(const_cast<WebCore::Element*>(element))); +} + +void WebChromeClient::enterFullScreenForElement(Element* element) +{ + WebKitFullScreenListener* listener = [[WebKitFullScreenListener alloc] initWithElement:element]; + CallUIDelegate(m_webView, @selector(webView:enterFullScreenForElement:listener:), kit(element), listener); + [listener release]; +} + +void WebChromeClient::exitFullScreenForElement(Element* element) +{ + WebKitFullScreenListener* listener = [[WebKitFullScreenListener alloc] initWithElement:element]; + CallUIDelegate(m_webView, @selector(webView:exitFullScreenForElement:listener:), kit(element), listener); + [listener release]; +} + +#endif + void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation) { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -856,3 +953,44 @@ void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geoloca } @end + +#if ENABLE(FULLSCREEN_API) + +@implementation WebKitFullScreenListener + +- (id)initWithElement:(Element*)element +{ + if (!(self = [super init])) + return nil; + + _element = element; + return self; +} + +- (void)webkitWillEnterFullScreen +{ + if (_element) + _element->document()->webkitWillEnterFullScreenForElement(_element.get()); +} + +- (void)webkitDidEnterFullScreen +{ + if (_element) + _element->document()->webkitDidEnterFullScreenForElement(_element.get()); +} + +- (void)webkitWillExitFullScreen +{ + if (_element) + _element->document()->webkitWillExitFullScreenForElement(_element.get()); +} + +- (void)webkitDidExitFullScreen +{ + if (_element) + _element->document()->webkitDidExitFullScreenForElement(_element.get()); +} + +@end + +#endif diff --git a/WebKit/mac/WebCoreSupport/WebContextMenuClient.h b/WebKit/mac/WebCoreSupport/WebContextMenuClient.h index c3ff4dd..077cd16 100644 --- a/WebKit/mac/WebCoreSupport/WebContextMenuClient.h +++ b/WebKit/mac/WebCoreSupport/WebContextMenuClient.h @@ -43,7 +43,7 @@ public: virtual void searchWithGoogle(const WebCore::Frame*); virtual void lookUpInDictionary(WebCore::Frame*); virtual bool isSpeaking(); - virtual void speak(const WebCore::String&); + virtual void speak(const WTF::String&); virtual void stopSpeaking(); virtual void searchWithSpotlight(); diff --git a/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm b/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm index 639f3c1..f3a85f0 100644 --- a/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm +++ b/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm @@ -43,6 +43,7 @@ #import "WebViewInternal.h" #import <WebCore/ContextMenu.h> #import <WebCore/KURL.h> +#import <WebCore/LocalizedStrings.h> #import <WebCore/RuntimeApplicationChecks.h> #import <WebKit/DOMPrivate.h> @@ -168,75 +169,77 @@ static void fixMenusReceivedFromOldClients(NSMutableArray *newMenuItems, NSMutab if (tag == WebMenuItemTagOther) { // Restore the specific tag for items on which we temporarily set WebMenuItemTagOther to match old behavior. NSString *title = [item title]; - if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagOpenLink]]) + if ([title isEqualToString:contextMenuItemTagOpenLink()]) modernTag = WebMenuItemTagOpenLink; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagIgnoreGrammar]]) + else if ([title isEqualToString:contextMenuItemTagIgnoreGrammar()]) modernTag = WebMenuItemTagIgnoreGrammar; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSpellingMenu]]) + else if ([title isEqualToString:contextMenuItemTagSpellingMenu()]) modernTag = WebMenuItemTagSpellingMenu; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagShowSpellingPanel:true]] - || [title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagShowSpellingPanel:false]]) + else if ([title isEqualToString:contextMenuItemTagShowSpellingPanel(true)] + || [title isEqualToString:contextMenuItemTagShowSpellingPanel(false)]) modernTag = WebMenuItemTagShowSpellingPanel; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagCheckSpelling]]) + else if ([title isEqualToString:contextMenuItemTagCheckSpelling()]) modernTag = WebMenuItemTagCheckSpelling; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagCheckSpellingWhileTyping]]) + else if ([title isEqualToString:contextMenuItemTagCheckSpellingWhileTyping()]) modernTag = WebMenuItemTagCheckSpellingWhileTyping; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagCheckGrammarWithSpelling]]) + else if ([title isEqualToString:contextMenuItemTagCheckGrammarWithSpelling()]) modernTag = WebMenuItemTagCheckGrammarWithSpelling; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagFontMenu]]) + else if ([title isEqualToString:contextMenuItemTagFontMenu()]) modernTag = WebMenuItemTagFontMenu; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagShowFonts]]) + else if ([title isEqualToString:contextMenuItemTagShowFonts()]) modernTag = WebMenuItemTagShowFonts; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagBold]]) + else if ([title isEqualToString:contextMenuItemTagBold()]) modernTag = WebMenuItemTagBold; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagItalic]]) + else if ([title isEqualToString:contextMenuItemTagItalic()]) modernTag = WebMenuItemTagItalic; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagUnderline]]) + else if ([title isEqualToString:contextMenuItemTagUnderline()]) modernTag = WebMenuItemTagUnderline; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagOutline]]) + else if ([title isEqualToString:contextMenuItemTagOutline()]) modernTag = WebMenuItemTagOutline; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagStyles]]) + else if ([title isEqualToString:contextMenuItemTagStyles()]) modernTag = WebMenuItemTagStyles; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagShowColors]]) + else if ([title isEqualToString:contextMenuItemTagShowColors()]) modernTag = WebMenuItemTagShowColors; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSpeechMenu]]) + else if ([title isEqualToString:contextMenuItemTagSpeechMenu()]) modernTag = WebMenuItemTagSpeechMenu; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagStartSpeaking]]) + else if ([title isEqualToString:contextMenuItemTagStartSpeaking()]) modernTag = WebMenuItemTagStartSpeaking; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagStopSpeaking]]) + else if ([title isEqualToString:contextMenuItemTagStopSpeaking()]) modernTag = WebMenuItemTagStopSpeaking; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagWritingDirectionMenu]]) + else if ([title isEqualToString:contextMenuItemTagWritingDirectionMenu()]) modernTag = WebMenuItemTagWritingDirectionMenu; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagDefaultDirection]]) + else if ([title isEqualToString:contextMenuItemTagDefaultDirection()]) modernTag = WebMenuItemTagDefaultDirection; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagLeftToRight]]) + else if ([title isEqualToString:contextMenuItemTagLeftToRight()]) modernTag = WebMenuItemTagLeftToRight; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagRightToLeft]]) + else if ([title isEqualToString:contextMenuItemTagRightToLeft()]) modernTag = WebMenuItemTagRightToLeft; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagCorrectSpellingAutomatically]]) + else if ([title isEqualToString:contextMenuItemTagInspectElement()]) + modernTag = WebMenuItemTagInspectElement; + else if ([title isEqualToString:contextMenuItemTagCorrectSpellingAutomatically()]) modernTag = WebMenuItemTagCorrectSpellingAutomatically; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSubstitutionsMenu]]) + else if ([title isEqualToString:contextMenuItemTagSubstitutionsMenu()]) modernTag = WebMenuItemTagSubstitutionsMenu; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagShowSubstitutions:true]] - || [title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagShowSubstitutions:false]]) + else if ([title isEqualToString:contextMenuItemTagShowSubstitutions(true)] + || [title isEqualToString:contextMenuItemTagShowSubstitutions(false)]) modernTag = WebMenuItemTagShowSubstitutions; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSmartCopyPaste]]) + else if ([title isEqualToString:contextMenuItemTagSmartCopyPaste()]) modernTag = WebMenuItemTagSmartCopyPaste; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSmartQuotes]]) + else if ([title isEqualToString:contextMenuItemTagSmartQuotes()]) modernTag = WebMenuItemTagSmartQuotes; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSmartDashes]]) + else if ([title isEqualToString:contextMenuItemTagSmartDashes()]) modernTag = WebMenuItemTagSmartDashes; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagSmartLinks]]) + else if ([title isEqualToString:contextMenuItemTagSmartLinks()]) modernTag = WebMenuItemTagSmartLinks; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagTextReplacement]]) + else if ([title isEqualToString:contextMenuItemTagTextReplacement()]) modernTag = WebMenuItemTagTextReplacement; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagTransformationsMenu]]) + else if ([title isEqualToString:contextMenuItemTagTransformationsMenu()]) modernTag = WebMenuItemTagTransformationsMenu; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagMakeUpperCase]]) + else if ([title isEqualToString:contextMenuItemTagMakeUpperCase()]) modernTag = WebMenuItemTagMakeUpperCase; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagMakeLowerCase]]) + else if ([title isEqualToString:contextMenuItemTagMakeLowerCase()]) modernTag = WebMenuItemTagMakeLowerCase; - else if ([title isEqualToString:[[WebViewFactory sharedFactory] contextMenuItemTagCapitalize]]) + else if ([title isEqualToString:contextMenuItemTagCapitalize()]) modernTag = WebMenuItemTagCapitalize; else { // We don't expect WebMenuItemTagOther for any items other than the ones we explicitly handle. diff --git a/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.h b/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.h new file mode 100644 index 0000000..8e1c274 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.h @@ -0,0 +1,58 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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. + */ + +#import "WebDeviceOrientationProvider.h" +#import <WebCore/DeviceOrientationClient.h> + +namespace WebCore { +class DeviceOrientationController; +} + +@class WebView; + +// This class is the Mac implementation of DeviceOrientationClient. It is +// passed to the Page constructor by the WebView. It is a simple proxy to +// either the real or mock client which is passed to the WebView. It is +// required because the WebView must pass a client to the Page constructor, +// but the real or mock client can not be specified until after the Page has +// been constructed. +class WebDeviceOrientationClient : public WebCore::DeviceOrientationClient { +public: + WebDeviceOrientationClient(WebView*); + + // DeviceOrientationClient methods + virtual void setController(WebCore::DeviceOrientationController*); + virtual void startUpdating(); + virtual void stopUpdating(); + virtual WebCore::DeviceOrientation* lastOrientation() const; + virtual void deviceOrientationControllerDestroyed(); + +private: + id<WebDeviceOrientationProvider> getProvider() const; + + WebView* m_webView; + WebCore::DeviceOrientationController* m_controller; + mutable id<WebDeviceOrientationProvider> m_provider; +}; diff --git a/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm b/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm new file mode 100644 index 0000000..3a4d5d7 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebDeviceOrientationClient.mm @@ -0,0 +1,76 @@ +/* + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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. + */ + +#import "WebDeviceOrientationClient.h" + +#import "WebDeviceOrientationInternal.h" +#import "WebDeviceOrientationProvider.h" +#import "WebViewInternal.h" +#import <objc/objc-runtime.h> + +using namespace WebCore; + +WebDeviceOrientationClient::WebDeviceOrientationClient(WebView* webView) + : m_webView(webView) + , m_controller(0) +{ +} + +void WebDeviceOrientationClient::setController(DeviceOrientationController* controller) +{ + // This is called by the Page constructor before our WebView has the provider set up. + // MemoryCache the controller for later use. + m_controller = controller; +} + +void WebDeviceOrientationClient::startUpdating() +{ + [getProvider() startUpdating]; +} + +void WebDeviceOrientationClient::stopUpdating() +{ + [getProvider() stopUpdating]; +} + +DeviceOrientation* WebDeviceOrientationClient::lastOrientation() const +{ + return core([getProvider() lastOrientation]); +} + +void WebDeviceOrientationClient::deviceOrientationControllerDestroyed() +{ + delete this; +} + +id<WebDeviceOrientationProvider> WebDeviceOrientationClient::getProvider() const +{ + if (!m_provider) { + m_provider = [m_webView _deviceOrientationProvider]; + if ([m_provider respondsToSelector:@selector(setController:)]) + objc_msgSend(m_provider, @selector(setController:), m_controller); + } + return m_provider; +} diff --git a/WebKit/mac/WebCoreSupport/WebDragClient.h b/WebKit/mac/WebCoreSupport/WebDragClient.h index 234090e..216a2fb 100644 --- a/WebKit/mac/WebCoreSupport/WebDragClient.h +++ b/WebKit/mac/WebCoreSupport/WebDragClient.h @@ -36,7 +36,7 @@ public: virtual void dragControllerDestroyed(); virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint); virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag); - virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL& url, const WebCore::String& label, WebCore::Frame*); + virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL& url, const WTF::String& label, WebCore::Frame*); virtual void declareAndWriteDragImage(NSPasteboard*, DOMElement*, NSURL*, NSString*, WebCore::Frame*); private: WebView* m_webView; diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.h b/WebKit/mac/WebCoreSupport/WebEditorClient.h index d7dfdd7..23cf312 100644 --- a/WebKit/mac/WebCoreSupport/WebEditorClient.h +++ b/WebKit/mac/WebCoreSupport/WebEditorClient.h @@ -27,6 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import <WebCore/Editor.h> #import <WebCore/EditorClient.h> #import <wtf/RetainPtr.h> #import <wtf/Forward.h> @@ -38,7 +39,7 @@ class WebEditorClient : public WebCore::EditorClient { public: WebEditorClient(WebView *); - + virtual ~WebEditorClient(); virtual void pageDestroyed(); virtual bool isGrammarCheckingEnabled(); @@ -57,7 +58,7 @@ public: virtual bool shouldBeginEditing(WebCore::Range*); virtual bool shouldEndEditing(WebCore::Range*); virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction); - virtual bool shouldInsertText(const WebCore::String&, WebCore::Range*, WebCore::EditorInsertAction); + virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction); virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting); virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); @@ -69,9 +70,11 @@ public: virtual void didWriteSelectionToPasteboard(); virtual void didSetSelectionTypesForPasteboard(); - virtual NSString* userVisibleString(NSURL*); + virtual NSString* userVisibleString(NSURL *); + virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource> >&); + virtual void setInsertionPasteboard(NSPasteboard *); #ifdef BUILDING_ON_TIGER - virtual NSArray* pasteboardTypesForSelection(WebCore::Frame*); + virtual NSArray *pasteboardTypesForSelection(WebCore::Frame*); #endif #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) @@ -116,24 +119,33 @@ public: virtual void textWillBeDeletedInTextField(WebCore::Element*); virtual void textDidChangeInTextArea(WebCore::Element*); - virtual void ignoreWordInSpellDocument(const WebCore::String&); - virtual void learnWord(const WebCore::String&); + virtual void ignoreWordInSpellDocument(const WTF::String&); + virtual void learnWord(const WTF::String&); virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength); - virtual WebCore::String getAutoCorrectSuggestionForMisspelledWord(const WebCore::String&); + virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&); virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); virtual void checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, WTF::Vector<WebCore::TextCheckingResult>& results); - virtual void updateSpellingUIWithGrammarString(const WebCore::String&, const WebCore::GrammarDetail&); - virtual void updateSpellingUIWithMisspelledWord(const WebCore::String&); + virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&); + virtual void updateSpellingUIWithMisspelledWord(const WTF::String&); virtual void showSpellingUI(bool show); virtual bool spellingUIIsShowing(); - virtual void getGuessesForWord(const WebCore::String&, WTF::Vector<WebCore::String>& guesses); + virtual void getGuessesForWord(const WTF::String&, WTF::Vector<WTF::String>& guesses); + virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, WebCore::Editor*); + virtual void dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot); + virtual bool isShowingCorrectionPanel(); +#endif private: void registerCommandForUndoOrRedo(PassRefPtr<WebCore::EditCommand>, bool isRedo); WebEditorClient(); - + WebView *m_webView; RetainPtr<WebEditorUndoTarget> m_undoTarget; - bool m_haveUndoRedoOperations; + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + BOOL m_correctionPanelIsShown; +#endif }; diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/WebKit/mac/WebCoreSupport/WebEditorClient.mm index 1e03d88..9efa766 100644 --- a/WebKit/mac/WebCoreSupport/WebEditorClient.mm +++ b/WebKit/mac/WebCoreSupport/WebEditorClient.mm @@ -30,6 +30,7 @@ #import "WebEditorClient.h" #import "DOMCSSStyleDeclarationInternal.h" +#import "DOMDocumentFragmentInternal.h" #import "DOMHTMLElementInternal.h" #import "DOMHTMLInputElementInternal.h" #import "DOMHTMLTextAreaElementInternal.h" @@ -48,8 +49,11 @@ #import "WebKitVersionChecks.h" #import "WebLocalizableStrings.h" #import "WebNSURLExtras.h" +#import "WebResourceInternal.h" #import "WebViewInternal.h" +#import <WebCore/ArchiveResource.h> #import <WebCore/Document.h> +#import <WebCore/DocumentFragment.h> #import <WebCore/EditAction.h> #import <WebCore/EditCommand.h> #import <WebCore/HTMLInputElement.h> @@ -59,20 +63,32 @@ #import <WebCore/LegacyWebArchive.h> #import <WebCore/PlatformKeyboardEvent.h> #import <WebCore/PlatformString.h> +#import <WebCore/UserTypingGestureIndicator.h> #import <WebCore/WebCoreObjCExtras.h> #import <runtime/InitializeThreading.h> #import <wtf/PassRefPtr.h> +#import <wtf/Threading.h> +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#import <AppKit/NSTextChecker.h> +#endif using namespace WebCore; using namespace WTF; using namespace HTMLNames; +@interface NSAttributedString (WebNSAttributedStringDetails) +- (id)_initWithDOMRange:(DOMRange*)range; +- (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources; +@end + static WebViewInsertAction kit(EditorInsertAction coreAction) { return static_cast<WebViewInsertAction>(coreAction); } +static const int InvalidCorrectionPanelTag = 0; + #ifdef BUILDING_ON_TIGER @interface NSSpellChecker (NotYetPublicMethods) - (void)learnWord:(NSString *)word; @@ -94,6 +110,7 @@ static WebViewInsertAction kit(EditorInsertAction coreAction) + (void)initialize { JSC::initializeThreading(); + WTF::initializeMainThreadToProcessMainThread(); #ifndef BUILDING_ON_TIGER WebCoreObjCFinalizeOnMainThread(self); #endif @@ -168,9 +185,19 @@ WebEditorClient::WebEditorClient(WebView *webView) : m_webView(webView) , m_undoTarget([[[WebEditorUndoTarget alloc] init] autorelease]) , m_haveUndoRedoOperations(false) +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + , m_correctionPanelIsShown(false) +#endif { } +WebEditorClient::~WebEditorClient() +{ +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + dismissCorrectionPanel(WebCore::CorrectionWasNotRejected); +#endif +} + bool WebEditorClient::isContinuousSpellCheckingEnabled() { return [m_webView isContinuousSpellCheckingEnabled]; @@ -305,13 +332,54 @@ void WebEditorClient::didSetSelectionTypesForPasteboard() [[m_webView _editingDelegateForwarder] webView:m_webView didSetSelectionTypesForPasteboard:[NSPasteboard generalPasteboard]]; } -NSString* WebEditorClient::userVisibleString(NSURL *URL) +NSString *WebEditorClient::userVisibleString(NSURL *URL) { return [URL _web_userVisibleString]; } +static NSArray *createExcludedElementsForAttributedStringConversion() +{ + NSArray *elements = [[NSArray alloc] initWithObjects: + // Omit style since we want style to be inline so the fragment can be easily inserted. + @"style", + // Omit xml so the result is not XHTML. + @"xml", + // Omit tags that will get stripped when converted to a fragment anyway. + @"doctype", @"html", @"head", @"body", + // Omit deprecated tags. + @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u", + // Omit object so no file attachments are part of the fragment. + @"object", nil]; + CFRetain(elements); + return elements; +} + +DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource> >& resources) +{ + static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion(); + + NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: excludedElements, NSExcludedElementsDocumentAttribute, + nil, @"WebResourceHandler", nil]; + + NSArray *subResources; + DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length]) + document:[[m_webView mainFrame] DOMDocument] + documentAttributes:dictionary + subresources:&subResources]; + for (WebResource* resource in subResources) + resources.append([resource _coreResource]); + + [dictionary release]; + return core(fragment); +} + +void WebEditorClient::setInsertionPasteboard(NSPasteboard *pasteboard) +{ + [m_webView _setInsertionPasteboard:pasteboard]; +} + #ifdef BUILDING_ON_TIGER -NSArray* WebEditorClient::pasteboardTypesForSelection(Frame* selectedFrame) +NSArray *WebEditorClient::pasteboardTypesForSelection(Frame* selectedFrame) { WebFrame* frame = kit(selectedFrame); return [[[frame frameView] documentView] pasteboardTypesForSelection]; @@ -555,12 +623,15 @@ void WebEditorClient::textFieldDidEndEditing(Element* element) FormDelegateLog(inputElement); CallFormDelegate(m_webView, @selector(textFieldDidEndEditing:inFrame:), inputElement, kit(element->document()->frame())); } - + void WebEditorClient::textDidChangeInTextField(Element* element) { if (!element->hasTagName(inputTag)) return; + if (!UserTypingGestureIndicator::processingUserTypingGesture() || UserTypingGestureIndicator::focusedElementAtGestureStart() != element) + return; + DOMHTMLInputElement* inputElement = kit(static_cast<HTMLInputElement*>(element)); FormDelegateLog(inputElement); CallFormDelegate(m_webView, @selector(textDidChangeInTextField:inFrame:), inputElement, kit(element->document()->frame())); @@ -572,7 +643,7 @@ static SEL selectorForKeyEvent(KeyboardEvent* event) // Eventually, we should move all of the auto-fill code down to WebKit and remove the need for this function by // not relying on the selector in the new implementation. // The key identifiers are from <http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set> - String key = event->keyIdentifier(); + const String& key = event->keyIdentifier(); if (key == "Up") return @selector(moveUp:); if (key == "Down") @@ -784,6 +855,48 @@ void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammar #endif } +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, Editor* editor) { + dismissCorrectionPanel(WebCore::CorrectionWasNotRejected); + + NSRect boundingBoxAsNSRect = boundingBoxOfReplacedString; + NSRect webViewFrame = m_webView.frame; + boundingBoxAsNSRect.origin.y = webViewFrame.size.height-NSMaxY(boundingBoxAsNSRect); + + // Need to explicitly use these local NSString objects, because the C++ references may be invalidated by the time the block below is executed. + NSString *replacedStringAsNSString = replacedString; + NSString *replacementStringAsNSString = replacementString; + + m_correctionPanelIsShown = YES; + NSCorrectionBubbleType bubbleType = panelType == WebCore::CorrectionPanelInfo::PanelTypeCorrection ? NSCorrectionBubbleTypeCorrection : NSCorrectionBubbleTypeReversion; + [[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:nil forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) { + if (!acceptedString && bubbleType == NSCorrectionBubbleTypeCorrection) { + [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; + editor->handleRejectedCorrection(); + } else if (acceptedString && bubbleType == NSCorrectionBubbleTypeReversion) { + [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; + editor->handleRejectedCorrection(); + } + }]; +} + +void WebEditorClient::dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot correctionWasRejectedOrNot) +{ + if (isShowingCorrectionPanel()) { + if (correctionWasRejectedOrNot == CorrectionWasRejected) + [[NSSpellChecker sharedSpellChecker] cancelCorrectionBubbleForView:m_webView]; + else + [[NSSpellChecker sharedSpellChecker] dismissCorrectionBubbleForView:m_webView]; + m_correctionPanelIsShown = NO; + } +} + +bool WebEditorClient::isShowingCorrectionPanel() +{ + return m_correctionPanelIsShown; +} +#endif + void WebEditorClient::updateSpellingUIWithMisspelledWord(const String& misspelledWord) { [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord]; @@ -816,6 +929,10 @@ void WebEditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& } } +void WebEditorClient::willSetInputMethodState() +{ +} + void WebEditorClient::setInputMethodState(bool) { } diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h index 2774783..2b3b2cc 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h @@ -42,7 +42,7 @@ namespace WebCore { class AuthenticationChallenge; class CachedFrame; class HistoryItem; - class String; + class ProtectionSpace; class ResourceLoader; class ResourceRequest; } @@ -79,6 +79,9 @@ private: virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); +#if USE(PROTECTION_SPACE_AUTH_CALLBACK) + virtual bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&); +#endif virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); @@ -98,7 +101,8 @@ private: virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); - virtual void dispatchDidReceiveTitle(const WebCore::String& title); + virtual void dispatchDidReceiveTitle(const WTF::String& title); + virtual void dispatchDidChangeIcons(); virtual void dispatchDidCommitLoad(); virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); virtual void dispatchDidFailLoad(const WebCore::ResourceError&); @@ -107,26 +111,26 @@ private: virtual void dispatchDidFirstLayout(); virtual void dispatchDidFirstVisuallyNonEmptyLayout(); - virtual WebCore::Frame* dispatchCreatePage(); + virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&); virtual void dispatchShow(); virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, - const WebCore::String& MIMEType, const WebCore::ResourceRequest&); + const WTF::String& MIMEType, const WebCore::ResourceRequest&); virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, - const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WebCore::String& frameName); + const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WTF::String& frameName); virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>); virtual void cancelPolicyCheck(); virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); + virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) { } virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); virtual void revertToProvisionalState(WebCore::DocumentLoader*); virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); - virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&); virtual void willChangeEstimatedProgress(); virtual void didChangeEstimatedProgress(); @@ -165,16 +169,19 @@ private: virtual bool shouldFallBack(const WebCore::ResourceError&); - virtual WebCore::String userAgent(const WebCore::KURL&); + virtual WTF::String userAgent(const WebCore::KURL&); virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); virtual void transitionToCommittedForNewPage(); + virtual void dispatchDidBecomeFrameset(bool); + virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; - virtual bool canShowMIMEType(const WebCore::String& MIMEType) const; - virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const; - virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const; + virtual bool canShowMIMEType(const WTF::String& MIMEType) const; + virtual bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const; + virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const; + virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const; virtual void frameLoadCompleted(); virtual void saveViewStateToItem(WebCore::HistoryItem*); @@ -184,19 +191,28 @@ private: virtual void prepareForDataSourceReplacement(); virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); - virtual void setTitle(const WebCore::String& title, const WebCore::KURL&); + virtual void setTitle(const WTF::String& title, const WebCore::KURL&); - virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, - const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); - virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WebCore::String>&, - const Vector<WebCore::String>&, const WebCore::String&, bool); + virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement*, + const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); + virtual void didTransferChildFrameToNewDocument(WebCore::Page* oldPage); + virtual void transferLoadingResourceFromPage(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&, WebCore::Page* oldPage); + virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WTF::String>&, + const Vector<WTF::String>&, const WTF::String&, bool); virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, - const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues); + const Vector<WTF::String>& paramNames, const Vector<WTF::String>& paramValues); - virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); - virtual WebCore::String overrideMediaType() const; +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) + virtual PassRefPtr<WebCore::Widget> createMediaPlayerProxyPlugin(const WebCore::IntSize&, WebCore::HTMLMediaElement*, const WebCore::KURL&, + const Vector<WTF::String>&, const Vector<WTF::String>&, const WTF::String&); + virtual void hideMediaPlayerProxyPlugin(WebCore::Widget*); + virtual void showMediaPlayerProxyPlugin(WebCore::Widget*); +#endif + + virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WTF::String& mimeType); + virtual WTF::String overrideMediaType() const; virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); virtual void documentElementAvailable(); @@ -204,7 +220,7 @@ private: virtual void registerForIconNotification(bool listen); -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) virtual jobject javaApplet(NSView*); #endif @@ -216,6 +232,8 @@ private: virtual bool canCachePage() const; + virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext(); + RetainPtr<WebFrame> m_webFrame; RetainPtr<WebFramePolicyListener> m_policyListener; diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm index eaec807..5968084 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm @@ -47,20 +47,20 @@ #import "WebFormDelegate.h" #import "WebFrameInternal.h" #import "WebFrameLoadDelegate.h" +#import "WebFrameNetworkingContext.h" #import "WebFrameViewInternal.h" #import "WebHTMLRepresentationPrivate.h" #import "WebHTMLViewInternal.h" -#import "WebHistoryItemInternal.h" #import "WebHistoryInternal.h" +#import "WebHistoryItemInternal.h" #import "WebIconDatabaseInternal.h" #import "WebKitErrorsPrivate.h" #import "WebKitLogging.h" #import "WebKitNSStringExtras.h" -#import "WebNavigationData.h" #import "WebNSURLExtras.h" -#import "WebNetscapePluginView.h" +#import "WebNavigationData.h" #import "WebNetscapePluginPackage.h" -#import "WebNullPluginView.h" +#import "WebNetscapePluginView.h" #import "WebPanelAuthenticationHandler.h" #import "WebPluginController.h" #import "WebPluginPackage.h" @@ -74,7 +74,6 @@ #import "WebUIDelegate.h" #import "WebUIDelegatePrivate.h" #import "WebViewInternal.h" -#import <WebKitSystemInterface.h> #import <WebCore/AuthenticationMac.h> #import <WebCore/BlockExceptions.h> #import <WebCore/CachedFrame.h> @@ -86,15 +85,17 @@ #import <WebCore/FormState.h> #import <WebCore/Frame.h> #import <WebCore/FrameLoader.h> +#import <WebCore/FrameLoaderStateMachine.h> #import <WebCore/FrameLoaderTypes.h> #import <WebCore/FrameTree.h> #import <WebCore/FrameView.h> #import <WebCore/HTMLAppletElement.h> -#import <WebCore/HTMLHeadElement.h> #import <WebCore/HTMLFormElement.h> #import <WebCore/HTMLFrameElement.h> #import <WebCore/HTMLFrameOwnerElement.h> +#import <WebCore/HTMLHeadElement.h> #import <WebCore/HTMLNames.h> +#import <WebCore/HTMLParserIdioms.h> #import <WebCore/HTMLPlugInElement.h> #import <WebCore/HistoryItem.h> #import <WebCore/HitTestResult.h> @@ -104,26 +105,31 @@ #import <WebCore/MouseEvent.h> #import <WebCore/Page.h> #import <WebCore/PlatformString.h> -#import <WebCore/PluginWidget.h> +#import <WebCore/PluginViewBase.h> #import <WebCore/ResourceError.h> #import <WebCore/ResourceHandle.h> #import <WebCore/ResourceLoader.h> #import <WebCore/ResourceRequest.h> #import <WebCore/ScriptController.h> -#import <WebCore/ScriptString.h> #import <WebCore/SharedBuffer.h> #import <WebCore/WebCoreObjCExtras.h> #import <WebCore/Widget.h> #import <WebKit/DOMElement.h> #import <WebKit/DOMHTMLFormElement.h> +#import <WebKitSystemInterface.h> #import <runtime/InitializeThreading.h> #import <wtf/PassRefPtr.h> +#import <wtf/Threading.h> -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) +#import <WebCore/HTMLMediaElement.h> +#endif + +#if ENABLE(JAVA_BRIDGE) #import "WebJavaPlugIn.h" #endif -#if USE(PLUGIN_HOST_PROCESS) +#if USE(PLUGIN_HOST_PROCESS) && ENABLE(NETSCAPE_PLUGIN_API) #import "NetscapePluginHostManager.h" #import "WebHostedNetscapePluginView.h" #endif @@ -132,7 +138,7 @@ using namespace WebCore; using namespace HTMLNames; using namespace std; -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) @interface NSView (WebJavaPluginDetails) - (jobject)pollForAppletInWindow:(NSWindow *)window; @end @@ -237,8 +243,6 @@ bool WebFrameLoaderClient::hasHTMLView() const void WebFrameLoaderClient::forceLayout() { NSView <WebDocumentView> *view = [m_webFrame->_private->webFrameView documentView]; - if ([view isKindOfClass:[WebHTMLView class]]) - [(WebHTMLView *)view setNeedsToApplyStyles:YES]; [view setNeedsLayout:YES]; [view layout]; } @@ -349,10 +353,6 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader return true; } -void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString) -{ -} - void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) { WebView *webView = getWebView(m_webFrame.get()); @@ -418,6 +418,27 @@ void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoa [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:webChallenge window:window]; } +#if USE(PROTECTION_SPACE_AUTH_CALLBACK) +bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader* loader, unsigned long identifier, const ProtectionSpace& protectionSpace) +{ + WebView *webView = getWebView(m_webFrame.get()); + WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView); + + NSURLProtectionSpace *webProtectionSpace = mac(protectionSpace); + + if (implementations->canAuthenticateAgainstProtectionSpaceFunc) { + if (id resource = [webView _objectForIdentifier:identifier]) { + return CallResourceLoadDelegateReturningBoolean(NO, implementations->canAuthenticateAgainstProtectionSpaceFunc, webView, @selector(webView:resource:canAuthenticateAgainstProtectionSpace:forDataSource:), resource, webProtectionSpace, dataSource(loader)); + } + } + + // If our resource load delegate doesn't handle the question, then only send authentication + // challenges for pre-10.6 protection spaces. This is the same as the default implementation + // in CFNetwork. + return (protectionSpace.authenticationScheme() < ProtectionSpaceAuthenticationSchemeClientCertificateRequested); +} +#endif + void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge&challenge) { WebView *webView = getWebView(m_webFrame.get()); @@ -598,6 +619,11 @@ void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) CallFrameLoadDelegate(implementations->didReceiveTitleForFrameFunc, webView, @selector(webView:didReceiveTitle:forFrame:), (NSString *)title, m_webFrame.get()); } +void WebFrameLoaderClient::dispatchDidChangeIcons() +{ + // FIXME: Implement this to allow container to update favicon. +} + void WebFrameLoaderClient::dispatchDidCommitLoad() { // Tell the client we've committed this URL. @@ -671,7 +697,7 @@ void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() CallFrameLoadDelegate(implementations->didFirstVisuallyNonEmptyLayoutInFrameFunc, webView, @selector(webView:didFirstVisuallyNonEmptyLayoutInFrame:), m_webFrame.get()); } -Frame* WebFrameLoaderClient::dispatchCreatePage() +Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction&) { WebView *currentWebView = getWebView(m_webFrame.get()); NSDictionary *features = [[NSDictionary alloc] init]; @@ -680,7 +706,7 @@ Frame* WebFrameLoaderClient::dispatchCreatePage() windowFeatures:features]; [features release]; -#if USE(PLUGIN_HOST_PROCESS) +#if USE(PLUGIN_HOST_PROCESS) && ENABLE(NETSCAPE_PLUGIN_API) if (newWebView) WebKit::NetscapePluginHostManager::shared().didCreateWindow(); #endif @@ -993,6 +1019,11 @@ bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const return [getWebView(m_webFrame.get()) _canShowMIMEType:MIMEType]; } +bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const +{ + return [WebView canShowMIMETypeAsHTML:MIMEType]; +} + bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const { return [WebView _representationExistsForURLScheme:URLScheme]; @@ -1155,7 +1186,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() if (usesDocumentViews) { // FIXME (Viewless): I assume we want the equivalent of this optimization for viewless mode too. bool willProduceHTMLView = [m_webFrame->_private->webFrameView _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class]; - bool canSkipCreation = core(m_webFrame.get())->loader()->committingFirstRealLoad() && willProduceHTMLView; + bool canSkipCreation = core(m_webFrame.get())->loader()->stateMachine()->committingFirstRealLoad() && willProduceHTMLView; if (canSkipCreation) { [[m_webFrame->_private->webFrameView documentView] setDataSource:dataSource]; return; @@ -1222,6 +1253,10 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() } } +void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool) +{ +} + RetainPtr<WebFramePolicyListener> WebFrameLoaderClient::setUpPolicyListener(FramePolicyFunction function) { // FIXME: <rdar://5634381> We need to support multiple active policy listeners. @@ -1352,6 +1387,20 @@ PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const Strin return 0; } +void WebFrameLoaderClient::didTransferChildFrameToNewDocument(Page* oldPage) +{ +} + +void WebFrameLoaderClient::transferLoadingResourceFromPage(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, Page* oldPage) +{ + ASSERT(oldPage != core(m_webFrame.get())->page()); + ASSERT(![getWebView(m_webFrame.get()) _objectForIdentifier:identifier]); + + assignIdentifierToInitialRequest(identifier, loader, request); + + [kit(oldPage) _removeObjectForIdentifier:identifier]; +} + ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeType) { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -1475,6 +1524,20 @@ static NSView *pluginView(WebFrame *frame, WebPluginPackage *pluginPackage, return view; } +class PluginWidget : public PluginViewBase { +public: + PluginWidget(NSView *view = 0) + : PluginViewBase(view) + { + } + +private: + virtual void invalidateRect(const IntRect& rect) + { + [platformWidget() setNeedsDisplayInRect:rect]; + } +}; + #if ENABLE(NETSCAPE_PLUGIN_API) class NetscapePluginWidget : public PluginWidget { @@ -1484,6 +1547,13 @@ public: { } +#if USE(ACCELERATED_COMPOSITING) + virtual PlatformLayer* platformLayer() const + { + return [(WebBaseNetscapePluginView *)platformWidget() pluginLayer]; + } +#endif + virtual void handleEvent(Event* event) { Frame* frame = Frame::frameForWidget(this); @@ -1493,18 +1563,22 @@ public: NSEvent* currentNSEvent = frame->eventHandler()->currentNSEvent(); if (event->type() == eventNames().mousemoveEvent) [(WebBaseNetscapePluginView *)platformWidget() handleMouseMoved:currentNSEvent]; + else if (event->type() == eventNames().mouseoverEvent) + [(WebBaseNetscapePluginView *)platformWidget() handleMouseEntered:currentNSEvent]; + else if (event->type() == eventNames().mouseoutEvent) + [(WebBaseNetscapePluginView *)platformWidget() handleMouseExited:currentNSEvent]; } }; -#endif // ENABLE(NETSCAPE_PLUGIN_API) - #if USE(PLUGIN_HOST_PROCESS) #define NETSCAPE_PLUGIN_VIEW WebHostedNetscapePluginView #else #define NETSCAPE_PLUGIN_VIEW WebNetscapePluginView #endif +#endif // ENABLE(NETSCAPE_PLUGIN_API) + PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { @@ -1516,16 +1590,32 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP WebView *webView = getWebView(m_webFrame.get()); SEL selector = @selector(webView:plugInViewWithArguments:); - NSURL *URL = url; + Document* document = core(m_webFrame.get())->document(); + NSURL *baseURL = document->baseURL(); + NSURL *pluginURL = url; + + // <rdar://problem/8366089>: AppleConnect has a bug where it does not + // understand the parameter names specified in the <object> element that + // embeds its plug-in. This site-specific hack works around the issue by + // converting the parameter names to lowercase before passing them to the + // plug-in. + Frame* frame = core(m_webFrame.get()); + NSMutableArray *attributeKeys = kit(paramNames); + if (frame && frame->settings()->needsSiteSpecificQuirks() && equalIgnoringCase(mimeType, "application/x-snkp")) { + for (NSUInteger i = 0; i < [attributeKeys count]; ++i) + [attributeKeys replaceObjectAtIndex:i withObject:[[attributeKeys objectAtIndex:i] lowercaseString]]; + } + if ([[webView UIDelegate] respondsToSelector:selector]) { - NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithObjects:kit(paramValues) forKeys:kit(paramNames)]; + NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithObjects:kit(paramValues) forKeys:attributeKeys]; NSDictionary *arguments = [[NSDictionary alloc] initWithObjectsAndKeys: attributes, WebPlugInAttributesKey, [NSNumber numberWithInt:loadManually ? WebPlugInModeFull : WebPlugInModeEmbed], WebPlugInModeKey, [NSNumber numberWithBool:!loadManually], WebPlugInShouldLoadMainResourceKey, kit(element), WebPlugInContainingElementKey, - URL, WebPlugInBaseURLKey, // URL might be nil, so add it last + // FIXME: We should be passing base URL, see <https://bugs.webkit.org/show_bug.cgi?id=35215>. + pluginURL, WebPlugInBaseURLKey, // pluginURL might be nil, so add it last nil]; NSView *view = CallUIDelegate(webView, selector, arguments); @@ -1547,14 +1637,8 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP pluginPackage = [webView _pluginForMIMEType:mimeType]; } - NSString *extension = [[URL path] pathExtension]; -#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) - // don't allow proxy plug-in selection by file extension - if (element->hasTagName(videoTag) || element->hasTagName(audioTag)) - extension = @""; -#endif - - if (!pluginPackage && [extension length] != 0) { + NSString *extension = [[pluginURL path] pathExtension]; + if (!pluginPackage && [extension length] && ![MIMEType length]) { pluginPackage = [webView _pluginForExtension:extension]; if (pluginPackage) { NSString *newMIMEType = [pluginPackage MIMETypeForExtension:extension]; @@ -1565,21 +1649,19 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP NSView *view = nil; - Document* document = core(m_webFrame.get())->document(); - NSURL *baseURL = document->baseURL(); if (pluginPackage) { if ([pluginPackage isKindOfClass:[WebPluginPackage class]]) - view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, kit(paramNames), kit(paramValues), baseURL, kit(element), loadManually); + view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, attributeKeys, kit(paramValues), baseURL, kit(element), loadManually); #if ENABLE(NETSCAPE_PLUGIN_API) else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) { WebBaseNetscapePluginView *pluginView = [[[NETSCAPE_PLUGIN_VIEW alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) pluginPackage:(WebNetscapePluginPackage *)pluginPackage - URL:URL + URL:pluginURL baseURL:baseURL MIMEType:MIMEType - attributeKeys:kit(paramNames) + attributeKeys:attributeKeys attributeValues:kit(paramValues) loadManually:loadManually element:element] autorelease]; @@ -1592,17 +1674,23 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP if (!errorCode && !view) errorCode = WebKitErrorCannotLoadPlugIn; + + if (errorCode && m_webFrame) { + WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView); + if (implementations->plugInFailedWithErrorFunc) { + KURL pluginPageURL = document->completeURL(stripLeadingAndTrailingHTMLSpaces(parameterValue(paramNames, paramValues, "pluginspage"))); + if (!pluginPageURL.protocolInHTTPFamily()) + pluginPageURL = KURL(); + NSString *pluginName = pluginPackage ? (NSString *)[pluginPackage pluginInfo].name : nil; + + NSError *error = [[NSError alloc] _initWithPluginErrorCode:errorCode + contentURL:pluginURL pluginPageURL:pluginPageURL pluginName:pluginName MIMEType:MIMEType]; + CallResourceLoadDelegate(implementations->plugInFailedWithErrorFunc, [m_webFrame.get() webView], + @selector(webView:plugInFailedWithError:dataSource:), error, [m_webFrame.get() _dataSource]); + [error release]; + } - if (errorCode) { - KURL pluginPageURL = document->completeURL(deprecatedParseURL(parameterValue(paramNames, paramValues, "pluginspage"))); - if (!pluginPageURL.protocolInHTTPFamily()) - pluginPageURL = KURL(); - NSError *error = [[NSError alloc] _initWithPluginErrorCode:errorCode - contentURL:URL pluginPageURL:pluginPageURL pluginName:[pluginPackage name] MIMEType:MIMEType]; - WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) - error:error DOMElement:kit(element)] autorelease]; - view = nullView; - [error release]; + return 0; } ASSERT(view); @@ -1639,7 +1727,7 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& size, HTMLAppletElement* element, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) { -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) BEGIN_BLOCK_OBJC_EXCEPTIONS; NSView *view = nil; @@ -1664,6 +1752,8 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s [values addObject:[NSString stringWithFormat:@"%d", size.height()]]; } view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, names, values, baseURL, kit(element), NO); + if (view) + return adoptRef(new PluginWidget(view)); } #if ENABLE(NETSCAPE_PLUGIN_API) else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) { @@ -1676,6 +1766,8 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s attributeValues:kit(paramValues) loadManually:NO element:element] autorelease]; + if (view) + return adoptRef(new NetscapePluginWidget(static_cast<WebBaseNetscapePluginView *>(view))); } else { ASSERT_NOT_REACHED(); } @@ -1683,27 +1775,98 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s } if (!view) { - NSError *error = [[NSError alloc] _initWithPluginErrorCode:WebKitErrorJavaUnavailable - contentURL:nil - pluginPageURL:nil - pluginName:[pluginPackage name] - MIMEType:MIMEType]; - view = [[[WebNullPluginView alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) + WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(getWebView(m_webFrame.get())); + if (implementations->plugInFailedWithErrorFunc) { + NSString *pluginName = pluginPackage ? (NSString *)[pluginPackage pluginInfo].name : nil; + NSError *error = [[NSError alloc] _initWithPluginErrorCode:WebKitErrorJavaUnavailable contentURL:nil pluginPageURL:nil pluginName:pluginName MIMEType:MIMEType]; + CallResourceLoadDelegate(implementations->plugInFailedWithErrorFunc, [m_webFrame.get() webView], + @selector(webView:plugInFailedWithError:dataSource:), error, [m_webFrame.get() _dataSource]); + [error release]; + } + } + + END_BLOCK_OBJC_EXCEPTIONS; +#endif // ENABLE(JAVA_BRIDGE) + return 0; +} + +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) +PassRefPtr<Widget> WebFrameLoaderClient::createMediaPlayerProxyPlugin(const IntSize& size, HTMLMediaElement* element, const KURL& url, + const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + ASSERT(paramNames.size() == paramValues.size()); + ASSERT(mimeType); + + int errorCode = 0; + WebView *webView = getWebView(m_webFrame.get()); + NSURL *URL = url; + + SEL selector = @selector(webView:plugInViewWithArguments:); + + if ([[webView UIDelegate] respondsToSelector:selector]) { + NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithObjects:kit(paramValues) forKeys:kit(paramNames)]; + NSDictionary *arguments = [[NSDictionary alloc] initWithObjectsAndKeys: + attributes, WebPlugInAttributesKey, + [NSNumber numberWithInt:WebPlugInModeEmbed], WebPlugInModeKey, + [NSNumber numberWithBool:YES], WebPlugInShouldLoadMainResourceKey, + kit(element), WebPlugInContainingElementKey, + URL, WebPlugInBaseURLKey, // URL might be nil, so add it last + nil]; + + NSView *view = CallUIDelegate(webView, selector, arguments); + + [attributes release]; + [arguments release]; + + if (view) + return adoptRef(new PluginWidget(view)); + } + + WebBasePluginPackage *pluginPackage = [webView _videoProxyPluginForMIMEType:mimeType]; + Document* document = core(m_webFrame.get())->document(); + NSURL *baseURL = document->baseURL(); + NSView *view = nil; + + if (pluginPackage) { + if ([pluginPackage isKindOfClass:[WebPluginPackage class]]) + view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, kit(paramNames), kit(paramValues), baseURL, kit(element), false); + } else + errorCode = WebKitErrorCannotFindPlugIn; + + if (!errorCode && !view) + errorCode = WebKitErrorCannotLoadPlugIn; + + if (errorCode) { + NSError *error = [[NSError alloc] _initWithPluginErrorCode:errorCode + contentURL:URL pluginPageURL:nil pluginName:[pluginPackage name] MIMEType:mimeType]; + WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) error:error DOMElement:kit(element)] autorelease]; + view = nullView; [error release]; } - + ASSERT(view); return adoptRef(new PluginWidget(view)); END_BLOCK_OBJC_EXCEPTIONS; - - return adoptRef(new PluginWidget); -#else + return 0; -#endif // ENABLE(MAC_JAVA_BRIDGE) } +void WebFrameLoaderClient::hideMediaPlayerProxyPlugin(Widget* widget) +{ + [WebPluginController pluginViewHidden:widget->platformWidget()]; +} + +void WebFrameLoaderClient::showMediaPlayerProxyPlugin(Widget* widget) +{ + [WebPluginController addPlugInView:widget->platformWidget()]; +} + +#endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) + String WebFrameLoaderClient::overrideMediaType() const { NSString* overrideType = [getWebView(m_webFrame.get()) mediaStyle]; @@ -1760,7 +1923,12 @@ void WebFrameLoaderClient::didPerformFirstNavigation() const [preferences setCacheModel:WebCacheModelDocumentBrowser]; } -#if ENABLE(MAC_JAVA_BRIDGE) +PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext() +{ + return WebFrameNetworkingContext::create(core(m_webFrame.get())); +} + +#if ENABLE(JAVA_BRIDGE) jobject WebFrameLoaderClient::javaApplet(NSView* view) { if ([view respondsToSelector:@selector(webPlugInGetApplet)]) @@ -1779,6 +1947,7 @@ jobject WebFrameLoaderClient::javaApplet(NSView* view) + (void)initialize { JSC::initializeThreading(); + WTF::initializeMainThreadToProcessMainThread(); #ifndef BUILDING_ON_TIGER WebCoreObjCFinalizeOnMainThread(self); #endif diff --git a/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h b/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h new file mode 100644 index 0000000..de89024 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#import <WebCore/FrameNetworkingContext.h> + +class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext { +public: + static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame* frame) + { + return adoptRef(new WebFrameNetworkingContext(frame)); + } + +private: + WebFrameNetworkingContext(WebCore::Frame* frame) + : WebCore::FrameNetworkingContext(frame) + { + } + + virtual bool needsSiteSpecificQuirks() const; + virtual bool localFileContentSniffingEnabled() const; + virtual WebCore::SchedulePairHashSet* scheduledRunLoopPairs() const; + virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const; +}; diff --git a/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm b/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm new file mode 100644 index 0000000..98b8ce1 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm @@ -0,0 +1,46 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#import "WebFrameNetworkingContext.h" + +#import <WebCore/Page.h> +#import <WebCore/ResourceError.h> +#import <WebCore/Settings.h> + +using namespace WebCore; + +bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const +{ + return frame() && frame()->settings() && frame()->settings()->needsSiteSpecificQuirks(); +} + +bool WebFrameNetworkingContext::localFileContentSniffingEnabled() const +{ + return frame() && frame()->settings() && frame()->settings()->localFileContentSniffingEnabled(); +} + +SchedulePairHashSet* WebFrameNetworkingContext::scheduledRunLoopPairs() const +{ + return frame() && frame()->page() ? frame()->page()->scheduledRunLoopPairs() : 0; +} + +ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const +{ + return frame()->loader()->blockedError(request); +} diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationControllerClient.h b/WebKit/mac/WebCoreSupport/WebGeolocationClient.h index 3965210..5ea3369 100644 --- a/WebKit/mac/WebCoreSupport/WebGeolocationControllerClient.h +++ b/WebKit/mac/WebCoreSupport/WebGeolocationClient.h @@ -23,7 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import <WebCore/GeolocationControllerClient.h> +#import <WebCore/GeolocationClient.h> namespace WebCore { class GeolocationPosition; @@ -31,14 +31,15 @@ namespace WebCore { @class WebView; -class WebGeolocationControllerClient : public WebCore::GeolocationControllerClient { +class WebGeolocationClient : public WebCore::GeolocationClient { public: - WebGeolocationControllerClient(WebView *); + WebGeolocationClient(WebView *); WebView *webView() { return m_webView; } void geolocationDestroyed(); void startUpdating(); void stopUpdating(); + void setEnableHighAccuracy(bool) { } WebCore::GeolocationPosition* lastPosition(); diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationControllerClient.mm b/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm index 98ffc72..a635b44 100644 --- a/WebKit/mac/WebCoreSupport/WebGeolocationControllerClient.mm +++ b/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm @@ -23,34 +23,34 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import "WebGeolocationControllerClient.h" +#import "WebGeolocationClient.h" #import "WebGeolocationPositionInternal.h" #import "WebViewInternal.h" using namespace WebCore; -WebGeolocationControllerClient::WebGeolocationControllerClient(WebView *webView) +WebGeolocationClient::WebGeolocationClient(WebView *webView) : m_webView(webView) { } -void WebGeolocationControllerClient::geolocationDestroyed() +void WebGeolocationClient::geolocationDestroyed() { delete this; } -void WebGeolocationControllerClient::startUpdating() +void WebGeolocationClient::startUpdating() { [[m_webView _geolocationProvider] registerWebView:m_webView]; } -void WebGeolocationControllerClient::stopUpdating() +void WebGeolocationClient::stopUpdating() { [[m_webView _geolocationProvider] unregisterWebView:m_webView]; } -GeolocationPosition* WebGeolocationControllerClient::lastPosition() +GeolocationPosition* WebGeolocationClient::lastPosition() { #if ENABLE(CLIENT_BASED_GEOLOCATION) return core([[m_webView _geolocationProvider] lastPosition]); diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm b/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm deleted file mode 100644 index 32e8d0d..0000000 --- a/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2009 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 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. - */ - -#import "WebGeolocationMockPrivate.h" - -#import <WebCore/GeolocationServiceMock.h> -#import <WebCore/Geoposition.h> -#import <WebCore/PositionError.h> -#import <wtf/CurrentTime.h> - - -using namespace WebCore; -using namespace WTF; - -@implementation WebGeolocationMock - -+ (void)setPosition:(double)latitude:(double)longitude:(double)accuracy -{ - RefPtr<Coordinates> coordinates = Coordinates::create(latitude, - longitude, - false, 0.0, // altitude - accuracy, - false, 0.0, // altitudeAccuracy - false, 0.0, // heading - false, 0.0); // speed - RefPtr<Geoposition> position = Geoposition::create(coordinates.release(), currentTime() * 1000.0); - GeolocationServiceMock::setPosition(position.release()); -} - -+ (void)setError:(int)code:(NSString *)message -{ - PositionError::ErrorCode codeEnum = static_cast<PositionError::ErrorCode>(code); - RefPtr<PositionError> error = PositionError::create(codeEnum, message); - GeolocationServiceMock::setError(error.release()); -} - -@end diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationMockPrivate.h b/WebKit/mac/WebCoreSupport/WebGeolocationMockPrivate.h deleted file mode 100644 index 28895f2..0000000 --- a/WebKit/mac/WebCoreSupport/WebGeolocationMockPrivate.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2009 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 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. - */ - -#import <Foundation/Foundation.h> - -@interface WebGeolocationMock : NSObject { -} - -+ (void)setPosition:(double)latitude:(double)longitude:(double)accuracy; -+ (void)setError:(int)code:(NSString *)message; -@end diff --git a/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.h b/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.h index e908242..3f9df13 100644 --- a/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.h +++ b/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.h @@ -27,14 +27,11 @@ */ #import <WebCore/IconDatabaseClient.h> - -namespace WebCore { - class String; -} +#import <wtf/Forward.h> class WebIconDatabaseClient : public WebCore::IconDatabaseClient { public: virtual bool performImport(); virtual void dispatchDidRemoveAllIcons(); - virtual void dispatchDidAddIconForPageURL(const WebCore::String& pageURL); + virtual void dispatchDidAddIconForPageURL(const WTF::String& pageURL); }; diff --git a/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.mm b/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.mm index 1b0c834..3651dea 100644 --- a/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.mm +++ b/WebKit/mac/WebCoreSupport/WebIconDatabaseClient.mm @@ -48,7 +48,7 @@ void WebIconDatabaseClient::dispatchDidRemoveAllIcons() [pool drain]; } -void WebIconDatabaseClient::dispatchDidAddIconForPageURL(const WebCore::String& pageURL) +void WebIconDatabaseClient::dispatchDidAddIconForPageURL(const WTF::String& pageURL) { // This is a quick notification that is likely to fire in a rapidly iterating loop // Therefore we let WebCore handle autorelease by draining its pool "from time to time" diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.h b/WebKit/mac/WebCoreSupport/WebInspectorClient.h index 64621f8..75a3cc6 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.h +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.h @@ -27,50 +27,75 @@ */ #import <WebCore/InspectorClient.h> +#import <WebCore/InspectorFrontendClientLocal.h> #import <WebCore/PlatformString.h> #import <wtf/RetainPtr.h> #ifdef __OBJC__ @class WebInspectorWindowController; +@class WebNodeHighlighter; @class WebView; #else class WebInspectorWindowController; +class WebNodeHighlighter; class WebView; #endif +namespace WebCore { + +class Page; + +} + class WebInspectorClient : public WebCore::InspectorClient { public: WebInspectorClient(WebView *); virtual void inspectorDestroyed(); - virtual WebCore::Page* createPage(); - virtual WebCore::String localizedStringsURL(); + virtual void openInspectorFrontend(WebCore::InspectorController*); + + virtual void highlight(WebCore::Node*); + virtual void hideHighlight(); + + virtual void populateSetting(const WTF::String& key, WTF::String* value); + virtual void storeSetting(const WTF::String& key, const WTF::String& value); + + virtual bool sendMessageToFrontend(const WTF::String&); + + void releaseFrontendPage(); - virtual WebCore::String hiddenPanels(); +private: + WebView *m_webView; + RetainPtr<WebNodeHighlighter> m_highlighter; + WebCore::Page* m_frontendPage; +}; - virtual void showWindow(); + +class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal { +public: + WebInspectorFrontendClient(WebView*, WebInspectorWindowController*, WebCore::InspectorController*, WebCore::Page*); + + virtual void frontendLoaded(); + + virtual WTF::String localizedStringsURL(); + virtual WTF::String hiddenPanels(); + + virtual void bringToFront(); virtual void closeWindow(); + virtual void disconnectFromBackend(); virtual void attachWindow(); virtual void detachWindow(); virtual void setAttachedWindowHeight(unsigned height); - - virtual void highlight(WebCore::Node*); - virtual void hideHighlight(); - virtual void inspectedURLChanged(const WebCore::String& newURL); - - virtual void populateSetting(const WebCore::String& key, WebCore::String* value); - virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); - - virtual void inspectorWindowObjectCleared(); + virtual void inspectedURLChanged(const WTF::String& newURL); private: void updateWindowTitle() const; - WebView *m_webView; + WebView* m_inspectedWebView; RetainPtr<WebInspectorWindowController> m_windowController; - WebCore::String m_inspectedURL; + WTF::String m_inspectedURL; }; diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm index 01515b1..b08c161 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm @@ -33,6 +33,8 @@ #import "WebFrameInternal.h" #import "WebFrameView.h" #import "WebInspector.h" +#import "WebInspectorPrivate.h" +#import "WebInspectorFrontend.h" #import "WebLocalizableStrings.h" #import "WebNodeHighlight.h" #import "WebUIDelegate.h" @@ -41,54 +43,109 @@ #import <WebCore/Page.h> #import <WebKit/DOMExtensions.h> #import <WebKitSystemInterface.h> +#import <wtf/PassOwnPtr.h> using namespace WebCore; -static const char* const inspectorStartsAttachedName = "inspectorStartsAttached"; - @interface WebInspectorWindowController : NSWindowController <NSWindowDelegate> { @private WebView *_inspectedWebView; WebView *_webView; - WebNodeHighlight *_currentHighlight; + WebInspectorFrontendClient* _frontendClient; + WebInspectorClient* _inspectorClient; BOOL _attachedToInspectedWebView; BOOL _shouldAttach; BOOL _visible; - BOOL _movingWindows; + BOOL _destroyingInspectorView; } - (id)initWithInspectedWebView:(WebView *)webView; -- (BOOL)inspectorVisible; - (WebView *)webView; - (void)attach; - (void)detach; +- (BOOL)attached; +- (void)setFrontendClient:(WebInspectorFrontendClient*)frontendClient; +- (void)setInspectorClient:(WebInspectorClient*)inspectorClient; - (void)setAttachedWindowHeight:(unsigned)height; +- (void)destroyInspectorView:(bool)notifyInspectorController; +@end + +#pragma mark - + +@interface WebNodeHighlighter : NSObject { +@private + WebView *_inspectedWebView; + WebNodeHighlight *_currentHighlight; +} +- (id)initWithInspectedWebView:(WebView *)webView; - (void)highlightNode:(DOMNode *)node; - (void)hideHighlight; @end #pragma mark - + WebInspectorClient::WebInspectorClient(WebView *webView) : m_webView(webView) +, m_highlighter(AdoptNS, [[WebNodeHighlighter alloc] initWithInspectedWebView:webView]) +, m_frontendPage(0) { } void WebInspectorClient::inspectorDestroyed() { - [[m_windowController.get() webView] close]; delete this; } -Page* WebInspectorClient::createPage() +void WebInspectorClient::openInspectorFrontend(InspectorController* inspectorController) +{ + RetainPtr<WebInspectorWindowController> windowController(AdoptNS, [[WebInspectorWindowController alloc] initWithInspectedWebView:m_webView]); + [windowController.get() setInspectorClient:this]; + + m_frontendPage = core([windowController.get() webView]); + WebInspectorFrontendClient* frontendClient = new WebInspectorFrontendClient(m_webView, windowController.get(), inspectorController, m_frontendPage); + m_frontendPage->inspectorController()->setInspectorFrontendClient(frontendClient); + + [[m_webView inspector] setFrontend:[[WebInspectorFrontend alloc] initWithFrontendClient:frontendClient]]; +} + +void WebInspectorClient::highlight(Node* node) +{ + [m_highlighter.get() highlightNode:kit(node)]; +} + +void WebInspectorClient::hideHighlight() { - if (m_windowController) - [[m_windowController.get() webView] close]; - m_windowController.adoptNS([[WebInspectorWindowController alloc] initWithInspectedWebView:m_webView]); + [m_highlighter.get() hideHighlight]; +} - return core([m_windowController.get() webView]); +WebInspectorFrontendClient::WebInspectorFrontendClient(WebView* inspectedWebView, WebInspectorWindowController* windowController, InspectorController* inspectorController, Page* frontendPage) + : InspectorFrontendClientLocal(inspectorController, frontendPage) + , m_inspectedWebView(inspectedWebView) + , m_windowController(windowController) +{ + [windowController setFrontendClient:this]; } -String WebInspectorClient::localizedStringsURL() +void WebInspectorFrontendClient::frontendLoaded() +{ + [m_windowController.get() showWindow:nil]; + if ([m_windowController.get() attached]) + restoreAttachedWindowHeight(); + + InspectorFrontendClientLocal::frontendLoaded(); + + WebFrame *frame = [m_inspectedWebView mainFrame]; + + WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_inspectedWebView); + if (implementations->didClearInspectorWindowObjectForFrameFunc) + CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_inspectedWebView, + @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame); + + bool attached = [m_windowController.get() attached]; + setAttachedWindow(attached); +} + +String WebInspectorFrontendClient::localizedStringsURL() { NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"localizedStrings" ofType:@"js"]; if (path) @@ -96,7 +153,7 @@ String WebInspectorClient::localizedStringsURL() return String(); } -String WebInspectorClient::hiddenPanels() +String WebInspectorFrontendClient::hiddenPanels() { NSString *hiddenPanels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebKitInspectorHiddenPanels"]; if (hiddenPanels) @@ -104,63 +161,52 @@ String WebInspectorClient::hiddenPanels() return String(); } -void WebInspectorClient::showWindow() +void WebInspectorFrontendClient::bringToFront() { updateWindowTitle(); [m_windowController.get() showWindow:nil]; } -void WebInspectorClient::closeWindow() +void WebInspectorFrontendClient::closeWindow() { - [m_windowController.get() close]; + [m_windowController.get() destroyInspectorView:true]; } -void WebInspectorClient::attachWindow() +void WebInspectorFrontendClient::disconnectFromBackend() { - [m_windowController.get() attach]; -} - -void WebInspectorClient::detachWindow() -{ - [m_windowController.get() detach]; + [m_windowController.get() destroyInspectorView:false]; } -void WebInspectorClient::setAttachedWindowHeight(unsigned height) +void WebInspectorFrontendClient::attachWindow() { - [m_windowController.get() setAttachedWindowHeight:height]; + if ([m_windowController.get() attached]) + return; + [m_windowController.get() attach]; + restoreAttachedWindowHeight(); } -void WebInspectorClient::highlight(Node* node) +void WebInspectorFrontendClient::detachWindow() { - [m_windowController.get() highlightNode:kit(node)]; + [m_windowController.get() detach]; } -void WebInspectorClient::hideHighlight() +void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height) { - [m_windowController.get() hideHighlight]; + [m_windowController.get() setAttachedWindowHeight:height]; } -void WebInspectorClient::inspectedURLChanged(const String& newURL) +void WebInspectorFrontendClient::inspectedURLChanged(const String& newURL) { m_inspectedURL = newURL; updateWindowTitle(); } -void WebInspectorClient::updateWindowTitle() const +void WebInspectorFrontendClient::updateWindowTitle() const { NSString *title = [NSString stringWithFormat:UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)m_inspectedURL]; [[m_windowController.get() window] setTitle:title]; } -void WebInspectorClient::inspectorWindowObjectCleared() -{ - WebFrame *frame = [m_webView mainFrame]; - - WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_webView); - if (implementations->didClearInspectorWindowObjectForFrameFunc) - CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_webView, - @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame); -} #pragma mark - @@ -171,11 +217,9 @@ void WebInspectorClient::inspectorWindowObjectCleared() return nil; // Keep preferences separate from the rest of the client, making sure we are using expected preference values. - // One reason this is good is that it keeps the inspector out of history via "private browsing". WebPreferences *preferences = [[WebPreferences alloc] init]; [preferences setAutosaves:NO]; - [preferences setPrivateBrowsingEnabled:YES]; [preferences setLoadsImagesAutomatically:YES]; [preferences setAuthorAndUserStylesEnabled:YES]; [preferences setJavaScriptEnabled:YES]; @@ -223,18 +267,12 @@ void WebInspectorClient::inspectorWindowObjectCleared() - (void)dealloc { - ASSERT(!_currentHighlight); [_webView release]; [super dealloc]; } #pragma mark - -- (BOOL)inspectorVisible -{ - return _visible; -} - - (WebView *)webView { return _webView; @@ -273,11 +311,7 @@ void WebInspectorClient::inspectorWindowObjectCleared() - (BOOL)windowShouldClose:(id)sender { - _visible = NO; - - [_inspectedWebView page]->inspectorController()->setWindowVisible(false); - - [self hideHighlight]; + [self destroyInspectorView:true]; return YES; } @@ -289,11 +323,6 @@ void WebInspectorClient::inspectorWindowObjectCleared() _visible = NO; - if (!_movingWindows) - [_inspectedWebView page]->inspectorController()->setWindowVisible(false); - - [self hideHighlight]; - if (_attachedToInspectedWebView) { if ([_inspectedWebView _isClosed]) return; @@ -327,8 +356,11 @@ void WebInspectorClient::inspectorWindowObjectCleared() _visible = YES; // If no preference is set - default to an attached window. This is important for inspector LayoutTests. - String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName); - _shouldAttach = shouldAttach != "false"; + // FIXME: This flag can be fetched directly from the flags storage. + _shouldAttach = [_inspectedWebView page]->inspectorController()->inspectorStartsAttached(); + + if (_shouldAttach && !_frontendClient->canAttachWindow()) + _shouldAttach = NO; if (_shouldAttach) { WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView]; @@ -351,8 +383,6 @@ void WebInspectorClient::inspectorWindowObjectCleared() [super showWindow:nil]; } - - [_inspectedWebView page]->inspectorController()->setWindowVisible(true, _shouldAttach); } #pragma mark - @@ -362,13 +392,11 @@ void WebInspectorClient::inspectorWindowObjectCleared() if (_attachedToInspectedWebView) return; - [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "true"); - _movingWindows = YES; + // FIXME: This flag can be saved directly to the flags storage. + [_inspectedWebView page]->inspectorController()->setInspectorStartsAttached(true); [self close]; [self showWindow:nil]; - - _movingWindows = NO; } - (void)detach @@ -376,14 +404,26 @@ void WebInspectorClient::inspectorWindowObjectCleared() if (!_attachedToInspectedWebView) return; - [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "false"); - _movingWindows = YES; + // FIXME: This flag can be saved to the flags storage directly. + [_inspectedWebView page]->inspectorController()->setInspectorStartsAttached(false); [self close]; [self showWindow:nil]; +} - _movingWindows = NO; +- (BOOL)attached +{ + return _attachedToInspectedWebView; +} +- (void)setFrontendClient:(WebInspectorFrontendClient*)frontendClient +{ + _frontendClient = frontendClient; +} + +- (void)setInspectorClient:(WebInspectorClient*)inspectorClient +{ + _inspectorClient = inspectorClient; } - (void)setAttachedWindowHeight:(unsigned)height @@ -404,29 +444,25 @@ void WebInspectorClient::inspectorWindowObjectCleared() [frameView setFrame:frameViewRect]; } -#pragma mark - - -- (void)highlightNode:(DOMNode *)node +- (void)destroyInspectorView:(bool)notifyInspectorController { - // The scrollview's content view stays around between page navigations, so target it - NSView *view = [[[[[_inspectedWebView mainFrame] frameView] documentView] enclosingScrollView] contentView]; - if (![view window]) - return; // skip the highlight if we have no window (e.g. hidden tab) + if (_destroyingInspectorView) + return; + _destroyingInspectorView = YES; - if (!_currentHighlight) { - _currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()]; - [_currentHighlight setDelegate:self]; - [_currentHighlight attach]; - } else - [[_currentHighlight highlightView] setNeedsDisplay:YES]; -} + if (_attachedToInspectedWebView) + [self close]; -- (void)hideHighlight -{ - [_currentHighlight detach]; - [_currentHighlight setDelegate:nil]; - [_currentHighlight release]; - _currentHighlight = nil; + _visible = NO; + + if (notifyInspectorController) { + if (Page* inspectedPage = [_inspectedWebView page]) + inspectedPage->inspectorController()->disconnectFrontend(); + + _inspectorClient->releaseFrontendPage(); + } + + [_webView close]; } #pragma mark - @@ -496,3 +532,60 @@ void WebInspectorClient::inspectorWindowObjectCleared() } @end + + +#pragma mark - + +@implementation WebNodeHighlighter +- (id)initWithInspectedWebView:(WebView *)webView +{ + // Don't retain to avoid a circular reference + _inspectedWebView = webView; + return self; +} + +- (void)dealloc +{ + ASSERT(!_currentHighlight); + [super dealloc]; +} + +#pragma mark - + +- (void)highlightNode:(DOMNode *)node +{ + // The scrollview's content view stays around between page navigations, so target it + NSView *view = [[[[[_inspectedWebView mainFrame] frameView] documentView] enclosingScrollView] contentView]; + if (![view window]) + return; // skip the highlight if we have no window (e.g. hidden tab) + + if (!_currentHighlight) { + _currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()]; + [_currentHighlight setDelegate:self]; + [_currentHighlight attach]; + } else + [[_currentHighlight highlightView] setNeedsDisplay:YES]; +} + +- (void)hideHighlight +{ + [_currentHighlight detach]; + [_currentHighlight setDelegate:nil]; + [_currentHighlight release]; + _currentHighlight = nil; +} + +#pragma mark - +#pragma mark WebNodeHighlight delegate + +- (void)didAttachWebNodeHighlight:(WebNodeHighlight *)highlight +{ + [_inspectedWebView setCurrentNodeHighlight:highlight]; +} + +- (void)willDetachWebNodeHighlight:(WebNodeHighlight *)highlight +{ + [_inspectedWebView setCurrentNodeHighlight:nil]; +} + +@end diff --git a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h b/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h index 94ff676..2aa37a6 100644 --- a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h +++ b/WebKit/mac/WebCoreSupport/WebPasteboardHelper.h @@ -34,9 +34,9 @@ class WebPasteboardHelper : public WebCore::PasteboardHelper { public: WebPasteboardHelper(WebHTMLView* view) : m_view(view) {} - virtual WebCore::String urlFromPasteboard(const NSPasteboard*, WebCore::String* title) const; - virtual WebCore::String plainTextFromPasteboard(const NSPasteboard*) const; - virtual DOMDocumentFragment* fragmentFromPasteboard(const NSPasteboard*) const; + virtual WTF::String urlFromPasteboard(NSPasteboard*, WTF::String* title) const; + virtual WTF::String plainTextFromPasteboard(NSPasteboard*) const; + virtual DOMDocumentFragment* fragmentFromPasteboard(NSPasteboard*) const; virtual NSArray* insertablePasteboardTypes() const; private: WebHTMLView* m_view; diff --git a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm b/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm index eb6a58d..fb93f8e 100644 --- a/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm +++ b/WebKit/mac/WebCoreSupport/WebPasteboardHelper.mm @@ -37,7 +37,7 @@ using namespace WebCore; -String WebPasteboardHelper::urlFromPasteboard(const NSPasteboard* pasteboard, String* title) const +String WebPasteboardHelper::urlFromPasteboard(NSPasteboard* pasteboard, String* title) const { NSURL *URL = [pasteboard _web_bestURL]; if (title) { @@ -48,7 +48,7 @@ String WebPasteboardHelper::urlFromPasteboard(const NSPasteboard* pasteboard, St return [URL _web_originalDataAsString]; } -String WebPasteboardHelper::plainTextFromPasteboard(const NSPasteboard *pasteboard) const +String WebPasteboardHelper::plainTextFromPasteboard(NSPasteboard *pasteboard) const { NSArray *types = [pasteboard types]; @@ -85,7 +85,7 @@ String WebPasteboardHelper::plainTextFromPasteboard(const NSPasteboard *pasteboa return String(); } -DOMDocumentFragment *WebPasteboardHelper::fragmentFromPasteboard(const NSPasteboard *pasteboard) const +DOMDocumentFragment *WebPasteboardHelper::fragmentFromPasteboard(NSPasteboard *pasteboard) const { return [m_view _documentFragmentFromPasteboard:pasteboard]; } diff --git a/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h b/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h new file mode 100644 index 0000000..fab7eee --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h @@ -0,0 +1,169 @@ +/* + * 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 WebPlatformStrategies_h +#define WebPlatformStrategies_h + +#include <WebCore/PlatformStrategies.h> +#include <WebCore/PluginStrategy.h> +#include <WebCore/LocalizationStrategy.h> +#include <WebCore/VisitedLinkStrategy.h> + +class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::PluginStrategy, private WebCore::LocalizationStrategy, private WebCore::VisitedLinkStrategy { +public: + static void initialize(); + +private: + WebPlatformStrategies(); + + // WebCore::PlatformStrategies + virtual WebCore::PluginStrategy* createPluginStrategy(); + virtual WebCore::LocalizationStrategy* createLocalizationStrategy(); + virtual WebCore::VisitedLinkStrategy* createVisitedLinkStrategy(); + + // WebCore::PluginStrategy + virtual void refreshPlugins(); + virtual void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&); + + // WebCore::LocalizationStrategy + virtual WTF::String inputElementAltText(); + virtual WTF::String resetButtonDefaultLabel(); + virtual WTF::String searchableIndexIntroduction(); + virtual WTF::String submitButtonDefaultLabel(); + virtual WTF::String fileButtonChooseFileLabel(); + virtual WTF::String fileButtonNoFileSelectedLabel(); + virtual WTF::String copyImageUnknownFileLabel(); +#if ENABLE(CONTEXT_MENUS) + virtual WTF::String contextMenuItemTagOpenLinkInNewWindow(); + virtual WTF::String contextMenuItemTagDownloadLinkToDisk(); + virtual WTF::String contextMenuItemTagCopyLinkToClipboard(); + virtual WTF::String contextMenuItemTagOpenImageInNewWindow(); + virtual WTF::String contextMenuItemTagDownloadImageToDisk(); + virtual WTF::String contextMenuItemTagCopyImageToClipboard(); + virtual WTF::String contextMenuItemTagOpenFrameInNewWindow(); + virtual WTF::String contextMenuItemTagCopy(); + virtual WTF::String contextMenuItemTagGoBack(); + virtual WTF::String contextMenuItemTagGoForward(); + virtual WTF::String contextMenuItemTagStop(); + virtual WTF::String contextMenuItemTagReload(); + virtual WTF::String contextMenuItemTagCut(); + virtual WTF::String contextMenuItemTagPaste(); + virtual WTF::String contextMenuItemTagNoGuessesFound(); + virtual WTF::String contextMenuItemTagIgnoreSpelling(); + virtual WTF::String contextMenuItemTagLearnSpelling(); + virtual WTF::String contextMenuItemTagSearchWeb(); + virtual WTF::String contextMenuItemTagLookUpInDictionary(); + virtual WTF::String contextMenuItemTagOpenLink(); + virtual WTF::String contextMenuItemTagIgnoreGrammar(); + virtual WTF::String contextMenuItemTagSpellingMenu(); + virtual WTF::String contextMenuItemTagShowSpellingPanel(bool show); + virtual WTF::String contextMenuItemTagCheckSpelling(); + virtual WTF::String contextMenuItemTagCheckSpellingWhileTyping(); + virtual WTF::String contextMenuItemTagCheckGrammarWithSpelling(); + virtual WTF::String contextMenuItemTagFontMenu(); + virtual WTF::String contextMenuItemTagBold(); + virtual WTF::String contextMenuItemTagItalic(); + virtual WTF::String contextMenuItemTagUnderline(); + virtual WTF::String contextMenuItemTagOutline(); + virtual WTF::String contextMenuItemTagWritingDirectionMenu(); + virtual WTF::String contextMenuItemTagTextDirectionMenu(); + virtual WTF::String contextMenuItemTagDefaultDirection(); + virtual WTF::String contextMenuItemTagLeftToRight(); + virtual WTF::String contextMenuItemTagRightToLeft(); + virtual WTF::String contextMenuItemTagSearchInSpotlight(); + virtual WTF::String contextMenuItemTagShowFonts(); + virtual WTF::String contextMenuItemTagStyles(); + virtual WTF::String contextMenuItemTagShowColors(); + virtual WTF::String contextMenuItemTagSpeechMenu(); + virtual WTF::String contextMenuItemTagStartSpeaking(); + virtual WTF::String contextMenuItemTagStopSpeaking(); + virtual WTF::String contextMenuItemTagCorrectSpellingAutomatically(); + virtual WTF::String contextMenuItemTagSubstitutionsMenu(); + virtual WTF::String contextMenuItemTagShowSubstitutions(bool show); + virtual WTF::String contextMenuItemTagSmartCopyPaste(); + virtual WTF::String contextMenuItemTagSmartQuotes(); + virtual WTF::String contextMenuItemTagSmartDashes(); + virtual WTF::String contextMenuItemTagSmartLinks(); + virtual WTF::String contextMenuItemTagTextReplacement(); + virtual WTF::String contextMenuItemTagTransformationsMenu(); + virtual WTF::String contextMenuItemTagMakeUpperCase(); + virtual WTF::String contextMenuItemTagMakeLowerCase(); + virtual WTF::String contextMenuItemTagCapitalize(); + virtual WTF::String contextMenuItemTagChangeBack(const WTF::String& replacedString); + virtual WTF::String contextMenuItemTagInspectElement(); + virtual WTF::String contextMenuItemTagOpenVideoInNewWindow(); + virtual WTF::String contextMenuItemTagOpenAudioInNewWindow(); + virtual WTF::String contextMenuItemTagCopyVideoLinkToClipboard(); + virtual WTF::String contextMenuItemTagCopyAudioLinkToClipboard(); + virtual WTF::String contextMenuItemTagToggleMediaControls(); + virtual WTF::String contextMenuItemTagToggleMediaLoop(); + virtual WTF::String contextMenuItemTagEnterVideoFullscreen(); + virtual WTF::String contextMenuItemTagMediaPlay(); + virtual WTF::String contextMenuItemTagMediaPause(); + virtual WTF::String contextMenuItemTagMediaMute(); +#endif // ENABLE(CONTEXT_MENUS) + virtual WTF::String searchMenuNoRecentSearchesText(); + virtual WTF::String searchMenuRecentSearchesText(); + virtual WTF::String searchMenuClearRecentSearchesText(); + virtual WTF::String AXWebAreaText(); + virtual WTF::String AXLinkText(); + virtual WTF::String AXListMarkerText(); + virtual WTF::String AXImageMapText(); + virtual WTF::String AXHeadingText(); + virtual WTF::String AXDefinitionListTermText(); + virtual WTF::String AXDefinitionListDefinitionText(); + virtual WTF::String AXARIAContentGroupText(const WTF::String& ariaType); + virtual WTF::String AXButtonActionVerb(); + virtual WTF::String AXRadioButtonActionVerb(); + virtual WTF::String AXTextFieldActionVerb(); + virtual WTF::String AXCheckedCheckBoxActionVerb(); + virtual WTF::String AXUncheckedCheckBoxActionVerb(); + virtual WTF::String AXMenuListActionVerb(); + virtual WTF::String AXMenuListPopupActionVerb(); + virtual WTF::String AXLinkActionVerb(); + virtual WTF::String missingPluginText(); + virtual WTF::String crashedPluginText(); + virtual WTF::String multipleFileUploadText(unsigned numberOfFiles); + virtual WTF::String unknownFileSizeText(); + virtual WTF::String imageTitle(const WTF::String& filename, const WebCore::IntSize& size); + virtual WTF::String mediaElementLoadingStateText(); + virtual WTF::String mediaElementLiveBroadcastStateText(); + virtual WTF::String localizedMediaControlElementString(const WTF::String&); + virtual WTF::String localizedMediaControlElementHelpText(const WTF::String&); + virtual WTF::String localizedMediaTimeDescription(float); + virtual WTF::String validationMessageValueMissingText(); + virtual WTF::String validationMessageTypeMismatchText(); + virtual WTF::String validationMessagePatternMismatchText(); + virtual WTF::String validationMessageTooLongText(); + virtual WTF::String validationMessageRangeUnderflowText(); + virtual WTF::String validationMessageRangeOverflowText(); + virtual WTF::String validationMessageStepMismatchText(); + + // WebCore::VisitedLinkStrategy + virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash); + virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash); +}; + +#endif // WebPlatformStrategies_h diff --git a/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm b/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm new file mode 100644 index 0000000..f95594a --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm @@ -0,0 +1,837 @@ +/* + * 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. + */ + +#import "WebPlatformStrategies.h" + +#import "WebLocalizableStrings.h" +#import "WebPluginDatabase.h" +#import "WebPluginPackage.h" +#import <WebCore/BlockExceptions.h> +#import <WebCore/IntSize.h> +#import <WebCore/Page.h> +#import <WebCore/PageGroup.h> +#import <wtf/StdLibExtras.h> + +#ifdef BUILDING_ON_TIGER +typedef unsigned NSUInteger; +#endif + +using namespace WebCore; + +void WebPlatformStrategies::initialize() +{ + DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ()); + setPlatformStrategies(&platformStrategies); +} + +WebPlatformStrategies::WebPlatformStrategies() +{ +} + +// PluginStrategy + +PluginStrategy* WebPlatformStrategies::createPluginStrategy() +{ + return this; +} + +LocalizationStrategy* WebPlatformStrategies::createLocalizationStrategy() +{ + return this; +} + +VisitedLinkStrategy* WebPlatformStrategies::createVisitedLinkStrategy() +{ + return this; +} + +void WebPlatformStrategies::refreshPlugins() +{ + [[WebPluginDatabase sharedDatabase] refresh]; +} + +void WebPlatformStrategies::getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>& plugins) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + NSArray* pluginsArray = [[WebPluginDatabase sharedDatabase] plugins]; + for (unsigned int i = 0; i < [pluginsArray count]; ++i) { + WebPluginPackage *plugin = [pluginsArray objectAtIndex:i]; + + plugins.append([plugin pluginInfo]); + } + + END_BLOCK_OBJC_EXCEPTIONS; +} + +// 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::copyImageUnknownFileLabel() +{ + return UI_STRING("unknown", "Unknown filename"); +} + +#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"); +} + +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"); +} + +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() +{ +#ifndef BUILDING_ON_TIGER + return UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item"); +#else + return UI_STRING("Spelling", "Spelling context sub-menu item"); +#endif +} + +String WebPlatformStrategies::contextMenuItemTagShowSpellingPanel(bool show) +{ +#ifndef BUILDING_ON_TIGER + if (show) + return UI_STRING("Show Spelling and Grammar", "menu item title"); + return UI_STRING("Hide Spelling and Grammar", "menu item title"); +#else + return UI_STRING("Spelling...", "menu item title"); +#endif +} + +String WebPlatformStrategies::contextMenuItemTagCheckSpelling() +{ +#ifndef BUILDING_ON_TIGER + return UI_STRING("Check Document Now", "Check spelling context menu item"); +#else + return UI_STRING("Check Spelling", "Check spelling context menu item"); +#endif +} + +String WebPlatformStrategies::contextMenuItemTagCheckSpellingWhileTyping() +{ +#ifndef BUILDING_ON_TIGER + return UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item"); +#else + return UI_STRING("Check Spelling as You Type", "Check spelling while typing context menu item"); +#endif +} + +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() +{ +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + return UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item"); +#else + return UI_STRING("Writing Direction", "Writing direction context sub-menu item"); +#endif +} + +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) +{ + static NSString *formatString = nil; +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + static bool lookedUpString = false; + if (!lookedUpString) { + formatString = [[[NSBundle bundleForClass:[NSSpellChecker class]] localizedStringForKey:@"Change Back to \\U201C%@\\U201D" value:nil table:@"MenuCommands"] retain]; + lookedUpString = true; + } +#endif + if (!formatString) + return replacedString; + return [NSString stringWithFormat:formatString, (NSString *)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"); +} + +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(); +} + +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() +{ + return String(); +} + +String WebPlatformStrategies::AXMenuListPopupActionVerb() +{ + return String(); +} + +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 [NSString stringWithFormat: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"); +} + +String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size) +{ +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + NSString *widthString = [NSNumberFormatter localizedStringFromNumber:[NSNumber numberWithInt:size.width()] numberStyle:NSNumberFormatterDecimalStyle]; + NSString *heightString = [NSNumberFormatter localizedStringFromNumber:[NSNumber numberWithInt:size.height()] numberStyle:NSNumberFormatterDecimalStyle]; + return [NSString localizedStringWithFormat:UI_STRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)"), (NSString *)filename, widthString, heightString]; +#else + return [NSString stringWithFormat:UI_STRING("%@ %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), (NSString *)filename, size.width(), size.height()]; +#endif +} + +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 = (int)fabsf(time); + int days = seconds / (60 * 60 * 24); + int hours = seconds / (60 * 60); + int minutes = (seconds / 60) % 60; + seconds %= 60; + + if (days) + return [NSString stringWithFormat: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]; + else if (hours) + return [NSString stringWithFormat:UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds]; + else if (minutes) + return [NSString stringWithFormat:UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds]; + + return [NSString stringWithFormat: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() +{ + return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum"); +} + +String WebPlatformStrategies::validationMessageRangeOverflowText() +{ + return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum"); +} + +String WebPlatformStrategies::validationMessageStepMismatchText() +{ + return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute"); +} + +// VisitedLinkStrategy +bool WebPlatformStrategies::isLinkVisited(Page* page, LinkHash hash) +{ + return page->group().isLinkVisited(hash); +} + +void WebPlatformStrategies::addVisitedLink(Page* page, LinkHash hash) +{ + return page->group().addVisitedLinkHash(hash); +} diff --git a/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h b/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h index a0d398d..ed4ff11 100644 --- a/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h +++ b/WebKit/mac/WebCoreSupport/WebPluginHalterClient.h @@ -24,10 +24,10 @@ */ #import <WebCore/PluginHalterClient.h> +#import <wtf/Forward.h> namespace WebCore { class Node; - class String; } @class WebView; @@ -36,7 +36,7 @@ class WebPluginHalterClient : public WebCore::PluginHalterClient { public: WebPluginHalterClient(WebView *); - virtual bool shouldHaltPlugin(WebCore::Node*, bool, const WebCore::String&) const; + virtual bool shouldHaltPlugin(WebCore::Node*, bool, const WTF::String&) const; virtual bool enabled() const; private: diff --git a/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm b/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm new file mode 100644 index 0000000..f19dcb5 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2007, 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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. + */ + +#import "WebSecurityOriginInternal.h" + +#import "WebApplicationCacheQuotaManager.h" +#import "WebDatabaseQuotaManager.h" +#import "WebQuotaManager.h" +#import <WebCore/KURL.h> +#import <WebCore/DatabaseTracker.h> +#import <WebCore/SecurityOrigin.h> + +using namespace WebCore; + +@implementation WebSecurityOrigin +- (id)initWithURL:(NSURL *)url +{ + self = [super init]; + if (!self) + return nil; + + RefPtr<SecurityOrigin> origin = SecurityOrigin::create(KURL([url absoluteURL])); + origin->ref(); + _private = reinterpret_cast<WebSecurityOriginPrivate*>(origin.get()); + + return self; +} + +- (NSString*)protocol +{ + return reinterpret_cast<SecurityOrigin*>(_private)->protocol(); +} + +- (NSString*)host +{ + return reinterpret_cast<SecurityOrigin*>(_private)->host(); +} + +// Deprecated. Use host instead. This needs to stay here until we ship a new Safari. +- (NSString*)domain +{ + return [self host]; +} + +- (unsigned short)port +{ + return reinterpret_cast<SecurityOrigin*>(_private)->port(); +} + +- (BOOL)isEqual:(id)anObject +{ + if (![anObject isMemberOfClass:[WebSecurityOrigin class]]) { + return NO; + } + + return [self _core]->equal([anObject _core]); +} + +- (void)dealloc +{ + if (_private) + reinterpret_cast<SecurityOrigin*>(_private)->deref(); + if (_applicationCacheQuotaManager) + [(NSObject *)_applicationCacheQuotaManager release]; + if (_databaseQuotaManager) + [(NSObject *)_databaseQuotaManager release]; + [super dealloc]; +} + +- (void)finalize +{ + if (_private) + reinterpret_cast<SecurityOrigin*>(_private)->deref(); + [super finalize]; +} + +@end + +@implementation WebSecurityOrigin (WebInternal) + +- (id)_initWithWebCoreSecurityOrigin:(SecurityOrigin*)origin +{ + ASSERT(origin); + self = [super init]; + if (!self) + return nil; + + origin->ref(); + _private = reinterpret_cast<WebSecurityOriginPrivate*>(origin); + + return self; +} + +- (SecurityOrigin *)_core +{ + return reinterpret_cast<SecurityOrigin*>(_private); +} + +@end + + +#pragma mark - +#pragma mark WebQuotaManagers + +@implementation WebSecurityOrigin (WebQuotaManagers) + +- (id<WebQuotaManager>)applicationCacheQuotaManager +{ + if (!_applicationCacheQuotaManager) + _applicationCacheQuotaManager = [[WebApplicationCacheQuotaManager alloc] initWithOrigin:self]; + return _applicationCacheQuotaManager; +} + +- (id<WebQuotaManager>)databaseQuotaManager +{ + if (!_databaseQuotaManager) + _databaseQuotaManager = [[WebDatabaseQuotaManager alloc] initWithOrigin:self]; + return _databaseQuotaManager; +} + +@end + + +#pragma mark - +#pragma mark Deprecated + +// FIXME: The following methods are deprecated and should removed later. +// Clients should instead get a WebQuotaManager, and query / set the quota via the Manager. +// NOTE: the <WebCore/DatabaseTracker.h> #include should be removed as well. + +@implementation WebSecurityOrigin (Deprecated) + +- (unsigned long long)usage +{ +#if ENABLE(DATABASE) + return DatabaseTracker::tracker().usageForOrigin(reinterpret_cast<SecurityOrigin*>(_private)); +#else + return 0; +#endif +} + +- (unsigned long long)quota +{ +#if ENABLE(DATABASE) + return DatabaseTracker::tracker().quotaForOrigin(reinterpret_cast<SecurityOrigin*>(_private)); +#else + return 0; +#endif +} + +- (void)setQuota:(unsigned long long)quota +{ +#if ENABLE(DATABASE) + DatabaseTracker::tracker().setQuota(reinterpret_cast<SecurityOrigin*>(_private), quota); +#endif +} + +@end diff --git a/WebKit/mac/WebCoreSupport/WebSecurityOriginInternal.h b/WebKit/mac/WebCoreSupport/WebSecurityOriginInternal.h new file mode 100644 index 0000000..7bd6817 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebSecurityOriginInternal.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2007 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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. + */ + +#include "WebSecurityOriginPrivate.h" + +namespace WebCore { + class SecurityOrigin; +} + +typedef WebCore::SecurityOrigin WebCoreSecurityOrigin; + +@interface WebSecurityOrigin (WebInternal) + +- (id)_initWithWebCoreSecurityOrigin:(WebCoreSecurityOrigin *)origin; +- (WebCoreSecurityOrigin *)_core; + +@end diff --git a/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h b/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h new file mode 100644 index 0000000..2973d92 --- /dev/null +++ b/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2007, 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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. + */ + +@class WebSecurityOriginPrivate; +@protocol WebQuotaManager; + +@interface WebSecurityOrigin : NSObject { + WebSecurityOriginPrivate *_private; + id<WebQuotaManager> _applicationCacheQuotaManager; + id<WebQuotaManager> _databaseQuotaManager; +} + +- (id)initWithURL:(NSURL *)url; + +- (NSString*)protocol; +- (NSString*)host; + +// Returns zero if the port is the default port for the protocol, non-zero otherwise. +- (unsigned short)port; + +@end + +@interface WebSecurityOrigin (WebQuotaManagers) +- (id<WebQuotaManager>)applicationCacheQuotaManager; +- (id<WebQuotaManager>)databaseQuotaManager; +@end + +// FIXME: The following methods are deprecated and should removed later. +// Clients should instead get a WebQuotaManager, and query / set the quota via the Manager. +@interface WebSecurityOrigin (Deprecated) +- (unsigned long long)usage; +- (unsigned long long)quota; +- (void)setQuota:(unsigned long long)quota; +@end diff --git a/WebKit/mac/WebCoreSupport/WebSystemInterface.h b/WebKit/mac/WebCoreSupport/WebSystemInterface.h index 6e20279..d460217 100644 --- a/WebKit/mac/WebCoreSupport/WebSystemInterface.h +++ b/WebKit/mac/WebCoreSupport/WebSystemInterface.h @@ -26,12 +26,4 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __cplusplus -extern "C" { -#endif - -void InitWebCoreSystemInterface(void); - -#ifdef __cplusplus -} -#endif +void InitWebCoreSystemInterface(); diff --git a/WebKit/mac/WebCoreSupport/WebSystemInterface.m b/WebKit/mac/WebCoreSupport/WebSystemInterface.mm index 7f4effd..2c57646 100644 --- a/WebKit/mac/WebCoreSupport/WebSystemInterface.m +++ b/WebKit/mac/WebCoreSupport/WebSystemInterface.mm @@ -1,5 +1,5 @@ /* - * Copyright 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright 2006, 2007, 2008, 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 @@ -28,12 +28,12 @@ #import "WebSystemInterface.h" -#import <WebCore/WebCoreSystemInterface.h> -#import <WebKitSystemInterface.h> - // Needed for builds not using PCH to expose BUILDING_ macros, see bug 32753. #include <wtf/Platform.h> +#import <WebCore/WebCoreSystemInterface.h> +#import <WebKitSystemInterface.h> + #define INIT(function) wk##function = WK##function void InitWebCoreSystemInterface(void) @@ -44,7 +44,9 @@ void InitWebCoreSystemInterface(void) INIT(AdvanceDefaultButtonPulseAnimation); INIT(CGContextGetShouldSmoothFonts); + INIT(CopyCFLocalizationPreferredName); INIT(CopyCONNECTProxyResponse); + INIT(CopyNSURLResponseStatusLine); INIT(CreateCustomCFReadStream); INIT(CreateNSURLConnectionDelegateProxy); INIT(DrawCapsLockIndicator); @@ -71,6 +73,7 @@ void InitWebCoreSystemInterface(void) INIT(SetCGFontRenderingMode); INIT(SetCONNECTProxyAuthorizationForStream); INIT(SetCONNECTProxyForStream); + INIT(SetCookieStoragePrivateBrowsingEnabled); INIT(SetDragImage); INIT(SetNSURLConnectionDefersCallbacks); INIT(SetNSURLRequestShouldContentSniff); @@ -83,12 +86,14 @@ void InitWebCoreSystemInterface(void) INIT(SignalCFReadStreamHasBytes); INIT(QTIncludeOnlyModernMediaFileTypes); INIT(QTMovieDataRate); + INIT(QTMovieDisableComponent); INIT(QTMovieMaxTimeLoaded); INIT(QTMovieMaxTimeLoadedChangeNotification); INIT(QTMovieMaxTimeSeekable); INIT(QTMovieGetType); INIT(QTMovieHasClosedCaptions); INIT(QTMovieSetShowClosedCaptions); + INIT(QTMovieSelectPreferredAlternates); INIT(QTMovieViewSetDrawSynchronously); #ifndef BUILDING_ON_TIGER @@ -109,8 +114,13 @@ void InitWebCoreSystemInterface(void) INIT(SupportsMultipartXMixedReplace); #endif +#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) + INIT(GetHyphenationLocationBeforeIndex); +#endif + + INIT(CreateCTLineWithUniCharProvider); #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - INIT(NoteOpenPanelFiles); + INIT(CreateCTTypesetterWithUniCharProviderAndOptions); #endif didInit = true; diff --git a/WebKit/mac/WebCoreSupport/WebViewFactory.mm b/WebKit/mac/WebCoreSupport/WebViewFactory.mm index 2607f18..055e3b4 100644 --- a/WebKit/mac/WebCoreSupport/WebViewFactory.mm +++ b/WebKit/mac/WebCoreSupport/WebViewFactory.mm @@ -31,11 +31,9 @@ #import <WebKit/WebFrameInternal.h> #import <WebKit/WebViewInternal.h> #import <WebKit/WebHTMLViewInternal.h> -#import <WebKit/WebLocalizableStrings.h> #import <WebKit/WebNSUserDefaultsExtras.h> #import <WebKit/WebNSObjectExtras.h> #import <WebKit/WebNSViewExtras.h> -#import <WebKit/WebPluginDatabase.h> #import <WebKitSystemInterface.h> #import <wtf/Assertions.h> @@ -65,389 +63,6 @@ ASSERT([[self sharedFactory] isKindOfClass:self]); } -- (NSArray *)pluginsInfo -{ - return [[WebPluginDatabase sharedDatabase] plugins]; -} - -- (void)refreshPlugins -{ - [[WebPluginDatabase sharedDatabase] refresh]; -} - -- (NSString *)inputElementAltText -{ - return UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value"); -} - -- (NSString *)resetButtonDefaultLabel -{ - return UI_STRING("Reset", "default label for Reset buttons in forms on web pages"); -} - -- (NSString *)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'"); -} - -- (NSString *)submitButtonDefaultLabel -{ - return UI_STRING("Submit", "default label for Submit buttons in forms on web pages"); -} - -- (NSString *)fileButtonChooseFileLabel -{ - return UI_STRING("Choose File", "title for file button used in HTML forms"); -} - -- (NSString *)fileButtonNoFileSelectedLabel -{ - return UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected"); -} - -- (NSString *)copyImageUnknownFileLabel -{ - return UI_STRING("unknown", "Unknown filename"); -} - -- (NSString *)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"); -} - -- (NSString *)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"); -} - -- (NSString *)searchMenuClearRecentSearchesText -{ - return UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents"); -} - -- (NSString *)defaultLanguageCode -{ - return [NSUserDefaults _webkit_preferredLanguageCode]; -} - -- (NSString *)contextMenuItemTagOpenLinkInNewWindow -{ - return UI_STRING("Open Link in New Window", "Open in New Window context menu item"); -} - -- (NSString *)contextMenuItemTagDownloadLinkToDisk -{ - return UI_STRING("Download Linked File", "Download Linked File context menu item"); -} - -- (NSString *)contextMenuItemTagCopyLinkToClipboard -{ - return UI_STRING("Copy Link", "Copy Link context menu item"); -} - -- (NSString *)contextMenuItemTagOpenImageInNewWindow -{ - return UI_STRING("Open Image in New Window", "Open Image in New Window context menu item"); -} - -- (NSString *)contextMenuItemTagDownloadImageToDisk -{ - return UI_STRING("Download Image", "Download Image context menu item"); -} - -- (NSString *)contextMenuItemTagCopyImageToClipboard -{ - return UI_STRING("Copy Image", "Copy Image context menu item"); -} - -- (NSString *)contextMenuItemTagOpenFrameInNewWindow -{ - return UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item"); -} - -- (NSString *)contextMenuItemTagCopy -{ - return UI_STRING("Copy", "Copy context menu item"); -} - -- (NSString *)contextMenuItemTagGoBack -{ - return UI_STRING("Back", "Back context menu item"); -} - -- (NSString *)contextMenuItemTagGoForward -{ - return UI_STRING("Forward", "Forward context menu item"); -} - -- (NSString *)contextMenuItemTagStop -{ - return UI_STRING("Stop", "Stop context menu item"); -} - -- (NSString *)contextMenuItemTagReload -{ - return UI_STRING("Reload", "Reload context menu item"); -} - -- (NSString *)contextMenuItemTagCut -{ - return UI_STRING("Cut", "Cut context menu item"); -} - -- (NSString *)contextMenuItemTagPaste -{ - return UI_STRING("Paste", "Paste context menu item"); -} - -- (NSString *)contextMenuItemTagNoGuessesFound -{ - return UI_STRING("No Guesses Found", "No Guesses Found context menu item"); -} - -- (NSString *)contextMenuItemTagIgnoreSpelling -{ - return UI_STRING("Ignore Spelling", "Ignore Spelling context menu item"); -} - -- (NSString *)contextMenuItemTagLearnSpelling -{ - return UI_STRING("Learn Spelling", "Learn Spelling context menu item"); -} - -- (NSString *)contextMenuItemTagSearchInSpotlight -{ - return UI_STRING("Search in Spotlight", "Search in Spotlight context menu item"); -} - -- (NSString *)contextMenuItemTagSearchWeb -{ - return UI_STRING("Search in Google", "Search in Google context menu item"); -} - -- (NSString *)contextMenuItemTagLookUpInDictionary -{ - return UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item"); -} - -- (NSString *)contextMenuItemTagOpenLink -{ - return UI_STRING("Open Link", "Open Link context menu item"); -} - -- (NSString *)contextMenuItemTagIgnoreGrammar -{ - return UI_STRING("Ignore Grammar", "Ignore Grammar context menu item"); -} - -- (NSString *)contextMenuItemTagSpellingMenu -{ -#ifndef BUILDING_ON_TIGER - return UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item"); -#else - return UI_STRING("Spelling", "Spelling context sub-menu item"); -#endif -} - -- (NSString *)contextMenuItemTagShowSpellingPanel:(bool)show -{ -#ifndef BUILDING_ON_TIGER - if (show) - return UI_STRING("Show Spelling and Grammar", "menu item title"); - return UI_STRING("Hide Spelling and Grammar", "menu item title"); -#else - return UI_STRING("Spelling...", "menu item title"); -#endif -} - -- (NSString *)contextMenuItemTagCheckSpelling -{ -#ifndef BUILDING_ON_TIGER - return UI_STRING("Check Document Now", "Check spelling context menu item"); -#else - return UI_STRING("Check Spelling", "Check spelling context menu item"); -#endif -} - -- (NSString *)contextMenuItemTagCheckSpellingWhileTyping -{ -#ifndef BUILDING_ON_TIGER - return UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item"); -#else - return UI_STRING("Check Spelling as You Type", "Check spelling while typing context menu item"); -#endif -} - -- (NSString *)contextMenuItemTagCheckGrammarWithSpelling -{ - return UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item"); -} - -- (NSString *)contextMenuItemTagFontMenu -{ - return UI_STRING("Font", "Font context sub-menu item"); -} - -- (NSString *)contextMenuItemTagShowFonts -{ - return UI_STRING("Show Fonts", "Show fonts context menu item"); -} - -- (NSString *)contextMenuItemTagBold -{ - return UI_STRING("Bold", "Bold context menu item"); -} - -- (NSString *)contextMenuItemTagItalic -{ - return UI_STRING("Italic", "Italic context menu item"); -} - -- (NSString *)contextMenuItemTagUnderline -{ - return UI_STRING("Underline", "Underline context menu item"); -} - -- (NSString *)contextMenuItemTagOutline -{ - return UI_STRING("Outline", "Outline context menu item"); -} - -- (NSString *)contextMenuItemTagStyles -{ - return UI_STRING("Styles...", "Styles context menu item"); -} - -- (NSString *)contextMenuItemTagShowColors -{ - return UI_STRING("Show Colors", "Show colors context menu item"); -} - -- (NSString *)contextMenuItemTagSpeechMenu -{ - return UI_STRING("Speech", "Speech context sub-menu item"); -} - -- (NSString *)contextMenuItemTagStartSpeaking -{ - return UI_STRING("Start Speaking", "Start speaking context menu item"); -} - -- (NSString *)contextMenuItemTagStopSpeaking -{ - return UI_STRING("Stop Speaking", "Stop speaking context menu item"); -} - -- (NSString *)contextMenuItemTagWritingDirectionMenu -{ -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - return UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item"); -#else - return UI_STRING("Writing Direction", "Writing direction context sub-menu item"); -#endif -} - -- (NSString *)contextMenuItemTagTextDirectionMenu -{ - return UI_STRING("Selection Direction", "Selection direction context sub-menu item"); -} - -- (NSString *)contextMenuItemTagDefaultDirection -{ - return UI_STRING("Default", "Default writing direction context menu item"); -} - -- (NSString *)contextMenuItemTagLeftToRight -{ - return UI_STRING("Left to Right", "Left to Right context menu item"); -} - -- (NSString *)contextMenuItemTagRightToLeft -{ - return UI_STRING("Right to Left", "Right to Left context menu item"); -} - -- (NSString *)contextMenuItemTagCorrectSpellingAutomatically -{ - return UI_STRING("Correct Spelling Automatically", "Correct Spelling Automatically context menu item"); -} - -- (NSString *)contextMenuItemTagSubstitutionsMenu -{ - return UI_STRING("Substitutions", "Substitutions context sub-menu item"); -} - -- (NSString *)contextMenuItemTagShowSubstitutions:(bool)show -{ - if (show) - return UI_STRING("Show Substitutions", "menu item title"); - return UI_STRING("Hide Substitutions", "menu item title"); -} - -- (NSString *)contextMenuItemTagSmartCopyPaste -{ - return UI_STRING("Smart Copy/Paste", "Smart Copy/Paste context menu item"); -} - -- (NSString *)contextMenuItemTagSmartQuotes -{ - return UI_STRING("Smart Quotes", "Smart Quotes context menu item"); -} - -- (NSString *)contextMenuItemTagSmartDashes -{ - return UI_STRING("Smart Dashes", "Smart Dashes context menu item"); -} - -- (NSString *)contextMenuItemTagSmartLinks -{ - return UI_STRING("Smart Links", "Smart Links context menu item"); -} - -- (NSString *)contextMenuItemTagTextReplacement -{ - return UI_STRING("Text Replacement", "Text Replacement context menu item"); -} - -- (NSString *)contextMenuItemTagTransformationsMenu -{ - return UI_STRING("Transformations", "Transformations context sub-menu item"); -} - -- (NSString *)contextMenuItemTagMakeUpperCase -{ - return UI_STRING("Make Upper Case", "Make Upper Case context menu item"); -} - -- (NSString *)contextMenuItemTagMakeLowerCase -{ - return UI_STRING("Make Lower Case", "Make Lower Case context menu item"); -} - -- (NSString *)contextMenuItemTagCapitalize -{ - return UI_STRING("Capitalize", "Capitalize context menu item"); -} - -- (NSString *)contextMenuItemTagChangeBack:(NSString *)replacedString -{ - static NSString *formatString = nil; -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - static bool lookedUpString = false; - if (!lookedUpString) { - formatString = [[[NSBundle bundleForClass:[NSSpellChecker class]] localizedStringForKey:@"Change Back to \\U201C%@\\U201D" value:nil table:@"MenuCommands"] retain]; - lookedUpString = true; - } -#endif - return formatString ? [NSString stringWithFormat:formatString, replacedString] : replacedString; -} - -- (NSString *)contextMenuItemTagInspectElement -{ - return UI_STRING("Inspect Element", "Inspect Element context menu item"); -} - - (BOOL)objectIsTextMarker:(id)object { return object != nil && CFGetTypeID(object) == WKGetAXTextMarkerTypeID(); @@ -518,298 +133,4 @@ WKUnregisterUniqueIdForElement(element); } -- (NSString *)AXWebAreaText -{ - return UI_STRING("HTML content", "accessibility role description for web area"); -} - -- (NSString *)AXLinkText -{ - return UI_STRING("link", "accessibility role description for link"); -} - -- (NSString *)AXListMarkerText -{ - return UI_STRING("list marker", "accessibility role description for list marker"); -} - -- (NSString *)AXImageMapText -{ - return UI_STRING("image map", "accessibility role description for image map"); -} - -- (NSString *)AXHeadingText -{ - return UI_STRING("heading", "accessibility role description for headings"); -} - -- (NSString *)AXDefinitionListTermText -{ - return UI_STRING("term", "term word of a definition"); -} - -- (NSString *)AXDefinitionListDefinitionText -{ - return UI_STRING("definition", "definition phrase"); -} - -- (NSString *)AXARIAContentGroupText:(NSString *)ariaType -{ - if ([ariaType isEqualToString:@"ARIAApplicationAlert"]) - return UI_STRING("alert", "An ARIA accessibility group that acts as an alert."); - if ([ariaType isEqualToString:@"ARIAApplicationAlertDialog"]) - return UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog."); - if ([ariaType isEqualToString:@"ARIAApplicationDialog"]) - return UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog."); - if ([ariaType isEqualToString:@"ARIAApplicationLog"]) - return UI_STRING("log", "An ARIA accessibility group that acts as a console log."); - if ([ariaType isEqualToString:@"ARIAApplicationMarquee"]) - return UI_STRING("marquee", "An ARIA accessibility group that acts as a marquee."); - if ([ariaType isEqualToString:@"ARIAApplicationStatus"]) - return UI_STRING("application status", "An ARIA accessibility group that acts as a status update."); - if ([ariaType isEqualToString:@"ARIAApplicationTimer"]) - return UI_STRING("timer", "An ARIA accessibility group that acts as an updating timer."); - if ([ariaType isEqualToString:@"ARIADocument"]) - return UI_STRING("document", "An ARIA accessibility group that acts as a document."); - if ([ariaType isEqualToString:@"ARIADocumentArticle"]) - return UI_STRING("article", "An ARIA accessibility group that acts as an article."); - if ([ariaType isEqualToString:@"ARIADocumentNote"]) - return UI_STRING("note", "An ARIA accessibility group that acts as a note in a document."); - if ([ariaType isEqualToString:@"ARIADocumentRegion"]) - return UI_STRING("region", "An ARIA accessibility group that acts as a distinct region in a document."); - if ([ariaType isEqualToString:@"ARIALandmarkApplication"]) - return UI_STRING("application", "An ARIA accessibility group that acts as an application."); - if ([ariaType isEqualToString:@"ARIALandmarkBanner"]) - return UI_STRING("banner", "An ARIA accessibility group that acts as a banner."); - if ([ariaType isEqualToString:@"ARIALandmarkComplementary"]) - return UI_STRING("complementary", "An ARIA accessibility group that acts as a region of complementary information."); - if ([ariaType isEqualToString:@"ARIALandmarkContentInfo"]) - return UI_STRING("content", "An ARIA accessibility group that contains content."); - if ([ariaType isEqualToString:@"ARIALandmarkMain"]) - return UI_STRING("main", "An ARIA accessibility group that is the main portion of the website."); - if ([ariaType isEqualToString:@"ARIALandmarkNavigation"]) - return UI_STRING("navigation", "An ARIA accessibility group that contains the main navigation elements of a website."); - if ([ariaType isEqualToString:@"ARIALandmarkSearch"]) - return UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website."); - if ([ariaType isEqualToString:@"ARIAUserInterfaceTooltip"]) - return UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip."); - if ([ariaType isEqualToString:@"ARIATabPanel"]) - return UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab."); - if ([ariaType isEqualToString:@"ARIADocumentMath"]) - return UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols."); - return nil; -} - -- (NSString *)AXButtonActionVerb -{ - return UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility"); -} - -- (NSString *)AXRadioButtonActionVerb -{ - return UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility"); -} - -- (NSString *)AXTextFieldActionVerb -{ - return UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility"); -} - -- (NSString *)AXCheckedCheckBoxActionVerb -{ - return UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility"); -} - -- (NSString *)AXUncheckedCheckBoxActionVerb -{ - return UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility"); -} - -- (NSString *)AXLinkActionVerb -{ - return UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility"); -} - -- (NSString *)AXMenuListPopupActionVerb -{ - return nil; -} - -- (NSString *)AXMenuListActionVerb -{ - return nil; -} - -- (NSString *)multipleFileUploadTextForNumberOfFiles:(unsigned)numberOfFiles -{ - return [NSString stringWithFormat:UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles]; -} - -- (NSString *)unknownFileSizeText -{ - return UI_STRING("Unknown", "Unknown filesize FTP directory listing item"); -} - -- (NSString*)imageTitleForFilename:(NSString*)filename width:(int)width height:(int)height -{ - return [NSString stringWithFormat:UI_STRING("%@ %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename, width, height]; -} - -- (NSString*)mediaElementLoadingStateText -{ - return UI_STRING("Loading...", "Media controller status message when the media is loading"); -} - -- (NSString*)mediaElementLiveBroadcastStateText -{ - return UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast"); -} - -- (NSString*)localizedMediaControlElementString:(NSString*)name -{ - if ([name isEqualToString:@"AudioElement"]) - return UI_STRING("audio element controller", "accessibility role description for audio element controller"); - if ([name isEqualToString:@"VideoElement"]) - return UI_STRING("video element controller", "accessibility role description for video element controller"); - - // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy. - if ([name isEqualToString:@"ControlsPanel"]) - return @""; - - if ([name isEqualToString:@"MuteButton"]) - return UI_STRING("mute", "accessibility role description for mute button"); - if ([name isEqualToString:@"UnMuteButton"]) - return UI_STRING("unmute", "accessibility role description for turn mute off button"); - if ([name isEqualToString:@"PlayButton"]) - return UI_STRING("play", "accessibility role description for play button"); - if ([name isEqualToString:@"PauseButton"]) - return UI_STRING("pause", "accessibility role description for pause button"); - if ([name isEqualToString:@"Slider"]) - return UI_STRING("movie time", "accessibility role description for timeline slider"); - if ([name isEqualToString:@"SliderThumb"]) - return UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb"); - if ([name isEqualToString:@"RewindButton"]) - return UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button"); - if ([name isEqualToString:@"ReturnToRealtimeButton"]) - return UI_STRING("return to realtime", "accessibility role description for return to real time button"); - if ([name isEqualToString:@"CurrentTimeDisplay"]) - return UI_STRING("elapsed time", "accessibility role description for elapsed time display"); - if ([name isEqualToString:@"TimeRemainingDisplay"]) - return UI_STRING("remaining time", "accessibility role description for time remaining display"); - if ([name isEqualToString:@"StatusDisplay"]) - return UI_STRING("status", "accessibility role description for movie status"); - if ([name isEqualToString:@"FullscreenButton"]) - return UI_STRING("fullscreen", "accessibility role description for enter fullscreen button"); - if ([name isEqualToString:@"SeekForwardButton"]) - return UI_STRING("fast forward", "accessibility role description for fast forward button"); - if ([name isEqualToString:@"SeekBackButton"]) - return UI_STRING("fast reverse", "accessibility role description for fast reverse button"); - if ([name isEqualToString:@"ShowClosedCaptionsButton"]) - return UI_STRING("show closed captions", "accessibility role description for show closed captions button"); - if ([name isEqualToString:@"HideClosedCaptionsButton"]) - return UI_STRING("hide closed captions", "accessibility role description for hide closed captions button"); - - ASSERT_NOT_REACHED(); - return @""; -} - -- (NSString*)localizedMediaControlElementHelpText:(NSString*)name -{ - if ([name isEqualToString:@"AudioElement"]) - return UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller"); - if ([name isEqualToString:@"VideoElement"]) - return UI_STRING("video element playback controls and status display", "accessibility role description for video element controller"); - - if ([name isEqualToString:@"MuteButton"]) - return UI_STRING("mute audio tracks", "accessibility help text for mute button"); - if ([name isEqualToString:@"UnMuteButton"]) - return UI_STRING("unmute audio tracks", "accessibility help text for un mute button"); - if ([name isEqualToString:@"PlayButton"]) - return UI_STRING("begin playback", "accessibility help text for play button"); - if ([name isEqualToString:@"PauseButton"]) - return UI_STRING("pause playback", "accessibility help text for pause button"); - if ([name isEqualToString:@"Slider"]) - return UI_STRING("movie time scrubber", "accessibility help text for timeline slider"); - if ([name isEqualToString:@"SliderThumb"]) - return UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb"); - if ([name isEqualToString:@"RewindButton"]) - return UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button"); - if ([name isEqualToString:@"ReturnToRealtimeButton"]) - return UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button"); - if ([name isEqualToString:@"CurrentTimeDisplay"]) - return UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display"); - if ([name isEqualToString:@"TimeRemainingDisplay"]) - return UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display"); - if ([name isEqualToString:@"StatusDisplay"]) - return UI_STRING("current movie status", "accessibility help text for movie status display"); - if ([name isEqualToString:@"SeekBackButton"]) - return UI_STRING("seek quickly back", "accessibility help text for fast rewind button"); - if ([name isEqualToString:@"SeekForwardButton"]) - return UI_STRING("seek quickly forward", "accessibility help text for fast forward button"); - if ([name isEqualToString:@"FullscreenButton"]) - return UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button"); - if ([name isEqualToString:@"ShowClosedCaptionsButton"]) - return UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button"); - if ([name isEqualToString:@"HideClosedCaptionsButton"]) - return UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button"); - ASSERT_NOT_REACHED(); - return @""; -} - -- (NSString*)localizedMediaTimeDescription:(float)time -{ - if (!isfinite(time)) - return UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value"); - - int seconds = (int)fabsf(time); - int days = seconds / (60 * 60 * 24); - int hours = seconds / (60 * 60); - int minutes = (seconds / 60) % 60; - seconds %= 60; - - if (days) - return [NSString stringWithFormat: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]; - else if (hours) - return [NSString stringWithFormat:UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds]; - else if (minutes) - return [NSString stringWithFormat:UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds]; - - return [NSString stringWithFormat:UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds]; -} - -- (NSString *)validationMessageValueMissingText -{ - return UI_STRING("value missing", "Validation message for required form control elements that have no value"); -} - -- (NSString *)validationMessageTypeMismatchText -{ - return UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type"); -} - -- (NSString *)validationMessagePatternMismatchText -{ - return UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern"); -} - -- (NSString *)validationMessageTooLongText -{ - return UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length"); -} - -- (NSString *)validationMessageRangeUnderflowText -{ - return UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum"); -} - -- (NSString *)validationMessageRangeOverflowText -{ - return UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum"); -} - -- (NSString *)validationMessageStepMismatchText -{ - return UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute"); -} - @end |
