diff options
| author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
| commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
| tree | f478babb801e720de7bfaee23443ffe029f58731 /Source/WebKit2/WebProcess/WebCoreSupport/mac | |
| parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
| download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 | |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebKit2/WebProcess/WebCoreSupport/mac')
9 files changed, 840 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm new file mode 100644 index 0000000..32d08b2 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm @@ -0,0 +1,85 @@ +/* + * 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. + */ + +#include "WebContextMenuClient.h" + +#include "NotImplemented.h" +#include "WebPage.h" +#include <WebCore/Frame.h> +#include <WebCore/Page.h> +#include <wtf/text/WTFString.h> + +using namespace WebCore; + +namespace WebKit { + +void WebContextMenuClient::lookUpInDictionary(Frame*) +{ + // FIXME: <rdar://problem/8750610> - Implement + notImplemented(); +} + +bool WebContextMenuClient::isSpeaking() +{ + return m_page->isSpeaking(); +} + +void WebContextMenuClient::speak(const String& string) +{ + m_page->speak(string); +} + +void WebContextMenuClient::stopSpeaking() +{ + m_page->stopSpeaking(); +} + +void WebContextMenuClient::searchWithSpotlight() +{ + // FIXME: Why do we need to search all the frames like this? + // Isn't there any function in WebCore that can do this? + // If not, can we find a place in WebCore to put this? + + Frame* mainFrame = m_page->corePage()->mainFrame(); + + Frame* selectionFrame = mainFrame; + for (; selectionFrame; selectionFrame = selectionFrame->tree()->traverseNext(mainFrame)) { + if (selectionFrame->selection()->isRange()) + break; + } + if (!selectionFrame) + selectionFrame = mainFrame; + + String selectedString = selectionFrame->displayStringModifiedByEncoding(selectionFrame->editor()->selectedText()); + + if (selectedString.isEmpty()) + return; + + NSString *convertedSelectedString = selectedString; + + [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:convertedSelectedString]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm new file mode 100644 index 0000000..d4eb3ac --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#include "WebDatabaseManager.h" + +namespace WebKit { + +NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory"; + +String WebDatabaseManager::databaseDirectory() const +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *databasesDirectory = [defaults objectForKey:WebDatabaseDirectoryDefaultsKey]; + if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]]) + databasesDirectory = @"~/Library/WebKit/Databases"; + + return [databasesDirectory stringByStandardizingPath]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm new file mode 100644 index 0000000..ce33890 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm @@ -0,0 +1,268 @@ +/* + * Copyright (C) 2006, 2010, 2011 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 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 + * 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 "WebEditorClient.h" + +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 +#include "NotImplemented.h" + +#include "WebCoreArgumentCoders.h" +#include "WebPage.h" +#include "WebFrame.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/ArchiveResource.h> +#include <WebCore/DocumentFragment.h> +#include <WebCore/DOMDocumentFragmentInternal.h> +#include <WebCore/DOMDocumentInternal.h> +#include <WebCore/FocusController.h> +#include <WebCore/Frame.h> +#include <WebCore/KeyboardEvent.h> +#include <WebCore/Page.h> +#include <WebKit/WebResource.h> +#include <WebKit/WebNSURLExtras.h> +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#import <AppKit/NSTextChecker.h> +#endif + +using namespace WebCore; + +@interface NSAttributedString (WebNSAttributedStringDetails) +- (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources; +@end + +@interface WebResource (WebResourceInternal) +- (WebCore::ArchiveResource*)_coreResource; +@end + +namespace WebKit { + +void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) +{ + if (m_page->interceptEditingKeyboardEvent(event, false)) + event->setDefaultHandled(); +} + +void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event) +{ + if (m_page->interceptEditingKeyboardEvent(event, true)) + event->setDefaultHandled(); +} + +NSString *WebEditorClient::userVisibleString(NSURL *url) +{ + return [url _web_userVisibleString]; +} + +NSURL *WebEditorClient::canonicalizeURL(NSURL *url) +{ + return [url _webkit_canonicalize]; +} + +NSURL *WebEditorClient::canonicalizeURLString(NSString *URLString) +{ + NSURL *URL = nil; + if ([URLString _webkit_looksLikeAbsoluteURL]) + URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize]; + return URL; +} + +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:kit(m_page->mainFrame()->coreFrame()->document()) + documentAttributes:dictionary + subresources:&subResources]; + for (WebResource* resource in subResources) + resources.append([resource _coreResource]); + + [dictionary release]; + return core(fragment); +} + +void WebEditorClient::setInsertionPasteboard(NSPasteboard *) +{ + // This is used only by Mail, no need to implement it now. + notImplemented(); +} + +#ifdef BUILDING_ON_TIGER +NSArray *WebEditorClient::pasteboardTypesForSelection(Frame*) +{ + notImplemented(); + return nil; +} +#endif + +static void changeWordCase(WebPage* page, SEL selector) +{ + Frame* frame = page->corePage()->focusController()->focusedOrMainFrame(); + if (!frame->editor()->canEdit()) + return; + + frame->editor()->command("selectWord").execute(); + + NSString *selectedString = frame->displayStringModifiedByEncoding(frame->editor()->selectedText()); + page->replaceSelectionWithText(frame, [selectedString performSelector:selector]); +} + +void WebEditorClient::uppercaseWord() +{ + changeWordCase(m_page, @selector(uppercaseString)); +} + +void WebEditorClient::lowercaseWord() +{ + changeWordCase(m_page, @selector(lowercaseString)); +} + +void WebEditorClient::capitalizeWord() +{ + changeWordCase(m_page, @selector(capitalizedString)); +} + +void WebEditorClient::showSubstitutionsPanel(bool) +{ + notImplemented(); +} + +bool WebEditorClient::substitutionsPanelIsShowing() +{ + notImplemented(); + return false; +} + +void WebEditorClient::toggleSmartInsertDelete() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticQuoteSubstitutionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticQuoteSubstitutionEnabled; +} + +void WebEditorClient::toggleAutomaticQuoteSubstitution() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticLinkDetectionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticLinkDetectionEnabled; +} + +void WebEditorClient::toggleAutomaticLinkDetection() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticDashSubstitutionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticDashSubstitutionEnabled; +} + +void WebEditorClient::toggleAutomaticDashSubstitution() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticTextReplacementEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticTextReplacementEnabled; +} + +void WebEditorClient::toggleAutomaticTextReplacement() +{ + // This is handled in the UI process. + ASSERT_NOT_REACHED(); +} + +bool WebEditorClient::isAutomaticSpellingCorrectionEnabled() +{ + return WebProcess::shared().textCheckerState().isAutomaticSpellingCorrectionEnabled; +} + +void WebEditorClient::toggleAutomaticSpellingCorrection() +{ + notImplemented(); +} + +void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<TextCheckingResult>& results) +{ + // FIXME: It would be nice if we wouldn't have to copy the text here. + m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results)); +} + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*) +{ + notImplemented(); +} + +void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) +{ + notImplemented(); +} + +bool WebEditorClient::isShowingCorrectionPanel() +{ + notImplemented(); + return false; +} +#endif + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm new file mode 100644 index 0000000..549d7ee --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm @@ -0,0 +1,178 @@ +/* + * 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. + */ + +#include "WebErrors.h" + +#include "WKError.h" +#include "WebError.h" +#include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> +#include <pthread.h> + +using namespace WebCore; +using namespace WebKit; + +// FIXME: We probably don't need to use NSErrors here. + +static NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIMETypeKey"; +static NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey"; +static NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey"; + +// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized +#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] + +// Policy errors +#define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description") +#define WebKitErrorDescriptionCannotShowURL UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description") +#define WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description") +#define WebKitErrorDescriptionCannotUseRestrictedPort UI_STRING("Not allowed to use restricted network port", "WebKitErrorCannotUseRestrictedPort description") + +// Plug-in and java errors +#define WebKitErrorDescriptionCannotFindPlugin UI_STRING("The plug-in can’t be found", "WebKitErrorCannotFindPlugin description") +#define WebKitErrorDescriptionCannotLoadPlugin UI_STRING("The plug-in can’t be loaded", "WebKitErrorCannotLoadPlugin description") +#define WebKitErrorDescriptionJavaUnavailable UI_STRING("Java is unavailable", "WebKitErrorJavaUnavailable description") +#define WebKitErrorDescriptionPlugInCancelledConnection UI_STRING("Plug-in cancelled", "WebKitErrorPlugInCancelledConnection description") +#define WebKitErrorDescriptionPlugInWillHandleLoad UI_STRING("Plug-in handled load", "WebKitErrorPlugInWillHandleLoad description") + +static pthread_once_t registerErrorsControl = PTHREAD_ONCE_INIT; +static void registerErrors(void); + +@interface NSError (WebKitExtras) ++ (NSError *)_webKitErrorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL; +@end + +@implementation NSError (WebKitExtras) + +static NSMutableDictionary *descriptions = nil; + ++ (void)_registerWebKitErrors +{ + pthread_once(®isterErrorsControl, registerErrors); +} + +-(id)_webkit_initWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL +{ + NSDictionary *descriptionsDict; + NSString *localizedDesc; + NSDictionary *dict; + // insert a localized string here for those folks not savvy to our category methods + descriptionsDict = [descriptions objectForKey:domain]; + localizedDesc = descriptionsDict ? [descriptionsDict objectForKey:[NSNumber numberWithInt:code]] : nil; + dict = [NSDictionary dictionaryWithObjectsAndKeys: + URL, @"NSErrorFailingURLKey", + [URL absoluteString], @"NSErrorFailingURLStringKey", + localizedDesc, NSLocalizedDescriptionKey, + nil]; + return [self initWithDomain:domain code:code userInfo:dict]; +} + ++(id)_webkit_errorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL +{ + return [[[self alloc] _webkit_initWithDomain:domain code:code URL:URL] autorelease]; +} + ++ (NSError *)_webKitErrorWithDomain:(NSString *)domain code:(int)code URL:(NSURL *)URL +{ + [self _registerWebKitErrors]; + return [self _webkit_errorWithDomain:domain code:code URL:URL]; +} + ++ (NSError *)_webKitErrorWithCode:(int)code failingURL:(NSString *)URLString +{ + return [self _webKitErrorWithDomain:WebError::webKitErrorDomain() code:code URL:[NSURL URLWithString:URLString]]; +} + ++ (void)_webkit_addErrorsWithCodesAndDescriptions:(NSDictionary *)dictionary inDomain:(NSString *)domain +{ + if (!descriptions) + descriptions = [[NSMutableDictionary alloc] init]; + + [descriptions setObject:dictionary forKey:domain]; +} + +static void registerErrors() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + // Policy errors + WebKitErrorDescriptionCannotShowMIMEType, [NSNumber numberWithInt: kWKErrorCodeCannotShowMIMEType], + WebKitErrorDescriptionCannotShowURL, [NSNumber numberWithInt: kWKErrorCodeCannotShowURL], + WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange, [NSNumber numberWithInt: kWKErrorCodeFrameLoadInterruptedByPolicyChange], + WebKitErrorDescriptionCannotUseRestrictedPort, [NSNumber numberWithInt: kWKErrorCodeCannotUseRestrictedPort], + + // Plug-in and java errors + WebKitErrorDescriptionCannotFindPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotFindPlugIn], + WebKitErrorDescriptionCannotLoadPlugin, [NSNumber numberWithInt: kWKErrorCodeCannotLoadPlugIn], + WebKitErrorDescriptionJavaUnavailable, [NSNumber numberWithInt: kWKErrorCodeJavaUnavailable], + WebKitErrorDescriptionPlugInCancelledConnection, [NSNumber numberWithInt: kWKErrorCodePlugInCancelledConnection], + WebKitErrorDescriptionPlugInWillHandleLoad, [NSNumber numberWithInt: kWKErrorCodePlugInWillHandleLoad], + nil]; + + [NSError _webkit_addErrorsWithCodesAndDescriptions:dict inDomain:WebError::webKitErrorDomain()]; + + [pool drain]; +} + +@end + +namespace WebKit { + +ResourceError cancelledError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:request.url()]; +} + +ResourceError blockedError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodeCannotUseRestrictedPort URL:request.url()]; +} + +ResourceError cannotShowURLError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodeCannotShowURL URL:request.url()]; +} + +ResourceError interruptForPolicyChangeError(const ResourceRequest& request) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodeFrameLoadInterruptedByPolicyChange URL:request.url()]; +} + +ResourceError cannotShowMIMETypeError(const ResourceResponse& response) +{ + return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:kWKErrorCodeCannotShowMIMEType URL:response.url()]; +} + +ResourceError fileDoesNotExistError(const ResourceResponse& response) +{ + return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:response.url()]; +} + +ResourceError pluginWillHandleLoadError(const ResourceResponse& response) +{ + return [NSError _webKitErrorWithDomain:WebError::webKitErrorDomain() code:kWKErrorCodePlugInWillHandleLoad URL:response.url()]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h new file mode 100644 index 0000000..994d285 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h @@ -0,0 +1,48 @@ +/* + 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. +*/ + +#ifndef WebFrameNetworkingContext_h +#define WebFrameNetworkingContext_h + +#import <WebCore/FrameNetworkingContext.h> + +namespace WebKit { + +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; +}; + +} + +#endif diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm new file mode 100644 index 0000000..570d351 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm @@ -0,0 +1,50 @@ +/* + 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; + +namespace WebKit { + +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/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm new file mode 100644 index 0000000..4d3d167 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#include "WebPopupMenu.h" + +#include "PlatformPopupMenuData.h" + +using namespace WebCore; + +namespace WebKit { + +void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData&) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h new file mode 100644 index 0000000..da0c2dd --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.h @@ -0,0 +1,31 @@ +/* + * 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 WebSystemInterface_h +#define WebSystemInterface_h + +void InitWebCoreSystemInterface(void); + +#endif /* WebSystemInterface_h */ diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm new file mode 100644 index 0000000..90b9a64 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -0,0 +1,100 @@ +/* + * Copyright (C) 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 + * 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 "WebSystemInterface.h" + +#import <WebCore/WebCoreSystemInterface.h> +#import <WebKitSystemInterface.h> + +#define INIT(function) wk##function = WK##function + +void InitWebCoreSystemInterface(void) +{ + static dispatch_once_t initOnce; + + dispatch_once(&initOnce, ^{ + INIT(AdvanceDefaultButtonPulseAnimation); + INIT(CopyCFLocalizationPreferredName); + INIT(CGContextGetShouldSmoothFonts); + INIT(CopyCONNECTProxyResponse); + INIT(CopyNSURLResponseStatusLine); + INIT(CreateCTLineWithUniCharProvider); + INIT(CreateCustomCFReadStream); + INIT(CreateNSURLConnectionDelegateProxy); + INIT(DrawBezeledTextArea); + INIT(DrawBezeledTextFieldCell); + INIT(DrawCapsLockIndicator); + INIT(DrawFocusRing); + INIT(DrawMediaSliderTrack); + INIT(DrawMediaUIPart); + INIT(DrawTextFieldCellFocusRing); + INIT(GetExtensionsForMIMEType); + INIT(GetFontInLanguageForCharacter); + INIT(GetFontInLanguageForRange); + INIT(GetGlyphTransformedAdvances); + INIT(GetGlyphsForCharacters); + INIT(GetMIMETypeForExtension); + INIT(GetNSURLResponseLastModifiedDate); + INIT(GetPreferredExtensionForMIMEType); + INIT(GetUserToBaseCTM); + INIT(GetWheelEventDeltas); + INIT(HitTestMediaUIPart); + INIT(InitializeMaximumHTTPConnectionCountPerHost); + INIT(IsLatchingWheelEvent); + INIT(MeasureMediaUIPart); + INIT(MediaControllerThemeAvailable); + INIT(PopupMenu); + INIT(QTIncludeOnlyModernMediaFileTypes); + INIT(QTMovieDataRate); + INIT(QTMovieDisableComponent); + INIT(QTMovieGetType); + INIT(QTMovieHasClosedCaptions); + INIT(QTMovieMaxTimeLoaded); + INIT(QTMovieMaxTimeLoadedChangeNotification); + INIT(QTMovieMaxTimeSeekable); + INIT(QTMovieSelectPreferredAlternates); + INIT(QTMovieSetShowClosedCaptions); + INIT(QTMovieViewSetDrawSynchronously); + INIT(SetCGFontRenderingMode); + INIT(SetCONNECTProxyAuthorizationForStream); + INIT(SetCONNECTProxyForStream); + INIT(SetCookieStoragePrivateBrowsingEnabled); + INIT(SetDragImage); + INIT(SetNSURLConnectionDefersCallbacks); + INIT(SetNSURLRequestShouldContentSniff); + INIT(SetPatternBaseCTM); + INIT(SetPatternPhaseInUserSpace); + INIT(SetUpFontCache); + INIT(SignalCFReadStreamEnd); + INIT(SignalCFReadStreamError); + INIT(SignalCFReadStreamHasBytes); + +#if !defined(BUILDING_ON_SNOW_LEOPARD) + INIT(CreateCTTypesetterWithUniCharProviderAndOptions); +#else + INIT(GetHyphenationLocationBeforeIndex); +#endif + }); +} |
