[iOS] Upstream PLATFORM(IOS) changes to Source/WebKit/
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Dec 2013 23:46:34 +0000 (23:46 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Dec 2013 23:46:34 +0000 (23:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125746

Reviewed by David Kilzer.

Source/WebKit:

* WebKit.xcodeproj/project.pbxproj: Added WebDatabaseManagerInternal.h
and iOS.xcconfig.

Source/WebKit/ios:

* WebCoreSupport/WebVisiblePosition.mm:
(-[WebVisiblePosition positionAtStartOrEndOfWord]): Changed a comment
to mention iOS rather than iPhone.

Source/WebKit/mac:

This is a straight upstreaming of the various PLATFORM(IOS) changes
made to Source/WebKit/ with the following modifications:

- Includes of <Cocoa/Cocoa.h> were generally replaced with an include
of <Foundation/Foundation.h> followed by an include of
<AppKit/AppKit.h> on non-iOS platforms. This assumes that nobody was
relying on <Cocoa/Cocoa.h>'s inclusion of <CoreData/CoreData.h>.

- Includes of <Cocoa/Cocoa.h> and <Foundation/Foundation.h> were
removed from files that include WebKitPrefix.h.

- Instances of 'iPhone (OS)' in comments were replaced with 'iOS', and
other sensitive terms were elided.

- Various PLATFORM(IOS) blocks were simplified. For instance:

    #if !PLATFORM(IOS)
    ...
    #endif
    #if PLATFORM(IOS)
    ...
    #endif

Was simplified to:

    #if !PLATFORM(IOS)
    ...
    #else
    ...
    #endif

* Configurations/Base.xcconfig:
* Configurations/DebugRelease.xcconfig:
* Configurations/Version.xcconfig:
* Configurations/WebKit.xcconfig:
* Configurations/iOS.xcconfig: Added.
* DOM/WebDOMOperations.mm:
* DefaultDelegates/WebDefaultContextMenuDelegate.mm:
* DefaultDelegates/WebDefaultEditingDelegate.m:
* DefaultDelegates/WebDefaultPolicyDelegate.m:
* DefaultDelegates/WebDefaultUIDelegate.h:
* DefaultDelegates/WebDefaultUIDelegate.m:
* History/WebBackForwardList.mm:
* History/WebHistory.mm:
* History/WebHistoryItem.mm:
* History/WebURLsWithTitles.m:
* Misc/WebCache.mm:
* Misc/WebDownload.mm:
* Misc/WebElementDictionary.mm:
* Misc/WebIconDatabase.mm:
* Misc/WebIconDatabaseInternal.h:
* Misc/WebKitNSStringExtras.mm:
* Misc/WebKitSystemBits.m:
* Misc/WebKitVersionChecks.h:
* Misc/WebKitVersionChecks.m:
* Misc/WebLocalizableStrings.mm:
* Misc/WebNSArrayExtras.h:
* Misc/WebNSArrayExtras.m:
* Misc/WebNSControlExtras.h:
* Misc/WebNSControlExtras.m:
* Misc/WebNSDictionaryExtras.h:
* Misc/WebNSDictionaryExtras.m:
* Misc/WebNSEventExtras.m:
* Misc/WebNSFileManagerExtras.mm:
* Misc/WebNSImageExtras.h:
* Misc/WebNSImageExtras.m:
* Misc/WebNSPasteboardExtras.mm:
* Misc/WebNSPrintOperationExtras.h:
* Misc/WebNSPrintOperationExtras.m:
* Misc/WebNSURLExtras.mm:
* Misc/WebNSViewExtras.m:
* Misc/WebNSWindowExtras.m:
* Panels/WebAuthenticationPanel.h:
* Panels/WebAuthenticationPanel.m:
* Panels/WebPanelAuthenticationHandler.m:
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
* Plugins/WebBasePluginPackage.h:
* Plugins/WebBasePluginPackage.mm:
* Plugins/WebJavaPlugIn.h:
* Plugins/WebPluginContainerCheck.mm:
* Plugins/WebPluginController.h:
* Plugins/WebPluginController.mm:
* Plugins/WebPluginDatabase.mm:
* Plugins/WebPluginPackage.mm:
* Plugins/WebPluginsPrivate.m:
* Storage/WebDatabaseManager.mm:
* Storage/WebDatabaseManagerClient.h:
* Storage/WebDatabaseManagerClient.mm:
* Storage/WebDatabaseManagerInternal.h: Added.
* Storage/WebStorageManager.mm:
* WebCoreSupport/CorrectionPanel.h:
* WebCoreSupport/WebAlternativeTextClient.h:
* WebCoreSupport/WebApplicationCache.mm:
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
* WebCoreSupport/WebContextMenuClient.mm:
* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
* WebCoreSupport/WebFrameNetworkingContext.h:
* WebCoreSupport/WebFrameNetworkingContext.mm:
* WebCoreSupport/WebGeolocationClient.h:
* WebCoreSupport/WebGeolocationClient.mm:
* WebCoreSupport/WebJavaScriptTextInputPanel.m:
* WebCoreSupport/WebKeyGenerator.mm:
* WebCoreSupport/WebNotificationClient.mm:
* WebCoreSupport/WebOpenPanelResultListener.mm:
* WebCoreSupport/WebSecurityOrigin.mm:
* WebCoreSupport/WebSystemInterface.mm:
* WebKitPrefix.h:
* WebView/WebArchive.mm:
* WebView/WebClipView.h:
* WebView/WebDataSource.mm:
* WebView/WebDelegateImplementationCaching.h:
* WebView/WebDelegateImplementationCaching.mm:
* WebView/WebDeviceOrientation.mm:
* WebView/WebDocumentInternal.h:
* WebView/WebDocumentLoaderMac.mm:
* WebView/WebDynamicScrollBarsViewInternal.h:
* WebView/WebFormDelegate.m:
* WebView/WebFrame.mm:
* WebView/WebFrameInternal.h:
* WebView/WebFrameView.mm:
* WebView/WebFullScreenController.h:
* WebView/WebFullScreenController.mm:
* WebView/WebHTMLRepresentation.mm:
* WebView/WebHTMLView.mm:
* WebView/WebHTMLViewInternal.h:
* WebView/WebPDFDocumentExtras.h:
* WebView/WebPDFDocumentExtras.mm:
* WebView/WebPDFRepresentation.h:
* WebView/WebPDFRepresentation.mm:
* WebView/WebPDFView.h:
* WebView/WebPDFView.mm:
* WebView/WebPreferences.mm:
* WebView/WebResource.mm:
* WebView/WebTextCompletionController.h:
* WebView/WebTextIterator.mm:
* WebView/WebView.mm:
* WebView/WebViewData.h:
* WebView/WebViewData.mm:
* WebView/WebViewInternal.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161185 268f45cc-cd09-0410-ab3c-d52691b4dbfc

117 files changed:
Source/WebKit/ChangeLog
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/Base.xcconfig
Source/WebKit/mac/Configurations/DebugRelease.xcconfig
Source/WebKit/mac/Configurations/Version.xcconfig
Source/WebKit/mac/Configurations/WebKit.xcconfig
Source/WebKit/mac/Configurations/iOS.xcconfig [new file with mode: 0644]
Source/WebKit/mac/DOM/WebDOMOperations.mm
Source/WebKit/mac/DefaultDelegates/WebDefaultContextMenuDelegate.mm
Source/WebKit/mac/DefaultDelegates/WebDefaultEditingDelegate.m
Source/WebKit/mac/DefaultDelegates/WebDefaultPolicyDelegate.m
Source/WebKit/mac/DefaultDelegates/WebDefaultUIDelegate.h
Source/WebKit/mac/DefaultDelegates/WebDefaultUIDelegate.m
Source/WebKit/mac/History/WebBackForwardList.mm
Source/WebKit/mac/History/WebHistory.mm
Source/WebKit/mac/History/WebHistoryItem.mm
Source/WebKit/mac/History/WebURLsWithTitles.m
Source/WebKit/mac/Misc/WebCache.mm
Source/WebKit/mac/Misc/WebDownload.mm
Source/WebKit/mac/Misc/WebElementDictionary.mm
Source/WebKit/mac/Misc/WebIconDatabase.mm
Source/WebKit/mac/Misc/WebIconDatabaseInternal.h
Source/WebKit/mac/Misc/WebKitNSStringExtras.mm
Source/WebKit/mac/Misc/WebKitSystemBits.m
Source/WebKit/mac/Misc/WebKitVersionChecks.h
Source/WebKit/mac/Misc/WebKitVersionChecks.m
Source/WebKit/mac/Misc/WebLocalizableStrings.mm
Source/WebKit/mac/Misc/WebNSArrayExtras.h
Source/WebKit/mac/Misc/WebNSArrayExtras.m
Source/WebKit/mac/Misc/WebNSControlExtras.h
Source/WebKit/mac/Misc/WebNSControlExtras.m
Source/WebKit/mac/Misc/WebNSDictionaryExtras.h
Source/WebKit/mac/Misc/WebNSDictionaryExtras.m
Source/WebKit/mac/Misc/WebNSEventExtras.m
Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm
Source/WebKit/mac/Misc/WebNSImageExtras.h
Source/WebKit/mac/Misc/WebNSImageExtras.m
Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm
Source/WebKit/mac/Misc/WebNSPrintOperationExtras.h
Source/WebKit/mac/Misc/WebNSPrintOperationExtras.m
Source/WebKit/mac/Misc/WebNSURLExtras.mm
Source/WebKit/mac/Misc/WebNSViewExtras.m
Source/WebKit/mac/Misc/WebNSWindowExtras.m
Source/WebKit/mac/Panels/WebAuthenticationPanel.h
Source/WebKit/mac/Panels/WebAuthenticationPanel.m
Source/WebKit/mac/Panels/WebPanelAuthenticationHandler.m
Source/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
Source/WebKit/mac/Plugins/WebBasePluginPackage.h
Source/WebKit/mac/Plugins/WebBasePluginPackage.mm
Source/WebKit/mac/Plugins/WebJavaPlugIn.h
Source/WebKit/mac/Plugins/WebPluginContainerCheck.mm
Source/WebKit/mac/Plugins/WebPluginController.h
Source/WebKit/mac/Plugins/WebPluginController.mm
Source/WebKit/mac/Plugins/WebPluginDatabase.mm
Source/WebKit/mac/Plugins/WebPluginPackage.mm
Source/WebKit/mac/Plugins/WebPluginsPrivate.m
Source/WebKit/mac/Storage/WebDatabaseManager.mm
Source/WebKit/mac/Storage/WebDatabaseManagerClient.h
Source/WebKit/mac/Storage/WebDatabaseManagerClient.mm
Source/WebKit/mac/Storage/WebDatabaseManagerInternal.h [new file with mode: 0644]
Source/WebKit/mac/Storage/WebStorageManager.mm
Source/WebKit/mac/WebCoreSupport/CorrectionPanel.h
Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.h
Source/WebKit/mac/WebCoreSupport/WebApplicationCache.mm
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
Source/WebKit/mac/WebCoreSupport/WebEditorClient.h
Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm
Source/WebKit/mac/WebCoreSupport/WebGeolocationClient.h
Source/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm
Source/WebKit/mac/WebCoreSupport/WebJavaScriptTextInputPanel.m
Source/WebKit/mac/WebCoreSupport/WebKeyGenerator.mm
Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm
Source/WebKit/mac/WebCoreSupport/WebOpenPanelResultListener.mm
Source/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit/mac/WebKitPrefix.h
Source/WebKit/mac/WebView/WebArchive.mm
Source/WebKit/mac/WebView/WebClipView.h
Source/WebKit/mac/WebView/WebDataSource.mm
Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h
Source/WebKit/mac/WebView/WebDelegateImplementationCaching.mm
Source/WebKit/mac/WebView/WebDeviceOrientation.mm
Source/WebKit/mac/WebView/WebDocumentInternal.h
Source/WebKit/mac/WebView/WebDocumentLoaderMac.mm
Source/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h
Source/WebKit/mac/WebView/WebFormDelegate.m
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebFrameInternal.h
Source/WebKit/mac/WebView/WebFrameView.mm
Source/WebKit/mac/WebView/WebFullScreenController.h
Source/WebKit/mac/WebView/WebFullScreenController.mm
Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebHTMLViewInternal.h
Source/WebKit/mac/WebView/WebPDFDocumentExtras.h
Source/WebKit/mac/WebView/WebPDFDocumentExtras.mm
Source/WebKit/mac/WebView/WebPDFRepresentation.h
Source/WebKit/mac/WebView/WebPDFRepresentation.mm
Source/WebKit/mac/WebView/WebPDFView.h
Source/WebKit/mac/WebView/WebPDFView.mm
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebResource.mm
Source/WebKit/mac/WebView/WebTextCompletionController.h
Source/WebKit/mac/WebView/WebTextIterator.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewData.h
Source/WebKit/mac/WebView/WebViewData.mm
Source/WebKit/mac/WebView/WebViewInternal.h

index fbec853..eb4e4d7 100644 (file)
@@ -1,3 +1,13 @@
+2013-12-31  Andy Estes  <aestes@apple.com>
+
+        [iOS] Upstream PLATFORM(IOS) changes to Source/WebKit/
+        https://bugs.webkit.org/show_bug.cgi?id=125746
+
+        Reviewed by David Kilzer.
+
+        * WebKit.xcodeproj/project.pbxproj: Added WebDatabaseManagerInternal.h
+        and iOS.xcconfig.
+
 2013-12-30  Martin Robinson  <mrobinson@igalia.com>
 
         [CMake] [GTK] Add support for GObject introspection
 
         * PlatformGTK.cmake: Use the new derived source variables.
 
-2013-12-23  Andy Estes  <aestes@apple.com>
-
-        Roll out r161043. It broke 32-bit Mac builds.
-
-2013-12-23  Andy Estes  <aestes@apple.com>
-
-        [iOS] Upstream PLATFORM(IOS) changes to Source/WebKit/
-        https://bugs.webkit.org/show_bug.cgi?id=125746
-
-        Reviewed by David Kilzer.
-
-        * WebKit.xcodeproj/project.pbxproj: Added WebDatabaseManagerInternal.h
-        and iOS.xcconfig.
-
 2013-12-22  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK][CMake] libtool-compatible soversion calculation
index 613c46e..9d33638 100644 (file)
                5158F6EF106D862A00AF457C /* WebHistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5158F6EE106D862A00AF457C /* WebHistoryDelegate.h */; };
                5185F62610712B80007AA393 /* WebNavigationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 5185F62510712B80007AA393 /* WebNavigationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5185F62810712B97007AA393 /* WebNavigationData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F62710712B97007AA393 /* WebNavigationData.mm */; };
+               51AEDEF10CECF45700854328 /* WebDatabaseManagerInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 51AEDEF00CECF45700854328 /* WebDatabaseManagerInternal.h */; };
                51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */; };
                51C714FB0B20F79F00E5E33C /* WebBackForwardListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C714FA0B20F79F00E5E33C /* WebBackForwardListInternal.h */; };
                51CBFCAD0D10E6C5002DBF51 /* WebCachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFCAC0D10E6C5002DBF51 /* WebCachedFramePlatformData.h */; };
                51A8B579042834F700CA2D3A /* WebView.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                51A8B57A042834F700CA2D3A /* WebView.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebView.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                51A8B57D0428353A00CA2D3A /* WebViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebViewPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               51AEDEF00CECF45700854328 /* WebDatabaseManagerInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseManagerInternal.h; sourceTree = "<group>"; };
                51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseDelegate.h; sourceTree = "<group>"; };
                51C714FA0B20F79F00E5E33C /* WebBackForwardListInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListInternal.h; sourceTree = "<group>"; };
                51CBFCAC0D10E6C5002DBF51 /* WebCachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCachedFramePlatformData.h; sourceTree = "<group>"; };
                F834AAD60E64B1C700E2737C /* WebTextIterator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextIterator.mm; sourceTree = "<group>"; };
                F8CA15B5029A39D901000122 /* WebAuthenticationPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebAuthenticationPanel.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F8CA15B6029A39D901000122 /* WebAuthenticationPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebAuthenticationPanel.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               FEE7D6910D99B06A005351F6 /* iOS.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = iOS.xcconfig; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                1C904FD50BA9DD0F0081E9D0 /* Base.xcconfig */,
                                1C904FD40BA9DD0F0081E9D0 /* DebugRelease.xcconfig */,
                                449098B90F8F82DF0076A327 /* FeatureDefines.xcconfig */,
+                               FEE7D6910D99B06A005351F6 /* iOS.xcconfig */,
                                1C904FD30BA9DD0F0081E9D0 /* Version.xcconfig */,
                                1C904FD20BA9DD0F0081E9D0 /* WebKit.xcconfig */,
                        );
                                511F3FD10CECC88F00852565 /* WebDatabaseManager.mm */,
                                511F3FD30CECC88F00852565 /* WebDatabaseManagerClient.h */,
                                511F3FD40CECC88F00852565 /* WebDatabaseManagerClient.mm */,
+                               51AEDEF00CECF45700854328 /* WebDatabaseManagerInternal.h */,
                                511F3FD20CECC88F00852565 /* WebDatabaseManagerPrivate.h */,
                                A5DEFC0D11D5343E00885273 /* WebDatabaseQuotaManager.h */,
                                A5DEFC0E11D5343E00885273 /* WebDatabaseQuotaManager.mm */,
                                939810160824BF01008DF038 /* WebCoreStatistics.h in Headers */,
                                93E2A1A4123B0B3C009FE12A /* WebDashboardRegion.h in Headers */,
                                511F3FD70CECC88F00852565 /* WebDatabaseManagerClient.h in Headers */,
+                               51AEDEF10CECF45700854328 /* WebDatabaseManagerInternal.h in Headers */,
                                511F3FD60CECC88F00852565 /* WebDatabaseManagerPrivate.h in Headers */,
                                A5DEFC0F11D5343E00885273 /* WebDatabaseQuotaManager.h in Headers */,
                                9398104B0824BF01008DF038 /* WebDataSource.h in Headers */,
index c1ecaa7..ab2e722 100644 (file)
@@ -1,17 +1,4 @@
-2013-12-27  Daniel Bates  <dabates@apple.com>
-
-        [iOS] Upstream WebCore/page changes
-        https://bugs.webkit.org/show_bug.cgi?id=126180
-
-        Reviewed by Darin Adler.
-
-        * WebCoreSupport/WebChromeClientIOS.mm: Substitute ENABLE(IOS_TOUCH_EVENTS) for ENABLE(TOUCH_EVENTS).
-
-2013-12-23  Andy Estes  <aestes@apple.com>
-
-        Roll out r161043. It broke 32-bit Mac builds.
-
-2013-12-23  Andy Estes  <aestes@apple.com>
+2013-12-31  Andy Estes  <aestes@apple.com>
 
         [iOS] Upstream PLATFORM(IOS) changes to Source/WebKit/
         https://bugs.webkit.org/show_bug.cgi?id=125746
@@ -22,6 +9,15 @@
         (-[WebVisiblePosition positionAtStartOrEndOfWord]): Changed a comment
         to mention iOS rather than iPhone.
 
+2013-12-27  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Upstream WebCore/page changes
+        https://bugs.webkit.org/show_bug.cgi?id=126180
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebChromeClientIOS.mm: Substitute ENABLE(IOS_TOUCH_EVENTS) for ENABLE(TOUCH_EVENTS).
+
 2013-12-04  Brian J. Burg  <burg@cs.washington.edu>
 
         Consolidate various frame snapshot capabilities.
index c5d7b4e..84f3c5a 100644 (file)
@@ -301,7 +301,7 @@ static inline SelectionDirection toSelectionDirection(WebTextAdjustmentDirection
 {
     // Ripped from WebCore::Frame::moveSelectionToStartOrEndOfCurrentWord
     
-    // Note: this is the iPhone notion, not the unicode notion.
+    // Note: this is the iOS notion, not the unicode notion.
     // Here, a word starts with non-whitespace or at the start of a line and
     // ends at the next whitespace, or at the end of a line.
     
index 62eec7c..30de075 100644 (file)
@@ -1,21 +1,4 @@
-2013-12-25  Commit Queue  <commit-queue@webkit.org>
-
-        Unreviewed, rolling out r161033 and r161074.
-        http://trac.webkit.org/changeset/161033
-        http://trac.webkit.org/changeset/161074
-        https://bugs.webkit.org/show_bug.cgi?id=126240
-
-        Oliver says that a rollout would be better (Requested by ap on
-        #webkit).
-
-        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
-        (WebKit::NetscapePluginInstanceProxy::setProperty):
-
-2013-12-23  Andy Estes  <aestes@apple.com>
-
-        Roll out r161043. It broke 32-bit Mac builds.
-
-2013-12-23  Andy Estes  <aestes@apple.com>
+2013-12-31  Andy Estes  <aestes@apple.com>
 
         [iOS] Upstream PLATFORM(IOS) changes to Source/WebKit/
         https://bugs.webkit.org/show_bug.cgi?id=125746
         * WebView/WebViewData.mm:
         * WebView/WebViewInternal.h:
 
+2013-12-25  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r161033 and r161074.
+        http://trac.webkit.org/changeset/161033
+        http://trac.webkit.org/changeset/161074
+        https://bugs.webkit.org/show_bug.cgi?id=126240
+
+        Oliver says that a rollout would be better (Requested by ap on
+        #webkit).
+
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::setProperty):
+
 2013-12-23  Oliver Hunt  <oliver@apple.com>
 
         Refactor PutPropertySlot to be aware of custom properties
index 2ccec9f..99eba83 100644 (file)
@@ -19,7 +19,9 @@
 // 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. 
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "iOS.xcconfig"
 
 CLANG_CXX_LANGUAGE_STANDARD = gnu++0x;
 CLANG_CXX_LIBRARY = libc++;
@@ -78,7 +80,10 @@ DEBUG_DEFINES_normal = NDEBUG;
 DEBUG_DEFINES = $(DEBUG_DEFINES_$(CURRENT_VARIANT));
 
 GCC_OPTIMIZATION_LEVEL = $(GCC_OPTIMIZATION_LEVEL_$(CURRENT_VARIANT));
-GCC_OPTIMIZATION_LEVEL_normal = 2;
+GCC_OPTIMIZATION_LEVEL_normal = $(GCC_OPTIMIZATION_LEVEL_normal_$(PLATFORM_NAME));
+GCC_OPTIMIZATION_LEVEL_normal_iphoneos = 3;
+GCC_OPTIMIZATION_LEVEL_normal_iphonesimulator = 3;
+GCC_OPTIMIZATION_LEVEL_normal_macosx = 2;
 GCC_OPTIMIZATION_LEVEL_debug = 0;
 
 STRIP_INSTALLED_PRODUCT = $(STRIP_INSTALLED_PRODUCT_$(CURRENT_VARIANT));
@@ -89,10 +94,14 @@ STRIP_INSTALLED_PRODUCT_debug = NO;
 // building the MiG bindings for WebKitPluginClient even when the functions that the bindings wrap are not built.
 DEAD_CODE_STRIPPING = YES;
 
-SECTORDER_FLAGS = -Wl,-order_file,mac/WebKit.order;
+SECTORDER_FLAGS = $(SECTORDER_FLAGS_$(PLATFORM_NAME));
+SECTORDER_FLAGS_iphoneos = -Wl,-order_file,$(SDKROOT)/AppleInternal/OrderFiles/WebKit.order;
+SECTORDER_FLAGS_macosx = -Wl,-order_file,mac/WebKit.order;
 
 SDKROOT = macosx.internal;
 
+SUPPORTED_PLATFORMS = iphonesimulator iphoneos macosx;
+
 TOOLCHAINS = $(TOOLCHAINS_$(PLATFORM_NAME));
 TOOLCHAINS_iphoneos = $(TOOLCHAINS);
 TOOLCHAINS_iphonesimulator = $(TOOLCHAINS);
index bf3a981..08cb51d 100644 (file)
@@ -29,8 +29,8 @@ ARCHS = $(ARCHS_STANDARD_32_64_BIT);
 ONLY_ACTIVE_ARCH = YES;
 
 MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(PLATFORM_NAME));
-MACOSX_DEPLOYMENT_TARGET_iphoneos = 10.5;
-MACOSX_DEPLOYMENT_TARGET_iphonesimulator = 10.5;
+MACOSX_DEPLOYMENT_TARGET_iphoneos = 10.8;
+MACOSX_DEPLOYMENT_TARGET_iphonesimulator = 10.8;
 MACOSX_DEPLOYMENT_TARGET_macosx = $(MACOSX_DEPLOYMENT_TARGET_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
 MACOSX_DEPLOYMENT_TARGET_macosx_1080 = 10.8;
 MACOSX_DEPLOYMENT_TARGET_macosx_1090 = 10.9;
index 805df84..6789618 100644 (file)
@@ -32,7 +32,7 @@ SHORT_VERSION_STRING = $(SHORT_VERSION_STRING_$(CONFIGURATION))
 
 // The system version prefix is based on the current system version.
 SYSTEM_VERSION_PREFIX = $(SYSTEM_VERSION_PREFIX_$(PLATFORM_NAME));
-SYSTEM_VERSION_PREFIX_iphoneos = 6; // iPhone OS is most like SnowLeopard currently.
+SYSTEM_VERSION_PREFIX_iphoneos = 8;
 SYSTEM_VERSION_PREFIX_iphonesimulator = $(SYSTEM_VERSION_PREFIX_iphoneos);
 SYSTEM_VERSION_PREFIX_macosx = $(SYSTEM_VERSION_PREFIX_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
 SYSTEM_VERSION_PREFIX_macosx_1080 = 8;
index 229857e..25cb75b 100644 (file)
@@ -33,9 +33,16 @@ EXPORTED_SYMBOLS_FILE = $(EXPORTED_SYMBOLS_FILE_$(CURRENT_ARCH));
 EXPORTED_SYMBOLS_FILE_ = mac/WebKit.exp;
 EXPORTED_SYMBOLS_FILE_armv6 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
 EXPORTED_SYMBOLS_FILE_armv7 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
-EXPORTED_SYMBOLS_FILE_i386 = mac/WebKit.exp;
+EXPORTED_SYMBOLS_FILE_armv7f = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
+EXPORTED_SYMBOLS_FILE_armv7s = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
+EXPORTED_SYMBOLS_FILE_arm64 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
+EXPORTED_SYMBOLS_FILE_i386 = $(EXPORTED_SYMBOLS_FILE_i386_$(PLATFORM_NAME));
+EXPORTED_SYMBOLS_FILE_i386_iphonesimulator = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
+EXPORTED_SYMBOLS_FILE_i386_macosx = mac/WebKit.exp;
 EXPORTED_SYMBOLS_FILE_ppc = mac/WebKit.exp;
-EXPORTED_SYMBOLS_FILE_x86_64 = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.LP64.exp;
+EXPORTED_SYMBOLS_FILE_x86_64 = $(EXPORTED_SYMBOLS_FILE_x86_64_$(PLATFORM_NAME));
+EXPORTED_SYMBOLS_FILE_x86_64_iphonesimulator = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.generated.exp;
+EXPORTED_SYMBOLS_FILE_x86_64_macosx = $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.LP64.exp;
 
 FRAMEWORK_SEARCH_PATHS = $(FRAMEWORK_SEARCH_PATHS_$(PLATFORM_NAME));
 FRAMEWORK_SEARCH_PATHS_iphoneos = $(FRAMEWORK_SEARCH_PATHS_iphoneos_$(CONFIGURATION));
@@ -54,7 +61,7 @@ OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS);
 
 GCC_PREFIX_HEADER = mac/WebKitPrefix.h;
 GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) FRAMEWORK_NAME=WebKit WEBKIT_VERSION_MIN_REQUIRED=WEBKIT_VERSION_LATEST $(GCC_PREPROCESSOR_DEFINITIONS);
-HEADER_SEARCH_PATHS = $(WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH) $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(WEBCORE_PRIVATE_HEADERS_DIR)/icu "${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit" $(HEADER_SEARCH_PATHS);
+HEADER_SEARCH_PATHS = $(WEBKITSYSTEMINTERFACE_STATIC_LIBRARY_HEADERS_FOLDER_PATH) $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(WEBCORE_PRIVATE_HEADERS_DIR)/icu "$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit" "$(BUILT_PRODUCTS_DIR)/usr/local/include" $(HEADER_SEARCH_PATHS);
 INFOPLIST_FILE = mac/Info.plist;
 INSTALL_PATH = $(INSTALL_PATH_$(PLATFORM_NAME));
 INSTALL_PATH_iphoneos = $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;
@@ -73,7 +80,7 @@ UMBRELLA_FRAMEWORKS_DIR = $(PRODUCTION_FRAMEWORKS_DIR)/WebKit.framework/Versions
 
 OTHER_LDFLAGS_BASE = -licucore -framework JavaScriptCore -framework QuartzCore -framework WebCore;
 OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_BASE) $(OTHER_LDFLAGS_$(PLATFORM_NAME));
-OTHER_LDFLAGS_iphoneos = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO;
+OTHER_LDFLAGS_iphoneos = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -lMobileGestalt;
 OTHER_LDFLAGS_iphonesimulator = $(OTHER_LDFLAGS_iphoneos);
 OTHER_LDFLAGS_macosx = -sub_umbrella WebCore -framework Carbon -framework Cocoa -framework DiskArbitration -framework IOKit -framework OpenGL -framework Security;
 
diff --git a/Source/WebKit/mac/Configurations/iOS.xcconfig b/Source/WebKit/mac/Configurations/iOS.xcconfig
new file mode 100644 (file)
index 0000000..177b319
--- /dev/null
@@ -0,0 +1 @@
+#include "<DEVELOPER_DIR>/AppleInternal/XcodeConfig/AspenFamily.xcconfig"
index 9e3ece7..e6f268e 100644 (file)
@@ -91,6 +91,42 @@ using namespace JSC;
     return [webArchive autorelease];
 }
 
+#if PLATFORM(IOS)
+- (BOOL)isHorizontalWritingMode
+{
+    Node* node = core(self);
+    if (!node)
+        return YES;
+    
+    RenderObject* renderer = node->renderer();
+    if (!renderer)
+        return YES;
+    
+    return renderer->style().isHorizontalWritingMode();
+}
+
+- (void)hidePlaceholder
+{
+    if (![self isKindOfClass:[DOMHTMLInputElement class]]
+        && ![self isKindOfClass:[DOMHTMLTextAreaElement class]])
+        return;
+    
+    Node *node = core(self);
+    HTMLTextFormControlElement *formControl = static_cast<HTMLTextFormControlElement *>(node);
+    formControl->hidePlaceholder();
+}
+
+- (void)showPlaceholderIfNecessary
+{
+    if (![self isKindOfClass:[DOMHTMLInputElement class]]
+        && ![self isKindOfClass:[DOMHTMLTextAreaElement class]])
+        return;
+    
+    HTMLTextFormControlElement *formControl = static_cast<HTMLTextFormControlElement *>(core(self));
+    formControl->showPlaceholderIfNecessary();
+}
+#endif
+
 @end
 
 @implementation DOMNode (WebDOMNodeOperationsPendingPublic)
index ac20be2..47ce64a 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebDefaultContextMenuDelegate.h"
 
 #import "WebDOMOperations.h"
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index f850dd6..01f9043 100644 (file)
@@ -26,8 +26,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <Cocoa/Cocoa.h>
-
 #import <WebKit/WebDefaultEditingDelegate.h>
 
 #import <WebKit/DOM.h>
