[iOS] Upstream Source/WebKit/ios/
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2013 23:48:35 +0000 (23:48 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2013 23:48:35 +0000 (23:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123470

Reviewed by Sam Weinig.

Source/WebKit:

* WebKit.xcodeproj/project.pbxproj:

Source/WebKit/ios:

* DefaultDelegates/WebDefaultFormDelegate.h: Added.
* DefaultDelegates/WebDefaultFormDelegate.m: Added.
* DefaultDelegates/WebDefaultFrameLoadDelegate.h: Added.
* DefaultDelegates/WebDefaultFrameLoadDelegate.m: Added.
* DefaultDelegates/WebDefaultResourceLoadDelegate.h: Added.
* DefaultDelegates/WebDefaultResourceLoadDelegate.m: Added.
* DefaultDelegates/WebDefaultUIKitDelegate.h: Added.
* DefaultDelegates/WebDefaultUIKitDelegate.m: Added.
* Misc/EmojiFallbackFontSelector.cpp: Added.
* Misc/EmojiFallbackFontSelector.h: Added.
* Misc/MemoryMeasure.h: Added.
* Misc/MemoryMeasure.mm: Added.
* Misc/WebGeolocationCoreLocationProvider.h: Added.
* Misc/WebGeolocationCoreLocationProvider.mm: Added.
* Misc/WebGeolocationProviderIOS.h: Added.
* Misc/WebGeolocationProviderIOS.mm: Added.
* Misc/WebNSStringDrawing.h: Added.
* Misc/WebNSStringDrawing.mm: Added.
* Misc/WebNSStringExtrasIOS.h: Added.
* Misc/WebNSStringExtrasIOS.m: Added.
* Misc/WebNSStringExtrasIPhone.h: Added.
* Misc/WebUIKitSupport.h: Added.
* Misc/WebUIKitSupport.mm: Added.
* Storage/WebSQLiteDatabaseTrackerClient.h: Added.
* Storage/WebSQLiteDatabaseTrackerClient.mm: Added.
* WebCoreSupport/PopupMenuIOS.h: Added.
* WebCoreSupport/PopupMenuIOS.mm: Added.
* WebCoreSupport/SearchPopupMenuIOS.cpp: Added.
* WebCoreSupport/SearchPopupMenuIOS.h: Added.
* WebCoreSupport/WebCaretChangeListener.h: Added.
* WebCoreSupport/WebChromeClientIOS.h: Added.
* WebCoreSupport/WebChromeClientIOS.mm: Added.
* WebCoreSupport/WebFixedPositionContent.h: Added.
* WebCoreSupport/WebFixedPositionContent.mm: Added.
* WebCoreSupport/WebFixedPositionContentInternal.h: Added.
* WebCoreSupport/WebFrameIOS.h: Added.
* WebCoreSupport/WebFrameIOS.mm: Added.
* WebCoreSupport/WebFrameIPhone.h: Added.
* WebCoreSupport/WebGeolocation.mm: Added.
* WebCoreSupport/WebGeolocationInternal.h: Added.
* WebCoreSupport/WebGeolocationPrivate.h: Added.
* WebCoreSupport/WebMIMETypeRegistry.h: Added.
* WebCoreSupport/WebMIMETypeRegistry.mm: Added.
* WebCoreSupport/WebSelectionRect.h: Added.
* WebCoreSupport/WebSelectionRect.m: Added.
* WebCoreSupport/WebVisiblePosition.h: Added.
* WebCoreSupport/WebVisiblePosition.mm: Added.
* WebCoreSupport/WebVisiblePositionInternal.h: Added.
* WebKit.iOS.exp: Added.
* WebView/WebFrameViewWAKCompatibility.m: Added.
* WebView/WebMailDelegate.h: Added.
* WebView/WebPDFViewIOS.h: Added.
* WebView/WebPDFViewIOS.mm: Added.
* WebView/WebPDFViewIPhone.h: Added.
* WebView/WebPDFViewPlaceholder.h: Added.
* WebView/WebPDFViewPlaceholder.mm: Added.
* WebView/WebPlainWhiteView.h: Added.
* WebView/WebPlainWhiteView.mm: Added.
* WebView/WebUIKitDelegate.h: Added.

Source/WebKit/mac:

* Configurations/WebKit.xcconfig: Excluded some iOS files from the Mac build.

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

64 files changed:
Source/WebKit/ChangeLog
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/DefaultDelegates/WebDefaultFormDelegate.h [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultFormDelegate.m [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultFrameLoadDelegate.h [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultFrameLoadDelegate.m [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultResourceLoadDelegate.h [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultResourceLoadDelegate.m [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.h [new file with mode: 0644]
Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.m [new file with mode: 0644]
Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp [new file with mode: 0644]
Source/WebKit/ios/Misc/EmojiFallbackFontSelector.h [new file with mode: 0644]
Source/WebKit/ios/Misc/MemoryMeasure.h [new file with mode: 0644]
Source/WebKit/ios/Misc/MemoryMeasure.mm [new file with mode: 0644]
Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h [new file with mode: 0644]
Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm [new file with mode: 0644]
Source/WebKit/ios/Misc/WebGeolocationProviderIOS.h [new file with mode: 0644]
Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm [new file with mode: 0644]
Source/WebKit/ios/Misc/WebNSStringDrawing.h [new file with mode: 0644]
Source/WebKit/ios/Misc/WebNSStringDrawing.mm [new file with mode: 0644]
Source/WebKit/ios/Misc/WebNSStringExtrasIOS.h [new file with mode: 0644]
Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m [new file with mode: 0644]
Source/WebKit/ios/Misc/WebNSStringExtrasIPhone.h [new file with mode: 0644]
Source/WebKit/ios/Misc/WebUIKitSupport.h [new file with mode: 0644]
Source/WebKit/ios/Misc/WebUIKitSupport.mm [new file with mode: 0644]
Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.h [new file with mode: 0644]
Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/PopupMenuIOS.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/PopupMenuIOS.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.cpp [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebCaretChangeListener.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebFixedPositionContentInternal.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebFrameIOS.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebFrameIPhone.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebGeolocation.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebGeolocationInternal.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebGeolocationPrivate.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebMIMETypeRegistry.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebMIMETypeRegistry.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebSelectionRect.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebSelectionRect.m [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.h [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.mm [new file with mode: 0644]
Source/WebKit/ios/WebCoreSupport/WebVisiblePositionInternal.h [new file with mode: 0644]
Source/WebKit/ios/WebKit.iOS.exp [new file with mode: 0644]
Source/WebKit/ios/WebView/WebFrameViewWAKCompatibility.m [new file with mode: 0644]
Source/WebKit/ios/WebView/WebMailDelegate.h [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPDFViewIOS.h [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPDFViewIOS.mm [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPDFViewIPhone.h [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPDFViewPlaceholder.h [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPDFViewPlaceholder.mm [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPlainWhiteView.h [new file with mode: 0644]
Source/WebKit/ios/WebView/WebPlainWhiteView.mm [new file with mode: 0644]
Source/WebKit/ios/WebView/WebUIKitDelegate.h [new file with mode: 0644]
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/WebKit.xcconfig

index 47da22e..d526eb0 100644 (file)
@@ -1,3 +1,12 @@
+2013-10-29  Andy Estes  <aestes@apple.com>
+
+        [iOS] Upstream Source/WebKit/ios/
+        https://bugs.webkit.org/show_bug.cgi?id=123470
+
+        Reviewed by Sam Weinig.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
 2013-10-30  Myles C. Maxfield  <mmaxfield@apple.com>
 
         WebKit/win/WebKitGraphics.h:void WebDrawText(WebTextRenderInfo*); is never called
index 0b9ce75..e1d751b 100644 (file)
                93EB178D09F88D460091F8FF /* WebSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EB178C09F88D460091F8FF /* WebSystemInterface.mm */; };
                93EB178F09F88D510091F8FF /* WebSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB178E09F88D510091F8FF /* WebSystemInterface.h */; };
                93FDE9330D79CAF30074F029 /* WebHistoryInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDE9320D79CAF30074F029 /* WebHistoryInternal.h */; };
+               A10C1D1818202F9C0036883A /* WebDefaultFormDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D1018202F9C0036883A /* WebDefaultFormDelegate.h */; };
+               A10C1D1918202F9C0036883A /* WebDefaultFormDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D1118202F9C0036883A /* WebDefaultFormDelegate.m */; };
+               A10C1D1A18202F9C0036883A /* WebDefaultFrameLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D1218202F9C0036883A /* WebDefaultFrameLoadDelegate.h */; };
+               A10C1D1B18202F9C0036883A /* WebDefaultFrameLoadDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D1318202F9C0036883A /* WebDefaultFrameLoadDelegate.m */; };
+               A10C1D1C18202F9C0036883A /* WebDefaultResourceLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D1418202F9C0036883A /* WebDefaultResourceLoadDelegate.h */; };
+               A10C1D1D18202F9C0036883A /* WebDefaultResourceLoadDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D1518202F9C0036883A /* WebDefaultResourceLoadDelegate.m */; };
+               A10C1D1E18202F9C0036883A /* WebDefaultUIKitDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D1618202F9C0036883A /* WebDefaultUIKitDelegate.h */; };
+               A10C1D1F18202F9C0036883A /* WebDefaultUIKitDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D1718202F9C0036883A /* WebDefaultUIKitDelegate.m */; };
+               A10C1D3018202FC50036883A /* EmojiFallbackFontSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2118202FC50036883A /* EmojiFallbackFontSelector.cpp */; };
+               A10C1D3118202FC50036883A /* EmojiFallbackFontSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2218202FC50036883A /* EmojiFallbackFontSelector.h */; };
+               A10C1D3218202FC50036883A /* MemoryMeasure.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2318202FC50036883A /* MemoryMeasure.h */; };
+               A10C1D3318202FC50036883A /* MemoryMeasure.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2418202FC50036883A /* MemoryMeasure.mm */; };
+               A10C1D3418202FC50036883A /* WebGeolocationCoreLocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2518202FC50036883A /* WebGeolocationCoreLocationProvider.h */; };
+               A10C1D3518202FC50036883A /* WebGeolocationCoreLocationProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2618202FC50036883A /* WebGeolocationCoreLocationProvider.mm */; };
+               A10C1D3618202FC50036883A /* WebGeolocationProviderIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2718202FC50036883A /* WebGeolocationProviderIOS.h */; };
+               A10C1D3718202FC50036883A /* WebGeolocationProviderIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2818202FC50036883A /* WebGeolocationProviderIOS.mm */; };
+               A10C1D3818202FC50036883A /* WebNSStringDrawing.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2918202FC50036883A /* WebNSStringDrawing.h */; };
+               A10C1D3918202FC50036883A /* WebNSStringDrawing.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2A18202FC50036883A /* WebNSStringDrawing.mm */; };
+               A10C1D3A18202FC50036883A /* WebNSStringExtrasIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2B18202FC50036883A /* WebNSStringExtrasIOS.h */; };
+               A10C1D3B18202FC50036883A /* WebNSStringExtrasIOS.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2C18202FC50036883A /* WebNSStringExtrasIOS.m */; };
+               A10C1D3C18202FC50036883A /* WebNSStringExtrasIPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2D18202FC50036883A /* WebNSStringExtrasIPhone.h */; };
+               A10C1D3D18202FC50036883A /* WebUIKitSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2E18202FC50036883A /* WebUIKitSupport.h */; };
+               A10C1D3E18202FC50036883A /* WebUIKitSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2F18202FC50036883A /* WebUIKitSupport.mm */; };
+               A10C1D4218202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D4018202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h */; };
+               A10C1D4318202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D4118202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm */; };
+               A10C1D5F1820300E0036883A /* PopupMenuIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D451820300E0036883A /* PopupMenuIOS.h */; };
+               A10C1D601820300E0036883A /* PopupMenuIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D461820300E0036883A /* PopupMenuIOS.mm */; };
+               A10C1D611820300E0036883A /* SearchPopupMenuIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D471820300E0036883A /* SearchPopupMenuIOS.cpp */; };
+               A10C1D621820300E0036883A /* SearchPopupMenuIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D481820300E0036883A /* SearchPopupMenuIOS.h */; };
+               A10C1D631820300E0036883A /* WebCaretChangeListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D491820300E0036883A /* WebCaretChangeListener.h */; };
+               A10C1D641820300E0036883A /* WebChromeClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D4A1820300E0036883A /* WebChromeClientIOS.h */; };
+               A10C1D651820300E0036883A /* WebChromeClientIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D4B1820300E0036883A /* WebChromeClientIOS.mm */; };
+               A10C1D661820300E0036883A /* WebDiskImageCacheClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D4C1820300E0036883A /* WebDiskImageCacheClientIOS.h */; };
+               A10C1D671820300E0036883A /* WebDiskImageCacheClientIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D4D1820300E0036883A /* WebDiskImageCacheClientIOS.mm */; };
+               A10C1D681820300E0036883A /* WebFixedPositionContent.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D4E1820300E0036883A /* WebFixedPositionContent.h */; };
+               A10C1D691820300E0036883A /* WebFixedPositionContent.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D4F1820300E0036883A /* WebFixedPositionContent.mm */; };
+               A10C1D6A1820300E0036883A /* WebFixedPositionContentInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D501820300E0036883A /* WebFixedPositionContentInternal.h */; };
+               A10C1D6B1820300E0036883A /* WebFrameIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D511820300E0036883A /* WebFrameIOS.h */; };
+               A10C1D6C1820300E0036883A /* WebFrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D521820300E0036883A /* WebFrameIOS.mm */; };
+               A10C1D6D1820300E0036883A /* WebFrameIPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D531820300E0036883A /* WebFrameIPhone.h */; };
+               A10C1D6E1820300E0036883A /* WebGeolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D541820300E0036883A /* WebGeolocation.mm */; };
+               A10C1D6F1820300E0036883A /* WebGeolocationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D551820300E0036883A /* WebGeolocationInternal.h */; };
+               A10C1D701820300E0036883A /* WebGeolocationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D561820300E0036883A /* WebGeolocationPrivate.h */; };
+               A10C1D711820300E0036883A /* WebInspectorClientIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D571820300E0036883A /* WebInspectorClientIOS.mm */; };
+               A10C1D721820300E0036883A /* WebMIMETypeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D581820300E0036883A /* WebMIMETypeRegistry.h */; };
+               A10C1D731820300E0036883A /* WebMIMETypeRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D591820300E0036883A /* WebMIMETypeRegistry.mm */; };
+               A10C1D741820300E0036883A /* WebSelectionRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D5A1820300E0036883A /* WebSelectionRect.h */; };
+               A10C1D751820300E0036883A /* WebSelectionRect.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D5B1820300E0036883A /* WebSelectionRect.m */; };
+               A10C1D761820300E0036883A /* WebVisiblePosition.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D5C1820300E0036883A /* WebVisiblePosition.h */; };
+               A10C1D771820300E0036883A /* WebVisiblePosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D5D1820300E0036883A /* WebVisiblePosition.mm */; };
+               A10C1D781820300E0036883A /* WebVisiblePositionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D5E1820300E0036883A /* WebVisiblePositionInternal.h */; };
+               A10C1D7F1820303D0036883A /* WebFrameViewWAKCompatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D7A1820303D0036883A /* WebFrameViewWAKCompatibility.m */; };
+               A10C1D801820303D0036883A /* WebMailDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D7B1820303D0036883A /* WebMailDelegate.h */; };
+               A10C1D811820303D0036883A /* WebPlainWhiteView.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D7C1820303D0036883A /* WebPlainWhiteView.h */; };
+               A10C1D821820303D0036883A /* WebPlainWhiteView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D7D1820303D0036883A /* WebPlainWhiteView.mm */; };
+               A10C1D831820303D0036883A /* WebUIKitDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D7E1820303D0036883A /* WebUIKitDelegate.h */; };
+               A10C1D8A1820305E0036883A /* WebPDFViewIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D851820305E0036883A /* WebPDFViewIOS.h */; };
+               A10C1D8B1820305E0036883A /* WebPDFViewIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D861820305E0036883A /* WebPDFViewIOS.mm */; };
+               A10C1D8C1820305E0036883A /* WebPDFViewIPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D871820305E0036883A /* WebPDFViewIPhone.h */; };
+               A10C1D8D1820305E0036883A /* WebPDFViewPlaceholder.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D881820305E0036883A /* WebPDFViewPlaceholder.h */; };
+               A10C1D8E1820305E0036883A /* WebPDFViewPlaceholder.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D891820305E0036883A /* WebPDFViewPlaceholder.mm */; };
+               A10C1D901820307D0036883A /* WebKit.iOS.exp in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D8F1820307D0036883A /* WebKit.iOS.exp */; };
                A17A11B1180DC84800E5498C /* WebPluginPackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A17A11B0180DC84800E5498C /* WebPluginPackagePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A5214FC713B975C8000015EF /* WebInspectorRemoteChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = A5214FC113B975C8000015EF /* WebInspectorRemoteChannel.h */; };
                A5214FC813B975C8000015EF /* WebInspectorRemoteChannel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5214FC213B975C8000015EF /* WebInspectorRemoteChannel.mm */; };
                A52209F813C53E75004BA7B1 /* WebInspectorRelayDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = A52209F713C53E75004BA7B1 /* WebInspectorRelayDefinitions.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               A560946614D8AD2600799A8A /* WebIndicateLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = A560946414D8AD2600799A8A /* WebIndicateLayer.h */; };
-               A560946714D8AD2600799A8A /* WebIndicateLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A560946514D8AD2600799A8A /* WebIndicateLayer.mm */; };
                A55E20FF14D7264C0031549E /* WebInspectorServerWebViewConnectionController.h in Headers */ = {isa = PBXBuildFile; fileRef = A55E20FD14D7264C0031549E /* WebInspectorServerWebViewConnectionController.h */; };
                A55E210014D7264C0031549E /* WebInspectorServerWebViewConnectionController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A55E20FE14D7264C0031549E /* WebInspectorServerWebViewConnectionController.mm */; };
+               A560946614D8AD2600799A8A /* WebIndicateLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = A560946414D8AD2600799A8A /* WebIndicateLayer.h */; };
+               A560946714D8AD2600799A8A /* WebIndicateLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A560946514D8AD2600799A8A /* WebIndicateLayer.mm */; };
                A5687BDA135B791A0074CBCB /* WebNodeHighlighter.h in Headers */ = {isa = PBXBuildFile; fileRef = A5687BD8135B791A0074CBCB /* WebNodeHighlighter.h */; };
                A5687BDB135B791A0074CBCB /* WebNodeHighlighter.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5687BD9135B791A0074CBCB /* WebNodeHighlighter.mm */; };
                A57C28A713BAA5AD0070ACAB /* WebInspectorServerWebViewConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = A57C28A113BAA5AD0070ACAB /* WebInspectorServerWebViewConnection.h */; };
                A57EB79013B97A4E008D691D /* WebInspectorClientRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = A57EB78E13B97A4E008D691D /* WebInspectorClientRegistry.mm */; };
                A58A5799143E727000125F50 /* WebOpenPanelResultListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A58A5797143E727000125F50 /* WebOpenPanelResultListener.h */; };
                A58A579A143E727000125F50 /* WebOpenPanelResultListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = A58A5798143E727000125F50 /* WebOpenPanelResultListener.mm */; };
-               A5C566BD127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A5C566BB127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.h */; };
-               A5C566BE127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5C566BC127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.mm */; };
                A5DEFC0A11D5331C00885273 /* WebSecurityOrigin.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC0711D5331C00885273 /* WebSecurityOrigin.mm */; };
                A5DEFC0B11D5331C00885273 /* WebSecurityOriginInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC0811D5331C00885273 /* WebSecurityOriginInternal.h */; };
                A5DEFC0C11D5331C00885273 /* WebSecurityOriginPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC0911D5331C00885273 /* WebSecurityOriginPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93FDE9320D79CAF30074F029 /* WebHistoryInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHistoryInternal.h; sourceTree = "<group>"; };
                9CAE9D070252A4130ECA16EA /* WebPreferencesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferencesPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                9CF0E249021361B00ECA16EA /* WebFramePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFramePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               A10C1D1018202F9C0036883A /* WebDefaultFormDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDefaultFormDelegate.h; path = ios/DefaultDelegates/WebDefaultFormDelegate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D1118202F9C0036883A /* WebDefaultFormDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebDefaultFormDelegate.m; path = ios/DefaultDelegates/WebDefaultFormDelegate.m; sourceTree = SOURCE_ROOT; };
+               A10C1D1218202F9C0036883A /* WebDefaultFrameLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDefaultFrameLoadDelegate.h; path = ios/DefaultDelegates/WebDefaultFrameLoadDelegate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D1318202F9C0036883A /* WebDefaultFrameLoadDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebDefaultFrameLoadDelegate.m; path = ios/DefaultDelegates/WebDefaultFrameLoadDelegate.m; sourceTree = SOURCE_ROOT; };
+               A10C1D1418202F9C0036883A /* WebDefaultResourceLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDefaultResourceLoadDelegate.h; path = ios/DefaultDelegates/WebDefaultResourceLoadDelegate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D1518202F9C0036883A /* WebDefaultResourceLoadDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebDefaultResourceLoadDelegate.m; path = ios/DefaultDelegates/WebDefaultResourceLoadDelegate.m; sourceTree = SOURCE_ROOT; };
+               A10C1D1618202F9C0036883A /* WebDefaultUIKitDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDefaultUIKitDelegate.h; path = ios/DefaultDelegates/WebDefaultUIKitDelegate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D1718202F9C0036883A /* WebDefaultUIKitDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebDefaultUIKitDelegate.m; path = ios/DefaultDelegates/WebDefaultUIKitDelegate.m; sourceTree = SOURCE_ROOT; };
+               A10C1D2118202FC50036883A /* EmojiFallbackFontSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmojiFallbackFontSelector.cpp; path = ios/Misc/EmojiFallbackFontSelector.cpp; sourceTree = SOURCE_ROOT; };
+               A10C1D2218202FC50036883A /* EmojiFallbackFontSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmojiFallbackFontSelector.h; path = ios/Misc/EmojiFallbackFontSelector.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2318202FC50036883A /* MemoryMeasure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MemoryMeasure.h; path = ios/Misc/MemoryMeasure.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2418202FC50036883A /* MemoryMeasure.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MemoryMeasure.mm; path = ios/Misc/MemoryMeasure.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D2518202FC50036883A /* WebGeolocationCoreLocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGeolocationCoreLocationProvider.h; path = ios/Misc/WebGeolocationCoreLocationProvider.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2618202FC50036883A /* WebGeolocationCoreLocationProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebGeolocationCoreLocationProvider.mm; path = ios/Misc/WebGeolocationCoreLocationProvider.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D2718202FC50036883A /* WebGeolocationProviderIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGeolocationProviderIOS.h; path = ios/Misc/WebGeolocationProviderIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2818202FC50036883A /* WebGeolocationProviderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebGeolocationProviderIOS.mm; path = ios/Misc/WebGeolocationProviderIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D2918202FC50036883A /* WebNSStringDrawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebNSStringDrawing.h; path = ios/Misc/WebNSStringDrawing.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2A18202FC50036883A /* WebNSStringDrawing.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebNSStringDrawing.mm; path = ios/Misc/WebNSStringDrawing.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D2B18202FC50036883A /* WebNSStringExtrasIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebNSStringExtrasIOS.h; path = ios/Misc/WebNSStringExtrasIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2C18202FC50036883A /* WebNSStringExtrasIOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebNSStringExtrasIOS.m; path = ios/Misc/WebNSStringExtrasIOS.m; sourceTree = SOURCE_ROOT; };
+               A10C1D2D18202FC50036883A /* WebNSStringExtrasIPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebNSStringExtrasIPhone.h; path = ios/Misc/WebNSStringExtrasIPhone.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2E18202FC50036883A /* WebUIKitSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebUIKitSupport.h; path = ios/Misc/WebUIKitSupport.h; sourceTree = SOURCE_ROOT; };
+               A10C1D2F18202FC50036883A /* WebUIKitSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebUIKitSupport.mm; path = ios/Misc/WebUIKitSupport.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D4018202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSQLiteDatabaseTrackerClient.h; path = ios/Storage/WebSQLiteDatabaseTrackerClient.h; sourceTree = SOURCE_ROOT; };
+               A10C1D4118202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebSQLiteDatabaseTrackerClient.mm; path = ios/Storage/WebSQLiteDatabaseTrackerClient.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D451820300E0036883A /* PopupMenuIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PopupMenuIOS.h; path = ios/WebCoreSupport/PopupMenuIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D461820300E0036883A /* PopupMenuIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PopupMenuIOS.mm; path = ios/WebCoreSupport/PopupMenuIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D471820300E0036883A /* SearchPopupMenuIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SearchPopupMenuIOS.cpp; path = ios/WebCoreSupport/SearchPopupMenuIOS.cpp; sourceTree = SOURCE_ROOT; };
+               A10C1D481820300E0036883A /* SearchPopupMenuIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SearchPopupMenuIOS.h; path = ios/WebCoreSupport/SearchPopupMenuIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D491820300E0036883A /* WebCaretChangeListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCaretChangeListener.h; path = ios/WebCoreSupport/WebCaretChangeListener.h; sourceTree = SOURCE_ROOT; };
+               A10C1D4A1820300E0036883A /* WebChromeClientIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebChromeClientIOS.h; path = ios/WebCoreSupport/WebChromeClientIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D4B1820300E0036883A /* WebChromeClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebChromeClientIOS.mm; path = ios/WebCoreSupport/WebChromeClientIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D4C1820300E0036883A /* WebDiskImageCacheClientIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebDiskImageCacheClientIOS.h; path = ios/WebCoreSupport/WebDiskImageCacheClientIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D4D1820300E0036883A /* WebDiskImageCacheClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebDiskImageCacheClientIOS.mm; path = ios/WebCoreSupport/WebDiskImageCacheClientIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D4E1820300E0036883A /* WebFixedPositionContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFixedPositionContent.h; path = ios/WebCoreSupport/WebFixedPositionContent.h; sourceTree = SOURCE_ROOT; };
+               A10C1D4F1820300E0036883A /* WebFixedPositionContent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebFixedPositionContent.mm; path = ios/WebCoreSupport/WebFixedPositionContent.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D501820300E0036883A /* WebFixedPositionContentInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFixedPositionContentInternal.h; path = ios/WebCoreSupport/WebFixedPositionContentInternal.h; sourceTree = SOURCE_ROOT; };
+               A10C1D511820300E0036883A /* WebFrameIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFrameIOS.h; path = ios/WebCoreSupport/WebFrameIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D521820300E0036883A /* WebFrameIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebFrameIOS.mm; path = ios/WebCoreSupport/WebFrameIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D531820300E0036883A /* WebFrameIPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFrameIPhone.h; path = ios/WebCoreSupport/WebFrameIPhone.h; sourceTree = SOURCE_ROOT; };
+               A10C1D541820300E0036883A /* WebGeolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebGeolocation.mm; path = ios/WebCoreSupport/WebGeolocation.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D551820300E0036883A /* WebGeolocationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGeolocationInternal.h; path = ios/WebCoreSupport/WebGeolocationInternal.h; sourceTree = SOURCE_ROOT; };
+               A10C1D561820300E0036883A /* WebGeolocationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGeolocationPrivate.h; path = ios/WebCoreSupport/WebGeolocationPrivate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D571820300E0036883A /* WebInspectorClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebInspectorClientIOS.mm; path = ios/WebCoreSupport/WebInspectorClientIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D581820300E0036883A /* WebMIMETypeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebMIMETypeRegistry.h; path = ios/WebCoreSupport/WebMIMETypeRegistry.h; sourceTree = SOURCE_ROOT; };
+               A10C1D591820300E0036883A /* WebMIMETypeRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebMIMETypeRegistry.mm; path = ios/WebCoreSupport/WebMIMETypeRegistry.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D5A1820300E0036883A /* WebSelectionRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSelectionRect.h; path = ios/WebCoreSupport/WebSelectionRect.h; sourceTree = SOURCE_ROOT; };
+               A10C1D5B1820300E0036883A /* WebSelectionRect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebSelectionRect.m; path = ios/WebCoreSupport/WebSelectionRect.m; sourceTree = SOURCE_ROOT; };
+               A10C1D5C1820300E0036883A /* WebVisiblePosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVisiblePosition.h; path = ios/WebCoreSupport/WebVisiblePosition.h; sourceTree = SOURCE_ROOT; };
+               A10C1D5D1820300E0036883A /* WebVisiblePosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVisiblePosition.mm; path = ios/WebCoreSupport/WebVisiblePosition.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D5E1820300E0036883A /* WebVisiblePositionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVisiblePositionInternal.h; path = ios/WebCoreSupport/WebVisiblePositionInternal.h; sourceTree = SOURCE_ROOT; };
+               A10C1D7A1820303D0036883A /* WebFrameViewWAKCompatibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebFrameViewWAKCompatibility.m; path = ios/WebView/WebFrameViewWAKCompatibility.m; sourceTree = SOURCE_ROOT; };
+               A10C1D7B1820303D0036883A /* WebMailDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebMailDelegate.h; path = ios/WebView/WebMailDelegate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D7C1820303D0036883A /* WebPlainWhiteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebPlainWhiteView.h; path = ios/WebView/WebPlainWhiteView.h; sourceTree = SOURCE_ROOT; };
+               A10C1D7D1820303D0036883A /* WebPlainWhiteView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPlainWhiteView.mm; path = ios/WebView/WebPlainWhiteView.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D7E1820303D0036883A /* WebUIKitDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebUIKitDelegate.h; path = ios/WebView/WebUIKitDelegate.h; sourceTree = SOURCE_ROOT; };
+               A10C1D851820305E0036883A /* WebPDFViewIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebPDFViewIOS.h; path = ios/WebView/WebPDFViewIOS.h; sourceTree = SOURCE_ROOT; };
+               A10C1D861820305E0036883A /* WebPDFViewIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPDFViewIOS.mm; path = ios/WebView/WebPDFViewIOS.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D871820305E0036883A /* WebPDFViewIPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebPDFViewIPhone.h; path = ios/WebView/WebPDFViewIPhone.h; sourceTree = SOURCE_ROOT; };
+               A10C1D881820305E0036883A /* WebPDFViewPlaceholder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebPDFViewPlaceholder.h; path = ios/WebView/WebPDFViewPlaceholder.h; sourceTree = SOURCE_ROOT; };
+               A10C1D891820305E0036883A /* WebPDFViewPlaceholder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPDFViewPlaceholder.mm; path = ios/WebView/WebPDFViewPlaceholder.mm; sourceTree = SOURCE_ROOT; };
+               A10C1D8F1820307D0036883A /* WebKit.iOS.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; name = WebKit.iOS.exp; path = ios/WebKit.iOS.exp; sourceTree = "<group>"; };
                A17A11B0180DC84800E5498C /* WebPluginPackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPluginPackagePrivate.h; sourceTree = "<group>"; };
                A5214FC113B975C8000015EF /* WebInspectorRemoteChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorRemoteChannel.h; path = remote/WebInspectorRemoteChannel.h; sourceTree = "<group>"; };
                A5214FC213B975C8000015EF /* WebInspectorRemoteChannel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebInspectorRemoteChannel.mm; path = remote/WebInspectorRemoteChannel.mm; sourceTree = "<group>"; };
                A52209F713C53E75004BA7B1 /* WebInspectorRelayDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorRelayDefinitions.h; path = remote/WebInspectorRelayDefinitions.h; sourceTree = "<group>"; };
-               A560946414D8AD2600799A8A /* WebIndicateLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIndicateLayer.h; sourceTree = "<group>"; };
-               A560946514D8AD2600799A8A /* WebIndicateLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebIndicateLayer.mm; sourceTree = "<group>"; };
                A55E20FD14D7264C0031549E /* WebInspectorServerWebViewConnectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorServerWebViewConnectionController.h; path = remote/WebInspectorServerWebViewConnectionController.h; sourceTree = "<group>"; };
                A55E20FE14D7264C0031549E /* WebInspectorServerWebViewConnectionController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebInspectorServerWebViewConnectionController.mm; path = remote/WebInspectorServerWebViewConnectionController.mm; sourceTree = "<group>"; };
+               A560946414D8AD2600799A8A /* WebIndicateLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIndicateLayer.h; sourceTree = "<group>"; };
+               A560946514D8AD2600799A8A /* WebIndicateLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebIndicateLayer.mm; sourceTree = "<group>"; };
                A5687BD8135B791A0074CBCB /* WebNodeHighlighter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNodeHighlighter.h; sourceTree = "<group>"; };
                A5687BD9135B791A0074CBCB /* WebNodeHighlighter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNodeHighlighter.mm; sourceTree = "<group>"; };
                A57C28A113BAA5AD0070ACAB /* WebInspectorServerWebViewConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorServerWebViewConnection.h; path = remote/WebInspectorServerWebViewConnection.h; sourceTree = "<group>"; };
                A57EB78E13B97A4E008D691D /* WebInspectorClientRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebInspectorClientRegistry.mm; path = remote/WebInspectorClientRegistry.mm; sourceTree = "<group>"; };
                A58A5797143E727000125F50 /* WebOpenPanelResultListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebOpenPanelResultListener.h; sourceTree = "<group>"; };
                A58A5798143E727000125F50 /* WebOpenPanelResultListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebOpenPanelResultListener.mm; sourceTree = "<group>"; };
-               A5C566BB127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDiskImageCacheClientIOS.h; sourceTree = "<group>"; };
-               A5C566BC127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDiskImageCacheClientIOS.mm; sourceTree = "<group>"; };
-               A5D6870E11E63FD7004E7E5D /* WebInspectorClientIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorClientIOS.mm; sourceTree = "<group>"; };
                A5DEFC0711D5331C00885273 /* WebSecurityOrigin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSecurityOrigin.mm; sourceTree = "<group>"; };
                A5DEFC0811D5331C00885273 /* WebSecurityOriginInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSecurityOriginInternal.h; sourceTree = "<group>"; };
                A5DEFC0911D5331C00885273 /* WebSecurityOriginPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSecurityOriginPrivate.h; sourceTree = "<group>"; };
                        children = (
                                1C6CB03E0AA6391D00D23BFD /* MigrateHeaders.make */,
                                F5F732D202FF4D4F01A80180 /* WebKit.exp */,
+                               A10C1D8F1820307D0036883A /* WebKit.iOS.exp */,
                                F5C283730284676D018635CA /* WebKitPrefix.h */,