@@ -102,9 +100,21 @@ static WebDefaultEditingDelegate *sharedDelegate = nil;
     return NO;
 }
 
+#if !PLATFORM(IOS)
 - (void)webView:(WebView *)webView didWriteSelectionToPasteboard:(NSPasteboard *)pasteboard
 {
 }
+#else
+- (NSArray *)supportedPasteboardTypesForCurrentSelection
+{
+    return nil;
+}
+
+- (DOMDocumentFragment *)documentFragmentForPasteboardItemAtIndex:(NSInteger)index
+{
+    return nil;
+}
+#endif
 
 - (void)webViewDidBeginEditing:(NSNotification *)notification
 {
index bad87d5..b12b40d 100644 (file)
@@ -91,7 +91,9 @@ static WebDefaultPolicyDelegate *sharedDelegate = nil;
         // A file URL shouldn't fall through to here, but if it did,
         // it would be a security risk to open it.
         if (![[request URL] isFileURL]) {
+#if !PLATFORM(IOS)
             [[NSWorkspace sharedWorkspace] openURL:[request URL]];
+#endif
         }
         [listener ignore];
     }
index 4315121..bf7d206 100644 (file)
@@ -30,7 +30,9 @@
 
 @interface WebDefaultUIDelegate : NSObject
 {
+#if !PLATFORM(IOS)
     IBOutlet NSMenu *defaultMenu;
+#endif
 }
 + (WebDefaultUIDelegate *)sharedUIDelegate;
 @end
index e17d8fb..57a7098 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <Cocoa/Cocoa.h>
+#import "WebDefaultUIDelegate.h"
 
-#import <Foundation/NSURLRequest.h>
-
-#import <WebKit/WebDefaultUIDelegate.h>
-#import <WebKit/WebJavaScriptTextInputPanel.h>
-#import <WebKit/WebView.h>
-#import <WebKit/WebUIDelegatePrivate.h>
-#import <WebKit/DOM.h>
+#import "WebJavaScriptTextInputPanel.h"
 #import "WebTypesInternal.h"
+#import "WebUIDelegatePrivate.h"
+#import "WebView.h"
+
+#if PLATFORM(IOS)
+#import <WebCore/WAKViewPrivate.h>
+#import <WebCore/WAKWindow.h>
+#import <WebCore/WKViewPrivate.h>
+#endif
 
+#if !PLATFORM(IOS)
 @interface NSApplication (DeclarationStolenFromAppKit)
 - (void)_cycleWindowsReversed:(BOOL)reversed;
 @end
+#endif
 
 @implementation WebDefaultUIDelegate
 
@@ -67,25 +71,38 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
     return nil;
 }
 
+#if PLATFORM(IOS)
+- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request userGesture:(BOOL)userGesture
+{
+    return nil;
+}
+#endif
+
 - (void)webViewShow: (WebView *)wv
 {
 }
 
 - (void)webViewClose: (WebView *)wv
 {
+#if !PLATFORM(IOS)
     [[wv window] close];
+#endif
 }
 
 - (void)webViewFocus: (WebView *)wv
 {
+#if !PLATFORM(IOS)
     [[wv window] makeKeyAndOrderFront:wv];
+#endif
 }
 
 - (void)webViewUnfocus: (WebView *)wv
 {
+#if !PLATFORM(IOS)
     if ([[wv window] isKeyWindow] || [[[wv window] attachedSheet] isKeyWindow]) {
         [NSApp _cycleWindowsReversed:FALSE];
     }
+#endif
 }
 
 - (NSResponder *)webViewFirstResponder: (WebView *)wv
@@ -131,19 +148,27 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
 
 - (BOOL)webViewIsResizable: (WebView *)wv
 {
+#if PLATFORM(IOS)
+    return NO;
+#else
     return [[wv window] showsResizeIndicator];
+#endif
 }
 
 - (void)webView: (WebView *)wv setResizable:(BOOL)resizable
 {
+#if !PLATFORM(IOS)
     // FIXME: This doesn't actually change the resizability of the window,
     // only visibility of the indicator.
     [[wv window] setShowsResizeIndicator:resizable];
+#endif
 }
 
 - (void)webView: (WebView *)wv setFrame:(NSRect)frame
 {
+#if !PLATFORM(IOS)
     [[wv window] setFrame:frame display:YES];
+#endif
 }
 
 - (NSRect)webViewFrame: (WebView *)wv
@@ -165,6 +190,7 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
 
 - (NSString *)webView: (WebView *)wv runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame
 {
+#if !PLATFORM(IOS)
     WebJavaScriptTextInputPanel *panel = [[WebJavaScriptTextInputPanel alloc] initWithPrompt:prompt text:defaultText];
     [panel showWindow:nil];
     NSString *result;
@@ -176,6 +202,9 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
     [[panel window] close];
     [panel release];
     return result;
+#else
+    return nil;
+#endif
 }
 
 - (void)webView: (WebView *)wv runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener
@@ -188,6 +217,7 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
 }
 
 
+#if !PLATFORM(IOS)
 - (BOOL)webView:(WebView *)webView shouldBeginDragForElement:(NSDictionary *)element dragImage:(NSImage *)dragImage mouseDownEvent:(NSEvent *)mouseDownEvent mouseDraggedEvent:(NSEvent *)mouseDraggedEvent
 {
     return YES;
@@ -210,6 +240,7 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
 - (void)webView:(WebView *)webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard
 {
 }
+#endif
 
 - (void)webView:(WebView *)sender didDrawRect:(NSRect)rect
 {
@@ -219,6 +250,7 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
 {
 }
 
+#if !PLATFORM(IOS)
 - (void)webView:(WebView *)sender willPopupMenu:(NSMenu *)menu
 {
 }
@@ -226,6 +258,7 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
 - (void)webView:(WebView *)sender contextMenuItemSelected:(NSMenuItem *)item forElement:(NSDictionary *)element
 {
 }
+#endif
 
 - (void)webView:(WebView *)sender exceededApplicationCacheOriginQuotaForSecurityOrigin:(WebSecurityOrigin *)origin totalSpaceNeeded:(NSUInteger)totalSpaceNeeded
 {
@@ -241,4 +274,10 @@ static WebDefaultUIDelegate *sharedDelegate = nil;
     return nil;
 }
 
+#if PLATFORM(IOS)
+- (void)webViewSupportedOrientationsUpdated:(WebView *)sender
+{
+}
+#endif
+
 @end
index 4befe66..550106d 100644 (file)
@@ -103,9 +103,11 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
@@ -164,6 +166,54 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
     core(self)->removeItem(core(item));
 }
 
+#if PLATFORM(IOS)
+
+// FIXME: Move into WebCore the code that deals directly with WebCore::BackForwardList.
+
+#define WebBackForwardListDictionaryEntriesKey @"entries"
+#define WebBackForwardListDictionaryCapacityKey @"capacity"
+#define WebBackForwardListDictionaryCurrentKey @"current"
+
+- (NSDictionary *)dictionaryRepresentation
+{
+    BackForwardList *coreBFList = core(self);
+    
+    HistoryItemVector historyItems = coreBFList->entries();
+    NSMutableArray *entriesArray = [[NSMutableArray alloc] init];
+    for (auto it : historyItems)
+        [entriesArray addObject:[(WebHistoryItem *)kit((*it).get()) dictionaryRepresentationIncludingChildren:NO]];
+    
+    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+        entriesArray, WebBackForwardListDictionaryEntriesKey,
+        [NSNumber numberWithUnsignedInt:coreBFList->current()], WebBackForwardListDictionaryCurrentKey,
+        [NSNumber numberWithInt:coreBFList->capacity()], WebBackForwardListDictionaryCapacityKey,
+        nil];
+        
+    [entriesArray release];
+    
+    return dictionary;
+}
+
+- (void)setToMatchDictionaryRepresentation:(NSDictionary *)dictionary
+{
+    BackForwardList *coreBFList = core(self);
+    
+    coreBFList->setCapacity([[dictionary objectForKey:WebBackForwardListDictionaryCapacityKey] intValue]);
+    
+    for (NSDictionary *itemDictionary in [dictionary objectForKey:WebBackForwardListDictionaryEntriesKey]) {
+        WebHistoryItem *item = [[WebHistoryItem alloc] initFromDictionaryRepresentation:itemDictionary];
+        coreBFList->addItem(core(item));
+        [item release];
+    }
+
+    unsigned currentIndex = [[dictionary objectForKey:WebBackForwardListDictionaryCurrentKey] unsignedIntValue];
+    size_t listSize = coreBFList->entries().size();
+    if (currentIndex >= listSize)
+        currentIndex = listSize - 1;
+    coreBFList->setCurrent(currentIndex);
+}
+#endif // PLATFORM(IOS)
+
 - (BOOL)containsItem:(WebHistoryItem *)item
 {
     return core(self)->containsItem(core(item));
@@ -211,10 +261,14 @@ static NSArray* vectorToNSArray(HistoryItemVector& list)
 
 static bool bumperCarBackForwardHackNeeded() 
 {
+#if !PLATFORM(IOS)
     static bool hackNeeded = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.freeverse.bumpercar"] && 
         !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_BUMPERCAR_BACK_FORWARD_QUIRK);
 
     return hackNeeded;
+#else
+    return false;
+#endif
 }
 
 - (NSArray *)backListWithLimit:(int)limit
index eab08b6..30d0f5c 100644 (file)
 #import <WebCore/HistoryItem.h>
 #import <WebCore/PageGroup.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WebCoreThreadMessage.h>
+#endif
+
 using namespace WebCore;
 
 typedef int64_t WebHistoryDateKey;
@@ -150,7 +154,7 @@ private:
 
 static void getDayBoundaries(NSTimeInterval interval, NSTimeInterval& beginningOfDay, NSTimeInterval& beginningOfNextDay)
 {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:interval];
     
     NSCalendar *calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
@@ -335,6 +339,7 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
 
     NSString *URLString = [entry URLString];
 
+#if !PLATFORM(IOS)
     WebHistoryItem *oldEntry = [_entriesByURL objectForKey:URLString];
     if (oldEntry) {
         if (discardDuplicate)
@@ -353,6 +358,32 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
 
     [self addItemToDateCaches:entry];
     [_entriesByURL setObject:entry forKey:URLString];
+#else
+    WebHistoryItem *otherEntry = [_entriesByURL objectForKey:URLString];
+    if (otherEntry) {
+        if (discardDuplicate)
+            return NO;
+
+        if ([otherEntry lastVisitedTimeInterval] < [entry lastVisitedTimeInterval]) {
+            // The last reference to oldEntry might be this dictionary, so we hold onto a reference
+            // until we're done with oldEntry.
+            [otherEntry retain];
+            [self removeItemForURLString:URLString];
+
+            // If we already have an item with this URL, we need to merge info that drives the
+            // URL autocomplete heuristics from that item into the new one.
+            [entry _mergeAutoCompleteHints:otherEntry];
+            [otherEntry release];
+
+            [self addItemToDateCaches:entry];
+            [_entriesByURL setObject:entry forKey:URLString];
+        } else
+            return NO; // Special case for merges when new items may be older than pre-existing entries.
+    } else {
+        [self addItemToDateCaches:entry];
+        [_entriesByURL setObject:entry forKey:URLString];
+    }
+#endif
     
     return YES;
 }
@@ -748,8 +779,12 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
 - (void)_sendNotification:(NSString *)name entries:(NSArray *)entries
 {
     NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:entries, WebHistoryItemsKey, nil];
+#if PLATFORM(IOS)
+    WebThreadPostNotification(name, self, userInfo);
+#else    
     [[NSNotificationCenter defaultCenter]
         postNotificationName:name object:self userInfo:userInfo];
+#endif
 }
 
 - (void)removeItems:(NSArray *)entries
@@ -813,9 +848,13 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
         return NO;
     }
 
+#if PLATFORM(IOS)
+    WebThreadPostNotification(WebHistoryLoadedNotification, self, nil);
+#else        
     [[NSNotificationCenter defaultCenter]
         postNotificationName:WebHistoryLoadedNotification
                       object:self];
+#endif
 
     if ([discardedItems count])
         [self _sendNotification:WebHistoryItemsDiscardedWhileLoadingNotification entries:discardedItems];
@@ -828,9 +867,13 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
 {
     if (![_historyPrivate saveToURL:URL error:error])
         return NO;
+#if PLATFORM(IOS)
+    WebThreadPostNotification(WebHistorySavedNotification, self, nil);
+#else        
     [[NSNotificationCenter defaultCenter]
         postNotificationName:WebHistorySavedNotification
                       object:self];
+#endif
     return YES;
 }
 
index a4d866c..cf48807 100644 (file)
 #import <wtf/StdLibExtras.h>
 #import <wtf/text/WTFString.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WebCoreThreadMessage.h>
+
+NSString *WebViewportInitialScaleKey = @"initial-scale";
+NSString *WebViewportMinimumScaleKey = @"minimum-scale";
+NSString *WebViewportMaximumScaleKey = @"maximum-scale";
+NSString *WebViewportUserScalableKey = @"user-scalable";
+NSString *WebViewportWidthKey        = @"width";
+NSString *WebViewportHeightKey       = @"height";
+NSString *WebViewportMinimalUIKey    = @"minimal-ui";
+
+static NSString *scaleKey = @"scale";
+static NSString *scaleIsInitialKey = @"scaleIsInitial";
+static NSString *scrollPointXKey = @"scrollPointX";
+static NSString *scrollPointYKey = @"scrollPointY";
+
+static NSString * const bookmarkIDKey = @"bookmarkID";
+static NSString * const sharedLinkUniqueIdentifierKey = @"sharedLinkUniqueIdentifier";
+#endif
+
 // Private keys used in the WebHistoryItem's dictionary representation.
 // see 3245793 for explanation of "lastVisitedDate"
 static NSString *lastVisitedTimeIntervalKey = @"lastVisitedDate";
@@ -87,17 +107,23 @@ static HistoryItemMap& historyItemWrappers()
 
 void WKNotifyHistoryItemChanged(HistoryItem*)
 {
+#if !PLATFORM(IOS)
     [[NSNotificationCenter defaultCenter]
         postNotificationName:WebHistoryItemChangedNotification object:nil userInfo:nil];
+#else
+    WebThreadPostNotification(WebHistoryItemChangedNotification, nil, nil);
+#endif
 }
 
 @implementation WebHistoryItem
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
@@ -179,10 +205,12 @@ void WKNotifyHistoryItemChanged(HistoryItem*)
     return nsStringNilIfEmpty(core(_private)->alternateTitle());
 }
 
+#if !PLATFORM(IOS)
 - (NSImage *)icon
 {
     return [[WebIconDatabase sharedIconDatabase] iconForURL:[self URLString] withSize:WebIconSmallSize];
 }
+#endif
 
 - (NSTimeInterval)lastVisitedTimeInterval
 {
@@ -390,6 +418,29 @@ WebHistoryItem *kit(HistoryItem* item)
         }
     }
 
+#if PLATFORM(IOS)
+    NSNumber *scaleValue = [dict objectForKey:scaleKey];
+    NSNumber *scaleIsInitialValue = [dict objectForKey:scaleIsInitialKey];
+    if (scaleValue && scaleIsInitialValue)
+        core(_private)->setScale([scaleValue floatValue], [scaleIsInitialValue boolValue]);
+
+    if (id viewportArguments = [dict objectForKey:@"WebViewportArguments"])
+        [self _setViewportArguments:viewportArguments];
+
+    NSNumber *scrollPointXValue = [dict objectForKey:scrollPointXKey];
+    NSNumber *scrollPointYValue = [dict objectForKey:scrollPointYKey];
+    if (scrollPointXValue && scrollPointYValue)
+        core(_private)->setScrollPoint(IntPoint([scrollPointXValue intValue], [scrollPointYValue intValue]));
+
+    uint32_t bookmarkIDValue = [[dict objectForKey:bookmarkIDKey] unsignedIntValue];
+    if (bookmarkIDValue)
+        core(_private)->setBookmarkID(bookmarkIDValue);
+
+    NSString *sharedLinkUniqueIdentifierValue = [dict objectForKey:sharedLinkUniqueIdentifierKey];
+    if (sharedLinkUniqueIdentifierValue)
+        core(_private)->setSharedLinkUniqueIdentifier(sharedLinkUniqueIdentifierValue);
+#endif
+
     return self;
 }
 
@@ -418,8 +469,18 @@ WebHistoryItem *kit(HistoryItem* item)
     return [self initWithURLString:[URL _web_originalDataAsString] title:title lastVisitedTimeInterval:0];
 }
 
+// FIXME: The only iOS difference here should be whether YES or NO is passed to dictionaryRepresentationIncludingChildren:
+#if PLATFORM(IOS)
 - (NSDictionary *)dictionaryRepresentation
 {
+    return [self dictionaryRepresentationIncludingChildren:YES];
+}
+
+- (NSDictionary *)dictionaryRepresentationIncludingChildren:(BOOL)includesChildren
+#else
+- (NSDictionary *)dictionaryRepresentation
+#endif
+{
     ASSERT_MAIN_THREAD();
     NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:8];
 
@@ -471,8 +532,12 @@ WebHistoryItem *kit(HistoryItem* item)
         [dict setObject:array forKey:weeklyVisitCountKey];
         [array release];
     }    
-    
+
+#if PLATFORM(IOS)
+    if (includesChildren && coreItem->children().size()) {
+#else
     if (coreItem->children().size()) {
+#endif
         const HistoryItemVector& children = coreItem->children();
         NSMutableArray *childDicts = [NSMutableArray arrayWithCapacity:children.size()];
         
@@ -481,6 +546,27 @@ WebHistoryItem *kit(HistoryItem* item)
         [dict setObject: childDicts forKey:childrenKey];
     }
 
+#if PLATFORM(IOS)
+    [dict setObject:[NSNumber numberWithFloat:core(_private)->scale()] forKey:scaleKey];
+    [dict setObject:[NSNumber numberWithBool:core(_private)->scaleIsInitial()] forKey:scaleIsInitialKey];
+
+    NSDictionary *viewportArguments = [self _viewportArguments];
+    if (viewportArguments)
+        [dict setObject:viewportArguments forKey:@"WebViewportArguments"];
+
+    IntPoint scrollPoint = core(_private)->scrollPoint();
+    [dict setObject:[NSNumber numberWithInt:scrollPoint.x()] forKey:scrollPointXKey];
+    [dict setObject:[NSNumber numberWithInt:scrollPoint.y()] forKey:scrollPointYKey];
+
+    uint32_t bookmarkID = core(_private)->bookmarkID();
+    if (bookmarkID)
+        [dict setObject:[NSNumber numberWithUnsignedInt:bookmarkID] forKey:bookmarkIDKey];
+
+    NSString *sharedLinkUniqueIdentifier = [self _sharedLinkUniqueIdentifier];
+    if (sharedLinkUniqueIdentifier)
+        [dict setObject:sharedLinkUniqueIdentifier forKey:sharedLinkUniqueIdentifierKey];
+#endif
+
     return dict;
 }
 
@@ -554,9 +640,11 @@ WebHistoryItem *kit(HistoryItem* item)
     return kit(core(_private)->targetItem());
 }
 
+#if !PLATFORM(IOS)
 + (void)_releaseAllPendingPageCaches
 {
 }
+#endif
 
 - (id)_transientPropertyForKey:(NSString *)key
 {
@@ -611,6 +699,80 @@ WebHistoryItem *kit(HistoryItem* item)
     return coreItem->weeklyVisitCounts().size();
 }
 
+#if PLATFORM(IOS)
+- (void)_setScale:(float)scale isInitial:(BOOL)aFlag
+{
+    core(_private)->setScale(scale, aFlag);
+}
+
+- (float)_scale
+{
+    return core(_private)->scale();
+}
+
+- (BOOL)_scaleIsInitial
+{
+    return core(_private)->scaleIsInitial();
+}
+
+- (NSDictionary *)_viewportArguments
+{
+    const ViewportArguments& viewportArguments = core(_private)->viewportArguments();
+    NSMutableDictionary *argumentsDictionary = [NSMutableDictionary dictionary];
+    [argumentsDictionary setObject:[NSNumber numberWithFloat:viewportArguments.zoom] forKey:WebViewportInitialScaleKey];
+    [argumentsDictionary setObject:[NSNumber numberWithFloat:viewportArguments.minZoom] forKey:WebViewportMinimumScaleKey];
+    [argumentsDictionary setObject:[NSNumber numberWithFloat:viewportArguments.maxZoom] forKey:WebViewportMaximumScaleKey];
+    [argumentsDictionary setObject:[NSNumber numberWithFloat:viewportArguments.width] forKey:WebViewportWidthKey];
+    [argumentsDictionary setObject:[NSNumber numberWithFloat:viewportArguments.height] forKey:WebViewportHeightKey];
+    [argumentsDictionary setObject:[NSNumber numberWithFloat:viewportArguments.userZoom] forKey:WebViewportUserScalableKey];
+    [argumentsDictionary setObject:[NSNumber numberWithBool:viewportArguments.minimalUI] forKey:WebViewportMinimalUIKey];
+    return argumentsDictionary;
+}
+
+- (void)_setViewportArguments:(NSDictionary *)arguments
+{
+    ViewportArguments viewportArguments;
+    viewportArguments.zoom = [[arguments objectForKey:WebViewportInitialScaleKey] floatValue];
+    viewportArguments.minZoom = [[arguments objectForKey:WebViewportMinimumScaleKey] floatValue];
+    viewportArguments.maxZoom = [[arguments objectForKey:WebViewportMaximumScaleKey] floatValue];
+    viewportArguments.width = [[arguments objectForKey:WebViewportWidthKey] floatValue];
+    viewportArguments.height = [[arguments objectForKey:WebViewportHeightKey] floatValue];
+    viewportArguments.userZoom = [[arguments objectForKey:WebViewportUserScalableKey] floatValue];
+    viewportArguments.minimalUI = [[arguments objectForKey:WebViewportMinimalUIKey] boolValue];
+    core(_private)->setViewportArguments(viewportArguments);
+}
+
+- (CGPoint)_scrollPoint
+{
+    return core(_private)->scrollPoint();
+}
+
+- (void)_setScrollPoint:(CGPoint)scrollPoint
+{
+    core(_private)->setScrollPoint(IntPoint(scrollPoint));
+}
+
+- (uint32_t)_bookmarkID
+{
+    return core(_private)->bookmarkID();
+}
+
+- (void)_setBookmarkID:(uint32_t)bookmarkID
+{
+    core(_private)->setBookmarkID(bookmarkID);
+}
+
+- (NSString *)_sharedLinkUniqueIdentifier
+{
+    return nsStringNilIfEmpty(core(_private)->sharedLinkUniqueIdentifier());
+}
+
+- (void)_setSharedLinkUniqueIdentifier:(NSString *)identifier
+{
+    core(_private)->setSharedLinkUniqueIdentifier(identifier);
+}
+#endif // PLATFORM(IOS)
+
 - (BOOL)_isInPageCache
 {
     return core(_private)->isInPageCache();
index df9ef75..0968de2 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebURLsWithTitles.h"
 
 #import <WebKit/WebNSURLExtras.h>
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index 7651876..d0b254a 100644 (file)
 #import <wtf/MainThread.h>
 #import <wtf/RunLoop.h>
 
+#if PLATFORM(IOS)
+#import "MemoryMeasure.h"
+#import "WebFrameInternal.h"
+#import <WebCore/CachedImage.h>
+#import <WebCore/CredentialStorage.h>
+#import <WebCore/Frame.h>
+#import <WebCore/PageCache.h>
+#import <WebCore/WebCoreThreadRun.h>
+#endif
+
 @implementation WebCache
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     InitWebCoreSystemInterface();   
 }
 
     WebCore::CrossOriginPreflightResultCache::shared().empty();
 }
 
+#if PLATFORM(IOS)
++ (void)emptyInMemoryResources
+{
+    // This method gets called from MobileSafari after it calls [WebView
+    // _close]. [WebView _close] schedules its work on the WebThread. So we
+    // schedule this method on the WebThread as well so as to pick up all the
+    // dead resources left behind after closing the WebViews
+    WebThreadRun(^{
+        WebKit::MemoryMeasure measurer("[WebCache emptyInMemoryResources]");
+
+        // Toggling the cache model like this forces the cache to evict all its in-memory resources.
+        WebCacheModel cacheModel = [WebView _cacheModel];
+        [WebView _setCacheModel:WebCacheModelDocumentViewer];
+        [WebView _setCacheModel:cacheModel];
+
+        WebCore::memoryCache()->pruneLiveResources(true);
+    });
+}
+
++ (void)sizeOfDeadResources:(int *)resources
+{
+    WebCore::MemoryCache::Statistics stats = WebCore::memoryCache()->getStatistics();
+    if (resources) {
+        *resources = (stats.images.size - stats.images.liveSize)
+                     + (stats.cssStyleSheets.size - stats.cssStyleSheets.liveSize)
+#if ENABLE(XSLT)
+                     + (stats.xslStyleSheets.size - stats.xslStyleSheets.liveSize)
+#endif
+                     + (stats.scripts.size - stats.scripts.liveSize);
+    }
+}
+
++ (void)clearCachedCredentials
+{
+    WebCore::CredentialStorage::clearCredentials();
+}
+
++ (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url
+{
+    return [WebCache addImageToCache:image forURL:url forFrame:nil];
+}
+
++ (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url forFrame:(WebFrame *)frame
+{
+    if (!image || !url || ![[url absoluteString] length])
+        return false;
+    WebCore::SecurityOrigin* topOrigin = nullptr;
+#if ENABLE(CACHE_PARTITIONING)
+    if (frame)
+        topOrigin = core(frame)->document()->topOrigin();
+#endif
+    return WebCore::memoryCache()->addImageToCache(image, url, topOrigin ? topOrigin->cachePartition() : emptyString());
+}
+
++ (void)removeImageFromCacheForURL:(NSURL *)url
+{
+    [WebCache removeImageFromCacheForURL:url forFrame:nil];
+}
+
++ (void)removeImageFromCacheForURL:(NSURL *)url forFrame:(WebFrame *)frame
+{
+    if (!url)
+        return;
+    WebCore::SecurityOrigin* topOrigin = nullptr;
+#if ENABLE(CACHE_PARTITIONING)
+    if (frame)
+        topOrigin = core(frame)->document()->topOrigin();
+#endif
+    WebCore::memoryCache()->removeImageFromCache(url, topOrigin ? topOrigin->cachePartition() : emptyString());
+}
+
++ (CGImageRef)imageForURL:(NSURL *)url
+{
+    if (!url)
+        return nullptr;
+    
+    WebCore::CachedResource* cachedResource = WebCore::memoryCache()->resourceForURL(url);
+    if (!cachedResource || cachedResource->type() != WebCore::CachedResource::ImageResource)
+        return nullptr;
+    WebCore::CachedImage* cachedImage = static_cast<WebCore::CachedImage*>(cachedResource);
+    if (!cachedImage || !cachedImage->hasImage())
+        return nullptr;
+    return cachedImage->image()->getCGImageRef();
+}
+
+#endif // PLATFORM(IOS)
+
 + (void)setDisabled:(BOOL)disabled
 {
     if (!pthread_main_np())
index 44a461e..99fa4ba 100644 (file)
@@ -125,6 +125,7 @@ using namespace WebCore;
 
 - (void)download:(NSURLDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
 {
+#if !PLATFORM(IOS)
     // Try previously stored credential first.
     if (![challenge previousFailureCount]) {
         NSURLCredential *credential = mac(CredentialStorage::get(core([challenge protectionSpace])));
@@ -144,15 +145,18 @@ using namespace WebCore;
 
         [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
     }
+#endif
 }
 
 - (void)download:(NSURLDownload *)download didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
 {
+#if !PLATFORM(IOS)
     if ([realDelegate respondsToSelector:@selector(download:didCancelAuthenticationChallenge:)]) {
         [realDelegate download:download didCancelAuthenticationChallenge:challenge];
     } else {
         [[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:challenge];
     }
+#endif
 }
 
 - (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response
index 9094a38..447f6a5 100644 (file)
@@ -65,9 +65,11 @@ static void cacheValueForKey(const void *key, const void *value, void *self)
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
@@ -210,8 +212,12 @@ static NSString* NSStringOrNil(String coreString)
 
 - (NSValue *)_imageRect
 {
+#if !PLATFORM(IOS)
     IntRect rect = _result->imageRect();
     return rect.isEmpty() ? nil : [NSValue valueWithRect:rect];
+#else
+    return nil;
+#endif
 }
 
 - (NSURL *)_absoluteImageURL
index 1e3991b..4f39463 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebIconDatabaseInternal.h"
 
 #import "WebIconDatabaseClient.h"
@@ -492,3 +494,5 @@ NSImage *webGetNSImage(Image* image, NSSize size)
     }
     return nsImage;
 }
+
+#endif // !PLATFORM(IOS)
index 498fa75..2419c1d 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebIconDatabasePrivate.h"
 
 namespace WebCore {
@@ -48,3 +50,5 @@ namespace WebCore {
 @end
 
 NSImage *webGetNSImage(WebCore::Image*, NSSize);
+
+#endif
index 08f8e6a..0330f15 100644 (file)
 #import <unicode/uchar.h>
 #import <sys/param.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WAKViewPrivate.h>
+#import <WebKit/DOM.h>
+#import <WebKit/WebFrame.h>
+#import <WebKit/WebFrameView.h>
+#import <WebKit/WebViewPrivate.h>
+#endif
+
 NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
 
+#if !PLATFORM(IOS)
 static inline CGFloat webkit_CGCeiling(CGFloat value)
 {
     if (sizeof(value) == sizeof(float))
         return ceilf(value);
     return ceil(value);
 }
+#endif
 
 using namespace WebCore;
 
 @implementation NSString (WebKitExtras)
 
+#if !PLATFORM(IOS)
 static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
 {
     unsigned i;
@@ -148,6 +159,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
 
     return [self sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]].width;
 }
+#endif // !PLATFORM(IOS)
 
 - (NSString *)_web_stringByAbbreviatingWithTildeInPath
 {
@@ -172,10 +184,12 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
     return newString;
 }
 
+#if !PLATFORM(IOS)
 + (NSStringEncoding)_web_encodingForResource:(Handle)resource
 {
     return CFStringConvertEncodingToNSStringEncoding(stringEncodingForResource(resource));
 }
+#endif
 
 - (BOOL)_webkit_isCaseInsensitiveEqualToString:(NSString *)string
 {
@@ -285,6 +299,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
     return [result autorelease];
 }
 
+#if !PLATFORM(IOS)
 -(NSString *)_webkit_fixedCarbonPOSIXPath
 {
     NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -326,6 +341,14 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
 
     return path;
 }
+#endif // !PLATFORM(IOS)
+
+#if PLATFORM(IOS)
++ (NSString *)_web_stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName
+{
+    return [WebFrame stringWithData:data textEncodingName:textEncodingName];
+}
+#endif
 
 + (NSString *)_webkit_localCacheDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier
 {
@@ -333,11 +356,15 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
     NSString *cacheDir = [defaults objectForKey:WebKitLocalCacheDefaultsKey];
 
     if (!cacheDir || ![cacheDir isKindOfClass:[NSString class]]) {
+#if PLATFORM(IOS)
+        cacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
+#else
         char cacheDirectory[MAXPATHLEN];
         size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
     
         if (cacheDirectoryLen)
             cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
+#endif
     }
 
     return [cacheDir stringByAppendingPathComponent:bundleIdentifier];
index d64f2de..c89b5c1 100644 (file)
@@ -57,8 +57,18 @@ static void initCapabilities(void)
 
 uint64_t WebMemorySize(void)
 {
+#if PLATFORM(IOS_SIMULATOR)
+    // Pretend we have 512MB of memory to make cache sizes behave like on device
+    return 512 * 1024 * 1024;
+#endif
     pthread_once(&initControl, initCapabilities);
+#if PLATFORM(IOS)
+    // On iOS, round up the memory size to a power of 2 because max_mem may not be exactly 256MB
+    // (for example) and we have code that depends on those boundaries.
+    return powf(2.0, ceilf(log2f(gHostBasicInfo.max_mem)));
+#else
     return gHostBasicInfo.max_mem;
+#endif
 }
 
 int WebNumberOfCPUs(void)
index 24b647a..1c16ee6 100644 (file)
@@ -36,6 +36,7 @@
     when adding a new version constant.
 */
 
+#if !PLATFORM(IOS)
 #define WEBKIT_FIRST_VERSION_WITH_3_0_CONTEXT_MENU_TAGS 0x020A0000 // 522.0.0
 #define WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION 0x020A0000 // 522.0.0
 #define WEBKIT_FIRST_VERSION_WITHOUT_APERTURE_QUIRK 0x020A0000 // 522.0.0
 #define WEBKIT_FIRST_VERSION_WITH_GET_MATCHED_CSS_RULES_RESTRICTIONS 0x02160B00 // 534.11.0
 #define WEBKIT_FIRST_VERSION_WITH_CSS_ATTRIBUTE_SETTERS_IGNORING_PRIORITY 0x02170D00 // 535.13.0
 #define WEBKIT_FIRST_VERSION_WITHOUT_LEGACY_BACKGROUNDSIZE_SHORTHAND_BEHAVIOR 0x02190100 // 537.1.0
+#else
+// <rdar://problem/6627758> Need to implement WebKitLinkedOnOrAfter
+// Actually UIKit version numbers, since applications don't link against WebKit
+#define WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION 229 // iOS 2.0
+#define WEBKIT_FIRST_VERSION_WITH_MORE_STRICT_LOCAL_RESOURCE_SECURITY_RESTRICTION 818 // iOS 3.0
+#define WEBKIT_FIRST_VERSION_WITH_FLIPPED_SHADOWS 1100 // iOS 3.2
+#define WEBKIT_FIRST_VERSION_WITHOUT_MULTIPLE_IFRAME_TOUCH_EVENT_DISPATCH 1400 // iOS 4.2
+#define WEBKIT_FIRST_VERSION_WITH_CSS_TRANSFORMS_AFFECTING_OVERFLOW 1600 // iOS 5.0
+#define WEBKIT_FIRST_VERSION_WITH_HTML5_PARSER 1600 // iOS 5.0
+#define WEBKIT_FIRST_VERSION_WITH_WINDOW_ON_ERROR 1600 // iOS 5.0
+#define WEBKIT_FIRST_VERSION_WITH_DELEGATE_CALLS_IN_COMMON_RUNLOOP_MODES 1600 // iOS 5.0
+#define WEBKIT_FIRST_VERSION_WITH_CSS_ATTRIBUTE_SETTERS_IGNORING_PRIORITY 2239 // iOS 6.0
+#define WEBKIT_FIRST_VERSION_WITH_YOUTUBE_EMBED_IFRAME_TRANSFORM 2239 // iOS 6.0
+#define WEBKIT_FIRST_VERSION_WITHOUT_LEGACY_BACKGROUNDSIZE_SHORTHAND_BEHAVIOR 2665 // iOS 7.0
+#endif // PLATFORM(IOS)
 
 #ifdef __cplusplus
 extern "C" {
index a63e10b..ebbc6eb 100644 (file)
@@ -34,7 +34,18 @@ static int overridenWebKitLinkTimeVersion;
 
 BOOL WebKitLinkedOnOrAfter(int version)
 {
+#if !PLATFORM(IOS)
     return (WebKitLinkTimeVersion() >= version);
+#else
+    int32_t linkTimeVersion = WebKitLinkTimeVersion();
+    int32_t majorVersion = linkTimeVersion >> 16 & 0x0000FFFF;
+    
+    // The application was not linked against UIKit so assume most recent WebKit
+    if (linkTimeVersion == -1)
+        return YES;
+    
+    return (majorVersion >= version);
+#endif
 }
 
 void setWebKitLinkTimeVersion(int version)
@@ -47,5 +58,11 @@ static int WebKitLinkTimeVersion(void)
     if (overridenWebKitLinkTimeVersion)
         return overridenWebKitLinkTimeVersion;
 
+#if !PLATFORM(IOS)
     return NSVersionOfLinkTimeLibrary("WebKit");
+#else
+    // <rdar://problem/6627758> Need to implement WebKitLinkedOnOrAfter
+    // Third party applications do not link against WebKit, but rather against UIKit.
+    return NSVersionOfLinkTimeLibrary("UIKit");
+#endif
 }
index 506cb5c..d4c49c0 100644 (file)
 #import <wtf/Assertions.h>
 #import <wtf/MainThread.h>
 
+#if PLATFORM(IOS)
+#import "WebLocalizableStringsInternal.h"
+#import <dispatch/dispatch.h>
+#endif
+
 WebLocalizableStringsBundle WebKitLocalizableStringsBundle = { "com.apple.WebKit", 0 };
 
 NSString *WebLocalizedString(WebLocalizableStringsBundle *stringsBundle, const char *key)
@@ -39,7 +44,9 @@ NSString *WebLocalizedString(WebLocalizableStringsBundle *stringsBundle, const c
     // and its use of [NSBundle localizedStringForKey:::], which is not guaranteed to be thread-safe. If
     // we decide we need to use this on background threads, we'll need to add locking here and make sure
     // it doesn't affect performance.
+#if !PLATFORM(IOS)
     ASSERT(isMainThread());
+#endif
 
     NSBundle *bundle;
     if (stringsBundle == NULL) {
@@ -65,3 +72,20 @@ NSString *WebLocalizedString(WebLocalizableStringsBundle *stringsBundle, const c
     ASSERT_WITH_MESSAGE(result != notFound, "could not find localizable string %s in bundle", key);
     return result;
 }
+
+#if PLATFORM(IOS)
+// See <rdar://problem/7902473> Optimize WebLocalizedString for why we do this on a background thread on a timer callback
+static void LoadWebLocalizedStringsTimerCallback(CFRunLoopTimerRef timer, void *info)
+{
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 
+        UI_STRING_KEY_INTERNAL("Typing", "Typing (Undo action name)", "We don't care if we find this string, but searching for it will load the plist and save the results.");
+    });
+}
+
+void LoadWebLocalizedStrings(void)
+{
+    CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 0, 0, 0, &LoadWebLocalizedStringsTimerCallback, NULL);
+    CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
+    CFRelease(timer);
+}
+#endif
index a69a694..64c5aed 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 #import "WebTypesInternal.h"
-#import <Cocoa/Cocoa.h>
 
 @interface NSArray (WebNSArrayExtras)
 
 
 @end
 
+#if !PLATFORM(IOS)
 @interface NSMutableArray (WebNSArrayExtras)
 
 - (void)_webkit_removeUselessMenuItemSeparators;
 
 @end
+#endif
index 6377010..540196a 100644 (file)
@@ -46,6 +46,7 @@
 
 @end
 
+#if !PLATFORM(IOS)
 @implementation NSMutableArray (WebNSArrayExtras)
 
 - (void)_webkit_removeUselessMenuItemSeparators
@@ -72,3 +73,4 @@
 }
 
 @end
+#endif
index cf4cfa6..6394aa2 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <Cocoa/Cocoa.h>
 
 @interface NSControl (WebExtras)
 - (void)sizeToFitAndAdjustWindowHeight;
 @end
+
+#endif
index 2a4c999..bc530be 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebNSControlExtras.h"
 
 @implementation NSControl (WebExtras)
@@ -53,3 +55,5 @@
 }
 
 @end
+
+#endif
index 928679a..2c559a4 100644 (file)
@@ -44,4 +44,7 @@
 - (void)_webkit_setBool:(BOOL)value forKey:(id)key;
 - (void)_webkit_setLongLong:(long long)value forKey:(id)key;
 - (void)_webkit_setUnsignedLongLong:(unsigned long long)value forKey:(id)key;
+#if PLATFORM(IOS)
+- (void)_webkit_setUnsignedInt:(unsigned)value forKey:(id)key;
+#endif
 @end
index 645a081..289ab95 100644 (file)
     [object release];
 }
 
+#if PLATFORM(IOS)
+- (void)_webkit_setUnsignedInt:(unsigned)value forKey:(id)key
+{
+    NSNumber *object = [[NSNumber alloc] initWithUnsignedInt:value];
+    [self setObject:object forKey:key];
+    [object release];
+}
+#endif
+
 @end
 
index 60fb3cf..fe5cc36 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <WebKit/WebNSEventExtras.h>
 
 @implementation NSEvent (WebExtras)
@@ -80,3 +82,5 @@
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index c842ebb..df9886c 100644 (file)
 #import <wtf/ObjcRuntimeExtras.h>
 #import <wtf/RetainPtr.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/FileSystemIOS.h>
+#endif
+
 @implementation NSFileManager (WebNSFileManagerExtras)
 
+#if !PLATFORM(IOS)
 
 typedef struct MetaDataInfo
 {
@@ -99,6 +104,8 @@ static void *setMetaData(void* context)
     return [[(NSString *)CFDictionaryGetValue(adoptCF(DADiskCopyDescription(disk.get())).get(), kDADiskDescriptionVolumeNameKey) copy] autorelease];
 }
 
+#endif // !PLATFORM(IOS)
+
 // -[NSFileManager fileExistsAtPath:] returns NO if there is a broken symlink at the path.
 // So we use this function instead, which returns YES if there is anything there, including
 // a broken symlink.
@@ -140,5 +147,12 @@ static BOOL fileExists(NSString *path)
     return path;
 }
 
+#if PLATFORM(IOS)
+- (NSString *)_webkit_createTemporaryDirectoryWithTemplatePrefix:(NSString *)prefix
+{
+    return WebCore::createTemporaryDirectory(prefix);
+}
+#endif
+
 @end
 
index b8ac5b5..b14aaea 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <Cocoa/Cocoa.h>
 
 @interface NSImage (WebExtras)
@@ -38,3 +40,5 @@
 - (void)_web_saveAndOpen;
 
 @end
+
+#endif
index 2b06ff6..4f729da 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <WebKit/WebNSImageExtras.h>
 
 #import <WebKit/WebKitLogging.h>
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index a4af935..40db6dc 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebNSPasteboardExtras.h"
 
 #import "DOMElementInternal.h"
@@ -293,3 +295,5 @@ static CachedImage* imageFromElement(DOMElement *domElement)
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index 3535369..b05f21d 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <Cocoa/Cocoa.h>
 
 @interface NSPrintOperation (WebKitExtras)
@@ -35,3 +37,5 @@
 - (float)_web_availablePaperHeight;
 
 @end
+
+#endif
index 0982b96..9c69b76 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebNSPrintOperationExtras.h"
 
 @implementation NSPrintOperation (WebKitExtras)
@@ -48,3 +50,5 @@
 }
 
 @end
+
+#endif
index 0771015..b01e72d 100644 (file)
 #import <unicode/uchar.h>
 #import <unicode/uscript.h>
 
+#if PLATFORM(IOS)
+#import <Foundation/NSString_NSURLExtras.h>
+#endif
+
 using namespace WebCore;
 using namespace WTF;
 
+#if PLATFORM(IOS)
+// Fake URL scheme.
+#define WebDataProtocolScheme @"webkit-fake-url"
+#endif
+
 #define URL_BYTES_BUFFER_LENGTH 2048
 
 @implementation NSURL (WebNSURLExtras)
@@ -280,6 +289,113 @@ using namespace WTF;
     return [NSURL URLWithString:[@"file:" stringByAppendingString:[self absoluteString]]];
 }
 
+#if PLATFORM(IOS)
+static inline NSURL *createYouTubeURL(NSString *videoID, NSString *timeID)
+{
+    // This method creates a youtube: URL, which is an internal format that is passed to YouTube.app.
+    // If the format of these internal links is changed below, then the app probably needs to be updated as well.
+
+    ASSERT(videoID && [videoID length] > 0 && ![videoID isEqualToString:@"/"]);
+
+    if ([timeID length])
+        return [NSURL URLWithString:[NSString stringWithFormat:@"youtube:%@?t=%@", videoID, timeID]];
+    return [NSURL URLWithString:[NSString stringWithFormat:@"youtube:%@", videoID]];
+}
+
+- (NSURL *)_webkit_youTubeURL
+{
+    // Bail out early if we aren't even on www.youtube.com or youtube.com.
+    NSString *scheme = [[self scheme] lowercaseString];
+    if (![scheme isEqualToString:@"http"] && ![scheme isEqualToString:@"https"])
+        return nil;
+
+    NSString *hostName = [[self host] lowercaseString];
+    BOOL isYouTubeMobileWebAppURL = [hostName isEqualToString:@"m.youtube.com"];
+    BOOL isYouTubeShortenedURL = [hostName isEqualToString:@"youtu.be"];
+    if (!isYouTubeMobileWebAppURL
+        && !isYouTubeShortenedURL
+        && ![hostName isEqualToString:@"www.youtube.com"]
+        && ![hostName isEqualToString:@"youtube.com"])
+        return nil;
+
+    NSString *path = [self path];
+
+    // Short URL of the form: http://youtu.be/v1d301D
+    if (isYouTubeShortenedURL) {
+        NSString *videoID = [path lastPathComponent];
+        if (videoID && ![videoID isEqualToString:@"/"])
+            return createYouTubeURL(videoID, nil);
+        return nil;
+    }
+
+    NSString *query = [self query];
+    NSString *fragment = [self fragment];
+
+    // On the YouTube mobile web app, the path and query string are put into the
+    // fragment so that one web page is only ever loaded (see <rdar://problem/9550639>).
+    if (isYouTubeMobileWebAppURL) {
+        NSRange range = [fragment rangeOfString:@"?"];
+        if (range.location == NSNotFound) {
+            path = fragment;
+            query = nil;
+        } else {
+            path = [fragment substringToIndex:range.location];
+            query = [fragment substringFromIndex:(range.location + 1)];
+        }
+        fragment = nil;
+    }
+
+    if ([[path lowercaseString] isEqualToString:@"/watch"]) {
+        if ([query length]) {
+            NSString *videoID = [[query _webkit_queryKeysAndValues] objectForKey:@"v"];
+            if (videoID) {
+                NSDictionary *fragmentDict = [[self fragment] _webkit_queryKeysAndValues];
+                NSString *timeID = [fragmentDict objectForKey:@"t"];
+                return createYouTubeURL(videoID, timeID);
+            }
+        }
+
+        // May be a new-style link (see <rdar://problem/7733692>).
+        if ([fragment hasPrefix:@"!"]) {
+            query = [fragment substringFromIndex:1];
+
+            if ([query length]) {
+                NSDictionary *queryDict = [query _webkit_queryKeysAndValues];
+                NSString *videoID = [queryDict objectForKey:@"v"];
+                if (videoID) {
+                    NSString *timeID = [queryDict objectForKey:@"t"];
+                    return createYouTubeURL(videoID, timeID);
+                }
+            }
+        }
+    } else if ([path _web_hasCaseInsensitivePrefix:@"/v/"] || [path _web_hasCaseInsensitivePrefix:@"/e/"]) {
+        NSString *videoID = [path lastPathComponent];
+
+        // These URLs are funny - they don't have a ? for the first query parameter.
+        // Strip all characters after and including '&' to remove extraneous parameters after the video ID.
+        NSRange ampersand = [videoID rangeOfString:@"&"];
+        if (ampersand.location != NSNotFound)
+            videoID = [videoID substringToIndex:ampersand.location];
+
+        if (videoID)
+            return createYouTubeURL(videoID, nil);
+    }
+
+    return nil;
+}
+
++ (NSURL *)uniqueURLWithRelativePart:(NSString *)relativePart
+{
+    CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
+    NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
+    CFRelease(UUIDRef);
+    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", WebDataProtocolScheme, UUIDString, relativePart]];
+    CFRelease(UUIDString);
+    
+    return URL;
+}
+
+#endif // PLATFORM(IOS)
 @end
 
 @implementation NSString (WebNSURLExtras)
@@ -390,4 +506,73 @@ using namespace WTF;
     return [self substringFromIndex:fragmentRange.location + 1];
 }
 
+#if PLATFORM(IOS)
+
+- (NSString *)_webkit_unescapedQueryValue
+{
+    NSMutableString *string = [[[self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] mutableCopy] autorelease];
+    if (!string) // If we failed to decode the URL as UTF8, fall back to Latin1
+        string = [[[self stringByReplacingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding] mutableCopy] autorelease];
+    [string replaceOccurrencesOfString:@"+" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [string length])];
+    return string;
+}
+
+- (NSDictionary *)_webkit_queryKeysAndValues
+{
+    unsigned queryLength = [self length];
+    if (!queryLength)
+        return nil;
+    
+    NSMutableDictionary *queryKeysAndValues = nil;
+    NSRange equalSearchRange = NSMakeRange(0, queryLength);
+    
+    while (equalSearchRange.location < queryLength - 1 && equalSearchRange.length) {
+        
+        // Search for "=".
+        NSRange equalRange = [self rangeOfString:@"=" options:NSLiteralSearch range:equalSearchRange];
+        if (equalRange.location == NSNotFound)
+            break;
+        
+        unsigned indexAfterEqual = equalRange.location + 1;
+        if (indexAfterEqual > queryLength - 1)
+            break;
+                        
+        // Get the key before the "=".
+        NSRange keyRange = NSMakeRange(equalSearchRange.location, equalRange.location - equalSearchRange.location);
+        
+        // Seach for the ampersand.
+        NSRange ampersandSearchRange = NSMakeRange(indexAfterEqual, queryLength - indexAfterEqual);
+        NSRange ampersandRange = [self rangeOfString:@"&" options:NSLiteralSearch range:ampersandSearchRange];
+        
+        // Get the value after the "=", before the ampersand.
+        NSRange valueRange;
+        if (ampersandRange.location != NSNotFound)
+            valueRange = NSMakeRange(indexAfterEqual, ampersandRange.location - indexAfterEqual);
+        else 
+            valueRange = NSMakeRange(indexAfterEqual, queryLength - indexAfterEqual);
+                
+        // Save the key and the value.
+        if (keyRange.length && valueRange.length) {
+            if (queryKeysAndValues == nil)
+                queryKeysAndValues = [NSMutableDictionary dictionary];
+            NSString *key = [[self substringWithRange:keyRange] lowercaseString];
+            NSString *value = [[self substringWithRange:valueRange] _webkit_unescapedQueryValue];
+            if ([key length] && [value length])
+                [queryKeysAndValues setObject:value forKey:key];
+        }
+        
+        // At the end.
+        if (ampersandRange.location == NSNotFound)
+            break;
+        
+        // Continue searching after the ampersand.
+        unsigned indexAfterAmpersand = ampersandRange.location + 1;
+        equalSearchRange = NSMakeRange(indexAfterAmpersand, queryLength - indexAfterAmpersand);
+    }
+    
+    return queryKeysAndValues;
+}
+
+#endif // PLATFORM(IOS)
+
 @end
index 97f05b4..e9851d5 100644 (file)
 #import <WebKit/WebNSURLExtras.h>
 #import <WebKit/WebView.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WAKViewPrivate.h>
+#import <WebCore/WAKWindow.h>
+#endif
+
 #define WebDragStartHysteresisX                 5.0f
 #define WebDragStartHysteresisY                 5.0f
 #define WebMaxDragImageSize                     NSMakeSize(400.0f, 400.0f)
@@ -59,6 +64,7 @@
     return (WebFrameView *)[self _web_superviewOfClass:[WebFrameView class]];
 }
 
+#if !PLATFORM(IOS)
 // FIXME: Mail is the only client of _webView, remove this method once no versions of Mail need it.
 - (WebView *)_webView
 {
     [self dragImage:dragImage at:origin offset:NSZeroSize event:event pasteboard:pasteboard source:source slideBack:YES];
 #pragma clang diagnostic pop
 }
+#endif // !PLATFORM(IOS)
 
 - (BOOL)_web_firstResponderIsSelfOrDescendantView
 {
 }
 
 @end
+
+#if PLATFORM(IOS)
+@implementation NSView (WebDocumentViewExtras)
+
+- (WebFrame *)_frame
+{
+    WebFrameView *webFrameView = [self _web_parentWebFrameView];
+    return [webFrameView webFrame];
+}
+
+- (WebView *)_webView
+{
+    // We used to use the view hierarchy exclusively here, but that won't work
+    // right when the first viewDidMoveToSuperview call is done, and this will.
+    return [[self _frame] webView];
+}
+
+@end
+#endif
index fd21c24..fc66cee 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebNSWindowExtras.h"
 
 @implementation NSWindow (WebExtras)
@@ -56,3 +58,5 @@
 }
 
 @end
+
+#endif
index 8f04f17..1e1370d 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <Cocoa/Cocoa.h>
 #import <Foundation/NSURLCredentialStorage.h>
 
@@ -67,3 +69,4 @@
 @interface WebNonBlockingPanel : NSPanel
 @end
 
+#endif // !PLATFORM(IOS)
index 715e7a2..beb427e 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <WebKit/WebAuthenticationPanel.h>
 
 #import "WebLocalizableStringsInternal.h"
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index ea255f0..f6d267e 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <WebKit/WebPanelAuthenticationHandler.h>
 
 #import <Foundation/NSURLAuthenticationChallenge.h>
@@ -160,3 +162,5 @@ WebPanelAuthenticationHandler *sharedHandler;
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index 181ab70..7f5911a 100644 (file)
@@ -71,9 +71,11 @@ extern "C" {
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
     WKSendUserChangeNotifications();
 }
index cf88464..1a960bf 100644 (file)
 typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
 #endif
 
+#if PLATFORM(IOS)
+#import <WebCore/WAKAppKitStubs.h>
+#endif
+
 @class WebPluginDatabase;
 
 @protocol WebPluginManualLoader
index e04bbb7..e7f8b9a 100644 (file)
@@ -66,9 +66,11 @@ using namespace WebCore;
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
@@ -102,6 +104,7 @@ static NSString *pathByResolvingSymlinksAndAliases(NSString *thePath)
 {
     NSString *newPath = [thePath stringByResolvingSymlinksInPath];
 
+#if !PLATFORM(IOS)
     FSRef fref;
     OSStatus err;
 
@@ -120,6 +123,7 @@ static NSString *pathByResolvingSymlinksAndAliases(NSString *thePath)
         newPath = [(NSURL *)URL path];
         CFRelease(URL);
     }
+#endif
 
     return newPath;
 }
index 5a1be6d..cd15915 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <JavaVM/jni.h>
 
 /*!
@@ -83,3 +85,4 @@ typedef enum {
        exceptionDescription:(NSString **)exceptionString;
 
 @end
+#endif // PLATFORM(IOS)
index 26bed7a..c856eb0 100644 (file)
 
 using namespace WebCore;
 
+#if PLATFORM(IOS)
+@interface WebPluginController (SecretsIKnow)
+- (WebFrame *)webFrame; // FIXME: This file calls -[WebPluginController webFrame], which is not declared in WebPluginController.h.  Merge issue?  Are the plug-in files out of date?
+@end
+#endif
+
 @implementation WebPluginContainerCheck
 
 - (id)initWithRequest:(NSURLRequest *)request target:(NSString *)target resultObject:(id)obj selector:(SEL)selector controller:(id <WebPluginContainerCheckController>)controller contextInfo:(id)contextInfo /*optional*/
index dc1f413..4c1f743 100644 (file)
@@ -34,6 +34,9 @@
 @class WebPluginPackage;
 @class WebView;
 @class WebDataSource;