-                               FED1400A0CECCD6800D89466 /* ios */,
                                6508A4A7099B375F00BCBF45 /* Default Delegates */,
                                F57D194A034E732C01A80180 /* DOM */,
                                25A8176801B5474B0ECA149E /* History */,
                254DC334016E1D3F0ECA149E /* Misc */ = {
                        isa = PBXGroup;
                        children = (
+                               A10C1D2018202FAF0036883A /* ios */,
                                A864B3E5123ED83D00C2A612 /* MailQuirksUserScript.js */,
                                1CCFFD120B1F81F2002EE926 /* OldWebAssertions.c */,
                                29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */,
                        tabWidth = 4;
                        usesTabs = 0;
                };
-               44A11FBE0EBA93B2009F69ED /* WebCoreSupport */ = {
-                       isa = PBXGroup;
-                       children = (
-                               A5C566BB127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.h */,
-                               A5C566BC127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.mm */,
-                               A5D6870E11E63FD7004E7E5D /* WebInspectorClientIOS.mm */,
-                       );
-                       path = WebCoreSupport;
-                       sourceTree = "<group>";
-               };
                511F3FC30CECC7E200852565 /* Storage */ = {
                        isa = PBXGroup;
                        children = (
+                               A10C1D3F18202FDC0036883A /* ios */,
                                511F3FD10CECC88F00852565 /* WebDatabaseManager.mm */,
                                511F3FD30CECC88F00852565 /* WebDatabaseManagerClient.h */,
                                511F3FD40CECC88F00852565 /* WebDatabaseManagerClient.mm */,
                51E94C0706C02CA300A9B09E /* PDF */ = {
                        isa = PBXGroup;
                        children = (
+                               A10C1D84182030450036883A /* ios */,
                                37D1DCA61065928C0068F7EF /* WebJSPDFDoc.h */,
                                37D1DCA71065928C0068F7EF /* WebJSPDFDoc.mm */,
                                37B6FB4C1063530C000FDB3B /* WebPDFDocumentExtras.h */,
                6508A4A7099B375F00BCBF45 /* Default Delegates */ = {
                        isa = PBXGroup;
                        children = (
+                               A10C1D0F18202F7A0036883A /* ios */,
                                5152FADD033FC50400CA2ACD /* WebDefaultContextMenuDelegate.h */,
                                5152FADE033FC50400CA2ACD /* WebDefaultContextMenuDelegate.mm */,
                                BE95BEE605FD0805006E1513 /* WebDefaultEditingDelegate.h */,
                        children = (
                                F52CA6BD02DF9D0F018635CA /* HTML */,
                                51E94C0706C02CA300A9B09E /* PDF */,
+                               A10C1D79182030190036883A /* ios */,
                                8373435A0624EE0D00F3B289 /* WebArchive.h */,
                                8373435B0624EE0D00F3B289 /* WebArchive.mm */,
                                44BB8B131241A022001E3A22 /* WebArchiveInternal.h */,
                        tabWidth = 4;
                        usesTabs = 0;
                };
+               A10C1D0F18202F7A0036883A /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A10C1D1018202F9C0036883A /* WebDefaultFormDelegate.h */,
+                               A10C1D1118202F9C0036883A /* WebDefaultFormDelegate.m */,
+                               A10C1D1218202F9C0036883A /* WebDefaultFrameLoadDelegate.h */,
+                               A10C1D1318202F9C0036883A /* WebDefaultFrameLoadDelegate.m */,
+                               A10C1D1418202F9C0036883A /* WebDefaultResourceLoadDelegate.h */,
+                               A10C1D1518202F9C0036883A /* WebDefaultResourceLoadDelegate.m */,
+                               A10C1D1618202F9C0036883A /* WebDefaultUIKitDelegate.h */,
+                               A10C1D1718202F9C0036883A /* WebDefaultUIKitDelegate.m */,
+                       );
+                       name = ios;
+                       sourceTree = "<group>";
+               };
+               A10C1D2018202FAF0036883A /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A10C1D2118202FC50036883A /* EmojiFallbackFontSelector.cpp */,
+                               A10C1D2218202FC50036883A /* EmojiFallbackFontSelector.h */,
+                               A10C1D2318202FC50036883A /* MemoryMeasure.h */,
+                               A10C1D2418202FC50036883A /* MemoryMeasure.mm */,
+                               A10C1D2518202FC50036883A /* WebGeolocationCoreLocationProvider.h */,
+                               A10C1D2618202FC50036883A /* WebGeolocationCoreLocationProvider.mm */,
+                               A10C1D2718202FC50036883A /* WebGeolocationProviderIOS.h */,
+                               A10C1D2818202FC50036883A /* WebGeolocationProviderIOS.mm */,
+                               A10C1D2918202FC50036883A /* WebNSStringDrawing.h */,
+                               A10C1D2A18202FC50036883A /* WebNSStringDrawing.mm */,
+                               A10C1D2B18202FC50036883A /* WebNSStringExtrasIOS.h */,
+                               A10C1D2C18202FC50036883A /* WebNSStringExtrasIOS.m */,
+                               A10C1D2D18202FC50036883A /* WebNSStringExtrasIPhone.h */,
+                               A10C1D2E18202FC50036883A /* WebUIKitSupport.h */,
+                               A10C1D2F18202FC50036883A /* WebUIKitSupport.mm */,
+                       );
+                       name = ios;
+                       sourceTree = "<group>";
+               };
+               A10C1D3F18202FDC0036883A /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A10C1D4018202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h */,
+                               A10C1D4118202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm */,
+                       );
+                       name = ios;
+                       sourceTree = "<group>";
+               };
+               A10C1D4418202FFB0036883A /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A10C1D451820300E0036883A /* PopupMenuIOS.h */,
+                               A10C1D461820300E0036883A /* PopupMenuIOS.mm */,
+                               A10C1D471820300E0036883A /* SearchPopupMenuIOS.cpp */,
+                               A10C1D481820300E0036883A /* SearchPopupMenuIOS.h */,
+                               A10C1D491820300E0036883A /* WebCaretChangeListener.h */,
+                               A10C1D4A1820300E0036883A /* WebChromeClientIOS.h */,
+                               A10C1D4B1820300E0036883A /* WebChromeClientIOS.mm */,
+                               A10C1D4C1820300E0036883A /* WebDiskImageCacheClientIOS.h */,
+                               A10C1D4D1820300E0036883A /* WebDiskImageCacheClientIOS.mm */,
+                               A10C1D4E1820300E0036883A /* WebFixedPositionContent.h */,
+                               A10C1D4F1820300E0036883A /* WebFixedPositionContent.mm */,
+                               A10C1D501820300E0036883A /* WebFixedPositionContentInternal.h */,
+                               A10C1D511820300E0036883A /* WebFrameIOS.h */,
+                               A10C1D521820300E0036883A /* WebFrameIOS.mm */,
+                               A10C1D531820300E0036883A /* WebFrameIPhone.h */,
+                               A10C1D541820300E0036883A /* WebGeolocation.mm */,
+                               A10C1D551820300E0036883A /* WebGeolocationInternal.h */,
+                               A10C1D561820300E0036883A /* WebGeolocationPrivate.h */,
+                               A10C1D571820300E0036883A /* WebInspectorClientIOS.mm */,
+                               A10C1D581820300E0036883A /* WebMIMETypeRegistry.h */,
+                               A10C1D591820300E0036883A /* WebMIMETypeRegistry.mm */,
+                               A10C1D5A1820300E0036883A /* WebSelectionRect.h */,
+                               A10C1D5B1820300E0036883A /* WebSelectionRect.m */,
+                               A10C1D5C1820300E0036883A /* WebVisiblePosition.h */,
+                               A10C1D5D1820300E0036883A /* WebVisiblePosition.mm */,
+                               A10C1D5E1820300E0036883A /* WebVisiblePositionInternal.h */,
+                       );
+                       name = ios;
+                       sourceTree = "<group>";
+               };
+               A10C1D79182030190036883A /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A10C1D7A1820303D0036883A /* WebFrameViewWAKCompatibility.m */,
+                               A10C1D7B1820303D0036883A /* WebMailDelegate.h */,
+                               A10C1D7C1820303D0036883A /* WebPlainWhiteView.h */,
+                               A10C1D7D1820303D0036883A /* WebPlainWhiteView.mm */,
+                               A10C1D7E1820303D0036883A /* WebUIKitDelegate.h */,
+                       );
+                       name = ios;
+                       sourceTree = "<group>";
+               };
+               A10C1D84182030450036883A /* ios */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A10C1D851820305E0036883A /* WebPDFViewIOS.h */,
+                               A10C1D861820305E0036883A /* WebPDFViewIOS.mm */,
+                               A10C1D871820305E0036883A /* WebPDFViewIPhone.h */,
+                               A10C1D881820305E0036883A /* WebPDFViewPlaceholder.h */,
+                               A10C1D891820305E0036883A /* WebPDFViewPlaceholder.mm */,
+                       );
+                       name = ios;
+                       sourceTree = "<group>";
+               };
                A5214FBF13B97596000015EF /* remote */ = {
                        isa = PBXGroup;
                        children = (
                F5B36B400281DE87018635CB /* WebCoreSupport */ = {
                        isa = PBXGroup;
                        children = (
+                               A10C1D4418202FFB0036883A /* ios */,
                                070F549917F1E42B00169E04 /* WebUserMediaClient.h */,
                                070F549A17F1E42B00169E04 /* WebUserMediaClient.mm */,
                                B82958D1132707D0000D0E79 /* CorrectionPanel.h */,
                        tabWidth = 4;
                        usesTabs = 0;
                };
-               FED1400A0CECCD6800D89466 /* ios */ = {
-                       isa = PBXGroup;
-                       children = (
-                               44A11FBE0EBA93B2009F69ED /* WebCoreSupport */,
-                       );
-                       path = ios;
-                       sourceTree = "<group>";
-               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
                                1A60519217502A5D00BC62F5 /* BinaryPropertyList.h in Headers */,
                                9398106A0824BF01008DF038 /* CarbonUtils.h in Headers */,
                                939810650824BF01008DF038 /* CarbonWindowAdapter.h in Headers */,
+                               A10C1D3C18202FC50036883A /* WebNSStringExtrasIPhone.h in Headers */,
                                939810660824BF01008DF038 /* CarbonWindowContentView.h in Headers */,
                                939810670824BF01008DF038 /* CarbonWindowFrame.h in Headers */,
                                B82958D3132707D0000D0E79 /* CorrectionPanel.h in Headers */,
                                1A60519417502A5D00BC62F5 /* HistoryPropertyList.h in Headers */,
                                939810680824BF01008DF038 /* HIViewAdapter.h in Headers */,
-                               A5C566BD127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.h in Headers */,
                                070F549B17F1E42B00169E04 /* WebUserMediaClient.h in Headers */,
                                939810690824BF01008DF038 /* HIWebView.h in Headers */,
                                1A8DED500EE88B8A00F25022 /* HostedNetscapePluginStream.h in Headers */,
                                1AAF5CEC0EDDE1FE008D883D /* NetscapePluginHostProxy.h in Headers */,
                                1AAF5CEE0EDDE1FE008D883D /* NetscapePluginInstanceProxy.h in Headers */,
                                7C01CB85173435C900C5D807 /* PopupMenuMac.h in Headers */,
+                               A10C1D1E18202F9C0036883A /* WebDefaultUIKitDelegate.h in Headers */,
                                1A2DBE9F0F251E3A0036F8A6 /* ProxyInstance.h in Headers */,
+                               A10C1D661820300E0036883A /* WebDiskImageCacheClientIOS.h in Headers */,
                                E169836211346D1B00894115 /* ProxyRuntimeObject.h in Headers */,
                                7C01CB87173435C900C5D807 /* SearchPopupMenuMac.h in Headers */,
+                               A10C1D6F1820300E0036883A /* WebGeolocationInternal.h in Headers */,
                                CEDA12DC152CBE6800D9E08D /* WebAlternativeTextClient.h in Headers */,
                                B6CE5C25100BC5F500219936 /* WebApplicationCache.h in Headers */,
+                               A10C1D721820300E0036883A /* WebMIMETypeRegistry.h in Headers */,
                                A5DEFC1311D5344B00885273 /* WebApplicationCacheQuotaManager.h in Headers */,
                                9398109A0824BF01008DF038 /* WebArchive.h in Headers */,
+                               A10C1D761820300E0036883A /* WebVisiblePosition.h in Headers */,
                                44BB8B141241A022001E3A22 /* WebArchiveInternal.h in Headers */,
                                939810290824BF01008DF038 /* WebAuthenticationPanel.h in Headers */,
                                939810110824BF01008DF038 /* WebBackForwardList.h in Headers */,
                                22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */,
                                1A4DF5E40EC8D104006BD4B4 /* WebBaseNetscapePluginView.h in Headers */,
                                9398102E0824BF01008DF038 /* WebBasePluginPackage.h in Headers */,
+                               A10C1D8A1820305E0036883A /* WebPDFViewIOS.h in Headers */,
                                5241ADF50B1BC48A004012BD /* WebCache.h in Headers */,
                                51CBFCAD0D10E6C5002DBF51 /* WebCachedFramePlatformData.h in Headers */,
                                14D8252F0AF955090004F057 /* WebChromeClient.h in Headers */,
                                934C11670D8710BB00C32ABD /* WebDynamicScrollBarsViewInternal.h in Headers */,
                                9398109E0824BF01008DF038 /* WebEditingDelegate.h in Headers */,
                                1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */,
+                               A10C1D1818202F9C0036883A /* WebDefaultFormDelegate.h in Headers */,
                                4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */,
                                DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */,
                                939810520824BF01008DF038 /* WebFormDelegate.h in Headers */,
                                939810640824BF01008DF038 /* WebFormDelegatePrivate.h in Headers */,
                                939810530824BF01008DF038 /* WebFrame.h in Headers */,
+                               A10C1D1A18202F9C0036883A /* WebDefaultFrameLoadDelegate.h in Headers */,
                                9398109C0824BF01008DF038 /* WebFrameInternal.h in Headers */,
                                9398105B0824BF01008DF038 /* WebFrameLoadDelegate.h in Headers */,
                                C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */,
                                931633EB0AEDFF930062B92D /* WebFrameLoaderClient.h in Headers */,
                                9391F275121B38BD00EBF7E8 /* WebFrameNetworkingContext.h in Headers */,
+                               A10C1D4218202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h in Headers */,
                                939810540824BF01008DF038 /* WebFramePrivate.h in Headers */,
+                               A10C1D621820300E0036883A /* SearchPopupMenuIOS.h in Headers */,
                                9398106E0824BF01008DF038 /* WebFrameView.h in Headers */,
                                9398106F0824BF01008DF038 /* WebFrameViewInternal.h in Headers */,
                                939810AF0824BF01008DF038 /* WebFrameViewPrivate.h in Headers */,
                                51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */,
                                9304B3000B02341500F7850D /* WebIconDatabaseInternal.h in Headers */,
                                939810190824BF01008DF038 /* WebIconDatabasePrivate.h in Headers */,
+                               A10C1D641820300E0036883A /* WebChromeClientIOS.h in Headers */,
                                5D7BF8140C2A1D90008CE06D /* WebInspector.h in Headers */,
                                06693DDC0BFBA85200216072 /* WebInspectorClient.h in Headers */,
                                A57EB78F13B97A4E008D691D /* WebInspectorClientRegistry.h in Headers */,
                                939810850824BF01008DF038 /* WebKeyGenerator.h in Headers */,
                                9398101B0824BF01008DF038 /* WebKit.h in Headers */,
                                9398101C0824BF01008DF038 /* WebKitErrors.h in Headers */,
+                               A10C1D8C1820305E0036883A /* WebPDFViewIPhone.h in Headers */,
                                9398106D0824BF01008DF038 /* WebKitErrorsPrivate.h in Headers */,
                                CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */,
                                9398101D0824BF01008DF038 /* WebKitLogging.h in Headers */,
+                               A10C1D3818202FC50036883A /* WebNSStringDrawing.h in Headers */,
                                9398101E0824BF01008DF038 /* WebKitNSStringExtras.h in Headers */,
                                1AAF58940EDCCF15008D883D /* WebKitPluginAgent.defs in Headers */,
                                1AAF58950EDCCF15008D883D /* WebKitPluginAgentReply.defs in Headers */,
                                1AAF58970EDCCF15008D883D /* WebKitPluginHost.defs in Headers */,
                                1AAF58980EDCCF15008D883D /* WebKitPluginHostTypes.defs in Headers */,
                                1AAF5D090EDDE71D008D883D /* WebKitPluginHostTypes.h in Headers */,
+                               A10C1D3118202FC50036883A /* EmojiFallbackFontSelector.h in Headers */,
+                               A10C1D1C18202F9C0036883A /* WebDefaultResourceLoadDelegate.h in Headers */,
                                939810470824BF01008DF038 /* WebKitPrefix.h in Headers */,
                                9398101F0824BF01008DF038 /* WebKitStatistics.h in Headers */,
                                939810200824BF01008DF038 /* WebKitStatisticsPrivate.h in Headers */,
+                               A10C1D3D18202FC50036883A /* WebUIKitSupport.h in Headers */,
                                9398107A0824BF01008DF038 /* WebKitSystemBits.h in Headers */,
                                1C0D40870AC1C8F40009C113 /* WebKitVersionChecks.h in Headers */,
                                939810790824BF01008DF038 /* WebLocalizableStrings.h in Headers */,
                                0AB752370FA2E4DB00D7CBB1 /* WebNetscapeContainerCheckContextInfo.h in Headers */,
                                0AEBFF630F9FA8BE000D486B /* WebNetscapeContainerCheckPrivate.h in Headers */,
                                1AEA66D40DC6B1FF003D12BF /* WebNetscapePluginEventHandler.h in Headers */,
+                               A10C1D3618202FC50036883A /* WebGeolocationProviderIOS.h in Headers */,
+                               A10C1D631820300E0036883A /* WebCaretChangeListener.h in Headers */,
                                1AEA66D80DC6B209003D12BF /* WebNetscapePluginEventHandlerCarbon.h in Headers */,
                                1AEA6A500DC8CE2F003D12BF /* WebNetscapePluginEventHandlerCocoa.h in Headers */,
+                               A10C1D5F1820300E0036883A /* PopupMenuIOS.h in Headers */,
                                A560946614D8AD2600799A8A /* WebIndicateLayer.h in Headers */,
                                939810310824BF01008DF038 /* WebNetscapePluginPackage.h in Headers */,
                                9398102B0824BF01008DF038 /* WebNetscapePluginStream.h in Headers */,
                                1A4DF5220EC8C74D006BD4B4 /* WebNetscapePluginView.h in Headers */,
                                1C68F66F095B5FC100C2984E /* WebNodeHighlight.h in Headers */,
                                A5687BDA135B791A0074CBCB /* WebNodeHighlighter.h in Headers */,
+                               A10C1D831820303D0036883A /* WebUIKitDelegate.h in Headers */,
                                1C68F671095B5FC100C2984E /* WebNodeHighlightView.h in Headers */,
                                312E2FE514E48182007CCA18 /* WebNotification.h in Headers */,
                                31C11A6E1476552E0049A4CC /* WebNotificationClient.h in Headers */,
                                312E2FE914E48215007CCA18 /* WebNotificationInternal.h in Headers */,
+                               A10C1D781820300E0036883A /* WebVisiblePositionInternal.h in Headers */,
                                EDE983800BCDF5FE00FDAE28 /* WebNSArrayExtras.h in Headers */,
                                939810210824BF01008DF038 /* WebNSControlExtras.h in Headers */,
                                939810820824BF01008DF038 /* WebNSDataExtras.h in Headers */,
                                939810230824BF01008DF038 /* WebNSPasteboardExtras.h in Headers */,
                                939810870824BF01008DF038 /* WebNSPrintOperationExtras.h in Headers */,
                                9398107E0824BF01008DF038 /* WebNSURLExtras.h in Headers */,
+                               A10C1D8D1820305E0036883A /* WebPDFViewPlaceholder.h in Headers */,
+                               A10C1D6A1820300E0036883A /* WebFixedPositionContentInternal.h in Headers */,
                                65E0F88408500917007E5CB9 /* WebNSURLRequestExtras.h in Headers */,
                                65E0F9E608500F23007E5CB9 /* WebNSUserDefaultsExtras.h in Headers */,
                                939810240824BF01008DF038 /* WebNSViewExtras.h in Headers */,
                                1AA879B611CBE9BF003C664F /* WebPlatformStrategies.h in Headers */,
                                939810350824BF01008DF038 /* WebPlugin.h in Headers */,
                                939810360824BF01008DF038 /* WebPluginContainer.h in Headers */,
+                               A10C1D801820303D0036883A /* WebMailDelegate.h in Headers */,
                                939810B10824BF01008DF038 /* WebPluginContainerCheck.h in Headers */,
                                939810B00824BF01008DF038 /* WebPluginContainerPrivate.h in Headers */,
                                939810370824BF01008DF038 /* WebPluginController.h in Headers */,
                                1A77B02E0EE7730500C8A1F9 /* WebPluginRequest.h in Headers */,
                                224100F3091818D900D2D266 /* WebPluginsPrivate.h in Headers */,
                                9398103A0824BF01008DF038 /* WebPluginViewFactory.h in Headers */,
+                               A10C1D701820300E0036883A /* WebGeolocationPrivate.h in Headers */,
                                939810AC0824BF01008DF038 /* WebPluginViewFactoryPrivate.h in Headers */,
+                               A10C1D6D1820300E0036883A /* WebFrameIPhone.h in Headers */,
                                939810720824BF01008DF038 /* WebPolicyDelegate.h in Headers */,
                                939810730824BF01008DF038 /* WebPolicyDelegatePrivate.h in Headers */,
                                939810A80824BF01008DF038 /* WebPreferenceKeysPrivate.h in Headers */,
                                939810600824BF01008DF038 /* WebResourceLoadDelegate.h in Headers */,
                                656D333E0AF21AE900212169 /* WebResourceLoadDelegatePrivate.h in Headers */,
                                939810890824BF01008DF038 /* WebResourcePrivate.h in Headers */,
+                               A10C1D3A18202FC50036883A /* WebNSStringExtrasIOS.h in Headers */,
                                7E6FEF0808985A7200C44C3F /* WebScriptDebugDelegate.h in Headers */,
                                C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */,
                                C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
                                BC26C69E10B743F400B687ED /* WebSerializedJSValue.h in Headers */,
                                F67DD7E6125E4527007BDCB8 /* WebSerializedJSValuePrivate.h in Headers */,
                                3AE15D5012DBDED4009323C8 /* WebStorageManagerInternal.h in Headers */,
+                               A10C1D681820300E0036883A /* WebFixedPositionContent.h in Headers */,
                                3AB02B0012C132B200FBB694 /* WebStorageManagerPrivate.h in Headers */,
+                               A10C1D811820303D0036883A /* WebPlainWhiteView.h in Headers */,
                                3ABB3C7A1309C3B500E93D94 /* WebStorageTrackerClient.h in Headers */,
                                939810270824BF01008DF038 /* WebStringTruncator.h in Headers */,
                                93EB178F09F88D510091F8FF /* WebSystemInterface.h in Headers */,
                                936A2DEA0FD2D08400D312DB /* WebTextCompletionController.h in Headers */,
                                1A74A28E0F4F75400082E228 /* WebTextInputWindowController.h in Headers */,
+                               A10C1D3218202FC50036883A /* MemoryMeasure.h in Headers */,
                                F834AAD70E64B1C700E2737C /* WebTextIterator.h in Headers */,
                                DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */,
                                939810750824BF01008DF038 /* WebUIDelegate.h in Headers */,
+                               A10C1D6B1820300E0036883A /* WebFrameIOS.h in Headers */,
                                939810830824BF01008DF038 /* WebUIDelegatePrivate.h in Headers */,
+                               A10C1D3418202FC50036883A /* WebGeolocationCoreLocationProvider.h in Headers */,
                                939810150824BF01008DF038 /* WebURLsWithTitles.h in Headers */,
                                C0C5B3EE1177A4A0002B0AEF /* WebUserContentURLPattern.h in Headers */,
                                939810700824BF01008DF038 /* WebView.h in Headers */,
+                               A10C1D741820300E0036883A /* WebSelectionRect.h in Headers */,
                                BC2E464D0FD8A96800A9D9DE /* WebViewData.h in Headers */,
                                9398109B0824BF01008DF038 /* WebViewInternal.h in Headers */,
                                939810710824BF01008DF038 /* WebViewPrivate.h in Headers */,
                                1AAF5CEF0EDDE1FE008D883D /* NetscapePluginInstanceProxy.mm in Sources */,
                                939810DD0824BF01008DF038 /* npapi.mm in Sources */,
                                1CCFFD130B1F81F2002EE926 /* OldWebAssertions.c in Sources */,
+                               A10C1D8E1820305E0036883A /* WebPDFViewPlaceholder.mm in Sources */,
                                7C01CB86173435C900C5D807 /* PopupMenuMac.mm in Sources */,
+                               A10C1D771820300E0036883A /* WebVisiblePosition.mm in Sources */,
                                1A2DBEA00F251E3A0036F8A6 /* ProxyInstance.mm in Sources */,
                                070F549C17F1E42B00169E04 /* WebUserMediaClient.mm in Sources */,
                                E169836C11346D5600894115 /* ProxyRuntimeObject.mm in Sources */,
                                7C01CB88173435C900C5D807 /* SearchPopupMenuMac.mm in Sources */,
                                CEDA12DB152CBE6800D9E08D /* WebAlternativeTextClient.mm in Sources */,
+                               A10C1D601820300E0036883A /* PopupMenuIOS.mm in Sources */,
                                B6CE5C24100BC5CE00219936 /* WebApplicationCache.mm in Sources */,
                                A5DEFC1411D5344B00885273 /* WebApplicationCacheQuotaManager.mm in Sources */,
+                               A10C1D731820300E0036883A /* WebMIMETypeRegistry.mm in Sources */,
                                9398111D0824BF01008DF038 /* WebArchive.mm in Sources */,
                                939810CF0824BF01008DF038 /* WebAuthenticationPanel.m in Sources */,
                                939810BC0824BF01008DF038 /* WebBackForwardList.mm in Sources */,
                                939810D30824BF01008DF038 /* WebBasePluginPackage.mm in Sources */,
                                5241ADF60B1BC48A004012BD /* WebCache.mm in Sources */,
                                14D825300AF955090004F057 /* WebChromeClient.mm in Sources */,
+                               A10C1D711820300E0036883A /* WebInspectorClientIOS.mm in Sources */,
                                939810EB0824BF01008DF038 /* WebClipView.mm in Sources */,
                                065AD5A40B0C32C7005A2B1D /* WebContextMenuClient.mm in Sources */,
                                939810BF0824BF01008DF038 /* WebCoreStatistics.mm in Sources */,
                                598AD9221201CF1000ABAE4E /* WebDeviceOrientation.mm in Sources */,
                                598AD91E1201CECF00ABAE4E /* WebDeviceOrientationClient.mm in Sources */,
                                598AD9281201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm in Sources */,
+                               A10C1D751820300E0036883A /* WebSelectionRect.m in Sources */,
                                65FFB7FD0AD0B7D30048CD05 /* WebDocumentLoaderMac.mm in Sources */,
+                               A10C1D1B18202F9C0036883A /* WebDefaultFrameLoadDelegate.m in Sources */,
                                9398111C0824BF01008DF038 /* WebDOMOperations.mm in Sources */,
                                E15663190FB61C1F00C199CA /* WebDownload.mm in Sources */,
                                A70936B00B5608DC00CDB48E /* WebDragClient.mm in Sources */,
                                931633EF0AEDFFAE0062B92D /* WebFrameLoaderClient.mm in Sources */,
                                9391F276121B38BD00EBF7E8 /* WebFrameNetworkingContext.mm in Sources */,
                                939811060824BF01008DF038 /* WebFrameView.mm in Sources */,
+                               A10C1D3018202FC50036883A /* EmojiFallbackFontSelector.cpp in Sources */,
                                CDA62AE3125F87C2007FD118 /* WebFullScreenController.mm in Sources */,
                                BC7F884C10C8775A00D6133D /* WebGeolocationClient.mm in Sources */,
                                BC7F889F10C9D30C00D6133D /* WebGeolocationPosition.mm in Sources */,
                                939811130824BF01008DF038 /* WebHistory.mm in Sources */,
                                939810BD0824BF01008DF038 /* WebHistoryItem.mm in Sources */,
                                1AAF5FC00EDE3A92008D883D /* WebHostedNetscapePluginView.mm in Sources */,
+                               A10C1D671820300E0036883A /* WebDiskImageCacheClientIOS.mm in Sources */,
                                939810F30824BF01008DF038 /* WebHTMLRepresentation.mm in Sources */,
                                939810F40824BF01008DF038 /* WebHTMLView.mm in Sources */,
+                               A10C1D7F1820303D0036883A /* WebFrameViewWAKCompatibility.m in Sources */,
+                               A10C1D3718202FC50036883A /* WebGeolocationProviderIOS.mm in Sources */,
                                939810C10824BF01008DF038 /* WebIconDatabase.mm in Sources */,
                                51494CD70C7EBDE0004178C5 /* WebIconDatabaseClient.mm in Sources */,
                                5D7BF8150C2A1D90008CE06D /* WebInspector.mm in Sources */,
+                               A10C1D901820307D0036883A /* WebKit.iOS.exp in Sources */,
                                06693DDD0BFBA85200216072 /* WebInspectorClient.mm in Sources */,
                                1C7B0C660EB2464D00A28502 /* WebInspectorClientCF.cpp in Sources */,
                                A57EB79013B97A4E008D691D /* WebInspectorClientRegistry.mm in Sources */,
                                A57C28A813BAA5AD0070ACAB /* WebInspectorServerWebViewConnection.mm in Sources */,
                                A55E210014D7264C0031549E /* WebInspectorServerWebViewConnectionController.mm in Sources */,
                                A57C28AC13BAA5AD0070ACAB /* WebInspectorXPCWrapper.m in Sources */,
+                               A10C1D1918202F9C0036883A /* WebDefaultFormDelegate.m in Sources */,
                                939810E40824BF01008DF038 /* WebJavaScriptTextInputPanel.m in Sources */,
+                               A10C1D8B1820305E0036883A /* WebPDFViewIOS.mm in Sources */,
                                37D1DCA91065928C0068F7EF /* WebJSPDFDoc.mm in Sources */,
                                939811170824BF01008DF038 /* WebKeyGenerator.mm in Sources */,
                                939811030824BF01008DF038 /* WebKitErrors.m in Sources */,
                                CD8BFCE715531224005AFB25 /* WebKitFullScreenListener.mm in Sources */,
                                939810C30824BF01008DF038 /* WebKitLogging.m in Sources */,
+                               A10C1D3318202FC50036883A /* MemoryMeasure.mm in Sources */,
                                939810C40824BF01008DF038 /* WebKitNSStringExtras.mm in Sources */,
                                1AAF5D0F0EDDE7A7008D883D /* WebKitPluginAgent.defs in Sources */,
+                               A10C1D1F18202F9C0036883A /* WebDefaultUIKitDelegate.m in Sources */,
                                1AAF5D000EDDE604008D883D /* WebKitPluginClient.defs in Sources */,
                                1AAF5CF10EDDE586008D883D /* WebKitPluginHost.defs in Sources */,
                                939810C50824BF01008DF038 /* WebKitStatistics.m in Sources */,
                                0AB752380FA2E4DB00D7CBB1 /* WebNetscapeContainerCheckContextInfo.mm in Sources */,
                                0AEBFF640F9FA8BE000D486B /* WebNetscapeContainerCheckPrivate.mm in Sources */,
                                1AEA66D50DC6B1FF003D12BF /* WebNetscapePluginEventHandler.mm in Sources */,
+                               A10C1D651820300E0036883A /* WebChromeClientIOS.mm in Sources */,
+                               A10C1D3518202FC50036883A /* WebGeolocationCoreLocationProvider.mm in Sources */,
                                1AEA66D90DC6B209003D12BF /* WebNetscapePluginEventHandlerCarbon.mm in Sources */,
                                1AEA6A510DC8CE2F003D12BF /* WebNetscapePluginEventHandlerCocoa.mm in Sources */,
                                939810D60824BF01008DF038 /* WebNetscapePluginPackage.mm in Sources */,
                                1A4DF5230EC8C74D006BD4B4 /* WebNetscapePluginView.mm in Sources */,
                                1C68F670095B5FC100C2984E /* WebNodeHighlight.mm in Sources */,
                                A5687BDB135B791A0074CBCB /* WebNodeHighlighter.mm in Sources */,
-                               A5C566BE127A3AE500E8A3FF /* WebDiskImageCacheClientIOS.mm in Sources */,
                                1C68F672095B5FC100C2984E /* WebNodeHighlightView.mm in Sources */,
+                               A10C1D611820300E0036883A /* SearchPopupMenuIOS.cpp in Sources */,
+                               A10C1D6C1820300E0036883A /* WebFrameIOS.mm in Sources */,
                                312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */,
                                31C11A6F1476552E0049A4CC /* WebNotificationClient.mm in Sources */,
                                EDE983810BCDF5FE00FDAE28 /* WebNSArrayExtras.m in Sources */,
                                939811150824BF01008DF038 /* WebNSDataExtras.m in Sources */,
                                65488DA2084FBCCB00831AD0 /* WebNSDictionaryExtras.m in Sources */,
                                939811160824BF01008DF038 /* WebNSEventExtras.m in Sources */,
+                               A10C1D3918202FC50036883A /* WebNSStringDrawing.mm in Sources */,
                                65EEDE58084FFC9E0002DB25 /* WebNSFileManagerExtras.mm in Sources */,
                                939810C70824BF01008DF038 /* WebNSImageExtras.m in Sources */,
+                               A10C1D4318202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm in Sources */,
                                934C4A910F01406C009372C0 /* WebNSObjectExtras.mm in Sources */,
                                939810C80824BF01008DF038 /* WebNSPasteboardExtras.mm in Sources */,
                                939811190824BF01008DF038 /* WebNSPrintOperationExtras.m in Sources */,
                                939810CA0824BF01008DF038 /* WebNSWindowExtras.m in Sources */,
                                A58A579A143E727000125F50 /* WebOpenPanelResultListener.mm in Sources */,
                                939810D00824BF01008DF038 /* WebPanelAuthenticationHandler.m in Sources */,
+                               A10C1D821820303D0036883A /* WebPlainWhiteView.mm in Sources */,
                                37B6FB4F1063530C000FDB3B /* WebPDFDocumentExtras.mm in Sources */,
                                9398111F0824BF01008DF038 /* WebPDFRepresentation.mm in Sources */,
                                9398111E0824BF01008DF038 /* WebPDFView.mm in Sources */,
                                939810F90824BF01008DF038 /* WebRenderNode.mm in Sources */,
                                9398111A0824BF01008DF038 /* WebResource.mm in Sources */,
                                7E6FEF0908985A7200C44C3F /* WebScriptDebugDelegate.mm in Sources */,
+                               A10C1D3B18202FC50036883A /* WebNSStringExtrasIOS.m in Sources */,
                                C0167BF90D7F5DD00028696E /* WebScriptDebugger.mm in Sources */,
                                C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */,
                                A5DEFC0A11D5331C00885273 /* WebSecurityOrigin.mm in Sources */,
                                BC26C6A510B7447A00B687ED /* WebSerializedJSValue.mm in Sources */,
                                3AB02AF612C1319B00FBB694 /* WebStorageManager.mm in Sources */,
+                               A10C1D691820300E0036883A /* WebFixedPositionContent.mm in Sources */,
                                3ABB3C7B1309C3B500E93D94 /* WebStorageTrackerClient.mm in Sources */,
                                939810CC0824BF01008DF038 /* WebStringTruncator.mm in Sources */,
+                               A10C1D6E1820300E0036883A /* WebGeolocation.mm in Sources */,
                                93EB178D09F88D460091F8FF /* WebSystemInterface.mm in Sources */,
                                936A2DE80FD2D08000D312DB /* WebTextCompletionController.mm in Sources */,
+                               A10C1D3E18202FC50036883A /* WebUIKitSupport.mm in Sources */,
                                1A74A28F0F4F75400082E228 /* WebTextInputWindowController.m in Sources */,
                                F834AAD80E64B1C700E2737C /* WebTextIterator.mm in Sources */,
+                               A10C1D1D18202F9C0036883A /* WebDefaultResourceLoadDelegate.m in Sources */,
                                939810BE0824BF01008DF038 /* WebURLsWithTitles.m in Sources */,
                                C0C5B3EF1177A4A0002B0AEF /* WebUserContentURLPattern.mm in Sources */,
                                939811070824BF01008DF038 /* WebView.mm in Sources */,
index 7b67421..d7b8265 100644 (file)
@@ -1,3 +1,70 @@
+2013-10-29  Andy Estes  <aestes@apple.com>
+
+        [iOS] Upstream Source/WebKit/ios/
+        https://bugs.webkit.org/show_bug.cgi?id=123470
+
+        Reviewed by Sam Weinig.
+
+        * DefaultDelegates/WebDefaultFormDelegate.h: Added.
+        * DefaultDelegates/WebDefaultFormDelegate.m: Added.
+        * DefaultDelegates/WebDefaultFrameLoadDelegate.h: Added.
+        * DefaultDelegates/WebDefaultFrameLoadDelegate.m: Added.
+        * DefaultDelegates/WebDefaultResourceLoadDelegate.h: Added.
+        * DefaultDelegates/WebDefaultResourceLoadDelegate.m: Added.
+        * DefaultDelegates/WebDefaultUIKitDelegate.h: Added.
+        * DefaultDelegates/WebDefaultUIKitDelegate.m: Added.
+        * Misc/EmojiFallbackFontSelector.cpp: Added.
+        * Misc/EmojiFallbackFontSelector.h: Added.
+        * Misc/MemoryMeasure.h: Added.
+        * Misc/MemoryMeasure.mm: Added.
+        * Misc/WebGeolocationCoreLocationProvider.h: Added.
+        * Misc/WebGeolocationCoreLocationProvider.mm: Added.
+        * Misc/WebGeolocationProviderIOS.h: Added.
+        * Misc/WebGeolocationProviderIOS.mm: Added.
+        * Misc/WebNSStringDrawing.h: Added.
+        * Misc/WebNSStringDrawing.mm: Added.
+        * Misc/WebNSStringExtrasIOS.h: Added.
+        * Misc/WebNSStringExtrasIOS.m: Added.
+        * Misc/WebNSStringExtrasIPhone.h: Added.
+        * Misc/WebUIKitSupport.h: Added.
+        * Misc/WebUIKitSupport.mm: Added.
+        * Storage/WebSQLiteDatabaseTrackerClient.h: Added.
+        * Storage/WebSQLiteDatabaseTrackerClient.mm: Added.
+        * WebCoreSupport/PopupMenuIOS.h: Added.
+        * WebCoreSupport/PopupMenuIOS.mm: Added.
+        * WebCoreSupport/SearchPopupMenuIOS.cpp: Added.
+        * WebCoreSupport/SearchPopupMenuIOS.h: Added.
+        * WebCoreSupport/WebCaretChangeListener.h: Added.
+        * WebCoreSupport/WebChromeClientIOS.h: Added.
+        * WebCoreSupport/WebChromeClientIOS.mm: Added.
+        * WebCoreSupport/WebFixedPositionContent.h: Added.
+        * WebCoreSupport/WebFixedPositionContent.mm: Added.
+        * WebCoreSupport/WebFixedPositionContentInternal.h: Added.
+        * WebCoreSupport/WebFrameIOS.h: Added.
+        * WebCoreSupport/WebFrameIOS.mm: Added.
+        * WebCoreSupport/WebFrameIPhone.h: Added.
+        * WebCoreSupport/WebGeolocation.mm: Added.
+        * WebCoreSupport/WebGeolocationInternal.h: Added.
+        * WebCoreSupport/WebGeolocationPrivate.h: Added.
+        * WebCoreSupport/WebMIMETypeRegistry.h: Added.
+        * WebCoreSupport/WebMIMETypeRegistry.mm: Added.
+        * WebCoreSupport/WebSelectionRect.h: Added.
+        * WebCoreSupport/WebSelectionRect.m: Added.
+        * WebCoreSupport/WebVisiblePosition.h: Added.
+        * WebCoreSupport/WebVisiblePosition.mm: Added.
+        * WebCoreSupport/WebVisiblePositionInternal.h: Added.
+        * WebKit.iOS.exp: Added.
+        * WebView/WebFrameViewWAKCompatibility.m: Added.
+        * WebView/WebMailDelegate.h: Added.
+        * WebView/WebPDFViewIOS.h: Added.
+        * WebView/WebPDFViewIOS.mm: Added.
+        * WebView/WebPDFViewIPhone.h: Added.
+        * WebView/WebPDFViewPlaceholder.h: Added.
+        * WebView/WebPDFViewPlaceholder.mm: Added.
+        * WebView/WebPlainWhiteView.h: Added.
+        * WebView/WebPlainWhiteView.mm: Added.
+        * WebView/WebUIKitDelegate.h: Added.
+
 2013-10-25  Joseph Pecoraro  <pecoraro@apple.com>
 
         Upstream ENABLE(REMOTE_INSPECTOR) and enable on iOS and Mac
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultFormDelegate.h b/Source/WebKit/ios/DefaultDelegates/WebDefaultFormDelegate.h
new file mode 100644 (file)
index 0000000..c7d2ed8
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WebFormDelegate.h>
+
+@interface WebDefaultFormDelegate : NSObject <WebFormDelegate> {
+}
++ (WebDefaultFormDelegate *)sharedFormDelegate;
+@end
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultFormDelegate.m b/Source/WebKit/ios/DefaultDelegates/WebDefaultFormDelegate.m
new file mode 100644 (file)
index 0000000..975b122
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebDefaultFormDelegate.h"
+
+@implementation WebDefaultFormDelegate
+
++ (WebDefaultFormDelegate *)sharedFormDelegate
+{
+    static WebDefaultFormDelegate * WebSharedDefaultFormDelegate = nil;
+    
+    if (!WebSharedDefaultFormDelegate) WebSharedDefaultFormDelegate = [[WebDefaultFormDelegate alloc] init];
+    return WebSharedDefaultFormDelegate;
+}
+
+- (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
+{
+}
+
+- (void)textFieldDidEndEditing:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
+{
+}
+
+- (void)textDidChangeInTextField:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
+{
+}
+
+- (void)textDidChangeInTextArea:(DOMHTMLTextAreaElement *)element inFrame:(WebFrame *)frame
+{
+}
+
+- (void)didFocusTextField:(DOMHTMLInputElement *)element inFrame:(WebFrame *)frame
+{
+}
+
+- (BOOL)textField:(DOMHTMLInputElement *)element doCommandBySelector:(SEL)commandSelector inFrame:(WebFrame *)frame
+{
+    return YES;
+}
+
+#if !PLATFORM(IOS)
+- (BOOL)textField:(DOMHTMLInputElement *)element shouldHandleEvent:(NSEvent *)event inFrame:(WebFrame *)frame
+{
+    return YES;
+}
+#endif
+
+- (void)frame:(WebFrame *)frame sourceFrame:(WebFrame *)sourceFrame willSubmitForm:(DOMElement *)form withValues:(NSDictionary *)values submissionListener:(id <WebFormSubmissionListener>)listener
+{
+    [listener continue];
+}
+
+- (void)willSendSubmitEventToForm:(DOMHTMLFormElement *)element inFrame:(WebFrame *)sourceFrame withValues:(NSDictionary *)values
+{
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultFrameLoadDelegate.h b/Source/WebKit/ios/DefaultDelegates/WebDefaultFrameLoadDelegate.h
new file mode 100644 (file)
index 0000000..016e188
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+@interface WebDefaultFrameLoadDelegate : NSObject {
+}
++ (WebDefaultFrameLoadDelegate *)sharedFrameLoadDelegate;
+@end
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultFrameLoadDelegate.m b/Source/WebKit/ios/DefaultDelegates/WebDefaultFrameLoadDelegate.m
new file mode 100644 (file)
index 0000000..51dc090
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebDefaultFrameLoadDelegate.h"
+
+#import <WebKit/WebFrameLoadDelegatePrivate.h>
+#import "WebViewPrivate.h"
+
+@implementation WebDefaultFrameLoadDelegate
+
++ (WebDefaultFrameLoadDelegate *)sharedFrameLoadDelegate
+{
+    static WebDefaultFrameLoadDelegate *sharedDelegate = nil;
+    if (!sharedDelegate)
+        sharedDelegate = [[WebDefaultFrameLoadDelegate alloc] init];
+    return sharedDelegate;
+}
+
+- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didCancelClientRedirectForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject
+{
+}
+
+- (void)webView:(WebView *)webView didCreateJavaScriptContext:(JSContext *)context forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webViewDidDisplayInsecureContent:(WebView *)webView
+{
+}
+
+- (void)webView:(WebView *)webView didRunInsecureContent:(WebSecurityOrigin *)origin
+{
+}
+
+- (void)webView:(WebView *)webView didDetectXSS:(NSURL *)insecureURL
+{
+}
+
+- (void)webView:(WebView *)webView didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world
+{
+}
+
+- (void)webView:(WebView *)webView didPushStateWithinPageForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView didReplaceStateWithinPageForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView didPopStateWithinPageForFrame:(WebFrame *)frame
+{
+}
+
+#pragma mark -
+#pragma mark SPI defined in a category in WebViewPrivate.h
+
+- (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didFinishDocumentLoadForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didHandleOnloadEventsForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didFirstVisuallyNonEmptyLayoutInFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView didClearInspectorWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView didRemoveFrameFromHierarchy:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didLayout:(WebLayoutMilestones)milestones
+{
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultResourceLoadDelegate.h b/Source/WebKit/ios/DefaultDelegates/WebDefaultResourceLoadDelegate.h
new file mode 100644 (file)
index 0000000..cbfa0b0
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+@interface WebDefaultResourceLoadDelegate : NSObject {
+}
++ (WebDefaultResourceLoadDelegate *)sharedResourceLoadDelegate;
+@end
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultResourceLoadDelegate.m b/Source/WebKit/ios/DefaultDelegates/WebDefaultResourceLoadDelegate.m
new file mode 100644 (file)
index 0000000..8b0a477
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebDefaultResourceLoadDelegate.h"
+
+#import <WebKit/WebResourceLoadDelegate.h>
+
+@implementation WebDefaultResourceLoadDelegate
+
++ (WebDefaultResourceLoadDelegate *)sharedResourceLoadDelegate
+{
+    static WebDefaultResourceLoadDelegate *sharedDelegate = nil;
+    if (!sharedDelegate)
+        sharedDelegate = [[WebDefaultResourceLoadDelegate alloc] init];
+    return sharedDelegate;
+}
+
+- (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)request fromDataSource:(WebDataSource *)dataSource
+{
+    return nil;
+}
+
+- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
+{
+    return request;
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (BOOL)webView:(WebView *)sender resource:(id)identifier canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace forDataSource:(WebDataSource *)dataSource
+{
+    return NO;
+}
+
+- (NSDictionary *)webView:(WebView *)sender connectionPropertiesForResource:(id)identifier dataSource:(WebDataSource *)dataSource
+{
+    return nil;
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didReceiveContentLength:(NSInteger)length fromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (void)webView:(WebView *)sender plugInFailedWithError:(NSError *)error dataSource:(WebDataSource *)dataSource
+{
+}
+
+- (void)webView:(WebView *)webView didLoadResourceFromMemoryCache:(NSURLRequest *)request response:(NSURLResponse *)response length:(NSInteger)length fromDataSource:(WebDataSource *)dataSource
+{
+}
+
+- (BOOL)webView:(WebView *)webView resource:(id)identifier shouldUseCredentialStorageForDataSource:(WebDataSource *)dataSource
+{
+    return YES;
+}
+
+#pragma mark -
+#pragma mark SPI defined in a category in WebViewPrivate.h
+
+- (NSCachedURLResponse *)webView:(WebView *)sender resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource
+{
+    return response;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.h b/Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.h
new file mode 100644 (file)
index 0000000..6236c74
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WebUIKitDelegate.h>
+
+@interface WebDefaultUIKitDelegate : NSObject {
+}
++ (WebDefaultUIKitDelegate *)sharedUIKitDelegate;
+@end
diff --git a/Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.m b/Source/WebKit/ios/DefaultDelegates/WebDefaultUIKitDelegate.m
new file mode 100644 (file)
index 0000000..cd4cabc
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebDefaultUIKitDelegate.h"
+
+#import "WebUIDelegate.h"
+
+static WebDefaultUIKitDelegate *sharedDelegate = nil;
+
+@implementation WebDefaultUIKitDelegate
+
++ (WebDefaultUIKitDelegate *)sharedUIKitDelegate
+{
+    if (!sharedDelegate) {
+        sharedDelegate = [[WebDefaultUIKitDelegate alloc] init];
+    }
+    return sharedDelegate;
+}
+
+- (CGPoint)contentsPointForWebView:(WebView *)aWebView
+{
+    return CGPointZero;
+}
+
+- (CGRect)documentVisibleRectForWebView:(WebView *)aWebView
+{
+    return CGRectZero;
+}
+
+- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
+{
+
+}
+
+- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
+{
+    
+}
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+
+}
+
+- (void)webView:(WebView *)webView saveStateToHistoryItem:(WebHistoryItem *)item forFrame:(WebFrame *)frame
+{
+    
+}
+
+- (void)webView:(WebView *)webView restoreStateFromHistoryItem:(WebHistoryItem *)item forFrame:(WebFrame *)frame force:(BOOL)force
+{
+    
+}
+
+- (void)webView:(WebView *)aWebView didReceiveViewportArguments:(NSDictionary *)arguments
+{
+
+}
+
+- (void)webView:(WebView *)aWebView needsScrollNotifications:(NSNumber *)aNumber forFrame:(WebFrame *)aFrame
+{
+    
+}
+
+- (void)webView:(WebView *)aWebView didObserveDeferredContentChange:(WKContentChange)aChange forFrame:(WebFrame *)frame
+{
+    
+}
+
+- (void)webViewDidPreventDefaultForEvent:(WebView *)webView
+{
+}
+
+- (BOOL)webView:(WebView *)webView shouldScrollToPoint:(CGPoint)point forFrame:(WebFrame *)frame
+{
+    return YES;
+}
+
+- (void)webView:(WebView *)webView willCloseFrame:(WebFrame *)frame
+{
+    
+}
+
+- (void)webView:(WebView *)webView didFinishDocumentLoadForFrame:(WebFrame *)frame
+{
+    
+}
+
+- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView didFirstLayoutInFrame:(WebFrame *)frame
+{
+    
+}
+
+- (void)webView:(WebView *)webView didFirstVisuallyNonEmptyLayoutInFrame:(WebFrame *)frame
+{
+}
+
+- (void)webView:(WebView *)webView elementDidFocusNode:(DOMNode *)node
+{
+}
+
+- (void)webView:(WebView *)webView elementDidBlurNode:(DOMNode *)node
+{
+}
+
+- (void)webViewDidRestoreFromPageCache:(WebView *)webView
+{
+}
+
+- (void)webView:(WebView *)webView didReceiveDocTypeForFrame:(WebFrame *)frame
+{
+    
+}
+
+- (NSView *)webView:(WebView *)webView plugInViewWithArguments:(NSDictionary *)arguments fromPlugInPackage:(WebPluginPackage *)package
+{
+    return nil;
+}
+
+- (void)webView:(WebView *)webView willShowFullScreenForPlugInView:(id)plugInView
+{
+}
+
+- (void)webView:(WebView *)webView didHideFullScreenForPlugInView:(id)plugInView
+{
+}
+
+- (void)webView:(WebView *)aWebView didReceiveMessage:(NSDictionary *)aMessage
+{
+}
+
+// FIXME: to be removed when UIKit implements the new one below.
+- (void)addInputString:(NSString *)str fromVariantKey:(BOOL)isPopupVariant
+{
+}
+
+- (void)addInputString:(NSString *)str withFlags:(NSUInteger)flags
+{
+}
+
+- (void)deleteFromInput
+{
+}
+
+- (void)_webthread_webView:(WebView *)sender attachRootLayer:(id)layer
+{
+}
+
+- (void)webViewDidCommitCompositingLayerChanges:(WebView*)webView
+{
+}
+
+- (void)webView:(WebView*)webView didCreateOrUpdateScrollingLayer:(id)layer withContentsLayer:(id)contentsLayer scrollSize:(NSValue*)sizeValue forNode:(DOMNode *)node
+    allowHorizontalScrollbar:(BOOL)allowHorizontalScrollbar allowVerticalScrollbar:(BOOL)allowVerticalScrollbar
+{
+}
+
+- (void)webView:(WebView*)webView willRemoveScrollingLayer:(id)layer withContentsLayer:(id)contentsLayer forNode:(DOMNode *)node
+{
+}
+
+- (void)revealedSelectionByScrollingWebFrame:(WebFrame *)webFrame
+{
+}
+
+- (void)webViewDidLayout:(WebView *)webView
+{
+}
+
+- (void)webViewDidStartOverflowScroll:(WebView *)webView
+{
+}
+
+- (void)webViewDidEndOverflowScroll:(WebView *)webView
+{
+}
+
+- (void)webView:(WebView *)webView runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener allowMultipleFiles:(BOOL)allowMultipleFiles acceptMIMETypes:(NSArray *)mimeTypes
+{
+    [resultListener cancel];
+}
+
+- (NSArray *)checkSpellingOfString:(NSString *)stringToCheck
+{
+    return nil;
+}
+
+- (void)writeDataToPasteboard:(NSDictionary *)representations
+{
+}
+
+- (NSArray*)readDataFromPasteboard:(NSString*)type withIndex:(NSInteger)index
+{
+    return nil;
+}
+
+- (NSInteger)getPasteboardItemsCount
+{
+    return 0;
+}
+
+- (NSArray*)supportedPasteboardTypesForCurrentSelection 
+{ 
+    return nil; 
+} 
+
+- (BOOL)hasRichlyEditableSelection
+{
+    return NO;
+}
+
+- (BOOL)performsTwoStepPaste:(DOMDocumentFragment*)fragment
+{
+    return NO;
+}
+
+- (NSInteger)getPasteboardChangeCount
+{
+    return 0;
+}
+
+- (BOOL)isUnperturbedDictationResultMarker:(id)metadataForMarker
+{
+    return NO;
+}
+
+- (void)webView:(WebView *)webView willAddPlugInView:(id)plugInView
+{
+}
+
+- (void)webViewDidDrawTiles:(WebView *)webView
+{
+}
+
+- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message withSource:(NSString *)source
+{
+}
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp b/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp
new file mode 100644 (file)
index 0000000..d5be0ca
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#include "EmojiFallbackFontSelector.h"
+
+#include <WebCore/FontCache.h>
+#include <WebCore/SimpleFontData.h>
+#include <wtf/Assertions.h>
+#include <wtf/text/AtomicString.h>
+
+using namespace WebCore;
+
+PassRefPtr<FontData> EmojiFallbackFontSelector::getFallbackFontData(const FontDescription& fontDescription, size_t)
+{
+    DEFINE_STATIC_LOCAL(AtomicString, appleColorEmoji, ("Apple Color Emoji"));
+    RefPtr<FontData> fontData = fontCache()->getCachedFontData(fontDescription, appleColorEmoji);
+    if (!fontData) {
+        LOG_ERROR("Failed to get \"Apple Color Emoji\" from the font cache. Using the last resort fallback font instead.");
+        fontData = fontCache()->getLastResortFallbackFont(fontDescription);
+    }
+
+    return fontData.release();
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.h b/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.h
new file mode 100644 (file)
index 0000000..b85cc69
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EmojiFallbackFontSelector_h
+#define EmojiFallbackFontSelector_h
+
+#include <WebCore/FontSelector.h>
+#include <wtf/PassRefPtr.h>
+
+class EmojiFallbackFontSelector : public WebCore::FontSelector {
+public:
+    static PassRefPtr<EmojiFallbackFontSelector> create() { return adoptRef(new EmojiFallbackFontSelector()); }
+    virtual ~EmojiFallbackFontSelector() OVERRIDE { }
+    virtual PassRefPtr<WebCore::FontData> getFontData(const WebCore::FontDescription&, const AtomicString& familyName) OVERRIDE { ASSERT_NOT_REACHED(); return 0; }
+    virtual bool resolvesFamilyFor(const WebCore::FontDescription&) const OVERRIDE { ASSERT_NOT_REACHED(); return false; }
+    virtual size_t fallbackFontDataCount() OVERRIDE { return 1; };
+    virtual PassRefPtr<WebCore::FontData> getFallbackFontData(const WebCore::FontDescription&, size_t) OVERRIDE;
+
+    virtual void registerForInvalidationCallbacks(WebCore::FontSelectorClient*) OVERRIDE { }
+    virtual void unregisterForInvalidationCallbacks(WebCore::FontSelectorClient*) OVERRIDE { }
+
+    virtual unsigned version() const OVERRIDE { return 0; }
+    virtual unsigned uniqueId() const OVERRIDE { return 0; }
+
+private:
+    EmojiFallbackFontSelector() { }
+};
+
+#endif // EmojiFallbackFontSelector_h
diff --git a/Source/WebKit/ios/Misc/MemoryMeasure.h b/Source/WebKit/ios/Misc/MemoryMeasure.h
new file mode 100644 (file)
index 0000000..dc6d509
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MemoryMeasure_h
+#define MemoryMeasure_h
+
+namespace WebKit {
+
+/*!
+ * A simple class that measures the difference in the resident memory of the
+ * process between its contruction and destruction. It uses the mach API -
+ * task_info - to figure this out.
+ */
+class MemoryMeasure {
+public:
+    MemoryMeasure()
+        : m_logString("")
+        , m_initialMemory(taskMemory())
+    {
+    }
+
+    MemoryMeasure(const char *log)
+        : m_logString(log)
+        , m_initialMemory(taskMemory())
+    {
+    }
+
+    ~MemoryMeasure();
+
+    static void enableLogging(bool enabled);
+    static bool isLoggingEnabled();
+
+private:
+    const char *m_logString;
+    long m_initialMemory;
+    static bool m_isLoggingEnabled;
+
+    /*!
+     * @return The resident memory (in bytes) consumed by the process. It uses
+     *         task_info() to get this information. If there is an error, it
+     *         returns -1.
+     */
+    long taskMemory();
+};
+
+}
+#endif
diff --git a/Source/WebKit/ios/Misc/MemoryMeasure.mm b/Source/WebKit/ios/Misc/MemoryMeasure.mm
new file mode 100644 (file)
index 0000000..49e28de
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#include "MemoryMeasure.h"
+
+#include <stdio.h>
+#include <mach/mach.h>
+
+static const int measureMemoryFailed = -1;
+
+namespace WebKit {
+
+bool MemoryMeasure::m_isLoggingEnabled;
+
+void MemoryMeasure::enableLogging(bool enabled)
+{
+    m_isLoggingEnabled = enabled;
+}
+
+bool MemoryMeasure::isLoggingEnabled()
+{
+    return m_isLoggingEnabled;
+}
+
+long MemoryMeasure::taskMemory()
+{
+    if (!MemoryMeasure::isLoggingEnabled())
+        return 0;
+
+    task_vm_info_data_t vmInfo;
+    mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
+    kern_return_t err = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count);
+    if (err != KERN_SUCCESS)
+        return measureMemoryFailed;
+
+    return (long) vmInfo.internal;
+}
+
+MemoryMeasure::~MemoryMeasure()
+{
+    if (!MemoryMeasure::isLoggingEnabled())
+        return;
+
+    long currentMemory = taskMemory();
+    if (currentMemory == measureMemoryFailed || m_initialMemory == measureMemoryFailed) {
+        NSLog(@"%s (Unable to get dirty memory information for process)\n", m_logString);
+        return;
+    }
+
+    long memoryDiff = currentMemory - m_initialMemory;
+    if (memoryDiff < 0)
+        NSLog(@"%s Dirty memory reduced by %ld bytes (from %ld to %ld)\n", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
+    else if (memoryDiff > 0)
+        NSLog(@"%s Dirty memory increased by %ld bytes (from %ld to %ld)\n", m_logString, memoryDiff, m_initialMemory, currentMemory);
+    else
+        NSLog(@"%s No change in dirty memory used by process (at %ld bytes)\n", m_logString, currentMemory);
+}
+
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h b/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h
new file mode 100644 (file)
index 0000000..2bc3da3
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/NSObject.h>
+#import <wtf/PassRefPtr.h>
+
+@class CLLocationManager;
+@class NSString;
+
+namespace WebCore {
+class GeolocationPosition;
+}
+
+// WebGeolocationCoreLocationDelegate abstracts the location services of CoreLocation.
+// All the results come back through the protocol GeolocationUpdateListener. Those callback can
+// be done synchronously and asynchronously in responses to calls made on WebGeolocationCoreLocationDelegate.
+
+// All calls to WebGeolocationCoreLocationDelegate must be on the main thread, all callbacks are done on the
+// main thread.
+
+@protocol WebGeolocationCoreLocationUpdateListener
+- (void)geolocationDelegateStarted;
+- (void)geolocationDelegateUnableToStart;
+
+- (void)positionChanged:(WebCore::GeolocationPosition*)position;
+- (void)errorOccurred:(NSString *)errorMessage;
+- (void)resetGeolocation;
+@end
+
+
+@interface WebGeolocationCoreLocationProvider : NSObject
+- (id)initWithListener:(id<WebGeolocationCoreLocationUpdateListener>)listener;
+
+- (void)start;
+- (void)stop;
+- (void)setEnableHighAccuracy:(BOOL)flag;
+@end
diff --git a/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm b/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm
new file mode 100644 (file)
index 0000000..48203db
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebGeolocationCoreLocationProvider.h"
+
+#import <CoreLocation/CLLocation.h>
+#import <CoreLocation/CLLocationManagerDelegate.h>
+#import <CoreLocation/CoreLocation.h>
+#import <CoreLocation/CoreLocationPriv.h>
+#import <WebCore/GeolocationPosition.h>
+#import <WebCore/SoftLinking.h>
+#import <WebKitLogging.h>
+#import <objc/objc-runtime.h>
+#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
+
+SOFT_LINK_FRAMEWORK(CoreLocation)
+
+SOFT_LINK_CLASS(CoreLocation, CLLocationManager)
+SOFT_LINK_CLASS(CoreLocation, CLLocation)
+
+SOFT_LINK_CONSTANT(CoreLocation, kCLLocationAccuracyBest, double)
+SOFT_LINK_CONSTANT(CoreLocation, kCLLocationAccuracyHundredMeters, double)
+
+#define kCLLocationAccuracyBest getkCLLocationAccuracyBest()
+#define kCLLocationAccuracyHundredMeters getkCLLocationAccuracyHundredMeters()
+
+using namespace WebCore;
+
+@interface WebGeolocationCoreLocationProvider () <CLLocationManagerDelegate>
+@end
+
+@implementation WebGeolocationCoreLocationProvider
+{
+    id<WebGeolocationCoreLocationUpdateListener> _positionListener;
+    RetainPtr<CLLocationManager> _locationManager;
+    BOOL _isWaitingForAuthorization;
+    CLAuthorizationStatus _lastAuthorizationStatus;
+}
+
+- (void)createLocationManager
+{
+    ASSERT(!_locationManager);
+
+#define CLLocationManager getCLLocationManagerClass()
+    _locationManager = adoptNS([[CLLocationManager alloc] init]);
+    _lastAuthorizationStatus = [CLLocationManager authorizationStatus];
+#undef CLLocationManager
+
+    [ _locationManager.get() setDelegate:self];
+}
+
+- (id)initWithListener:(id<WebGeolocationCoreLocationUpdateListener>)listener
+{
+    ASSERT_MAIN_THREAD();
+    self = [super init];
+    if (self) {
+        _positionListener = listener;
+        [self createLocationManager];
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    ASSERT_MAIN_THREAD();
+    _locationManager.get().delegate = nil;
+    [super dealloc];
+}
+
+- (BOOL)handleExternalAuthorizationStatusChange:(CLAuthorizationStatus)newStatus
+{
+    CLAuthorizationStatus previousStatus = _lastAuthorizationStatus;
+    _lastAuthorizationStatus = newStatus;
+    if (!_isWaitingForAuthorization && previousStatus != newStatus) {
+        [_locationManager.get() stopUpdatingLocation];
+        [_positionListener resetGeolocation];
+        return YES;
+    }
+    return NO;
+}
+
+- (void)start
+{
+    ASSERT_MAIN_THREAD();
+
+#define CLLocationManager getCLLocationManagerClass()
+    CLAuthorizationStatus authorizationStatus = [CLLocationManager authorizationStatus];
+    if ([self handleExternalAuthorizationStatusChange:authorizationStatus])
+        return;
+
+    if (![CLLocationManager locationServicesEnabled]) {
+        [_positionListener geolocationDelegateUnableToStart];
+        return;
+    }
+
+    switch (authorizationStatus) {
+    case kCLAuthorizationStatusNotDetermined:
+        _isWaitingForAuthorization = YES;
+        [_locationManager.get() startUpdatingLocation];
+        return;
+    case kCLAuthorizationStatusDenied:
+    case kCLAuthorizationStatusRestricted:
+        [_positionListener geolocationDelegateUnableToStart];
+        return;
+    case kCLAuthorizationStatusAuthorized:
+        [_locationManager.get() startUpdatingLocation];
+        [_positionListener geolocationDelegateStarted];
+        return;
+    }
+#undef CLLocationManager
+    ASSERT_NOT_REACHED();
+    [_positionListener geolocationDelegateUnableToStart];
+}
+
+- (void)stop
+{
+    ASSERT_MAIN_THREAD();
+    [_locationManager.get() stopUpdatingLocation];
+}
+
+- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
+{
+    if ([self handleExternalAuthorizationStatusChange:status])
+        return;
+
+    if (_isWaitingForAuthorization) {
+        switch (status) {
+        case kCLAuthorizationStatusNotDetermined:
+            // This can happen after resume if the user has still not answered the dialog. We just have to wait for the permission.
+            break;
+        case kCLAuthorizationStatusDenied:
+        case kCLAuthorizationStatusRestricted:
+            _isWaitingForAuthorization = NO;
+            [_positionListener geolocationDelegateUnableToStart];
+            break;
+        case kCLAuthorizationStatusAuthorized:
+            _isWaitingForAuthorization = NO;
+            [_positionListener geolocationDelegateStarted];
+            break;
+        }
+    }
+}
+
+- (void)sendLocation:(CLLocation *)newLocation
+{
+    // Normalize.
+    bool canProvideAltitude = true;
+    bool canProvideAltitudeAccuracy = true;
+    double altitude = newLocation.altitude;
+    double altitudeAccuracy = newLocation.verticalAccuracy;
+    if (altitudeAccuracy < 0.0) {
+        canProvideAltitude = false;
+        canProvideAltitudeAccuracy = false;
+    }
+
+    bool canProvideSpeed = true;
+    double speed = newLocation.speed;
+    if (speed < 0.0)
+        canProvideSpeed = false;
+
+    bool canProvideHeading = true;
+    double heading = newLocation.course;
+    if (heading < 0.0)
+        canProvideHeading = false;
+
+    double timestamp = [newLocation.timestamp timeIntervalSince1970];
+    RefPtr<GeolocationPosition> geolocationPosition = GeolocationPosition::create(timestamp, newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.horizontalAccuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed);
+    [_positionListener positionChanged:geolocationPosition.get()];
+}
+
+- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
+{
+    UNUSED_PARAM(manager);
+    for (CLLocation *location in locations)
+        [self sendLocation:location];
+}
+
+- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
+{
+    ASSERT(_positionListener);
+    ASSERT(error);
+    UNUSED_PARAM(manager);
+
+    if ([error code] == kCLErrorDenied) {
+        // Ignore the error here and let locationManager:didChangeAuthorizationStatus: handle the permission.
+        return;
+    }
+
+    NSString *errorMessage = [error localizedDescription];
+    [_positionListener errorOccurred:errorMessage];
+}
+
+- (void)setEnableHighAccuracy:(BOOL)flag
+{
+    ASSERT_MAIN_THREAD();
+    [_locationManager.get() setDesiredAccuracy:flag ? kCLLocationAccuracyBest : kCLLocationAccuracyHundredMeters];
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.h b/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.h
new file mode 100644 (file)
index 0000000..a6104e3
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/NSObject.h>
+#import <WebKit/WebViewPrivate.h>
+
+@interface WebGeolocationProviderIOS : NSObject<WebGeolocationProvider>
+
++ (WebGeolocationProviderIOS *)sharedGeolocationProvider;
+
+// suspend turns off location services completely and releases the CLLocationManager.
+- (void)suspend;
+- (void)resume;
+
+@end
diff --git a/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm b/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm
new file mode 100644 (file)
index 0000000..b0fe093
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+ * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebGeolocationProviderIOS.h"
+
+#import "WebGeolocationCoreLocationProvider.h"
+#import <WebGeolocationPosition.h>
+#import <WebCore/GeolocationPosition.h>
+#import <WebCore/WebCoreThread.h>
+#import <WebCore/WebCoreThreadRun.h>
+#import <wtf/HashSet.h>
+#import <wtf/HashMap.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
+
+#if PLATFORM(IOS)
+#import "WebDelegateImplementationCaching.h"
+#endif
+
+using namespace WebCore;
+
+@interface WebGeolocationPosition (Internal)
+- (id)initWithGeolocationPosition:(PassRefPtr<GeolocationPosition>)coreGeolocationPosition;
+@end
+
+// CoreLocation runs in the main thread. WebGeolocationProviderIOS lives on the WebThread.
+// _WebCoreLocationUpdateThreadingProxy forward updates from CoreLocation to WebGeolocationProviderIOS.
+@interface _WebCoreLocationUpdateThreadingProxy : NSObject<WebGeolocationCoreLocationUpdateListener>
+- (id)initWithProvider:(WebGeolocationProviderIOS*)provider;
+@end
+
+typedef HashMap<RetainPtr<WebView>, RetainPtr<id<WebGeolocationProviderInitializationListener> > > GeolocationInitializationCallbackMap;
+
+@implementation WebGeolocationProviderIOS {
+@private
+    RetainPtr<WebGeolocationCoreLocationProvider> _coreLocationProvider;
+    RetainPtr<_WebCoreLocationUpdateThreadingProxy> _coreLocationUpdateListenerProxy;
+
+    BOOL _enableHighAccuracy;
+    BOOL _isSuspended;
+    BOOL _shouldResetOnResume;
+
+    // WebViews waiting for CoreLocation to be ready. If the Application does not yet have the permission to use Geolocation
+    // we also have to wait for that to be granted.
+    GeolocationInitializationCallbackMap _webViewsWaitingForCoreLocationStart;
+
+    // WebViews that have required location services and are in "Warm Up" while waiting to be registered or denied for the SecurityOrigin.
+    // The warm up expire after some time to avoid keeping CoreLocation alive while waiting for the user response for the Security Origin.
+    HashSet<WebView*> _warmUpWebViews;
+
+    // List of WebView needing the initial position after registerWebView:. This is needed because WebKit does not
+    // handle sending the position synchronously in response to registerWebView:, so we queue sending lastPosition behind a timer.
+    HashSet<WebView*> _pendingInitialPositionWebView;
+
+    // List of WebViews registered to WebGeolocationProvider for Geolocation update.
+    HashSet<WebView*> _registeredWebViews;
+
+    // All the views that might need a reset if the permission change externally.
+    HashSet<WebView*> _trackedWebViews;
+
+    RetainPtr<NSTimer> _sendLastPositionAsynchronouslyTimer;
+    RetainPtr<WebGeolocationPosition> _lastPosition;
+}
+
+static inline void abortSendLastPosition(WebGeolocationProviderIOS* provider)
+{
+    provider->_pendingInitialPositionWebView.clear();
+    [provider->_sendLastPositionAsynchronouslyTimer.get() invalidate];
+    provider->_sendLastPositionAsynchronouslyTimer.clear();
+}
+
+- (void)dealloc
+{
+    abortSendLastPosition(self);
+    [super dealloc];
+}
+
+#pragma mark - Public API of WebGeolocationProviderIOS.
++ (WebGeolocationProviderIOS *)sharedGeolocationProvider
+{
+    static dispatch_once_t once;
+    static WebGeolocationProviderIOS *sharedGeolocationProvider;
+    dispatch_once(&once, ^{
+        sharedGeolocationProvider = [[WebGeolocationProviderIOS alloc] init];
+    });
+    return sharedGeolocationProvider;
+}
+
+- (void)suspend
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+    ASSERT(pthread_main_np());
+
+    ASSERT(!_isSuspended);
+    _isSuspended = YES;
+
+    // A new position is acquired and sent to all registered views on resume.
+    _lastPosition.clear();
+    abortSendLastPosition(self);
+    [_coreLocationProvider.get() stop];
+}
+
+- (void)resume
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+    ASSERT(pthread_main_np());
+
+    ASSERT(_isSuspended);
+    _isSuspended = NO;
+
+    if (_shouldResetOnResume) {
+        [self resetGeolocation];
+        _shouldResetOnResume = NO;
+        return;
+    }
+
+    if (_registeredWebViews.isEmpty() && _webViewsWaitingForCoreLocationStart.isEmpty() && _warmUpWebViews.isEmpty())
+        return;
+
+    if (!_coreLocationProvider) {
+        ASSERT(!_coreLocationUpdateListenerProxy);
+        _coreLocationUpdateListenerProxy = adoptNS([[_WebCoreLocationUpdateThreadingProxy alloc] initWithProvider:self]);
+        _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:_coreLocationUpdateListenerProxy.get()]);
+    }
+    [_coreLocationProvider.get() setEnableHighAccuracy:_enableHighAccuracy];
+    [_coreLocationProvider.get() start];
+}
+
+#pragma mark - Internal utility methods
+- (void)_startCoreLocationDelegate
+{
+    ASSERT(!(_registeredWebViews.isEmpty() && _webViewsWaitingForCoreLocationStart.isEmpty()));
+
+    if (_isSuspended)
+        return;
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (!_coreLocationProvider.get()) {
+            ASSERT(!_coreLocationUpdateListenerProxy);
+            _coreLocationUpdateListenerProxy = adoptNS([[_WebCoreLocationUpdateThreadingProxy alloc] initWithProvider:self]);
+            _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:_coreLocationUpdateListenerProxy.get()]);
+        }
+        [_coreLocationProvider.get() start];
+    });
+}
+
+- (void)_stopCoreLocationDelegateIfNeeded
+{
+    if (_registeredWebViews.isEmpty() && _webViewsWaitingForCoreLocationStart.isEmpty() && _warmUpWebViews.isEmpty()) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [_coreLocationProvider.get() stop];
+        });
+        _enableHighAccuracy = NO;
+        _lastPosition.clear();
+    }
+}
+
+- (void)_handlePendingInitialPosition:(NSTimer*)timer
+{
+    ASSERT_UNUSED(timer, timer == _sendLastPositionAsynchronouslyTimer);
+
+    if (_lastPosition) {
+        Vector<WebView*> webViewsCopy;
+        copyToVector(_pendingInitialPositionWebView, webViewsCopy);
+        for (size_t i = 0; i < webViewsCopy.size(); ++i)
+            [webViewsCopy[i] _geolocationDidChangePosition:_lastPosition.get()];
+    }
+    abortSendLastPosition(self);
+}
+
+#pragma mark - Implementation of WebGeolocationProvider
+
+- (void)registerWebView:(WebView *)webView
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+
+    if (_registeredWebViews.contains(webView))
+        return;
+
+    _registeredWebViews.add(webView);
+    _warmUpWebViews.remove(webView);
+#if PLATFORM(IOS)
+    if (!CallUIDelegateReturningBoolean(YES, webView, @selector(webViewCanCheckGeolocationAuthorizationStatus:)))
+        return;
+#endif
+
+    [self _startCoreLocationDelegate];
+
+    // We send the lastPosition asynchronously because WebKit does not handle updating the position synchronously.
+    // On WebKit2, we could skip that and send the position directly from the UIProcess.
+    _pendingInitialPositionWebView.add(webView);
+    if (!_sendLastPositionAsynchronouslyTimer)
+        _sendLastPositionAsynchronouslyTimer = [NSTimer scheduledTimerWithTimeInterval:0
+                                                                                target:self
+                                                                              selector:@selector(_handlePendingInitialPosition:)
+                                                                              userInfo:nil
+                                                                               repeats:NO];
+}
+
+- (void)unregisterWebView:(WebView *)webView
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+
+    if (!_registeredWebViews.contains(webView))
+        return;
+
+    _registeredWebViews.remove(webView);
+    _pendingInitialPositionWebView.remove(webView);
+    [self _stopCoreLocationDelegateIfNeeded];
+}
+
+- (WebGeolocationPosition *)lastPosition
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+    return _lastPosition.get();
+}
+
+- (void)setEnableHighAccuracy:(BOOL)enableHighAccuracy
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+    _enableHighAccuracy = _enableHighAccuracy || enableHighAccuracy;
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [_coreLocationProvider.get() setEnableHighAccuracy:_enableHighAccuracy];
+    });
+}
+
+- (void)initializeGeolocationForWebView:(WebView *)webView listener:(id<WebGeolocationProviderInitializationListener>)listener
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+
+#if PLATFORM(IOS)
+    if (!CallUIDelegateReturningBoolean(YES, webView, @selector(webViewCanCheckGeolocationAuthorizationStatus:)))
+        return;
+#endif
+    _webViewsWaitingForCoreLocationStart.add(webView, listener);
+    _trackedWebViews.add(webView);
+
+    [self _startCoreLocationDelegate];
+}
+
+- (void)cancelWarmUpForWebView:(WebView *)webView
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+
+    _warmUpWebViews.remove(webView);
+    [self _stopCoreLocationDelegateIfNeeded];
+}
+
+- (void)stopTrackingWebView:(WebView*)webView
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+    _trackedWebViews.remove(webView);
+}
+
+#pragma mark - Mirror to WebGeolocationCoreLocationUpdateListener called by the proxy.
+- (void)geolocationDelegateStarted
+{
+    ASSERT(WebThreadIsCurrent());
+
+    // This could be called recursively. We must clean _webViewsWaitingForCoreLocationStart before invoking the callbacks.
+    Vector<RetainPtr<WebView> > webViews;
+    copyKeysToVector(_webViewsWaitingForCoreLocationStart, webViews);
+
+    Vector<RetainPtr<id<WebGeolocationProviderInitializationListener> > > initializationListeners;
+    copyValuesToVector(_webViewsWaitingForCoreLocationStart, initializationListeners);
+
+    _webViewsWaitingForCoreLocationStart.clear();
+
+    // Start warmup period for each view in intialization.
+    const int64_t warmUpTimeoutInterval = 20 * NSEC_PER_SEC;
+    dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, warmUpTimeoutInterval);
+    for (size_t i = 0; i < webViews.size(); ++i) {
+        WebView *webView = webViews[i].get();
+
+        _warmUpWebViews.add(webView);
+
+        dispatch_after(when, dispatch_get_main_queue(), ^{
+            _warmUpWebViews.remove(webView);
+            [self _stopCoreLocationDelegateIfNeeded];
+        });
+    }
+
+    // Inform the listeners the initialization succeeded.
+    for (size_t i = 0; i < webViews.size(); ++i) {
+        RetainPtr<WebView>& webView = webViews[i];
+        RetainPtr<id<WebGeolocationProviderInitializationListener> >& listener = initializationListeners[i];
+        [listener.get() initializationAllowedWebView:webView.get() provider:self];
+    }
+}
+
+- (void)geolocationDelegateUnableToStart
+{
+    ASSERT(WebThreadIsCurrent());
+
+    // This could be called recursively. We must clean _webViewsWaitingForCoreLocationStart before invoking the callbacks.
+    Vector<RetainPtr<WebView> > webViews;
+    copyKeysToVector(_webViewsWaitingForCoreLocationStart, webViews);
+
+    Vector<RetainPtr<id<WebGeolocationProviderInitializationListener> > > initializationListeners;
+    copyValuesToVector(_webViewsWaitingForCoreLocationStart, initializationListeners);
+
+    _webViewsWaitingForCoreLocationStart.clear();
+
+    // Inform the listeners of the failure.
+    for (size_t i = 0; i < webViews.size(); ++i) {
+        RetainPtr<WebView>& webView = webViews[i];
+        RetainPtr<id<WebGeolocationProviderInitializationListener> >& listener = initializationListeners[i];
+        [listener.get() initializationDeniedWebView:webView.get() provider:self];
+    }
+}
+
+- (void)positionChanged:(WebGeolocationPosition*)position
+{
+    ASSERT(WebThreadIsCurrent());
+
+    abortSendLastPosition(self);
+
+    _lastPosition = position;
+    Vector<WebView*> webViewsCopy;
+    copyToVector(_registeredWebViews, webViewsCopy);
+    for (size_t i = 0; i < webViewsCopy.size(); ++i)
+        [webViewsCopy.at(i) _geolocationDidChangePosition:_lastPosition.get()];
+}
+
+- (void)errorOccurred:(NSString *)errorMessage
+{
+    ASSERT(WebThreadIsCurrent());
+
+    _lastPosition.clear();
+
+    Vector<WebView*> webViewsCopy;
+    copyToVector(_registeredWebViews, webViewsCopy);
+    for (size_t i = 0; i < webViewsCopy.size(); ++i)
+        [webViewsCopy.at(i) _geolocationDidFailWithMessage:errorMessage];
+}
+
+- (void)resetGeolocation
+{
+    ASSERT(WebThreadIsCurrent());
+
+    if (_isSuspended) {
+        _shouldResetOnResume = YES;
+        return;
+    }
+    // 1) Stop all ongoing Geolocation initialization and tracking.
+    _webViewsWaitingForCoreLocationStart.clear();
+    _warmUpWebViews.clear();
+    _registeredWebViews.clear();
+    abortSendLastPosition(self);
+    [self _stopCoreLocationDelegateIfNeeded];
+
+    // 2) Reset the views, each frame will register back if needed.
+    Vector<WebView*> webViewsCopy;
+    copyToVector(_trackedWebViews, webViewsCopy);
+    for (size_t i = 0; i < webViewsCopy.size(); ++i)
+        [webViewsCopy.at(i) _resetAllGeolocationPermission];
+}
+@end
+
+#pragma mark - _WebCoreLocationUpdateThreadingProxy implementation.
+@implementation _WebCoreLocationUpdateThreadingProxy {
+    WebGeolocationProviderIOS* _provider;
+}
+
+- (id)initWithProvider:(WebGeolocationProviderIOS*)provider
+{
+    self = [super init];
+    if (self)
+        _provider = provider;
+    return self;
+}
+
+- (void)geolocationDelegateStarted
+{
+    WebThreadRun(^{ [_provider geolocationDelegateStarted]; });
+}
+
+- (void)geolocationDelegateUnableToStart
+{
+    WebThreadRun(^{ [_provider geolocationDelegateUnableToStart]; });
+}
+
+- (void)positionChanged:(WebCore::GeolocationPosition*)position
+{
+    RetainPtr<WebGeolocationPosition> webPosition = adoptNS([[WebGeolocationPosition alloc] initWithGeolocationPosition:position]);
+    WebThreadRun(^{ [_provider positionChanged:webPosition.get()]; });
+}
+
+- (void)errorOccurred:(NSString *)errorMessage
+{
+    WebThreadRun(^{ [_provider errorOccurred:errorMessage]; });
+}
+
+- (void)resetGeolocation
+{
+    WebThreadRun(^{ [_provider resetGeolocation]; });
+}
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/WebNSStringDrawing.h b/Source/WebKit/ios/Misc/WebNSStringDrawing.h
new file mode 100644 (file)
index 0000000..0363550
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebNSStringDrawing_h
+#define WebNSStringDrawing_h
+
+#if PLATFORM(IOS)
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <Foundation/Foundation.h>
+#import <GraphicsServices/GraphicsServices.h>
+
+typedef enum {
+    // The order of the enum items is important, and it is used for >= comparisions
+    WebEllipsisStyleNone = 0, // Old style, no truncation. Doesn't respect the "width" passed to it. Left in for compatability.
+    WebEllipsisStyleHead = 1,
+    WebEllipsisStyleTail = 2,
+    WebEllipsisStyleCenter = 3,
+    WebEllipsisStyleClip = 4, // Doesn't really clip, but instad truncates at the last character.
+    WebEllipsisStyleWordWrap = 5, // Truncates based on the width/height passed to it.
+    WebEllipsisStyleCharacterWrap = 6, // For "drawAtPoint", it is just like WebEllipsisStyleClip, since it doesn't really clip, but truncates at the last character
+} WebEllipsisStyle;
+
+typedef enum {
+    WebTextAlignmentLeft = 0,
+    WebTextAlignmentCenter = 1,
+    WebTextAlignmentRight = 2,
+} WebTextAlignment;
+
+@protocol WebTextRenderingAttributes
+
+@property(nonatomic, readonly)          GSFontRef font; // font the text should be rendered with (defaults to nil)
+@property(nonatomic, readonly)          CGFloat lineSpacing; // set to specify the line spacing (defaults to 0.0 which indicates the default line spacing)
+
+@property(nonatomic, readonly)          WebEllipsisStyle ellipsisStyle; // text will be wrapped and truncated according to the line break mode (defaults to UILineBreakModeWordWrap)
+@property(nonatomic, readonly)          CGFloat letterSpacing; // number of extra pixels to be added or subtracted between each pair of characters  (defalts to 0)
+@property(nonatomic, readonly)          WebTextAlignment alignment; // specifies the horizontal alignment that should be used when rendering the text (defaults to UITextAlignmentLeft)
+@property(nonatomic, readonly)          BOOL includeEmoji; // if yes, the text can include Emoji characters.
+@property(nonatomic, readwrite)         CGRect truncationRect; // the truncation rect argument, if non-nil, will be used instead of an ellipsis character for truncation sizing. if no truncation occurs, the truncationRect will be changed to CGRectNull. If truncation occurs, the rect will be updated with its placement.
+
+@property(nonatomic, readonly)          NSString **renderString; // An out-parameter for the actual rendered string. Defaults to nil.
+@property(nonatomic, readonly)          BOOL drawUnderline; // if yes, the text will be painted with underline.
+
+@end
+
+@interface NSString (WebStringDrawing)
+
++ (void)_web_setWordRoundingEnabled:(BOOL)flag;
++ (BOOL)_web_wordRoundingEnabled;
+
++ (void)_web_setWordRoundingAllowed:(BOOL)flag;
++ (BOOL)_web_wordRoundingAllowed;
+
++ (void)_web_setAscentRoundingEnabled:(BOOL)flag;
++ (BOOL)_web_ascentRoundingEnabled;
+
+- (CGSize)_web_drawAtPoint:(CGPoint)point withFont:(GSFontRef)font;
+
+- (CGSize)_web_sizeWithFont:(GSFontRef)font;
+
+// Size after applying ellipsis style and clipping to width.
+- (CGSize)_web_sizeWithFont:(GSFontRef)font forWidth:(float)width ellipsis:(WebEllipsisStyle)ellipsisStyle;
+- (CGSize)_web_sizeWithFont:(GSFontRef)font forWidth:(float)width ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing;
+- (CGSize)_web_sizeWithFont:(GSFontRef)font forWidth:(float)width ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing resultRange:(NSRange *)resultRangeOut;
+
+// Draw text to fit width. Clip or apply ellipsis according to style.
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle;
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing;
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing includeEmoji:(BOOL)includeEmoji;
+
+// Wrap and clip to rect.
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment;
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment lineSpacing:(int)lineSpacing;
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment lineSpacing:(int)lineSpacing includeEmoji:(BOOL)includeEmoj truncationRect:(CGRect *)truncationRect;
+- (CGSize)_web_sizeInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle;
+- (CGSize)_web_sizeInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle lineSpacing:(int)lineSpacing;
+
+// Clip or apply ellipsis according to style. Return the string which results.
+- (NSString *)_web_stringForWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing includeEmoji:(BOOL)includeEmoji;
+
+// These methods should eventually replace all string drawing/sizing methods above
+
+// Sizing/drawing a single line of text
+- (CGSize)_web_sizeForWidth:(CGFloat)width withAttributes:(id <WebTextRenderingAttributes>)attributes;
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(CGFloat)width withAttributes:(id <WebTextRenderingAttributes>)attributes;
+
+// Sizing/drawing multiline text
+- (CGSize)_web_sizeInRect:(CGRect)rect withAttributes:(id <WebTextRenderingAttributes>)attributes;
+- (CGSize)_web_drawInRect:(CGRect)rect withAttributes:(id <WebTextRenderingAttributes>)attributes;
+
+@end
+
+#endif // PLATFORM(IOS)
+
+#endif // WebNSStringDrawing_h
diff --git a/Source/WebKit/ios/Misc/WebNSStringDrawing.mm b/Source/WebKit/ios/Misc/WebNSStringDrawing.mm
new file mode 100644 (file)
index 0000000..a2783fe
--- /dev/null
@@ -0,0 +1,935 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebNSStringDrawing.h"
+
+#if PLATFORM(IOS)
+
+#import "EmojiFallbackFontSelector.h"
+#import <CoreFoundation/CFPriv.h>
+#import <CoreGraphics/CGColor.h>
+#import <float.h>
+#import <sys/types.h>
+#import <unicode/ubrk.h>
+#import <unicode/uchar.h>
+#import <unicode/utf.h>
+#import <WebCore/BidiResolver.h>
+#import <WebCore/break_lines.h>
+#import <WebCore/Font.h>
+#import <WebCore/FontCache.h>
+#import <WebCore/GraphicsContext.h>
+#import <WebCore/StringTruncator.h>
+#import <WebCore/TextBreakIterator.h>
+#import <WebCore/TextRun.h>
+#import <WebCore/WKGraphics.h>
+#import <WebCore/WebCoreSystemInterface.h>
+#import <wtf/text/WTFString.h>
+#import <wtf/unicode/CharacterNames.h>
+
+using namespace WebCore;
+using namespace std;
+
+static BOOL ascentRoundingEnabled = NO;
+
+static BOOL wordRoundingEnabled;
+
+static BOOL wordRoundingAllowed = YES;
+
+static inline bool linkedOnOrAfterIPhoneOS3()
+{
+    static bool s_linkedOnOrAfterIOS3 = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_3_0);
+    return s_linkedOnOrAfterIOS3;
+}
+
+static inline bool shouldDisableWordRounding()
+{
+    // Note that even when rounding hacks are not disabled at this level, they will only be applied
+    // if +[WebView _setAllowsRoundingHacks:YES] is called. Thus, in iOS 5 and later, rounding hacks are never
+    // applied (see WebKitInitialize() in WebUIKitSupport.mm).
+
+    if (!wordRoundingAllowed)
+        return true;
+
+    if (linkedOnOrAfterIPhoneOS3())
+        return false;
+
+    return !wordRoundingEnabled;
+}
+
+static inline int boundedTextBreakFollowing(TextBreakIterator* it, int offset, int length)
+{
+    int result = textBreakFollowing(it, offset);
+    return result == TextBreakDone ? length : result;
+}
+
+static inline Font rendererForFont( GSFontRef font )
+{
+    GSFontTraitMask traits = GSFontGetSynthesizedTraits(font);
+    float size = GSFontGetSize(font);
+
+    static EmojiFallbackFontSelector* fontSelector = EmojiFallbackFontSelector::create().leakRef();
+
+    FontPlatformData platformData(font, size, true, traits & GSBoldFontMask, traits & GSItalicFontMask);
+    Font renderer(platformData, PassRefPtr<FontSelector>(fontSelector));
+    
+    return renderer;
+}
+
+static String applyEllipsisStyle(const String& srcString, WebEllipsisStyle style, float width, const Font& font, StringTruncator::EnableRoundingHacksOrNot enableRoundingHacks, float* resultWidth, bool insertEllipsis = true, float customTruncationElementWidth = 0, bool alwaysTruncate = false)
+{
+    // If it is WebEllipsisStyleClip, WebEllipsisStyleWordWrap, or WebEllipsisStyleCharacterWrap,
+    // and we don't have any confine on the width, then it is the same as WebEllipsisStyleNone.
+    if (style >= WebEllipsisStyleClip && width >= FLT_MAX)
+        style = WebEllipsisStyleNone;
+
+    float truncatedWidth = width;
+    String truncatedString(srcString);
+
+    switch (style) {
+    case WebEllipsisStyleNone:
+        truncatedWidth = StringTruncator::width(srcString, font, enableRoundingHacks);
+        break;
+    case WebEllipsisStyleHead:
+        truncatedString = StringTruncator::leftTruncate(srcString, width, font, enableRoundingHacks, truncatedWidth, insertEllipsis, customTruncationElementWidth);
+        break;
+    case WebEllipsisStyleTail:
+        truncatedString = StringTruncator::rightTruncate(srcString, width, font, enableRoundingHacks, truncatedWidth, insertEllipsis, customTruncationElementWidth);
+        break;
+    case WebEllipsisStyleCenter:
+        truncatedString = StringTruncator::centerTruncate(srcString, width, font, enableRoundingHacks, truncatedWidth, insertEllipsis, customTruncationElementWidth);
+        break;
+
+    // Character wrap is the same as clipping for a single line, since we can't clip mid-character.
+    case WebEllipsisStyleCharacterWrap:
+    case WebEllipsisStyleClip:
+        // If we were given a specific width to draw in, we shouldn't draw larger than that.
+        truncatedString = StringTruncator::rightClipToCharacter(srcString, width, font, enableRoundingHacks, truncatedWidth, insertEllipsis, customTruncationElementWidth);
+        break;
+    case WebEllipsisStyleWordWrap:
+        // If we were given a specific width to draw in, we shouldn't draw larger than that.
+        truncatedString = StringTruncator::rightClipToWord(srcString, width, font, enableRoundingHacks, truncatedWidth, insertEllipsis, customTruncationElementWidth, alwaysTruncate);
+        break;
+    }
+
+    if (resultWidth)
+        *resultWidth = truncatedWidth;
+    
+    return truncatedString;
+}
+
+static float drawAtPoint(const UChar* str, const int runLength, const FloatPoint& point, const Font& renderer, GraphicsContext* context, bool drawUnderLine = false, BidiStatus* status = 0, int length = -1)
+{
+    TextRun textRun(str, runLength);
+    if (shouldDisableWordRounding())
+        textRun.disableRoundingHacks();
+
+    float width = 0;
+    if (!status)
+        width = renderer.drawText(context, textRun, point);
+    else
+        width = context->drawBidiText(renderer, textRun, point, WebCore::Font::DoNotPaintIfFontNotReady, status, length);
+
+    if (drawUnderLine)
+        context->drawLineForText(point, width, false);
+    return width;
+}
+
+static bool needsBidiLayout(const UChar *characters, unsigned length, WTF::Unicode::Direction& baseDirection, bool oneParagraph = false)
+{
+    bool foundFirstStrong = false;
+    bool result = false;
+    baseDirection = WTF::Unicode::LeftToRight;
+    for (unsigned i = 0; i < length;) {
+        UChar32 c;
+        U16_NEXT(characters, i, length, c);
+        switch (WTF::Unicode::direction(c)) {
+            case WTF::Unicode::RightToLeft:
+            case WTF::Unicode::RightToLeftArabic:
+                if (!foundFirstStrong) {
+                    foundFirstStrong = true;
+                    baseDirection = WTF::Unicode::RightToLeft;
+                }
+                // Fall through to rest of strongly directional cases
+            case WTF::Unicode::LeftToRightEmbedding:
+            case WTF::Unicode::LeftToRightOverride:
+            case WTF::Unicode::RightToLeftEmbedding:
+            case WTF::Unicode::RightToLeftOverride:
+            case WTF::Unicode::PopDirectionalFormat:
+                result = true;
+                if (foundFirstStrong)
+                    return result;
+                break;
+            case WTF::Unicode::LeftToRight:
+                foundFirstStrong = true;
+                if (result)
+                    return result;
+                break;
+            case WTF::Unicode::BlockSeparator:
+                if (oneParagraph)
+                    return result;
+                break;
+            default:
+                break;
+        }
+    }
+    return result;
+}
+
+@implementation NSString (WebStringDrawing)
+
++ (void)_web_setWordRoundingEnabled:(BOOL)flag
+{
+    if (!linkedOnOrAfterIPhoneOS3())
+        wordRoundingEnabled = flag;
+}
+
++ (BOOL)_web_wordRoundingEnabled
+{
+    return wordRoundingEnabled;
+}
+
++ (void)_web_setWordRoundingAllowed:(BOOL)flag
+{
+    wordRoundingAllowed = flag;
+}
+
++ (BOOL)_web_wordRoundingAllowed
+{
+    return wordRoundingAllowed;
+}
+
++ (void)_web_setAscentRoundingEnabled:(BOOL)flag
+{
+    ascentRoundingEnabled = flag;
+}
+
++ (BOOL)_web_ascentRoundingEnabled
+{
+    return ascentRoundingEnabled;
+}
+
+#pragma mark Internal primitives used for string drawing/sizing
+
+// These methods should not be called from outside of this file
+
+- (CGSize)__web_drawAtPoint:(CGPoint)point
+                   forWidth:(CGFloat)width
+                   withFont:(GSFontRef)font
+                   ellipsis:(WebEllipsisStyle)ellipsisStyle
+              letterSpacing:(float)letterSpacing
+               includeEmoji:(BOOL)includeEmoji
+                measureOnly:(BOOL)measureOnly
+          renderedStringOut:(NSString **)renderedStringOut
+              drawUnderline:(BOOL)drawUnderline
+{
+    if (width < 0) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: width must be greater than zero.\n", __FUNCTION__);
+#endif
+        return CGSizeZero;
+    }
+    
+    if (font == NULL) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: font must be non-null.\n", __FUNCTION__);
+#endif
+        return CGSizeZero;
+    }
+    
+    if ([self isEqualToString:@""]) {
+        return CGSizeZero;
+    }
+
+    FontCachePurgePreventer fontCachePurgePreventer;
+
+    Font renderer = rendererForFont(font);
+    if (letterSpacing != 0.0)
+        renderer.setLetterSpacing(letterSpacing);
+
+    String fullString(self);
+    WTF::Unicode::Direction base = WTF::Unicode::LeftToRight;
+    bool stringNeedsBidi = needsBidiLayout(fullString.characters(), fullString.length(), base);
+    float stringWidth;
+    String s = (width >= FLT_MAX && !measureOnly) ? fullString : applyEllipsisStyle(fullString, ellipsisStyle, width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &stringWidth);
+    
+    if (!measureOnly) {
+        CGContextRef cgContext= WKGetCurrentGraphicsContext();
+        GraphicsContext context(static_cast<PlatformGraphicsContext*>(cgContext), false);
+        context.setEmojiDrawingEnabled(includeEmoji);
+
+        if (stringNeedsBidi) {
+            BidiStatus status(base, base, base, BidiContext::create((base == WTF::Unicode::LeftToRight) ? 0 : 1, base, false));
+            // FIXME: For proper bidi rendering, we need to pass the whole string, rather than the truncated string.
+            // Otherwise, weak/neutral characters on either side of the ellipsis may pick up the wrong direction
+            // if there are strong characters ellided.
+            stringWidth = drawAtPoint(s.characters(), s.length(), point, renderer, &context, drawUnderline, &status);
+        } else {
+            stringWidth = drawAtPoint(s.characters(), s.length(), point, renderer, &context, drawUnderline);
+        }
+    }
+    
+    if (renderedStringOut)
+        *renderedStringOut = (NSString *)s;
+
+    return CGSizeMake(stringWidth, GSFontGetLineSpacing(font));
+}
+
+- (CGSize)__web_drawAtPoint:(CGPoint)point
+                   forWidth:(CGFloat)width
+                   withFont:(GSFontRef)font
+                   ellipsis:(WebEllipsisStyle)ellipsisStyle
+              letterSpacing:(float)letterSpacing
+               includeEmoji:(BOOL)includeEmoji
+                measureOnly:(BOOL)measureOnly
+          renderedStringOut:(NSString **)renderedStringOut
+{
+    return [self __web_drawAtPoint:point
+                          forWidth:width
+                          withFont:font
+                          ellipsis:ellipsisStyle
+                     letterSpacing:letterSpacing
+                      includeEmoji:includeEmoji
+                       measureOnly:measureOnly
+                 renderedStringOut:renderedStringOut
+                     drawUnderline:NO];
+}
+
+- (CGSize)__web_drawAtPoint:(CGPoint)point
+                   forWidth:(CGFloat)width
+                   withFont:(GSFontRef)font
+                   ellipsis:(WebEllipsisStyle)ellipsisStyle
+              letterSpacing:(float)letterSpacing
+               includeEmoji:(BOOL)includeEmoji
+                measureOnly:(BOOL)measureOnly
+{
+    return [self __web_drawAtPoint:point
+                          forWidth:width
+                          withFont:font
+                          ellipsis:ellipsisStyle
+                     letterSpacing:letterSpacing
+                      includeEmoji:includeEmoji
+                       measureOnly:measureOnly
+                 renderedStringOut:nil];
+}
+
+- (CGSize)__web_drawInRect:(CGRect)rect
+                  withFont:(GSFontRef)font
+                  ellipsis:(WebEllipsisStyle)ellipsisStyle
+                 alignment:(WebTextAlignment)alignment
+             letterSpacing:(CGFloat)letterSpacing
+               lineSpacing:(CGFloat)lineSpacing
+              includeEmoji:(BOOL)includeEmoji
+            truncationRect:(CGRect *)truncationRect
+               measureOnly:(BOOL)measureOnly
+         renderedStringOut:(NSString **)renderedStringOut
+             drawUnderline:(BOOL)drawUnderline
+{    
+    if (rect.size.width < 0) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: width must be greater than zero.\n", __FUNCTION__);
+#endif
+        return CGSizeZero;
+    }
+    
+    if (font == NULL) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: font must be non-null.\n", __FUNCTION__);
+#endif
+        return CGSizeZero;
+    }    
+
+    String renderedString = (renderedStringOut ? String("") : String());
+
+    FontCachePurgePreventer fontCachePurgePreventer;
+
+    Font renderer = rendererForFont(font);
+    renderer.setLetterSpacing(letterSpacing);
+    String drawString = String(self);
+    if (drawString.contains('\r')) {
+        drawString.replace("\r\n", "\n");
+        drawString.replace('\r', '\n');
+    }
+    int length = drawString.length();
+    
+    CGPoint textPoint;
+    CGPoint cursor = rect.origin;
+    BOOL hasCustomLinespacing = YES;
+    if (lineSpacing == 0.0) {
+        lineSpacing = GSFontGetLineSpacing(font);
+        hasCustomLinespacing = NO;
+    }
+    float ascent = GSFontGetAscent(font);
+    if (ascentRoundingEnabled) {
+        // This opt-in ascent rounding mode matches standard WebKit text rendering and is used by clients that want
+        // to match, like a placeholder label inside a textfield that needs to line up exactly with text in the 
+        // WebView that will eventually replace it.
+        ascent = ceilf(ascent);
+    } else {
+        // For all other drawing, we round to the nearest 1/128 to avoid inaccurate results in the computations below, 
+        // due to limited floating-point precision.  We round to the nearest 1/128 because a) it is a power of two, 
+        // and you can exactly multiply integers by a power of 2, and b) it is small enough to not effect rendering 
+        // at any resolution that we will conceivably use.  See <rdar://problem/8102100>.
+        ascent = ceilf(ascent * 128) / 128.0f;
+    }
+    float maxLineWidth = 0;
+    cursor.y += ascent;
+
+    const UniChar *buffer = drawString.characters();
+    const UniChar *startOfLine = buffer;
+
+    BOOL lastLine = NO;
+    BOOL finishedLastLine = NO;
+    WTF::Unicode::Direction base;
+    BOOL paragraphNeedsBidi = needsBidiLayout(buffer, length, base, true);
+    BidiStatus status;
+    if (paragraphNeedsBidi)
+        status = BidiStatus(base, base, base, BidiContext::create((base == WTF::Unicode::LeftToRight) ? 0 : 1, base, false));
+
+    int lengthRemaining = length;
+    
+    while (lengthRemaining > 0 && !finishedLastLine) {
+        if ((cursor.y - rect.origin.y) + lineSpacing > rect.size.height)
+            lastLine = YES;
+        
+        BOOL reachedEndOfLine = NO;
+        BOOL foundNewline = NO;
+
+        UniChar *pos = const_cast<UniChar*>(startOfLine);
+        float lineWidth = 0.0f; 
+        float trailingSpaceWidth = 0.0f; // Width of trailing space(s) on line, if any
+        int trailingSpaceCount = 0; // Count of trailing space(s) on line, if any
+        
+        BOOL lastLineEllipsed = lastLine && (ellipsisStyle >= WebEllipsisStyleHead && ellipsisStyle <= WebEllipsisStyleCenter);
+        BOOL lastLineClipped = lastLine && (ellipsisStyle >= WebEllipsisStyleClip);
+        int skippedWhitespace = 0;
+        
+        while (!(lastLineEllipsed || lastLineClipped) && lengthRemaining > 0 && !reachedEndOfLine) {
+            int breakPos = 0;
+            
+            if (ellipsisStyle != WebEllipsisStyleCharacterWrap) {
+                //FIXME: <rdar://problem/12457790> investigate perf impact after merging TOT r129662.
+                LazyLineBreakIterator breakIterator(String(pos, lengthRemaining));
+                breakPos = nextBreakablePosition(breakIterator, 0);
+            }
+
+            // FIXME: This code currently works because there are no characters with these break or whitespace
+            // properties outside plane 0. If that ever changes, surrogate pair handling will be needed everywhere
+            // below where the width or a break or space is assumed to be 1.
+            BOOL foundSpace = NO;
+
+            if (breakPos < lengthRemaining) {
+                ULineBreak breakProperty = (ULineBreak) u_getIntPropertyValue(pos[breakPos], UCHAR_LINE_BREAK);
+                switch (breakProperty) {
+                    case U_LB_SPACE:
+                    case U_LB_ZWSPACE:
+                        foundSpace = YES;
+                        break;
+                    case U_LB_LINE_FEED:
+                    case U_LB_NEXT_LINE:
+                    case U_LB_MANDATORY_BREAK:
+                    case U_LB_CARRIAGE_RETURN:
+                        foundNewline = YES;
+                        break;
+                    default:
+                        if (ellipsisStyle == WebEllipsisStyleCharacterWrap) {
+                            // We can break on characters. We should do something smarter, like split the length of the entire line 
+                            // Don't, however, break in the middle of a character.
+                            NonSharedCharacterBreakIterator it(pos, lengthRemaining);
+                            breakPos = boundedTextBreakFollowing(it, 0, lengthRemaining);
+                        }                        
+                        break;
+                }                
+            }
+
+            // NSLog(@"apparently the break is %x", pos[breakPos]);
+
+            // ICU reports the break to us as the position just before the character it gives us (between two characters).
+            // measure everything up to the break
+            TextRun textRun(pos, breakPos);
+            if (shouldDisableWordRounding())
+                textRun.disableRoundingHacks();
+            float wordWidth = renderer.width(textRun);
+
+            // NSLog(@"measuring at pos = %d len = %d, size = %f", pos - startOfLine, breakPos, wordWidth);
+            if (lineWidth + wordWidth <= rect.size.width) {               
+                // advance to the break character.
+                pos += breakPos;
+                lengthRemaining = length - (pos - buffer);
+                lineWidth += wordWidth;
+                
+                // Reset trailing spaces if there was a real word.
+                if (breakPos > 0) {
+                    trailingSpaceWidth = 0.0f;
+                    trailingSpaceCount = 0;
+                }
+
+                reachedEndOfLine = foundNewline;
+                // don't ask the renderer to draw the line break character itself - skip ahead.
+                if (foundNewline) {
+                    pos++;
+                    lengthRemaining--;
+                    skippedWhitespace++;
+                } else if (foundSpace) {
+                    if (lengthRemaining > 0) {
+                        // measure space break width
+                        TextRun textRun(pos, 1);
+                        if (shouldDisableWordRounding())
+                            textRun.disableRoundingHacks();
+
+                        float spaceWidth = renderer.width(textRun);
+
+                        if (lineWidth + spaceWidth < rect.size.width) {
+                            // Space fits on line, add it...
+                            lineWidth += spaceWidth;
+                            trailingSpaceWidth += spaceWidth;
+                            trailingSpaceCount++;
+                            pos++;
+                            lengthRemaining--;
+                        } else {
+                            // Space does not fit on this line - it is legal then to skip through all consecutive spaces
+                            reachedEndOfLine = YES;
+                            do { // Line breaking code reported we found a space, so always skip at least one.
+                                lengthRemaining--;
+                                pos++;
+                                skippedWhitespace++;
+                                if (pos[-1] == '\n') { // Stop the loop just after a newline character, as spaces after that should render
+                                    foundNewline = YES; // Record the fact that we found a new line
+                                    break;
+                                }
+                            } while (lengthRemaining > 0 && u_isWhitespace(pos[0])); // continue to skip end-of-line whitespace
+                        }
+                    }                    
+                } else if (wordWidth == 0 && breakPos == 0 && lengthRemaining > 0) {
+                    // Should not happen, but be safe and make sure we always either add width to the line or advance by a character.
+                    // If not, skip ahead.
+                    // FIXME: Should advance using character iterator and look for paragraph separator, but don't bother for now
+                    // since this is a "can't happen" path.
+                    pos++;
+                    lengthRemaining--;
+                }
+            } else {
+                reachedEndOfLine = YES;
+                foundNewline = NO;      // We are not consuming any paragraph break, so don't react to it yet.
+                if (lineWidth == 0 && lengthRemaining > 0) {
+                    // We have nothing on the line so far but reached the end of the line?
+                    // This must be a long word that doesn't fit inside the entire width
+                    // Fit it on a line one character at a time and break when no more characters fit
+                    // Force at least one character to avoid the edge case where a single glyph doesn't fit within width
+                    NonSharedCharacterBreakIterator it(pos, lengthRemaining);
+                    int offset = 0;
+                    int nextCharBreak = boundedTextBreakFollowing(it, offset, lengthRemaining);
+                    TextRun textRun(pos, nextCharBreak);
+                    if (shouldDisableWordRounding())
+                        textRun.disableRoundingHacks();
+                    lineWidth += renderer.width(textRun);
+                    float newLineWidth = lineWidth;
+                    do {
+                        lineWidth = newLineWidth;
+                        offset = nextCharBreak;
+                        if (lengthRemaining > offset) {
+                            nextCharBreak = boundedTextBreakFollowing(it, offset, lengthRemaining);
+                            TextRun textRun(pos + offset, nextCharBreak - offset);
+                            if (shouldDisableWordRounding())
+                                textRun.disableRoundingHacks();
+                            newLineWidth += renderer.width(textRun);
+                        }
+                    } while (newLineWidth <= rect.size.width && lengthRemaining > offset);
+                    // Update pos and lengthRemaining. Due to the semantics of boundedTextBreakFollowing, this will
+                    // never exceed the bounds.
+                    ASSERT(lengthRemaining >= offset);
+                    pos += offset;
+                    lengthRemaining -= offset;
+                }
+            }
+        }
+        
+        if (lastLineEllipsed || lastLineClipped) {
+            int i;
+            for (i = 0; i < lengthRemaining && pos[i] != '\n'; i++) {
+                /* Empty body - we just want to know if there's a newline between here and the end of the string */
+            }
+            
+            bool droppingLines = (i != lengthRemaining);
+            
+            String lastLine = String(pos, i);
+            if (lastLineEllipsed && i < lengthRemaining && !(pos[i] == '\n' && i == lengthRemaining - 1)) {
+                // linebreak on last line with extra content that won't be rendered - insert an ellipse (5133005);
+                // the exception is if we're at the last character and its a newline - next line won't render/size so don't ellipsise
+                // This is OK for bidi since characters after a newline will not influence direction preceding it.
+                const UChar ellipsisCharacter = 0x2026;
+                lastLine.append(ellipsisCharacter);
+            }
+            // The last line is either everything that's left or everything until the next newline character
+            if (!measureOnly) {
+                bool insertEllipsis = (truncationRect == NULL);
+                bool forceTruncation = (droppingLines && truncationRect);
+                float customTruncationElementWidth = truncationRect ? truncationRect->size.width : 0;                
+                
+                textPoint = cursor;
+                String ellipsisResult;
+                float lastLineWidth;
+                if (alignment == WebTextAlignmentCenter) {
+                    ellipsisResult = applyEllipsisStyle(lastLine, ellipsisStyle, rect.size.width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &lastLineWidth, insertEllipsis, customTruncationElementWidth);
+                    if (lastLineWidth != 0) // special case for single glyphs wider  than the rect to which we are rendering... applyEllipsisStyle can return 0 in this case.
+                        textPoint.x += (rect.size.width - lastLineWidth) / 2.0f;
+                } else if (alignment == WebTextAlignmentRight) {
+                    ellipsisResult = applyEllipsisStyle(lastLine, ellipsisStyle, rect.size.width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &lastLineWidth, insertEllipsis, customTruncationElementWidth);
+                    if (lastLineWidth != 0)
+                        textPoint.x += rect.size.width - lastLineWidth;
+                } else {
+                    ellipsisResult = applyEllipsisStyle(lastLine, ellipsisStyle, rect.size.width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &lastLineWidth, insertEllipsis, customTruncationElementWidth, forceTruncation);
+                    if (truncationRect && (ellipsisResult != lastLine || droppingLines)
+                        && lastLineWidth && base == WTF::Unicode::RightToLeft)
+                        textPoint.x += truncationRect->size.width;
+                }
+                CGContextRef cgContext = WKGetCurrentGraphicsContext();
+                GraphicsContext context(static_cast<PlatformGraphicsContext*>(cgContext), false);
+                context.setEmojiDrawingEnabled(includeEmoji);
+                // FIXME: For proper bidi rendering, we need to pass the whole string, rather than the truncated string.
+                // Otherwise, weak/neutral characters on either side of the ellipsis may pick up the wrong direction
+                // if there are strong characters ellided.
+                lineWidth = drawAtPoint(ellipsisResult.characters(), ellipsisResult.length(), textPoint, renderer, &context, drawUnderline, paragraphNeedsBidi ? &status : 0);
+                if (!renderedString.isNull())
+                    renderedString.append(ellipsisResult.characters(), ellipsisResult.length());
+                
+                if (truncationRect) {
+                    if (ellipsisResult == lastLine && !droppingLines) {
+                        *truncationRect = CGRectNull;
+                    } else {
+                        truncationRect->origin = textPoint;
+                        truncationRect->origin.x += (base == WTF::Unicode::RightToLeft) ? (-truncationRect->size.width) : lineWidth;
+                        truncationRect->origin.y -= ascent;
+                        truncationRect->size.height = ascent - GSFontGetDescent(font);
+                    }
+                }
+            } else {
+                applyEllipsisStyle(lastLine, ellipsisStyle, rect.size.width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &lineWidth);
+            }
+        } else  {
+            if (!measureOnly) {
+                textPoint = cursor;
+                if (alignment == WebTextAlignmentCenter && lineWidth <= rect.size.width) {
+                    textPoint.x += (rect.size.width - (lineWidth - trailingSpaceWidth)) / 2.0f;
+                } else if (alignment == WebTextAlignmentRight && lineWidth <= rect.size.width) {
+                    textPoint.x += rect.size.width - (lineWidth - trailingSpaceWidth);
+                }
+                CGContextRef cgContext = WKGetCurrentGraphicsContext();
+                GraphicsContext context(static_cast<PlatformGraphicsContext*>(cgContext), false);
+                context.setEmojiDrawingEnabled(includeEmoji);
+                if (paragraphNeedsBidi) {
+                    drawAtPoint(startOfLine, pos - startOfLine + lengthRemaining, textPoint, renderer, &context, drawUnderline, &status, pos - startOfLine - trailingSpaceCount - skippedWhitespace);
+                    if (!renderedString.isNull())
+                        renderedString.append(startOfLine, pos - startOfLine + lengthRemaining);
+                } else {
+                    drawAtPoint(startOfLine, pos - startOfLine - trailingSpaceCount - skippedWhitespace, textPoint, renderer, &context, drawUnderline);
+                    if (!renderedString.isNull())
+                        renderedString.append(startOfLine, pos - startOfLine);
+                }
+            }
+            startOfLine = pos;
+        }
+        if (lastLine)
+            finishedLastLine = YES;
+        else if (foundNewline) {
+            // Redetermine whether the succeeding paragraph needs bidi layout, and if so, determine the base direction
+            paragraphNeedsBidi = needsBidiLayout(startOfLine, lengthRemaining, base, true);
+            if (paragraphNeedsBidi)
+                status = BidiStatus(base, base, base, BidiContext::create((base == WTF::Unicode::LeftToRight) ? 0 : 1, base, false));
+        }
+        maxLineWidth = max(maxLineWidth, lineWidth);
+        cursor.y += lineSpacing;
+    }
+    
+    CGSize drawnSize;
+    drawnSize.width = ceilf(maxLineWidth);
+    if (!hasCustomLinespacing) {
+        if (measureOnly)
+            drawnSize.height = ceilf(cursor.y - rect.origin.y - ascent);
+        else
+            drawnSize.height = min<CGFloat>(ceilf(cursor.y - rect.origin.y - ascent), rect.size.height);
+    } else {
+        // for custom linespacing, the formula above does not hold true.
+        float descent = GSFontGetDescent(font);
+        if (measureOnly)
+            drawnSize.height = ceilf(cursor.y - rect.origin.y - lineSpacing - descent);
+        else
+            drawnSize.height = min<CGFloat>(ceilf(cursor.y - rect.origin.y - lineSpacing - descent), rect.size.height);
+    }
+    
+    if (renderedStringOut)
+        *renderedStringOut = (NSString *)renderedString;
+
+    return drawnSize;        
+}
+
+- (CGSize)__web_drawInRect:(CGRect)rect
+              withFont:(GSFontRef)font
+              ellipsis:(WebEllipsisStyle)ellipsisStyle
+             alignment:(WebTextAlignment)alignment
+         letterSpacing:(CGFloat)letterSpacing
+           lineSpacing:(CGFloat)lineSpacing
+          includeEmoji:(BOOL)includeEmoji
+        truncationRect:(CGRect *)truncationRect
+           measureOnly:(BOOL)measureOnly
+     renderedStringOut:(NSString **)renderedStringOut
+{
+    return [self __web_drawInRect:rect
+                         withFont:font
+                         ellipsis:ellipsisStyle
+                        alignment:alignment
+                    letterSpacing:letterSpacing
+                      lineSpacing:lineSpacing includeEmoji:includeEmoji
+                   truncationRect:truncationRect
+                      measureOnly:measureOnly
+                renderedStringOut:renderedStringOut
+                    drawUnderline:NO];
+}
+
+- (CGSize)__web_drawInRect:(CGRect)rect
+                  withFont:(GSFontRef)font
+                  ellipsis:(WebEllipsisStyle)ellipsisStyle
+                 alignment:(WebTextAlignment)alignment
+             letterSpacing:(CGFloat)letterSpacing
+               lineSpacing:(CGFloat)lineSpacing
+              includeEmoji:(BOOL)includeEmoji
+            truncationRect:(CGRect *)truncationRect
+               measureOnly:(BOOL)measureOnly
+{
+    return [self __web_drawInRect:rect
+                         withFont:font
+                         ellipsis:ellipsisStyle
+                        alignment:alignment
+                    letterSpacing:letterSpacing
+                      lineSpacing:lineSpacing includeEmoji:includeEmoji
+                   truncationRect:truncationRect
+                      measureOnly:measureOnly
+                renderedStringOut:nil];
+}
+
+
+#pragma mark Public methods
+
+- (CGSize)_web_drawAtPoint:(CGPoint)point withFont:(GSFontRef)font
+{
+    return [self _web_drawAtPoint:point forWidth:FLT_MAX withFont:font ellipsis:WebEllipsisStyleNone letterSpacing:0.0f includeEmoji:YES];
+}
+
+- (CGSize)_web_sizeWithFont:(GSFontRef)font
+{
+    return [self _web_sizeWithFont:font forWidth:FLT_MAX ellipsis:WebEllipsisStyleNone letterSpacing:0.0f];
+}
+
+- (CGSize)_web_sizeWithFont:(GSFontRef)font forWidth:(float)width ellipsis:(WebEllipsisStyle)ellipsisStyle
+{
+    return [self _web_sizeWithFont:font forWidth:width ellipsis:ellipsisStyle letterSpacing:0.0f];
+}
+
+- (CGSize)_web_sizeWithFont:(GSFontRef)font forWidth:(float)width ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing
+{
+    return [self _web_sizeWithFont:font forWidth:width ellipsis:ellipsisStyle letterSpacing:letterSpacing resultRange:NULL];
+}
+
+- (CGSize)_web_sizeWithFont:(GSFontRef)font forWidth:(float)width ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing resultRange:(NSRange *)resultRangeOut
+{
+    if (width < 0) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: width must be greater than zero.\n", __FUNCTION__);
+#endif
+        return CGSizeZero;
+    }
+    
+    if (font == NULL) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: font must be non-null.\n", __FUNCTION__);
+#endif
+        return CGSizeZero;
+    }
+    
+    if ([self isEqualToString:@""]) {
+        return CGSizeZero;
+    }
+
+    float stringWidth;
+    String s = String(self);
+    
+    FontCachePurgePreventer fontCachePurgePreventer;
+
+    Font renderer = rendererForFont(font);
+    if (letterSpacing != 0.0)
+        renderer.setLetterSpacing(letterSpacing);
+    
+    if (resultRangeOut) {
+        // Don't insert the ellipsis.
+        String truncated = applyEllipsisStyle(s, ellipsisStyle, width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &stringWidth, false);
+        NSRange resultRange = NSMakeRange(0, truncated.length());
+        *resultRangeOut = resultRange;
+    } else {
+        applyEllipsisStyle(s, ellipsisStyle, width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, &stringWidth);
+    }
+    
+    // Ensure integral sizes. Ceil to avoid possible clipping.
+    CGSize size = CGSizeMake (stringWidth, GSFontGetLineSpacing(font));
+    size.width = ceilf(size.width);
+    size.height = ceilf(size.height);
+    return size;
+}
+
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle
+{
+    return [self _web_drawAtPoint:point forWidth:width withFont:font ellipsis:ellipsisStyle letterSpacing:0.0f includeEmoji:YES];
+}
+
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing
+{
+    return [self _web_drawAtPoint:(CGPoint)point forWidth:width withFont:font ellipsis:ellipsisStyle letterSpacing:letterSpacing includeEmoji:YES];
+}
+
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing includeEmoji:(BOOL)includeEmoji
+{
+    return [self __web_drawAtPoint:point forWidth:width withFont:font ellipsis:ellipsisStyle letterSpacing:letterSpacing includeEmoji:includeEmoji measureOnly:NO];
+}
+
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment lineSpacing:(int)lineSpacing includeEmoji:(BOOL)includeEmoji truncationRect:(CGRect *)truncationRect measureOnly:(BOOL)measureOnly
+{
+    return [self __web_drawInRect:rect withFont:font ellipsis:ellipsisStyle alignment:alignment letterSpacing:(CGFloat)0.0 lineSpacing:(CGFloat)lineSpacing includeEmoji:includeEmoji truncationRect:truncationRect measureOnly:measureOnly];
+}
+
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment lineSpacing:(int)lineSpacing includeEmoji:(BOOL)includeEmoji truncationRect:(CGRect *)truncationRect
+{
+    return [self _web_drawInRect:rect withFont:font ellipsis:ellipsisStyle alignment:alignment lineSpacing:lineSpacing includeEmoji:includeEmoji truncationRect:truncationRect measureOnly:NO];
+}
+
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment lineSpacing:(int)lineSpacing
+{
+    return [self _web_drawInRect:rect withFont:font ellipsis:ellipsisStyle alignment:alignment lineSpacing:lineSpacing includeEmoji:YES truncationRect:nil measureOnly:NO];
+}
+
+- (CGSize)_web_drawInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle alignment:(WebTextAlignment)alignment
+{
+    return [self _web_drawInRect:rect withFont:font ellipsis:ellipsisStyle alignment:alignment lineSpacing:0 includeEmoji:YES truncationRect:nil measureOnly:NO];
+}
+
+- (CGSize)_web_sizeInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle lineSpacing:(int)lineSpacing
+{
+    return [self _web_drawInRect:rect withFont:font ellipsis:ellipsisStyle alignment:WebTextAlignmentLeft lineSpacing:lineSpacing includeEmoji:YES truncationRect:nil measureOnly:YES];
+}
+
+- (CGSize)_web_sizeInRect:(CGRect)rect withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle
+{
+    return [self _web_drawInRect:rect withFont:font ellipsis:ellipsisStyle alignment:WebTextAlignmentLeft lineSpacing:0 includeEmoji:YES truncationRect:nil measureOnly:YES];
+}
+
+- (NSString *)_web_stringForWidth:(float)width withFont:(GSFontRef)font ellipsis:(WebEllipsisStyle)ellipsisStyle letterSpacing:(float)letterSpacing includeEmoji:(BOOL)includeEmoji
+{
+    UNUSED_PARAM(includeEmoji);
+
+    if (width <= 0) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: width must be greater than zero.\n", __FUNCTION__);
+#endif
+        return @"";
+    }
+    
+    if (font == NULL) {
+#ifndef NDEBUG
+        fprintf(stderr, "%s: font must be non-null.\n", __FUNCTION__);
+#endif
+        return self;
+    }    
+
+    FontCachePurgePreventer fontCachePurgePreventer;
+
+    Font renderer = rendererForFont(font);
+    if (letterSpacing != 0.0)
+        renderer.setLetterSpacing(letterSpacing);
+
+    return applyEllipsisStyle(self, ellipsisStyle, width, renderer, shouldDisableWordRounding() ? StringTruncator::DisableRoundingHacks : StringTruncator::EnableRoundingHacks, 0);
+}
+
+- (CGSize)_web_sizeForWidth:(CGFloat)width withAttributes:(id <WebTextRenderingAttributes>)attributes
+{
+    // FIXME: We're not computing the correct truncation rect here
+    attributes.truncationRect = CGRectZero;
+    return [self __web_drawAtPoint:CGPointZero
+                          forWidth:width
+                          withFont:attributes.font
+                          ellipsis:attributes.ellipsisStyle
+                     letterSpacing:attributes.letterSpacing
+                      includeEmoji:attributes.includeEmoji
+                       measureOnly:YES
+                 renderedStringOut:attributes.renderString];
+}
+
+- (CGSize)_web_drawAtPoint:(CGPoint)point forWidth:(CGFloat)width withAttributes:(id <WebTextRenderingAttributes>)attributes
+{
+    // FIXME: We're not computing the correct truncation rect here
+    attributes.truncationRect = CGRectZero;
+    return [self __web_drawAtPoint:point
+                          forWidth:width
+                          withFont:attributes.font
+                          ellipsis:attributes.ellipsisStyle
+                     letterSpacing:attributes.letterSpacing
+                      includeEmoji:attributes.includeEmoji
+                       measureOnly:NO
+                 renderedStringOut:attributes.renderString
+                     drawUnderline:attributes.drawUnderline];
+}
+
+- (CGSize)_web_sizeInRect:(CGRect)rect withAttributes:(id <WebTextRenderingAttributes>)attributes
+{
+    // FIXME: We're not computing the correct truncation rect here
+    CGSize size = [self __web_drawInRect:rect
+                                withFont:attributes.font
+                                ellipsis:attributes.ellipsisStyle
+                               alignment:attributes.alignment
+                           letterSpacing:attributes.letterSpacing
+                             lineSpacing:attributes.lineSpacing
+                            includeEmoji:attributes.includeEmoji
+                          truncationRect:NULL
+                             measureOnly:YES
+                       renderedStringOut:attributes.renderString];
+    return size;
+}
+
+- (CGSize)_web_drawInRect:(CGRect)rect withAttributes:(id <WebTextRenderingAttributes>)attributes
+{
+    // FIXME: We're not computing the correct truncation rect here
+    CGSize size = [self __web_drawInRect:rect
+                                withFont:attributes.font
+                                ellipsis:attributes.ellipsisStyle
+                               alignment:attributes.alignment
+                           letterSpacing:attributes.letterSpacing
+                             lineSpacing:attributes.lineSpacing
+                            includeEmoji:attributes.includeEmoji
+                          truncationRect:NULL
+                             measureOnly:NO
+                       renderedStringOut:attributes.renderString
+                           drawUnderline:attributes.drawUnderline];
+    return size;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.h b/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.h
new file mode 100644 (file)
index 0000000..599a416
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <Foundation/Foundation.h>
+
+@interface NSString (WebNSStringExtrasIOS)
+
+- (NSArray *)_web_possibleURLsForUserTypedString;
+- (NSArray *)_web_possibleURLPrefixesForUserTypedString;
+- (NSURL *)_web_bestURLForUserTypedString;
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m b/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m
new file mode 100644 (file)
index 0000000..54c80c3
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <Foundation/NSString_NSURLExtras.h>
+#import "WebNSStringExtrasIOS.h"
+#import "WebNSURLExtras.h"
+
+@implementation NSString (WebNSStringExtrasIOS)
+
+- (NSArray *)_web_possibleURLsForForUserTypedString:(BOOL)isPrefix
+{
+    NSMutableArray *result = [NSMutableArray array];
+    
+    NSMutableString *workString = [NSMutableString stringWithString:self];
+    
+    // Trim whitespace from ends (likely cut & paste artifact)
+    CFStringTrimWhitespace((CFMutableStringRef)workString);
+    
+    // Strip out newlines and carriage returns (likely cut & paste artifact)
+    CFStringFindAndReplace((CFMutableStringRef)workString, CFSTR("\n"), CFSTR(""), CFRangeMake (0, [workString length]), 0);
+    CFStringFindAndReplace((CFMutableStringRef)workString, CFSTR("\r"), CFSTR(""), CFRangeMake (0, [workString length]), 0);
+    
+    if ([workString length] > 0) {
+        
+        // Looks like an absolute path or a ~-path
+        if ([workString characterAtIndex:0] == '/' || 
+            [workString characterAtIndex:0] == '~') {
+            // - treat it as a pathname
+            NSURL *URL = [NSURL fileURLWithPath:[workString _web_stringByExpandingTildeInPath]];
+            if (URL != nil) {
+                [result addObject:URL];
+            }
+        } else {
+            NSRange firstColonRange = [workString rangeOfString:@":"];
+            NSRange firstSlashRange = [workString rangeOfString:@"/"];
+            NSRange firstDotRange = [workString rangeOfString:@"."];
+            NSRange firstAtRange = [workString rangeOfString:@"@"];
+            
+            BOOL URLHasScheme = NO;
+            if (firstColonRange.location != NSNotFound && (firstSlashRange.location == NSNotFound || firstSlashRange.location >= firstColonRange.location)) {
+                // Do a "sanity check" on the scheme, if it is not one of the "well-known"
+                // schemes we support, do some work to add some possibilities.
+                // This is so typed strings like "localhost:8080" do not get
+                // misinterpreted as a URL with the localhost: scheme.
+                // Perhaps this could be improved to be a dynamic list of schemes
+                // based on loaded protocol handlers, but I do not see the need for
+                // the extra complexity.
+                if ([workString _web_hasCaseInsensitivePrefix:@"http:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"https:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"file:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"ftp:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"javascript:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"about:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"radar:"] ||
+                    [workString _web_hasCaseInsensitivePrefix:@"rdar:"]) {
+                    URLHasScheme = YES;
+                }
+                else if ([workString length] > firstColonRange.location + 1) {
+                    // If the first character following the first colon is not a number
+                    // guess that this is not is a host:port combination, and that
+                    // the string preceding the colon is a scheme we don't know about.
+                    unichar c = [workString characterAtIndex:firstColonRange.location + 1];
+                    if (c < '0' || c > '9') {
+                        URLHasScheme = YES;
+                    }
+                } else {
+                    // If there is no character following the colon, then assume the
+                    // string preceding the colon is a scheme.
+                    URLHasScheme = YES;
+                }
+            }
+            
+            if (URLHasScheme) {
+                // - use it unchanged
+                NSURL *URL = [NSURL _web_URLWithUserTypedString:workString];
+                if (URL != nil) {
+                    [result addObject:URL];
+                }
+            } else {
+                NSURL *URL;
+                
+                // apparent hostname contains a dot and starts with "www." 
+                if ([[workString lowercaseString] hasPrefix:@"www."]) {
+                    // - just prepend "http://"
+                    [workString insertString:@"http://" atIndex:0];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                // apparent hostname contains a dot and starts with "ftp."
+                } else if ([[workString lowercaseString] hasPrefix:@"ftp."]) {
+                    // - just prepend "ftp://"
+                    [workString insertString:@"ftp://" atIndex:0];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                // apparent hostname contains "@"
+                } else if (firstAtRange.location != NSNotFound && firstAtRange.location < firstSlashRange.location) {
+                    // - justprepend "http://"
+                    [workString insertString:@"http://" atIndex:0];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                // apparent hostname contains a dot and doesn't start with anything special
+                } else if (firstDotRange.location != NSNotFound && firstDotRange.location < firstSlashRange.location) {
+                    // - try prepending "http://"
+                    [workString insertString:@"http://" atIndex:0];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                    // - try prepending "http://www."
+                    [workString insertString:@"www." atIndex:strlen("http://")];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                // apparent hostname doesn't contain a dot but is equal to "localhost"
+                } else if ([[workString lowercaseString] isEqualToString:@"localhost"] ||
+                           [[workString lowercaseString] hasPrefix:@"localhost/"]) {
+                    // - just prepend "http://"
+                    [workString insertString:@"http://" atIndex:0];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                // apparent hostname doesn't contain a dot and is nothing special
+                } else {
+                    // - try prepending "http://"
+                    [workString insertString:@"http://" atIndex:0];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                    
+                    // - try prepending "http://www." and appending .com to the hostname, 
+                    // but account for a port number if there is one
+                    NSRange secondColonRange = [workString rangeOfString:@":" options:NSLiteralSearch range:NSMakeRange(5, [workString length] - 5)]; // 5 is length of http:
+                    unsigned endOfHostnameOrPort = (secondColonRange.location != NSNotFound) ?
+                        secondColonRange.location :
+                        (firstSlashRange.location != NSNotFound) ?
+                        strlen("http://") + firstSlashRange.location : 
+                        [workString length];  
+                    
+                    if (!(isPrefix && endOfHostnameOrPort == [workString length])) {
+                        [workString insertString:@".com" atIndex:endOfHostnameOrPort];
+                    }
+                    [workString insertString:@"www." atIndex:strlen("http://")];
+                    URL = [NSURL _web_URLWithUserTypedString:workString];
+                    if (URL != nil) {
+                        [result addObject:URL];
+                    }
+                }
+            }
+        }
+    }
+    
+    return result;
+}
+
+
+- (NSArray *)_web_possibleURLPrefixesForUserTypedString
+{
+    return [self _web_possibleURLsForForUserTypedString:YES];
+}
+
+- (NSArray *)_web_possibleURLsForUserTypedString
+{
+    return [self _web_possibleURLsForForUserTypedString:NO];
+}
+
+- (NSURL *)_web_bestURLForUserTypedString
+{
+    NSArray *URLs = [self _web_possibleURLsForUserTypedString];
+    if ([URLs count] == 0) {
+        return nil;
+    }
+    return [[URLs objectAtIndex:0] _webkit_canonicalize];
+}
+
+@end
+
+#endif // PLATFORM(IOS)
+
diff --git a/Source/WebKit/ios/Misc/WebNSStringExtrasIPhone.h b/Source/WebKit/ios/Misc/WebNSStringExtrasIPhone.h
new file mode 100644 (file)
index 0000000..9205115
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WebNSStringExtrasIOS.h>
diff --git a/Source/WebKit/ios/Misc/WebUIKitSupport.h b/Source/WebKit/ios/Misc/WebUIKitSupport.h
new file mode 100644 (file)
index 0000000..241ced2
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <unicode/uchar.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// To be able to use background tasks from within WebKit, we need to expose that UIKit functionality
+// without linking to UIKit.
+// We accomplish this by giving UIKit 3 methods to set up:
+//   - The invalid task ID value
+//   - A block for starting a background task
+//   - A block for ending a background task.
+typedef NSUInteger WebBackgroundTaskIdentifier;
+typedef void (^VoidBlock)(void);
+typedef WebBackgroundTaskIdentifier (^StartBackgroundTaskBlock)(VoidBlock);
+typedef void (^EndBackgroundTaskBlock)(WebBackgroundTaskIdentifier);
+
+void WebKitSetInvalidWebBackgroundTaskIdentifier(WebBackgroundTaskIdentifier);
+void WebKitSetStartBackgroundTaskBlock(StartBackgroundTaskBlock);
+void WebKitSetEndBackgroundTaskBlock(EndBackgroundTaskBlock);
+
+// These methods are what WebKit uses to start/stop background tasks after UIKit has set things up.
+WebBackgroundTaskIdentifier invalidWebBackgroundTaskIdentifier();
+WebBackgroundTaskIdentifier startBackgroundTask(VoidBlock);
+void endBackgroundTask(WebBackgroundTaskIdentifier);
+
+// This method gives WebKit the notifications to listen to so it knows about app Suspend/Resume
+void WebKitSetBackgroundAndForegroundNotificationNames(NSString *, NSString *);
+
+// This method does the minimum amount of work for WebNSStringDrawing to work
+// correctly.
+void WebKitInitialize(void);
+void WebKitSetIsClassic(BOOL);
+float WebKitGetMinimumZoomFontSize(void);
+    
+int WebKitGetLastLineBreakInBuffer(UChar *characters, int position, int length);
+
+const char *WebKitPlatformSystemRootDirectory(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Source/WebKit/ios/Misc/WebUIKitSupport.mm b/Source/WebKit/ios/Misc/WebUIKitSupport.mm
new file mode 100644 (file)
index 0000000..29048d5
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebUIKitSupport.h"
+
+#import <CoreFoundation/CFPriv.h>
+#import <WebCore/break_lines.h>
+#import <WebCore/ResourceRequest.h>
+#import <WebCore/TextBreakIterator.h>
+#import <WebCore/WebCoreSystemInterface.h>
+#import <WebCore/WebCoreThreadSystemInterface.h>
+#import "WebDatabaseManagerInternal.h"
+#import "WebKitSystemInterface.h"
+#import "WebLocalizableStrings.h"
+#import "WebPlatformStrategies.h"
+#import "WebSystemInterface.h"
+#import "WebViewPrivate.h"
+
+
+#import <runtime/InitializeThreading.h>
+
+using namespace WebCore;
+
+static inline bool linkedOnOrAfterIOS5()
+{
+    static bool s_linkedOnOrAfterIOS5 = iosExecutableWasLinkedOnOrAfterVersion(wkIOSSystemVersion_5_0);
+    return s_linkedOnOrAfterIOS5;
+}
+
+void WebKitInitialize(void)
+{
+    static bool webkitInitialized;
+    if (webkitInitialized)
+        return;
+
+    ASSERT(pthread_main_np());
+    webkitInitialized = true;
+    InitWebCoreThreadSystemInterface();
+    [WebView enableWebThread];
+    InitWebCoreSystemInterface();
+
+    // Initialize our platform strategies.
+    WebPlatformStrategies::initializeIfNecessary();
+
+    // We'd rather eat this cost at startup than slow down situations that need to be responsive.
+    // See <rdar://problem/6776301>.
+    LoadWebLocalizedStrings();
+    [WebView _setAllowsRoundingHacks:!linkedOnOrAfterIOS5()];
+    [WebView registerForMemoryNotifications];
+    
+    // This needs to be called before any requests are made in the process, <rdar://problem/9691871>
+    WebCore::initializeHTTPConnectionSettingsOnStartup();
+    WebCore::enableKURLSchemeCanonicalization(linkedOnOrAfterIOS5());
+}
+
+void WebKitSetIsClassic(BOOL flag)
+{
+    WKSetIsClassic(flag);
+}
+
+float WebKitGetMinimumZoomFontSize(void)
+{
+    return WKGetMinimumZoomFontSize();
+}
+
+int WebKitGetLastLineBreakInBuffer(UChar *characters, int position, int length)
+{
+    int lastBreakPos = position;
+    int breakPos = 0;
+    LazyLineBreakIterator breakIterator(String(characters, length));
+    while ((breakPos = nextBreakablePosition(breakIterator, breakPos)) < position)
+        lastBreakPos = breakPos++;
+    return lastBreakPos < position ? (NSUInteger)lastBreakPos : INT_MAX;
+}
+
+const char *WebKitPlatformSystemRootDirectory(void)
+{
+#if PLATFORM(IOS_SIMULATOR)
+    static const char *platformSystemRootDirectory = nil;
+    if (!platformSystemRootDirectory) {
+        char *simulatorRoot = getenv("IPHONE_SIMULATOR_ROOT");
+        platformSystemRootDirectory = simulatorRoot ? simulatorRoot : "/";
+    }
+    return platformSystemRootDirectory;
+#else
+    return "/";
+#endif
+}
+
+static void applicationDidEnterBackground(CFNotificationCenterRef, void*, CFStringRef, const void *, CFDictionaryRef)
+{
+    WebKitSetWebDatabasePaused(true);
+}
+
+static void applicationWillEnterForeground(CFNotificationCenterRef, void*, CFStringRef, const void*, CFDictionaryRef)
+{
+    WebKitSetWebDatabasePaused(false);
+}
+
+void WebKitSetBackgroundAndForegroundNotificationNames(NSString *didEnterBackgroundName, NSString *willEnterForegroundName)
+{
+    static bool initialized = false;
+    if (initialized)
+        return;
+    initialized = true;
+
+    CFNotificationCenterRef notificationCenter = CFNotificationCenterGetLocalCenter();
+    CFNotificationCenterAddObserver(notificationCenter, 0, applicationDidEnterBackground, (CFStringRef)didEnterBackgroundName, NULL, CFNotificationSuspensionBehaviorCoalesce);
+    CFNotificationCenterAddObserver(notificationCenter, 0, applicationWillEnterForeground, (CFStringRef)willEnterForegroundName, NULL, CFNotificationSuspensionBehaviorCoalesce);
+
+}
+
+static WebBackgroundTaskIdentifier invalidTaskIdentifier = 0;
+static StartBackgroundTaskBlock startBackgroundTaskBlock = 0;
+static EndBackgroundTaskBlock endBackgroundTaskBlock = 0;
+
+void WebKitSetInvalidWebBackgroundTaskIdentifier(WebBackgroundTaskIdentifier taskIdentifier)
+{
+    invalidTaskIdentifier = taskIdentifier;
+}
+
+void WebKitSetStartBackgroundTaskBlock(StartBackgroundTaskBlock startBlock)
+{
+    Block_release(startBackgroundTaskBlock);
+    startBackgroundTaskBlock = Block_copy(startBlock);    
+}
+
+void WebKitSetEndBackgroundTaskBlock(EndBackgroundTaskBlock endBlock)
+{
+    Block_release(endBackgroundTaskBlock);
+    endBackgroundTaskBlock = Block_copy(endBlock);    
+}
+
+WebBackgroundTaskIdentifier invalidWebBackgroundTaskIdentifier()
+{
+    return invalidTaskIdentifier;
+}
+
+WebBackgroundTaskIdentifier startBackgroundTask(VoidBlock expirationHandler)
+{
+    if (!startBackgroundTaskBlock)
+        return invalidTaskIdentifier;
+    return startBackgroundTaskBlock(expirationHandler);
+}
+
+void endBackgroundTask(WebBackgroundTaskIdentifier taskIdentifier)
+{
+    if (!endBackgroundTaskBlock)
+        return;
+    endBackgroundTaskBlock(taskIdentifier);
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.h b/Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.h
new file mode 100644 (file)
index 0000000..39a2aff
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebCore/SQLiteDatabaseTrackerClient.h>
+
+class WebSQLiteDatabaseTrackerClient : public WebCore::SQLiteDatabaseTrackerClient {
+public:
+    static WebSQLiteDatabaseTrackerClient* sharedWebSQLiteDatabaseTrackerClient();
+
+    virtual ~WebSQLiteDatabaseTrackerClient() OVERRIDE { }
+
+    virtual void willBeginFirstTransaction() OVERRIDE;
+    virtual void didFinishLastTransaction() OVERRIDE;
+
+private:
+    WebSQLiteDatabaseTrackerClient() { }
+};
diff --git a/Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.mm b/Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.mm
new file mode 100644 (file)
index 0000000..54ff645
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebSQLiteDatabaseTrackerClient.h"
+
+#import "WebDatabaseManagerInternal.h"
+#import "WebDatabaseManagerPrivate.h"
+
+#import <WebCore/SQLiteDatabaseTracker.h>
+
+using namespace WebCore;
+
+WebSQLiteDatabaseTrackerClient* WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient()
+{
+    static WebSQLiteDatabaseTrackerClient* sharedClient = new WebSQLiteDatabaseTrackerClient();
+    return sharedClient;
+}
+
+void WebSQLiteDatabaseTrackerClient::willBeginFirstTransaction()
+{
+    [WebDatabaseManager willBeginFirstTransaction];
+}
+
+void WebSQLiteDatabaseTrackerClient::didFinishLastTransaction()
+{
+    [WebDatabaseManager didFinishLastTransaction];
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/PopupMenuIOS.h b/Source/WebKit/ios/WebCoreSupport/PopupMenuIOS.h
new file mode 100644 (file)
index 0000000..f53c978
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PopupMenuIOS_h
+#define PopupMenuIOS_h
+
+#include <WebCore/IntRect.h>
+#include <WebCore/PopupMenu.h>
+
+namespace WebCore {
+class PopupMenuClient;
+}
+
+class PopupMenuIOS : public WebCore::PopupMenu {
+public:
+    PopupMenuIOS(WebCore::PopupMenuClient*);
+
+    virtual void show(const WebCore::IntRect&, WebCore::FrameView*, int index) OVERRIDE;
+    virtual void hide() OVERRIDE;
+    virtual void updateFromElement() OVERRIDE;
+    virtual void disconnectClient() OVERRIDE;
+
+private:
+    WebCore::PopupMenuClient* client() const { return m_popupClient; }
+
+    WebCore::PopupMenuClient* m_popupClient;
+};
+
+#endif // PopupMenuIOS_h
diff --git a/Source/WebKit/ios/WebCoreSupport/PopupMenuIOS.mm b/Source/WebKit/ios/WebCoreSupport/PopupMenuIOS.mm
new file mode 100644 (file)
index 0000000..f7adefd
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "PopupMenuIOS.h"
+
+#if PLATFORM(IOS)
+
+using namespace WebCore;
+
+PopupMenuIOS::PopupMenuIOS(PopupMenuClient* client)
+    : m_popupClient(client)
+{
+}
+
+void PopupMenuIOS::show(const IntRect&, FrameView*, int /*index*/)
+{
+}
+
+void PopupMenuIOS::hide()
+{
+}
+    
+void PopupMenuIOS::updateFromElement()
+{
+}
+
+void PopupMenuIOS::disconnectClient()
+{
+    m_popupClient = 0;
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.cpp b/Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.cpp
new file mode 100644 (file)
index 0000000..75da6ed
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "SearchPopupMenuIOS.h"
+
+#include <wtf/text/AtomicString.h>
+
+#if PLATFORM(IOS)
+
+using namespace WebCore;
+
+SearchPopupMenuIOS::SearchPopupMenuIOS(PopupMenuClient* client)
+    : m_popup(adoptRef(new PopupMenuIOS(client)))
+{
+}
+
+PopupMenu* SearchPopupMenuIOS::popupMenu()
+{
+    return m_popup.get();
+}
+
+void SearchPopupMenuIOS::saveRecentSearches(const AtomicString&, const Vector<String>& /*searchItems*/)
+{
+}
+
+void SearchPopupMenuIOS::loadRecentSearches(const AtomicString&, Vector<String>& /*searchItems*/)
+{
+}
+
+bool SearchPopupMenuIOS::enabled()
+{
+    return false;
+}
+
+#endif // !PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.h b/Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.h
new file mode 100644 (file)
index 0000000..ae64cc0
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuIOS_h
+#define SearchPopupMenuIOS_h
+
+#include "PopupMenuIOS.h"
+#include <WebCore/SearchPopupMenu.h>
+
+namespace WebCore {
+class PopupMenuClient;
+}
+
+class SearchPopupMenuIOS : public WebCore::SearchPopupMenu {
+public:
+    SearchPopupMenuIOS(WebCore::PopupMenuClient*);
+
+    virtual WebCore::PopupMenu* popupMenu() OVERRIDE;
+    virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) OVERRIDE;
+    virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) OVERRIDE;
+    virtual bool enabled() OVERRIDE;
+
+private:
+    RefPtr<PopupMenuIOS> m_popup;
+};
+
+#endif // SearchPopupMenuIOS_h
diff --git a/Source/WebKit/ios/WebCoreSupport/WebCaretChangeListener.h b/Source/WebKit/ios/WebCoreSupport/WebCaretChangeListener.h
new file mode 100644 (file)
index 0000000..2179446
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Apple Computer, 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.
+ */
+
+@protocol WebCaretChangeListener
+- (void)caretChanged;
+@end
diff --git a/Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.h b/Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.h
new file mode 100644 (file)
index 0000000..d0e4c54
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+#import "WebChromeClient.h"
+
+class WebChromeClientIOS : public WebChromeClient {
+public:
+    WebChromeClientIOS(WebView *webView)
+        : WebChromeClient(webView)
+        , m_formNotificationSuppressions(0) { }
+    
+    virtual void setWindowRect(const WebCore::FloatRect&) OVERRIDE;
+    virtual WebCore::FloatRect windowRect() OVERRIDE;
+    virtual void setStatusbarText(const WTF::String&) OVERRIDE { }
+
+    virtual void focus() OVERRIDE;
+    virtual void takeFocus(WebCore::FocusDirection) OVERRIDE { }
+
+    virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&) OVERRIDE;
+    virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&) OVERRIDE;
+    virtual bool runJavaScriptPrompt(WebCore::Frame*, const WTF::String& message, const WTF::String& defaultValue, WTF::String& result) OVERRIDE;
+
+    virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>) OVERRIDE;
+
+#if ENABLE(TOUCH_EVENTS)
+    virtual void didPreventDefaultForEvent() OVERRIDE;
+#endif
+    virtual void didReceiveDocType(WebCore::Frame*) OVERRIDE;
+    virtual void setNeedsScrollNotifications(WebCore::Frame*, bool) OVERRIDE;
+    virtual void observedContentChange(WebCore::Frame*) OVERRIDE;
+    virtual void clearContentChangeObservers(WebCore::Frame*) OVERRIDE;
+    virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const OVERRIDE;
+    virtual void notifyRevealedSelectionByScrollingFrame(WebCore::Frame*) OVERRIDE;
+    virtual bool isStopping() OVERRIDE;
+    virtual void didLayout(LayoutType) OVERRIDE;
+    virtual void didStartOverflowScroll() OVERRIDE;
+    virtual void didEndOverflowScroll() OVERRIDE;
+
+    virtual void suppressFormNotifications() OVERRIDE;
+    virtual void restoreFormNotifications() OVERRIDE;
+    
+    virtual void formStateDidChange(const WebCore::Node*) OVERRIDE { }
+
+    virtual void elementDidFocus(const WebCore::Node*) OVERRIDE;
+    virtual void elementDidBlur(const WebCore::Node*) OVERRIDE;
+
+#if USE(ACCELERATED_COMPOSITING)
+    virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) OVERRIDE;
+#endif
+
+    virtual void didFlushCompositingLayers() OVERRIDE;
+
+    virtual void updateViewportConstrainedLayers(HashMap<PlatformLayer*, OwnPtr<WebCore::ViewportConstraints> >&, HashMap<PlatformLayer*, PlatformLayer*>&) OVERRIDE;
+
+    virtual bool fetchCustomFixedPositionLayoutRect(WebCore::IntRect&) OVERRIDE;
+    virtual void addOrUpdateScrollingLayer(WebCore::Node*, PlatformLayer*, PlatformLayer*, const WebCore::IntSize&, bool allowHorizontalScrollbar, bool allowVerticalScrollbar) OVERRIDE;
+    virtual void removeScrollingLayer(WebCore::Node*, PlatformLayer*, PlatformLayer*) OVERRIDE;
+
+    virtual bool selectItemWritingDirectionIsNatural() OVERRIDE;
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection() OVERRIDE;
+    virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const OVERRIDE;
+    virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const OVERRIDE;
+
+    virtual void webAppOrientationsUpdated() OVERRIDE;
+    virtual void focusedNodeChanged(WebCore::Node*) OVERRIDE;
+
+private:
+    int m_formNotificationSuppressions;
+};
+#endif
diff --git a/Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.mm b/Source/WebKit/ios/WebCoreSupport/WebChromeClientIOS.mm
new file mode 100644 (file)
index 0000000..683db47
--- /dev/null
@@ -0,0 +1,307 @@
+/*
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+#import "WebChromeClientIOS.h"
+
+#import "DOMNodeInternal.h"
+#import "PopupMenuIOS.h"
+#import "SearchPopupMenuIOS.h"
+#import "WebDelegateImplementationCaching.h"
+#import "WebFixedPositionContent.h"
+#import "WebFixedPositionContentInternal.h"
+#import "WebFormDelegate.h"
+#import "WebFrameInternal.h"
+#import "WebKitSystemInterface.h"
+#import "WebOpenPanelResultListener.h"
+#import "WebUIDelegate.h"
+#import "WebUIDelegatePrivate.h"
+#import "WebView.h"
+#import "WebViewInternal.h"
+#import "WebViewPrivate.h"
+#import "WebUIKitDelegate.h"
+
+#import <wtf/HashMap.h>
+#import <wtf/RefPtr.h>
+#import <WebCore/FileChooser.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/Frame.h>
+#import <WebCore/GraphicsLayer.h>
+#import <WebCore/HTMLInputElement.h>
+#import <WebCore/HTMLNames.h>
+#import <WebCore/IntRect.h>
+#import <WebCore/Node.h>
+#import <WebCore/RenderBox.h>
+#import <WebCore/RenderObject.h>
+#import <WebCore/RuntimeApplicationChecksIOS.h>
+#import <WebCore/ScrollingConstraints.h>
+#import <WebCore/WAKWindow.h>
+#import <WebCore/WebCoreThreadMessage.h>
+
+using namespace WebCore;
+
+void WebChromeClientIOS::setWindowRect(const WebCore::FloatRect& r)
+{
+    [[webView() _UIDelegateForwarder] webView:webView() setFrame:r];
+}
+
+FloatRect WebChromeClientIOS::windowRect()
+{
+    CGRect windowRect = [[webView() _UIDelegateForwarder] webViewFrame:webView()];
+    return enclosingIntRect(windowRect);
+}
+
+void WebChromeClientIOS::focus()
+{
+    [[webView() _UIDelegateForwarder] webViewFocus:webView()];
+}
+
+void WebChromeClientIOS::runJavaScriptAlert(Frame* frame, const WTF::String& message)
+{
+    WebThreadLockPushModal();
+    [[webView() _UIDelegateForwarder] webView:webView() runJavaScriptAlertPanelWithMessage:message initiatedByFrame:kit(frame)];
+    WebThreadLockPopModal();
+}
+
+bool WebChromeClientIOS::runJavaScriptConfirm(Frame* frame, const WTF::String& message)
+{
+    WebThreadLockPushModal();
+    bool result = [[webView() _UIDelegateForwarder] webView:webView() runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:kit(frame)];
+    WebThreadLockPopModal();
+    return result;
+}
+
+bool WebChromeClientIOS::runJavaScriptPrompt(Frame* frame, const WTF::String& prompt, const WTF::String& defaultText, WTF::String& result)
+{
+    WebThreadLockPushModal();
+    result = [[webView() _UIDelegateForwarder] webView:webView() runJavaScriptTextInputPanelWithPrompt:prompt defaultText:defaultText initiatedByFrame:kit(frame)];
+    WebThreadLockPopModal();
+    return !result.isNull();
+}
+
+void WebChromeClientIOS::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
+{
+    const FileChooserSettings& settings = chooser->settings();
+    BOOL allowMultipleFiles = settings.allowsMultipleFiles;
+    Vector<String> acceptMIMETypes = settings.acceptMIMETypes;
+    WebOpenPanelResultListener *listener = [[WebOpenPanelResultListener alloc] initWithChooser:chooser];
+
+    // Convert the accept attribute string into a list of MIME types.
+    size_t numMIMETypes = acceptMIMETypes.size();
+    NSMutableArray *mimeTypes = [NSMutableArray arrayWithCapacity:numMIMETypes];
+    for (size_t i = 0; i < numMIMETypes; ++i)
+        [mimeTypes addObject:acceptMIMETypes[i]];
+
+    if (WebThreadIsCurrent()) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [[webView() _UIKitDelegateForwarder] webView:webView() runOpenPanelForFileButtonWithResultListener:listener allowMultipleFiles:allowMultipleFiles acceptMIMETypes:mimeTypes];
+        });
+    } else
+        [[webView() _UIKitDelegateForwarder] webView:webView() runOpenPanelForFileButtonWithResultListener:listener allowMultipleFiles:allowMultipleFiles acceptMIMETypes:mimeTypes];
+
+    [listener release];
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void WebChromeClientIOS::didPreventDefaultForEvent()
+{
+    [[webView() _UIKitDelegateForwarder] webViewDidPreventDefaultForEvent:webView()];
+}
+#endif
+
+void WebChromeClientIOS::didReceiveDocType(WebCore::Frame* frame)
+{
+    [[webView() _UIKitDelegateForwarder] webView:webView() didReceiveDocTypeForFrame:kit(frame)];
+}
+
+void WebChromeClientIOS::setNeedsScrollNotifications(WebCore::Frame* frame, bool flag)
+{
+    [[webView() _UIKitDelegateForwarder] webView:webView() needsScrollNotifications:[NSNumber numberWithBool:flag] forFrame:kit(frame)];
+}
+
+void WebChromeClientIOS::observedContentChange(WebCore::Frame* frame)
+{
+    [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:WKObservedContentChange() forFrame:kit(frame)];
+}
+
+void WebChromeClientIOS::clearContentChangeObservers(WebCore::Frame* frame)
+{
+    ASSERT(WebThreadCountOfObservedContentModifiers() > 0);
+    if (WebThreadCountOfObservedContentModifiers() > 0) {
+        WebThreadClearObservedContentModifiers();
+        observedContentChange(frame);
+    }        
+}
+
+static inline NSDictionary* dictionaryForViewportArguments(const WebCore::ViewportArguments& arguments)
+{
+    return @{ @"initial-scale":@(arguments.zoom),
+              @"minimum-scale":@(arguments.minZoom),
+              @"maximum-scale":@(arguments.maxZoom),
+              @"user-scalable":@(arguments.userZoom),
+              @"width":@(arguments.width),
+              @"height":@(arguments.height) };
+}
+
+void WebChromeClientIOS::dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments& arguments) const
+{
+    [[webView() _UIKitDelegateForwarder] webView:webView() didReceiveViewportArguments:dictionaryForViewportArguments(arguments)];
+}
+
+void WebChromeClientIOS::notifyRevealedSelectionByScrollingFrame(WebCore::Frame* frame)
+{
+    [[webView() _UIKitDelegateForwarder] revealedSelectionByScrollingWebFrame:kit(frame)];
+}
+
+bool WebChromeClientIOS::isStopping()
+{
+    return [webView() _isStopping];
+}
+
+void WebChromeClientIOS::didLayout(LayoutType changeType)
+{
+    [[webView() _UIKitDelegate] webThreadWebViewDidLayout:webView() byScrolling:(changeType == ChromeClient::Scroll)];
+}
+
+void WebChromeClientIOS::didStartOverflowScroll()
+{
+    [[[webView() _UIKitDelegateForwarder] asyncForwarder] webViewDidStartOverflowScroll:webView()];
+}
+
+void WebChromeClientIOS::didEndOverflowScroll()
+{
+    [[[webView() _UIKitDelegateForwarder] asyncForwarder] webViewDidEndOverflowScroll:webView()];
+}
+
+void WebChromeClientIOS::suppressFormNotifications() 
+{
+    m_formNotificationSuppressions++;
+}
+
+void WebChromeClientIOS::restoreFormNotifications() 
+{
+    m_formNotificationSuppressions--;
+    ASSERT(m_formNotificationSuppressions >= 0);
+    if (m_formNotificationSuppressions < 0)
+        m_formNotificationSuppressions = 0;
+}
+
+void WebChromeClientIOS::elementDidFocus(const WebCore::Node* node)
+{
+    if (m_formNotificationSuppressions <= 0)
+        [[webView() _UIKitDelegateForwarder] webView:webView() elementDidFocusNode:kit(const_cast<WebCore::Node*>(node))];
+}
+
+void WebChromeClientIOS::elementDidBlur(const WebCore::Node* node)
+{
+    if (m_formNotificationSuppressions <= 0)
+        [[webView() _UIKitDelegateForwarder] webView:webView() elementDidBlurNode:kit(const_cast<WebCore::Node*>(node))];
+}
+
+bool WebChromeClientIOS::selectItemWritingDirectionIsNatural()
+{
+    return false;
+}
+
+bool WebChromeClientIOS::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return true;
+}
+
+PassRefPtr<WebCore::PopupMenu> WebChromeClientIOS::createPopupMenu(WebCore::PopupMenuClient* client) const
+{
+    return adoptRef(new PopupMenuIOS(client));
+}
+
+PassRefPtr<WebCore::SearchPopupMenu> WebChromeClientIOS::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
+{
+    return adoptRef(new SearchPopupMenuIOS(client));
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void WebChromeClientIOS::attachRootGraphicsLayer(Frame*, GraphicsLayer* graphicsLayer)
+{
+    // FIXME: for non-root frames we rely on RenderView positioning the root layer,
+    // which is a hack. <rdar://problem/5906146>
+    // Send the delegate message on the web thread to avoid <rdar://problem/8567677>
+    [[webView() _UIKitDelegate] _webthread_webView:webView() attachRootLayer:graphicsLayer ? graphicsLayer->platformLayer() : 0];
+}
+#endif
+
+void WebChromeClientIOS::didFlushCompositingLayers()
+{
+    [[[webView() _UIKitDelegateForwarder] asyncForwarder] webViewDidCommitCompositingLayerChanges:webView()];
+}
+
+bool WebChromeClientIOS::fetchCustomFixedPositionLayoutRect(IntRect& rect)
+{
+    NSRect updatedRect;
+    if ([webView() _fetchCustomFixedPositionLayoutRect:&updatedRect]) {
+        rect = enclosingIntRect(updatedRect);
+        return true;
+    }
+
+    return false;
+}
+
+void WebChromeClientIOS::updateViewportConstrainedLayers(HashMap<PlatformLayer*, OwnPtr<ViewportConstraints> >& layerMap, HashMap<PlatformLayer*, PlatformLayer*>& stickyContainers)
+{
+    [[webView() _fixedPositionContent] setViewportConstrainedLayers:layerMap stickyContainerMap:stickyContainers];
+}
+
+void WebChromeClientIOS::addOrUpdateScrollingLayer(Node* node, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const IntSize& scrollSize, bool allowHorizontalScrollbar, bool allowVerticalScrollbar)
+{
+    DOMNode *domNode = kit(node);
+
+    [[[webView() _UIKitDelegateForwarder] asyncForwarder] webView:webView() didCreateOrUpdateScrollingLayer:scrollingLayer withContentsLayer:contentsLayer scrollSize:[NSValue valueWithSize:scrollSize] forNode:domNode
+        allowHorizontalScrollbar:allowHorizontalScrollbar allowVerticalScrollbar:allowVerticalScrollbar];
+}
+
+void WebChromeClientIOS::removeScrollingLayer(Node* node, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer)
+{
+    DOMNode *domNode = kit(node);
+    [[[webView() _UIKitDelegateForwarder] asyncForwarder] webView:webView() willRemoveScrollingLayer:scrollingLayer withContentsLayer:contentsLayer forNode:domNode];
+}
+
+void WebChromeClientIOS::webAppOrientationsUpdated()
+{
+    [[webView() _UIDelegateForwarder] webViewSupportedOrientationsUpdated:webView()];
+}
+
+void WebChromeClientIOS::focusedNodeChanged(Node* node)
+{
+    if (!node)
+        return;
+    if (!node->hasTagName(HTMLNames::inputTag))
+        return;
+
+    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(node);
+    if (!inputElement->isText())
+        return;
+
+    CallFormDelegate(webView(), @selector(didFocusTextField:inFrame:), kit(inputElement), kit(inputElement->document()->frame()));
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.h b/Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.h
new file mode 100644 (file)
index 0000000..be5ece7
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+
+@class CALayer;
+@class WebView;
+
+typedef NS_ENUM(NSInteger, WebFixedPositionAnchorEdge) {
+    WebFixedPositionAnchorEdgeLeft,
+    WebFixedPositionAnchorEdgeRight,
+    WebFixedPositionAnchorEdgeTop,
+    WebFixedPositionAnchorEdgeBottom
+};
+
+// Encapsulates page content that needs to be repositioned during scrolling,
+// like position:fixed layers.
+// Can be called without taking the WebThread lock.
+
+@interface WebFixedPositionContent : NSObject {
+    struct WebFixedPositionContentData* _private;
+}
+
+- (id)initWithWebView:(WebView *)webView;
+
+- (void)scrollOrZoomChanged:(CGRect)positionedObjectsRect;
+- (void)overflowScrollPositionForLayer:(CALayer *)scrollLayer changedTo:(CGPoint)scrollPosition;
+- (void)didFinishScrollingOrZooming;
+- (BOOL)hasFixedOrStickyPositionLayers;
+// Returns CGFLOAT_MAX if there are no layers anchored to the given edge.
+- (CGFloat)minimumOffsetFromFixedPositionLayersToAnchorEdge:(WebFixedPositionAnchorEdge)anchorEdge ofRect:(CGRect)rect inLayer:(CALayer *)layer;
+
+@end
diff --git a/Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.mm b/Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.mm
new file mode 100644 (file)
index 0000000..1a58129
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebFixedPositionContent.h"
+#import "WebFixedPositionContentInternal.h"
+
+#import "WebViewInternal.h"
+#import <WebCore/ChromeClient.h>
+#import <WebCore/Frame.h>
+#import <WebCore/IntSize.h>
+#import <WebCore/ScrollingConstraints.h>
+#import <WebCore/WebCoreThreadRun.h>
+
+#import <wtf/HashMap.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/StdLibExtras.h>
+#import <wtf/Threading.h>
+
+#import <CoreGraphics/CGFloat.h>
+#import <QuartzCore/QuartzCore.h>
+#import <Foundation/Foundation.h>
+#import <algorithm>
+
+using namespace WebCore;
+using namespace std;
+
+static Mutex& WebFixedPositionContentDataLock()
+{
+    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    return mutex;
+}
+
+struct ViewportConstrainedLayerData {
+    ViewportConstrainedLayerData()
+        : m_enclosingAcceleratedScrollLayer(nil)
+    { }
+    CALayer* m_enclosingAcceleratedScrollLayer; // May be nil.
+    OwnPtr<ViewportConstraints> m_viewportConstraints;
+};
+
+typedef HashMap<RetainPtr<CALayer>, OwnPtr<ViewportConstrainedLayerData> > LayerInfoMap;
+
+struct WebFixedPositionContentData {
+public:
+    WebFixedPositionContentData(WebView *);
+    ~WebFixedPositionContentData();
+    
+    WebView *m_webView;
+    LayerInfoMap m_viewportConstainedLayers;
+};
+
+
+WebFixedPositionContentData::WebFixedPositionContentData(WebView *webView)
+    : m_webView(webView)
+{
+}
+
+WebFixedPositionContentData::~WebFixedPositionContentData()
+{
+}
+
+@implementation WebFixedPositionContent
+
+- (id)initWithWebView:(WebView *)webView
+{
+    if ((self = [super init])) {
+        _private = new WebFixedPositionContentData(webView);
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    delete _private;
+    [super dealloc];
+}
+
+- (void)scrollOrZoomChanged:(CGRect)positionedObjectsRect
+{
+    MutexLocker lock(WebFixedPositionContentDataLock());
+
+    LayerInfoMap::const_iterator end = _private->m_viewportConstainedLayers.end();
+    for (LayerInfoMap::const_iterator it = _private->m_viewportConstainedLayers.begin(); it != end; ++it) {
+        CALayer *layer = it->key.get();
+        ViewportConstrainedLayerData* constraintData = it->value.get();
+        const ViewportConstraints& constraints = *(constraintData->m_viewportConstraints.get());
+
+        switch (constraints.constraintType()) {
+        case ViewportConstraints::FixedPositionConstaint: {
+                const FixedPositionViewportConstraints& fixedConstraints = static_cast<const FixedPositionViewportConstraints&>(constraints);
+
+                FloatPoint layerPosition = fixedConstraints.layerPositionForViewportRect(positionedObjectsRect);
+            
+                CGRect layerBounds = [layer bounds];
+                CGPoint anchorPoint = [layer anchorPoint];
+                CGPoint newPosition = CGPointMake(layerPosition.x() - constraints.alignmentOffset().width() + anchorPoint.x * layerBounds.size.width,
+                                                  layerPosition.y() - constraints.alignmentOffset().height() + anchorPoint.y * layerBounds.size.height);
+                [layer setPosition:newPosition];
+                break;
+            }
+        case ViewportConstraints::StickyPositionConstraint: {
+                const StickyPositionViewportConstraints& stickyConstraints = static_cast<const StickyPositionViewportConstraints&>(constraints);
+
+                FloatPoint layerPosition = stickyConstraints.layerPositionForConstrainingRect(positionedObjectsRect);
+
+                CGRect layerBounds = [layer bounds];
+                CGPoint anchorPoint = [layer anchorPoint];
+                CGPoint newPosition = CGPointMake(layerPosition.x() - constraints.alignmentOffset().width() + anchorPoint.x * layerBounds.size.width,
+                                                  layerPosition.y() - constraints.alignmentOffset().height() + anchorPoint.y * layerBounds.size.height);
+                [layer setPosition:newPosition];
+                break;
+            }
+        }
+    }
+}
+
+- (void)overflowScrollPositionForLayer:(CALayer *)scrollLayer changedTo:(CGPoint)scrollPosition
+{
+    MutexLocker lock(WebFixedPositionContentDataLock());
+
+    LayerInfoMap::const_iterator end = _private->m_viewportConstainedLayers.end();
+    for (LayerInfoMap::const_iterator it = _private->m_viewportConstainedLayers.begin(); it != end; ++it) {
+        CALayer *layer = it->key.get();
+        ViewportConstrainedLayerData* constraintData = it->value.get();
+        
+        if (constraintData->m_enclosingAcceleratedScrollLayer == scrollLayer) {
+            const StickyPositionViewportConstraints& stickyConstraints = static_cast<const StickyPositionViewportConstraints&>(*(constraintData->m_viewportConstraints.get()));
+            FloatRect constrainingRectAtLastLayout = stickyConstraints.constrainingRectAtLastLayout();
+            FloatRect scrolledConstrainingRect = FloatRect(scrollPosition.x, scrollPosition.y, constrainingRectAtLastLayout.width(), constrainingRectAtLastLayout.height());
+            FloatPoint layerPosition = stickyConstraints.layerPositionForConstrainingRect(scrolledConstrainingRect);
+
+            CGRect layerBounds = [layer bounds];
+            CGPoint anchorPoint = [layer anchorPoint];
+            CGPoint newPosition = CGPointMake(layerPosition.x() - stickyConstraints.alignmentOffset().width() + anchorPoint.x * layerBounds.size.width,
+                                              layerPosition.y() - stickyConstraints.alignmentOffset().height() + anchorPoint.y * layerBounds.size.height);
+            [layer setPosition:newPosition];
+        }
+    }
+}
+
+// FIXME: share code with 'sendScrollEvent'?
+- (void)didFinishScrollingOrZooming
+{
+    WebThreadRun(^{
+        if (Frame* frame = [_private->m_webView _mainCoreFrame])
+            frame->viewportOffsetChanged(Frame::CompletedScrollOffset);
+    });
+}
+
+- (void)setViewportConstrainedLayers:(WTF::HashMap<CALayer *, OwnPtr<WebCore::ViewportConstraints> >&)layerMap stickyContainerMap:(WTF::HashMap<CALayer*, CALayer*>&)stickyContainers
+{
+    MutexLocker lock(WebFixedPositionContentDataLock());
+
+    _private->m_viewportConstainedLayers.clear();
+
+    HashMap<CALayer *, OwnPtr<ViewportConstraints> >::iterator end = layerMap.end();
+    for (HashMap<CALayer *, OwnPtr<ViewportConstraints> >::iterator it = layerMap.begin(); it != end; ++it) {
+        CALayer* layer = it->key;
+        OwnPtr<ViewportConstrainedLayerData> layerData = adoptPtr(new ViewportConstrainedLayerData);
+
+        layerData->m_enclosingAcceleratedScrollLayer = stickyContainers.get(layer);
+        layerData->m_viewportConstraints = it->value.release();
+
+        _private->m_viewportConstainedLayers.set(layer, layerData.release());
+    }
+}
+
+- (BOOL)hasFixedOrStickyPositionLayers
+{
+    MutexLocker lock(WebFixedPositionContentDataLock());
+    return !_private->m_viewportConstainedLayers.isEmpty();
+}
+
+static ViewportConstraints::AnchorEdgeFlags anchorEdgeFlagsForAnchorEdge(WebFixedPositionAnchorEdge edge)
+{
+    switch (edge) {
+    case WebFixedPositionAnchorEdgeLeft:
+        return ViewportConstraints::AnchorEdgeFlags::AnchorEdgeLeft;
+    case WebFixedPositionAnchorEdgeRight:
+        return ViewportConstraints::AnchorEdgeFlags::AnchorEdgeRight;
+    case WebFixedPositionAnchorEdgeTop:
+        return ViewportConstraints::AnchorEdgeFlags::AnchorEdgeTop;
+    case WebFixedPositionAnchorEdgeBottom:
+        return ViewportConstraints::AnchorEdgeFlags::AnchorEdgeBottom;
+    }
+}
+
+- (CGFloat)minimumOffsetFromFixedPositionLayersToAnchorEdge:(WebFixedPositionAnchorEdge)anchorEdge ofRect:(CGRect)rect inLayer:(CALayer *)layer
+{
+    MutexLocker lock(WebFixedPositionContentDataLock());
+    ViewportConstraints::AnchorEdgeFlags anchorEdgeFlags = anchorEdgeFlagsForAnchorEdge(anchorEdge);
+    CGFloat minimumOffset = CGFLOAT_MAX;
+    LayerInfoMap::const_iterator end = _private->m_viewportConstainedLayers.end();
+    for (LayerInfoMap::const_iterator it = _private->m_viewportConstainedLayers.begin(); it != end; ++it) {
+        CALayer *fixedLayer = it->key.get();
+        ViewportConstrainedLayerData* constraintData = it->value.get();
+        const ViewportConstraints& constraints = *(constraintData->m_viewportConstraints.get());
+
+        if (!constraints.hasAnchorEdge(anchorEdgeFlags))
+            continue;
+        // According to Simon: It's possible that there are windows of time
+        // where these CALayers are unparented (because we've flushed on the web
+        // thread but haven't updated those layers yet).
+        if (![fixedLayer superlayer])
+            continue;
+
+        CGRect fixedLayerExtent = [layer convertRect:[fixedLayer bounds] fromLayer:fixedLayer];
+        CGFloat offset;
+        switch (anchorEdge) {
+        case WebFixedPositionAnchorEdgeLeft:
+            offset = CGRectGetMinX(fixedLayerExtent) - CGRectGetMinX(rect);
+            break;
+        case WebFixedPositionAnchorEdgeRight:
+            offset = CGRectGetMaxX(rect) - CGRectGetMaxX(fixedLayerExtent);
+            break;
+        case WebFixedPositionAnchorEdgeTop:
+            offset = CGRectGetMinY(fixedLayerExtent) - CGRectGetMinY(rect);
+            break;
+        case WebFixedPositionAnchorEdgeBottom:
+            offset = CGRectGetMaxY(rect) - CGRectGetMaxY(fixedLayerExtent);
+            break;
+        }
+        minimumOffset = CGFloatMin(minimumOffset, offset);
+    }
+    return minimumOffset;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebFixedPositionContentInternal.h b/Source/WebKit/ios/WebCoreSupport/WebFixedPositionContentInternal.h
new file mode 100644 (file)
index 0000000..64e2660
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+#import <wtf/HashMap.h>
+#import <wtf/OwnPtr.h>
+
+@class CALayer;
+
+namespace WebCore {
+class ViewportConstraints;
+}
+
+@interface WebFixedPositionContent(WebKitInternal)
+// Called from inside WebKit.
+
+- (void)setViewportConstrainedLayers:(WTF::HashMap<CALayer *, OwnPtr<WebCore::ViewportConstraints> >&)layerMap stickyContainerMap:(WTF::HashMap<CALayer*, CALayer*>&)stickyContainers;
+
+@end
diff --git a/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.h b/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.h
new file mode 100644 (file)
index 0000000..f2194b4
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <WebKit/WebFrame.h>
+#import <WebKit/WebVisiblePosition.h>
+
+@class DOMRange;
+@class DOMVisiblePosition;
+
+typedef enum {
+    WebTextSelectionStateNone,
+    WebTextSelectionStateCaret,
+    WebTextSelectionStateRange,
+} WebTextSelectionState;
+
+typedef enum {
+    WebTextSmartExtendDirectionNone,
+    WebTextSmartExtendDirectionLeft,
+    WebTextSmartExtendDirectionRight,
+} WebTextSmartExtendDirection;
+
+@interface WebFrame (WebFrameIOS)
+
+- (void)moveSelectionToPoint:(CGPoint)point;
+
+- (void)clearSelection;
+- (BOOL)hasSelection;
+- (WebTextSelectionState)selectionState;
+- (CGRect)caretRectForPosition:(WebVisiblePosition *)position;
+- (CGRect)closestCaretRectInMarkedTextRangeForPoint:(CGPoint)point;
+- (void)collapseSelection;
+- (NSArray *)selectionRects;
+- (NSArray *)selectionRectsForRange:(DOMRange *)domRange;
+- (DOMRange *)wordAtPoint:(CGPoint)point;
+- (WebVisiblePosition *)webVisiblePositionForPoint:(CGPoint)point;
+- (void)setRangedSelectionBaseToCurrentSelection;
+- (void)setRangedSelectionBaseToCurrentSelectionStart;
+- (void)setRangedSelectionBaseToCurrentSelectionEnd;
+- (void)clearRangedSelectionInitialExtent;
+- (void)setRangedSelectionInitialExtentToCurrentSelectionStart;
+- (void)setRangedSelectionInitialExtentToCurrentSelectionEnd;
+- (BOOL)setRangedSelectionExtentPoint:(CGPoint)extentPoint baseIsStart:(BOOL)baseIsStart allowFlipping:(BOOL)allowFlipping;
+- (BOOL)setSelectionWithBasePoint:(CGPoint)basePoint extentPoint:(CGPoint)extentPoint baseIsStart:(BOOL)baseIsStart;
+- (BOOL)setSelectionWithBasePoint:(CGPoint)basePoint extentPoint:(CGPoint)extentPoint baseIsStart:(BOOL)baseIsStart allowFlipping:(BOOL)allowFlipping;
+- (void)setSelectionWithFirstPoint:(CGPoint)firstPoint secondPoint:(CGPoint)secondPoint;
+- (void)ensureRangedSelectionContainsInitialStartPoint:(CGPoint)initialStartPoint initialEndPoint:(CGPoint)initialEndPoint;
+
+- (void)smartExtendRangedSelection:(WebTextSmartExtendDirection)direction;
+- (void)aggressivelyExpandSelectionToWordContainingCaretSelection; // Doesn't accept no for an answer; expands past white space.
+
+- (WKWritingDirection)selectionBaseWritingDirection;
+- (void)toggleBaseWritingDirection;
+- (void)setBaseWritingDirection:(WKWritingDirection)direction;
+
+- (void)moveSelectionToStart;
+- (void)moveSelectionToEnd;
+
+- (void)setSelectionGranularity:(WebTextGranularity)granularity;
+- (void)setRangedSelectionWithExtentPoint:(CGPoint)point;
+
+- (WebVisiblePosition *)startPosition;
+- (WebVisiblePosition *)endPosition;
+
+- (BOOL)renderedCharactersExceed:(NSUInteger)threshold;
+
+- (CGImageRef)imageForNode:(DOMNode *)node allowDownsampling:(BOOL)allowDownsampling drawContentBehindTransparentNodes:(BOOL)drawContentBehindTransparentNodes;
+
+- (WebVisiblePosition *)previousUnperturbedDictationResultBoundaryFromPosition:(WebVisiblePosition *)position;
+- (WebVisiblePosition *)nextUnperturbedDictationResultBoundaryFromPosition:(WebVisiblePosition *)position;
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm b/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm
new file mode 100644 (file)
index 0000000..5dff6f0
--- /dev/null
@@ -0,0 +1,971 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebFrameIOS.h"
+
+#import <WebCore/Editor.h>
+#import <WebCore/Element.h>
+#import <WebCore/DocumentMarkerController.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameSelection.h>
+#import <WebCore/FrameSnapshottingMac.h>
+#import <WebCore/FrameView.h>
+#import <WebCore/HitTestResult.h>
+#import <WebCore/htmlediting.h>
+#import <WebCore/Position.h>
+#import <WebCore/Range.h>
+#import <WebCore/RenderObject.h>
+#import <WebCore/RenderText.h>
+#import <WebCore/SelectionRect.h>
+#import <WebCore/TextBoundaries.h>
+#import <WebCore/TextDirection.h>
+#import <WebCore/VisiblePosition.h>
+#import <WebCore/VisibleUnits.h>
+#import <WebKit/DOM.h>
+#import <WebKit/DOMRange.h>
+#import <WebKit/DOMUIKitExtensions.h>
+#import <WebKit/WebSelectionRect.h>
+#import <WebKit/WebVisiblePosition.h>
+#import <unicode/uchar.h>
+
+#import "DOMNodeInternal.h"
+#import "DOMRangeInternal.h"
+#import "WebFrameInternal.h"
+#import "WebUIKitDelegate.h"
+#import "WebViewPrivate.h"
+#import "WebVisiblePosition.h"
+#import "WebVisiblePositionInternal.h"
+
+using namespace WebCore;
+
+//-------------------
+
+@interface WebFrame (WebSecretsIKnowAbout)
+- (VisiblePosition)_visiblePositionForPoint:(CGPoint)point;
+@end
+
+@implementation WebFrame (WebFrameIOS)
+
+//-------------------
+
+- (WebCore::Frame *)coreFrame
+{
+    return _private->coreFrame;
+}
+
+- (VisiblePosition)visiblePositionForPoint:(CGPoint)point
+{
+    return [self _visiblePositionForPoint:point];
+}
+
+- (VisiblePosition)closestWordBoundary:(VisiblePosition)position
+{
+    VisiblePosition start = startOfWord(position);
+    VisiblePosition end = endOfWord(position);
+    int startDistance = position.deepEquivalent().deprecatedEditingOffset() - start.deepEquivalent().deprecatedEditingOffset();
+    int endDistance = end.deepEquivalent().deprecatedEditingOffset() - position.deepEquivalent().deprecatedEditingOffset() ;
+    return (startDistance < endDistance) ? start : end;    
+}
+
+//-------------------
+
+- (void)clearSelection
+{
+    Frame *frame = [self coreFrame];
+    if (frame)
+        frame->selection()->clearCurrentSelection();    
+    
+}
+
+- (WebTextSelectionState)selectionState
+{
+    WebTextSelectionState state;
+    
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    
+    if (!frameSelection) {
+        state = WebTextSelectionStateNone;
+    } else if (frameSelection->isCaret()) {
+        state = WebTextSelectionStateCaret;
+    } else if (frameSelection->isRange()) {
+        state = WebTextSelectionStateRange;
+    } else {
+        state = WebTextSelectionStateNone;
+    }
+    
+    return state;
+}
+
+
+- (BOOL)hasSelection
+{
+    WebTextSelectionState state = [self selectionState];
+    return state == WebTextSelectionStateCaret || state == WebTextSelectionStateRange;
+}
+
+- (CGRect)caretRectForPosition:(WebVisiblePosition *)position
+{
+    return position ? [position _visiblePosition].absoluteCaretBounds() : CGRectZero;
+}
+
+- (CGRect)closestCaretRectInMarkedTextRangeForPoint:(CGPoint)point
+{
+    Frame *frame = [self coreFrame];
+    Range *markedTextRange = frame->editor().compositionRange().get();
+    VisibleSelection markedTextRangeSelection = VisibleSelection(markedTextRange);
+
+    IntRect result;
+
+    if (markedTextRangeSelection.isRange()) {
+        VisiblePosition start(markedTextRangeSelection.start());
+        VisiblePosition end(markedTextRangeSelection.end());
+
+        // Adjust pos and give it an appropriate affinity.
+        VisiblePosition pos;
+        Vector<IntRect> intRects;
+        markedTextRange->textRects(intRects, NO);
+        unsigned size = intRects.size();
+        CGRect firstRect = intRects[0];
+        CGRect lastRect  = intRects[size-1];
+        if (point.y < firstRect.origin.y) {
+            point.y = firstRect.origin.y;
+            pos = [self visiblePositionForPoint:point];
+            pos.setAffinity(UPSTREAM);
+        }
+        else if (point.y >= lastRect.origin.y) {
+            point.y = lastRect.origin.y;
+            pos = [self visiblePositionForPoint:point];
+            pos.setAffinity(DOWNSTREAM);
+        }
+        else {
+            pos = [self visiblePositionForPoint:point];
+        }
+        
+        if (pos == start || pos < start) {
+            start.setAffinity(UPSTREAM);
+            //result = start.next().absoluteCaretBounds();
+            result = start.absoluteCaretBounds(); //<rdar://problem/6716185>: Allow placing the caaret to the left of the first character.
+        } else if (pos > end) {
+            end.setAffinity(DOWNSTREAM);
+            result = end.absoluteCaretBounds();
+        } else {
+            result = pos.absoluteCaretBounds();
+        }
+    } else {
+        VisiblePosition pos = [self visiblePositionForPoint:point];
+        result = pos.absoluteCaretBounds();
+    }
+    
+    return (CGRect) result;    
+}
+
+
+- (void)collapseSelection
+{
+    if ([self selectionState] == WebTextSelectionStateRange) {
+        Frame *frame = [self coreFrame];
+        FrameSelection* frameSelection = frame->selection();
+        VisiblePosition end(frameSelection->end());
+        frameSelection->moveTo(end);
+    }
+}
+
+- (void)extendSelection:(BOOL)start
+{
+    if ([self selectionState] == WebTextSelectionStateRange) {
+        Frame *frame = [self coreFrame];
+        FrameSelection* frameSelection = frame->selection();
+        if (start) {
+            VisiblePosition start = startOfWord(frameSelection->start());
+            frameSelection->moveTo(start, frameSelection->end());
+        } else {
+            VisiblePosition end = endOfWord(frameSelection->end());
+            frameSelection->moveTo(frameSelection->start(), end);
+        }
+    }    
+}
+
+- (NSArray *)selectionRectsForCoreRange:(Range *)range
+{
+    if (!range)
+        return nil;
+    
+    Vector<SelectionRect> rects;
+    range->collectSelectionRects(rects);
+    unsigned size = rects.size();
+    
+    NSMutableArray *result = [NSMutableArray arrayWithCapacity:size];
+    for (unsigned i = 0; i < size; i++) {
+        SelectionRect &coreRect = rects[i];
+        WebSelectionRect *webRect = [WebSelectionRect selectionRect];
+        webRect.rect = static_cast<CGRect>(coreRect.rect());
+        webRect.writingDirection = coreRect.direction() == LTR ? WKWritingDirectionLeftToRight : WKWritingDirectionRightToLeft;
+        webRect.isLineBreak = coreRect.isLineBreak();
+        webRect.isFirstOnLine = coreRect.isFirstOnLine();
+        webRect.isLastOnLine = coreRect.isLastOnLine();
+        webRect.containsStart = coreRect.containsStart();
+        webRect.containsEnd = coreRect.containsEnd();
+        webRect.isInFixedPosition = coreRect.isInFixedPosition();
+        webRect.isHorizontal = coreRect.isHorizontal();
+        [result addObject:webRect];
+    }
+    
+    return result;        
+}
+
+- (NSArray *)selectionRectsForRange:(DOMRange *)domRange
+{
+    return [self selectionRectsForCoreRange:core(domRange)];
+}
+
+- (NSArray *)selectionRects
+{
+    if (![self hasSelection])
+        return nil;
+
+    Frame *frame = [self coreFrame];
+    Range *range = frame->selection()->toNormalizedRange().get();
+    return [self selectionRectsForCoreRange:range];
+}
+
+- (DOMRange *)wordAtPoint:(CGPoint)point
+{
+    VisiblePosition pos = [self visiblePositionForPoint:point];
+    VisiblePosition start = startOfWord(pos);
+    VisiblePosition end = endOfWord(pos);
+    DOMRange *wordRange = kit(makeRange(start, end).get());
+    return wordRange;   
+}
+
+- (WebVisiblePosition *)webVisiblePositionForPoint:(CGPoint)point
+{
+    return [WebVisiblePosition _wrapVisiblePosition:[self visiblePositionForPoint:point]];
+}
+
+- (void)setRangedSelectionBaseToCurrentSelection
+{
+    Frame *frame = [self coreFrame];
+    frame->setRangedSelectionBaseToCurrentSelection();
+}
+
+- (void)setRangedSelectionBaseToCurrentSelectionStart
+{
+    Frame *frame = [self coreFrame];
+    frame->setRangedSelectionBaseToCurrentSelectionStart();
+}
+
+- (void)setRangedSelectionBaseToCurrentSelectionEnd
+{
+    Frame *frame = [self coreFrame];
+    frame->setRangedSelectionBaseToCurrentSelectionEnd();
+}
+
+- (void)clearRangedSelectionInitialExtent
+{
+    Frame *frame = [self coreFrame];
+    frame->clearRangedSelectionInitialExtent();
+}
+
+- (void)setRangedSelectionInitialExtentToCurrentSelectionStart
+{
+    Frame *frame = [self coreFrame];
+    frame->setRangedSelectionInitialExtentToCurrentSelectionStart();
+}
+
+- (void)setRangedSelectionInitialExtentToCurrentSelectionEnd
+{
+    Frame *frame = [self coreFrame];
+    frame->setRangedSelectionInitialExtentToCurrentSelectionEnd();
+}
+
+- (void)setRangedSelectionWithExtentPoint:(CGPoint)point
+{    
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition pos = [self visiblePositionForPoint:point];
+    VisibleSelection base = frame->rangedSelectionBase();
+    
+    if (pos.isNull() || !base.isRange())
+        return;
+    
+    VisiblePosition start(base.start());
+    VisiblePosition end(base.end());    
+    
+    if (pos < start) {        
+        frameSelection->moveTo(pos, end);
+    } 
+    else if (pos > end) {
+        frameSelection->moveTo(start, pos);
+    } 
+    else {
+        frameSelection->moveTo(start, end);
+    }
+}
+
+- (BOOL)setRangedSelectionExtentPoint:(CGPoint)extentPoint baseIsStart:(BOOL)baseIsStart allowFlipping:(BOOL)allowFlipping
+{
+    Frame *frame = [self coreFrame];
+    VisibleSelection rangedSelectionBase(frame->rangedSelectionBase());
+    VisiblePosition baseStart(rangedSelectionBase.start(), rangedSelectionBase.affinity());
+    VisiblePosition baseEnd;
+    if (rangedSelectionBase.isNone()) {
+        return baseIsStart;
+    }
+    else if (rangedSelectionBase.isCaret()) {
+        baseEnd = baseStart;
+    }
+    else {
+        baseEnd = VisiblePosition(rangedSelectionBase.end(), rangedSelectionBase.affinity());
+    }
+
+    VisiblePosition extent([self visiblePositionForPoint:extentPoint]);
+    
+    if (rangedSelectionBase.isRange() && baseStart < extent && extent < baseEnd) {
+        frame->selection()->moveTo(baseStart, baseEnd);
+        return NO;
+    }    
+    
+    CGRect caretRect = baseIsStart ? baseStart.absoluteCaretBounds() : baseEnd.absoluteCaretBounds();
+    CGPoint basePoint = CGPointMake(caretRect.origin.x, caretRect.origin.y);
+
+    static const CGFloat FlipMargin = 30;
+    bool didFlipStartEnd = false;
+    bool canFlipStartEnd = allowFlipping && 
+        (fabs(basePoint.x - extentPoint.x) > FlipMargin || fabs(basePoint.y - extentPoint.y) > FlipMargin);
+
+    VisiblePosition base;
+    if (baseIsStart) {                
+        base = baseStart;
+        BOOL wouldFlip = (extent < base);
+        if (wouldFlip) {
+            if (!canFlipStartEnd) {
+                // We're going to prevent flipping.  First try for a position on the same line.
+                // If that fails, just choose something after the start.
+                CGRect baseCaret = base.absoluteCaretBounds();
+                bool baseIsHorizontal = baseCaret.size.height > baseCaret.size.width;
+                CGPoint pointInLine = baseIsHorizontal ? CGPointMake(extentPoint.x, CGRectGetMidY(baseCaret)) :
+                                                         CGPointMake(CGRectGetMidX(baseCaret), extentPoint.y);
+                VisiblePosition positionInLine = [self visiblePositionForPoint:pointInLine];
+                if (positionInLine.isNotNull() && positionInLine > base) {
+                    extent = positionInLine;
+                } else {
+                    extent = base.next();
+                }
+            } else {
+                didFlipStartEnd = YES;
+            }
+        }
+        
+        if (base == extent)
+            extent = base.next();
+    }
+    else {
+        base = baseEnd;
+        BOOL wouldFlip = (extent > base);
+        if (wouldFlip) {
+            if (!canFlipStartEnd) {
+                // We're going to prevent flipping.  First try for a position on the same line.
+                // If that fails, just choose something before the end.
+                CGRect baseCaret = base.absoluteCaretBounds();
+                bool baseIsHorizontal = baseCaret.size.height > baseCaret.size.width;
+                CGPoint pointInLine = baseIsHorizontal ? CGPointMake(extentPoint.x, CGRectGetMidY(baseCaret)) :
+                                                         CGPointMake(CGRectGetMidX(baseCaret), extentPoint.y);
+                VisiblePosition positionInLine = [self visiblePositionForPoint:pointInLine];
+                if (positionInLine.isNotNull() && positionInLine < base) {
+                    extent = positionInLine;
+                } else {
+                    extent = base.previous();
+                }
+            } else {
+                didFlipStartEnd = YES;
+            }
+        }
+        
+        if (base == extent)
+            extent = base.previous();
+    }
+    
+    frame->selection()->moveTo(base, extent);
+
+    return didFlipStartEnd ? !baseIsStart : baseIsStart;
+}
+
+- (BOOL)setSelectionWithBasePoint:(CGPoint)basePoint extentPoint:(CGPoint)extentPoint baseIsStart:(BOOL)baseIsStart allowFlipping:(BOOL)allowFlipping
+{
+    // This function updates the selection using two points and an existing notion of
+    // which is the base and which is the extent. However, if the allowFlipping argument
+    // is YES, it will allow the base and extent positions to flip if the extent moves a
+    // certain amount to the "other side" of the base. When a flip of start/end occurs
+    // relative to base/extent,  this is reported back to the calling code, which is then
+    // expected to take the flip into account in subsequent calls to this function (for at
+    // least as long as a single, logical selection session continues).
+
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition base([self visiblePositionForPoint:basePoint]);
+    VisiblePosition extent([self visiblePositionForPoint:extentPoint]);
+
+    static const CGFloat FlipMargin = 30;
+    bool didFlipStartEnd = false;
+    bool canFlipStartEnd = allowFlipping &&
+                        ((baseIsStart &&  (extentPoint.x <= basePoint.x - FlipMargin || extentPoint.y <= basePoint.y - FlipMargin)) ||
+                         (!baseIsStart && (extentPoint.x >= basePoint.x + FlipMargin || extentPoint.y >= basePoint.y + FlipMargin)));
+    
+                        
+    if (extent == base) {
+        extent = baseIsStart ? base.next() : base.previous();
+    }
+    else if (baseIsStart && extent < base) {
+        if (canFlipStartEnd)
+            didFlipStartEnd = true;
+        else
+            extent = base.next();
+    }
+    else if (!baseIsStart && extent > base) {
+        if (canFlipStartEnd)
+            didFlipStartEnd = true;
+        else
+            extent = base.previous();
+    }
+
+    frameSelection->moveTo(base, extent);
+
+    return didFlipStartEnd ? !baseIsStart : baseIsStart;
+}
+
+- (BOOL)setSelectionWithBasePoint:(CGPoint)basePoint extentPoint:(CGPoint)extentPoint baseIsStart:(BOOL)baseIsStart
+{
+    return [self setSelectionWithBasePoint:basePoint extentPoint:extentPoint baseIsStart:baseIsStart allowFlipping:YES];
+}
+
+- (void)setSelectionWithFirstPoint:(CGPoint)firstPoint secondPoint:(CGPoint)secondPoint
+{
+    // We still support two-finger taps to make a selection, and these taps
+    // don't care about base/extent.
+    VisiblePosition first([self visiblePositionForPoint:firstPoint]);
+    VisiblePosition second([self visiblePositionForPoint:secondPoint]);
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    frameSelection->moveTo(first, second);
+}
+
+- (void)ensureRangedSelectionContainsInitialStartPoint:(CGPoint)initialStartPoint initialEndPoint:(CGPoint)initialEndPoint
+{
+    // This method ensures that selection ends doesn't contract such that it no
+    // longer contains these points. This is the desirable behavior when the
+    // user does the tap-and-a-half + drag operation.
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    Position ensureStart([self visiblePositionForPoint:initialStartPoint].deepEquivalent());
+    Position ensureEnd([self visiblePositionForPoint:initialEndPoint].deepEquivalent());
+    if (frameSelection->start() > ensureStart) {
+        frameSelection->moveTo(ensureStart, frameSelection->end());
+    }
+    else if (frameSelection->end() < ensureEnd) {
+        frameSelection->moveTo(frameSelection->start(), ensureEnd);
+    }
+}
+
+- (void)aggressivelyExpandSelectionToWordContainingCaretSelection
+{
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition end(frameSelection->end());
+    if (end == endOfDocument(end) && end != startOfDocument(end) && end == startOfLine(end)) {
+        frameSelection->moveTo(end.previous(), end);
+    }
+
+    [self expandSelectionToWordContainingCaretSelection];
+
+    // This is a temporary hack until we get the improvements
+    // I'm working on for RTL selection.
+    if (frameSelection->granularity() == WordGranularity) {
+        frameSelection->moveTo(frameSelection->start(), frameSelection->end());
+    }
+    
+    if (frameSelection->isCaret()) {
+        VisiblePosition pos(frameSelection->end());
+        if (isStartOfLine(pos) && isEndOfLine(pos)) {
+            VisiblePosition next(pos.next());
+            if (next.isNotNull()) {
+                frameSelection->moveTo(end, next);
+            }
+        }
+        else {
+            while (pos.isNotNull()) {
+                VisiblePosition wordStart(startOfWord(pos));
+                if (wordStart != pos) {
+                    frameSelection->moveTo(wordStart, frameSelection->end());
+                    break;
+                }
+                pos = pos.previous();
+            }
+        }
+    }
+}
+
+- (void)expandSelectionToSentence
+{
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition pos = frameSelection->start();
+    VisiblePosition start = startOfSentence(pos);
+    VisiblePosition end = endOfSentence(pos);
+    frameSelection->moveTo(start, end);    
+}
+
+- (WKWritingDirection)selectionBaseWritingDirection
+{
+    Frame *frame = [self coreFrame];
+    switch (frame->editor().baseWritingDirectionForSelectionStart()) {
+    case LeftToRightWritingDirection:
+        return WKWritingDirectionLeftToRight;
+
+    case RightToLeftWritingDirection:
+        return WKWritingDirectionRightToLeft;
+
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+    return WKWritingDirectionLeftToRight;
+}
+
+- (void)toggleBaseWritingDirection
+{
+    WKWritingDirection updated = WKWritingDirectionRightToLeft;
+    switch ([self selectionBaseWritingDirection]) {
+        case WKWritingDirectionLeftToRight:
+            updated = WKWritingDirectionRightToLeft;
+            break;
+        case WKWritingDirectionRightToLeft:
+            updated = WKWritingDirectionLeftToRight;
+            break;
+        default:
+            // WebCore should never return anything else, including WKWritingDirectionNatural
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    [self setBaseWritingDirection:updated];
+}
+
+- (void)setBaseWritingDirection:(WKWritingDirection)direction
+{
+    WKWritingDirection originalDirection = [self selectionBaseWritingDirection];
+
+    Frame *frame = [self coreFrame];
+    if (!frame->selection()->isContentEditable())
+        return;
+    
+    WritingDirection wcDirection = LeftToRightWritingDirection;
+    switch (direction) {
+        case WKWritingDirectionNatural:
+            wcDirection = NaturalWritingDirection;
+            break;
+        case WKWritingDirectionLeftToRight:
+            wcDirection = LeftToRightWritingDirection;
+            break;
+        case WKWritingDirectionRightToLeft:
+            wcDirection = RightToLeftWritingDirection;
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    frame->editor().setBaseWritingDirection(wcDirection);
+    
+    if (originalDirection != [self selectionBaseWritingDirection])
+        frame->editor().setTextAlignmentForChangedBaseWritingDirection(wcDirection);
+}
+
+- (void)moveSelectionToStart
+{
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition start = startOfDocument(frameSelection->selection().start());
+    frameSelection->moveTo(start);
+}
+
+- (void)moveSelectionToEnd
+{
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition end =  endOfDocument(frameSelection->selection().end());
+    frameSelection->moveTo(end);
+}
+
+- (void)moveSelectionToPoint:(CGPoint)point
+{
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    VisiblePosition pos = [self _visiblePositionForPoint:point];
+    frameSelection->moveTo(pos);
+}
+
+- (void)setSelectionGranularity:(WebTextGranularity)granularity
+{
+    TextGranularity wcGranularity = CharacterGranularity;
+    switch (granularity) {
+        case WebTextGranularityCharacter:
+            wcGranularity = CharacterGranularity;
+            break;
+        case WebTextGranularityWord:
+            wcGranularity = WordGranularity;
+            break;
+        case WebTextGranularitySentence:
+            wcGranularity = SentenceGranularity;
+            break;
+        case WebTextGranularityParagraph:
+            wcGranularity = ParagraphGranularity;
+            break;
+        case WebTextGranularityAll:
+            // FIXME: Add DocumentGranularity.
+            wcGranularity = ParagraphGranularity;
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    FrameSelection* frameSelection = _private->coreFrame->selection();
+    frameSelection->setSelection(frameSelection->selection(), wcGranularity);
+}
+
+static inline bool isAlphaNumericCharacter(UChar32 c)
+{
+    static CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric);
+    return CFCharacterSetIsCharacterMember(set, c);
+}
+
+static VisiblePosition SimpleSmartExtendStart(const VisiblePosition& start, const VisiblePosition& end, const VisibleSelection& initialExtent)
+{
+    VisiblePosition pos(start);
+    VisiblePosition initialStart;
+    if (initialExtent.isCaretOrRange())
+        initialStart = VisiblePosition(initialExtent.start(), initialExtent.affinity());
+
+    if (initialStart == start) {
+        // No smarts needed. Leave selection where it is.
+        return pos;
+    }
+
+    UChar32 charBefore = pos.characterBefore();
+    UChar32 charAfter = pos.characterAfter();
+    if (isAlphaNumericCharacter(charAfter) && !isAlphaNumericCharacter(charBefore)) {
+        // This is a word start. Leave selection where it is.
+        return pos;
+    }
+    
+    if (isAlphaNumericCharacter(charBefore) && !isAlphaNumericCharacter(charAfter)) {
+        // This is a word end. Nudge the selection to the next character before proceeding.
+        pos = pos.next();
+    }
+
+    // Extend to the start of the word.
+    // If this isn't where the start was initially, use this position.
+    VisiblePosition wordStart(startOfWord(pos));
+    if (wordStart != initialStart) {
+        return wordStart;
+    }
+    // Conversely, if the initial start equals the current word start, then
+    // run the rest of this function to see if the selection should extend
+    // back to the next word.
+
+    // Passed-in end must be at least three characters from initialStart or
+    // must cross word boundary.
+    // If this is where the start was initially, skip to the end of the word,
+    // then iterate forward in the document until we hit an alphanumeric.
+    VisiblePosition wordEnd(endOfWord(pos));
+    pos = wordEnd;
+    while (pos.isNotNull() && !isStartOfLine(pos) && !isEndOfLine(pos) && pos != end) {
+        UChar32 c = pos.characterAfter();
+        if (isAlphaNumericCharacter(c))
+            break;
+        pos = pos.next();
+    }
+    
+    // Don't let the smart extension make the start equal the end.
+    // Expand out to word boundary.
+    if (pos == end)
+        pos = wordStart;
+    return pos;
+}
+
+static VisiblePosition SimpleSmartExtendEnd(const VisiblePosition& start, const VisiblePosition& end, const VisibleSelection& initialExtent)
+{
+    VisiblePosition pos(end);
+
+    VisiblePosition initialEnd;
+    if (initialExtent.isCaretOrRange())
+        initialEnd = VisiblePosition(initialExtent.end(), initialExtent.affinity());
+    
+    if (initialEnd == end) {
+        // No smarts needed. Leave selection where it is.
+        return pos;
+    }
+    
+    UChar32 charBefore = pos.characterBefore();
+    UChar32 charAfter = pos.characterAfter();
+    if (isAlphaNumericCharacter(charBefore) && !isAlphaNumericCharacter(charAfter)) {
+        // This is a word end. Leave selection where it is.
+        return pos;
+    }
+
+    if (!isAlphaNumericCharacter(charBefore) && isAlphaNumericCharacter(charAfter)) {
+        // This is a word start. Nudge the selection to the previous character before proceeding.
+        pos = pos.previous();
+    }
+
+    // Extend to the end of the word.
+    // If this isn't where the end was initially, use this position.
+    VisiblePosition wordEnd(endOfWord(pos));
+    if (wordEnd != initialEnd && isAlphaNumericCharacter(wordEnd.characterBefore())) {
+        return wordEnd;
+    }
+    // Conversely, if the initial end equals the current word end, then
+    // run the rest of this function to see if the selection should extend
+    // back to the previous word.
+
+    // If this is where the end was initially, skip to the start of the word,
+    // then iterate backward in the document until we hit an alphanumeric.
+    VisiblePosition wordStart(startOfWord(pos));
+    pos = wordStart;
+    while (pos.isNotNull() && !isStartOfLine(pos) && !isEndOfLine(pos) && pos != start) {
+        UChar32 c = pos.characterBefore();
+        if (isAlphaNumericCharacter(c))
+            break;
+        pos = pos.previous();
+    }
+
+    // Don't let the smart extension make the end equal the start.
+    // Expand out to word boundary.
+    if (pos == start)
+        pos = wordEnd;
+    
+    return pos;
+}
+
+- (void)smartExtendRangedSelection:(WebTextSmartExtendDirection)direction
+{
+    if ([self selectionState] != WebTextSelectionStateRange)
+        return;
+    
+    Frame *frame = [self coreFrame];
+    FrameSelection* frameSelection = frame->selection();
+    EAffinity affinity = frameSelection->selection().affinity();
+    VisiblePosition start(frameSelection->start(), affinity);
+    VisiblePosition end(frameSelection->end(), affinity);
+    VisiblePosition base(frame->rangedSelectionBase().base());  // should equal start or end
+
+    // Base must equal start or end
+    if (base != start && base != end)
+        return;
+
+    VisiblePosition extent(frameSelection->selection().extent(), affinity);
+    
+    // We don't yet support smart extension for languages which
+    // require context for word boundary.
+    if (requiresContextForWordBoundary(extent.characterAfter()) || 
+        requiresContextForWordBoundary(extent.characterBefore()))
+        return;
+
+    // If the smart-extend direction is neither left nor right, do
+    // not pass rangedSelectionInitialExtent to the smart extend functions.
+    // This will have the effect of always extending out to include the
+    // word which contains the extent.
+    VisibleSelection initialExtent;
+    if (direction != WebTextSmartExtendDirectionNone)
+        initialExtent = frame->rangedSelectionInitialExtent();
+
+    VisiblePosition smartExtent;
+    if (base == end) {  // extend start
+        smartExtent = SimpleSmartExtendStart(start, end, initialExtent);
+    }
+    else {  // base == start / extend end
+        smartExtent = SimpleSmartExtendEnd(start, end, initialExtent);
+    }
+
+    if (smartExtent.isNotNull() && smartExtent != extent)
+        frameSelection->moveTo(base, smartExtent);
+
+}
+
+- (WebVisiblePosition *)startPosition
+{
+    Frame *frame = [self coreFrame];
+    Element *rootElement = frame->document()->documentElement();
+    return [WebVisiblePosition _wrapVisiblePosition:startOfDocument(static_cast<Node*>(rootElement))];
+}
+
+- (WebVisiblePosition *)endPosition
+{
+    Frame *frame = [self coreFrame];
+    Element *rootElement = frame->document()->documentElement();
+    return [WebVisiblePosition _wrapVisiblePosition:endOfDocument(static_cast<Node*>(rootElement))];
+}
+
+- (BOOL)renderedCharactersExceed:(NSUInteger)threshold
+{
+    Frame *frame = [self coreFrame];
+    return frame->view()->renderedCharactersExceed(threshold);
+}
+
+- (CGImageRef)imageForNode:(DOMNode *)node allowDownsampling:(BOOL)allowDownsampling drawContentBehindTransparentNodes:(BOOL)drawContentBehindTransparentNodes
+{
+    Node* coreNode = core(node);
+    Frame* frame = [self coreFrame];
+    NodeImageFlags flags = DrawNormally;
+    if (allowDownsampling)
+        flags |= AllowDownsampling;
+    if (drawContentBehindTransparentNodes)
+        flags |= DrawContentBehindTransparentNodes;
+    if (coreNode)
+        return nodeImage(frame, coreNode, flags);
+    return NULL;
+}
+
+// Iterates backward through the document and returns the point at which untouched dictation results end.
+- (WebVisiblePosition *)previousUnperturbedDictationResultBoundaryFromPosition:(WebVisiblePosition *)position
+{
+    VisiblePosition currentVisiblePosition = [position _visiblePosition];
+    if (currentVisiblePosition.isNull())
+        return position;
+    
+    Document* document = currentVisiblePosition.deepEquivalent().anchorNode()->document();
+    if (!document)
+        return position;
+    
+    id uikitDelegate = [[self webView] _UIKitDelegate];
+    if (![uikitDelegate respondsToSelector:@selector(isUnperturbedDictationResultMarker:)])
+        return position;
+    
+    while (currentVisiblePosition.isNotNull()) {
+        WebVisiblePosition *currentWebVisiblePosition = [WebVisiblePosition _wrapVisiblePosition:currentVisiblePosition];
+        
+        Node *currentNode = currentVisiblePosition.deepEquivalent().anchorNode();
+        int lastOffset = lastOffsetForEditing(currentNode);
+        ASSERT(lastOffset >= 0);
+        if (lastOffset < 0)
+            return currentWebVisiblePosition;
+        
+        VisiblePosition previousVisiblePosition = currentVisiblePosition.previous();
+        if (previousVisiblePosition.isNull())
+            return currentWebVisiblePosition;
+        
+        RefPtr<Range> graphemeRange = Range::create(document, previousVisiblePosition.deepEquivalent(), currentVisiblePosition.deepEquivalent());
+        
+        Vector<DocumentMarker*> markers = document->markers()->markersInRange(graphemeRange.get(), DocumentMarker::DictationResult);
+        if (markers.isEmpty())
+            return currentWebVisiblePosition;
+        
+        // FIXME: Result markers should not overlap, so there should only ever be one for a single grapheme.
+        // <rdar://problem/9810617> Too much document context is omitted when sending dictation hints because of problems with WebCore DocumentMarkers
+        // ASSERT(markers.size() == 1);
+        if (markers.size() > 1)
+            return currentWebVisiblePosition;
+        DocumentMarker* resultMarker = markers.at(0);
+        
+        // FIXME: WebCore doesn't always update markers correctly during editing. Bail if resultMarker extends off the edge of 
+        // this node, because that means it's invalid.
+        if (resultMarker->endOffset() > (unsigned)lastOffset)
+            return currentWebVisiblePosition;
+        
+        if (![uikitDelegate isUnperturbedDictationResultMarker:resultMarker->metadata()])
+            return currentWebVisiblePosition;
+        
+        if (resultMarker->startOffset() > 0)
+            return [WebVisiblePosition _wrapVisiblePosition:VisiblePosition(createLegacyEditingPosition(currentNode, resultMarker->startOffset()))];
+        
+        currentVisiblePosition = VisiblePosition(createLegacyEditingPosition(currentNode, 0));
+    }
+    
+    return position;
+}
+
+// Iterates forward through the document and returns the point at which untouched dictation results end.
+- (WebVisiblePosition *)nextUnperturbedDictationResultBoundaryFromPosition:(WebVisiblePosition *)position
+{
+    VisiblePosition currentVisiblePosition = [position _visiblePosition];
+    if (currentVisiblePosition.isNull())
+        return position;
+    
+    Document* document = currentVisiblePosition.deepEquivalent().anchorNode()->document();
+    if (!document)
+        return position;
+    
+    id uikitDelegate = [[self webView] _UIKitDelegate];
+    if (![uikitDelegate respondsToSelector:@selector(isUnperturbedDictationResultMarker:)])
+        return position;
+    
+    while (currentVisiblePosition.isNotNull()) {
+        WebVisiblePosition *currentWebVisiblePosition = [WebVisiblePosition _wrapVisiblePosition:currentVisiblePosition];
+        
+        Node *currentNode = currentVisiblePosition.deepEquivalent().anchorNode();
+        int lastOffset = lastOffsetForEditing(currentNode);
+        ASSERT(lastOffset >= 0);
+        if (lastOffset < 0)
+            return currentWebVisiblePosition;
+        
+        VisiblePosition nextVisiblePosition = currentVisiblePosition.next();
+        if (nextVisiblePosition.isNull())
+            return currentWebVisiblePosition;
+        
+        RefPtr<Range> graphemeRange = Range::create(document, currentVisiblePosition.deepEquivalent(), nextVisiblePosition.deepEquivalent());
+        
+        Vector<DocumentMarker*> markers = document->markers()->markersInRange(graphemeRange.get(), DocumentMarker::DictationResult);
+        if (markers.isEmpty())
+            return currentWebVisiblePosition;
+        
+        // FIXME: Result markers should not overlap, so there should only ever be one for a single grapheme.
+        // <rdar://problem/9810617> Too much document context is omitted when sending dictation hints because of problems with WebCore DocumentMarkers
+        //ASSERT(markers.size() == 1);
+        if (markers.size() > 1)
+            return currentWebVisiblePosition;
+        DocumentMarker* resultMarker = markers.at(0);
+        
+        // FIXME: WebCore doesn't always update markers correctly during editing. Bail if resultMarker extends off the edge of 
+        // this node, because that means it's invalid.
+        if (resultMarker->endOffset() > static_cast<unsigned>(lastOffset))
+            return currentWebVisiblePosition;
+        
+        if (![uikitDelegate isUnperturbedDictationResultMarker:resultMarker->metadata()])
+            return currentWebVisiblePosition;
+        
+        if (resultMarker->endOffset() <= static_cast<unsigned>(lastOffset))
+            return [WebVisiblePosition _wrapVisiblePosition:VisiblePosition(createLegacyEditingPosition(currentNode, resultMarker->endOffset()))];
+        
+        currentVisiblePosition = VisiblePosition(createLegacyEditingPosition(currentNode, lastOffset));
+    }
+    
+    return position;
+}
+
+@end
+
+#endif  // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebFrameIPhone.h b/Source/WebKit/ios/WebCoreSupport/WebFrameIPhone.h
new file mode 100644 (file)
index 0000000..3733c92
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WebFrameIOS.h>
diff --git a/Source/WebKit/ios/WebCoreSupport/WebGeolocation.mm b/Source/WebKit/ios/WebCoreSupport/WebGeolocation.mm
new file mode 100644 (file)
index 0000000..dac61c1
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebGeolocationInternal.h"
+#import <WebCore/Geolocation.h>
+
+using namespace WebCore;
+
+@implementation WebGeolocation (WebInternal)
+
+- (id)_initWithWebCoreGeolocation:(WebCoreGeolocation *)geolocation
+{
+    ASSERT(geolocation);
+
+    self = [super init];
+    if (self) {
+        geolocation->ref();
+        _private = reinterpret_cast<WebGeolocationPrivate*>(geolocation);
+    }
+    return self;
+}
+
+@end
+
+@implementation WebGeolocation
+
+- (void)setIsAllowed:(BOOL)allowed
+{
+    reinterpret_cast<Geolocation*>(_private)->setIsAllowed(allowed);
+}
+
+- (void)dealloc
+{
+    if (_private)
+        reinterpret_cast<Geolocation*>(_private)->deref();
+    [super dealloc];
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebGeolocationInternal.h b/Source/WebKit/ios/WebCoreSupport/WebGeolocationInternal.h
new file mode 100644 (file)
index 0000000..909dd29
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "WebGeolocationPrivate.h"
+
+namespace WebCore {
+class Geolocation;
+}
+
+typedef WebCore::Geolocation WebCoreGeolocation;
+
+@interface WebGeolocation (WebInternal)
+
+- (id)_initWithWebCoreGeolocation:(WebCoreGeolocation *)geolocation;
+
+@end
diff --git a/Source/WebKit/ios/WebCoreSupport/WebGeolocationPrivate.h b/Source/WebKit/ios/WebCoreSupport/WebGeolocationPrivate.h
new file mode 100644 (file)
index 0000000..1663040
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import <Foundation/Foundation.h>
+
+@class WebGeolocationPrivate;
+
+@interface WebGeolocation : NSObject {
+@private
+    WebGeolocationPrivate *_private;
+}
+
+- (void)setIsAllowed:(BOOL)allowed;
+@end
diff --git a/Source/WebKit/ios/WebCoreSupport/WebMIMETypeRegistry.h b/Source/WebKit/ios/WebCoreSupport/WebMIMETypeRegistry.h
new file mode 100644 (file)
index 0000000..5e2d0cd
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <Foundation/Foundation.h>
+
+@interface WebMIMETypeRegistry : NSObject
+
++ (NSString *)mimeTypeForExtension:(NSString *)extension;
+
++ (NSString *)preferredExtensionForMIMEType:(NSString *)mimeType;
+
+// Check to see if a mime type is suitable for being loaded inline as an
+// image (e.g., <img> tags).
++ (BOOL)isSupportedImageMIMEType:(NSString *)mimeType;
+
+// Check to see if a mime type is suitable for being loaded using <video> and <audio>
++ (BOOL)isSupportedMediaMIMEType:(NSString *)mimeType;
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebMIMETypeRegistry.mm b/Source/WebKit/ios/WebCoreSupport/WebMIMETypeRegistry.mm
new file mode 100644 (file)
index 0000000..4a96d0b
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebMIMETypeRegistry.h"
+
+#import <WebCore/MIMETypeRegistry.h>
+
+using WebCore::MIMETypeRegistry;
+
+@implementation WebMIMETypeRegistry
+
++ (NSString *)mimeTypeForExtension:(NSString *)extension
+{
+    return MIMETypeRegistry::getMIMETypeForExtension(extension);
+}
+
++ (NSString *)preferredExtensionForMIMEType:(NSString *)mimeType
+{
+    return MIMETypeRegistry::getPreferredExtensionForMIMEType(mimeType);
+}
+
++ (BOOL)isSupportedImageMIMEType:(NSString *)mimeType
+{
+    return MIMETypeRegistry::isSupportedImageMIMEType(mimeType);
+}
+
++ (BOOL)isSupportedMediaMIMEType:(NSString *)mimeType
+{
+    return MIMETypeRegistry::isSupportedMediaMIMEType(mimeType);
+}
+
+@end
+
+#endif  // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebSelectionRect.h b/Source/WebKit/ios/WebCoreSupport/WebSelectionRect.h
new file mode 100644 (file)
index 0000000..2af11dd
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <Foundation/Foundation.h>
+#import <WebKit/WebFrameIOS.h>
+
+@interface WebSelectionRect : NSObject <NSCopying> {
+    CGRect m_rect;
+    WKWritingDirection m_writingDirection;
+    BOOL m_isLineBreak;
+    BOOL m_isFirstOnLine;
+    BOOL m_isLastOnLine;
+    BOOL m_containsStart;
+    BOOL m_containsEnd;
+    BOOL m_isInFixedPosition;
+    BOOL m_isHorizontal;
+}
+
+@property (nonatomic, assign) CGRect rect;
+@property (nonatomic, assign) WKWritingDirection writingDirection;
+@property (nonatomic, assign) BOOL isLineBreak;
+@property (nonatomic, assign) BOOL isFirstOnLine;
+@property (nonatomic, assign) BOOL isLastOnLine;
+@property (nonatomic, assign) BOOL containsStart;
+@property (nonatomic, assign) BOOL containsEnd;
+@property (nonatomic, assign) BOOL isInFixedPosition;
+@property (nonatomic, assign) BOOL isHorizontal;
+
++ (WebSelectionRect *)selectionRect;
+
++ (CGRect)startEdge:(NSArray *)rects;
++ (CGRect)endEdge:(NSArray *)rects;
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebSelectionRect.m b/Source/WebKit/ios/WebCoreSupport/WebSelectionRect.m
new file mode 100644 (file)
index 0000000..8a021f9
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebSelectionRect.h"
+
+@implementation WebSelectionRect
+
+@synthesize rect = m_rect;
+@synthesize writingDirection = m_writingDirection;
+@synthesize isLineBreak = m_isLineBreak;
+@synthesize isFirstOnLine = m_isFirstOnLine;
+@synthesize isLastOnLine = m_isLastOnLine;
+@synthesize containsStart = m_containsStart;
+@synthesize containsEnd = m_containsEnd;
+@synthesize isInFixedPosition = m_isInFixedPosition;
+@synthesize isHorizontal = m_isHorizontal;
+
++ (WebSelectionRect *)selectionRect
+{
+    return [[[self alloc] init] autorelease];
+}
+
++ (CGRect)startEdge:(NSArray *)rects
+{
+    if (rects.count == 0)
+        return CGRectZero;
+
+    WebSelectionRect *selectionRect = nil;
+    for (WebSelectionRect *srect in rects) {
+        if (srect.containsStart) {
+            selectionRect = srect;
+            break;
+        }
+    }
+    if (!selectionRect)
+        selectionRect = [rects objectAtIndex:0];
+    
+    CGRect rect = selectionRect.rect;
+    
+    if (!selectionRect.isHorizontal) {
+        switch (selectionRect.writingDirection) {
+            case WKWritingDirectionNatural:
+            case WKWritingDirectionLeftToRight:
+                // collapse to top edge
+                rect.size.height = 1;
+                break;
+            case WKWritingDirectionRightToLeft:
+                // collapse to bottom edge
+                rect.origin.y += (rect.size.height - 1);
+                rect.size.height = 1;
+                break;
+        }
+        return rect;
+    }
+    
+    switch (selectionRect.writingDirection) {
+        case WKWritingDirectionNatural:
+        case WKWritingDirectionLeftToRight:
+            // collapse to left edge
+            rect.size.width = 1;
+            break;
+        case WKWritingDirectionRightToLeft:
+            // collapse to right edge
+            rect.origin.x += (rect.size.width - 1);
+            rect.size.width = 1;
+            break;
+    }
+    return rect;
+}
+
++ (CGRect)endEdge:(NSArray *)rects
+{
+    if (rects.count == 0)
+        return CGRectZero;
+
+    WebSelectionRect *selectionRect = nil;
+    for (WebSelectionRect *srect in rects) {
+        if (srect.containsEnd) {
+            selectionRect = srect;
+            break;
+        }
+    }
+    if (!selectionRect)
+        selectionRect = [rects lastObject];
+
+    CGRect rect = selectionRect.rect;
+    
+    if (!selectionRect.isHorizontal) {
+        switch (selectionRect.writingDirection) {
+            case WKWritingDirectionNatural:
+            case WKWritingDirectionLeftToRight:
+                // collapse to bottom edge
+                rect.origin.y += (rect.size.height - 1);
+                rect.size.height = 1;
+                break;
+            case WKWritingDirectionRightToLeft:
+                // collapse to top edge
+                rect.size.height = 1;
+                break;
+        }
+        return rect;
+    }
+    
+    switch (selectionRect.writingDirection) {
+        case WKWritingDirectionNatural:
+        case WKWritingDirectionLeftToRight:
+            // collapse to right edge
+            rect.origin.x += (rect.size.width - 1);
+            rect.size.width = 1;
+            break;
+        case WKWritingDirectionRightToLeft:
+            // collapse to left edge
+            rect.size.width = 1;
+            break;
+    }
+    return rect;
+}
+
+- (id)init
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    
+    self.rect = CGRectZero;
+    self.writingDirection = WKWritingDirectionLeftToRight;
+    self.isLineBreak = NO;
+    self.isFirstOnLine = NO;
+    self.isLastOnLine = NO;
+    self.containsStart = NO;
+    self.containsEnd = NO;
+    self.isInFixedPosition = NO;
+    self.isHorizontal = NO;
+    
+    return self;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+    WebSelectionRect *copy = [[WebSelectionRect selectionRect] retain];
+    copy.rect = self.rect;
+    copy.writingDirection = self.writingDirection;
+    copy.isLineBreak = self.isLineBreak;
+    copy.isFirstOnLine = self.isFirstOnLine;
+    copy.isLastOnLine = self.isLastOnLine;
+    copy.containsStart = self.containsStart;
+    copy.containsEnd = self.containsEnd;
+    copy.isInFixedPosition = self.isInFixedPosition;
+    copy.isHorizontal = self.isHorizontal;
+    return copy;
+}
+
+- (NSString *)description
+{
+    return [NSString stringWithFormat:@"<WebSelectionRect: %p> : { %.1f,%.1f,%.1f,%.1f } %@%@%@%@%@%@%@%@",
+        self, 
+        self.rect.origin.x, self.rect.origin.y, self.rect.size.width, self.rect.size.height,
+        self.writingDirection == WKWritingDirectionLeftToRight ? @"[LTR]" : @"[RTL]",
+        self.isLineBreak ? @" [BR]" : @"",
+        self.isFirstOnLine ? @" [FIRST]" : @"",
+        self.isLastOnLine ? @" [LAST]" : @"",
+        self.containsStart ? @" [START]" : @"",
+        self.containsEnd ? @" [END]" : @"",
+        self.isInFixedPosition ? @" [FIXED]" : @"",
+        !self.isHorizontal ? @" [VERTICAL]" : @""];
+}
+
+@end
+
+#endif  // PLATFORM(IOS)
diff --git a/Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.h b/Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.h
new file mode 100644 (file)
index 0000000..91fb9c3
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009   Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit/DOMUIKitExtensions.h>
+
+#import <WebKit/WAKAppKitStubs.h>
+
+typedef struct WebObjectInternal WebObjectInternal;
+
+typedef enum {
+    WebTextGranularityCharacter,
+    WebTextGranularityWord,
+    WebTextGranularitySentence,
+    WebTextGranularityParagraph,
+    WebTextGranularityLine,
+    WebTextGranularityAll,
+} WebTextGranularity;
+
+@interface WebVisiblePosition : NSObject {
+@private
+    WebObjectInternal *_internal;
+}
+
+@property (nonatomic) NSSelectionAffinity affinity;
+
+- (NSComparisonResult)compare:(WebVisiblePosition *)other;
+- (int)distanceFromPosition:(WebVisiblePosition *)other;
+- (WebVisiblePosition *)positionByMovingInDirection:(WebTextAdjustmentDirection)direction amount:(UInt32)amount;
+- (WebVisiblePosition *)positionByMovingInDirection:(WebTextAdjustmentDirection)direction amount:(UInt32)amount withAffinityDownstream:(BOOL)affinityDownstream;
+
+// Returnes YES only if a position is at a boundary of a text unit of the specified granularity in the particular direction.
+- (BOOL)atBoundaryOfGranularity:(WebTextGranularity)granularity inDirection:(WebTextAdjustmentDirection)direction;
+
+// Returns the next boundary position of a text unit of the given granularity in the given direction, or nil if there is no such position.
+- (WebVisiblePosition *)positionOfNextBoundaryOfGranularity:(WebTextGranularity)granularity inDirection:(WebTextAdjustmentDirection)direction;
+
+// Returns YES if position is within a text unit of the given granularity. If the position is at a boundary, returns YES only if
+// if the boundary is part of the text unit in the given direction.
+- (BOOL)withinTextUnitOfGranularity:(WebTextGranularity)granularity inDirectionIfAtBoundary:(WebTextAdjustmentDirection)direction;
+
+// Returns range of the enclosing text unit of the given granularity, or nil if there is no such enclosing unit. Whether a boundary position
+// is enclosed depends on the given direction, using the same rule as -[WebVisiblePosition withinTextUnitOfGranularity:inDirectionAtBoundary:].
+- (DOMRange *)enclosingTextUnitOfGranularity:(WebTextGranularity)granularity inDirectionIfAtBoundary:(WebTextAdjustmentDirection)direction;
+
+// Uses fine-tuned logic originally from WebCore::Frame::moveSelectionToStartOrEndOfCurrentWord
+- (WebVisiblePosition *)positionAtStartOrEndOfWord;
+
+- (BOOL)isEditable;
+- (BOOL)requiresContextForWordBoundary;
+- (BOOL)atAlphaNumericBoundaryInDirection:(WebTextAdjustmentDirection)direction;
+
+- (DOMRange *)enclosingRangeWithDictationPhraseAlternatives:(NSArray **)alternatives;
+- (DOMRange *)enclosingRangeWithCorrectionIndicator;
+
+@end
+
+@interface DOMRange (VisiblePositionExtensions)
+
+- (WebVisiblePosition *)startPosition;
+- (WebVisiblePosition *)endPosition;
++ (DOMRange *)rangeForFirstPosition:(WebVisiblePosition *)first second:(WebVisiblePosition *)second;
+
+// Uses fine-tuned logic from SelectionController::wordSelectionContainingCaretSelection
+- (DOMRange *)enclosingWordRange;
+
+@end
+
+@interface DOMNode (VisiblePositionExtensions)
+
+- (WebVisiblePosition *)startPosition;
+- (WebVisiblePosition *)endPosition;
+
+@end
diff --git a/Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.mm b/Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.mm
new file mode 100644 (file)
index 0000000..e8482db
--- /dev/null
@@ -0,0 +1,636 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import "WebVisiblePosition.h"
+#import "WebVisiblePositionInternal.h"
+
+#import <WebCore/DocumentMarkerController.h>
+#import <WebCore/FrameSelection.h>
+#import <WebCore/HTMLTextFormControlElement.h>
+#import <WebCore/Node.h>
+#import <WebCore/Position.h>
+#import <WebCore/Range.h>
+#import <WebCore/RenderTextControl.h>
+#import <WebCore/TextBoundaries.h>
+#import <WebCore/TextDirection.h>
+#import <WebCore/TextGranularity.h>
+#import <WebCore/TextIterator.h>
+#import <WebCore/VisiblePosition.h>
+#import <WebCore/VisibleUnits.h>
+#import <WebCore/htmlediting.h>
+
+
+#import "DOMNodeInternal.h"
+#import "DOMRangeInternal.h"
+
+using namespace WebCore;
+
+//-------------------
+
+@implementation WebVisiblePosition (Internal)
+
+// Since VisiblePosition isn't refcounted, we have to use new and delete on a copy.
+
++ (WebVisiblePosition *)_wrapVisiblePosition:(VisiblePosition)visiblePosition
+{
+    WebVisiblePosition *vp = [[WebVisiblePosition alloc] init];
+    VisiblePosition *copy = new VisiblePosition(visiblePosition);
+    vp->_internal = reinterpret_cast<WebObjectInternal *>(copy);
+    return [vp autorelease];
+}
+
+// Returns nil if visible position is null.
++ (WebVisiblePosition *)_wrapVisiblePositionIfValid:(VisiblePosition)visiblePosition
+{
+    return (visiblePosition.isNotNull() ? [WebVisiblePosition _wrapVisiblePosition:visiblePosition] : nil);
+}
+
+- (VisiblePosition)_visiblePosition
+{
+    VisiblePosition *vp = reinterpret_cast<VisiblePosition *>(_internal);
+    return *vp;
+}
+
+@end
+
+@implementation WebVisiblePosition
+
+- (void)dealloc
+{
+    VisiblePosition *vp = reinterpret_cast<VisiblePosition *>(_internal);
+    delete vp;
+    _internal = nil;
+    [super dealloc];
+}
+
+- (BOOL)isEqual:(WebVisiblePosition *)other
+{
+    VisiblePosition myVP = [self _visiblePosition];
+    VisiblePosition otherVP = [other _visiblePosition];
+    return (myVP == otherVP);
+}
+
+- (NSComparisonResult)compare:(WebVisiblePosition *)other
+{
+    VisiblePosition myVP = [self _visiblePosition];
+    VisiblePosition otherVP = [other _visiblePosition];
+    
+    if (myVP == otherVP)
+        return NSOrderedSame;
+    else if (myVP < otherVP)
+        return NSOrderedAscending;
+    else
+        return NSOrderedDescending;
+}
+
+- (int)distanceFromPosition:(WebVisiblePosition *)other
+{
+    return distanceBetweenPositions([self _visiblePosition], [other _visiblePosition]);
+}
+
+- (NSString *)description
+{
+    
+    NSMutableString *description = [NSMutableString stringWithString:[super description]];
+    VisiblePosition vp = [self _visiblePosition];
+    int offset = vp.deepEquivalent().offsetInContainerNode();
+
+    [description appendFormat:@"(offset=%d, context=([%c|%c], [u+%04x|u+%04x])", offset, vp.characterBefore(), vp.characterAfter(),
+        vp.characterBefore(), vp.characterAfter()];
+    
+    return description;
+}
+
+
+- (TextDirection)textDirection
+{
+    // TODO: implement
+    return LTR;
+}
+
+- (BOOL)directionIsDownstream:(WebTextAdjustmentDirection)direction
+{
+    if (direction == WebTextAdjustmentBackward)
+        return NO;
+    
+    if (direction == WebTextAdjustmentForward)
+        return YES;
+    
+    
+    if ([self textDirection] == LTR) {
+        return (direction == WebTextAdjustmentRight);
+    } else {
+        return (direction == WebTextAdjustmentLeft);
+    }
+}
+
+- (WebVisiblePosition *)positionByMovingInDirection:(WebTextAdjustmentDirection)direction amount:(UInt32)amount withAffinityDownstream:(BOOL)affinityDownstream
+{
+    VisiblePosition vp = [self _visiblePosition];
+                          
+    vp.setAffinity(affinityDownstream ? DOWNSTREAM : VP_UPSTREAM_IF_POSSIBLE);
+
+    switch (direction) {
+        case WebTextAdjustmentForward: {
+            for (UInt32 i = 0; i < amount; i++)
+                vp = vp.next();
+            break;
+        }
+        case WebTextAdjustmentBackward: {
+            for (UInt32 i = 0; i < amount; i++)
+                vp = vp.previous();
+            break;
+        }
+        case WebTextAdjustmentRight: {
+            for (UInt32 i = 0; i < amount; i++)
+                vp = vp.right();
+            break;
+        }
+        case WebTextAdjustmentLeft: {
+            for (UInt32 i = 0; i < amount; i++)
+                vp = vp.left();
+            break;
+        }
+        case WebTextAdjustmentUp: {
+            int xOffset = vp.lineDirectionPointForBlockDirectionNavigation();
+            for (UInt32 i = 0; i < amount; i++)
+                vp = previousLinePosition(vp, xOffset);            
+            break;
+        }
+        case WebTextAdjustmentDown: {
+            int xOffset = vp.lineDirectionPointForBlockDirectionNavigation();
+            for (UInt32 i = 0; i < amount; i++)
+                vp = nextLinePosition(vp, xOffset);            
+            break;
+        }
+        default: {
+            ASSERT_NOT_REACHED();
+            break;
+        }
+    }
+    return [WebVisiblePosition _wrapVisiblePositionIfValid:vp];
+}
+
+- (WebVisiblePosition *)positionByMovingInDirection:(WebTextAdjustmentDirection)direction amount:(UInt32)amount
+
+{
+    return [self positionByMovingInDirection:direction amount:amount withAffinityDownstream:YES];
+}
+
+static inline TextGranularity toTextGranularity(WebTextGranularity webGranularity)
+{
+    TextGranularity granularity;
+    
+    switch (webGranularity) {
+        case WebTextGranularityCharacter:
+            granularity = CharacterGranularity;
+            break;
+
+        case WebTextGranularityWord:
+            granularity = WordGranularity;
+            break;
+
+        case WebTextGranularitySentence:
+            granularity = SentenceGranularity;
+            break;
+
+        case WebTextGranularityLine:
+            granularity = LineGranularity;
+            break;
+
+        case WebTextGranularityParagraph:
+            granularity = ParagraphGranularity;
+            break;
+
+        case WebTextGranularityAll:
+            granularity = DocumentGranularity;
+            break;
+
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+            
+    return granularity;
+}
+
+static inline SelectionDirection toSelectionDirection(WebTextAdjustmentDirection direction)
+{
+    SelectionDirection result;
+    
+    switch (direction) {
+        case WebTextAdjustmentForward:
+            result = DirectionForward;
+            break;
+            
+        case WebTextAdjustmentBackward:
+            result = DirectionBackward;
+            break;
+            
+        case WebTextAdjustmentRight:
+            result = DirectionRight;
+            break;
+            
+        case WebTextAdjustmentLeft:
+            result = DirectionLeft;
+            break;
+        
+        case WebTextAdjustmentUp:
+            result = DirectionLeft;
+            break;
+        
+        case WebTextAdjustmentDown:
+            result = DirectionRight;
+            break;
+    }
+
+    return result;
+}
+
+// Returnes YES only if a position is at a boundary of a text unit of the specified granularity in the particular direction.
+- (BOOL)atBoundaryOfGranularity:(WebTextGranularity)granularity inDirection:(WebTextAdjustmentDirection)direction
+{
+    return atBoundaryOfGranularity([self _visiblePosition], toTextGranularity(granularity), toSelectionDirection(direction));
+}
+
+// Returns the next boundary position of a text unit of the given granularity in the given direction, or nil if there is no such position.
+- (WebVisiblePosition *)positionOfNextBoundaryOfGranularity:(WebTextGranularity)granularity inDirection:(WebTextAdjustmentDirection)direction
+{
+    return [WebVisiblePosition _wrapVisiblePositionIfValid:positionOfNextBoundaryOfGranularity([self _visiblePosition], toTextGranularity(granularity), toSelectionDirection(direction))];
+}
+
+// Returns YES if position is within a text unit of the given granularity.  If the position is at a boundary, returns YES only if
+// if the boundary is part of the text unit in the given direction.
+- (BOOL)withinTextUnitOfGranularity:(WebTextGranularity)granularity inDirectionIfAtBoundary:(WebTextAdjustmentDirection)direction
+{
+    return withinTextUnitOfGranularity([self _visiblePosition], toTextGranularity(granularity), toSelectionDirection(direction));
+}
+
+// Returns range of the enclosing text unit of the given granularity, or nil if there is no such enclosing unit.  Whether a boundary position
+// is enclosed depends on the given direction, using the same rule as -[WebVisiblePosition withinTextUnitOfGranularity:inDirectionAtBoundary:].
+- (DOMRange *)enclosingTextUnitOfGranularity:(WebTextGranularity)granularity inDirectionIfAtBoundary:(WebTextAdjustmentDirection)direction
+{
+    return kit(enclosingTextUnitOfGranularity([self _visiblePosition], toTextGranularity(granularity), toSelectionDirection(direction)).get());
+}
+
+- (WebVisiblePosition *)positionAtStartOrEndOfWord
+{
+    // Ripped from WebCore::Frame::moveSelectionToStartOrEndOfCurrentWord
+    
+    // Note: this is the iPhone 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.
+    
+    // Selection rule: If the selection is before the first character or
+    // just after the first character of a word that is longer than one
+    // character, move to the start of the word. Otherwise, move to the
+    // end of the word.
+    
+    VisiblePosition pos = [self _visiblePosition];
+    VisiblePosition originalPos(pos);
+    
+    UChar32 ch = pos.characterAfter();
+    bool isComplex = requiresContextForWordBoundary(ch);
+    if (isComplex) {
+        // for complex layout, find word around insertion point
+        VisiblePosition visibleWordStart = startOfWord(pos);
+        Position wordStart = visibleWordStart.deepEquivalent();
+        
+        // place caret in front of word if pos is within first 2 characters of word (see Selection Rule above)
+        if (wordStart.deprecatedEditingOffset() + 1 >= pos.deepEquivalent().deprecatedEditingOffset()) {
+            pos = wordStart;
+        } else {
+            // calculate end of word to insert caret after word
+            VisiblePosition visibleWordEnd = endOfWord(pos);
+            Position wordEnd = visibleWordEnd.deepEquivalent();
+            pos = wordEnd;
+        }
+    } else {
+        UChar32 c = pos.characterAfter();
+        CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline);
+        if (c == 0 || CFCharacterSetIsLongCharacterMember(set, c)) {
+            // search backward for a non-space
+            while (1) {
+                if (pos.isNull() || isStartOfLine(pos))
+                    break;
+                c = pos.characterBefore();
+                if (!CFCharacterSetIsLongCharacterMember(set, c))
+                    break;
+                pos = pos.previous(CannotCrossEditingBoundary);  // stay in editable content
+            }
+        }
+        else {
+            // See how far the selection extends into the current word.
+            // Follow the rule stated above.
+            int index = 0;
+            while (1) {
+                if (pos.isNull() || isStartOfLine(pos))
+                    break;
+                c = pos.characterBefore();
+                if (CFCharacterSetIsLongCharacterMember(set, c))
+                    break;
+                pos = pos.previous(CannotCrossEditingBoundary);  // stay in editable content
+                index++;
+                if (index > 1)
+                    break;
+            }
+            if (index > 1) {
+                // search forward for a space
+                pos = originalPos;
+                while (1) {
+                    if (pos.isNull() || isEndOfLine(pos))
+                        break;
+                    c = pos.characterAfter();
+                    if (CFCharacterSetIsLongCharacterMember(set, c))
+                        break;
+                    pos = pos.next(CannotCrossEditingBoundary);  // stay in editable content
+                }
+            }
+        }
+    }
+    
+    return [WebVisiblePosition _wrapVisiblePositionIfValid:pos];
+}
+
+- (BOOL)isEditable
+{
+    return isEditablePosition([self _visiblePosition].deepEquivalent());
+}
+
+- (BOOL)requiresContextForWordBoundary
+{
+    VisiblePosition vp = [self _visiblePosition];
+    return requiresContextForWordBoundary(vp.characterAfter()) || requiresContextForWordBoundary(vp.characterBefore());
+}    
+
+- (BOOL)atAlphaNumericBoundaryInDirection:(WebTextAdjustmentDirection)direction
+{
+    static CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric);
+    VisiblePosition pos = [self _visiblePosition];
+    UChar32 charBefore = pos.characterBefore();
+    UChar32 charAfter = pos.characterAfter();
+    bool before = CFCharacterSetIsCharacterMember(set, charBefore);
+    bool after = CFCharacterSetIsCharacterMember(set, charAfter);
+    return [self directionIsDownstream:direction] ? (before && !after) : (!before && after);
+}
+
+- (DOMRange *)enclosingRangeWithDictationPhraseAlternatives:(NSArray **)alternatives
+{
+    ASSERT(alternatives);
+    if (!alternatives)
+        return nil;
+        
+    // *alternatives should not already point to an array.
+    ASSERT(!(*alternatives));
+    *alternatives = nil;
+        
+    VisiblePosition p = [self _visiblePosition];
+    if (p.isNull())
+        return nil;
+        
+    int o = p.deepEquivalent().deprecatedEditingOffset();
+    if (o < 0)
+        return nil;
+    unsigned offset = o;
+    
+    Node* node = p.deepEquivalent().anchorNode();
+    Document* document = node->document();
+    if (!document)
+        return nil;
+    
+    const Vector<DocumentMarker*>& markers = document->markers()->markersFor(node);
+    if (markers.isEmpty())
+        return nil;
+        
+    for (size_t i = 0; i < markers.size(); i++) {
+        const DocumentMarker* marker = markers[i];
+        if (marker->type() != DocumentMarker::DictationPhraseWithAlternatives)
+            continue;
+            
+        if (marker->startOffset() <= offset && marker->endOffset() >= offset) {
+            const Vector<String>& markerAlternatives = marker->alternatives();
+            *alternatives = [NSMutableArray arrayWithCapacity:markerAlternatives.size()];
+            for (size_t j = 0; j < markerAlternatives.size(); j++)
+                [(NSMutableArray *)*alternatives addObject:(NSString *)(markerAlternatives[j])];
+                
+            RefPtr<Range> range = Range::create(document, node, marker->startOffset(), node, marker->endOffset());
+            return kit(range.get());
+        }
+    }
+        
+    return nil;
+}
+
+- (DOMRange *)enclosingRangeWithCorrectionIndicator
+{
+    VisiblePosition p = [self _visiblePosition];
+    if (p.isNull())
+        return nil;
+    
+    int o = p.deepEquivalent().deprecatedEditingOffset();
+    if (o < 0)
+        return nil;
+    unsigned offset = o;
+    
+    Node* node = p.deepEquivalent().anchorNode();
+    Document* document = node->document();
+    if (!document)
+        return nil;
+    
+    const Vector<DocumentMarker>& markers = document->markers()->markersForNode(node);
+    if (markers.isEmpty())
+        return nil;
+    
+    for (size_t i = 0; i < markers.size(); i++) {
+        const DocumentMarker& marker = markers[i];
+        if (marker.type() != DocumentMarker::Spelling)
+            continue;
+        
+        if (marker.startOffset() <= offset && marker.endOffset() >= offset) {
+            RefPtr<Range> range = Range::create(document, node, marker.startOffset(), node, marker.endOffset());
+            return kit(range.get());
+        }
+    }
+    
+    return nil;
+}
+
+- (NSSelectionAffinity)affinity
+{
+    return (NSSelectionAffinity)[self _visiblePosition].affinity();
+}
+
+- (void)setAffinity:(NSSelectionAffinity)affinity
+{
+    reinterpret_cast<VisiblePosition *>(_internal)->setAffinity((WebCore::EAffinity)affinity);
+}
+
+@end
+
+@implementation DOMRange (VisiblePositionExtensions)
+
+- (WebVisiblePosition *)startPosition
+{
+    Range *range = core(self);
+    return [WebVisiblePosition _wrapVisiblePosition:VisiblePosition(range->startPosition())];
+}
+
+- (WebVisiblePosition *)endPosition
+{
+    Range *range = core(self);
+    return [WebVisiblePosition _wrapVisiblePosition:VisiblePosition(range->endPosition())];
+}
+
+- (DOMRange *)enclosingWordRange
+{
+    VisibleSelection selection([self.startPosition _visiblePosition], [self.endPosition _visiblePosition]);
+    selection = FrameSelection::wordSelectionContainingCaretSelection(selection);
+    WebVisiblePosition *start = [WebVisiblePosition _wrapVisiblePosition:selection.visibleStart()];
+    WebVisiblePosition *end = [WebVisiblePosition _wrapVisiblePosition:selection.visibleEnd()];
+    return [DOMRange rangeForFirstPosition:start second:end];
+}
+
++ (DOMRange *)rangeForFirstPosition:(WebVisiblePosition *)first second:(WebVisiblePosition *)second
+{
+    VisiblePosition firstVP = [first _visiblePosition];
+    VisiblePosition secondVP = [second _visiblePosition];
+    
+    if (firstVP.isNull() || secondVP.isNull())
+        return nil;
+    
+    RefPtr<Range> range;
+    if (firstVP < secondVP) {
+        range = Range::create(firstVP.deepEquivalent().deprecatedNode()->document(),
+                                     firstVP, secondVP);
+    } else {
+        range = Range::create(firstVP.deepEquivalent().deprecatedNode()->document(),
+                                            secondVP, firstVP);
+    }
+    
+    
+    return kit(range.get());
+}
+
+@end
+
+@implementation DOMNode (VisiblePositionExtensions)
+
+- (DOMRange *)rangeOfContents
+{
+    DOMRange *range = [[self ownerDocument] createRange];
+    [range setStart:self offset:0];
+    [range setEnd:self offset:[[self childNodes] length]];
+    return range;    
+}
+
+- (WebVisiblePosition *)startPosition
+{
+#if USE(UIKIT_EDITING)
+    // When in editable content, we need to calculate the startPosition from the beginning of the
+    // editable area.
+    Node* node = core(self);
+    if (node->isContentEditable()) {
+        VisiblePosition vp(createLegacyEditingPosition(node, 0), VP_DEFAULT_AFFINITY);
+        return [WebVisiblePosition _wrapVisiblePosition:startOfEditableContent(vp)];
+    }
+#endif
+    return [[self rangeOfContents] startPosition];
+}
+
+- (WebVisiblePosition *)endPosition
+{
+#if USE(UIKIT_EDITING)
+    // When in editable content, we need to calculate the endPosition from the end of the
+    // editable area.
+    Node* node = core(self);
+    if (node->isContentEditable()) {
+        VisiblePosition vp(createLegacyEditingPosition(node, 0), VP_DEFAULT_AFFINITY);
+        return [WebVisiblePosition _wrapVisiblePosition:endOfEditableContent(vp)];
+    }
+#endif
+    return [[self rangeOfContents] endPosition];
+}
+
+@end
+
+@implementation DOMHTMLInputElement (VisiblePositionExtensions)
+
+- (WebVisiblePosition *)startPosition
+{
+    Node *node = core(self);
+    RenderObject *obj