+#if PLATFORM(IOS)
+@class CALayer;
+#endif
 
 @interface WebPluginController : NSObject <WebPluginManualLoader, WebPluginContainerCheckController>
 {
 + (void)pluginViewHidden:(NSView *)view;
 #endif
 
+#if PLATFORM(IOS)
++ (void)addPlugInView:(NSView *)view;
+- (BOOL)plugInsAreRunning;
+- (CALayer *)superlayerForPluginView:(NSView *)view;
+#endif
 - (void)startAllPlugins;
 - (void)stopAllPlugins;
 - (void)destroyAllPlugins;
+#if PLATFORM(IOS)
+- (void)stopPluginsForPageCache;
+- (void)restorePluginsFromCache;
+#endif
 
 - (WebFrame *)webFrame;
 - (WebView *)webView;
index ea9ba4d..813a588 100644 (file)
 #import <runtime/JSLock.h>
 #import <wtf/text/WTFString.h>
 
+#if PLATFORM(IOS)
+#import "DOMElementInternal.h"
+#import "WebUIKitDelegate.h"
+#import <WebCore/FrameView.h>
+#import <WebCore/GraphicsLayer.h>
+#import <WebCore/Page.h>
+#import <WebCore/RuntimeApplicationChecksIOS.h>
+#import <WebCore/SoftLinking.h>
+#import <WebCore/WebCoreThreadRun.h>
+#endif
+
 using namespace WebCore;
 using namespace HTMLNames;
 
@@ -69,10 +80,12 @@ using namespace HTMLNames;
 - (void)setContainingWindow:(NSWindow *)w;
 @end
 
+#if !PLATFORM(IOS)
 // For compatibility only.
 @interface NSObject (OldPluginAPI)
 + (NSView *)pluginViewWithArguments:(NSDictionary *)arguments;
 @end
+#endif
 
 @interface NSView (OldPluginAPI)
 - (void)pluginInitialize;
@@ -81,21 +94,49 @@ using namespace HTMLNames;
 - (void)pluginDestroy;
 @end
 
+#if !PLATFORM(IOS)
 static bool isKindOfClass(id, NSString* className);
 static void installFlip4MacPlugInWorkaroundIfNecessary();
+#endif
 
 
 static NSMutableSet *pluginViews = nil;
 
+#if PLATFORM(IOS)
+static void initializeAudioSession()
+{
+    static bool wasAudioSessionInitialized;
+    if (wasAudioSessionInitialized)
+        return;
+
+    wasAudioSessionInitialized = true;
+    if (!WebCore::applicationIsMobileSafari())
+        return;
+
+    AudioSession::sharedSession().setCategory(AudioSession::MediaPlayback);
+}
+#endif
+
 @implementation WebPluginController
 
 + (NSView *)plugInViewWithArguments:(NSDictionary *)arguments fromPluginPackage:(WebPluginPackage *)pluginPackage
 {
+#if PLATFORM(IOS)
+    initializeAudioSession();
+#endif
+
     [pluginPackage load];
     Class viewFactory = [pluginPackage viewFactory];
     
     NSView *view = nil;
 
+#if PLATFORM(IOS)
+    {
+        WebView *webView = [_documentView _webView];
+        JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+        view = [[webView _UIKitDelegateForwarder] webView:webView plugInViewWithArguments:arguments fromPlugInPackage:pluginPackage];
+    }
+#else
     if ([viewFactory respondsToSelector:@selector(plugInViewWithArguments:)]) {
         JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
         view = [viewFactory plugInViewWithArguments:arguments];
@@ -103,6 +144,7 @@ static NSMutableSet *pluginViews = nil;
         JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
         view = [viewFactory pluginViewWithArguments:arguments];
     }
+#endif
     
     if (view == nil) {
         return nil;
@@ -116,6 +158,15 @@ static NSMutableSet *pluginViews = nil;
     return view;
 }
 
+#if PLATFORM(IOS)
++ (void)addPlugInView:(NSView *)view
+{
+    if (pluginViews == nil)
+        pluginViews = [[NSMutableSet alloc] init];
+    [pluginViews addObject:view];
+}
+#endif
+
 + (BOOL)isPlugInView:(NSView *)view
 {
     return [pluginViews containsObject:view];
@@ -147,6 +198,36 @@ static NSMutableSet *pluginViews = nil;
     [super dealloc];
 }
 
+#if PLATFORM(IOS)
+- (BOOL)plugInsAreRunning
+{
+    NSUInteger pluginViewCount = [_views count];
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    pluginViewCount += [_viewsNotInDocument count];
+#endif
+    return _started && pluginViewCount;
+}
+
+- (CALayer *)superlayerForPluginView:(NSView *)view
+{
+#if USE(ACCELERATED_COMPOSITING)
+    Frame* coreFrame = core([self webFrame]);
+    FrameView* coreView = coreFrame ? coreFrame->view() : nullptr;
+    if (!coreView)
+        return nil;
+
+    // Get a GraphicsLayer;
+    GraphicsLayer* layerForWidget = coreView->graphicsLayerForPlatformWidget(view);
+    if (!layerForWidget)
+        return nil;
+    
+    return layerForWidget->platformLayer();
+#else
+    return nil;
+#endif
+}
+#endif
+
 - (void)stopOnePlugin:(NSView *)view
 {
     if ([view respondsToSelector:@selector(webPlugInStop)]) {
@@ -158,6 +239,17 @@ static NSMutableSet *pluginViews = nil;
     }
 }
 
+#if PLATFORM(IOS)
+- (void)stopOnePluginForPageCache:(NSView *)view
+{
+    if ([view respondsToSelector:@selector(webPlugInStopForPageCache)]) {
+        JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());
+        [view webPlugInStopForPageCache];
+    } else
+        [self stopOnePlugin:view];
+}
+#endif
+
 - (void)destroyOnePlugin:(NSView *)view
 {
     if ([view respondsToSelector:@selector(webPlugInDestroy)]) {
@@ -213,6 +305,47 @@ static NSMutableSet *pluginViews = nil;
     _started = NO;
 }
 
+#if PLATFORM(IOS)
+- (void)stopPluginsForPageCache
+{
+    if (!_started)
+        return;
+
+    NSUInteger viewsCount = [_views count];
+    if (viewsCount > 0)
+        LOG(Plugins, "stopping WebKit plugins for PageCache: %@", [_views description]);
+
+    for (NSUInteger i = 0; i < viewsCount; ++i)
+        [self stopOnePluginForPageCache:[_views objectAtIndex:i]];
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    NSUInteger viewsNotInDocumentCount = [_viewsNotInDocument count];
+    for (NSUInteger i = 0; i < viewsNotInDocumentCount; ++i)
+        [self stopOnePluginForPageCache:[_viewsNotInDocument objectAtIndex:i]];
+#endif
+
+    _started = NO;
+}
+
+- (void)restorePluginsFromCache
+{
+    WebView *webView = [_documentView _webView];
+
+    NSUInteger viewsCount = [_views count];
+    if (viewsCount > 0)
+        LOG(Plugins, "restoring WebKit plugins from PageCache: %@", [_views description]);
+
+    for (NSUInteger i = 0; i < viewsCount; ++i)
+        [[webView _UIKitDelegateForwarder] webView:webView willAddPlugInView:[_views objectAtIndex:i]];
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    NSUInteger viewsNotInDocumentCount = [_viewsNotInDocument count];
+    for (NSUInteger i = 0; i < viewsNotInDocumentCount; ++i)
+        [[webView _UIKitDelegateForwarder] webView:webView willAddPlugInView:[_viewsNotInDocument objectAtIndex:i]];
+#endif
+}
+#endif // PLATFORM(IOS)
+
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 - (void)pluginViewCreated:(NSView *)view
 {
@@ -237,19 +370,23 @@ static NSMutableSet *pluginViews = nil;
     
     if (![_views containsObject:view]) {
         [_views addObject:view];
+#if !PLATFORM(IOS)
         [[_documentView _webView] addPluginInstanceView:view];
+#endif
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
         if ([_viewsNotInDocument containsObject:view])
             [_viewsNotInDocument removeObject:view];
 #endif
 
+#if !PLATFORM(IOS)
         BOOL oldDefersCallbacks = [[self webView] defersCallbacks];
         if (!oldDefersCallbacks)
             [[self webView] setDefersCallbacks:YES];
 
         if (isKindOfClass(view, @"WmvPlugin"))
             installFlip4MacPlugInWorkaroundIfNecessary();
+#endif
 
         LOG(Plugins, "initializing plug-in %@", view);
         if ([view respondsToSelector:@selector(webPlugInInitialize)]) {
@@ -260,8 +397,10 @@ static NSMutableSet *pluginViews = nil;
             [view pluginInitialize];
         }
 
+#if !PLATFORM(IOS)
         if (!oldDefersCallbacks)
             [[self webView] setDefersCallbacks:NO];
+#endif
         
         if (_started) {
             LOG(Plugins, "starting plug-in %@", view);
@@ -298,7 +437,9 @@ static NSMutableSet *pluginViews = nil;
 #endif
         
         [pluginViews removeObject:view];
+#if !PLATFORM(IOS)
         [[_documentView _webView] removePluginInstanceView:view];
+#endif
         [_views removeObject:view];
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
         [_viewsNotInDocument removeObject:view];
@@ -347,7 +488,9 @@ static void cancelOutstandingCheck(const void *item, void *context)
 #endif
         
         [pluginViews removeObject:aView];
+#if !PLATFORM(IOS)
         [[_documentView _webView] removePluginInstanceView:aView];
+#endif
     }
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
@@ -356,13 +499,24 @@ static void cancelOutstandingCheck(const void *item, void *context)
         [self destroyOnePlugin:[_viewsNotInDocument objectAtIndex:i]];
 #endif
 
+#if !PLATFORM(IOS)
     [_views makeObjectsPerformSelector:@selector(removeFromSuperviewWithoutNeedingDisplay)];
+#else
+    [_views makeObjectsPerformSelector:@selector(removeFromSuperview)];
+#endif
     [_views release];
     _views = nil;
 
     _documentView = nil;
 }
 
+#if PLATFORM(IOS)
+- (BOOL)processingUserGesture
+{
+    return ScriptController::processingUserGesture();
+}
+#endif
+
 - (id)_webPluginContainerCheckIfAllowedToLoadRequest:(NSURLRequest *)request inFrame:(NSString *)target resultObject:(id)obj selector:(SEL)selector
 {
     WebPluginContainerCheck *check = [WebPluginContainerCheck checkWithRequest:request target:target resultObject:obj selector:selector controller:self contextInfo:nil];
@@ -409,6 +563,20 @@ static void cancelOutstandingCheck(const void *item, void *context)
     }
 }
 
+#if PLATFORM(IOS)
+- (void)webPlugInContainerWillShowFullScreenForView:(id)plugInView
+{
+    WebView *webView = [_dataSource _webView];
+    [[webView _UIKitDelegateForwarder] webView:webView willShowFullScreenForPlugInView:plugInView];
+}
+
+- (void)webPlugInContainerDidHideFullScreenForView:(id)plugInView
+{
+    WebView *webView = [_dataSource _webView];
+    [[webView _UIKitDelegateForwarder] webView:webView didHideFullScreenForPlugInView:plugInView];
+}
+#endif
+
 - (void)webPlugInContainerShowStatus:(NSString *)message
 {
     if (!message)
@@ -424,6 +592,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
     [self webPlugInContainerShowStatus:message];
 }
 
+#if !PLATFORM(IOS)
 - (NSColor *)webPlugInContainerSelectionColor
 {
     bool primary = true;
@@ -437,6 +606,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
 {
     return [self webPlugInContainerSelectionColor];
 }
+#endif
 
 - (WebFrame *)webFrame
 {
@@ -509,21 +679,34 @@ static WebCore::HTMLMediaElement* mediaProxyClient(DOMElement* element)
 
 - (void)_webPluginContainerSetMediaPlayerProxy:(WebMediaPlayerProxy *)proxy forElement:(DOMElement *)element
 {
+#if PLATFORM(IOS)
+    WebThreadRun(^{
+#endif
     WebCore::HTMLMediaElement* client = mediaProxyClient(element);
     if (client)
         client->setMediaPlayerProxy(proxy);
+#if PLATFORM(IOS)
+    });
+#endif
 }
 
 - (void)_webPluginContainerPostMediaPlayerNotification:(int)notification forElement:(DOMElement *)element
 {
+#if PLATFORM(IOS)
+    WebThreadRun(^{
+#endif
     WebCore::HTMLMediaElement* client = mediaProxyClient(element);
     if (client)
         client->deliverNotification((MediaPlayerProxyNotificationType)notification);
+#if PLATFORM(IOS)
+    });
+#endif
 }
 #endif
 
 @end
 
+#if !PLATFORM(IOS)
 static bool isKindOfClass(id object, NSString *className)
 {
     Class cls = NSClassFromString(className);
@@ -605,3 +788,4 @@ static void installFlip4MacPlugInWorkaroundIfNecessary()
         hasInstalledFlip4MacPlugInWorkaround = true;
     }
 }
+#endif // !PLATFORM(IOS)
index 3be1f12..c5c556a 100644 (file)
 #import <WebKitSystemInterface.h>
 #import <wtf/Assertions.h>
 
+#if PLATFORM(IOS)
+#import "WebUIKitSupport.h"
+#endif
+
 using namespace WebCore;
 
 static void checkCandidate(WebBasePluginPackage **currentPlugin, WebBasePluginPackage **candidatePlugin);
@@ -386,6 +390,7 @@ static NSArray *additionalWebPlugInPaths;
 
 + (NSArray *)_defaultPlugInPaths
 {
+#if !PLATFORM(IOS)
     // Plug-ins are found in order of precedence.
     // If there are duplicates, the first found plug-in is used.
     // For example, if there is a QuickTime.plugin in the users's home directory
@@ -396,6 +401,19 @@ static NSArray *additionalWebPlugInPaths;
         @"/Library/Internet Plug-Ins",
         [[NSBundle mainBundle] builtInPlugInsPath],
         nil];
+#else
+    // iOS plug-ins are all located in /System/Library/Internet Plug-Ins
+#if !PLATFORM(IOS_SIMULATOR)
+    NSArray *systemLibrary = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES);
+    if (!systemLibrary || [systemLibrary count] == 0)
+        return nil;
+    NSString *systemDir = (NSString*)[systemLibrary objectAtIndex:0];
+#else
+    NSString* platformRootDir = [NSString stringWithUTF8String:WebKitPlatformSystemRootDirectory()];
+    NSString *systemDir = [platformRootDir stringByAppendingPathComponent:@"System/Library"];
+#endif
+    return [NSArray arrayWithObject:[systemDir stringByAppendingPathComponent:@"Internet Plug-Ins"]];
+#endif
 }
 
 - (NSArray *)_plugInPaths
index 6072128..5a9197e 100644 (file)
@@ -61,6 +61,7 @@ NSString *WebPlugInContainingElementKey =       @"WebPlugInContainingElementKey"
         }
     }
     
+#if !PLATFORM(IOS)
     NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[nsBundle executablePath]];
     NSData *data = [executableFile readDataOfLength:512];
     [executableFile closeFile];
@@ -68,6 +69,7 @@ NSString *WebPlugInContainingElementKey =       @"WebPlugInContainingElementKey"
         [self release];
         return nil;
     }
+#endif
 
     if (![self getPluginInfoFromPLists]) {
         [self release];
index 79896b6..084a63f 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #include "WebPluginsPrivate.h"
 
 NSString *WebPluginWillPresentNativeUserInterfaceNotification = @"WebPluginWillPresentNativeUserInterface";
+
+#endif
index eb582d0..ebbaeb0 100644 (file)
 #import <WebCore/DatabaseManager.h>
 #import <WebCore/SecurityOrigin.h>
 
+#if PLATFORM(IOS)
+#import "WebDatabaseManagerInternal.h"
+#import <WebCore/DatabaseTracker.h>
+#import <WebCore/WebCoreThread.h>
+#endif
+
 using namespace WebCore;
 
 NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory";
@@ -49,6 +55,10 @@ NSString *WebDatabaseDidModifyOriginNotification = @"WebDatabaseDidModifyOriginN
 NSString *WebDatabaseDidModifyDatabaseNotification = @"WebDatabaseDidModifyDatabaseNotification";
 NSString *WebDatabaseIdentifierKey = @"WebDatabaseIdentifierKey";
 
+#if PLATFORM(IOS)
+CFStringRef WebDatabaseOriginsDidChangeNotification = CFSTR("WebDatabaseOriginsDidChangeNotification");
+#endif
+
 static NSString *databasesDirectoryPath();
 
 @implementation WebDatabaseManager
@@ -125,6 +135,11 @@ static NSString *databasesDirectoryPath();
 - (void)deleteAllDatabases
 {
     DatabaseManager::manager().deleteAllDatabases();
+#if PLATFORM(IOS)
+    // FIXME: This needs to be removed once DatabaseTrackers in multiple processes
+    // are in sync: <rdar://problem/9567500> Remove Website Data pane is not kept in sync with Safari
+    [[NSFileManager defaultManager] removeItemAtPath:databasesDirectoryPath() error:NULL];
+#endif
 }
 
 - (BOOL)deleteOrigin:(WebSecurityOrigin *)origin
@@ -137,8 +152,150 @@ static NSString *databasesDirectoryPath();
     return DatabaseManager::manager().deleteDatabase([origin _core], databaseIdentifier);
 }
 
+#if PLATFORM(IOS)
+static bool isFileHidden(NSString *file)
+{
+    ASSERT([file length]);
+    return [file characterAtIndex:0] == '.';
+}
+
++ (void)removeEmptyDatabaseFiles
+{
+    NSString *databasesDirectory = databasesDirectoryPath();
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    NSArray *array = [fileManager contentsOfDirectoryAtPath:databasesDirectory error:0];
+    if (!array)
+        return;
+    
+    NSUInteger count = [array count];
+    for (NSUInteger i = 0; i < count; ++i) {
+        NSString *fileName = [array objectAtIndex:i];
+        // Skip hidden files.
+        if (![fileName length] || isFileHidden(fileName))
+            continue;
+        
+        NSString *path = [databasesDirectory stringByAppendingPathComponent:fileName];
+        // Look for directories that contain database files belonging to the same origins.
+        BOOL isDirectory;
+        if (![fileManager fileExistsAtPath:path isDirectory:&isDirectory] || !isDirectory)
+            continue;
+        
+        // Make sure the directory is not a symbolic link that points to something else.
+        NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:0];
+        if ([attributes fileType] == NSFileTypeSymbolicLink)
+            continue;
+        
+        NSArray *databaseFilesInOrigin = [fileManager contentsOfDirectoryAtPath:path error:0];
+        NSUInteger databaseFileCount = [databaseFilesInOrigin count];
+        NSUInteger deletedDatabaseFileCount = 0;
+        for (NSUInteger j = 0; j < databaseFileCount; ++j) {
+            NSString *dbFileName = [databaseFilesInOrigin objectAtIndex:j];
+            // Skip hidden files.
+            if (![dbFileName length] || isFileHidden(dbFileName))
+                continue;
+            
+            NSString *dbFilePath = [path stringByAppendingPathComponent:dbFileName];
+            
+            // There shouldn't be any directories in this folder - but check for it anyway.
+            if (![fileManager fileExistsAtPath:dbFilePath isDirectory:&isDirectory] || isDirectory)
+                continue;
+            
+            if (DatabaseTracker::deleteDatabaseFileIfEmpty(dbFilePath))
+                ++deletedDatabaseFileCount;
+        }
+        
+        // If we have removed every database file for this origin, delete the folder for this origin.
+        if (databaseFileCount == deletedDatabaseFileCount) {
+            // Use rmdir - we don't want the deletion to happen if the folder is not empty.
+            rmdir([path fileSystemRepresentation]);
+        }
+    }
+}
+
++ (void)scheduleEmptyDatabaseRemoval
+{
+    DatabaseTracker::emptyDatabaseFilesRemovalTaskWillBeScheduled();
+    
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        [WebDatabaseManager removeEmptyDatabaseFiles];
+        DatabaseTracker::emptyDatabaseFilesRemovalTaskDidFinish();
+    });
+}
+#endif // PLATFORM(IOS)
+
+@end
+
+#if PLATFORM(IOS)
+@implementation WebDatabaseManager (WebDatabaseManagerInternal)
+
+static Mutex& transactionBackgroundTaskIdentifierLock()
+{
+    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    return mutex;
+}
+
+static WebBackgroundTaskIdentifier transactionBackgroundTaskIdentifier;
+
+static void setTransactionBackgroundTaskIdentifier(WebBackgroundTaskIdentifier identifier)
+{
+    transactionBackgroundTaskIdentifier = identifier;
+}
+
+static WebBackgroundTaskIdentifier getTransactionBackgroundTaskIdentifier()
+{
+    static dispatch_once_t pred;
+    dispatch_once(&pred, ^{
+        setTransactionBackgroundTaskIdentifier(invalidWebBackgroundTaskIdentifier());
+    });
+    
+    return transactionBackgroundTaskIdentifier;
+}
+
++ (void)willBeginFirstTransaction
+{
+    [self startBackgroundTask];
+}
+
++ (void)didFinishLastTransaction
+{
+    [self endBackgroundTask];
+}
+
++ (void)startBackgroundTask
+{
+    MutexLocker lock(transactionBackgroundTaskIdentifierLock());
+
+    // If there's already an existing background task going on, there's no need to start a new one.
+    if (getTransactionBackgroundTaskIdentifier() != invalidWebBackgroundTaskIdentifier())
+        return;
+    
+    setTransactionBackgroundTaskIdentifier(startBackgroundTask(^ { [WebDatabaseManager endBackgroundTask]; }));
+}
+
++ (void)endBackgroundTask
+{
+    MutexLocker lock(transactionBackgroundTaskIdentifierLock());
+
+    // It is possible that we were unable to start the background task when the first transaction began.
+    // Don't try to end the task in that case.
+    // It is also possible we finally finish the last transaction right when the background task expires
+    // and this will end up being called twice for the same background task.  transactionBackgroundTaskIdentifier
+    // will be invalid for the second caller.
+    if (getTransactionBackgroundTaskIdentifier() == invalidWebBackgroundTaskIdentifier())
+        return;
+        
+    endBackgroundTask(getTransactionBackgroundTaskIdentifier());
+    setTransactionBackgroundTaskIdentifier(invalidWebBackgroundTaskIdentifier());
+}
+
 @end
 
+void WebKitSetWebDatabasePaused(bool paused)
+{
+    DatabaseTracker::tracker().setDatabasesPaused(paused);
+}
+#endif // PLATFORM(IOS)
+
 static NSString *databasesDirectoryPath()
 {
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
index 28f8428..67c08de 100644 (file)
@@ -34,8 +34,25 @@ public:
     virtual ~WebDatabaseManagerClient();
     virtual void dispatchDidModifyOrigin(WebCore::SecurityOrigin*);
     virtual void dispatchDidModifyDatabase(WebCore::SecurityOrigin*, const WTF::String& databaseIdentifier);
+#if PLATFORM(IOS)
+    virtual void dispatchDidAddNewOrigin(WebCore::SecurityOrigin*) OVERRIDE;
+    virtual void dispatchDidDeleteDatabase() OVERRIDE;
+    virtual void dispatchDidDeleteDatabaseOrigin() OVERRIDE;
+    void newDatabaseOriginWasAdded();
+    void databaseWasDeleted();
+    void databaseOriginWasDeleted();
+#endif
+
 private:
     WebDatabaseManagerClient();
+
+#if PLATFORM(IOS)
+    void databaseOriginsDidChange();
+
+    bool m_isHandlingNewDatabaseOriginNotification;
+    bool m_isHandlingDeleteDatabaseNotification;
+    bool m_isHandlingDeleteDatabaseOriginNotification;
+#endif
 };
 
 #endif
index 02e73f3..c53638e 100644 (file)
 #import <wtf/RetainPtr.h>
 #import <WebCore/SecurityOrigin.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WebCoreThread.h>
+#endif
+
 using namespace WebCore;
 
+#if PLATFORM(IOS)
+static CFStringRef WebDatabaseOriginWasAddedNotification = CFSTR("com.apple.MobileSafariSettings.WebDatabaseOriginWasAddedNotification");
+static CFStringRef WebDatabaseWasDeletedNotification = CFSTR("com.apple.MobileSafariSettings.WebDatabaseWasDeletedNotification");
+static CFStringRef WebDatabaseOriginWasDeletedNotification = CFSTR("com.apple.MobileSafariSettings.WebDatabaseOriginWasDeletedNotification");
+#endif
+
 WebDatabaseManagerClient* WebDatabaseManagerClient::sharedWebDatabaseManagerClient()
 {
     static WebDatabaseManagerClient* sharedClient = new WebDatabaseManagerClient();
     return sharedClient;
 }
 
+#if PLATFORM(IOS)
+static void onNewDatabaseOriginAdded(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT(observer);
+    
+    WebDatabaseManagerClient* client = reinterpret_cast<WebDatabaseManagerClient*>(observer);
+    client->newDatabaseOriginWasAdded();
+}
+
+static void onDatabaseDeleted(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT(observer);
+    
+    WebDatabaseManagerClient* client = reinterpret_cast<WebDatabaseManagerClient*>(observer);
+    client->databaseWasDeleted();
+}
+
+static void onDatabaseOriginDeleted(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT(observer);
+    
+    WebDatabaseManagerClient* client = reinterpret_cast<WebDatabaseManagerClient*>(observer);
+    client->databaseOriginWasDeleted();
+}
+#endif
+
 WebDatabaseManagerClient::WebDatabaseManagerClient()
+#if PLATFORM(IOS)
+    : m_isHandlingNewDatabaseOriginNotification(false)
+    , m_isHandlingDeleteDatabaseNotification(false)
+    , m_isHandlingDeleteDatabaseOriginNotification(false)
+#endif
 {
+#if PLATFORM(IOS)
+    CFNotificationCenterRef center = CFNotificationCenterGetDarwinNotifyCenter(); 
+    CFNotificationCenterAddObserver(center, this, onNewDatabaseOriginAdded, WebDatabaseOriginWasAddedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
+    CFNotificationCenterAddObserver(center, this, onDatabaseDeleted, WebDatabaseWasDeletedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
+    CFNotificationCenterAddObserver(center, this, onDatabaseOriginDeleted, WebDatabaseOriginWasDeletedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);    
+#endif
 }
 
 WebDatabaseManagerClient::~WebDatabaseManagerClient()
 {
+#if PLATFORM(IOS)
+    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, 0, 0);
+#endif
 }
 
 class DidModifyOriginData {
@@ -106,4 +156,80 @@ void WebDatabaseManagerClient::dispatchDidModifyDatabase(SecurityOrigin* origin,
                                                       userInfo:userInfo.get()];
 }
 
+#if PLATFORM(IOS)
+void WebDatabaseManagerClient::dispatchDidAddNewOrigin(SecurityOrigin*)
+{    
+    m_isHandlingNewDatabaseOriginNotification = true;
+    // Send a notification to all apps that a new origin has been added, so other apps with opened database can refresh their origin maps.
+    CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), WebDatabaseOriginWasAddedNotification, 0, 0, true);
+}
+
+void WebDatabaseManagerClient::dispatchDidDeleteDatabase()
+{
+    m_isHandlingDeleteDatabaseNotification = true;
+    // Send a notification to all apps that a database has been deleted, so other apps with the deleted database open will close it properly.
+    CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), WebDatabaseWasDeletedNotification, 0, 0, true);
+}
+
+void WebDatabaseManagerClient::dispatchDidDeleteDatabaseOrigin()
+{
+    m_isHandlingDeleteDatabaseOriginNotification = true;
+    // Send a notification to all apps that an origin has been deleted, so other apps can update their origin maps.
+    CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), WebDatabaseOriginWasDeletedNotification, 0, 0, true);
+}
+
+void WebDatabaseManagerClient::newDatabaseOriginWasAdded()
+{
+    // Locks the WebThread for the rest of the run loop.
+    WebThreadLock();
+
+    // If this is the process that added the new origin, its quota map should have been updated
+    // and does not need to be invalidated.
+    if (m_isHandlingNewDatabaseOriginNotification) {
+        m_isHandlingNewDatabaseOriginNotification = false;
+        return;
+    }
+    
+    databaseOriginsDidChange();
+}
+
+void WebDatabaseManagerClient::databaseWasDeleted()
+{
+    // Locks the WebThread for the rest of the run loop.
+    WebThreadLock();
+    
+    // If this is the process that added the new origin, its quota map should have been updated
+    // and does not need to be invalidated.
+    if (m_isHandlingDeleteDatabaseNotification) {
+        m_isHandlingDeleteDatabaseNotification = false;
+        return;
+    }
+    
+    DatabaseTracker::tracker().removeDeletedOpenedDatabases();
+}
+
+void WebDatabaseManagerClient::databaseOriginWasDeleted()
+{
+    // Locks the WebThread for the rest of the run loop.
+    WebThreadLock();
+    
+    // If this is the process that added the new origin, its quota map should have been updated
+    // and does not need to be invalidated.
+    if (m_isHandlingDeleteDatabaseOriginNotification) {
+        m_isHandlingDeleteDatabaseOriginNotification = false;
+        return;
+    }
+
+    databaseOriginsDidChange();
+}
+
+void WebDatabaseManagerClient::databaseOriginsDidChange()
+{
+    // Send a notification (within the app) about the origins change.  If an app needs to update its UI when the origins change
+    // (such as Safari Settings), it can listen for that notification.
+    CFNotificationCenterPostNotification(CFNotificationCenterGetLocalCenter(), WebDatabaseOriginsDidChangeNotification, 0, 0, true);
+}
+
+#endif // PLATFORM(IOS)
+
 #endif
diff --git a/Source/WebKit/mac/Storage/WebDatabaseManagerInternal.h b/Source/WebKit/mac/Storage/WebDatabaseManagerInternal.h
new file mode 100644 (file)
index 0000000..3786875
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#import "WebDatabaseManagerPrivate.h"
+
+#if ENABLE(SQL_DATABASE)
+
+#if PLATFORM(IOS)
+@interface WebDatabaseManager (WebDatabaseManagerInternal)
++ (void)willBeginFirstTransaction;
++ (void)didFinishLastTransaction;
++ (void)startBackgroundTask;
++ (void)endBackgroundTask;
+@end
+
+void WebKitSetWebDatabasePaused(bool);
+#endif
+
+#endif
index 130880c..bf0e912 100644 (file)
@@ -50,6 +50,18 @@ static pthread_once_t registerLocalStoragePath = PTHREAD_ONCE_INIT;
     return sharedManager;
 }
 
+#if PLATFORM(IOS)
+- (id)init
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    WebKitInitializeStorageIfNecessary();
+    
+    return self;
+}
+#endif
+
 - (NSArray *)origins
 {
     Vector<RefPtr<SecurityOrigin>> coreOrigins;
@@ -70,6 +82,11 @@ static pthread_once_t registerLocalStoragePath = PTHREAD_ONCE_INIT;
 - (void)deleteAllOrigins
 {
     StorageTracker::tracker().deleteAllOrigins();
+#if PLATFORM(IOS)
+    // FIXME: This needs to be removed once StorageTrackers in multiple processes
+    // are in sync: <rdar://problem/9567500> Remove Website Data pane is not kept in sync with Safari
+    [[NSFileManager defaultManager] removeItemAtPath:[WebStorageManager _storageDirectoryPath] error:NULL];
+#endif
 }
 
 - (void)deleteOrigin:(WebSecurityOrigin *)origin
index cf6c2e4..893e577 100644 (file)
 #ifndef CorrectionPanel_h
 #define CorrectionPanel_h
 
+#if USE(AUTOCORRECTION_PANEL)
+
 #import <AppKit/NSSpellChecker.h>
 #import <WebCore/AlternativeTextClient.h>
 #import <wtf/RetainPtr.h>
 
-#if USE(AUTOCORRECTION_PANEL)
-
 @class WebView;
 
 class CorrectionPanel {
index 226d15b..ce4cc79 100644 (file)
@@ -49,7 +49,16 @@ public:
     virtual Vector<String> dictationAlternatives(uint64_t dictationContext) OVERRIDE;
 #endif
 private:
+#if PLATFORM(IOS)
+#pragma clang diagnostic push
+#if defined(__has_warning) && __has_warning("-Wunused-private-field")
+#pragma clang diagnostic ignored "-Wunused-private-field"
+#endif
+#endif
     WebView* m_webView;
+#if PLATFORM(IOS)
+#pragma clang diagnostic pop
+#endif
 #if USE(AUTOCORRECTION_PANEL)
     CorrectionPanel m_correctionPanel;
 #endif
index 58a9d06..44d7eda 100644 (file)
 #import <WebCore/SecurityOrigin.h>
 #import <wtf/RetainPtr.h>
 
+#if PLATFORM(IOS)
+#import "WebKitNSStringExtras.h"
+#import "WebSQLiteDatabaseTrackerClient.h"
+#import <WebCore/SQLiteDatabaseTracker.h>
+#endif
+
 using namespace WebCore;
 
 @implementation WebApplicationCache
 
+#if PLATFORM(IOS)
+// FIXME: This will be removed when WebKitInitializeApplicationCachePathIfNecessary()
+// is moved from WebView.mm to WebKitInitializeApplicationCacheIfNecessary() in this file.
+// https://bugs.webkit.org/show_bug.cgi?id=57567 
++ (void)initializeWithBundleIdentifier:(NSString *)bundleIdentifier
+{
+    static BOOL initialized = NO;
+    if (initialized)
+        return;
+    
+    SQLiteDatabaseTracker::setClient(WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient());
+
+    cacheStorage().setCacheDirectory([NSString _webkit_localCacheDirectoryWithBundleIdentifier:bundleIdentifier]);
+    
+    initialized = YES;
+}
+#endif
+
 + (long long)maximumSize
 {
     return cacheStorage().maximumSize();
index 45da8eb..7066cdb 100644 (file)
 #import <WebCore/FocusDirection.h>
 #import <wtf/Forward.h>
 
+#if PLATFORM(IOS)
+#import <wtf/Platform.h>
+#import <wtf/text/WTFString.h>
+#import <WebCore/Chrome.h>
+
+using WebCore::MessageLevel;
+using WebCore::MessageSource;
+#endif
+
 @class WebView;
 
 class WebChromeClient : public WebCore::ChromeClient {
@@ -123,8 +132,10 @@ public:
     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>) OVERRIDE;
     virtual void loadIconForFiles(const Vector<WTF::String>&, WebCore::FileIconLoader*) OVERRIDE;
 
+#if !PLATFORM(IOS)
     virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
     virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
+#endif
 
     virtual WebCore::FloatRect customHighlightRect(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& lineRect) OVERRIDE;
     virtual void paintCustomHighlight(WebCore::Node*, const WTF::AtomicString& type, const WebCore::FloatRect& boxRect, const WebCore::FloatRect& lineRect, bool behindText, bool entireLine) OVERRIDE;
@@ -163,11 +174,14 @@ public:
             VideoTrigger |
             PluginTrigger| 
             CanvasTrigger |
+#if PLATFORM(IOS)
+            AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iOS: <rdar://problem/7830677>
+#endif
             AnimationTrigger);
     }
 #endif
 
-#if ENABLE(VIDEO)
+#if ENABLE(VIDEO) && !PLATFORM(IOS)
     virtual bool supportsFullscreenForNode(const WebCore::Node*) OVERRIDE;
     virtual void enterFullscreenForNode(WebCore::Node*) OVERRIDE;
     virtual void exitFullscreenForNode(WebCore::Node*) OVERRIDE;
@@ -188,7 +202,11 @@ public:
 
     virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE { }
 
+#if PLATFORM(IOS)
+    WebView* webView() const { return m_webView; }
+#else
     WebView* webView() { return m_webView; }
+#endif
 
 private:
     WebView *m_webView;
index 0e996ad..7450722 100644 (file)
 #import "NetscapePluginHostManager.h"
 #endif
 
+#if PLATFORM(IOS) && ENABLE(GEOLOCATION)
+#import <WebCore/Geolocation.h>
+#endif
+
+#if PLATFORM(IOS)
+#import <WebCore/Console.h>
+#import <WebCore/WAKClipView.h>
+#import <WebCore/WAKWindow.h>
+#import <WebCore/WebCoreThreadMessage.h>
+#endif
+
 NSString *WebConsoleMessageXMLMessageSource = @"XMLMessageSource";
 NSString *WebConsoleMessageJSMessageSource = @"JSMessageSource";
 NSString *WebConsoleMessageNetworkMessageSource = @"NetworkMessageSource";
@@ -109,9 +120,11 @@ NSString *WebConsoleMessageWarningMessageLevel = @"WarningMessageLevel";
 NSString *WebConsoleMessageErrorMessageLevel = @"ErrorMessageLevel";
 
 
+#if !PLATFORM(IOS)
 @interface NSApplication (WebNSApplicationDetails)
 - (NSCursor *)_cursorRectCursor;
 @end
+#endif
 
 @interface NSView (WebNSViewDetails)
 - (NSView *)_findLastViewInKeyViewLoop;
@@ -122,9 +135,11 @@ NSString *WebConsoleMessageErrorMessageLevel = @"ErrorMessageLevel";
 - (void)setIsSelected:(BOOL)isSelected;
 @end
 
+#if !PLATFORM(IOS)
 @interface NSWindow (AppKitSecretsIKnowAbout)
 - (NSRect)_growBoxRect;
 @end
+#endif
 
 using namespace WebCore;
 using namespace HTMLNames;
@@ -144,14 +159,20 @@ void WebChromeClient::chromeDestroyed()
 
 void WebChromeClient::setWindowRect(const FloatRect& rect)
 {
+#if !PLATFORM(IOS)
     NSRect windowRect = toDeviceSpace(rect, [m_webView window]);
     [[m_webView _UIDelegateForwarder] webView:m_webView setFrame:windowRect];
+#endif
 }
 
 FloatRect WebChromeClient::windowRect()
 {
+#if !PLATFORM(IOS)
     NSRect windowRect = [[m_webView _UIDelegateForwarder] webViewFrame:m_webView];
     return toUserSpace(windowRect, [m_webView window]);
+#else
+    return FloatRect();
+#endif
 }
 
 // FIXME: We need to add API for setting and getting this.
@@ -179,6 +200,7 @@ bool WebChromeClient::canTakeFocus(FocusDirection)
 
 void WebChromeClient::takeFocus(FocusDirection direction)
 {
+#if !PLATFORM(IOS)
     if (direction == FocusDirectionForward) {
         // Since we're trying to move focus out of m_webView, and because
         // m_webView may contain subviews within it, we ask it for the next key
@@ -195,6 +217,7 @@ void WebChromeClient::takeFocus(FocusDirection direction)
             return;
         [[m_webView window] selectKeyViewPrecedingView:m_webView];
     }
+#endif
 }
 
 void WebChromeClient::focusedElementChanged(Element* element)
@@ -393,7 +416,18 @@ inline static NSString *stringForMessageLevel(MessageLevel level)
 
 void WebChromeClient::addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned int lineNumber, unsigned columnNumber, const String& sourceURL)
 {
+#if !PLATFORM(IOS)
     id delegate = [m_webView UIDelegate];
+#else
+    if (![m_webView _allowsMessaging])
+        return;
+
+    id delegate = [m_webView _UIKitDelegate];
+    // No delegate means nothing to send this data to so bail.
+    if (!delegate)
+        return;
+#endif
+
     BOOL respondsToNewSelector = NO;
 
     SEL selector = @selector(webView:addMessageToConsole:withSource:);
@@ -418,10 +452,14 @@ void WebChromeClient::addMessageToConsole(MessageSource source, MessageLevel lev
         stringForMessageLevel(level), @"MessageLevel",
         NULL];
 
+#if PLATFORM(IOS)
+    [[[m_webView _UIKitDelegateForwarder] asyncForwarder] webView:m_webView addMessageToConsole:dictionary withSource:messageSource];
+#else
     if (respondsToNewSelector)
         CallUIDelegate(m_webView, selector, dictionary, messageSource);
     else
         CallUIDelegate(m_webView, selector, dictionary);
+#endif
 
     [dictionary release];
 }
@@ -525,7 +563,11 @@ void WebChromeClient::setStatusbarText(const String& status)
 
 IntRect WebChromeClient::windowResizerRect() const
 {
+#if !PLATFORM(IOS)
     return enclosingIntRect([[m_webView window] _growBoxRect]);
+#else
+    return IntRect();
+#endif
 }
 
 bool WebChromeClient::supportsImmediateInvalidation()
@@ -535,10 +577,14 @@ bool WebChromeClient::supportsImmediateInvalidation()
 
 void WebChromeClient::invalidateRootView(const IntRect&, bool immediate)
 {
+#if !PLATFORM(IOS)
     if (immediate) {
         [[m_webView window] displayIfNeeded];
         [[m_webView window] flushWindowIfNeeded];
     }
+#else
+    UNUSED_PARAM(immediate);
+#endif
 }
 
 void WebChromeClient::invalidateContentsAndRootView(const IntRect& rect, bool immediate)
@@ -638,11 +684,13 @@ void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& database
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
+#if !PLATFORM(IOS)
     // 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 databaseQuotaManager] setQuota:defaultQuota];
     } else
+#endif
         CallUIDelegate(m_webView, @selector(webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:), kit(frame), webOrigin, (NSString *)databaseName);
     [webOrigin release];
 
@@ -757,6 +805,7 @@ void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIcon
     iconLoader->notifyFinished(Icon::createIconForFiles(filenames));
 }
 
+#if !PLATFORM(IOS)
 void WebChromeClient::setCursor(const WebCore::Cursor& cursor)
 {
     if ([NSApp _cursorRectCursor])
@@ -772,6 +821,7 @@ void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
 {
     [NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
 }
+#endif
 
 KeyboardUIMode WebChromeClient::keyboardUIMode()
 {
@@ -800,12 +850,16 @@ void WebChromeClient::makeFirstResponder(NSResponder *responder)
 
 void WebChromeClient::enableSuddenTermination()
 {
+#if !PLATFORM(IOS)
     [[NSProcessInfo processInfo] enableSuddenTermination];
+#endif
 }
 
 void WebChromeClient::disableSuddenTermination()
 {
+#if !PLATFORM(IOS)
     [[NSProcessInfo processInfo] disableSuddenTermination];
+#endif
 }
 
 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
@@ -850,18 +904,30 @@ bool WebChromeClient::hasOpenedPopup() const
 
 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
 {
+#if !PLATFORM(IOS)
     return adoptRef(new PopupMenuMac(client));
+#else
+    return nullptr;
+#endif
 }
 
 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
 {
+#if !PLATFORM(IOS)
     return adoptRef(new SearchPopupMenuMac(client));
+#else
+    return nullptr;
+#endif
 }
 
 bool WebChromeClient::shouldPaintEntireContents() const
 {
+#if PLATFORM(IOS)
+    return false;
+#else
     NSView *documentView = [[[m_webView mainFrame] frameView] documentView];
     return [documentView layer];
+#endif
 }
 
 #if USE(ACCELERATED_COMPOSITING)
@@ -901,7 +967,7 @@ void WebChromeClient::scheduleCompositingLayerFlush()
 
 #endif
 
-#if ENABLE(VIDEO)
+#if ENABLE(VIDEO) && !PLATFORM(IOS)
 
 bool WebChromeClient::supportsFullscreenForNode(const Node* node)
 {
@@ -931,7 +997,11 @@ bool WebChromeClient::supportsFullScreenForElement(const Element* element, bool
     SEL selector = @selector(webView:supportsFullScreenForElement:withKeyboard:);
     if ([[m_webView UIDelegate] respondsToSelector:selector])
         return CallUIDelegateReturningBoolean(false, m_webView, selector, kit(const_cast<WebCore::Element*>(element)), withKeyboard);
+#if !PLATFORM(IOS)
     return [m_webView _supportsFullScreenForElement:const_cast<WebCore::Element*>(element) withKeyboard:withKeyboard];
+#else
+    return NO;
+#endif
 }
 
 void WebChromeClient::enterFullScreenForElement(Element* element)
@@ -941,8 +1011,11 @@ void WebChromeClient::enterFullScreenForElement(Element* element)
         WebKitFullScreenListener* listener = [[WebKitFullScreenListener alloc] initWithElement:element];
         CallUIDelegate(m_webView, selector, kit(element), listener);
         [listener release];
-    } else
+    }
+#if !PLATFORM(IOS)
+    else
         [m_webView _enterFullScreenForElement:element];
+#endif
 }
 
 void WebChromeClient::exitFullScreenForElement(Element* element)
@@ -952,8 +1025,11 @@ void WebChromeClient::exitFullScreenForElement(Element* element)
         WebKitFullScreenListener* listener = [[WebKitFullScreenListener alloc] initWithElement:element];
         CallUIDelegate(m_webView, selector, kit(element), listener);
         [listener release];
-    } else
+    }
+#if !PLATFORM(IOS)
+    else
         [m_webView _exitFullScreenForElement:element];
+#endif
 }
 
 void WebChromeClient::fullScreenRendererChanged(RenderBox* renderer)
index b832e88..85ba9ea 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebContextMenuClient.h"
 
 #import "WebDelegateImplementationCaching.h"
@@ -371,3 +373,5 @@ void WebContextMenuClient::showContextMenu()
     if (nsMenu)
         [NSMenu popUpContextMenu:nsMenu withEvent:event forView:view];
 }
+
+#endif // !PLATFORM(IOS)
index c96071c..c730590 100644 (file)
@@ -42,11 +42,20 @@ public:
     virtual ~WebEditorClient();
     virtual void pageDestroyed() OVERRIDE;
 
+#if !PLATFORM(IOS)
     virtual bool isGrammarCheckingEnabled() OVERRIDE;
     virtual void toggleGrammarChecking() OVERRIDE;
     virtual bool isContinuousSpellCheckingEnabled() OVERRIDE;
     virtual void toggleContinuousSpellChecking() OVERRIDE;
     virtual int spellCheckerDocumentTag() OVERRIDE;
+#else
+    virtual bool isGrammarCheckingEnabled() OVERRIDE { return false; }
+    virtual void toggleGrammarChecking() OVERRIDE { }
+    // Note: isContinuousSpellCheckingEnabled() is implemented.
+    virtual bool isContinuousSpellCheckingEnabled() OVERRIDE;
+    virtual void toggleContinuousSpellChecking() OVERRIDE { }
+    virtual int spellCheckerDocumentTag() OVERRIDE { return 0; }
+#endif
 
     virtual bool smartInsertDeleteEnabled() OVERRIDE;
     virtual bool isSelectTrailingWhitespaceEnabled() OVERRIDE;
@@ -127,7 +136,23 @@ public:
     virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) OVERRIDE;
     virtual void textWillBeDeletedInTextField(WebCore::Element*) OVERRIDE;
     virtual void textDidChangeInTextArea(WebCore::Element*) OVERRIDE;
+
+#if PLATFORM(IOS)
+    virtual void suppressSelectionNotifications() OVERRIDE;
+    virtual void restoreSelectionNotifications() OVERRIDE;
+    virtual void startDelayingAndCoalescingContentChangeNotifications() OVERRIDE;
+    virtual void stopDelayingAndCoalescingContentChangeNotifications() OVERRIDE;
+    virtual void writeDataToPasteboard(NSDictionary*) OVERRIDE;
+    virtual NSArray* supportedPasteboardTypesForCurrentSelection() OVERRIDE;
+    virtual NSArray* readDataFromPasteboard(NSString* type, int index) OVERRIDE;
+    virtual bool hasRichlyEditableSelection() OVERRIDE;
+    virtual int getPasteboardItemsCount() OVERRIDE;
+    virtual WebCore::DocumentFragment* documentFragmentFromDelegate(int index) OVERRIDE;
+    virtual bool performsTwoStepPaste(WebCore::DocumentFragment*) OVERRIDE;
+    virtual int pasteboardChangeCount() OVERRIDE;
+#endif
     
+#if !PLATFORM(IOS)
     virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const OVERRIDE;
     virtual void ignoreWordInSpellDocument(const WTF::String&) OVERRIDE;
     virtual void learnWord(const WTF::String&) OVERRIDE;
@@ -140,6 +165,21 @@ public:
     virtual void showSpellingUI(bool show) OVERRIDE;
     virtual bool spellingUIIsShowing() OVERRIDE;
     virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) OVERRIDE;
+#else
+    virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const OVERRIDE { return true; }
+    virtual void ignoreWordInSpellDocument(const WTF::String&) OVERRIDE { }
+    virtual void learnWord(const WTF::String&) OVERRIDE { }
+    virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) OVERRIDE { }
+    virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) OVERRIDE { return ""; }
+    virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) OVERRIDE { }
+    // Note: checkTextOfParagraph() is implemented. 
+    virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, WTF::Vector<WebCore::TextCheckingResult>& results) OVERRIDE;
+    virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&) OVERRIDE { }
+    virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) OVERRIDE { }
+    virtual void showSpellingUI(bool show) OVERRIDE { }
+    virtual bool spellingUIIsShowing() OVERRIDE { return false; }
+    virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) OVERRIDE { }
+#endif // PLATFORM(IOS)
     virtual void willSetInputMethodState() OVERRIDE;
     virtual void setInputMethodState(bool enabled) OVERRIDE;
     virtual void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>) OVERRIDE;
@@ -154,4 +194,9 @@ private:
     RetainPtr<WebEditorUndoTarget> m_undoTarget;
     bool m_haveUndoRedoOperations;
     RefPtr<WebCore::TextCheckingRequest> m_textCheckingRequest;
+#if PLATFORM(IOS)
+    int m_selectionNotificationSuppressions;
+    bool m_delayingContentChangeNotifications;
+    bool m_hasDelayedContentChangeNotification;
+#endif
 };
index f0867c1..1cdd3e6 100644 (file)
 #import <wtf/RunLoop.h>
 #import <wtf/text/WTFString.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WebCoreThreadMessage.h>
+#import "DOMElementInternal.h"
+#import "WebFrameView.h"
+#import "WebUIKitDelegate.h"
+#endif
+
 using namespace WebCore;
 
 using namespace HTMLNames;
 
+#if !PLATFORM(IOS)
 @interface NSSpellChecker (WebNSSpellCheckerDetails)
 - (NSString *)languageForWordRange:(NSRange)range inString:(NSString *)string orthography:(NSOrthography *)orthography;
 @end
+#endif
 
 @interface NSAttributedString (WebNSAttributedStringDetails)
 - (id)_initWithDOMRange:(DOMRange*)range;
@@ -105,9 +114,11 @@ static WebViewInsertAction kit(EditorInsertAction coreAction)
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
@@ -182,6 +193,11 @@ WebEditorClient::WebEditorClient(WebView *webView)
     : m_webView(webView)
     , m_undoTarget([[[WebEditorUndoTarget alloc] init] autorelease])
     , m_haveUndoRedoOperations(false)
+#if PLATFORM(IOS)
+    , m_selectionNotificationSuppressions(0)
+    , m_delayingContentChangeNotifications(0)
+    , m_hasDelayedContentChangeNotification(0)
+#endif
 {
 }
 
@@ -194,6 +210,7 @@ bool WebEditorClient::isContinuousSpellCheckingEnabled()
     return [m_webView isContinuousSpellCheckingEnabled];
 }
 
+#if !PLATFORM(IOS)
 void WebEditorClient::toggleContinuousSpellChecking()
 {
     [m_webView toggleContinuousSpellChecking:nil];
@@ -213,6 +230,7 @@ int WebEditorClient::spellCheckerDocumentTag()
 {
     return [m_webView spellCheckerDocumentTag];
 }
+#endif
 
 bool WebEditorClient::shouldDeleteRange(Range* range)
 {
@@ -284,15 +302,44 @@ bool WebEditorClient::shouldChangeSelectedRange(Range* fromRange, Range* toRange
 
 void WebEditorClient::didBeginEditing()
 {
+#if !PLATFORM(IOS)
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidBeginEditingNotification object:m_webView];
+#else
+    WebThreadPostNotification(WebViewDidBeginEditingNotification, m_webView, nil);
+#endif
 }
 
+#if PLATFORM(IOS)
+void WebEditorClient::startDelayingAndCoalescingContentChangeNotifications()
+{
+    m_delayingContentChangeNotifications = true;
+}
+
+void WebEditorClient::stopDelayingAndCoalescingContentChangeNotifications()
+{
+    m_delayingContentChangeNotifications = false;
+    
+    if (m_hasDelayedContentChangeNotification)
+        this->respondToChangedContents();
+    
+    m_hasDelayedContentChangeNotification = false;
+}
+#endif
+
 void WebEditorClient::respondToChangedContents()
 {
+#if !PLATFORM(IOS)
     NSView <WebDocumentView> *view = [[[m_webView selectedFrame] frameView] documentView];
     if ([view isKindOfClass:[WebHTMLView class]])
         [(WebHTMLView *)view _updateFontPanel];
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidChangeNotification object:m_webView];    
+#else
+    if (m_delayingContentChangeNotifications) {
+        m_hasDelayedContentChangeNotification = true;
+    } else {
+        WebThreadPostNotification(WebViewDidChangeNotification, m_webView, nil);
+    }
+#endif
 }
 
 void WebEditorClient::respondToChangedSelection(Frame* frame)
@@ -301,21 +348,34 @@ void WebEditorClient::respondToChangedSelection(Frame* frame)
     if ([documentView isKindOfClass:[WebHTMLView class]])
         [(WebHTMLView *)documentView _selectionChanged];
 
+#if !PLATFORM(IOS)
     // FIXME: This quirk is needed due to <rdar://problem/5009625> - We can phase it out once Aperture can adopt the new behavior on their end
     if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_APERTURE_QUIRK) && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Aperture"])
         return;
 
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidChangeSelectionNotification object:m_webView];
+#else
+    // Selection can be changed while deallocating down the WebView / Frame / Editor.  Do not post in that case because it's already too late
+    // for the NSInvocation to retain the WebView.
+    if (![m_webView _isClosing] && m_selectionNotificationSuppressions == 0)
+        WebThreadPostNotification(WebViewDidChangeSelectionNotification, m_webView, nil);
+#endif
 }
 
 void WebEditorClient::didEndEditing()
 {
+#if !PLATFORM(IOS)
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidEndEditingNotification object:m_webView];
+#else
+    WebThreadPostNotification(WebViewDidEndEditingNotification, m_webView, nil);
+#endif
 }
 
 void WebEditorClient::didWriteSelectionToPasteboard()
 {
+#if !PLATFORM(IOS)
     [[m_webView _editingDelegateForwarder] webView:m_webView didWriteSelectionToPasteboard:[NSPasteboard generalPasteboard]];
+#endif
 }
 
 void WebEditorClient::willWriteSelectionToPasteboard(WebCore::Range*)
@@ -363,6 +423,10 @@ static NSArray *createExcludedElementsForAttributedStringConversion()
     return elements;
 }
 
+#if PLATFORM(IOS)
+static NSString *NSExcludedElementsDocumentAttribute = @"ExcludedElements";
+#endif
+
 DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *string, Vector<RefPtr<ArchiveResource>>& resources)
 {
     static NSArray *excludedElements = createExcludedElementsForAttributedStringConversion();
@@ -382,8 +446,10 @@ DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttrib
 
 void WebEditorClient::setInsertionPasteboard(const String& pasteboardName)
 {
+#if !PLATFORM(IOS)
     NSPasteboard *pasteboard = pasteboardName.isEmpty() ? nil : [NSPasteboard pasteboardWithName:pasteboardName];
     [m_webView _setInsertionPasteboard:pasteboard];
+#endif
 }
 
 #if USE(APPKIT)
@@ -521,6 +587,10 @@ static NSString* undoNameForEditAction(EditAction editAction)
         case EditActionOutdent: return UI_STRING_KEY_INTERNAL("Outdent", "Outdent (Undo action name)", "Undo action name");
         case EditActionBold: return UI_STRING_KEY_INTERNAL("Bold", "Bold (Undo action name)", "Undo action name");
         case EditActionItalics: return UI_STRING_KEY_INTERNAL("Italics", "Italics (Undo action name)", "Undo action name");
+#if PLATFORM(IOS)
+        case EditActionDelete: return UI_STRING_KEY_INTERNAL("Delete", "Delete (Undo action name)", "Undo action name (Used only by PLATFORM(IOS) code)");
+        case EditActionDictation: return UI_STRING_KEY_INTERNAL("Dictation", "Dictation (Undo action name)", "Undo action name (Used only by PLATFORM(IOS) code)");
+#endif
     }
     return nil;
 }
@@ -530,6 +600,13 @@ void WebEditorClient::registerUndoOrRedoStep(PassRefPtr<UndoStep> step, bool isR
     ASSERT(step);
     
     NSUndoManager *undoManager = [m_webView undoManager];
+#if PLATFORM(IOS)
+    // While we are undoing, we shouldn't be asked to register another Undo operation, we shouldn't even be touching the DOM.  But
+    // just in case this happens, return to avoid putting the undo manager into an inconsistent state.  Same for being
+    // asked to register a Redo operation in the midst of another Redo.
+    if (([undoManager isUndoing] && !isRedo) || ([undoManager isRedoing] && isRedo))
+        return;
+#endif
     NSString *actionName = undoNameForEditAction(step->editingAction());
     WebUndoStep *webEntry = [WebUndoStep stepWithUndoStep:step];
     [undoManager registerUndoWithTarget:m_undoTarget.get() selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:webEntry];
@@ -603,17 +680,27 @@ void WebEditorClient::redo()
 void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
 {
     Frame* frame = event->target()->toNode()->document().frame();
+#if !PLATFORM(IOS)
     WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView];
     if ([webHTMLView _interpretKeyEvent:event savingCommands:NO])
         event->setDefaultHandled();
+#else
+    WebHTMLView *webHTMLView = (WebHTMLView *)[[kit(frame) frameView] documentView];
+    if ([webHTMLView _handleEditingKeyEvent:event])
+        event->setDefaultHandled();
+#endif
 }
 
 void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
 {
+#if !PLATFORM(IOS)
     Frame* frame = event->target()->toNode()->document().frame();
     WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView];
     if ([webHTMLView _interpretKeyEvent:event savingCommands:YES])
         event->setDefaultHandled();
+#else
+    // iOS does not use input manager this way
+#endif
 }
 
 #define FormDelegateLog(ctrl)  LOG(FormDelegate, "control=%@", ctrl)
@@ -643,8 +730,10 @@ void WebEditorClient::textDidChangeInTextField(Element* element)
     if (!isHTMLInputElement(element))
         return;
 
+#if !PLATFORM(IOS)
     if (!UserTypingGestureIndicator::processingUserTypingGesture() || UserTypingGestureIndicator::focusedElementAtGestureStart() != element)
         return;
+#endif
 
     DOMHTMLInputElement* inputElement = kit(toHTMLInputElement(element));
     FormDelegateLog(inputElement);
@@ -707,6 +796,103 @@ void WebEditorClient::textDidChangeInTextArea(Element* element)
     CallFormDelegate(m_webView, @selector(textDidChangeInTextArea:inFrame:), textAreaElement, kit(element->document().frame()));
 }
 
+#if PLATFORM(IOS)
+void WebEditorClient::suppressSelectionNotifications() 
+{
+    m_selectionNotificationSuppressions++;
+}
+
+void WebEditorClient::restoreSelectionNotifications() 
+{
+    --m_selectionNotificationSuppressions;
+    if (m_selectionNotificationSuppressions < 0)
+        m_selectionNotificationSuppressions = 0;
+}
+
+void WebEditorClient::writeDataToPasteboard(NSDictionary* representation)
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(writeDataToPasteboard:)])
+        [[m_webView _UIKitDelegateForwarder] writeDataToPasteboard:representation];
+}
+
+NSArray* WebEditorClient::supportedPasteboardTypesForCurrentSelection() 
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(supportedPasteboardTypesForCurrentSelection)]) 
+        return [[m_webView _UIKitDelegateForwarder] supportedPasteboardTypesForCurrentSelection]; 
+
+    return nil; 
+}
+
+NSArray* WebEditorClient::readDataFromPasteboard(NSString* type, int index)
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(readDataFromPasteboard:withIndex:)])
+        return [[m_webView _UIKitDelegateForwarder] readDataFromPasteboard:type withIndex:index];
+    
+    return nil;
+}
+
+bool WebEditorClient::hasRichlyEditableSelection()
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(hasRichlyEditableSelection)])
+        return [[m_webView _UIKitDelegateForwarder] hasRichlyEditableSelection];
+    
+    return false;
+}
+
+int WebEditorClient::getPasteboardItemsCount()
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(getPasteboardItemsCount)])
+        return [[m_webView _UIKitDelegateForwarder] getPasteboardItemsCount];
+    
+    return 0;
+}
+
+WebCore::DocumentFragment* WebEditorClient::documentFragmentFromDelegate(int index)
+{
+    if ([[m_webView _editingDelegateForwarder] respondsToSelector:@selector(documentFragmentForPasteboardItemAtIndex:)]) {
+        DOMDocumentFragment *fragmentFromDelegate = [[m_webView _editingDelegateForwarder] documentFragmentForPasteboardItemAtIndex:index];
+        if (fragmentFromDelegate)
+            return core(fragmentFromDelegate);
+    }
+    
+    return 0;
+}
+
+bool WebEditorClient::performsTwoStepPaste(WebCore::DocumentFragment* fragment)
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(performsTwoStepPaste:)])
+        return [[m_webView _UIKitDelegateForwarder] performsTwoStepPaste:kit(fragment)];
+
+    return false;
+}
+
+int WebEditorClient::pasteboardChangeCount()
+{
+    if ([[m_webView _UIKitDelegateForwarder] respondsToSelector:@selector(getPasteboardChangeCount)])
+        return [[m_webView _UIKitDelegateForwarder] getPasteboardChangeCount];
+    
+    return 0;
+}
+
+void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
+{
+    ASSERT(checkingTypes & NSTextCheckingTypeSpelling);
+    NSString *textString = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO];
+    NSArray *incomingResults = [[m_webView _UIKitDelegateForwarder] checkSpellingOfString:textString];
+    [textString release];
+    for (NSValue *incomingResult in incomingResults) {
+        NSRange resultRange = [incomingResult rangeValue];
+        ASSERT(resultRange.location != NSNotFound && resultRange.length > 0);
+        TextCheckingResult result;
+        result.type = TextCheckingTypeSpelling;
+        result.location = resultRange.location;
+        result.length = resultRange.length;
+        results.append(result);
+    }
+}
+#endif // PLATFORM(IOS)
+
+#if !PLATFORM(IOS)
 bool WebEditorClient::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const
 {
     // This prevents erasing spelling markers on OS X Lion or later to match AppKit on these Mac OS X versions.
@@ -916,6 +1102,7 @@ void WebEditorClient::getGuessesForWord(const String& word, const String& contex
             guesses.append(string);
     }
 }
+#endif // !PLATFORM(IOS)
 
 void WebEditorClient::willSetInputMethodState()
 {
@@ -925,6 +1112,7 @@ void WebEditorClient::setInputMethodState(bool)
 {
 }
 
+#if !PLATFORM(IOS)
 @interface WebEditorSpellCheckResponder : NSObject
 {
     WebEditorClient* _client;
@@ -960,9 +1148,11 @@ void WebEditorClient::didCheckSucceed(int sequence, NSArray* results)
     m_textCheckingRequest->didSucceed(core(results, m_textCheckingRequest->data().mask()));
     m_textCheckingRequest.clear();
 }
+#endif
 
 void WebEditorClient::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest> request)
 {
+#if !PLATFORM(IOS)
     ASSERT(!m_textCheckingRequest);
     m_textCheckingRequest = request;
 
@@ -975,4 +1165,5 @@ void WebEditorClient::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRe
                                   target:[[[WebEditorSpellCheckResponder alloc] initWithClient:this sequence:sequence results:results] autorelease]
                                 argument:nil order:0 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
         }];
+#endif
 }
index 11c746d..8af7c87 100644 (file)
@@ -63,6 +63,9 @@ private:
     virtual void makeRepresentation(WebCore::DocumentLoader*) OVERRIDE;
     virtual bool hasHTMLView() const OVERRIDE;
     virtual void forceLayout() OVERRIDE;
+#if PLATFORM(IOS)
+    virtual void forceLayoutWithoutRecalculatingStyles() OVERRIDE;
+#endif
     virtual void forceLayoutForNonHTML() OVERRIDE;
 
     virtual void setCopiesOnScroll() OVERRIDE;
@@ -81,6 +84,11 @@ private:
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     virtual bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&) OVERRIDE;
 #endif
+
+#if PLATFORM(IOS)
+    virtual RetainPtr<CFDictionaryRef> connectionProperties(WebCore::DocumentLoader*, unsigned long identifier) OVERRIDE;
+#endif
+
     virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&) OVERRIDE;
     virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength) OVERRIDE;
     virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier) OVERRIDE;
@@ -126,11 +134,17 @@ private:
     virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) OVERRIDE;
     virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) OVERRIDE;
 
+#if !PLATFORM(IOS)
     virtual void willChangeEstimatedProgress() OVERRIDE;
     virtual void didChangeEstimatedProgress() OVERRIDE;
+#endif
     virtual void postProgressStartedNotification() OVERRIDE;
     virtual void postProgressEstimateChangedNotification() OVERRIDE;
+#if !PLATFORM(IOS)
     virtual void postProgressFinishedNotification() OVERRIDE;
+#else
+    virtual void postProgressFinishedNotification() OVERRIDE { }
+#endif
     
     virtual void setMainFrameDocumentReady(bool) OVERRIDE;
 
@@ -167,6 +181,9 @@ private:
     
     virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*) OVERRIDE;
     virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) OVERRIDE;
+#if PLATFORM(IOS)
+    virtual void didRestoreFrameHierarchyForCachedFrame() OVERRIDE;
+#endif
     virtual void transitionToCommittedForNewPage() OVERRIDE;
 
     virtual void didSaveToPageCache() OVERRIDE;
@@ -216,6 +233,10 @@ private:
 
     virtual void registerForIconNotification(bool listen) OVERRIDE;
 
+#if PLATFORM(IOS)
+    virtual bool shouldLoadMediaElementURL(const WebCore::URL&) const OVERRIDE;
+#endif
+
 #if PLATFORM(MAC)
     virtual RemoteAXObjectRef accessibilityRemoteObject() OVERRIDE { return 0; }
 #endif
index 6e78a1c..54f3a6d 100644 (file)
 #import "WebHostedNetscapePluginView.h"
 #endif
 
+#if PLATFORM(IOS)
+#import <WebCore/HTMLPlugInImageElement.h>
+#import <WebCore/WAKClipView.h>
+#import <WebCore/WAKScrollView.h>
+#import <WebCore/WAKViewPrivate.h>
+#import <WebCore/WAKWindow.h>
+#import <WebCore/WebCoreThreadMessage.h>
+#import "WebKitVersionChecks.h"
+#import "WebMailDelegate.h"
+#import "WebUIKitDelegate.h"
+#endif
+
 using namespace WebCore;
 using namespace HTMLNames;
 
+#if PLATFORM(IOS)
+@interface WebHTMLView (Init)
+- (id)initWithFrame:(CGRect)frame;
+@end
+#endif
+
 // For backwards compatibility with older WebKit plug-ins.
 NSString *WebPluginBaseURLKey = @"WebPluginBaseURL";
 NSString *WebPluginAttributesKey = @"WebPluginAttributes";
@@ -161,6 +179,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     return loader ? static_cast<WebDocumentLoaderMac*>(loader)->dataSource() : nil;
 }
 
+#if !PLATFORM(IOS)
 // Quirk for the Apple Dictionary application.
 //
 // If a top level frame has a <script> element in its <head> for a script named MainPageJavaScript.js,
@@ -193,14 +212,17 @@ static void applyAppleDictionaryApplicationQuirkNonInlinePart(WebFrameLoaderClie
         }
     }
 }
+#endif
 
 static inline void applyAppleDictionaryApplicationQuirk(WebFrameLoaderClient* client, const ResourceRequest& request)
 {
+#if !PLATFORM(IOS)
     // Use a one-time-initialized global variable so we can quickly determine there's nothing to do in
     // all applications other than Apple Dictionary.
     static bool isAppleDictionary = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Dictionary"];
     if (isAppleDictionary)
         applyAppleDictionaryApplicationQuirkNonInlinePart(client, request);
+#endif
 }
 
 WebFrameLoaderClient::WebFrameLoaderClient(WebFrame *webFrame)
@@ -233,9 +255,42 @@ bool WebFrameLoaderClient::hasHTMLView() const
 void WebFrameLoaderClient::forceLayout()
 {
     NSView <WebDocumentView> *view = [m_webFrame->_private->webFrameView documentView];
+#if PLATFORM(IOS)
+    // This gets called to lay out a page restored from the page cache.
+    // To work around timing problems with UIKit, restore fixed 
+    // layout settings here.
+    WebView* webView = getWebView(m_webFrame.get());
+    bool isMainFrame = [webView mainFrame] == m_webFrame.get();
+    Frame* coreFrame = core(m_webFrame.get());
+    if (isMainFrame && coreFrame->view()) {
+        IntSize newSize([webView _fixedLayoutSize]);
+        coreFrame->view()->setFixedLayoutSize(newSize);
+        coreFrame->view()->setUseFixedLayout(!newSize.isEmpty()); 
+    }
+#endif
+    [view setNeedsLayout:YES];
+    [view layout];
+}
+
+#if PLATFORM(IOS)
+void WebFrameLoaderClient::forceLayoutWithoutRecalculatingStyles()
+{
+    NSView <WebDocumentView> *view = [m_webFrame->_private->webFrameView documentView];
+    // This gets called to lay out a page restored from the page cache.
+    // To work around timing problems with UIKit, restore fixed 
+    // layout settings here.
+    WebView* webView = getWebView(m_webFrame.get());
+    bool isMainFrame = [webView mainFrame] == m_webFrame.get();
+    Frame* coreFrame = core(m_webFrame.get());
+    if (isMainFrame && coreFrame->view()) {
+        IntSize newSize([webView _fixedLayoutSize]);
+        coreFrame->view()->setFixedLayoutSize(newSize);
+        coreFrame->view()->setUseFixedLayout(!newSize.isEmpty());
+    }
     [view setNeedsLayout:YES];
     [view layout];
 }
+#endif
 
 void WebFrameLoaderClient::forceLayoutForNonHTML()
 {
@@ -261,7 +316,9 @@ void WebFrameLoaderClient::detachedFromParent2()
 {
     //remove any NetScape plugins that are children of this frame because they are about to be detached
     WebView *webView = getWebView(m_webFrame.get());
+#if !PLATFORM(IOS)
     [webView removePluginInstanceViewsFor:(m_webFrame.get())];
+#endif
     [m_webFrame->_private->webFrameView _setWebFrame:nil]; // needed for now to be compatible w/ old behavior
 
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
@@ -315,6 +372,12 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader
 
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
+#if PLATFORM(IOS)
+    if (implementations->webThreadDidLoadResourceFromMemoryCacheFunc) {
+        CallResourceLoadDelegateInWebThread(implementations->webThreadDidLoadResourceFromMemoryCacheFunc, webView, @selector(webThreadWebView:didLoadResourceFromMemoryCache:response:length:fromDataSource:), request.nsURLRequest(UpdateHTTPBody), response.nsURLResponse(), length, dataSource(loader));
+        return true;
+    } 
+#endif
     if (!implementations->didLoadResourceFromMemoryCacheFunc)
         return false;
 
@@ -329,6 +392,11 @@ void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identi
 
     id object = nil;
     BOOL shouldRelease = NO;
+#if PLATFORM(IOS)
+    if (implementations->webThreadIdentifierForRequestFunc) {
+        object = CallResourceLoadDelegateInWebThread(implementations->webThreadIdentifierForRequestFunc, webView, @selector(webThreadWebView:identifierForInitialRequest:fromDataSource:), request.nsURLRequest(UpdateHTTPBody), dataSource(loader));
+    } else
+#endif
     if (implementations->identifierForRequestFunc)
         object = CallResourceLoadDelegate(implementations->identifierForRequestFunc, webView, @selector(webView:identifierForInitialRequest:fromDataSource:), request.nsURLRequest(UpdateHTTPBody), dataSource(loader));
     else {
@@ -354,11 +422,20 @@ void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader* loader, unsig
 
     NSURLRequest *currentURLRequest = request.nsURLRequest(UpdateHTTPBody);
     NSURLRequest *newURLRequest = currentURLRequest;
+#if PLATFORM(IOS)
+    bool isMainResourceRequest = request.isMainResourceRequest();
+    if (implementations->webThreadWillSendRequestFunc) {
+        newURLRequest = (NSURLRequest *)CallResourceLoadDelegateInWebThread(implementations->webThreadWillSendRequestFunc, webView, @selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:), [webView _objectForIdentifier:identifier], currentURLRequest, redirectResponse.nsURLResponse(), dataSource(loader));
+    } else
+#endif
     if (implementations->willSendRequestFunc)
         newURLRequest = (NSURLRequest *)CallResourceLoadDelegate(implementations->willSendRequestFunc, webView, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:), [webView _objectForIdentifier:identifier], currentURLRequest, redirectResponse.nsURLResponse(), dataSource(loader));
 
     if (newURLRequest != currentURLRequest)
         request = newURLRequest;
+#if PLATFORM(IOS)
+    request.setMainResourceRequest(isMainResourceRequest);
+#endif
 }
 
 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader* loader, unsigned long identifier)
@@ -388,8 +465,10 @@ void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoa
         }
     }
 
+#if !PLATFORM(IOS)
     NSWindow *window = [webView hostWindow] ? [webView hostWindow] : [webView window];
     [[WebPanelAuthenticationHandler sharedHandler] startAuthentication:webChallenge window:window];
+#endif
 }
 
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
@@ -407,12 +486,28 @@ bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*
     }
 
     // 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
+    // challenges for pre-iOS-3.0, pre-10.6 protection spaces.  This is the same as the default implementation
     // in CFNetwork.
     return (protectionSpace.authenticationScheme() < ProtectionSpaceAuthenticationSchemeClientCertificateRequested);
 }
 #endif
 
+#if PLATFORM(IOS)
+RetainPtr<CFDictionaryRef> WebFrameLoaderClient::connectionProperties(DocumentLoader* loader, unsigned long identifier)
+{
+    WebView *webView = getWebView(m_webFrame.get());
+    id resource = [webView _objectForIdentifier:identifier];
+    if (!resource)
+        return nullptr;
+
+    WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
+    if (implementations->connectionPropertiesFunc)
+        return (CFDictionaryRef)CallResourceLoadDelegate(implementations->connectionPropertiesFunc, webView, @selector(webView:connectionPropertiesForResource:dataSource:), resource, dataSource(loader));
+
+    return nullptr;
+}
+#endif
+
 bool WebFrameLoaderClient::shouldPaintBrokenImage(const URL& imageURL) const
 {
     WebView *webView = getWebView(m_webFrame.get());
@@ -438,13 +533,23 @@ void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoad
         }
     }
 
+#if !PLATFORM(IOS)
     [(WebPanelAuthenticationHandler *)[WebPanelAuthenticationHandler sharedHandler] cancelAuthentication:webChallenge];
+#endif
 }
 
 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& response)
 {
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
+
+#if PLATFORM(IOS)
+    if (implementations->webThreadDidReceiveResponseFunc) {
+        if (id resource = [webView _objectForIdentifier:identifier])
+            CallResourceLoadDelegateInWebThread(implementations->webThreadDidReceiveResponseFunc, webView, @selector(webThreadWebView:resource:didReceiveResponse:fromDataSource:), resource, response.nsURLResponse(), dataSource(loader));
+        
+    } else
+#endif
     if (implementations->didReceiveResponseFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
             CallResourceLoadDelegate(implementations->didReceiveResponseFunc, webView, @selector(webView:resource:didReceiveResponse:fromDataSource:), resource, response.nsURLResponse(), dataSource(loader));
@@ -456,6 +561,13 @@ NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader* loa
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
 
+#if PLATFORM(IOS)
+    if (implementations->webThreadWillCacheResponseFunc) {
+        if (id resource = [webView _objectForIdentifier:identifier])
+            return CallResourceLoadDelegateInWebThread(implementations->webThreadWillCacheResponseFunc, webView, @selector(webThreadWebView:resource:willCacheResponse:fromDataSource:), resource, response, dataSource(loader));
+        
+    } else
+#endif
     if (implementations->willCacheResponseFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
             return CallResourceLoadDelegate(implementations->willCacheResponseFunc, webView, @selector(webView:resource:willCacheResponse:fromDataSource:), resource, response, dataSource(loader));
@@ -468,6 +580,12 @@ void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader* loade
 {
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
+#if PLATFORM(IOS)
+    if (implementations->webThreadDidReceiveContentLengthFunc) {
+        if (id resource = [webView _objectForIdentifier:identifier])
+            CallResourceLoadDelegateInWebThread(implementations->webThreadDidReceiveContentLengthFunc, webView, @selector(webThreadWebView:resource:didReceiveContentLength:fromDataSource:), resource, (NSInteger)dataLength, dataSource(loader));
+    } else
+#endif
     if (implementations->didReceiveContentLengthFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
             CallResourceLoadDelegate(implementations->didReceiveContentLengthFunc, webView, @selector(webView:resource:didReceiveContentLength:fromDataSource:), resource, (NSInteger)dataLength, dataSource(loader));
@@ -479,6 +597,13 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, unsi
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
 
+#if PLATFORM(IOS)
+    if (implementations->webThreadDidFinishLoadingFromDataSourceFunc) {
+        if (id resource = [webView _objectForIdentifier:identifier])
+            CallResourceLoadDelegateInWebThread(implementations->webThreadDidFinishLoadingFromDataSourceFunc, webView, @selector(webThreadWebView:resource:didFinishLoadingFromDataSource:), resource, dataSource(loader));
+    } else
+#endif
+
     if (implementations->didFinishLoadingFromDataSourceFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
             CallResourceLoadDelegate(implementations->didFinishLoadingFromDataSourceFunc, webView, @selector(webView:resource:didFinishLoadingFromDataSource:), resource, dataSource(loader));
@@ -494,6 +619,12 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, unsign
     WebView *webView = getWebView(m_webFrame.get());
     WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView);
 
+#if PLATFORM(IOS)
+    if (implementations->webThreadDidFailLoadingWithErrorFromDataSourceFunc) {
+        if (id resource = [webView _objectForIdentifier:identifier])
+            CallResourceLoadDelegateInWebThread(implementations->webThreadDidFailLoadingWithErrorFromDataSourceFunc, webView, @selector(webThreadWebView:resource:didFailLoadingWithError:fromDataSource:), resource, (NSError *)error, dataSource(loader));
+    } else
+#endif
     if (implementations->didFailLoadingWithErrorFromDataSourceFunc) {
         if (id resource = [webView _objectForIdentifier:identifier])
             CallResourceLoadDelegate(implementations->didFailLoadingWithErrorFromDataSourceFunc, webView, @selector(webView:resource:didFailLoadingWithError:fromDataSource:), resource, (NSError *)error, dataSource(loader));
@@ -548,6 +679,9 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didChangeLocationWithinPageForFrameFunc)
         CallFrameLoadDelegate(implementations->didChangeLocationWithinPageForFrameFunc, webView, @selector(webView:didChangeLocationWithinPageForFrame:), m_webFrame.get());
+#if PLATFORM(IOS)
+    [[webView _UIKitDelegateForwarder] webView:webView didChangeLocationWithinPageForFrame:m_webFrame.get()];
+#endif
 }
 
 void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
@@ -586,6 +720,9 @@ void WebFrameLoaderClient::dispatchWillClose()
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->willCloseFrameFunc)
         CallFrameLoadDelegate(implementations->willCloseFrameFunc, webView, @selector(webView:willCloseFrame:), m_webFrame.get());
+#if PLATFORM(IOS)
+    [[webView _UIKitDelegateForwarder] webView:webView willCloseFrame:m_webFrame.get()];
+#endif
 }
 
 void WebFrameLoaderClient::dispatchDidReceiveIcon()
@@ -603,7 +740,13 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
     m_webFrame->_private->provisionalURL = core(m_webFrame.get())->loader().provisionalDocumentLoader()->url().string();
 
     WebView *webView = getWebView(m_webFrame.get());
+#if !PLATFORM(IOS)
     [webView _didStartProvisionalLoadForFrame:m_webFrame.get()];
+#endif
+
+#if PLATFORM(IOS)
+    [[webView _UIKitDelegateForwarder] webView:webView didStartProvisionalLoadForFrame:m_webFrame.get()];
+#endif
 
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didStartProvisionalLoadForFrameFunc)
@@ -635,6 +778,10 @@ void WebFrameLoaderClient::dispatchDidCommitLoad()
     m_webFrame->_private->url = m_webFrame->_private->provisionalURL;
     m_webFrame->_private->provisionalURL = nullptr;
 
+#if PLATFORM(IOS)
+    [[webView _UIKitDelegateForwarder] webView:webView didCommitLoadForFrame:m_webFrame.get()];
+#endif
+    
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didCommitLoadForFrameFunc)
         CallFrameLoadDelegate(implementations->didCommitLoadForFrameFunc, webView, @selector(webView:didCommitLoadForFrame:), m_webFrame.get());
@@ -645,7 +792,9 @@ void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& e
     m_webFrame->_private->provisionalURL = nullptr;
 
     WebView *webView = getWebView(m_webFrame.get());
+#if !PLATFORM(IOS)
     [webView _didFailProvisionalLoadWithError:error forFrame:m_webFrame.get()];
+#endif
 
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didFailProvisionalLoadWithErrorForFrameFunc)
@@ -659,11 +808,16 @@ void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
     ASSERT(!m_webFrame->_private->provisionalURL);
 
     WebView *webView = getWebView(m_webFrame.get());
+#if !PLATFORM(IOS)
     [webView _didFailLoadWithError:error forFrame:m_webFrame.get()];
+#endif
 
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didFailLoadWithErrorForFrameFunc)
         CallFrameLoadDelegate(implementations->didFailLoadWithErrorForFrameFunc, webView, @selector(webView:didFailLoadWithError:forFrame:), (NSError *)error, m_webFrame.get());
+#if PLATFORM(IOS)
+    [[webView _UIKitDelegateForwarder] webView:webView didFailLoadWithError:((NSError *)error) forFrame:m_webFrame.get()];
+#endif
 
     [m_webFrame->_private->internalLoadDelegate webFrame:m_webFrame.get() didFinishLoadWithError:error];
 }
@@ -671,6 +825,14 @@ void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
 {
     WebView *webView = getWebView(m_webFrame.get());
+
+#if PLATFORM(IOS)
+    id webThreadDel = [webView _webMailDelegate];
+    if ([webThreadDel respondsToSelector:@selector(_webthread_webView:didFinishDocumentLoadForFrame:)]) {
+        [webThreadDel _webthread_webView:webView didFinishDocumentLoadForFrame:m_webFrame.get()];
+    }
+#endif
+
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didFinishDocumentLoadForFrameFunc)
         CallFrameLoadDelegate(implementations->didFinishDocumentLoadForFrameFunc, webView, @selector(webView:didFinishDocumentLoadForFrame:), m_webFrame.get());
@@ -681,7 +843,16 @@ void WebFrameLoaderClient::dispatchDidFinishLoad()
     ASSERT(!m_webFrame->_private->provisionalURL);
 
     WebView *webView = getWebView(m_webFrame.get());
+#if !PLATFORM(IOS)
     [webView _didFinishLoadForFrame:m_webFrame.get()];
+#else
+    [[webView _UIKitDelegateForwarder] webView:webView didFinishLoadForFrame:m_webFrame.get()];
+
+    id webThreadDel = [webView _webMailDelegate];
+    if ([webThreadDel respondsToSelector:@selector(_webthread_webView:didFinishLoadForFrame:)]) {
+        [webThreadDel _webthread_webView:webView didFinishLoadForFrame:m_webFrame.get()];
+    }
+#endif
 
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didFinishLoadForFrameFunc)
@@ -695,8 +866,13 @@ void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones)
     WebView *webView = getWebView(m_webFrame.get());
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
 
+#if PLATFORM(IOS)
+    if (implementations->webThreadDidLayoutFunc)
+        CallFrameLoadDelegateInWebThread(implementations->webThreadDidLayoutFunc, webView, @selector(webThreadWebView:didLayout:), kitLayoutMilestones(milestones));
+#else
     if (implementations->didLayoutFunc)
         CallFrameLoadDelegate(implementations->didLayoutFunc, webView, @selector(webView:didLayout:), kitLayoutMilestones(milestones));
+#endif
 
     if (milestones & DidFirstLayout) {
         // FIXME: We should consider removing the old didFirstLayout API since this is doing double duty with the
@@ -704,12 +880,18 @@ void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones)
         if (implementations->didFirstLayoutInFrameFunc)
             CallFrameLoadDelegate(implementations->didFirstLayoutInFrameFunc, webView, @selector(webView:didFirstLayoutInFrame:), m_webFrame.get());
 
+#if PLATFORM(IOS)
+        [[webView _UIKitDelegateForwarder] webView:webView didFirstLayoutInFrame:m_webFrame.get()];
+#endif
         // See WebFrameLoaderClient::provisionalLoadStarted.
         WebDynamicScrollBarsView *scrollView = [m_webFrame->_private->webFrameView _scrollView];
         if ([getWebView(m_webFrame.get()) drawsBackground])
             [scrollView setDrawsBackground:YES];
+#if !PLATFORM(IOS)
         [scrollView setVerticalScrollElasticity:NSScrollElasticityAutomatic];
         [scrollView setHorizontalScrollElasticity:NSScrollElasticityAutomatic];
+#endif
     }
 
     if (milestones & DidFirstVisuallyNonEmptyLayout) {
@@ -717,6 +899,10 @@ void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones)
         // double duty with the new didLayout API.
         if (implementations->didFirstVisuallyNonEmptyLayoutInFrameFunc)
             CallFrameLoadDelegate(implementations->didFirstVisuallyNonEmptyLayoutInFrameFunc, webView, @selector(webView:didFirstVisuallyNonEmptyLayoutInFrame:), m_webFrame.get());
+#if PLATFORM(IOS)
+        if ([webView mainFrame] == m_webFrame.get())
+            [[webView _UIKitDelegateForwarder] webView:webView didFirstVisuallyNonEmptyLayoutInFrame:m_webFrame.get()];
+#endif
     }
 }
 
@@ -830,6 +1016,7 @@ void WebFrameLoaderClient::setMainDocumentError(DocumentLoader* loader, const Re
     [dataSource(loader) _setMainDocumentError:error];
 }
 
+#if !PLATFORM(IOS)
 void WebFrameLoaderClient::willChangeEstimatedProgress()
 {
     [getWebView(m_webFrame.get()) _willChangeValueForKey:_WebEstimatedProgressKey];
@@ -839,21 +1026,44 @@ void WebFrameLoaderClient::didChangeEstimatedProgress()
 {
     [getWebView(m_webFrame.get()) _didChangeValueForKey:_WebEstimatedProgressKey];
 }
+#endif
 
 void WebFrameLoaderClient::postProgressStartedNotification()
 {
+#if !PLATFORM(IOS)
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewProgressStartedNotification object:getWebView(m_webFrame.get())];
+#else
+    WebThreadPostNotification(WebViewProgressStartedNotification, getWebView(m_webFrame.get()), nil);
+#endif
 }
 
 void WebFrameLoaderClient::postProgressEstimateChangedNotification()
 {
+#if !PLATFORM(IOS)
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewProgressEstimateChangedNotification object:getWebView(m_webFrame.get())];
+#else
+    WebView *webView = getWebView(m_webFrame.get());
+    NSNumber *progress = [NSNumber numberWithFloat:[webView estimatedProgress]];
+    CGColorRef bodyBackgroundColor = [[webView mainFrame] _bodyBackgroundColor];
+
+    // Use a CFDictionary so we can add the CGColorRef without compile errors. And then thanks to
+    // toll-free bridging we can pass the CFDictionary as an NSDictionary to postNotification.
+    CFMutableDictionaryRef userInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFDictionaryAddValue(userInfo, WebViewProgressEstimatedProgressKey, progress);
+    if (bodyBackgroundColor)
+        CFDictionaryAddValue(userInfo, WebViewProgressBackgroundColorKey, bodyBackgroundColor);
+
+    WebThreadPostNotification(WebViewProgressEstimateChangedNotification, webView, (NSDictionary *) userInfo);
+    CFRelease(userInfo);
+#endif
 }
 
+#if !PLATFORM(IOS)
 void WebFrameLoaderClient::postProgressFinishedNotification()
 {
     [[NSNotificationCenter defaultCenter] postNotificationName:WebViewProgressFinishedNotification object:getWebView(m_webFrame.get())];
 }
+#endif
 
 void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready)
 {
@@ -868,14 +1078,18 @@ void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const S
 
 void WebFrameLoaderClient::willChangeTitle(DocumentLoader* loader)
 {
+#if !PLATFORM(IOS)
     // FIXME: Should do this only in main frame case, right?
     [getWebView(m_webFrame.get()) _willChangeValueForKey:_WebMainFrameTitleKey];
+#endif
 }
 
 void WebFrameLoaderClient::didChangeTitle(DocumentLoader* loader)
 {
+#if !PLATFORM(IOS)
     // FIXME: Should do this only in main frame case, right?
     [getWebView(m_webFrame.get()) _didChangeValueForKey:_WebMainFrameTitleKey];
+#endif
 }
 
 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
@@ -901,6 +1115,10 @@ void WebFrameLoaderClient::updateGlobalHistory()
 {
     WebView* view = getWebView(m_webFrame.get());
     DocumentLoader* loader = core(m_webFrame.get())->loader().documentLoader();
+#if PLATFORM(IOS)
+    if (loader->urlForHistory() == blankURL())
+        return;
+#endif
 
     if ([view historyDelegate]) {
         WebHistoryDelegateImplementationCache* implementations = WebViewGetHistoryDelegateImplementations(view);
@@ -1096,6 +1314,16 @@ void WebFrameLoaderClient::saveViewStateToItem(HistoryItem* item)
 {
     if (!item)
         return;
+
+#if PLATFORM(IOS)
+    // Let UIKit handle the scroll point for the main frame.
+    WebFrame *webFrame = m_webFrame.get();
+    WebView *webView = getWebView(webFrame);   
+    if (webFrame == [webView mainFrame]) {
+        [[webView _UIKitDelegateForwarder] webView:webView saveStateToHistoryItem:kit(item) forFrame:webFrame];
+        return;
+    }
+#endif                    
     
     NSView <WebDocumentView> *docView = [m_webFrame->_private->webFrameView documentView];
 
@@ -1117,6 +1345,16 @@ void WebFrameLoaderClient::restoreViewState()
     // so there *is* no scroll state to restore!
     if (!currentItem)
         return;
+
+#if PLATFORM(IOS)
+    // Let UIKit handle the scroll point for the main frame.
+    WebFrame *webFrame = m_webFrame.get();
+    WebView *webView = getWebView(webFrame);   
+    if (webFrame == [webView mainFrame]) {
+        [[webView _UIKitDelegateForwarder] webView:webView restoreStateFromHistoryItem:kit(currentItem) forFrame:webFrame force:NO];
+        return;
+    }
+#endif                    
     
     NSView <WebDocumentView> *docView = [m_webFrame->_private->webFrameView documentView];
     if ([docView conformsToProtocol:@protocol(_WebDocumentViewState)]) {        
@@ -1140,8 +1378,10 @@ void WebFrameLoaderClient::provisionalLoadStarted()
 
     WebDynamicScrollBarsView *scrollView = [m_webFrame->_private->webFrameView _scrollView];
     [scrollView setDrawsBackground:NO];
+#if !PLATFORM(IOS)
     [scrollView setVerticalScrollElasticity:NSScrollElasticityNone];
     [scrollView setHorizontalScrollElasticity:NSScrollElasticityNone];
+#endif
 }
 
 void WebFrameLoaderClient::didFinishLoad()
@@ -1156,6 +1396,7 @@ void WebFrameLoaderClient::prepareForDataSourceReplacement()
         return;
     }
     
+#if !PLATFORM(IOS)
     // Make sure that any work that is triggered by resigning first reponder can get done.
     // The main example where this came up is the textDidEndEditing that is sent to the
     // FormsDelegate (3223413). We need to do this before _detachChildren, since that will
@@ -1173,6 +1414,7 @@ void WebFrameLoaderClient::prepareForDataSourceReplacement()
     NSResponder *firstResp = [window firstResponder];
     if ([firstResp isKindOfClass:[NSView class]] && [(NSView *)firstResp isDescendantOf:frameView])
         [window endEditingFor:firstResp];
+#endif
 }
 
 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
@@ -1205,6 +1447,10 @@ void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const URL&
     nsURL = [nsURL _webkit_canonicalize];
     if(!nsURL)
         return;
+#if PLATFORM(IOS)
+    if ([[nsURL absoluteString] isEqualToString:@"about:blank"])
+        return;
+#endif
     NSString *titleNSString = title.string();
        
     [[[WebHistory optionalSharedHistory] itemForURL:nsURL] setTitle:titleNSString];
@@ -1214,6 +1460,12 @@ void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFram
 {
     OwnPtr<WebCachedFramePlatformData> webPlatformData = adoptPtr(new WebCachedFramePlatformData([m_webFrame->_private->webFrameView documentView]));
     cachedFrame->setCachedFramePlatformData(webPlatformData.release());
+
+#if PLATFORM(IOS)
+    // At this point we know this frame is going to be cached. Stop all plugins.
+    WebView *webView = getWebView(m_webFrame.get());
+    [webView _stopAllPlugInsForPageCache];
+#endif
 }
 
 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame* cachedFrame)
@@ -1224,25 +1476,49 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame* cac
     ASSERT(cachedFrame->documentLoader());
     [cachedView setDataSource:dataSource(cachedFrame->documentLoader())];
     
+#if !PLATFORM(IOS)
     // clean up webkit plugin instances before WebHTMLView gets freed.
     WebView *webView = getWebView(m_webFrame.get());
     [webView removePluginInstanceViewsFor:(m_webFrame.get())];
+#endif
     
     [m_webFrame->_private->webFrameView _setDocumentView:cachedView];
 }
 
+#if PLATFORM(IOS)
+void WebFrameLoaderClient::didRestoreFrameHierarchyForCachedFrame()
+{
+    // When entering the PageCache the Document is detached and the plugin view may
+    // have cleaned itself up (removing its webview and layer references). Now, when
+    // restoring the page we want to recreate whatever is necessary.
+    WebView *webView = getWebView(m_webFrame.get());
+    [webView _restorePlugInsFromCache];
+}
+#endif
+
 void WebFrameLoaderClient::transitionToCommittedForNewPage()
 {
     WebView *webView = getWebView(m_webFrame.get());
     WebDataSource *dataSource = [m_webFrame.get() _dataSource];
 
+#if PLATFORM(IOS)
+    bool willProduceHTMLView;
+    // Fast path that skips initialization of objc class objects.
+    if ([dataSource _documentLoader]->responseMIMEType() == "text/html")
+        willProduceHTMLView = true;
+    else
+        willProduceHTMLView = [m_webFrame->_private->webFrameView _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class];
+#else
+    // 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];
+#endif
     bool canSkipCreation = core(m_webFrame.get())->loader().stateMachine()->committingFirstRealLoad() && willProduceHTMLView;
     if (canSkipCreation) {
         [[m_webFrame->_private->webFrameView documentView] setDataSource:dataSource];
         return;
     }
 
+#if !PLATFORM(IOS)
     // Don't suppress scrollbars before the view creation if we're making the view for a non-HTML view.
     if (!willProduceHTMLView)
         [[m_webFrame->_private->webFrameView _scrollView] setScrollBarsSuppressed:NO repaintOnUnsuppress:NO];
@@ -1251,6 +1527,17 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
     [webView removePluginInstanceViewsFor:(m_webFrame.get())];
     
     NSView <WebDocumentView> *documentView = [m_webFrame->_private->webFrameView _makeDocumentViewForDataSource:dataSource];
+#else
+    NSView <WebDocumentView> *documentView = nil;
+
+    // Fast path that skips initialization of objc class objects.
+    if (willProduceHTMLView) {
+        documentView = [[WebHTMLView alloc] initWithFrame:[m_webFrame->_private->webFrameView bounds]];
+        [m_webFrame->_private->webFrameView _setDocumentView:documentView];
+        [documentView release];
+    } else
+        documentView = [m_webFrame->_private->webFrameView _makeDocumentViewForDataSource:dataSource];
+#endif
     if (!documentView)
         return;
 
@@ -1269,8 +1556,12 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
     [m_webFrame.get() _updateBackgroundAndUpdatesWhileOffscreen];
     [m_webFrame->_private->webFrameView _install];
 
-    if (isMainFrame)
+    if (isMainFrame) {
+#if PLATFORM(IOS)
+        coreView->setDelegatesScrolling(true);
+#endif
         coreView->setParentVisible(true);
+    }
 
     // Call setDataSource on the document view after it has been placed in the view hierarchy.
     // This what we for the top-level view, so should do this for views in subframes as well.
@@ -1298,6 +1589,11 @@ void WebFrameLoaderClient::didSaveToPageCache()
 
 void WebFrameLoaderClient::didRestoreFromPageCache()
 {
+#if PLATFORM(IOS)
+    WebView *webView = getWebView(m_webFrame.get());
+    if ([webView mainFrame] == m_webFrame.get())
+        [[webView _UIKitDelegateForwarder] webViewDidRestoreFromPageCache:webView];
+#endif
 }
 
 void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool)
@@ -1341,6 +1637,7 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& act
 {
     unsigned modifierFlags = 0;
     const Event* event = action.event();
+#if !PLATFORM(IOS)
     if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(event))) {
         if (keyStateEvent->ctrlKey())
             modifierFlags |= NSControlKeyMask;
@@ -1351,6 +1648,10 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& act
         if (keyStateEvent->metaKey())
             modifierFlags |= NSCommandKeyMask;
     }
+#else
+    // No modifier flags on iOS right now
+    modifierFlags = 0;
+#endif
 
     NSURL *originalURL = action.url();
 
@@ -1555,6 +1856,53 @@ private:
     }
 };
 
+#if PLATFORM(IOS)
+@interface WAKView (UIKitSecretsWebKitKnowsAboutSeeUIWebPlugInView)
+#if USE(ACCELERATED_COMPOSITING)
+- (PlatformLayer *)pluginLayer;
+- (BOOL)willProvidePluginLayer;
+- (void)attachPluginLayer;
+- (void)detachPluginLayer;
+#endif
+@end
+
+class PluginWidgetIOS : public PluginWidget {
+public:
+    PluginWidgetIOS(WAKView *view)
+        : PluginWidget(view)
+    {
+    }
+
+#if USE(ACCELERATED_COMPOSITING)
+    virtual PlatformLayer* platformLayer() const
+    {
+        if (![platformWidget() respondsToSelector:@selector(pluginLayer)])
+            return nullptr;
+
+        return [platformWidget() pluginLayer];   
+    }
+
+    virtual bool willProvidePluginLayer() const
+    {
+        return [platformWidget() respondsToSelector:@selector(willProvidePluginLayer)]
+            && [platformWidget() willProvidePluginLayer];
+    }
+
+    virtual void attachPluginLayer()
+    {
+        if ([platformWidget() respondsToSelector:@selector(attachPluginLayer)])
+            [platformWidget() attachPluginLayer];
+    }
+
+    virtual void detachPluginLayer()
+    {
+        if ([platformWidget() respondsToSelector:@selector(detachPluginLayer)])
+            [platformWidget() detachPluginLayer];
+    }
+#endif
+};
+#endif // PLATFORM(IOS)
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 class NetscapePluginWidget : public PluginWidget {
@@ -1645,7 +1993,9 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
     int errorCode = 0;
 
     WebView *webView = getWebView(m_webFrame.get());
+#if !PLATFORM(IOS)
     SEL selector = @selector(webView:plugInViewWithArguments:);
+#endif
 
     Document* document = core(m_webFrame.get())->document();
     NSURL *baseURL = document->baseURL();
@@ -1656,8 +2006,11 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
     // 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.
+#if !PLATFORM(IOS)
     Frame* frame = core(m_webFrame.get());
+#endif
     NSMutableArray *attributeKeys = kit(paramNames);
+#if !PLATFORM(IOS)
     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]];
@@ -1682,6 +2035,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
         if (view)
             return adoptRef(new PluginWidget(view));
     }
+#endif
 
     NSString *MIMEType;
     WebBasePluginPackage *pluginPackage;
@@ -1694,7 +2048,12 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
     }
     
     NSString *extension = [[pluginURL path] pathExtension];
+
+#if PLATFORM(IOS)
+    if (!pluginPackage && [extension length]) {
+#else
     if (!pluginPackage && [extension length] && ![MIMEType length]) {
+#endif
         pluginPackage = [webView _pluginForExtension:extension];
         if (pluginPackage) {
             NSString *newMIMEType = [pluginPackage MIMETypeForExtension:extension];
@@ -1752,11 +2111,75 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
             [error release];
         }
 
+#if PLATFORM(IOS)
+        // See if this is a YouTube Flash plug-in
+        if ([MIMEType isEqualToString:@"application/x-shockwave-flash"]) {
+            NSDictionary *attributes = [NSDictionary dictionaryWithObjects:kit(paramValues) forKeys:kit(paramNames)];
+            NSString *srcString = [attributes objectForKey:@"src"];
+            if (srcString) {
+                NSURL *srcURL = [NSURL URLWithString:srcString];
+                NSURL *youtubeURL = [srcURL _webkit_youTubeURL];
+                if (srcURL && youtubeURL) {
+                    // Transform the youtubeURL (youtube:VideoID) to iframe embed url which has the format: http://www.youtube.com/embed/VideoID
+                    NSString *srcPath = [srcURL path];
+                    NSString *videoID = [[youtubeURL absoluteString] substringFromIndex:[[youtubeURL scheme] length] + 1];
+                    NSRange rangeOfVideoIDInPath = [srcPath rangeOfString:videoID];
+                    NSString *srcURLPrefix = nil;
+                    if (rangeOfVideoIDInPath.location == NSNotFound && !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_YOUTUBE_EMBED_IFRAME_TRANSFORM)) {
+                        // If the videoID is not inside srcPath, the embed src url is in wrong format. We still want to support them for apps build against 5.1 and older.
+                        // For embed src like http://www.youtube.com/watch?v=VideoID, we make srcURLPrefix "http://www.youtube.com".
+                        // See: <rdar://problem/11517502> youtube videos don't work in FAO Forestry
+                        srcURLPrefix = [srcString substringToIndex:[srcString rangeOfString:srcPath].location];
+                    } else {
+                        ASSERT(rangeOfVideoIDInPath.length);
+
+                        // From the original URL, we need to get the part before /path/VideoId.
+                        NSRange rangeOfPathBeforeVideoID = [srcString rangeOfString:[srcPath substringToIndex:rangeOfVideoIDInPath.location]];
+                        ASSERT(rangeOfPathBeforeVideoID.length);
+
+                        srcURLPrefix = [srcString substringToIndex:rangeOfPathBeforeVideoID.location];
+                    }
+                    NSString *query = [srcURL query];
+                    // By default, the iframe will display information like the video title and uploader on top of the video.  Don't display
+                    // them if the embeding html doesn't specify it.
+                    if (query && [query length] && [query rangeOfString:@"showinfo"].location == NSNotFound)
+                        query = [query stringByAppendingFormat:@"&showinfo=0"];
+                    else
+                        query = @"showinfo=0";
+
+                    // Append the query string if it is valid.  Some sites apparently forget to add "?" for the query string, in that case,
+                    // we will discard the parameters in the url.
+                    // See: <rdar://problem/11535155> [Bincompat] Regression: SC2Casts app: Videos don't play in SC2Casts
+                    NSString *embedSrc = query ? [srcURLPrefix stringByAppendingFormat:@"/embed/%@?%@", videoID, query] : [srcURLPrefix stringByAppendingFormat:@"/embed/%@", videoID];
+
+                    if (element->hasTagName(HTMLNames::embedTag) || element->hasTagName(HTMLNames::objectTag)) {
+                        // Create a shadow subtree for the plugin element, the iframe player is injected in the shadow tree.
+                        HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
+                        pluginElement->createShadowIFrameSubtree(embedSrc);
+                        return nullptr;
+                    }
+
+                    // If this is a YouTube Flash plug-in.  We don't have Flash.  Create an instance of Apple's special YouTube plug-in instead
+                    pluginPackage = [webView _pluginForMIMEType:@"application/x-apple-fake-youtube-plugin"];
+                    if (pluginPackage) {
+                        view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, kit(paramNames), kit(paramValues), baseURL, kit(element), loadManually);
+                        if (view)
+                            return adoptRef(new PluginWidgetIOS(view));
+                    }
+                }
+            }
+        }
+#endif // PLATFORM(IOS)
+
         return 0;
     }
     
     ASSERT(view);
+#if PLATFORM(IOS)
+    return adoptRef(new PluginWidgetIOS(view));
+#else
     return adoptRef(new PluginWidget(view));
+#endif
 
     END_BLOCK_OBJC_EXCEPTIONS;
 
@@ -1861,6 +2284,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createMediaPlayerProxyPlugin(const IntS
     WebView *webView = getWebView(m_webFrame.get());
     NSURL *URL = url;
 
+#if !PLATFORM(IOS)
     SEL selector = @selector(webView:plugInViewWithArguments:);
 
     if ([[webView UIDelegate] respondsToSelector:selector]) {
@@ -1881,6 +2305,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createMediaPlayerProxyPlugin(const IntS
         if (view)
             return adoptRef(new PluginWidget(view));
     }
+#endif
 
     WebBasePluginPackage *pluginPackage = [webView _videoProxyPluginForMIMEType:mimeType];
     Document* document = core(m_webFrame.get())->document();
@@ -1906,7 +2331,11 @@ PassRefPtr<Widget> WebFrameLoaderClient::createMediaPlayerProxyPlugin(const IntS
     }
     
     ASSERT(view);
+#if PLATFORM(IOS)
+    return adoptRef(new PluginWidgetIOS(view));
+#else
     return adoptRef(new PluginWidget(view));
+#endif
 
     END_BLOCK_OBJC_EXCEPTIONS;
 
@@ -1993,13 +2422,28 @@ PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext
     return WebFrameNetworkingContext::create(core(m_webFrame.get()));
 }
 
+#if PLATFORM(IOS)
+bool WebFrameLoaderClient::shouldLoadMediaElementURL(const URL& url) const 
+{
+    WebView *webView = getWebView(m_webFrame.get());
+    
+    if (id policyDelegate = [webView policyDelegate]) {
+        if ([policyDelegate respondsToSelector:@selector(webView:shouldLoadMediaURL:inFrame:)])
+            return [policyDelegate webView:webView shouldLoadMediaURL:url inFrame:m_webFrame.get()];
+    }
+    return true;
+}
+#endif
+
 @implementation WebFramePolicyListener
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
index 6471921..ee6ddab 100644 (file)
@@ -38,6 +38,12 @@ public:
     static void ensurePrivateBrowsingSession();
     static void destroyPrivateBrowsingSession();
 
+#if PLATFORM(IOS)
+    // FIXME: If MobileSafari ever switches to per-tab or non-shared private storage, then this can be removed.
+    // <rdar://problem/10075665> Sub-TLF: Per-tab private browsing
+    static void clearPrivateBrowsingSessionCookieStorage();
+#endif
+
 private:
 
     WebFrameNetworkingContext(WebCore::Frame* frame)
index aa95727..0db4f80 100644 (file)
 #include <WebCore/Settings.h>
 #include <wtf/NeverDestroyed.h>
 
+#if PLATFORM(IOS)
+#import <CFNetwork/CFHTTPCookiesPriv.h>
+#import <WebCore/WebCoreThread.h>
+#import <WebKit/WebFrameLoadDelegate.h>
+#endif
+
 using namespace WebCore;
 
 static std::unique_ptr<NetworkStorageSession>& privateSession()
@@ -59,6 +65,16 @@ void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
     privateSession() = nullptr;
 }
 
+#if PLATFORM(IOS)
+void WebFrameNetworkingContext::clearPrivateBrowsingSessionCookieStorage()
+{
+    ASSERT(isMainThread());
+    ASSERT(privateSession());
+
+    CFHTTPCookieStorageDeleteAllCookies(privateSession()->cookieStorage().get());
+}
+#endif
+
 bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const
 {
     return frame() && frame()->settings().needsSiteSpecificQuirks();
index 5443622..80a4389 100644 (file)
@@ -40,7 +40,12 @@ public:
     virtual void geolocationDestroyed() OVERRIDE;
     virtual void startUpdating() OVERRIDE;
     virtual void stopUpdating() OVERRIDE;
+#if PLATFORM(IOS)
+    // FIXME: unify this with Mac on OpenSource.
+    virtual void setEnableHighAccuracy(bool) OVERRIDE;
+#else
     virtual void setEnableHighAccuracy(bool) OVERRIDE { }
+#endif
 
     virtual WebCore::GeolocationPosition* lastPosition() OVERRIDE;
 
index 27e5bab..d58460e 100644 (file)
 #import <WebCore/Frame.h>
 #import <WebCore/Geolocation.h>
 
+#if PLATFORM(IOS)
+#import <WebCore/WAKResponder.h>
+#import <WebKit/WebCoreThreadRun.h>
+#endif
+
 using namespace WebCore;
 
+#if !PLATFORM(IOS)
+@interface WebGeolocationPolicyListener : NSObject <WebAllowDenyPolicyListener>
+{
+    RefPtr<Geolocation> _geolocation;
+}
+- (id)initWithGeolocation:(Geolocation*)geolocation;
+@end
+#else
 @interface WebGeolocationPolicyListener : NSObject <WebAllowDenyPolicyListener>
 {
     RefPtr<Geolocation> _geolocation;
+    RetainPtr<WebView *> _webView;
+    RetainPtr<id<WebGeolocationProvider> > _geolocationProvider;
+}
+- (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView provider:(id<WebGeolocationProvider>)provider;
+@end
+#endif
+
+#if PLATFORM(IOS)
+@interface WebGeolocationProviderInitializationListener : NSObject <WebGeolocationProviderInitializationListener> {
+@private
+    RefPtr<Geolocation> m_geolocation;
 }
 - (id)initWithGeolocation:(Geolocation*)geolocation;
 @end
+#endif
 
 WebGeolocationClient::WebGeolocationClient(WebView *webView)
     : m_webView(webView)
@@ -67,6 +92,15 @@ void WebGeolocationClient::stopUpdating()
     [[m_webView _geolocationProvider] unregisterWebView:m_webView];
 }
 
+#if PLATFORM(IOS)
+void WebGeolocationClient::setEnableHighAccuracy(bool wantsHighAccuracy)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    [[m_webView _geolocationProvider] setEnableHighAccuracy:wantsHighAccuracy];
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+#endif
+
 void WebGeolocationClient::requestPermission(Geolocation* geolocation)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -77,6 +111,7 @@ void WebGeolocationClient::requestPermission(Geolocation* geolocation)
         return;
     }
 
+#if !PLATFORM(IOS)
     Frame *frame = geolocation->frame();
     WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
     WebGeolocationPolicyListener* listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:geolocation];
@@ -85,7 +120,10 @@ void WebGeolocationClient::requestPermission(Geolocation* geolocation)
 
     [webOrigin release];
     [listener release];
-
+#else
+    RetainPtr<WebGeolocationProviderInitializationListener> listener = adoptNS([[WebGeolocationProviderInitializationListener alloc] initWithGeolocation:geolocation]);
+    [[m_webView _geolocationProvider] initializeGeolocationForWebView:m_webView listener:listener.get()];
+#endif
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
@@ -94,6 +132,7 @@ GeolocationPosition* WebGeolocationClient::lastPosition()
     return core([[m_webView _geolocationProvider] lastPosition]);
 }
 
+#if !PLATFORM(IOS)
 @implementation WebGeolocationPolicyListener
 
 - (id)initWithGeolocation:(Geolocation*)geolocation
@@ -116,4 +155,86 @@ GeolocationPosition* WebGeolocationClient::lastPosition()
 
 @end
 
+#else
+@implementation WebGeolocationPolicyListener
+- (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView provider:(id<WebGeolocationProvider>)provider
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    _geolocation = geolocation;
+    _webView = webView;
+    _geolocationProvider = provider;
+    return self;
+}
+
+- (void)allow
+{
+    WebThreadRun(^{
+        _geolocation->setIsAllowed(true);
+    });
+}
+
+- (void)deny
+{
+    WebThreadRun(^{
+        _geolocation->setIsAllowed(false);
+        [_geolocationProvider.get() cancelWarmUpForWebView:_webView.get()];
+    });
+}
+
+- (void)denyOnlyThisRequest
+{
+    WebThreadRun(^{
+        // A soft deny does not prevent subsequent request from the Geolocation object.
+        [self deny];
+        _geolocation->resetAllGeolocationPermission();
+    });
+}
+
+- (BOOL)shouldClearCache
+{
+    // Theoretically, WebView could changes the WebPreferences after we get the pointer.
+    // We lock to be on the safe side.
+    WebThreadLock();
+
+    return [[_webView.get() preferences] _alwaysRequestGeolocationPermission];
+}
+@end
+
+@implementation WebGeolocationProviderInitializationListener
+- (id)initWithGeolocation:(Geolocation*)geolocation
+{
+    self = [super init];
+    if (self)
+        m_geolocation = geolocation;
+    return self;
+}
+
+- (void)initializationAllowedWebView:(WebView *)webView provider:(id<WebGeolocationProvider>)provider
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+    Frame* frame = m_geolocation->frame();
+    if (!frame) {
+        [provider cancelWarmUpForWebView:webView];
+        return;
+    }
+    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
+    WebGeolocationPolicyListener *listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:m_geolocation.get() forWebView:webView provider:provider];
+    SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:);
+    CallUIDelegate(webView, selector, webOrigin, kit(frame), listener);
+    [webOrigin release];
+    [listener release];
+
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+- (void)initializationDeniedWebView:(WebView *)webView provider:(id<WebGeolocationProvider>)provider
+{
+    m_geolocation->setIsAllowed(false);
+}
+@end
+#endif // PLATFORM(IOS)
+
 #endif // ENABLE(GEOLOCATION)
index 4728a6e..de9d041 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebJavaScriptTextInputPanel.h"
 
 #import <wtf/Assertions.h>
@@ -71,3 +73,5 @@
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index 3e535ea..864d991 100644 (file)
@@ -23,6 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <WebKit/WebKeyGenerator.h>
 
 #import <WebKitSystemInterface.h>
@@ -59,3 +61,5 @@ static inline WebCertificateParseResult toWebCertificateParseResult(WKCertificat
 }
 
 @end
+
+#endif // !PLATFORM(IOS)
index 2d4a0a3..b4a1c3f 100644 (file)
@@ -288,5 +288,18 @@ uint64_t WebNotificationClient::notificationIDForTesting(WebCore::Notification*
 #endif
 }
 
+#if PLATFORM(IOS)
+- (void)denyOnlyThisRequest
+{
+    ASSERT_NOT_REACHED();
+}
+
+- (BOOL)shouldClearCache
+{
+    ASSERT_NOT_REACHED();
+    return NO;
+}
+#endif
+
 @end
 #endif
index 2295e07..3573341 100644 (file)
@@ -88,4 +88,30 @@ using namespace WebCore;
     _chooser = 0;
 }
 
+#if PLATFORM(IOS)
+- (void)chooseFilename:(NSString *)filename displayString:(NSString *)displayString iconImage:(CGImageRef)imageRef
+{
+    [self chooseFilenames:[NSArray arrayWithObject:filename] displayString:displayString iconImage:imageRef];
+}
+
+- (void)chooseFilenames:(NSArray *)filenames displayString:(NSString *)displayString iconImage:(CGImageRef)imageRef
+{
+    ASSERT(_chooser);
+    if (!_chooser)
+        return;
+
+    RefPtr<Icon> icon = Icon::createIconForImage(imageRef);
+
+    NSUInteger count = [filenames count];
+    Vector<String> names(count);
+    for (NSUInteger i = 0; i < count; ++i)
+        names[i] = [filenames objectAtIndex:i];
+    _chooser->chooseMediaFiles(names, displayString, icon.get());
+    
+    // FIXME: we shouldn't be manually deref()'ing here.
+    _chooser->deref();
+    _chooser = nullptr;
+}
+#endif
+
 @end
index a180045..a8a751f 100644 (file)
@@ -66,6 +66,13 @@ using namespace WebCore;
     return reinterpret_cast<SecurityOrigin*>(_private)->databaseIdentifier();
 }
 
+#if PLATFORM(IOS)
+- (NSString *)toString
+{
+    return reinterpret_cast<SecurityOrigin*>(_private)->toString();
+}
+#endif
+
 - (NSString *)stringValue
 {
     return reinterpret_cast<SecurityOrigin*>(_private)->toString();
index 485e656..35dcbf4 100644 (file)
@@ -42,15 +42,19 @@ void InitWebCoreSystemInterface(void)
     if (didInit)
         return;
 
+#if !PLATFORM(IOS)
     INIT(AdvanceDefaultButtonPulseAnimation);
+#endif
     INIT(CALayerEnumerateRectsBeingDrawnWithBlock);
+#if !PLATFORM(IOS)
     INIT(CGContextGetShouldSmoothFonts);
+#endif
     INIT(CGPatternCreateWithImageAndTransform);
     INIT(CGContextResetClip);
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
     INIT(CGContextDrawsWithCorrectShadowOffsets);
 #endif
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     INIT(CTFontTransformGlyphs);
 #endif
     INIT(CopyCFLocalizationPreferredName);
@@ -60,6 +64,7 @@ void InitWebCoreSystemInterface(void)
     INIT(CopyNSURLResponseCertificateChain);
 #endif
     INIT(CreateCustomCFReadStream);
+#if !PLATFORM(IOS)
     INIT(DrawCapsLockIndicator);
     INIT(DrawBezeledTextArea);
     INIT(DrawBezeledTextFieldCell);
@@ -71,9 +76,11 @@ void InitWebCoreSystemInterface(void)
     INIT(GetFontInLanguageForCharacter);
     INIT(GetFontInLanguageForRange);
     INIT(GetGlyphTransformedAdvances);
+#endif
     INIT(GetHTTPPipeliningPriority);
     INIT(GetMIMETypeForExtension);
     INIT(GetNSURLResponseLastModifiedDate);
+#if !PLATFORM(IOS)
     INIT(SignedPublicKeyAndChallengeString);
     INIT(GetPreferredExtensionForMIMEType);
     INIT(GetWheelEventDeltas);
@@ -81,18 +88,23 @@ void InitWebCoreSystemInterface(void)
     INIT(GetNSEventKeyChar);
 #endif
     INIT(HitTestMediaUIPart);
+#endif
     INIT(InitializeMaximumHTTPConnectionCountPerHost);
+#if !PLATFORM(IOS)
     INIT(MeasureMediaUIPart);
     INIT(CreateMediaUIBackgroundView);
     INIT(CreateMediaUIControl);
     INIT(WindowSetAlpha);
     INIT(WindowSetScaledFrame);
     INIT(PopupMenu);
-    INIT(SetBaseCTM);
     INIT(SetCGFontRenderingMode);
+#endif
+    INIT(SetBaseCTM);
     INIT(SetCONNECTProxyAuthorizationForStream);
     INIT(SetCONNECTProxyForStream);
+#if !PLATFORM(IOS)
     INIT(SetDragImage);
+#endif
     INIT(SetHTTPPipeliningMaximumPriority);
     INIT(SetHTTPPipeliningPriority);
     INIT(SetHTTPPipeliningMinimumFastLanePriority);
@@ -105,6 +117,7 @@ void InitWebCoreSystemInterface(void)
     INIT(SignalCFReadStreamEnd);
     INIT(SignalCFReadStreamError);
     INIT(SignalCFReadStreamHasBytes);
+#if ENABLE(VIDEO) && !PLATFORM(IOS)
     INIT(QTIncludeOnlyModernMediaFileTypes);
     INIT(QTMovieDataRate);
     INIT(QTMovieDisableComponent);
@@ -120,22 +133,36 @@ void InitWebCoreSystemInterface(void)
     INIT(QTGetSitesInMediaDownloadCache);
     INIT(QTClearMediaDownloadCacheForSite);
     INIT(QTClearMediaDownloadCache);
+#endif
 
+#if !PLATFORM(IOS)
     INIT(GetGlyphsForCharacters);
+#endif
     INIT(GetVerticalGlyphsForCharacters);
+#if PLATFORM(IOS)
+    INIT(ExecutableWasLinkedOnOrAfterIOSVersion);
+    INIT(GetDeviceClass);
+    INIT(GetViewportScreenSize);
+    INIT(GetScreenScaleFactor);
+    INIT(IsGB18030ComplianceRequired);
+#endif
 
     INIT(CreateCTLineWithUniCharProvider);
 
+#if !PLATFORM(IOS_SIMULATOR)
     INIT(IOSurfaceContextCreate);
     INIT(IOSurfaceContextCreateImage);
+#endif
     INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
     INIT(CTRunGetInitialAdvance);
+#if !PLATFORM(IOS)
     INIT(RecommendedScrollerStyle);
     INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
     INIT(SetCrashReportApplicationSpecificInformation);
     INIT(CopyDefaultSearchProviderDisplayName);
     INIT(AVAssetResolvedURL);
     INIT(Cursor);
+#endif
 
 #if USE(CFNETWORK)
     INIT(GetDefaultHTTPCookieStorage);
@@ -146,6 +173,7 @@ void InitWebCoreSystemInterface(void)
     INIT(SetRequestStorageSession);
 #endif
 
+#if !PLATFORM(IOS)
 #if PLATFORM(MAC)
     INIT(SpeechSynthesisGetVoiceIdentifiers);
     INIT(SpeechSynthesisGetDefaultVoiceIdentifierForLocale);
@@ -160,6 +188,7 @@ void InitWebCoreSystemInterface(void)
     INIT(AccessibilityHandleFocusChanged);
     INIT(CreateAXUIElementRef);
     INIT(UnregisterUniqueIdForElement);
+#endif
     INIT(CreatePrivateStorageSession);
     INIT(CopyRequestWithStorageSession);
     INIT(CopyHTTPCookieStorage);
@@ -180,20 +209,24 @@ void InitWebCoreSystemInterface(void)
     INIT(CopyCFURLResponseSuggestedFilename);
     INIT(SetCFURLResponseMIMEType);
 
+#if !PLATFORM(IOS)
     INIT(SetMetadataURL);
+#endif
 
 #if PLATFORM(MAC)
     // FIXME: We should stop using this file in Chromium.
 
     INIT(DestroyRenderingResources);
 
+#if !PLATFORM(IOS)
     INIT(CreateVMPressureDispatchOnMainQueue);
+#endif
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     INIT(CreateMemoryStatusPressureCriticalDispatchOnMainQueue);
 #endif
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
     INIT(ExecutableWasLinkedOnOrBeforeLion);
 #endif
 
index 0abdaa0..2a1bf4b 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <TargetConditionals.h>
+
 #ifdef __cplusplus
 #define NULL __null
 #else
@@ -54,6 +56,7 @@
 
 #endif
 
+#if !TARGET_OS_IPHONE
 #import <ApplicationServices/ApplicationServices.h>
 #import <Carbon/Carbon.h>
 
@@ -65,9 +68,14 @@ typedef float CGFloat;
 #endif
 #define CGFLOAT_DEFINED 1
 #endif
+#endif
 
 #ifdef __OBJC__
+#if !TARGET_OS_IPHONE
 #import <Cocoa/Cocoa.h>
+#else
+#import <Foundation/Foundation.h>
+#endif
 #endif
 
 #include <wtf/Platform.h>
index 3572945..670a268 100644 (file)
@@ -67,9 +67,11 @@ static NSString * const WebSubframeArchivesKey = @"WebSubframeArchives";
 
 + (void)initialize
 {
+#if !PLATFORM(IOS)
     JSC::initializeThreading();
     WTF::initializeMainThreadToProcessMainThread();
     RunLoop::initializeMainRunLoop();
+#endif
     WebCoreObjCFinalizeOnMainThread(self);
 }
 
index 968d2de..5383980 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import <AppKit/AppKit.h>
 
 @interface WebClipView : NSClipView
@@ -41,3 +43,5 @@
 - (NSRect)additionalClip;
 
 @end
+
+#endif
index 6a96482..9267e6b 100644 (file)
 #import <wtf/RetainPtr.h>
 #import <wtf/RunLoop.h>
 
+#if PLATFORM(IOS)
+#import "WebPDFViewIOS.h"
+#endif
+
 using namespace WebCore;
 
 class WebDataSourcePrivate
@@ -75,6 +79,9 @@ public:
         : loader(loader)
         , representationFinishedLoading(NO)
         , includedInWebKitStatistics(NO)
+#if PLATFORM(IOS)
+        , _dataSourceDelegate(nil)
+#endif
     {
         ASSERT(this->loader);
     }
@@ -90,6 +97,9 @@ public:
     RetainPtr<id<WebDocumentRepresentation> > representation;
     BOOL representationFinishedLoading;
     BOOL includedInWebKitStatistics;
+#if PLATFORM(IOS)
+    NSObject<WebDataSourcePrivateDelegate> *_dataSourceDelegate;
+#endif
 };
 
 static inline WebDataSourcePrivate* toPrivate(void* privateAttribute)
@@ -143,9 +153,11 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 + (void)initialize
 {
     if (self == [WebDataSource class]) {
+#if !PLATFORM(IOS)
         JSC::initializeThreading();
         WTF::initializeMainThreadToProcessMainThread();
         RunLoop::initializeMainRunLoop();
+#endif
         WebCoreObjCFinalizeOnMainThread(self);
     }
 }
@@ -164,6 +176,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
         toPrivate(_private)->loader->addAllArchiveResources([archive _coreLegacyWebArchive]);
 }
 
+#if !PLATFORM(IOS)
 - (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL
 {
     if ([URL isFileURL])
@@ -182,6 +195,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     
     return nil;
 }
+#endif
 
 - (NSString *)_responseMIMEType
 {
@@ -206,6 +220,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     toPrivate(_private)->loader->setDeferMainResourceDataLoad(flag);
 }
 
+#if PLATFORM(IOS)
+- (void)_setOverrideTextEncodingName:(NSString *)encoding
+{
+    toPrivate(_private)->loader->setOverrideEncoding([encoding UTF8String]);
+}
+#endif
+
 - (void)_setAllowToBeMemoryMapped
 {
 #if ENABLE(DISK_IMAGE_CACHE) && PLATFORM(IOS)
@@ -298,7 +319,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
         // Since this is a "secret default" we don't both registering it.
         BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
         if (!omitPDFSupport)
+#if PLATFORM(IOS)
+#define WebPDFRepresentation ([WebView _getPDFRepresentationClass])
+#endif
             addTypesFromClass(repTypes, [WebPDFRepresentation class], [WebPDFRepresentation supportedMIMETypes]);
+#if PLATFORM(IOS)
+#undef WebPDFRepresentation
+#endif
     }
     
     if (!addedImageTypes && !allowImageTypeOmission) {
@@ -389,7 +416,12 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 - (void)_makeRepresentation
 {
     Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType] allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];
-    
+
+#if PLATFORM(IOS)
+    if ([repClass respondsToSelector:@selector(_representationClassForWebFrame:)])
+        repClass = [repClass performSelector:@selector(_representationClassForWebFrame:) withObject:[self webFrame]];
+#endif
+
     // Check if the data source was already bound?
     if (![[self representation] isKindOfClass:repClass]) {
         id newRep = repClass != nil ? [[repClass alloc] init] : nil;
@@ -399,6 +431,9 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
     id<WebDocumentRepresentation> representation = toPrivate(_private)->representation.get();
     [representation setDataSource:self];
+#if PLATFORM(IOS)
+    toPrivate(_private)->loader->setResponseMIMEType([self _responseMIMEType]);
+#endif
 }
 
 - (DocumentLoader*)_documentLoader
index 2029ecf..18876bc 100644 (file)
 #import "WebTypesInternal.h"
 #import <JavaScriptCore/JSBase.h>
 
+#if PLATFORM(IOS)
+#import <WebKit/WAKAppKitStubs.h>
+#endif
+
 @class WebView;
 
 struct WebResourceDelegateImplementationCache {
@@ -39,6 +43,19 @@ struct WebResourceDelegateImplementationCache {
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     IMP canAuthenticateAgainstProtectionSpaceFunc;
 #endif
+
+#if PLATFORM(IOS)
+    IMP connectionPropertiesFunc;
+    IMP webThreadDidFinishLoadingFromDataSourceFunc;
+    IMP webThreadDidFailLoadingWithErrorFromDataSourceFunc;
+    IMP webThreadIdentifierForRequestFunc;
+    IMP webThreadDidLoadResourceFromMemoryCacheFunc;
+    IMP webThreadWillSendRequestFunc;
+    IMP webThreadDidReceiveResponseFunc;
+    IMP webThreadDidReceiveContentLengthFunc;
+    IMP webThreadWillCacheResponseFunc;
+#endif
+
     IMP identifierForRequestFunc;
     IMP willSendRequestFunc;
     IMP didReceiveResponseFunc;
@@ -84,6 +101,9 @@ struct WebFrameLoadDelegateImplementationCache {
     IMP didRunInsecureContentFunc;
     IMP didDetectXSSFunc;
     IMP didRemoveFrameFromHierarchyFunc;
+#if PLATFORM(IOS)
+    IMP webThreadDidLayoutFunc;
+#endif
 };
 
 struct WebScriptDebugDelegateImplementationCache {
@@ -126,6 +146,9 @@ BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id);
 BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, id);
 BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, BOOL);
 BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, BOOL, id);
+#if PLATFORM(IOS)
+BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id, id, BOOL);
+#endif
 
 id CallFrameLoadDelegate(IMP, WebView *, SEL);
 id CallFrameLoadDelegate(IMP, WebView *, SEL, NSUInteger);
@@ -134,6 +157,10 @@ id CallFrameLoadDelegate(IMP, WebView *, SEL, id, id);
 id CallFrameLoadDelegate(IMP, WebView *, SEL, id, id, id);
 id CallFrameLoadDelegate(IMP, WebView *, SEL, id, id, id, id);
 id CallFrameLoadDelegate(IMP, WebView *, SEL, id, NSTimeInterval, id, id);
+#if PLATFORM(IOS)
+id CallFrameLoadDelegate(IMP, WebView *, SEL, id, double);
+id CallFrameLoadDelegateInWebThread(IMP, WebView *, SEL, NSUInteger);
+#endif
 
 BOOL CallFrameLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL);
 
@@ -142,6 +169,13 @@ id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, id);
 id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, id, id);
 id CallResourceLoadDelegate(IMP, WebView *, SEL, id, NSInteger, id);
 id CallResourceLoadDelegate(IMP, WebView *, SEL, id, id, NSInteger, id);
+#if PLATFORM(IOS)
+id CallResourceLoadDelegateInWebThread(IMP, WebView *, SEL, id, id);
+id CallResourceLoadDelegateInWebThread(IMP, WebView *, SEL, id, id, id);
+id CallResourceLoadDelegateInWebThread(IMP, WebView *, SEL, id, id, id, id);
+id CallResourceLoadDelegateInWebThread(IMP, WebView *, SEL, id, NSInteger, id);
+id CallResourceLoadDelegateInWebThread(IMP, WebView *, SEL, id, id, NSInteger, id);
+#endif
 
 BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id);
 BOOL CallResourceLoadDelegateReturningBoolean(BOOL, IMP, WebView *, SEL, id, id);
index 7085ac8..d01cb9b 100644 (file)
 #import "WebViewData.h"
 #import <wtf/ObjcRuntimeExtras.h>
 
+#if PLATFORM(IOS)
+#import "WebViewInternal.h"
+#import <WebCore/WebCoreThreadMessage.h>
+#endif
+
 @implementation WebView (WebDelegateImplementationCaching)
 
 WebResourceDelegateImplementationCache* WebViewGetResourceLoadDelegateImplementations(WebView *webView)
@@ -73,14 +78,17 @@ WebHistoryDelegateImplementationCache* WebViewGetHistoryDelegateImplementations(
 // preventing more ObjC message dispatch and compensating for the expense of the @try/@catch.
 
 typedef float (*ObjCMsgSendFPRet)(id, SEL, ...);
+#if !PLATFORM(IOS)
 #if defined(__i386__)
 static const ObjCMsgSendFPRet objc_msgSend_float_return = reinterpret_cast<ObjCMsgSendFPRet>(objc_msgSend_fpret);
 #else
 static const ObjCMsgSendFPRet objc_msgSend_float_return = reinterpret_cast<ObjCMsgSendFPRet>(objc_msgSend);
 #endif
+#endif
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -89,10 +97,31 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector)
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -101,10 +130,32 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector, id objec
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector, NSRect rect)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -113,10 +164,32 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector, NSRect r
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&rect atIndex:3];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -125,10 +198,33 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector, id objec
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object, BOOL boolean)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -137,10 +233,33 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector, id objec
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+    [invocation setArgument:&boolean atIndex:4];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object1, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -149,10 +268,34 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector, id objec
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+    [invocation setArgument:&object3 atIndex:5];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(WebView *self, id delegate, SEL selector, id object, NSUInteger integer)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
     @try {
@@ -161,10 +304,33 @@ static inline id CallDelegate(WebView *self, id delegate, SEL selector, id objec
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+    [invocation setArgument:&integer atIndex:4];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline float CallDelegateReturningFloat(WebView *self, id delegate, SEL selector)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return 0.0f;
     @try {
@@ -173,10 +339,28 @@ static inline float CallDelegateReturningFloat(WebView *self, id delegate, SEL s
         ReportDiscardedDelegateException(selector, exception);
     }
     return 0.0f;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return 0.0f;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+
+    float returnValue = 0.0f;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return 0.0f;
+#endif
 }
 
 static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return result;
     @try {
@@ -185,10 +369,28 @@ static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id d
         ReportDiscardedDelegateException(selector, exception);
     }
     return result;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return result;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+
+    BOOL returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return result;
+#endif
 }
 
 static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return result;
     @try {
@@ -197,10 +399,29 @@ static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id d
         ReportDiscardedDelegateException(selector, exception);
     }
     return result;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return result;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+
+    BOOL returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return result;
+#endif
 }
 
 static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object, BOOL boolean)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return result;
     @try {
@@ -209,6 +430,25 @@ static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id d
         ReportDiscardedDelegateException(selector, exception);
     }
     return result;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return result;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+    [invocation setArgument:&boolean atIndex:4];
+
+    BOOL returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return result;
+#endif
 }
 
 static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object, BOOL boolean, id object2)
@@ -225,6 +465,7 @@ static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id d
 
 static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     if (!delegate || ![delegate respondsToSelector:selector])
         return result;
     @try {
@@ -233,10 +474,54 @@ static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id d
         ReportDiscardedDelegateException(selector, exception);
     }
     return result;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return result;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+
+    BOOL returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return result;
+#endif
+}
+
+#if PLATFORM(IOS)
+static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector, id object1, id object2, BOOL boolean)
+{
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return result;
+    
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+    [invocation setArgument:&boolean atIndex:5];
+    
+    BOOL returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return result;
 }
+#endif
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -245,10 +530,31 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, NSUInteger integer)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -257,10 +563,32 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate || ![delegate respondsToSelector:selector])
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&integer atIndex:3];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -269,10 +597,83 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
+#if PLATFORM(IOS)
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2)
+{
+    if (!delegate)
+        return nil;
+    @try {
+        return wtfCallIMP<id>(implementation, delegate, selector, self, object1, object2);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, id object3)
+{
+    if (!delegate)
+        return nil;
+    @try {
+        return wtfCallIMP<id>(implementation, delegate, selector, self, object1, object2, object3);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, id object3, id object4)
+{
+    if (!delegate)
+        return nil;
+    @try {
+        return wtfCallIMP<id>(implementation, delegate, selector, self, object1, object2, object3, object4);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, NSUInteger integer)
+{
+    if (!delegate)
+        return nil;
+    @try {
+        return wtfCallIMP<id>(implementation, delegate, selector, self, integer);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+
+#endif // PLATFORM(IOS)
+
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -281,10 +682,59 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
+#if PLATFORM(IOS)
+static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object, double double1)
+{
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+    [invocation setArgument:&double1 atIndex:4];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+#endif
+
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -293,10 +743,34 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+    [invocation setArgument:&object3 atIndex:5];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, id object3, id object4)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -305,10 +779,35 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+    [invocation setArgument:&object3 atIndex:5];
+    [invocation setArgument:&object4 atIndex:6];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer, id object2)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -317,9 +816,36 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&integer atIndex:4];
+    [invocation setArgument:&object2 atIndex:5];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
+#if !PLATFORM(IOS)
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer1, int integer2, id object2)
+#else
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer1, int integer2, id object2)
+#endif
 {
     if (!delegate)
         return nil;
@@ -345,6 +871,7 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, NSInteger integer, id object3)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -353,9 +880,62 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+    [invocation setArgument:&integer atIndex:5];
+    [invocation setArgument:&object3 atIndex:6];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
+#if PLATFORM(IOS)
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer, id object2)
+{
+    if (!delegate)
+        return nil;
+    @try {
+        return wtfCallIMP<id>(implementation, delegate, selector, self, object1, integer, object2);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, id object2, NSInteger integer, id object3)
+{
+    if (!delegate)
+        return nil;
+    @try {
+        return wtfCallIMP<id>(implementation, delegate, selector, self, object1, object2, integer, object3);
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+}
+#endif
+
+#if !PLATFORM(IOS)
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer1, id object2, NSInteger integer2, id object3)
+#else
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer1, id object2, NSInteger integer2, id object3)
+#endif
 {
     if (!delegate)
         return nil;
@@ -367,7 +947,11 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
     return nil;
 }
 
+#if !PLATFORM(IOS)
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer, id object2, id object3, id object4)
+#else
+static inline id CallDelegateInWebThread(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSInteger integer, id object2, id object3, id object4)
+#endif
 {
     if (!delegate)
         return nil;
@@ -381,6 +965,7 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
 
 static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SEL selector, id object1, NSTimeInterval interval, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     if (!delegate)
         return nil;
     @try {
@@ -389,112 +974,234 @@ static inline id CallDelegate(IMP implementation, WebView *self, id delegate, SE
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&self atIndex:2];
+    [invocation setArgument:&object1 atIndex:3];
+    [invocation setArgument:&interval atIndex:4];
+    [invocation setArgument:&object2 atIndex:5];
+    [invocation setArgument:&object3 atIndex:6];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector);
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector, id object)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector, object);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector, object);
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector, id object, BOOL boolean)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector, object, boolean);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector, object, boolean);
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector, NSRect rect)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector, rect);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector, rect);
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector, object1, object2);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector, object1, object2);
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector, id object1, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector, object1, object2, object3);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector, object1, object2, object3);
+#endif
 }
 
 id CallUIDelegate(WebView *self, SEL selector, id object, NSUInteger integer)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(self, self->_private->UIDelegate, selector, object, integer);
+#else
+    return CallDelegate(self, [self _UIDelegateForSelector:selector], selector, object, integer);
+#endif
 }
 
 float CallUIDelegateReturningFloat(WebView *self, SEL selector)
 {
+#if !PLATFORM(IOS)
     return CallDelegateReturningFloat(self, self->_private->UIDelegate, selector);
+#else
+    return CallDelegateReturningFloat(self, [self _UIDelegateForSelector:selector], selector);
+#endif
 }
 
 BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector)
 {
+#if !PLATFORM(IOS)
     return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector);
+#else
+    return CallDelegateReturningBoolean(result, self, [self _UIDelegateForSelector:selector], selector);
+#endif
 }
 
 BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object)
 {
+#if !PLATFORM(IOS)
     return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object);
+#else
+    return CallDelegateReturningBoolean(result, self, [self _UIDelegateForSelector:selector], selector, object);
+#endif
 }
 
 BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object, BOOL boolean)
 {
+#if !PLATFORM(IOS)
     return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object, boolean);
+#else
+    return CallDelegateReturningBoolean(result, self, [self _UIDelegateForSelector:selector], selector, object, boolean);
+#endif
 }
 
 BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object, BOOL boolean, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object, boolean, object2);
+#else
+    return CallDelegateReturningBoolean(result, self, [self _UIDelegateForSelector:selector], selector, object, boolean, object2);
+#endif
 }
 
 BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegateReturningBoolean(result, self, self->_private->UIDelegate, selector, object1, object2);
+#else
+    return CallDelegateReturningBoolean(result, self, [self _UIDelegateForSelector:selector], selector, object1, object2);
+#endif
 }
 
+#if PLATFORM(IOS)
+BOOL CallUIDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object1, id object2, BOOL boolean)
+{
+    return CallDelegateReturningBoolean(result, self, [self _UIDelegateForSelector:selector], selector, object1, object2, boolean);
+}
+#endif
+
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector);
+#endif
 }
 
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, NSUInteger integer)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, integer);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, integer);
+#endif
 }
 
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, object);
+#endif
 }
 
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, object2);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, object1, object2);
+#endif
 }
 
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, object2, object3);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, object1, object2, object3);
+#endif
 }
 
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3, id object4)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, object2, object3, object4);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, object1, object2, object3, object4);
+#endif
 }
 
 id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSTimeInterval interval, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->frameLoadDelegate, selector, object1, interval, object2, object3);
+#else
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, object1, interval, object2, object3);
+#endif
 }
 
+#if PLATFORM(IOS)
+id CallFrameLoadDelegate(IMP implementation, WebView *self, SEL selector, id object, double double1)
+{
+    return CallDelegate(implementation, self, [self _frameLoadDelegateForwarder], selector, object, double1);
+}
+#endif
+
 BOOL CallFrameLoadDelegateReturningBoolean(BOOL result, IMP implementation, WebView *self, SEL selector)
 {
     @try {
+#if !PLATFORM(IOS)
         return reinterpret_cast<BOOL (*)(id, SEL, WebView *)>(objc_msgSend)(self->_private->frameLoadDelegate, selector, self);
+#else
+        return reinterpret_cast<BOOL (*)(id, SEL, WebView *)>(objc_msgSend)([self _frameLoadDelegateForwarder], selector, self);
+#endif
     } @catch(id exception) {
         ReportDiscardedDelegateException(selector, exception);
     }
@@ -503,29 +1210,81 @@ BOOL CallFrameLoadDelegateReturningBoolean(BOOL result, IMP implementation, WebV
 
 id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2);
+#else
+    return CallDelegate(implementation, self, [self _resourceLoadDelegateForwarder], selector, object1, object2);
+#endif
 }
 
 id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, object3);
+#else
+    return CallDelegate(implementation, self, [self _resourceLoadDelegateForwarder], selector, object1, object2, object3);
+#endif
 }
 
 id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3, id object4)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, object3, object4);
+#else
+    return CallDelegate(implementation, self, [self _resourceLoadDelegateForwarder], selector, object1, object2, object3, object4);
+#endif
 }
 
 id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, integer, object2);
+#else
+    return CallDelegate(implementation, self, [self _resourceLoadDelegateForwarder], selector, object1, integer, object2);
+#endif
 }
 
 id CallResourceLoadDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, NSInteger integer, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, integer, object3);
+#else
+    return CallDelegate(implementation, self, [self _resourceLoadDelegateForwarder], selector, object1, object2, integer, object3);
+#endif
+}
+
+#if PLATFORM(IOS)
+id CallResourceLoadDelegateInWebThread(IMP implementation, WebView *self, SEL selector, id object1, id object2)
+{
+    return CallDelegateInWebThread(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2);
+}
+
+id CallResourceLoadDelegateInWebThread(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3)
+{
+    return CallDelegateInWebThread(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, object3);
 }
 
+id CallResourceLoadDelegateInWebThread(IMP implementation, WebView *self, SEL selector, id object1, id object2, id object3, id object4)
+{
+    return CallDelegateInWebThread(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, object3, object4);
+}
+
+id CallResourceLoadDelegateInWebThread(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer, id object2)
+{
+    return CallDelegateInWebThread(implementation, self, self->_private->resourceProgressDelegate, selector, object1, integer, object2);
+}
+
+id CallResourceLoadDelegateInWebThread(IMP implementation, WebView *self, SEL selector, id object1, id object2, NSInteger integer, id object3)
+{
+    return CallDelegateInWebThread(implementation, self, self->_private->resourceProgressDelegate, selector, object1, object2, integer, object3);
+}
+
+id CallFrameLoadDelegateInWebThread(IMP implementation, WebView *self, SEL selector, NSUInteger integer)
+{
+    return CallDelegateInWebThread(implementation, self, self->_private->frameLoadDelegate, selector, integer);
+}
+#endif // PLATFORM(IOS)
+
 BOOL CallResourceLoadDelegateReturningBoolean(BOOL result, IMP implementation, WebView *self, SEL selector, id object1)
 {
     @try {
@@ -558,22 +1317,38 @@ BOOL CallResourceLoadDelegateReturningBoolean(BOOL result, IMP implementation, W
 
 id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, id object2, NSInteger integer, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, object2, integer, object3);
+#else
+    return CallDelegateInWebThread(implementation, self, self->_private->scriptDebugDelegate, selector, object1, object2, integer, object3);
+#endif
 }
 
 id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer1, id object2, NSInteger integer2, id object3)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer1, object2, integer2, object3);
+#else
+    return CallDelegateInWebThread(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer1, object2, integer2, object3);
+#endif
 }
 
 id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer, id object2, id object3, id object4)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer, object2, object3, object4);
+#else
+    return CallDelegateInWebThread(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer, object2, object3, object4);
+#endif
 }
 
 id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, NSInteger integer1, int integer2, id object2)
 {
+#if !PLATFORM(IOS)
     return CallDelegate(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer1, integer2, object2);
+#else
+    return CallDelegateInWebThread(implementation, self, self->_private->scriptDebugDelegate, selector, object1, integer1, integer2, object2);
+#endif
 }
 
 id CallScriptDebugDelegate(IMP implementation, WebView *self, SEL selector, id object1, BOOL boolean, NSInteger integer1, int integer2, id object2)
@@ -600,6 +1375,7 @@ id CallHistoryDelegate(IMP implementation, WebView *self, SEL selector, id objec
 
 id CallFormDelegate(WebView *self, SEL selector, id object1, id object2)
 {
+#if !PLATFORM(IOS)
     id delegate = self->_private->formDelegate;
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
@@ -609,10 +1385,33 @@ id CallFormDelegate(WebView *self, SEL selector, id object1, id object2)
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    id delegate = [self _formDelegateForSelector:selector];
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&object1 atIndex:2];
+    [invocation setArgument:&object2 atIndex:3];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3)
 {
+#if !PLATFORM(IOS)
     id delegate = self->_private->formDelegate;
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
@@ -622,10 +1421,34 @@ id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id obje
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    id delegate = [self _formDelegateForSelector:selector];
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&object1 atIndex:2];
+    [invocation setArgument:&object2 atIndex:3];
+    [invocation setArgument:&object3 atIndex:4];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id object3, id object4, id object5)
 {
+#if !PLATFORM(IOS)
     id delegate = self->_private->formDelegate;
     if (!delegate || ![delegate respondsToSelector:selector])
         return nil;
@@ -635,10 +1458,36 @@ id CallFormDelegate(WebView *self, SEL selector, id object1, id object2, id obje
         ReportDiscardedDelegateException(selector, exception);
     }
     return nil;
+#else
+    id delegate = [self _formDelegateForSelector:selector];
+    if (!delegate)
+        return nil;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&object1 atIndex:2];
+    [invocation setArgument:&object2 atIndex:3];
+    [invocation setArgument:&object3 atIndex:4];
+    [invocation setArgument:&object4 atIndex:5];
+    [invocation setArgument:&object5 atIndex:6];
+
+    id returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        if ([[invocation methodSignature] methodReturnLength] == 0) {
+            return nil;
+        }
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return nil;
+#endif
 }
 
 BOOL CallFormDelegateReturningBoolean(BOOL result, WebView *self, SEL selector, id object1, SEL selectorArg, id object2)
 {
+#if !PLATFORM(IOS)
     id delegate = self->_private->formDelegate;
     if (!delegate || ![delegate respondsToSelector:selector])
         return result;
@@ -648,6 +1497,26 @@ BOOL CallFormDelegateReturningBoolean(BOOL result, WebView *self, SEL selector,
         ReportDiscardedDelegateException(selector, exception);
     }
     return result;
+#else
+    id delegate = [self _formDelegateForSelector:selector];
+    if (!delegate)
+        return result;
+
+    NSInvocation *invocation = WebThreadMakeNSInvocation(delegate, selector);
+    [invocation setArgument:&object1 atIndex:2];
+    [invocation setArgument:&selectorArg atIndex:3];
+    [invocation setArgument:&object2 atIndex:4];
+
+    BOOL returnValue;
+    @try {
+        WebThreadCallDelegate(invocation);
+        [invocation getReturnValue:&returnValue];
+        return returnValue;
+    } @catch(id exception) {
+        ReportDiscardedDelegateException(selector, exception);
+    }
+    return result;
+#endif
 }
 
 @end
index db7894f..34fa188 100644 (file)
@@ -65,7 +65,13 @@ DeviceOrientationData* core(WebDeviceOrientation* orientation)
     self = [super init];
     if (!self)
         return nil;
+#if PLATFORM(IOS)
+    // We don't use this API, but make sure that it compiles with the new
+    // compass parameters.
+    m_internal = [[WebDeviceOrientationInternal alloc] initWithCoreDeviceOrientation:DeviceOrientationData::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma, false, 0, false, 0)];
+#else
     m_internal = [[WebDeviceOrientationInternal alloc] initWithCoreDeviceOrientation:DeviceOrientationData::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma)];
+#endif
     return self;
 }
 
index d37b16f..5be27ac 100644 (file)
 #import <WebKit/WebHTMLView.h>
 #import <WebKit/WebViewPrivate.h>
 
+#if PLATFORM(IOS)
+#if !defined(IBAction)
+#define IBAction void
+#endif
+#endif
+
 /*!
 @protocol _WebDocumentZooming
 @discussion Optional protocol for a view that wants to handle its own zoom.
index 564f38d..b482bc5 100644 (file)
@@ -42,9 +42,13 @@ WebDocumentLoaderMac::WebDocumentLoaderMac(const ResourceRequest& request, const
 
 static inline bool needsDataLoadWorkaround(WebView *webView)
 {
+#if !PLATFORM(IOS)
     static bool needsWorkaround = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_ADOBE_INSTALLER_QUIRK) 
                                   && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.adobe.Installers.Setup"];
     return needsWorkaround;
+#else
+    return NO;
+#endif
 }
 
 void WebDocumentLoaderMac::setDataSource(WebDataSource *dataSource, WebView *webView)
index f0dacb0..11e30e3 100644 (file)
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if !PLATFORM(IOS)
+
 #import "WebDynamicScrollBarsView.h"
 #import <WebCore/WebCoreFrameView.h>
 
@@ -62,3 +64,5 @@
 // scrollers from inside this class should not fire JS events.
 - (BOOL)inProgrammaticScroll;
 @end
+
+#endif // !PLATFORM(IOS)
index 8c4cedb..274800d 100644 (file)
@@ -69,10 +69,12 @@ static WebFormDelegate *sharedDelegate = nil;
     return NO;
 }
 
+#if !PLATFORM(IOS)    
 - (BOOL)textField:(DOMHTMLInputElement *)element shouldHandleEvent:(NSEvent *)event inFrame:(WebFrame *)frame
 {
     return NO;
 }
+#endif
 
 - (void)frame:(WebFrame *)frame sourceFrame:(WebFrame *)sourceFrame willSubmitForm:(DOMElement *)form
     withValues:(NSDictionary *)values submissionListener:(id <WebFormSubmissionListener>)listener
index fae7fac..f7a9e7b 100644 (file)
 #import <runtime/JSCJSValue.h>
 #import <wtf/CurrentTime.h>
 
+#if PLATFORM(IOS)
+#import "WebMailDelegate.h"
+#import "WebResource.h"
+#import "WebUIKitDelegate.h"
+#import <JavaScriptCore/APIShims.h>
+#import <WebCore/Document.h>
+#import <WebCore/Editor.h>
+#import <WebCore/EditorClient.h>
+#import <WebCore/FocusController.h>
+#import <WebCore/FrameSelection.h>
+#import <WebCore/HistoryController.h>
+#import <WebCore/NodeTraversal.h>
+#import <WebCore/RenderLayer.h>
+#import <WebCore/SimpleFontData.h>
+#import <WebCore/TextResourceDecoder.h>
+#import <WebCore/WAKScrollView.h>
+#import <WebCore/WAKViewPrivate.h>
+#import <WebCore/WKGraphics.h>
+#import <WebCore/WebCoreThreadRun.h>
+#endif
+
 using namespace WebCore;
 using namespace HTMLNames;
 
@@ -303,6 +324,22 @@ WebView *getWebView(WebFrame *webFrame)
     return _private && _private->includedInWebKitStatistics;
 }
 
+#if PLATFORM(IOS)
+static NSURL *createUniqueWebDataURL();
+
++ (void)_createMainFrameWithSimpleHTMLDocumentWithPage:(Page*)page frameView:(WebFrameView *)frameView style:(NSString *)style
+{
+    WebView *webView = kit(page);
+    
+    WebFrame *frame = [[self alloc] _initWithWebFrameView:frameView webView:webView];
+    frame->_private->coreFrame = &page->mainFrame();
+    static_cast<WebFrameLoaderClient&>(page->mainFrame().loader().client()).setWebFrame(frame);
+    [frame release];
+
+    frame->_private->coreFrame->initWithSimpleHTMLDocument(style, createUniqueWebDataURL());
+}
+#endif
+
 - (void)_attachScriptDebugger
 {
     ScriptController& scriptController = _private->coreFrame->script();
@@ -362,7 +399,11 @@ WebView *getWebView(WebFrame *webFrame)
 {
     WebView *webView = getWebView(self);
     BOOL drawsBackground = [webView drawsBackground];
+#if !PLATFORM(IOS)
     NSColor *backgroundColor = [webView backgroundColor];
+#else
+    CGColorRef backgroundColor = [webView backgroundColor];
+#endif
 
     Frame* coreFrame = _private->coreFrame;
     for (Frame* frame = coreFrame; frame; frame = frame->tree().traverseNext(coreFrame)) {
@@ -371,11 +412,18 @@ WebView *getWebView(WebFrame *webFrame)
         WebFrame *webFrame = kit(frame);
         if (!drawsBackground)
             [[[webFrame frameView] _scrollView] setDrawsBackground:NO];
+#if !PLATFORM(IOS)
         [[[webFrame frameView] _scrollView] setBackgroundColor:backgroundColor];
+#endif
 
         if (FrameView* view = frame->view()) {
             view->setTransparent(!drawsBackground);
-            view->setBaseBackgroundColor(colorFromNSColor([backgroundColor colorUsingColorSpaceName:NSDeviceRGBColorSpace]));
+#if !PLATFORM(IOS)
+            Color color = colorFromNSColor([backgroundColor colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
+#else
+            Color color = Color(backgroundColor);
+#endif
+            view->setBaseBackgroundColor(color);
             view->setShouldUpdateWhileOffscreen([webView shouldUpdateWhileOffscreen]);
         }
     }
@@ -402,11 +450,13 @@ WebView *getWebView(WebFrame *webFrame)
 
 - (void)_unmarkAllMisspellings
 {
+#if !PLATFORM(IOS)
     Frame* coreFrame = _private->coreFrame;
     for (Frame* frame = coreFrame; frame; frame = frame->tree().traverseNext(coreFrame)) {
         if (Document* document = frame->document())
             document->markers().removeMarkers(DocumentMarker::Spelling);
     }
+#endif
 }
 
 - (BOOL)_hasSelection
@@ -481,6 +531,18 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     return dataSource(_private->coreFrame->loader().documentLoader());
 }
 
+#if PLATFORM(IOS)
+- (BOOL)_isCommitting
+{
+    return _private->isCommitting;
+}
+
+- (void)_setIsCommitting:(BOOL)value
+{
+    _private->isCommitting = value;
+}
+#endif
+
 - (NSArray *)_nodesFromList:(Vector<Node*> *)nodesVector
 {
     size_t size = nodesVector->size();
@@ -502,10 +564,12 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (BOOL)_shouldFlattenCompositingLayers:(CGContextRef)context
 {
+#if !PLATFORM(IOS)
     // -currentContextDrawingToScreen returns YES for bitmap contexts.
     BOOL isPrinting = ![NSGraphicsContext currentContextDrawingToScreen];
     if (isPrinting)
         return YES;
+#endif
 
     if (!WKCGContextIsBitmapContext(context))
         return NO;
@@ -520,11 +584,22 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (void)_drawRect:(NSRect)rect contentsOnly:(BOOL)contentsOnly
 {
+#if !PLATFORM(IOS)
     ASSERT([[NSGraphicsContext currentContext] isFlipped]);
 
     CGContextRef ctx = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+#else
+    CGContextRef ctx = WKGetCurrentGraphicsContext();
+#endif
     GraphicsContext context(ctx);
 
+#if PLATFORM(IOS)
+    // FIXME: when <rdar://problem/9034977> is fixed there will be no need to do this here.
+    WebCore::Frame *frame = core(self);
+    if (WebCore::Page* page = frame->page())
+        context.setIsAcceleratedContext(page->settings().acceleratedDrawingEnabled());
+#endif
+
     FrameView* view = _private->coreFrame->view();
     
     bool shouldFlatten = false;
@@ -577,6 +652,14 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     ASSERT(_private->coreFrame->document());
     RetainPtr<WebFrame> protect(self); // Executing arbitrary JavaScript can destroy the frame.
     
+#if PLATFORM(IOS)
+    ASSERT(WebThreadIsLockedOrDisabled());
+    JSC::ExecState* exec = _private->coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec();
+    // Need to use the full entry shim to prevent crashes arising from the UI thread being unknown
+    // to the JSC GC: <rdar://problem/11553172> Crash when breaking in the Web Inspector during stringByEvaluatingJavaScriptFromString:
+    JSC::APIEntryShim jscLock(exec);
+#endif
+
     JSC::JSValue result = _private->coreFrame->script().executeScript(string, forceUserGesture).jsValue();
 
     if (!_private->coreFrame) // In case the script removed our frame from the page.
@@ -588,8 +671,10 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     if (!result || (!result.isBoolean() && !result.isString() && !result.isNumber()))
         return @"";
 
+#if !PLATFORM(IOS)
     JSC::ExecState* exec = _private->coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec();
     JSC::JSLockHolder lock(exec);
+#endif
     return result.toWTFString(exec);
 }
 
@@ -609,15 +694,52 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     NSRect rangeRect = [self _firstRectForDOMRange:range];    
     Node *startNode = core([range startContainer]);
         
-    if (startNode && startNode->renderer())
+    if (startNode && startNode->renderer()) {
+#if !PLATFORM(IOS)
         startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
+#else
+        RenderLayer* layer = startNode->renderer()->enclosingLayer();
+        if (layer) {
+            layer->setAdjustForIOSCaretWhenScrolling(true);
+            startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
+            layer->setAdjustForIOSCaretWhenScrolling(false);
+            _private->coreFrame->selection().setCaretRectNeedsUpdate();
+            _private->coreFrame->selection().updateAppearance();
+        }
+#endif
+    }
+}
+
+#if PLATFORM(IOS)
+- (void)_scrollDOMRangeToVisible:(DOMRange *)range withInset:(CGFloat)inset
+{
+    NSRect rangeRect = NSInsetRect([self _firstRectForDOMRange:range], inset, inset);
+    Node *startNode = core([range startContainer]);
+
+    if (startNode && startNode->renderer()) {
+        RenderLayer* layer = startNode->renderer()->enclosingLayer();
+        if (layer) {
+            layer->setAdjustForIOSCaretWhenScrolling(true);
+            startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
+            layer->setAdjustForIOSCaretWhenScrolling(false);
+
+            Frame *coreFrame = core(self);
+            if (coreFrame) {
+                FrameSelection& frameSelection = coreFrame->selection();
+                frameSelection.setCaretRectNeedsUpdate();
+                frameSelection.updateAppearance();
+            }
+        }
+    }
 }
+#endif
 
 - (BOOL)_needsLayout
 {
     return _private->coreFrame->view() ? _private->coreFrame->view()->needsLayout() : false;
 }
 
+#if !PLATFORM(IOS)
 - (DOMRange *)_rangeByAlteringCurrentSelection:(FrameSelection::EAlteration)alteration direction:(SelectionDirection)direction granularity:(TextGranularity)granularity
 {
     if (_private->coreFrame->selection().isNone())
@@ -628,6 +750,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     selection.modify(alteration, direction, granularity);
     return kit(selection.toNormalizedRange().get());
 }
+#endif
 
 - (TextGranularity)_selectionGranularity
 {
@@ -858,7 +981,11 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     _private->shouldCreateRenderers = shouldCreateRenderers;
 }
 
+#if !PLATFORM(IOS)
 - (NSColor *)_bodyBackgroundColor
+#else
+- (CGColorRef)_bodyBackgroundColor
+#endif
 {
     Document* document = _private->coreFrame->document();
     if (!document)
@@ -872,7 +999,11 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     Color color = bodyRenderer->style().visitedDependentColor(CSSPropertyBackgroundColor);
     if (!color.isValid())
         return nil;
+#if !PLATFORM(IOS)
     return nsColor(color);
+#else
+    return cachedCGColor(color, ColorSpaceDeviceRGB);
+#endif
 }
 
 - (BOOL)_isFrameSet
@@ -898,6 +1029,61 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     return (WebFrameLoadType)_private->coreFrame->loader().loadType();
 }
 
+#if PLATFORM(IOS)
+- (BOOL)needsLayout
+{
+    // Needed for Mail <rdar://problem/6228038>
+    return _private->coreFrame ? [self _needsLayout] : NO;
+}
+
+- (void)_setLoadsSynchronously:(BOOL)flag
+{
+    _private->coreFrame->loader().setLoadsSynchronously(flag);
+}
+
+- (BOOL)_loadsSynchronously
+{
+    return _private->coreFrame->loader().loadsSynchronously();
+}
+
+// FIXME: selection
+
+- (NSArray *)_rectsForRange:(DOMRange *)domRange
+{
+    Range *range = core(domRange);
+    
+    
+    Vector<IntRect> intRects;
+    range->textRects(intRects, NO);
+    unsigned size = intRects.size();
+    
+    NSMutableArray *rectArray = [NSMutableArray arrayWithCapacity:size];
+    for (unsigned i = 0; i < size; i++) {
+        [rectArray addObject:[NSValue valueWithRect:(CGRect )intRects[i]]];
+    }
+    
+    return rectArray;
+}
+
+- (DOMRange *)_selectionRangeForFirstPoint:(CGPoint)first secondPoint:(CGPoint)second