[iOS] Upstream WAK
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 00:46:39 +0000 (00:46 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 00:46:39 +0000 (00:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126724

Reviewed by David Kilzer.

* Configurations/WebCore.xcconfig: Excluded new iOS-specific Private
headers on the Mac build.
* WebCore.xcodeproj/project.pbxproj: Added new files to the project.
* platform/ios/wak/WAKAppKitStubs.h: Added.
* platform/ios/wak/WAKAppKitStubs.m: Added.
* platform/ios/wak/WAKClipView.h: Added.
* platform/ios/wak/WAKClipView.m: Added.
* platform/ios/wak/WAKResponder.h: Added.
* platform/ios/wak/WAKResponder.m: Added.
* platform/ios/wak/WAKScrollView.h: Added.
* platform/ios/wak/WAKScrollView.mm: Added.
* platform/ios/wak/WAKView.h: Added.
* platform/ios/wak/WAKView.mm: Added.
* platform/ios/wak/WAKViewPrivate.h: Added.
* platform/ios/wak/WAKWindow.h: Added.
* platform/ios/wak/WAKWindow.mm: Added.
* platform/ios/wak/WKContentObservation.cpp: Added.
* platform/ios/wak/WKContentObservation.h: Added.
* platform/ios/wak/WKGraphics.h: Added.
* platform/ios/wak/WKGraphics.mm: Added.
* platform/ios/wak/WKTypes.h: Added.
* platform/ios/wak/WKUtilities.c: Added.
* platform/ios/wak/WKUtilities.h: Added.
* platform/ios/wak/WKView.h: Added.
* platform/ios/wak/WKView.mm: Added.
* platform/ios/wak/WKViewPrivate.h: Added.
* platform/ios/wak/WebCoreThread.h: Added.
* platform/ios/wak/WebCoreThread.mm: Added.
* platform/ios/wak/WebCoreThreadInternal.h: Added.
* platform/ios/wak/WebCoreThreadMessage.h: Added.
* platform/ios/wak/WebCoreThreadRun.cpp: Added.
* platform/ios/wak/WebCoreThreadRun.h: Added.
* platform/ios/wak/WebCoreThreadSafe.h: Added.
* platform/ios/wak/WebCoreThreadSystemInterface.cpp: Added.
* platform/ios/wak/WebCoreThreadSystemInterface.h: Added.

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

35 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/ios/wak/WAKAppKitStubs.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKAppKitStubs.m [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKClipView.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKClipView.m [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKResponder.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKResponder.m [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKScrollView.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKScrollView.mm [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKView.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKView.mm [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKViewPrivate.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKWindow.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WAKWindow.mm [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKContentObservation.cpp [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKContentObservation.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKGraphics.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKGraphics.mm [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKTypes.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKUtilities.c [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKUtilities.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKView.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKView.mm [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WKViewPrivate.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThread.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThread.mm [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadInternal.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadMessage.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadRun.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadSafe.h [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.cpp [new file with mode: 0644]
Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.h [new file with mode: 0644]

index 87c54df..1b352ec 100644 (file)
@@ -1,3 +1,46 @@
+2014-01-09  Andy Estes  <aestes@apple.com>
+
+        [iOS] Upstream WAK
+        https://bugs.webkit.org/show_bug.cgi?id=126724
+
+        Reviewed by David Kilzer.
+
+        * Configurations/WebCore.xcconfig: Excluded new iOS-specific Private
+        headers on the Mac build.
+        * WebCore.xcodeproj/project.pbxproj: Added new files to the project.
+        * platform/ios/wak/WAKAppKitStubs.h: Added.
+        * platform/ios/wak/WAKAppKitStubs.m: Added.
+        * platform/ios/wak/WAKClipView.h: Added.
+        * platform/ios/wak/WAKClipView.m: Added.
+        * platform/ios/wak/WAKResponder.h: Added.
+        * platform/ios/wak/WAKResponder.m: Added.
+        * platform/ios/wak/WAKScrollView.h: Added.
+        * platform/ios/wak/WAKScrollView.mm: Added.
+        * platform/ios/wak/WAKView.h: Added.
+        * platform/ios/wak/WAKView.mm: Added.
+        * platform/ios/wak/WAKViewPrivate.h: Added.
+        * platform/ios/wak/WAKWindow.h: Added.
+        * platform/ios/wak/WAKWindow.mm: Added.
+        * platform/ios/wak/WKContentObservation.cpp: Added.
+        * platform/ios/wak/WKContentObservation.h: Added.
+        * platform/ios/wak/WKGraphics.h: Added.
+        * platform/ios/wak/WKGraphics.mm: Added.
+        * platform/ios/wak/WKTypes.h: Added.
+        * platform/ios/wak/WKUtilities.c: Added.
+        * platform/ios/wak/WKUtilities.h: Added.
+        * platform/ios/wak/WKView.h: Added.
+        * platform/ios/wak/WKView.mm: Added.
+        * platform/ios/wak/WKViewPrivate.h: Added.
+        * platform/ios/wak/WebCoreThread.h: Added.
+        * platform/ios/wak/WebCoreThread.mm: Added.
+        * platform/ios/wak/WebCoreThreadInternal.h: Added.
+        * platform/ios/wak/WebCoreThreadMessage.h: Added.
+        * platform/ios/wak/WebCoreThreadRun.cpp: Added.
+        * platform/ios/wak/WebCoreThreadRun.h: Added.
+        * platform/ios/wak/WebCoreThreadSafe.h: Added.
+        * platform/ios/wak/WebCoreThreadSystemInterface.cpp: Added.
+        * platform/ios/wak/WebCoreThreadSystemInterface.h: Added.
+
 2014-01-09  Daniel Bates  <dabates@apple.com>
 
         Another attempt to fix the Windows build following <http://trac.webkit.org/changeset/161589>
index 1009570..dfb23c1 100644 (file)
@@ -108,4 +108,4 @@ JAVASCRIPTCORE_PRIVATE_HEADERS_engineering = $(BUILT_PRODUCTS_DIR)/JavaScriptCor
 EXCLUDED_SOURCE_FILE_NAMES = $(EXCLUDED_SOURCE_FILE_NAMES_$(PLATFORM_NAME));
 EXCLUDED_SOURCE_FILE_NAMES_iphoneos = *.tiff *Cursor.png Cursor.cpp CursorMac.mm EventHandlerMac.mm HTMLConverter.mm KillRingMac.mm PlatformEventFactoryMac.mm SSLKeyGeneratorMac.cpp SearchPopupMenuMac.mm SharedTimerMac.mm WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm;
 EXCLUDED_SOURCE_FILE_NAMES_iphonesimulator = $(EXCLUDED_SOURCE_FILE_NAMES_iphoneos);
-EXCLUDED_SOURCE_FILE_NAMES_macosx = *IOS.h *IOS.cpp *IOS.mm KillRingNone.cpp;
+EXCLUDED_SOURCE_FILE_NAMES_macosx = *IOS.h *IOS.cpp *IOS.mm KillRingNone.cpp WAKAppKitStubs.h WAKClipView.h WAKResponder.h WAKScrollView.h WAKView.h WAKViewPrivate.h WAKWindow.h WKContentObservation.h WKGraphics.h WKTypes.h WKUtilities.h WKView.h WKViewPrivate.h WebCoreThread.h WebCoreThreadMessage.h WebCoreThreadRun.h WebCoreThreadSystemInterface.h;
index 369dcf7..1605ede 100644 (file)
                A12A1050166444FD008FA311 /* GridTrackSize.h in Headers */ = {isa = PBXBuildFile; fileRef = A12A104E166444DC008FA311 /* GridTrackSize.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */; };
                A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */ = {isa = PBXBuildFile; fileRef = A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */; };
+               A14832B0187F618D00DA63A6 /* WAKAppKitStubs.h in Headers */ = {isa = PBXBuildFile; fileRef = A148328C187F508700DA63A6 /* WAKAppKitStubs.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832B1187F61E100DA63A6 /* WAKAppKitStubs.m in Sources */ = {isa = PBXBuildFile; fileRef = A148328D187F508700DA63A6 /* WAKAppKitStubs.m */; };
+               A14832B2187F61ED00DA63A6 /* WAKClipView.h in Headers */ = {isa = PBXBuildFile; fileRef = A148328E187F508700DA63A6 /* WAKClipView.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832B3187F629100DA63A6 /* WAKClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = A148328F187F508700DA63A6 /* WAKClipView.m */; };
+               A14832B4187F629A00DA63A6 /* WAKResponder.h in Headers */ = {isa = PBXBuildFile; fileRef = A1483290187F508700DA63A6 /* WAKResponder.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832B5187F62FC00DA63A6 /* WAKResponder.m in Sources */ = {isa = PBXBuildFile; fileRef = A1483291187F508700DA63A6 /* WAKResponder.m */; };
+               A14832B6187F631F00DA63A6 /* WAKScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1483292187F508700DA63A6 /* WAKScrollView.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832B7187F636C00DA63A6 /* WAKScrollView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1483293187F508700DA63A6 /* WAKScrollView.mm */; };
+               A14832B8187F638600DA63A6 /* WAKView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1483294187F508700DA63A6 /* WAKView.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832B9187F63D500DA63A6 /* WAKView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1483295187F508700DA63A6 /* WAKView.mm */; };
+               A14832BA187F63E900DA63A6 /* WAKViewPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1483296187F508700DA63A6 /* WAKViewPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832BB187F643200DA63A6 /* WAKWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A1483297187F508700DA63A6 /* WAKWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832BC187F648E00DA63A6 /* WAKWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1483298187F508700DA63A6 /* WAKWindow.mm */; };
+               A14832BD187F64B400DA63A6 /* WKContentObservation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A14832A2187F508700DA63A6 /* WKContentObservation.cpp */; };
+               A14832BE187F64CC00DA63A6 /* WKContentObservation.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832A3187F508700DA63A6 /* WKContentObservation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832BF187F652C00DA63A6 /* WKGraphics.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832A4187F508700DA63A6 /* WKGraphics.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832C0187F656600DA63A6 /* WKGraphics.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14832A5187F508700DA63A6 /* WKGraphics.mm */; };
+               A14832C1187F657A00DA63A6 /* WKTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832A6187F508700DA63A6 /* WKTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832C2187F65C700DA63A6 /* WKUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = A14832A7187F508700DA63A6 /* WKUtilities.c */; };
+               A14832C3187F65DF00DA63A6 /* WKUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832A8187F508700DA63A6 /* WKUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832C4187F663C00DA63A6 /* WKView.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832A9187F508700DA63A6 /* WKView.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832C5187F668300DA63A6 /* WKView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14832AA187F508700DA63A6 /* WKView.mm */; };
+               A14832C6187F668F00DA63A6 /* WKViewPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832AB187F508700DA63A6 /* WKViewPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832C7187F66C800DA63A6 /* WebCoreThread.h in Headers */ = {isa = PBXBuildFile; fileRef = A1483299187F508700DA63A6 /* WebCoreThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832C8187F673F00DA63A6 /* WebCoreThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = A148329A187F508700DA63A6 /* WebCoreThread.mm */; };
+               A14832C9187F676B00DA63A6 /* WebCoreThreadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A148329B187F508700DA63A6 /* WebCoreThreadInternal.h */; };
+               A14832CA187F678000DA63A6 /* WebCoreThreadMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = A148329C187F508700DA63A6 /* WebCoreThreadMessage.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832CB187F67B400DA63A6 /* WebCoreThreadRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A148329D187F508700DA63A6 /* WebCoreThreadRun.cpp */; };
+               A14832CC187F67C400DA63A6 /* WebCoreThreadRun.h in Headers */ = {isa = PBXBuildFile; fileRef = A148329E187F508700DA63A6 /* WebCoreThreadRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A14832CD187F682E00DA63A6 /* WebCoreThreadSafe.h in Headers */ = {isa = PBXBuildFile; fileRef = A148329F187F508700DA63A6 /* WebCoreThreadSafe.h */; };
+               A14832CE187F683400DA63A6 /* WebCoreThreadSystemInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A14832A0187F508700DA63A6 /* WebCoreThreadSystemInterface.cpp */; };
+               A14832CF187F684700DA63A6 /* WebCoreThreadSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = A14832A1187F508700DA63A6 /* WebCoreThreadSystemInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */; };
                A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */; };
                A1C7FAA2133A5D3500D6732D /* JSXPathResultCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1C7FAA1133A5D3500D6732D /* JSXPathResultCustom.cpp */; };
                A12A104E166444DC008FA311 /* GridTrackSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridTrackSize.h; path = style/GridTrackSize.h; sourceTree = "<group>"; };
                A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestProgressEventThrottle.cpp; sourceTree = "<group>"; };
                A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEventThrottle.h; sourceTree = "<group>"; };
+               A148328C187F508700DA63A6 /* WAKAppKitStubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKAppKitStubs.h; path = ios/wak/WAKAppKitStubs.h; sourceTree = "<group>"; };
+               A148328D187F508700DA63A6 /* WAKAppKitStubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WAKAppKitStubs.m; path = ios/wak/WAKAppKitStubs.m; sourceTree = "<group>"; };
+               A148328E187F508700DA63A6 /* WAKClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKClipView.h; path = ios/wak/WAKClipView.h; sourceTree = "<group>"; };
+               A148328F187F508700DA63A6 /* WAKClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WAKClipView.m; path = ios/wak/WAKClipView.m; sourceTree = "<group>"; };
+               A1483290187F508700DA63A6 /* WAKResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKResponder.h; path = ios/wak/WAKResponder.h; sourceTree = "<group>"; };
+               A1483291187F508700DA63A6 /* WAKResponder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WAKResponder.m; path = ios/wak/WAKResponder.m; sourceTree = "<group>"; };
+               A1483292187F508700DA63A6 /* WAKScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKScrollView.h; path = ios/wak/WAKScrollView.h; sourceTree = "<group>"; };
+               A1483293187F508700DA63A6 /* WAKScrollView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WAKScrollView.mm; path = ios/wak/WAKScrollView.mm; sourceTree = "<group>"; };
+               A1483294187F508700DA63A6 /* WAKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKView.h; path = ios/wak/WAKView.h; sourceTree = "<group>"; };
+               A1483295187F508700DA63A6 /* WAKView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WAKView.mm; path = ios/wak/WAKView.mm; sourceTree = "<group>"; };
+               A1483296187F508700DA63A6 /* WAKViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKViewPrivate.h; path = ios/wak/WAKViewPrivate.h; sourceTree = "<group>"; };
+               A1483297187F508700DA63A6 /* WAKWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKWindow.h; path = ios/wak/WAKWindow.h; sourceTree = "<group>"; };
+               A1483298187F508700DA63A6 /* WAKWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WAKWindow.mm; path = ios/wak/WAKWindow.mm; sourceTree = "<group>"; };
+               A1483299187F508700DA63A6 /* WebCoreThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreThread.h; path = ios/wak/WebCoreThread.h; sourceTree = "<group>"; };
+               A148329A187F508700DA63A6 /* WebCoreThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebCoreThread.mm; path = ios/wak/WebCoreThread.mm; sourceTree = "<group>"; };
+               A148329B187F508700DA63A6 /* WebCoreThreadInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreThreadInternal.h; path = ios/wak/WebCoreThreadInternal.h; sourceTree = "<group>"; };
+               A148329C187F508700DA63A6 /* WebCoreThreadMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreThreadMessage.h; path = ios/wak/WebCoreThreadMessage.h; sourceTree = "<group>"; };
+               A148329D187F508700DA63A6 /* WebCoreThreadRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebCoreThreadRun.cpp; path = ios/wak/WebCoreThreadRun.cpp; sourceTree = "<group>"; };
+               A148329E187F508700DA63A6 /* WebCoreThreadRun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreThreadRun.h; path = ios/wak/WebCoreThreadRun.h; sourceTree = "<group>"; };
+               A148329F187F508700DA63A6 /* WebCoreThreadSafe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreThreadSafe.h; path = ios/wak/WebCoreThreadSafe.h; sourceTree = "<group>"; };
+               A14832A0187F508700DA63A6 /* WebCoreThreadSystemInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebCoreThreadSystemInterface.cpp; path = ios/wak/WebCoreThreadSystemInterface.cpp; sourceTree = "<group>"; };
+               A14832A1187F508700DA63A6 /* WebCoreThreadSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreThreadSystemInterface.h; path = ios/wak/WebCoreThreadSystemInterface.h; sourceTree = "<group>"; };
+               A14832A2187F508700DA63A6 /* WKContentObservation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WKContentObservation.cpp; path = ios/wak/WKContentObservation.cpp; sourceTree = "<group>"; };
+               A14832A3187F508700DA63A6 /* WKContentObservation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKContentObservation.h; path = ios/wak/WKContentObservation.h; sourceTree = "<group>"; };
+               A14832A4187F508700DA63A6 /* WKGraphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKGraphics.h; path = ios/wak/WKGraphics.h; sourceTree = "<group>"; };
+               A14832A5187F508700DA63A6 /* WKGraphics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKGraphics.mm; path = ios/wak/WKGraphics.mm; sourceTree = "<group>"; };
+               A14832A6187F508700DA63A6 /* WKTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKTypes.h; path = ios/wak/WKTypes.h; sourceTree = "<group>"; };
+               A14832A7187F508700DA63A6 /* WKUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = WKUtilities.c; path = ios/wak/WKUtilities.c; sourceTree = "<group>"; };
+               A14832A8187F508700DA63A6 /* WKUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKUtilities.h; path = ios/wak/WKUtilities.h; sourceTree = "<group>"; };
+               A14832A9187F508700DA63A6 /* WKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKView.h; path = ios/wak/WKView.h; sourceTree = "<group>"; };
+               A14832AA187F508700DA63A6 /* WKView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKView.mm; path = ios/wak/WKView.mm; sourceTree = "<group>"; };
+               A14832AB187F508700DA63A6 /* WKViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKViewPrivate.h; path = ios/wak/WKViewPrivate.h; sourceTree = "<group>"; };
                A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; };
                A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; };
                A1C7FAA1133A5D3500D6732D /* JSXPathResultCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXPathResultCustom.cpp; sourceTree = "<group>"; };
                        path = ios;
                        sourceTree = "<group>";
                };
+               A148328B187F506800DA63A6 /* wak */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A148328C187F508700DA63A6 /* WAKAppKitStubs.h */,
+                               A148328D187F508700DA63A6 /* WAKAppKitStubs.m */,
+                               A148328E187F508700DA63A6 /* WAKClipView.h */,
+                               A148328F187F508700DA63A6 /* WAKClipView.m */,
+                               A1483290187F508700DA63A6 /* WAKResponder.h */,
+                               A1483291187F508700DA63A6 /* WAKResponder.m */,
+                               A1483292187F508700DA63A6 /* WAKScrollView.h */,
+                               A1483293187F508700DA63A6 /* WAKScrollView.mm */,
+                               A1483294187F508700DA63A6 /* WAKView.h */,
+                               A1483295187F508700DA63A6 /* WAKView.mm */,
+                               A1483296187F508700DA63A6 /* WAKViewPrivate.h */,
+                               A1483297187F508700DA63A6 /* WAKWindow.h */,
+                               A1483298187F508700DA63A6 /* WAKWindow.mm */,
+                               A14832A2187F508700DA63A6 /* WKContentObservation.cpp */,
+                               A14832A3187F508700DA63A6 /* WKContentObservation.h */,
+                               A14832A4187F508700DA63A6 /* WKGraphics.h */,
+                               A14832A5187F508700DA63A6 /* WKGraphics.mm */,
+                               A14832A6187F508700DA63A6 /* WKTypes.h */,
+                               A14832A7187F508700DA63A6 /* WKUtilities.c */,
+                               A14832A8187F508700DA63A6 /* WKUtilities.h */,
+                               A14832A9187F508700DA63A6 /* WKView.h */,
+                               A14832AA187F508700DA63A6 /* WKView.mm */,
+                               A14832AB187F508700DA63A6 /* WKViewPrivate.h */,
+                               A1483299187F508700DA63A6 /* WebCoreThread.h */,
+                               A148329A187F508700DA63A6 /* WebCoreThread.mm */,
+                               A148329B187F508700DA63A6 /* WebCoreThreadInternal.h */,
+                               A148329C187F508700DA63A6 /* WebCoreThreadMessage.h */,
+                               A148329D187F508700DA63A6 /* WebCoreThreadRun.cpp */,
+                               A148329E187F508700DA63A6 /* WebCoreThreadRun.h */,
+                               A148329F187F508700DA63A6 /* WebCoreThreadSafe.h */,
+                               A14832A0187F508700DA63A6 /* WebCoreThreadSystemInterface.cpp */,
+                               A14832A1187F508700DA63A6 /* WebCoreThreadSystemInterface.h */,
+                       );
+                       name = wak;
+                       sourceTree = "<group>";
+               };
                A59E3C1B11580F340072928E /* ios */ = {
                        isa = PBXGroup;
                        children = (
+                               A148328B187F506800DA63A6 /* wak */,
                                2903716416BA11BC00FEFDF0 /* ContentFilterIOS.mm */,
                                2655414B1489AA2B000DFC5D /* CursorIOS.cpp */,
                                31EAF97C121435A400E7C1BF /* DeviceMotionClientIOS.h */,
                                FDE2D55B159E66EB00DCCCF8 /* AudioIOCallback.h in Headers */,
                                FD31601012B0267600C1A359 /* AudioListener.h in Headers */,
                                0705852417FDC140005F2BCB /* MediaTrackConstraints.h in Headers */,
+                               A14832CA187F678000DA63A6 /* WebCoreThreadMessage.h in Headers */,
                                FD31601312B0267600C1A359 /* AudioNode.h in Headers */,
                                FD31601612B0267600C1A359 /* AudioNodeInput.h in Headers */,
                                FD31601812B0267600C1A359 /* AudioNodeOutput.h in Headers */,
                                0705853217FDE6D9005F2BCB /* JSMediaTrackConstraint.h in Headers */,
                                1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */,
                                93309DDF099E64920056E581 /* DeleteFromTextNodeCommand.h in Headers */,
+                               A14832B2187F61ED00DA63A6 /* WAKClipView.h in Headers */,
                                07C59B6417F4D1C4000FBCBB /* MockMediaStreamCenter.h in Headers */,
                                E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */,
                                93309DE1099E64920056E581 /* DeleteSelectionCommand.h in Headers */,
                                078E093417D16B0B00420AA1 /* MediaStreamCenter.h in Headers */,
                                31FB1A5B120A5D0600DC02A0 /* DeviceMotionData.h in Headers */,
                                31FB1A5D120A5D0600DC02A0 /* DeviceMotionEvent.h in Headers */,
+                               A14832C3187F65DF00DA63A6 /* WKUtilities.h in Headers */,
                                E1C6571F1816E50300256CDD /* CryptoAlgorithmHmacParams.h in Headers */,
                                59A8F1D811A69520001AC34A /* DeviceOrientationClient.h in Headers */,
                                59309A1311F4AE6A00250603 /* DeviceOrientationClientMock.h in Headers */,
+                               A14832B6187F631F00DA63A6 /* WAKScrollView.h in Headers */,
                                51D719CC181106E00016DC51 /* IDBDatabaseCallbacksImpl.h in Headers */,
                                59A8F1D611A69513001AC34A /* DeviceOrientationController.h in Headers */,
                                590E1B4911E4EF4B0069F784 /* DeviceOrientationData.h in Headers */,
                                854075200AD6C5FB00620C57 /* DOMEventTarget.h in Headers */,
                                85C78A680ABDE1B40044FC16 /* DOMException.h in Headers */,
                                BC1A37B5097C715F0019F3D8 /* DOMExtensions.h in Headers */,
+                               A14832BF187F652C00DA63A6 /* WKGraphics.h in Headers */,
                                BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */,
                                2E3BC108117D479800B9409A /* DOMFileError.h in Headers */,
                                2E3BC10B117D47C800B9409A /* DOMFileErrorInternal.h in Headers */,
                                85DF81990AA77E4B00486AD7 /* DOMHTMLIFrameElement.h in Headers */,
                                85E711B10AC5D5350053270F /* DOMHTMLIFrameElementInternal.h in Headers */,
                                85DF81290AA7787200486AD7 /* DOMHTMLImageElement.h in Headers */,
+                               A14832B0187F618D00DA63A6 /* WAKAppKitStubs.h in Headers */,
                                85E711B20AC5D5350053270F /* DOMHTMLImageElementInternal.h in Headers */,
                                85F32AEC0AA63B8700FF3184 /* DOMHTMLInputElement.h in Headers */,
                                85E711B30AC5D5350053270F /* DOMHTMLInputElementInternal.h in Headers */,
                                85E711BE0AC5D5350053270F /* DOMHTMLOListElementInternal.h in Headers */,
                                85F32AEE0AA63B8700FF3184 /* DOMHTMLOptGroupElement.h in Headers */,
                                CD9DE18217AAD6A400EA386D /* DOMURLMediaSource.h in Headers */,
+                               A14832B8187F638600DA63A6 /* WAKView.h in Headers */,
                                85E711BF0AC5D5350053270F /* DOMHTMLOptGroupElementInternal.h in Headers */,
                                E125F85E182C2DF600D84CD9 /* CryptoKeyData.h in Headers */,
                                8540756B0AD6CBF900620C57 /* DOMHTMLOptionElement.h in Headers */,
                                76FC2B0C12370DA0006A991A /* DOMTokenList.h in Headers */,
                                E145349716A9BB6A000F6FD2 /* DOMTransitionEvent.h in Headers */,
                                E145349916A9BB6A000F6FD2 /* DOMTransitionEventInternal.h in Headers */,
+                               A14832BB187F643200DA63A6 /* WAKWindow.h in Headers */,
                                BC1A37BE097C715F0019F3D8 /* DOMTraversal.h in Headers */,
                                85526CD20AB0B7D9000302EA /* DOMTreeWalker.h in Headers */,
                                850B41C30AD9E7E700A6ED4F /* DOMTreeWalkerInternal.h in Headers */,
                                2D8287F716E4A0380086BD00 /* HitTestLocation.h in Headers */,
                                930908910AF7EDE40081DF01 /* HitTestRequest.h in Headers */,
                                9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */,
+                               A14832CF187F684700DA63A6 /* WebCoreThreadSystemInterface.h in Headers */,
                                BC3BC29C0E91AB0F00835588 /* HostWindow.h in Headers */,
                                FD31609912B026F700C1A359 /* HRTFDatabase.h in Headers */,
                                FD31609B12B026F700C1A359 /* HRTFDatabaseLoader.h in Headers */,
                                37E3524D12450C6600BAF5D9 /* InputType.h in Headers */,
                                C348612415FDE21E007A1CC9 /* InputTypeNames.h in Headers */,
                                93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */,
+                               A14832C7187F66C800DA63A6 /* WebCoreThread.h in Headers */,
                                57CF497514EE36D700ECFF14 /* InsertionPoint.h in Headers */,
                                93309DEC099E64920056E581 /* InsertLineBreakCommand.h in Headers */,
                                D07DEABA0A36554A00CA30F8 /* InsertListCommand.h in Headers */,
                                FDA15EA412B03EE1003A583A /* JSChannelSplitterNode.h in Headers */,
                                65DF31F409D1CC60000BE325 /* JSCharacterData.h in Headers */,
                                BCC065880F3CE2A700CD2D87 /* JSClientRect.h in Headers */,
+                               A14832C4187F663C00DA63A6 /* WKView.h in Headers */,
                                BCC0658A0F3CE2A700CD2D87 /* JSClientRectList.h in Headers */,
                                BCA83E500D7CE1E9003421A8 /* JSClipboard.h in Headers */,
                                51FB5504113E3E9100821176 /* JSCloseEvent.h in Headers */,
                                BC46C2070C0DDCA10020CFC3 /* JSCSSStyleRule.h in Headers */,
                                BCC5BE010C0E93110011C2DB /* JSCSSStyleSheet.h in Headers */,
                                FC54D05816A7676E00575E4D /* JSCSSSupportsRule.h in Headers */,
+                               A14832CC187F67C400DA63A6 /* WebCoreThreadRun.h in Headers */,
                                14CF78A609F58CD800EB3665 /* JSCSSValue.h in Headers */,
                                A8D05FAC0A23B30F005E7203 /* JSCSSValueList.h in Headers */,
                                E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */,
                                E44614170CD6826900FADA75 /* JSHTMLVideoElement.h in Headers */,
                                C585A67D11D4FB08004C3E4B /* JSIDBAny.h in Headers */,
                                81BE20D311F4BC3200915DFA /* JSIDBCursor.h in Headers */,
+                               A14832C1187F657A00DA63A6 /* WKTypes.h in Headers */,
                                C585A68311D4FB08004C3E4B /* JSIDBDatabase.h in Headers */,
                                C585A69711D4FB13004C3E4B /* JSIDBFactory.h in Headers */,
                                C572EE1F1201C9BC007D8F82 /* JSIDBIndex.h in Headers */,
                                B2FA3D610AB75A6F000E5AC4 /* JSSVGCursorElement.h in Headers */,
                                B2FA3D630AB75A6F000E5AC4 /* JSSVGDefsElement.h in Headers */,
                                B2FA3D650AB75A6F000E5AC4 /* JSSVGDescElement.h in Headers */,
+                               A14832C9187F676B00DA63A6 /* WebCoreThreadInternal.h in Headers */,
                                B2FA3D670AB75A6F000E5AC4 /* JSSVGDocument.h in Headers */,
                                B222F69D0AB771B80022EFAD /* JSSVGElement.h in Headers */,
                                B2CB92440B5BD970009BAA78 /* JSSVGElementInstance.h in Headers */,
                                E1BD331C182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h in Headers */,
                                3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */,
                                65A21468097A329100B9050A /* Page.h in Headers */,
+                               A14832B4187F629A00DA63A6 /* WAKResponder.h in Headers */,
                                9B50B1DE17CD4C0F0087F63C /* FormNamedItem.h in Headers */,
                                1477E7770BF4134A00152872 /* PageCache.h in Headers */,
                                DAED203116F244480070EC0F /* PageConsole.h in Headers */,
                                ABC128770B33AA6D00C693D5 /* PopupMenuClient.h in Headers */,
                                BC3BE12B0E98092F00835588 /* PopupMenuStyle.h in Headers */,
                                37F567CE165358F400DDE92B /* PopupOpeningObserver.h in Headers */,
+                               A14832C6187F668F00DA63A6 /* WKViewPrivate.h in Headers */,
                                93F199DE08245E59001E9ABC /* Position.h in Headers */,
                                9746AF2C14F4DDE6003E7A70 /* PositionCallback.h in Headers */,
                                9746AF2E14F4DDE6003E7A70 /* PositionError.h in Headers */,
                                514C767D0CE923A1007EF3CD /* ResourceRequestBase.h in Headers */,
                                07969DB817D14151007FF842 /* JSRTCIceCandidateEvent.h in Headers */,
                                7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */,
+                               A14832CD187F682E00DA63A6 /* WebCoreThreadSafe.h in Headers */,
                                7EE6847012D26E3800E79415 /* ResourceResponse.h in Headers */,
                                514C767F0CE923A1007EF3CD /* ResourceResponseBase.h in Headers */,
                                FD3160A512B026F700C1A359 /* Reverb.h in Headers */,
                                0FE71406142170B800DB33BA /* ScrollbarThemeMock.h in Headers */,
                                5D925B680F64D4DD00B847F0 /* ScrollBehavior.h in Headers */,
                                1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */,
+                               A14832BA187F63E900DA63A6 /* WAKViewPrivate.h in Headers */,
                                0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */,
                                1AF62EE814DA22A70041556C /* ScrollingCoordinator.h in Headers */,
                                9391A991162746CB00297330 /* ScrollingCoordinatorMac.h in Headers */,
                                1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */,
                                854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */,
                                C375D7FE16639519006184AB /* TypeAhead.h in Headers */,
+                               A14832BE187F64CC00DA63A6 /* WKContentObservation.h in Headers */,
                                37C28A6810F659CC008C7813 /* TypesettingFeatures.h in Headers */,
                                93309E1A099E64920056E581 /* TypingCommand.h in Headers */,
                                85031B4E0A44EFC700F992E0 /* UIEvent.h in Headers */,
                                BCE7898B1120E8020060ECE5 /* BidiRun.cpp in Sources */,
                                FD31608C12B026F700C1A359 /* Biquad.cpp in Sources */,
                                FD31602412B0267600C1A359 /* BiquadDSPKernel.cpp in Sources */,
+                               A14832B3187F629100DA63A6 /* WAKClipView.m in Sources */,
                                FDC54F041399B0DA008D9117 /* BiquadFilterNode.cpp in Sources */,
                                FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */,
                                070584FF17F9F05E005F2BCB /* CapabilityRange.cpp in Sources */,
                                ABAF22080C03B1C700B0BCF0 /* ChromeMac.mm in Sources */,
                                CD9DE17417AAC74C00EA386D /* JSMediaSource.cpp in Sources */,
                                4ACBC0BE12713CBD0094F9B2 /* ClassList.cpp in Sources */,
+                               A14832C5187F668300DA63A6 /* WKView.mm in Sources */,
                                BC904B760D10998F00680D32 /* ClassNodeList.cpp in Sources */,
                                BCC0657D0F3CE1B700CD2D87 /* ClientRect.cpp in Sources */,
                                A584FE341864D5AF00843B10 /* CommandLineAPIHost.cpp in Sources */,
                                85ECBEF20AA7626900544F0B /* DOMHTMLHRElement.mm in Sources */,
                                85992EBD0AA5069500AC0785 /* DOMHTMLHtmlElement.mm in Sources */,
                                85DF819A0AA77E4B00486AD7 /* DOMHTMLIFrameElement.mm in Sources */,
+                               A14832B9187F63D500DA63A6 /* WAKView.mm in Sources */,
                                85DF812A0AA7787200486AD7 /* DOMHTMLImageElement.mm in Sources */,
                                85F32AED0AA63B8700FF3184 /* DOMHTMLInputElement.mm in Sources */,
                                A6148A6812E41D940044A784 /* DOMHTMLKeygenElement.mm in Sources */,
                                514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */,
                                371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */,
                                97E4028F13A696ED00913D67 /* IconController.cpp in Sources */,
+                               A14832BC187F648E00DA63A6 /* WAKWindow.mm in Sources */,
                                5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
                                516953971329A3C800B92D04 /* IconDatabaseBase.cpp in Sources */,
                                513F14530AB634C400094DDF /* IconLoader.cpp in Sources */,
                                E44614180CD6826900FADA75 /* JSMediaError.cpp in Sources */,
                                E19AC3F41824DC7900349426 /* CryptoAlgorithmSHA512.cpp in Sources */,
                                510B7DB7182D9F5D009BF957 /* IDBTransactionBackend.cpp in Sources */,
+                               A14832CB187F67B400DA63A6 /* WebCoreThreadRun.cpp in Sources */,
                                CDA98DA31601464100FEA3B1 /* JSMediaKeyError.cpp in Sources */,
                                CDB859FA160D494900E5B07F /* JSMediaKeyEvent.cpp in Sources */,
                                CDA98DDF16026A3700FEA3B1 /* JSMediaKeyMessageEvent.cpp in Sources */,
                                E446141A0CD6826900FADA75 /* JSTimeRanges.cpp in Sources */,
                                070334E9145A1F36008D8D45 /* JSTrackCustom.cpp in Sources */,
                                07846342145B151A00A58DF1 /* JSTrackEvent.cpp in Sources */,
+                               A14832C0187F656600DA63A6 /* WKGraphics.mm in Sources */,
                                07BDD6EC1469B4C2009C9F85 /* JSTrackEventCustom.cpp in Sources */,
                                E17B492216A9B8FF001C8839 /* JSTransitionEvent.cpp in Sources */,
                                078E091317D14CEE00420AA1 /* UserMediaRequest.cpp in Sources */,
                                85031B490A44EFC700F992E0 /* MutationEvent.cpp in Sources */,
                                C6F0900E14327B6100685849 /* MutationObserver.cpp in Sources */,
                                D6E528A3149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp in Sources */,
+                               A14832B1187F61E100DA63A6 /* WAKAppKitStubs.m in Sources */,
                                E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */,
                                D6E276AF14637455001D280A /* MutationObserverRegistration.cpp in Sources */,
                                C6F08FBC1430FE8F00685849 /* MutationRecord.cpp in Sources */,
                                9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */,
                                E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */,
                                7A674BDB0F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp in Sources */,
+                               A14832B5187F62FC00DA63A6 /* WAKResponder.m in Sources */,
                                1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */,
                                FBDB619D16D6034600BB3394 /* PageRuleCollector.cpp in Sources */,
                                F3820894147D35F90010BC06 /* PageRuntimeAgent.cpp in Sources */,
                                1A569D240D7E2B82007C3983 /* runtime_root.cpp in Sources */,
                                293EAE211356B32E0067ACF9 /* RuntimeApplicationChecks.cpp in Sources */,
                                8C6EA61911EF7E0400FD8EE3 /* RuntimeEnabledFeatures.cpp in Sources */,
+                               A14832CE187F683400DA63A6 /* WebCoreThreadSystemInterface.cpp in Sources */,
                                49E911CA0EF86D47009D0CAF /* ScaleTransformOperation.cpp in Sources */,
                                5DFE8F560D16477B0076E937 /* ScheduledAction.cpp in Sources */,
                                5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */,
                                7134496D146941B300720312 /* SVGLengthContext.cpp in Sources */,
                                07CA120E182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp in Sources */,
                                B2227A350D00BF220071B782 /* SVGLengthList.cpp in Sources */,
+                               A14832BD187F64B400DA63A6 /* WKContentObservation.cpp in Sources */,
                                07277E5017D018CC0015534D /* JSMediaStreamEvent.cpp in Sources */,
                                B2227A380D00BF220071B782 /* SVGLinearGradientElement.cpp in Sources */,
                                B2227A3B0D00BF220071B782 /* SVGLineElement.cpp in Sources */,
                                BC2274780E8366E200E7F975 /* SVGRenderStyle.cpp in Sources */,
                                BC22747A0E8366E200E7F975 /* SVGRenderStyleDefs.cpp in Sources */,
                                B2227AA20D00BF220071B782 /* SVGScriptElement.cpp in Sources */,
+                               A14832B7187F636C00DA63A6 /* WAKScrollView.mm in Sources */,
                                B2227AA50D00BF220071B782 /* SVGSetElement.cpp in Sources */,
                                E4AFD00F0DAF335500F5F55C /* SVGSMILElement.cpp in Sources */,
                                B2227AA80D00BF220071B782 /* SVGStopElement.cpp in Sources */,
                                B2227ABD0D00BF220071B782 /* SVGSwitchElement.cpp in Sources */,
                                B2227AC00D00BF220071B782 /* SVGSymbolElement.cpp in Sources */,
                                51D719D2181106E00016DC51 /* IDBFactory.cpp in Sources */,
+                               A14832C2187F65C700DA63A6 /* WKUtilities.c in Sources */,
                                078E090A17D14CEE00420AA1 /* RTCIceCandidateEvent.cpp in Sources */,
+                               A14832C8187F673F00DA63A6 /* WebCoreThread.mm in Sources */,
                                B2227AC40D00BF220071B782 /* SVGTests.cpp in Sources */,
                                B2227AC70D00BF220071B782 /* SVGTextContentElement.cpp in Sources */,
                                07969DBB17D14151007FF842 /* JSRTCSessionDescription.cpp in Sources */,
diff --git a/Source/WebCore/platform/ios/wak/WAKAppKitStubs.h b/Source/WebCore/platform/ios/wak/WAKAppKitStubs.h
new file mode 100644 (file)
index 0000000..7385ec0
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+/* Unicodes we reserve for function keys on the keyboard,  OpenStep reserves the range 0xF700-0xF8FF for this purpose.  The availability of various keys will be system dependent. */
+
+#ifndef WAKAppKitStubs_h
+#define WAKAppKitStubs_h
+
+#if TARGET_OS_IPHONE
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <Foundation/Foundation.h>
+// FIXME: <rdar://problem/6669434> Switch from using NSGeometry methods to CGGeometry methods
+#import <Foundation/NSGeometry.h>
+
+#ifndef NSClipView
+#define NSClipView WAKClipView
+#endif
+#ifndef NSView
+#define NSView WAKView
+#endif
+#ifndef NSScrollView
+#define NSScrollView WAKScrollView
+#endif
+#ifndef WebDynamicScrollBarsView
+#define WebDynamicScrollBarsView WAKScrollView
+#endif
+#ifndef NSWindow
+#define NSWindow WAKWindow
+#endif
+#ifndef NSResponder
+#define NSResponder WAKResponder
+#endif
+
+#ifdef __OBJC__
+@class WAKClipView;
+@class WAKResponder;
+@class WAKScrollView;
+@class WAKView;
+@class WAKWindow;
+#endif
+
+/* Device-independent bits found in event modifier flags */
+enum {
+    NSAlphaShiftKeyMask = 1 << 16,
+    NSShiftKeyMask =      1 << 17,
+    NSControlKeyMask =    1 << 18,
+    NSAlternateKeyMask =  1 << 19,
+    NSCommandKeyMask =    1 << 20,
+    NSNumericPadKeyMask = 1 << 21,
+    NSHelpKeyMask =       1 << 22,
+    NSFunctionKeyMask =   1 << 23,
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+    NSDeviceIndependentModifierFlagsMask = 0xffff0000U
+#endif
+};
+
+typedef enum _WKWritingDirection {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+    WKWritingDirectionNatural     = -1, /* Determines direction using the Unicode Bidi Algorithm rules P2 and P3 */
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */
+    WKWritingDirectionLeftToRight = 0,  /* Left to right writing direction */
+    WKWritingDirectionRightToLeft       /* Right to left writing direction */
+} WKWritingDirection;
+
+typedef enum _NSSelectionAffinity {
+    NSSelectionAffinityUpstream = 0,
+    NSSelectionAffinityDownstream = 1
+} NSSelectionAffinity;
+
+typedef enum _NSCellState {
+    NSMixedState = -1,
+    NSOffState   =  0,
+    NSOnState    =  1    
+} NSCellStateValue;
+
+typedef enum _NSCompositingOperation {
+    NSCompositeClear           = 0,
+    NSCompositeCopy            = 1,
+    NSCompositeSourceOver      = 2,
+    NSCompositeSourceIn        = 3,
+    NSCompositeSourceOut       = 4,
+    NSCompositeSourceAtop      = 5,
+    NSCompositeDestinationOver = 6,
+    NSCompositeDestinationIn   = 7,
+    NSCompositeDestinationOut  = 8,
+    NSCompositeDestinationAtop = 9,
+    NSCompositeXOR             = 10,
+    NSCompositePlusDarker      = 11,
+    NSCompositeHighlight       = 12,
+    NSCompositePlusLighter     = 13
+} NSCompositingOperation;
+
+typedef enum _NSSelectionDirection {
+    NSDirectSelection = 0,
+    NSSelectingNext,
+    NSSelectingPrevious
+} NSSelectionDirection;
+
+@interface NSCursor : NSObject
++ (void)setHiddenUntilMouseMoves:(BOOL)flag;
+@end
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+BOOL WKMouseInRect(CGPoint aPoint, CGRect aRect);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKAppKitStubs_h
diff --git a/Source/WebCore/platform/ios/wak/WAKAppKitStubs.m b/Source/WebCore/platform/ios/wak/WAKAppKitStubs.m
new file mode 100644 (file)
index 0000000..df921f2
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 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 "config.h"
+#import "WAKAppKitStubs.h"
+
+#if PLATFORM(IOS)
+
+id NSApp = nil;
+
+BOOL WKMouseInRect(CGPoint aPoint, CGRect aRect) 
+{
+    return aPoint.x >= aRect.origin.x &&
+        aPoint.x < (aRect.origin.x + aRect.size.width) &&
+        aPoint.y >= aRect.origin.y && aPoint.y < (aRect.origin.y + aRect.size.height);
+}
+
+@implementation NSCursor
++ (void)setHiddenUntilMouseMoves:(BOOL)flag
+{
+    UNUSED_PARAM(flag);
+}
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WAKClipView.h b/Source/WebCore/platform/ios/wak/WAKClipView.h
new file mode 100644 (file)
index 0000000..afbf8af
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#ifndef WAKClipView_h
+#define WAKClipView_h
+
+#if TARGET_OS_IPHONE
+
+#import "WAKView.h"
+
+@interface WAKClipView : WAKView
+
+@property (nonatomic, readonly) WAKView *documentView;
+@property (nonatomic, assign) BOOL copiesOnScroll;
+
+- (CGRect)documentVisibleRect;
+
+@end
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKClipView_h
diff --git a/Source/WebCore/platform/ios/wak/WAKClipView.m b/Source/WebCore/platform/ios/wak/WAKClipView.m
new file mode 100644 (file)
index 0000000..9fb4373
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 "config.h"
+#import "WAKClipView.h"
+
+#if PLATFORM(IOS)
+
+#import "WAKViewPrivate.h"
+#import <wtf/Assertions.h>
+
+@implementation WAKClipView
+
+@synthesize documentView = _documentView;
+@synthesize copiesOnScroll = _copiesOnScroll;
+
+- (id)initWithFrame:(CGRect)rect
+{
+    WKViewRef view = WKViewCreateWithFrame(rect, &viewContext);
+    self = [self _initWithViewRef:view];
+    WKRelease(view);
+    return self;
+}
+
+- (void)dealloc
+{
+    [_documentView release];
+    [super dealloc];
+}
+
+// WAK internal function for WAKScrollView.
+- (void)_setDocumentView:(WAKView *)aView
+{
+    if (_documentView == aView)
+        return;
+
+    [_documentView removeFromSuperview];
+    [_documentView release];
+    _documentView = [aView retain];
+    [self addSubview:_documentView];
+}
+
+- (CGRect)documentVisibleRect 
+{     
+    if (_documentView)
+        return WKViewConvertRectFromSuperview([_documentView _viewRef], [self bounds]);
+    return CGRectZero;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WAKResponder.h b/Source/WebCore/platform/ios/wak/WAKResponder.h
new file mode 100644 (file)
index 0000000..2c58eb4
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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 WAKResponder_h
+#define WAKResponder_h
+
+#if TARGET_OS_IPHONE
+
+#import "WKTypes.h"
+#import <Foundation/Foundation.h>
+
+@class WebEvent;
+
+@interface WAKResponder : NSObject
+{
+
+}
+
+- (void)handleEvent:(WebEvent *)event;
+
+- (void)scrollWheel:(WebEvent *)theEvent;
+- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
+- (void)mouseEntered:(WebEvent *)theEvent;
+- (void)mouseExited:(WebEvent *)theEvent;
+- (void)keyDown:(WebEvent *)event;
+- (void)keyUp:(WebEvent *)event;
+#if ENABLE(TOUCH_EVENTS)
+- (void)touch:(WebEvent *)event;
+#endif
+
+- (void)insertText:(NSString *)text;
+
+- (void)deleteBackward:(id)sender;
+- (void)deleteForward:(id)sender;
+- (void)insertParagraphSeparator:(id)sender;
+
+- (void)moveDown:(id)sender;
+- (void)moveDownAndModifySelection:(id)sender;
+- (void)moveLeft:(id)sender;
+- (void)moveLeftAndModifySelection:(id)sender;
+- (void)moveRight:(id)sender;
+- (void)moveRightAndModifySelection:(id)sender;
+- (void)moveUp:(id)sender;
+- (void)moveUpAndModifySelection:(id)sender;
+
+- (WAKResponder *)nextResponder;
+- (BOOL)acceptsFirstResponder;
+- (BOOL)becomeFirstResponder;
+- (BOOL)resignFirstResponder;
+
+- (void)mouseUp:(WebEvent *)theEvent;
+- (void)mouseDown:(WebEvent *)theEvent;
+- (void)mouseMoved:(WebEvent *)theEvent;
+
+@end
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKResponder_h
diff --git a/Source/WebCore/platform/ios/wak/WAKResponder.m b/Source/WebCore/platform/ios/wak/WAKResponder.m
new file mode 100644 (file)
index 0000000..e77c35d
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * 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 "config.h"
+#import "WAKResponder.h"
+
+#if PLATFORM(IOS)
+
+#import "WAKViewPrivate.h"
+#import "WKViewPrivate.h"
+
+@implementation WAKResponder
+
+// FIXME: the functions named handleEvent generally do not forward event to the parent chain.
+// This method should ideally be removed, or renamed "sendEvent".
+- (void)handleEvent:(WebEvent *)event
+{
+    UNUSED_PARAM(event);
+}
+
+- (void)_forwardEvent:(WebEvent *)event
+{
+    [[self nextResponder] handleEvent:event];
+}
+
+- (void)scrollWheel:(WebEvent *)event 
+{ 
+    [self _forwardEvent:event];
+}
+
+- (void)mouseEntered:(WebEvent *)event
+{ 
+    [self _forwardEvent:event];
+}
+
+- (void)mouseExited:(WebEvent *)event 
+{ 
+    [self _forwardEvent:event];
+}
+
+- (void)mouseMoved:(WebEvent *)theEvent
+{
+    [self _forwardEvent:theEvent];
+}
+
+- (void)keyDown:(WebEvent *)event
+{ 
+    [self _forwardEvent:event];
+}
+- (void)keyUp:(WebEvent *)event
+{ 
+    [self _forwardEvent:event];
+}
+
+#if ENABLE(TOUCH_EVENTS)
+- (void)touch:(WebEvent *)event
+{
+    [self _forwardEvent:event];
+}
+#endif
+
+- (WAKResponder *)nextResponder { return nil; }
+
+- (void)insertText:(NSString *)text
+{
+    UNUSED_PARAM(text);
+}
+
+- (void)deleteBackward:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)deleteForward:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)insertParagraphSeparator:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveDown:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveDownAndModifySelection:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveLeft:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveLeftAndModifySelection:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveRight:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveRightAndModifySelection:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveUp:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)moveUpAndModifySelection:(id)sender
+{
+    UNUSED_PARAM(sender);
+}
+
+- (void)mouseUp:(WebEvent *)event 
+{
+    [self _forwardEvent:event];
+}
+
+- (void)mouseDown:(WebEvent *)event 
+{
+    [self _forwardEvent:event];
+}
+
+- (BOOL)acceptsFirstResponder { return true; }
+- (BOOL)becomeFirstResponder { return true; }
+- (BOOL)resignFirstResponder { return true; }
+
+- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject 
+{ 
+    if ([self respondsToSelector:anAction]) {
+        [self performSelector:anAction withObject:anObject];
+        return YES;
+    }
+    return NO; 
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WAKScrollView.h b/Source/WebCore/platform/ios/wak/WAKScrollView.h
new file mode 100644 (file)
index 0000000..0b40697
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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 WAKScrollView_h
+#define WAKScrollView_h
+
+#if TARGET_OS_IPHONE
+
+#import "WAKView.h"
+#import "WebCoreFrameView.h"
+#import <Foundation/Foundation.h>
+
+@class WAKClipView;
+
+@interface WAKScrollView : WAKView <WebCoreFrameScrollView>
+{
+    WAKView *_documentView;  // Only here so the ObjC instance stays around.
+    WAKClipView *_contentView;
+    id _delegate;
+    NSPoint _scrollOrigin;
+}
+
+- (CGRect)documentVisibleRect;
+- (WAKClipView *)contentView;
+- (id)documentView;
+- (void)setDocumentView:(WAKView *)aView;
+- (void)setHasVerticalScroller:(BOOL)flag;
+- (BOOL)hasVerticalScroller;
+- (void)setHasHorizontalScroller:(BOOL)flag;
+- (BOOL)hasHorizontalScroller;
+- (void)reflectScrolledClipView:(WAKClipView *)aClipView;
+- (void)setDrawsBackground:(BOOL)flag;
+- (float)verticalLineScroll;
+- (void)setLineScroll:(float)aFloat;
+- (BOOL)drawsBackground;
+- (float)horizontalLineScroll;
+
+- (void)setDelegate:(id)delegate;
+- (id)delegate;
+
+- (CGRect)actualDocumentVisibleRect;
+- (void)setActualScrollPosition:(CGPoint)point;
+
+- (CGRect)documentVisibleExtent; // Like actualDocumentVisibleRect, but includes areas possibly covered by translucent UI.
+
+- (BOOL)inProgrammaticScroll;
+@end
+
+@interface NSObject (WAKScrollViewDelegate)
+- (BOOL)scrollView:(WAKScrollView *)scrollView shouldScrollToPoint:(CGPoint)point;
+@end
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKScrollView_h
diff --git a/Source/WebCore/platform/ios/wak/WAKScrollView.mm b/Source/WebCore/platform/ios/wak/WAKScrollView.mm
new file mode 100644 (file)
index 0000000..2d12b5d
--- /dev/null
@@ -0,0 +1,447 @@
+/*
+ * 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 "config.h"
+#import "WAKScrollView.h"
+
+#if PLATFORM(IOS)
+
+#import "WAKAppKitStubs.h"
+#import "WAKClipView.h"
+#import "WAKViewPrivate.h"
+#import "WAKWindow.h"
+#import "WebEvent.h"
+
+@interface WAKClipView(PrivateAPI)
+- (void)_setDocumentView:(WAKView *)aView;
+@end
+
+// FIXME: get rid of this and use polymorphic response to notifications.
+@interface WAKScrollView()
+- (void)_adjustScrollers;
+@end
+
+static void _notificationCallback(WKViewRef v, WKViewNotificationType type, void *userInfo)
+{
+    UNUSED_PARAM(v);
+    switch (type){
+        case WKViewNotificationViewFrameSizeChanged: {
+            WAKScrollView *scrollView = (WAKScrollView *)userInfo;
+            ASSERT(scrollView);
+            ASSERT([scrollView isKindOfClass:[WAKScrollView class]]);
+            [scrollView _adjustScrollers];
+            break;
+        }
+        default: {
+            break;
+        }
+    }
+}
+
+@implementation WAKScrollView
+
+- (id)initWithFrame:(CGRect)rect
+{
+    WKViewRef view = WKViewCreateWithFrame(rect, &viewContext);
+    viewContext.notificationCallback = _notificationCallback;
+    viewContext.notificationUserInfo = self;
+    self = [super _initWithViewRef:(WKViewRef)view];
+    WKRelease(view);
+
+    _contentView = [[WAKClipView alloc] initWithFrame:rect];
+    [self addSubview:_contentView];
+
+    return self;
+}
+
+- (void)dealloc
+{
+    [_documentView autorelease];
+    [_contentView release];
+    [super dealloc];
+}
+
+- (BOOL)_selfHandleEvent:(WebEvent *)event
+{
+    switch (event.type) {
+        case WebEventScrollWheel:
+            [self scrollWheel:event];
+            return YES;
+        default:
+            return NO;
+    }
+}
+
+- (void)setHasVerticalScroller:(BOOL)flag
+{
+    UNUSED_PARAM(flag);
+}
+
+- (BOOL)hasVerticalScroller
+{
+    return NO;
+}
+
+- (void)setHasHorizontalScroller:(BOOL)flag
+{
+    UNUSED_PARAM(flag);
+}
+
+- (BOOL)hasHorizontalScroller
+{
+    return NO;
+}
+
+- (void)setDelegate:(id)delegate
+{
+    _delegate = delegate;
+}
+
+- (id)delegate
+{
+    return _delegate;
+}
+
+- (CGRect)documentVisibleRect 
+{
+    return [_contentView documentVisibleRect];
+}
+
+- (void)setDocumentView:(WAKView *)view
+{
+    if (view != _documentView) {
+        [_documentView release];
+        _documentView = [view retain];
+        [_contentView _setDocumentView:view];
+    }
+}
+
+- (id)documentView 
+{
+    return _documentView;
+}
+
+- (WAKClipView *)contentView 
+{ 
+    return _contentView;
+}
+
+- (void)setDrawsBackground:(BOOL)flag
+{
+    UNUSED_PARAM(flag);
+}
+
+- (BOOL)drawsBackground 
+{
+    return NO; 
+}
+
+- (void)setLineScroll:(float)value
+{
+    UNUSED_PARAM(value);
+}
+
+- (float)verticalLineScroll
+{
+    return 0;
+}
+
+- (float)horizontalLineScroll 
+{ 
+    return 0;
+}
+
+- (void)reflectScrolledClipView:(WAKClipView *)aClipView
+{
+    UNUSED_PARAM(aClipView);
+}
+
+- (void)drawRect:(CGRect)rect
+{
+    UNUSED_PARAM(rect);
+}
+
+// WebCoreFrameView methods
+
+- (void)setHorizontalScrollingMode:(WebCore::ScrollbarMode)mode
+{
+    UNUSED_PARAM(mode);
+}
+
+- (void)setVerticalScrollingMode:(WebCore::ScrollbarMode)mode
+{
+    UNUSED_PARAM(mode);
+}
+
+- (void)setScrollingMode:(WebCore::ScrollbarMode)mode
+{
+    UNUSED_PARAM(mode);
+}
+
+- (WebCore::ScrollbarMode)horizontalScrollingMode
+{
+    return WebCore::ScrollbarAuto;
+}
+
+- (WebCore::ScrollbarMode)verticalScrollingMode
+{
+    return WebCore::ScrollbarAuto;
+}
+
+#pragma mark -
+#pragma mark WebCoreFrameScrollView protocol
+
+- (void)setScrollingModes:(WebCore::ScrollbarMode)hMode vertical:(WebCore::ScrollbarMode)vMode andLock:(BOOL)lock
+{
+    UNUSED_PARAM(hMode);
+    UNUSED_PARAM(vMode);
+    UNUSED_PARAM(lock);
+}
+
+- (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode
+{
+    UNUSED_PARAM(hMode);
+    UNUSED_PARAM(vMode);
+}
+
+- (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint
+{
+    UNUSED_PARAM(suppressed);
+    UNUSED_PARAM(repaint);
+}
+
+- (void)setScrollOrigin:(NSPoint)scrollOrigin updatePositionAtAll:(BOOL)updatePositionAtAll immediately:(BOOL)updatePositionImmediately
+{
+    UNUSED_PARAM(updatePositionAtAll);
+    UNUSED_PARAM(updatePositionImmediately);
+
+    // The cross-platform ScrollView call already checked to see if the old/new scroll origins were the same or not
+    // so we don't have to check for equivalence here.
+    _scrollOrigin = scrollOrigin;
+
+    [_documentView setBoundsOrigin:NSMakePoint(-scrollOrigin.x, -scrollOrigin.y)];
+}
+
+- (NSPoint)scrollOrigin
+{
+    return _scrollOrigin;
+}
+
+#pragma mark -
+
+static bool shouldScroll(WAKScrollView *scrollView, CGPoint scrollPoint)
+{
+    // We can scroll as long as we are not the last scroll view.
+    WAKView *view = scrollView;
+    while ((view = [view superview]))
+        if ([view isKindOfClass:[WAKScrollView class]])
+            return YES;
+
+    id delegate = [scrollView delegate];
+    SEL selector = @selector(scrollView:shouldScrollToPoint:);
+    return delegate == nil || ![delegate respondsToSelector:selector] || [delegate scrollView:scrollView shouldScrollToPoint:scrollPoint];
+}
+
+static float viewDocumentScrollableLength(WAKScrollView *scrollView, bool horizontalOrientation)
+{
+    float scrollableAmount = 0, documentLength = 0, clipLength = 0;
+    WAKView *documentView = [scrollView documentView];
+    ASSERT(documentView);
+
+    CGRect frame = [documentView frame];
+    if (horizontalOrientation)
+        documentLength = frame.size.width;
+    else
+        documentLength = frame.size.height;
+
+    WAKClipView *clipView = [scrollView contentView];
+    ASSERT_WITH_MESSAGE(clipView, "The WAKClipView is supposed to be created by the WAKScrollView at initialization.");
+    if (clipView) {
+        CGRect frame = [clipView frame];
+        if (horizontalOrientation)
+            clipLength = frame.size.width;
+        else
+            clipLength = frame.size.height;
+    }
+
+    scrollableAmount = documentLength - clipLength;
+    if (scrollableAmount <= 0)
+        scrollableAmount = 0;
+
+    return scrollableAmount;
+}
+
+static float updateScrollerWithDocumentPosition(WAKScrollView *scrollView, bool horizontalOrientation, float documentPosition)
+{
+    float documentOriginPosition = 0.;
+    if (documentPosition > 0) {
+        float scrollableLength = viewDocumentScrollableLength(scrollView, horizontalOrientation);
+        if (scrollableLength > 0) {
+            float scrolledLength = MIN(documentPosition, scrollableLength);
+            documentOriginPosition = -scrolledLength;
+        }
+    }
+
+    return documentOriginPosition;
+}
+
+static bool setDocumentViewOrigin(WAKScrollView *scrollView, WAKView *documentView, CGPoint newDocumentOrigin)
+{
+    ASSERT(documentView);
+    ASSERT(documentView == [scrollView documentView]);
+
+    CGPoint oldDocumentOrigin = [documentView frame].origin;
+    if (!CGPointEqualToPoint(oldDocumentOrigin, newDocumentOrigin)) {
+        [documentView setFrameOrigin:newDocumentOrigin];
+        [scrollView setNeedsDisplay:YES];
+        WKViewRef documentViewRef = [documentView _viewRef];
+        if (documentViewRef->context && documentViewRef->context->notificationCallback)
+            documentViewRef->context->notificationCallback(documentViewRef, WKViewNotificationViewDidScroll, documentViewRef->context->notificationUserInfo);
+        return true;
+    }
+    return false;
+}
+
+
+static BOOL scrollViewToPoint(WAKScrollView *scrollView, CGPoint point)
+{
+    WAKView *documentView = [scrollView documentView];
+    if (!documentView)
+        return NO;
+
+    if (!shouldScroll(scrollView, point))
+        return NO;
+
+    CGPoint newDocumentOrigin;
+    newDocumentOrigin.x = updateScrollerWithDocumentPosition(scrollView, /* horizontal? = */ true, point.x);
+    newDocumentOrigin.y = updateScrollerWithDocumentPosition(scrollView, /* horizontal? = */ false, point.y);
+    return setDocumentViewOrigin(scrollView, documentView, newDocumentOrigin);
+}
+
+- (void)scrollPoint:(NSPoint)point
+{
+    scrollViewToPoint(self, point);
+}
+
+- (void)scrollWheel:(WebEvent *)anEvent
+{
+    if (!_documentView)
+        return [[self nextResponder] scrollWheel:anEvent];
+    
+    CGPoint origin = [_documentView frame].origin;
+    origin.x = roundf(-origin.x - anEvent.deltaX);
+    origin.y = roundf(-origin.y - anEvent.deltaY);
+
+    if (!scrollViewToPoint(self, origin))
+        return [[self nextResponder] scrollWheel:anEvent];
+}
+
+- (CGRect)actualDocumentVisibleRect
+{
+    // Only called by WebCore::ScrollView::actualVisibleContentRect
+    WAKView* view = self;
+    while ((view = [view superview])) {
+        if ([view isKindOfClass:[WAKScrollView class]])
+            return [self documentVisibleRect];
+    }
+
+    WAKWindow* window = [self window];
+    // If we don't have a WAKWindow, we must be in a offscreen WebView.
+    if (!window)
+        return [self documentVisibleRect];
+
+    CGRect windowVisibleRect = CGRectIntegral([window exposedScrollViewRect]);
+    return [_documentView convertRect:windowVisibleRect fromView:nil];
+}
+
+- (CGRect)documentVisibleExtent
+{
+    // Only called by WebCore::ScrollView::visibleExtentContentRect
+    WAKView* view = self;
+    while ((view = [view superview])) {
+        if ([view isKindOfClass:[WAKScrollView class]])
+            return [self documentVisibleRect];
+    }
+
+    WAKWindow* window = [self window];
+    // If we don't have a WAKWindow, we must be in a offscreen WebView.
+    if (!window)
+        return [self documentVisibleRect];
+
+    CGRect windowVisibleRect = CGRectIntegral([window extendedVisibleRect]);
+    return [_documentView convertRect:windowVisibleRect fromView:nil];
+}
+
+- (void)setActualScrollPosition:(CGPoint)point
+{
+    WAKView* view = self;
+    while ((view = [view superview])) {
+        if ([view isKindOfClass:[WAKScrollView class]]) {
+            // No need for coordinate transformation if what is being scrolled is a subframe
+            [self scrollPoint:point];
+            return;
+        }
+    }
+
+    if (!_documentView)
+        return;
+    CGPoint windowPoint = [_documentView convertPoint:point toView:nil];
+    [self scrollPoint:windowPoint];
+}
+
+- (NSString *)description
+{
+    NSMutableString *description = [NSMutableString stringWithFormat:@"<%@: ; ", [super description]];
+
+    [description appendFormat:@"documentView: WAK: %p; ", _documentView];
+
+    CGRect frame = [self documentVisibleRect];
+    [description appendFormat:@"documentVisible = (%g %g; %g %g); ", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
+
+    frame = [self actualDocumentVisibleRect];
+    [description appendFormat:@"actualDocumentVisible = (%g %g; %g %g)>", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
+
+    return description;
+}
+
+- (BOOL)inProgrammaticScroll
+{
+    return NO;
+}
+
+- (void)_adjustScrollers
+{
+    // Set the clip view's size to the scroll view's size so the document view can use the correct clip view size when laying out.
+    [_contentView setFrameSize:[self bounds].size];
+
+    if (_documentView) {
+        CGPoint newDocumentOrigin = [_documentView frame].origin;
+        setDocumentViewOrigin(self, _documentView, newDocumentOrigin);
+    }
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WAKView.h b/Source/WebCore/platform/ios/wak/WAKView.h
new file mode 100644 (file)
index 0000000..ec8b571
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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 WAKView_h
+#define WAKView_h
+
+#if TARGET_OS_IPHONE
+
+#import "WAKResponder.h"
+#import "WKView.h"
+#import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
+
+#ifndef NSRect
+#define NSRect CGRect
+#endif
+#define NSPoint CGPoint
+#define NSSize CGSize
+
+extern NSString *WAKViewFrameSizeDidChangeNotification;
+extern NSString *WAKViewDidScrollNotification;
+
+@class WAKWindow;
+
+@interface WAKView : WAKResponder
+{
+    WKViewContext viewContext;
+    WKViewRef viewRef;
+    
+    NSMutableSet *subviewReferences;    // This array is only used to keep WAKViews alive.
+                                        // The actual subviews are maintained by the WKView.
+
+    BOOL _isHidden;
+    BOOL _drawsOwnDescendants;
+}
+
++ (WAKView *)focusView;
+
+- (id)initWithFrame:(CGRect)rect;
+
+- (WAKWindow *)window;
+
+- (NSRect)bounds;
+- (NSRect)frame;
+
+- (void)setFrame:(NSRect)frameRect;
+- (void)setFrameOrigin:(NSPoint)newOrigin;
+- (void)setFrameSize:(NSSize)newSize;
+- (void)setBoundsOrigin:(NSPoint)newOrigin;
+- (void)setBoundsSize:(NSSize)size;
+- (void)frameSizeChanged;
+
+- (NSArray *)subviews;
+- (WAKView *)superview;
+- (void)addSubview:(WAKView *)subview;
+- (void)willRemoveSubview:(WAKView *)subview;
+- (void)removeFromSuperview;
+- (BOOL)isDescendantOf:(WAKView *)aView;
+- (BOOL)isHiddenOrHasHiddenAncestor;
+- (WAKView *)lastScrollableAncestor;
+
+- (void)viewDidMoveToWindow;
+
+- (void)lockFocus;
+- (void)unlockFocus;
+
+- (void)setNeedsDisplay:(BOOL)flag;
+- (void)setNeedsDisplayInRect:(CGRect)invalidRect;
+- (BOOL)needsDisplay;
+- (void)display;
+- (void)displayIfNeeded;
+- (void)displayRect:(NSRect)rect;
+- (void)displayRectIgnoringOpacity:(NSRect)rect;
+- (void)displayRectIgnoringOpacity:(NSRect)rect inContext:(CGContextRef)context;
+- (void)drawRect:(CGRect)rect;
+- (void)viewWillDraw;
+
+- (WAKView *)hitTest:(NSPoint)point;
+- (NSPoint)convertPoint:(NSPoint)point fromView:(WAKView *)aView;
+- (NSPoint)convertPoint:(NSPoint)point toView:(WAKView *)aView;
+- (NSSize)convertSize:(NSSize)size toView:(WAKView *)aView;
+- (NSRect)convertRect:(NSRect)rect fromView:(WAKView *)aView;
+- (NSRect)convertRect:(NSRect)rect toView:(WAKView *)aView;
+
+- (BOOL)needsPanelToBecomeKey;
+
+- (BOOL)scrollRectToVisible:(NSRect)aRect;
+- (void)scrollPoint:(NSPoint)aPoint;
+- (NSRect)visibleRect;
+
+- (void)setHidden:(BOOL)flag;
+
+- (void)setNextKeyView:(WAKView *)aView;
+- (WAKView *)nextKeyView;
+- (WAKView *)nextValidKeyView;
+- (WAKView *)previousKeyView;
+- (WAKView *)previousValidKeyView;
+
+- (void)invalidateGState;
+- (void)releaseGState;
+
+- (void)setAutoresizingMask:(unsigned int)mask;
+- (unsigned int)autoresizingMask;
+- (BOOL)inLiveResize;
+
+- (BOOL)mouse:(NSPoint)aPoint inRect:(NSRect)aRect;
+
+- (void)setNeedsLayout:(BOOL)flag;
+- (void)layout;
+- (void)layoutIfNeeded;
+
+- (void)setScale:(float)scale;
+- (float)scale;
+
+- (void)_setDrawsOwnDescendants:(BOOL)draw;
+
+- (void)_appendDescriptionToString:(NSMutableString *)info atLevel:(int)level;
+
++ (void)_setInterpolationQuality:(int)quality;
+
+@end
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKView_h
diff --git a/Source/WebCore/platform/ios/wak/WAKView.mm b/Source/WebCore/platform/ios/wak/WAKView.mm
new file mode 100644 (file)
index 0000000..653687c
--- /dev/null
@@ -0,0 +1,783 @@
+/*
+ * 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 "config.h"
+#import "WAKViewPrivate.h"
+
+#if PLATFORM(IOS)
+
+#import "GraphicsContext.h"
+#import "WAKClipView.h"
+#import "WAKScrollView.h"
+#import "WAKViewPrivate.h"
+#import "WAKWindow.h"
+#import "WKGraphics.h"
+#import "WKUtilities.h"
+#import "WKViewPrivate.h"
+#import "WebCoreThreadMessage.h"
+#import "WebEvent.h"
+#import <wtf/Assertions.h>
+
+NSString *WAKViewFrameSizeDidChangeNotification =   @"WAKViewFrameSizeDidChangeNotification";
+NSString *WAKViewDidScrollNotification =            @"WAKViewDidScrollNotification";
+
+static WAKView *globalFocusView = nil;
+static CGInterpolationQuality sInterpolationQuality;
+
+static void setGlobalFocusView(WAKView *view)
+{
+    if (view == globalFocusView)
+        return;
+
+    [view retain];
+    [globalFocusView release];
+    globalFocusView = view;
+}
+
+static WAKScrollView *enclosingScrollView(WAKView *view)
+{
+    view = [view superview];
+    while (view && ![view isKindOfClass:[WAKScrollView class]])
+        view = [view superview];
+    return (WAKScrollView *)view;
+}
+
+@interface WAKScrollView()
+- (void)_adjustScrollers;
+@end
+
+@interface WAKView (WAKInternal)
+- (id)_initWithViewRef:(WKViewRef)viewRef;
+@end
+
+@implementation WAKView
+
+static NSInvocation* invocationForPostNotification(NSString *name, id object, id userInfo)
+{
+    NSNotificationCenter *target = [NSNotificationCenter defaultCenter];
+    NSInvocation *invocation = WebThreadMakeNSInvocation(target, @selector(postNotificationName:object:userInfo:));
+    [invocation setArgument:&name atIndex:2];
+    [invocation setArgument:&object atIndex:3];
+    [invocation setArgument:&userInfo atIndex:4];
+    return invocation;
+}
+
+static void notificationCallback (WKViewRef v, WKViewNotificationType type, void *userInfo)
+{
+    UNUSED_PARAM(v);
+    WAKView *view = (WAKView *)userInfo;
+    switch (type){
+        case WKViewNotificationViewDidMoveToWindow: {
+            [view viewDidMoveToWindow];
+            break;
+        }
+        case WKViewNotificationViewFrameSizeChanged: {
+            [view frameSizeChanged];
+            if (WAKScrollView *scrollView = enclosingScrollView(view))
+                [scrollView _adjustScrollers];
+
+            // Posting a notification to the main thread can cause the WebThreadLock to be
+            // relinquished, which gives the main thread a change to run (and possible try
+            // to paint). We don't want this to happen if we've updating view sizes in the middle
+            // of layout, so use an async notification. <rdar://problem/6745974>
+            NSInvocation *invocation = invocationForPostNotification(WAKViewFrameSizeDidChangeNotification, view, nil);
+            WebThreadCallDelegateAsync(invocation);
+            break;
+        }
+        case WKViewNotificationViewDidScroll: {
+            WebThreadRunOnMainThread(^ {
+                 [[NSNotificationCenter defaultCenter] postNotificationName:WAKViewDidScrollNotification object:view userInfo:nil];
+            });
+            break;
+        }            
+        default: {
+            break;
+        }
+    }
+}
+
+- (void)handleEvent:(WebEvent *)event
+{
+    ASSERT(event);
+    WAKView *view = self;
+    while (view) {
+        if ([view _selfHandleEvent:event])
+            break;
+        view = [view superview];
+    }
+}
+
+- (BOOL)_selfHandleEvent:(WebEvent *)event
+{
+    WebEventType type = event.type;
+    
+    switch (type) {
+        case WebEventMouseDown: {
+            [self mouseDown:event];
+            break;
+        }
+        case WebEventMouseUp: {
+            [self mouseUp:event];
+            break;
+        }
+        case WebEventMouseMoved: {
+            [self mouseMoved:event];
+            break;
+        }
+        case WebEventKeyDown: {
+            [self keyDown:event];
+            break;
+        }
+        case WebEventKeyUp: {
+            [self keyUp:event];
+            break;
+        }
+        case WebEventScrollWheel: {
+            [self scrollWheel:event];
+            break;
+        }
+#if ENABLE(TOUCH_EVENTS)
+        case WebEventTouchBegin:
+        case WebEventTouchChange:
+        case WebEventTouchEnd:
+        case WebEventTouchCancel: {
+            [self touch:event];
+            break;
+        }
+#endif
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    return YES;
+}
+
+- (NSResponder *)nextResponder
+{
+    return [self superview];
+}
+
+static bool responderCallback(WKViewRef, WKViewResponderCallbackType type, void *userInfo)
+{
+    return [(WAKView *)userInfo _handleResponderCall:type];
+}
+
+- (BOOL)_handleResponderCall:(WKViewResponderCallbackType)type
+{
+    switch (type) {
+        case WKViewResponderAcceptsFirstResponder:
+            return [self acceptsFirstResponder];
+        case WKViewResponderBecomeFirstResponder:
+            return [self becomeFirstResponder];
+        case WKViewResponderResignFirstResponder:
+            return [self resignFirstResponder];
+    }
+    return NO;
+}
+
+static void willRemoveSubviewCallback(WKViewRef view, WKViewRef subview)
+{
+    [WAKViewForWKViewRef(view) willRemoveSubview:WAKViewForWKViewRef(subview)];
+}
+
+static void invalidateGStateCallback(WKViewRef view)
+{
+    [WAKViewForWKViewRef(view) invalidateGState];
+}
+
++ (WAKView *)_wrapperForViewRef:(WKViewRef)_viewRef
+{
+    ASSERT(_viewRef);
+    if (_viewRef->isa.classInfo == &WKViewClassInfo)
+        return [[[WAKView alloc] _initWithViewRef:_viewRef] autorelease];
+    WKError ("unable to create wrapper for %s\n", _viewRef->isa.classInfo->name);
+    return nil;
+}
+
+- (id)_initWithViewRef:(WKViewRef)viewR
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    viewRef = (WKViewRef)WKRetain (viewR);
+    viewRef->wrapper = (void *)self;
+
+    return self;
+}
+
+- (id)init
+{
+    return [self initWithFrame:CGRectZero];
+}
+
+- (id)initWithFrame:(CGRect)rect
+{
+    WKViewRef view = WKViewCreateWithFrame(rect, &viewContext);
+    self = [self _initWithViewRef:view];
+    if (self) {
+        viewContext.notificationCallback = notificationCallback;
+        viewContext.notificationUserInfo = self;
+        viewContext.responderCallback = responderCallback;
+        viewContext.responderUserInfo = self;
+        viewContext.willRemoveSubviewCallback = willRemoveSubviewCallback;
+        viewContext.invalidateGStateCallback = invalidateGStateCallback;
+    }
+    WKRelease(view);
+    return self;
+}
+
+- (void)dealloc
+{
+    [[[subviewReferences copy] autorelease] makeObjectsPerformSelector:@selector(removeFromSuperview)];
+
+    if (viewRef) {
+        _WKViewSetViewContext (viewRef, 0);
+        viewRef->wrapper = NULL;
+        WKRelease (viewRef);
+    }
+    
+    [subviewReferences release];
+    
+    [super dealloc];
+}
+
+- (WAKWindow *)window
+{
+    return WKViewGetWindow(viewRef);
+}
+
+- (WKViewRef)_viewRef
+{
+    return viewRef;
+}
+
+- (NSMutableSet *)_subviewReferences
+{
+    if (!subviewReferences)
+        subviewReferences = [[NSMutableSet alloc] init];
+    return subviewReferences;
+}
+
+static void _WAKCopyWrapper(const void *value, void *context)
+{
+    if (!value)
+        return;
+    if (!context)
+        return;
+    
+    NSMutableArray *array = (NSMutableArray *)context;
+    WAKView *view = WAKViewForWKViewRef((WKViewRef)value);
+    if (view)
+        [array addObject:view];
+}
+
+- (NSArray *)subviews
+{
+    CFArrayRef subviews = WKViewGetSubviews([self _viewRef]);
+    if (!subviews)
+        return [NSArray array];
+    
+    CFIndex count = CFArrayGetCount(subviews);
+    if (count == 0)
+        return [NSArray array];
+    
+    NSMutableArray *result = [NSMutableArray arrayWithCapacity:count];
+    if (!result)
+        return [NSArray array];
+    
+    CFArrayApplyFunction(subviews, CFRangeMake(0, count), _WAKCopyWrapper, (void*)result);
+    
+    return result;
+}
+
+- (WAKView *)superview
+{
+    return WAKViewForWKViewRef(viewRef->superview);
+}
+
+- (WAKView *)lastScrollableAncestor
+{
+    WAKView *view = nil;
+    WAKScrollView *scrollView = enclosingScrollView(self);
+    
+    while (scrollView) {
+        
+        CGSize scrollViewSize = WKViewGetFrame((WKViewRef)scrollView).size;
+
+        WAKView *documentView = [scrollView documentView];
+        scrollView = enclosingScrollView(scrollView);
+                                         
+        // If this document view can be scrolled, and this is NOT the last scroll view.
+        // Our last scroll view is non-existent as far as we're concerned.
+
+        if (scrollView && !CGSizeEqualToSize(scrollViewSize, [documentView frame].size))
+            view = documentView;
+    }
+    
+    return view;
+}
+
+- (void)addSubview:(WAKView *)subview
+{
+    [subview retain];
+    [subview removeFromSuperview];
+    WKViewAddSubview (viewRef, [subview _viewRef]);
+    
+    // Keep a reference to subview so it sticks around.
+    [[self _subviewReferences] addObject:subview];
+    [subview release];
+}
+
+- (void)willRemoveSubview:(WAKView *)subview
+{
+    UNUSED_PARAM(subview);
+}
+
+- (void)removeFromSuperview
+{
+    WAKView *oldSuperview = [[self superview] retain];
+    WKViewRemoveFromSuperview (viewRef);
+    [[oldSuperview _subviewReferences] removeObject:self];
+    [oldSuperview release];
+}
+
+- (void)viewDidMoveToWindow
+{
+}
+
+- (void)frameSizeChanged
+{
+}
+
+- (void)setNeedsDisplay:(BOOL)flag
+{
+    if (!flag)
+        return;
+    [self setNeedsDisplayInRect:WKViewGetBounds(viewRef)];
+}
+
+- (void)setNeedsDisplayInRect:(CGRect)invalidRect
+{
+    if (_isHidden)
+        return;
+
+    WAKWindow *window = [self window];
+    if (!window || CGRectIsEmpty(invalidRect))
+        return;
+
+    CGRect rect = CGRectIntersection(invalidRect, [self bounds]);
+    if (CGRectIsEmpty(rect))
+        return;
+
+    CGRect baseRect = WKViewConvertRectToBase(viewRef, rect);
+    [window setNeedsDisplayInRect:baseRect];
+}
+
+- (BOOL)needsDisplay 
+{
+    return NO;
+}
+
+- (void)display
+{
+    [self displayRect:WKViewGetBounds(viewRef)];
+}
+
+- (void)displayIfNeeded
+{
+}
+
+- (void)drawRect:(CGRect)rect
+{
+    // Do nothing.  Override in subclass.
+    UNUSED_PARAM(rect);
+}
+
+- (void)viewWillDraw
+{
+    [[self subviews] makeObjectsPerformSelector:@selector(viewWillDraw)];
+}
+
++ (WAKView *)focusView
+{
+    return globalFocusView;
+}
+
+- (NSRect)bounds
+{ 
+    return WKViewGetBounds (viewRef);
+}
+
+- (NSRect)frame 
+{ 
+    return WKViewGetFrame (viewRef);
+}
+
+- (void)setFrame:(NSRect)frameRect
+{
+    WKViewSetFrameOrigin (viewRef, frameRect.origin);
+    WKViewSetFrameSize (viewRef, frameRect.size);
+}
+
+- (void)setFrameOrigin:(NSPoint)newOrigin
+{
+    WKViewSetFrameOrigin (viewRef, newOrigin);
+}
+
+- (void)setFrameSize:(NSSize)newSize
+{
+    WKViewSetFrameSize (viewRef, newSize);
+}
+
+- (void)setBoundsSize:(NSSize)size
+{
+    WKViewSetBoundsSize (viewRef, size);
+}
+
+- (void)setBoundsOrigin:(NSPoint)newOrigin
+{
+    WKViewSetBoundsOrigin(viewRef, newOrigin);
+}
+
+- (void)_lockFocusViewInContext:(CGContextRef)context
+{
+    ASSERT(context);
+    setGlobalFocusView(self);
+    CGContextSaveGState(context);
+
+    WAKView *superview = [self superview];
+    if (superview)
+        CGContextClipToRect(context, [superview bounds]);
+
+    CGContextConcatCTM(context, _WKViewGetTransform(viewRef));
+}
+
+- (void)_unlockFocusViewInContext:(CGContextRef)context
+{
+    ASSERT(context);
+    CGContextRestoreGState(context);
+    setGlobalFocusView(nil);
+}
+
+static CGInterpolationQuality toCGInterpolationQuality(WebCore::InterpolationQuality quality)
+{
+    switch (quality) {
+    case WebCore::InterpolationDefault:
+        return kCGInterpolationDefault;
+    case WebCore::InterpolationNone:
+        return kCGInterpolationNone;
+    case WebCore::InterpolationLow:
+        return kCGInterpolationLow;
+    case WebCore::InterpolationMedium:
+        return kCGInterpolationMedium;
+    case WebCore::InterpolationHigh:
+        return kCGInterpolationHigh;
+    default:
+        ASSERT_NOT_REACHED();
+        return kCGInterpolationLow;
+    }
+}
+
++ (void)_setInterpolationQuality:(int)quality
+{
+    sInterpolationQuality = toCGInterpolationQuality((WebCore::InterpolationQuality)quality);
+}
+
+- (void)_drawRect:(NSRect)dirtyRect context:(CGContextRef)context lockFocus:(bool)lockFocus
+{
+    if (_isHidden)
+        return;
+
+    ASSERT(viewRef);
+    ASSERT(context);
+    CGRect localRect = WKViewGetBounds(viewRef);
+    dirtyRect = CGRectIntersection(localRect, dirtyRect);
+    if (CGRectIsEmpty(dirtyRect))
+        return;
+
+    if (lockFocus)
+        [self _lockFocusViewInContext:context];
+
+    if (viewRef->scale != 1)
+        CGContextSetInterpolationQuality(context, sInterpolationQuality);
+
+    CGContextClipToRect(context, dirtyRect);
+    [self drawRect:dirtyRect];
+
+    if (!_drawsOwnDescendants) {
+        NSArray *subViews = [self subviews];
+        for (WAKView *subView in subViews) {
+            NSRect childDirtyRect = [self convertRect:dirtyRect toView:subView];
+            [subView _drawRect:CGRectIntegral(childDirtyRect) context:context lockFocus:YES];
+        }
+    }
+
+    if (lockFocus)
+        [self _unlockFocusViewInContext:context];
+}
+
+- (void)displayRect:(NSRect)rect
+{
+    CGContextRef context = WKGetCurrentGraphicsContext();
+    if (!context) {
+        WKError ("unable to get context for view");
+        return;
+    }
+
+    [self _drawRect:rect context:context lockFocus:YES];
+}
+
+- (void)displayRectIgnoringOpacity:(NSRect)rect
+{
+    [self displayRect:rect];
+}
+
+- (void)displayRectIgnoringOpacity:(NSRect)rect inContext:(CGContextRef)context
+{
+    if (!context) {
+        WKError ("invalid parameter: context must not be NULL");
+        return;
+    }
+
+    CGContextRef previousContext = WKGetCurrentGraphicsContext();
+    if (context != previousContext)
+        WKSetCurrentGraphicsContext(context);
+
+    [self _drawRect:rect context:context lockFocus:NO];
+
+    if (context != previousContext)
+        WKSetCurrentGraphicsContext (previousContext);
+}
+
+- (NSRect)visibleRect
+{
+    return WKViewGetVisibleRect (viewRef);
+}
+
+- (NSPoint)convertPoint:(NSPoint)aPoint toView:(WAKView *)aView 
+{
+    CGPoint p = WKViewConvertPointToBase (viewRef, aPoint);
+    if (aView)
+        return WKViewConvertPointFromBase ([aView _viewRef], p);
+    return p;
+}
+
+- (NSPoint)convertPoint:(NSPoint)aPoint fromView:(WAKView *)aView
+{
+    if (aView)
+        aPoint = WKViewConvertPointToBase ([aView _viewRef], aPoint);
+    return WKViewConvertPointFromBase (viewRef, aPoint);
+}
+
+- (NSSize)convertSize:(NSSize)size toView:(WAKView *)aView
+{
+    return [self convertRect:NSMakeRect(0.0f, 0.0f, size.width, size.height) toView:aView].size;
+}
+
+- (NSRect)convertRect:(NSRect)aRect fromView:(WAKView *)aView
+{
+    if (aView)
+        aRect = WKViewConvertRectToBase ([aView _viewRef], aRect);
+    return WKViewConvertRectFromBase (viewRef, aRect);
+}
+
+- (NSRect)convertRect:(NSRect)aRect toView:(WAKView *)aView
+{
+    CGRect r = WKViewConvertRectToBase (viewRef, aRect);
+    if (aView)
+        return WKViewConvertRectFromBase ([aView _viewRef], r);
+    return r;
+}
+
+- (void)lockFocus
+{
+    [self _lockFocusViewInContext:WKGetCurrentGraphicsContext()];
+}
+
+- (void)unlockFocus
+{
+    [self _unlockFocusViewInContext:WKGetCurrentGraphicsContext()];
+}
+
+- (WAKView *)hitTest:(NSPoint)point
+{
+    if (!CGRectContainsPoint([self frame], point))
+        return nil;
+
+    CGPoint subviewPoint = WKViewConvertPointFromSuperview(viewRef, point);
+    for (WAKView *subview in [self subviews]) {
+        if (WAKView *hitView = [subview hitTest: subviewPoint])
+            return hitView;
+    }
+
+    return self;
+}
+
+- (void)setHidden:(BOOL)flag 
+{
+    ASSERT(viewRef);
+    if (_isHidden != flag) {
+        // setNeedsDisplay does nothing if the view is hidden so call it at the right time.
+        if (flag) {
+            [self setNeedsDisplay:YES];
+            _isHidden = flag;
+        } else {
+            _isHidden = flag;
+            [self setNeedsDisplay:YES];
+        }
+    }
+}
+
+- (BOOL)isDescendantOf:(NSView *)aView
+{
+    if (aView == self)
+        return YES;
+    else if (![self superview])
+        return NO;
+    else
+        return [[self superview] isDescendantOf:aView];
+}
+
+- (BOOL)isHiddenOrHasHiddenAncestor
+{
+    if (_isHidden)
+        return YES;
+
+    if (![self superview])
+        return NO;
+
+    return [[self superview] isHiddenOrHasHiddenAncestor];
+}
+
+- (BOOL)mouse:(NSPoint)aPoint inRect:(NSRect)aRect 
+{ 
+    return WKMouseInRect (aPoint, aRect);
+}
+
+- (BOOL)needsPanelToBecomeKey
+{
+    return true;
+}
+
+- (void)setNextKeyView:(NSView *)aView
+{
+    UNUSED_PARAM(aView);
+}
+
+- (WAKView *)previousValidKeyView { return nil; }
+- (WAKView *)nextKeyView { return nil; }
+- (WAKView *)nextValidKeyView { return nil; }
+- (WAKView *)previousKeyView { return nil; }
+
+- (void)invalidateGState { }
+- (void)releaseGState { }
+- (BOOL)inLiveResize { return NO; }
+
+- (void)setAutoresizingMask:(unsigned int)mask
+{
+    WKViewSetAutoresizingMask(viewRef, mask);
+}
+
+- (unsigned int)autoresizingMask
+{
+    return WKViewGetAutoresizingMask(viewRef);
+}
+
+- (void)scrollPoint:(NSPoint)point 
+{
+    if (WAKScrollView *scrollView = enclosingScrollView(self)) {
+        CGPoint scrollViewPoint = [self convertPoint:point toView:scrollView];
+        [scrollView scrollPoint:scrollViewPoint];
+    }
+}
+
+- (BOOL)scrollRectToVisible:(NSRect)rect
+{
+    // Scroll if the rect is not already visible.
+    CGRect visibleRect = [self visibleRect];
+    if (!CGRectContainsRect(visibleRect, rect) && !CGRectContainsRect(rect, visibleRect))
+        [self scrollPoint:rect.origin];
+
+    // Return value ignored by WebCore.
+
+    return NO;
+}
+
+// Overridden by subclasses (only WebHTMLView for now).
+- (void)setNeedsLayout:(BOOL)flag
+{
+    UNUSED_PARAM(flag);
+}
+
+- (void)layout { }
+- (void)layoutIfNeeded { }
+
+- (void)setScale:(float)scale
+{
+    WKViewSetScale(viewRef, scale);
+}
+
+- (float)scale
+{
+    return WKViewGetScale(viewRef);
+}
+
+- (void)_setDrawsOwnDescendants:(BOOL)draw
+{
+    _drawsOwnDescendants = draw;
+}
+
+- (NSString *)description
+{
+    NSMutableString *description = [NSMutableString stringWithFormat:@"<%@: WAK: %p (WK: %p); ", [self class], self, viewRef];
+
+    CGRect frame = [self frame];
+    [description appendFormat:@"frame = (%g %g; %g %g)>", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
+
+    return description;
+}
+
+- (void)_appendDescriptionToString:(NSMutableString *)info atLevel:(int)level
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    if ([info length] != 0)
+        [info appendString:@"\n"];
+
+    for (int i = 1; i <= level; i++)
+        [info appendString:@"   | "];
+
+    [info appendString:[self description]];
+
+    for (WAKView *subview in [self subviews])
+        [subview _appendDescriptionToString:info atLevel:level + 1];
+
+    [pool release];
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WAKViewPrivate.h b/Source/WebCore/platform/ios/wak/WAKViewPrivate.h
new file mode 100644 (file)
index 0000000..4be3f2a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 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 WAKViewPrivate_h
+#define WAKViewPrivate_h
+
+#if TARGET_OS_IPHONE
+
+#import "WAKView.h"
+
+@interface WAKView (WAKPrivate)
+- (WKViewRef)_viewRef;
++ (WAKView *)_wrapperForViewRef:(WKViewRef)_viewRef;
+- (id)_initWithViewRef:(WKViewRef)view;
+- (BOOL)_handleResponderCall:(WKViewResponderCallbackType)type;
+- (NSMutableSet *)_subviewReferences;
+- (BOOL)_selfHandleEvent:(WebEvent *)event;
+@end
+
+static inline WAKView *WAKViewForWKViewRef(WKViewRef view)
+{
+    if (!view)
+        return nil;
+    WAKView *wrapper = (WAKView *)view->wrapper;
+    if (wrapper)
+        return wrapper;
+    return [WAKView _wrapperForViewRef:view];
+}
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKViewPrivate_h
diff --git a/Source/WebCore/platform/ios/wak/WAKWindow.h b/Source/WebCore/platform/ios/wak/WAKWindow.h
new file mode 100644 (file)
index 0000000..0129d21
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 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.
+ */
+
+#ifndef WAKWindow_h
+#define WAKWindow_h
+
+#if TARGET_OS_IPHONE
+
+#import "WAKAppKitStubs.h"
+#import "WAKResponder.h"
+#import "WAKView.h"
+#import "WKContentObservation.h"
+#import <CoreGraphics/CoreGraphics.h>
+#import <Foundation/Foundation.h>
+
+@class CALayer;
+@class WebEvent;
+
+#ifdef __cplusplus
+namespace WebCore {
+    class TileCache;
+}
+typedef WebCore::TileCache TileCache;
+#else
+typedef struct TileCache TileCache;
+#endif
+
+typedef enum {
+    kWAKWindowTilingModeNormal,
+    kWAKWindowTilingModeMinimal,
+    kWAKWindowTilingModePanning,
+    kWAKWindowTilingModeZooming,
+    kWAKWindowTilingModeDisabled,
+    kWAKWindowTilingModeScrollToTop,
+} WAKWindowTilingMode;
+
+typedef enum {
+    kWAKTilingDirectionUp,
+    kWAKTilingDirectionDown,
+    kWAKTilingDirectionLeft,
+    kWAKTilingDirectionRight,
+} WAKTilingDirection;
+
+extern NSString * const WAKWindowScreenScaleDidChangeNotification;
+extern NSString * const WAKWindowVisibilityDidChangeNotification;
+
+@interface WAKWindow : WAKResponder
+{
+    CALayer* _hostLayer;
+    TileCache* _tileCache;
+    CGRect _frozenVisibleRect;
+    CALayer *_rootLayer;
+
+    CGSize _screenSize;
+    CGSize _availableScreenSize;
+    CGFloat _screenScale;
+
+    CGRect _frame;
+
+    WAKView *_contentView;
+    WAKView *_responderView;
+    WAKView *_nextResponder;
+
+    BOOL _visible;
+    BOOL _useOrientationDependentFontAntialiasing;
+}
+
+@property (nonatomic, assign) BOOL useOrientationDependentFontAntialiasing;
+
+// If non-NULL, contentReplacementImage will draw into tiles instead of web content.
+@property (nonatomic) CGImageRef contentReplacementImage;
+
+// Create layer hosted window
+- (id)initWithLayer:(CALayer *)hostLayer;
+// Create unhosted window for manual painting
+- (id)initWithFrame:(CGRect)frame;
+
+- (CALayer*)hostLayer;
+
+- (void)setContentView:(WAKView *)aView;
+- (WAKView *)contentView;
+- (void)close;
+- (WAKView *)firstResponder;
+
+- (NSPoint)convertBaseToScreen:(NSPoint)aPoint;
+- (NSPoint)convertScreenToBase:(NSPoint)aPoint;
+- (BOOL)isKeyWindow;
+- (void)makeKeyWindow;
+- (BOOL)isVisible;
+- (void)setVisible:(BOOL)visible;
+- (NSSelectionDirection)keyViewSelectionDirection;
+- (BOOL)makeFirstResponder:(NSResponder *)aResponder;
+- (WAKView *)_newFirstResponderAfterResigning;
+- (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
+- (CGRect)frame;
+- (void)setContentRect:(CGRect)rect;
+- (void)setScreenSize:(CGSize)size;
+- (CGSize)screenSize;
+- (void)setAvailableScreenSize:(CGSize)size;
+- (CGSize)availableScreenSize;
+- (void)setScreenScale:(CGFloat)scale;
+- (CGFloat)screenScale;
+- (void)setRootLayer:(CALayer *)layer;
+- (CALayer *)rootLayer;
+- (void)sendEvent:(WebEvent *)anEvent;
+- (void)sendEventSynchronously:(WebEvent *)anEvent;
+- (void)sendMouseMoveEvent:(WebEvent *)anEvent contentChange:(WKContentChange *)aContentChange;
+
+// Thread safe way of providing the "usable" rect of the WAKWindow in the viewport/scrollview.
+- (CGRect)exposedScrollViewRect;
+// setExposedScrollViewRect should only ever be called from UIKit.
+- (void)setExposedScrollViewRect:(CGRect)exposedScrollViewRect;
+
+// Tiling support
+- (void)layoutTiles;
+- (void)layoutTilesNow;
+- (void)layoutTilesNowForRect:(CGRect)rect;
+- (void)setNeedsDisplay;
+- (void)setNeedsDisplayInRect:(CGRect)rect;
+- (BOOL)tilesOpaque;
+- (void)setTilesOpaque:(BOOL)opaque;
+- (CGRect)visibleRect;
+// The extended visible rect includes the area outside superviews with
+// masksToBounds set to NO.
+- (CGRect)extendedVisibleRect;
+- (void)removeAllNonVisibleTiles;
+- (void)removeAllTiles;
+- (void)removeForegroundTiles;
+- (void)setTilingMode:(WAKWindowTilingMode)mode;
+- (WAKWindowTilingMode)tilingMode;
+- (void)setTilingDirection:(WAKTilingDirection)tilingDirection;
+- (WAKTilingDirection)tilingDirection;
+- (BOOL)hasPendingDraw;
+- (void)displayRect:(NSRect)rect;
+- (void)setZoomedOutTileScale:(float)scale;
+- (float)zoomedOutTileScale;
+- (void)setCurrentTileScale:(float)scale;
+- (float)currentTileScale;
+- (void)setKeepsZoomedOutTiles:(BOOL)keepsZoomedOutTiles;
+- (BOOL)keepsZoomedOutTiles;
+- (TileCache *)tileCache;
+
+- (void)dumpTiles;
+
+- (void)setTileBordersVisible:(BOOL)visible;
+- (void)setTilePaintCountsVisible:(BOOL)visible;
+- (void)setAcceleratedDrawingEnabled:(BOOL)enabled;
+
+- (void)freezeVisibleRect;
+- (void)unfreezeVisibleRect;
+- (void)willRotate;
+- (void)didRotate;
+
+- (BOOL)useOrientationDependentFontAntialiasing;
+- (void)setUseOrientationDependentFontAntialiasing:(BOOL)aa;
++ (BOOL)hasLandscapeOrientation;
++ (void)setOrientationProvider:(id)provider;
+
++ (WebEvent *)currentEvent;
+
+- (NSString *)recursiveDescription;
+@end
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WAKWindow_h
diff --git a/Source/WebCore/platform/ios/wak/WAKWindow.mm b/Source/WebCore/platform/ios/wak/WAKWindow.mm
new file mode 100644 (file)
index 0000000..75c9d7e
--- /dev/null
@@ -0,0 +1,697 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 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 "config.h"
+#import "WAKWindow.h"
+
+#if PLATFORM(IOS)
+
+#import "TileCache.h"
+#import "WAKViewPrivate.h"
+#import "WebCoreSystemInterface.h"
+#import "WebCoreThreadRun.h"
+#import "WebEvent.h"
+#import "WKContentObservation.h"
+#import "WKViewPrivate.h"
+#import <QuartzCore/QuartzCore.h>
+#import <wtf/TCSpinLock.h>
+
+NSString * const WAKWindowScreenScaleDidChangeNotification = @"WAKWindowScreenScaleDidChangeNotification";
+NSString * const WAKWindowVisibilityDidChangeNotification = @"WAKWindowVisibilityDidChangeNotification";
+
+using namespace WebCore;
+
+@protocol OrientationProvider
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
+- (BOOL)hasLandscapeOrientation;
+#else
+- (int)orientation;
+#endif
+@end
+
+static WAKWindow *_WAKKeyWindow = nil;        // weak
+static WebEvent *currentEvent = nil;
+static id<OrientationProvider> gOrientationProvider;
+
+@implementation WAKWindow {
+    SpinLock _exposedScrollViewRectLock;
+    CGRect _exposedScrollViewRect;
+}
+
+@synthesize useOrientationDependentFontAntialiasing = _useOrientationDependentFontAntialiasing;
+
+- (id)initWithLayer:(CALayer *)layer
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _hostLayer = [layer retain];
+
+    _frame = [_hostLayer frame];
+    _screenScale = wkGetScreenScaleFactor();
+    
+    _tileCache = new TileCache(self);
+
+    _frozenVisibleRect = CGRectNull;
+
+    _exposedScrollViewRectLock = SPINLOCK_INITIALIZER;
+    _exposedScrollViewRect = CGRectNull;
+
+    return self;
+}
+
+// This is used for WebViews that are not backed by the tile cache. Their content must be painted manually.
+- (id)initWithFrame:(CGRect)frame
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _frame = frame;
+    _screenScale = wkGetScreenScaleFactor();
+
+    _exposedScrollViewRectLock = SPINLOCK_INITIALIZER;
+    _exposedScrollViewRect = CGRectNull;
+
+    return self;
+}
+
+- (void)dealloc
+{
+    delete _tileCache;
+    [_hostLayer release];
+    
+    [super dealloc];
+}
+
+- (void)setContentView:(WAKView *)aView
+{
+    [aView retain];
+    [_contentView release];
+
+    if (aView)
+        _WKViewSetWindow([aView _viewRef], self);
+    _contentView = aView;
+}
+
+- (WAKView *)contentView
+{
+    return _contentView;
+}
+
+- (void)close
+{
+    if (_contentView) {
+        _WKViewSetWindow([_contentView _viewRef], nil);
+        [_contentView release];
+        _contentView = nil;
+    }
+
+    [_responderView release];
+    _responderView = nil;
+}
+
+- (WAKView *)firstResponder
+{
+    return _responderView;
+}
+
+- (WAKView *)_newFirstResponderAfterResigning
+{
+    return _nextResponder;
+}
+
+- (NSPoint)convertBaseToScreen:(NSPoint)aPoint
+{
+    UNUSED_PARAM(aPoint);
+    NSPoint p = { 0, 0 };
+    return p;
+}
+
+- (NSPoint)convertScreenToBase:(NSPoint)aPoint
+{
+    UNUSED_PARAM(aPoint);
+    NSPoint p = { 0, 0 };
+    return p;
+}
+
+- (BOOL)isKeyWindow
+{
+    return YES || self == _WAKKeyWindow; 
+}
+
+- (void)makeKeyWindow
+{
+    if ([self isKeyWindow])
+        return;
+    
+    _WAKKeyWindow = self;
+}
+
+- (BOOL)isVisible
+{
+    return _visible;
+}
+
+- (void)setVisible:(BOOL)visible
+{
+    if (_visible == visible)
+        return;
+
+    _visible = visible;
+
+    WebThreadRun(^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:WAKWindowVisibilityDidChangeNotification object:self userInfo:nil];
+    });
+}
+
+- (NSSelectionDirection)keyViewSelectionDirection
+{
+    return (NSSelectionDirection)0;
+}
+
+- (BOOL)makeFirstResponder:(NSResponder *)aResponder
+{
+    if (![aResponder isKindOfClass:[WAKView class]])
+        return NO;
+
+    WAKView *view = static_cast<WAKView*>(aResponder);
+    BOOL result = YES;
+    if (view != _responderView) {
+        // We need to handle the case of the view not accepting to be a first responder,
+        // where we don't need to resign as first responder.
+        BOOL acceptsFirstResponder = view ? WKViewAcceptsFirstResponder([view _viewRef]) : YES;
+        if (acceptsFirstResponder && _responderView) {
+            _nextResponder = view;
+            if (WKViewResignFirstResponder([_responderView _viewRef])) {
+                _nextResponder = nil;
+                [_responderView release];
+                _responderView = nil;
+            }  else {
+                _nextResponder = nil;
+                result = NO;
+            }
+        }
+
+        if (result && view) {
+            if (acceptsFirstResponder && WKViewBecomeFirstResponder([view _viewRef]))
+                _responderView = [view retain];
+            else
+                result = NO;
+        }
+    }
+
+    return result;
+}
+
+// FIXME: This method can lead to incorrect state. Remove if possible.
+- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
+{
+    UNUSED_PARAM(flag);
+    _frame = frameRect;
+}
+
+// FIXME: the correct value if there is a host layer is likely to return [_hostLayer frame].
+- (CGRect)frame
+{
+    return _frame;
+}
+
+- (void)setContentRect:(CGRect)rect
+{
+    if (CGRectEqualToRect(rect, _frame))
+        return;
+    _frame = rect;
+
+    // FIXME: Size of the host layer is directly available so there is no real reason to save it here.
+    // However we currently use this call to catch changes to the host layer size.
+    if (_tileCache)
+        _tileCache->hostLayerSizeChanged();
+}
+
+- (void)setScreenSize:(CGSize)size
+{
+    _screenSize = size;
+}
+
+- (CGSize)screenSize
+{
+    return _screenSize;
+}
+
+- (void)setAvailableScreenSize:(CGSize)size
+{
+    _availableScreenSize = size;
+}
+
+- (CGSize)availableScreenSize
+{
+    return _availableScreenSize;
+}
+
+- (void)setScreenScale:(CGFloat)scale
+{
+    _screenScale = scale;
+
+    WebThreadRun(^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:WAKWindowScreenScaleDidChangeNotification object:self userInfo:nil];
+    });
+}
+
+- (CGFloat)screenScale
+{
+    return _screenScale;
+}
+
+- (void)setRootLayer:(CALayer *)layer
+{
+    _rootLayer = layer;
+}
+
+- (CALayer *)rootLayer
+{
+    return _rootLayer;
+}
+
+- (void)sendEvent:(WebEvent *)anEvent
+{
+    ASSERT(anEvent);
+    WebThreadRun(^{
+        [self sendEventSynchronously:anEvent];
+    });
+}
+
+- (void)sendEventSynchronously:(WebEvent *)anEvent
+{
+    ASSERT(anEvent);
+    ASSERT(WebThreadIsLockedOrDisabled());
+    WebEvent *lastEvent = currentEvent;
+    currentEvent = [anEvent retain];
+
+    switch (anEvent.type) {
+        case WebEventMouseMoved:
+        case WebEventScrollWheel:
+            if (WAKView *hitView = [_contentView hitTest:(anEvent.locationInWindow)])
+                [hitView handleEvent:anEvent];
+            break;
+
+        case WebEventMouseUp:
+        case WebEventKeyDown:
+        case WebEventKeyUp:
+        case WebEventTouchChange:
+            [_responderView handleEvent:anEvent];
+            break;
+
+        case WebEventMouseDown:
+        case WebEventTouchBegin:
+        case WebEventTouchEnd:
+        case WebEventTouchCancel:
+            if (WAKView *hitView = [_contentView hitTest:(anEvent.locationInWindow)]) {
+                [self makeFirstResponder:hitView];
+                [hitView handleEvent:anEvent];
+            }
+            break;
+
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+
+    [currentEvent release];
+    currentEvent = lastEvent;
+}
+
+- (void)sendMouseMoveEvent:(WebEvent *)anEvent contentChange:(WKContentChange *)aContentChange
+{
+    WebThreadRun(^{
+        [self sendEvent:anEvent];
+
+        if (aContentChange)
+            *aContentChange = WKObservedContentChange();
+    });
+}
+
+- (void)setExposedScrollViewRect:(CGRect)exposedScrollViewRect
+{
+    SpinLockHolder locker(&_exposedScrollViewRectLock);
+    _exposedScrollViewRect = exposedScrollViewRect;
+}
+
+- (CGRect)exposedScrollViewRect
+{
+    {
+        SpinLockHolder locker(&_exposedScrollViewRectLock);
+        if (!CGRectIsNull(_exposedScrollViewRect))
+            return _exposedScrollViewRect;
+    }
+    return [self visibleRect];
+}
+
+// Tiling
+
+- (void)layoutTiles
+{
+    if (!_tileCache)
+        return;    
+    _tileCache->layoutTiles();
+}
+
+- (void)layoutTilesNow
+{
+    if (!_tileCache)
+        return;
+    _tileCache->layoutTilesNow();
+}
+
+- (void)layoutTilesNowForRect:(CGRect)rect
+{
+    if (!_tileCache)
+        return;
+    _tileCache->layoutTilesNowForRect(enclosingIntRect(rect));
+}
+
+- (void)setNeedsDisplay
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setNeedsDisplay();
+}
+
+- (void)setNeedsDisplayInRect:(CGRect)rect
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setNeedsDisplayInRect(enclosingIntRect(rect));
+}
+
+- (BOOL)tilesOpaque
+{
+    if (!_tileCache)
+        return NO;
+    return _tileCache->tilesOpaque();
+}
+
+- (void)setTilesOpaque:(BOOL)opaque
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setTilesOpaque(opaque);
+}
+
+- (CGRect)_visibleRectRespectingMasksToBounds:(BOOL)respectsMasksToBounds
+{
+    if (!CGRectIsNull(_frozenVisibleRect))
+        return _frozenVisibleRect;
+
+    CALayer* layer = _hostLayer;
+    CGRect bounds = [layer bounds];
+    CGRect rect = bounds;
+    CALayer* superlayer = [layer superlayer];
+
+    while (superlayer && layer != _rootLayer) {
+        CGRect rectInSuper = [superlayer convertRect:rect fromLayer:layer];
+        if ([superlayer masksToBounds] || !respectsMasksToBounds)
+            rect = CGRectIntersection([superlayer bounds], rectInSuper);
+        else
+            rect = rectInSuper;
+        layer = superlayer;
+        superlayer = [layer superlayer];
+    }
+    
+    if (layer != _hostLayer) {
+        rect = CGRectIntersection([layer bounds], rect);
+        rect = [_hostLayer convertRect:rect fromLayer:layer];
+    }
+    
+    return CGRectIntersection(bounds, rect);
+}
+
+- (CGRect)visibleRect
+{
+    return [self _visibleRectRespectingMasksToBounds:NO];
+}
+
+- (CGRect)extendedVisibleRect
+{
+    return [self _visibleRectRespectingMasksToBounds:YES];
+}
+
+- (void)removeAllNonVisibleTiles
+{
+    if (!_tileCache)
+        return;
+    _tileCache->removeAllNonVisibleTiles();
+}
+
+- (void)removeAllTiles
+{
+    if (!_tileCache)
+        return;
+    _tileCache->removeAllTiles();
+}
+
+- (void)removeForegroundTiles
+{
+    if (!_tileCache)
+        return;
+    _tileCache->removeForegroundTiles();
+}
+
+- (void)setTilingMode:(WAKWindowTilingMode)mode
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setTilingMode((TileCache::TilingMode)mode);
+}
+
+- (WAKWindowTilingMode)tilingMode
+{
+    if (!_tileCache)
+        return kWAKWindowTilingModeDisabled;
+    return (WAKWindowTilingMode)_tileCache->tilingMode();
+}
+
+- (void)setTilingDirection:(WAKTilingDirection)tilingDirection
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setTilingDirection((TileCache::TilingDirection)tilingDirection);
+}
+
+- (WAKTilingDirection)tilingDirection
+{
+    if (!_tileCache)
+        return kWAKTilingDirectionDown;
+    return (WAKTilingDirection)_tileCache->tilingDirection();
+}
+
+- (void)setZoomedOutTileScale:(float)scale
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setZoomedOutScale(scale);
+}
+
+- (float)zoomedOutTileScale
+{
+    if (!_tileCache)
+        return 1.0f;
+    return _tileCache->zoomedOutScale();
+}
+
+- (void)setCurrentTileScale:(float)scale
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setCurrentScale(scale);
+}
+
+- (float)currentTileScale
+{
+    if (!_tileCache)
+        return 1.0f;
+    return _tileCache->currentScale();
+}
+
+- (void)setKeepsZoomedOutTiles:(BOOL)keepsZoomedOutTiles
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setKeepsZoomedOutTiles(keepsZoomedOutTiles);
+}
+
+- (BOOL)keepsZoomedOutTiles
+{
+    if (!_tileCache)
+        return NO;
+    return _tileCache->keepsZoomedOutTiles();
+}
+
+- (TileCache*)tileCache
+{
+    return _tileCache;
+}
+
+- (BOOL)hasPendingDraw
+{
+    if (!_tileCache)
+        return NO;
+     return _tileCache->hasPendingDraw();
+}
+
+- (void)setContentReplacementImage:(CGImageRef)contentReplacementImage
+{
+    if (!_tileCache)
+        return;
+    _tileCache->setContentReplacementImage(contentReplacementImage);
+}
+
+- (CGImageRef)contentReplacementImage
+{
+    if (!_tileCache)
+        return NULL;
+    return _tileCache->contentReplacementImage().get();
+}
+
+- (void)displayRect:(NSRect)rect
+{
+    [[self contentView] displayRect:rect];
+}
+
+- (void)willRotate
+{
+    [self freezeVisibleRect];
+}
+
+- (void)didRotate
+{
+    [self unfreezeVisibleRect];
+}
+
+- (void)freezeVisibleRect
+{
+    _frozenVisibleRect = [self visibleRect];
+}
+
+- (void)unfreezeVisibleRect
+{
+    _frozenVisibleRect = CGRectNull;
+}
+
++ (void)setOrientationProvider:(id)provider
+{
+    // This is really the UIWebDocumentView class that calls into UIApplication to get the orientation.
+    gOrientationProvider = provider;
+}
+
++ (BOOL)hasLandscapeOrientation
+{
+    // this should be perfectly thread safe
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
+    return [gOrientationProvider hasLandscapeOrientation];
+#else
+    int orientation = [gOrientationProvider orientation];
+    return orientation == 90 || orientation == -90;
+#endif
+}
+
+- (CALayer*)hostLayer
+{
+    return _hostLayer;
+}
+
+- (void)setTileBordersVisible:(BOOL)visible
+{
+    if (!_tileCache)
+        return;
+
+    _tileCache->setTileBordersVisible(visible);
+}
+
+- (void)setTilePaintCountsVisible:(BOOL)visible
+{
+    if (!_tileCache)
+        return;
+
+    _tileCache->setTilePaintCountersVisible(visible);
+}
+
+- (void)setAcceleratedDrawingEnabled:(BOOL)enabled
+{
+    if (!_tileCache)
+        return;
+
+    _tileCache->setAcceleratedDrawingEnabled(enabled);
+}
+
+- (void)dumpTiles
+{
+    CGRect savedFrozenVisibleRect = _frozenVisibleRect;
+    NSLog(@"=================");
+    if (!CGRectIsNull(_frozenVisibleRect)) {
+        NSLog(@"VISIBLE RECT IS CACHED: [%6.1f %6.1f %6.1f %6.1f]", _frozenVisibleRect.origin.x, _frozenVisibleRect.origin.y, _frozenVisibleRect.size.width, _frozenVisibleRect.size.height);
+        _frozenVisibleRect = CGRectNull;
+    }
+    CGRect visibleRect = [self visibleRect];
+    NSLog(@"visibleRect = [%6.1f %6.1f %6.1f %6.1f]", visibleRect.origin.x, visibleRect.origin.y, visibleRect.size.width, visibleRect.size.height);
+    _frozenVisibleRect = savedFrozenVisibleRect;
+    _tileCache->dumpTiles();
+}
+
+- (NSString *)description
+{
+    NSMutableString *description = [NSMutableString stringWithFormat:@"<%@: WAK: %p; ", [self class], self];
+
+    CGRect frame = [self frame];
+    [description appendFormat:@"frame = (%g %g; %g %g); ", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height];
+
+    [description appendFormat:@"first responder = WK %p; ", _responderView];
+    [description appendFormat:@"next responder = WK %p; ", _nextResponder];
+
+    [description appendFormat:@"layer = %@>", [_hostLayer description]];
+
+    return description;
+}
+
++ (WebEvent *)currentEvent
+{
+    return currentEvent;
+}
+
+- (NSString *)recursiveDescription
+{
+    NSMutableString *info = [NSMutableString string];
+
+    [info appendString:[self description]];
+
+    [[self contentView] _appendDescriptionToString:info atLevel:1];
+
+    return info;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WKContentObservation.cpp b/Source/WebCore/platform/ios/wak/WKContentObservation.cpp
new file mode 100644 (file)
index 0000000..855819a
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WKContentObservation.h"
+
+#if PLATFORM(IOS)
+
+#include "JSDOMBinding.h"
+#include "WebCoreThread.h"
+#include <wtf/HashMap.h>
+
+WKContentChange _WKContentChange                    = WKContentNoChange;
+bool            _WKObservingContentChanges          = false;
+bool            _WKObservingIndeterminateChanges    = false;
+
+using namespace WTF;
+
+bool WKObservingContentChanges(void)
+{
+    return _WKObservingContentChanges;
+}
+
+void WKStopObservingContentChanges(void)
+{
+    _WKObservingContentChanges = false;
+    _WKObservingIndeterminateChanges = false;
+}
+
+void WKBeginObservingContentChanges(bool allowsIntedeterminateChanges)
+{
+    _WKContentChange = WKContentNoChange;
+    _WKObservingContentChanges = true;
+    
+    _WKObservingIndeterminateChanges = allowsIntedeterminateChanges;
+    if (_WKObservingIndeterminateChanges)
+        WebThreadClearObservedContentModifiers();
+}
+
+WKContentChange WKObservedContentChange(void)
+{
+    return _WKContentChange;
+}
+
+void WKSetObservedContentChange(WKContentChange aChange)
+{
+    if (aChange > _WKContentChange && (_WKObservingIndeterminateChanges || aChange != WKContentIndeterminateChange)) {
+        _WKContentChange = aChange;
+        if (_WKContentChange == WKContentVisibilityChange)
+            WebThreadClearObservedContentModifiers();
+    }
+}
+
+static HashMap<void *, void *> * WebThreadGetObservedContentModifiers()
+{
+    ASSERT(WebThreadIsLockedOrDisabled());
+    typedef HashMap<void *, void *> VoidVoidMap;
+    DEFINE_STATIC_LOCAL(VoidVoidMap, observedContentModifiers, ());
+    return &observedContentModifiers;
+}
+
+int WebThreadCountOfObservedContentModifiers(void)
+{
+    return WebThreadGetObservedContentModifiers()->size();
+}
+
+void WebThreadClearObservedContentModifiers()
+{
+    WebThreadGetObservedContentModifiers()->clear();
+}
+
+bool WebThreadContainsObservedContentModifier(void * aContentModifier)
+{
+    return WebThreadGetObservedContentModifiers()->contains(aContentModifier);
+}
+
+void WebThreadAddObservedContentModifier(void * aContentModifier)
+{
+    if (_WKContentChange != WKContentVisibilityChange && _WKObservingIndeterminateChanges)
+        WebThreadGetObservedContentModifiers()->set(aContentModifier, aContentModifier);
+}
+
+void WebThreadRemoveObservedContentModifier(void * aContentModifier)
+{
+    WebThreadGetObservedContentModifiers()->remove(aContentModifier);
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WKContentObservation.h b/Source/WebCore/platform/ios/wak/WKContentObservation.h
new file mode 100644 (file)
index 0000000..78fce3a
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 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 WKContentObservation_h
+#define WKContentObservation_h
+
+#if TARGET_OS_IPHONE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+    WKContentNoChange               = 0,
+    WKContentVisibilityChange       = 2,
+    WKContentIndeterminateChange    = 1
+}   WKContentChange;
+
+bool WKObservingContentChanges(void);
+
+void WKStopObservingContentChanges(void);
+void WKBeginObservingContentChanges(bool allowsIntedeterminateChanges);
+
+WKContentChange WKObservedContentChange(void);
+void WKSetObservedContentChange(WKContentChange aChange);
+
+int WebThreadCountOfObservedContentModifiers(void);
+void WebThreadClearObservedContentModifiers(void);
+
+bool WebThreadContainsObservedContentModifier(void * aContentModifier);
+void WebThreadAddObservedContentModifier(void * aContentModifier);
+void WebThreadRemoveObservedContentModifier(void * aContentModifier);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WKContentObservation_h
diff --git a/Source/WebCore/platform/ios/wak/WKGraphics.h b/Source/WebCore/platform/ios/wak/WKGraphics.h
new file mode 100644 (file)
index 0000000..c3f3017
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 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 WKGraphics_h
+#define WKGraphics_h
+
+#if TARGET_OS_IPHONE
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <CoreGraphics/CoreGraphicsPrivate.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CGContextRef WKGetCurrentGraphicsContext(void);
+void WKSetCurrentGraphicsContext(CGContextRef context);
+
+void WKRectFill(CGContextRef context, CGRect aRect);
+void WKRectFillUsingOperation(CGContextRef context, CGRect aRect, CGCompositeOperation op);
+
+CGImageRef WKGraphicsCreateImageFromBundleWithName(const char *image_file);
+CGPatternRef WKCreatePatternFromCGImage(CGImageRef imageRef);
+void WKSetPattern(CGContextRef context, CGPatternRef pattern, bool fill, bool stroke);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+class WKFontAntialiasingStateSaver
+{
+public:
+
+    WKFontAntialiasingStateSaver(CGContextRef context, bool useOrientationDependentFontAntialiasing)
+        : m_context(context)
+        , m_useOrientationDependentFontAntialiasing(useOrientationDependentFontAntialiasing)
+    {
+    }
+
+    void setup(bool isLandscapeOrientation);
+    void restore();
+
+private:
+
+#if PLATFORM(IOS_SIMULATOR)
+#pragma clang diagnostic push
+#if defined(__has_warning) && __has_warning("-Wunused-private-field")
+#pragma clang diagnostic ignored "-Wunused-private-field"
+#endif
+#endif
+    CGContextRef m_context;
+    bool m_useOrientationDependentFontAntialiasing;
+    CGFontAntialiasingStyle m_oldAntialiasingStyle;
+#if PLATFORM(IOS_SIMULATOR)
+#pragma clang diagnostic pop
+#endif
+};
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WKGraphics_h
diff --git a/Source/WebCore/platform/ios/wak/WKGraphics.mm b/Source/WebCore/platform/ios/wak/WKGraphics.mm
new file mode 100644 (file)
index 0000000..3e7e68a
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 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 "config.h"
+#import "WKGraphics.h"
+
+#if PLATFORM(IOS)
+
+#import "WebCoreSystemInterface.h"
+#import "Font.h"
+#import "WebCoreThread.h"
+#import <ImageIO/ImageIO.h>
+#import <wtf/StdLibExtras.h>
+
+using namespace WebCore;
+
+static inline void _FillRectsUsingOperation(CGContextRef context, const CGRect* rects, int count, CGCompositeOperation op)
+{
+    int i;
+    CGRect *integralRects = reinterpret_cast<CGRect *>(alloca(sizeof(CGRect) * count));
+    
+    assert (integralRects);
+    
+    for (i = 0; i < count; i++) {
+        integralRects[i] = CGRectApplyAffineTransform (rects[i], CGContextGetCTM(context));
+        integralRects[i] = CGRectIntegral (integralRects[i]);
+        integralRects[i] = CGRectApplyAffineTransform (integralRects[i], CGAffineTransformInvert(CGContextGetCTM(context)));
+    }
+    CGCompositeOperation oldOp = CGContextGetCompositeOperation(context);
+    CGContextSetCompositeOperation(context, op);
+    CGContextFillRects(context, integralRects, count);
+    CGContextSetCompositeOperation(context, oldOp);
+}
+
+static inline void _FillRectUsingOperation(CGContextRef context, CGRect rect, CGCompositeOperation op)
+{
+    if (rect.size.width > 0 && rect.size.height > 0) {
+        _FillRectsUsingOperation (context, &rect, 1, op);
+    }
+}
+
+void WKRectFill(CGContextRef context, CGRect aRect)
+{
+    if (aRect.size.width > 0 && aRect.size.height > 0) {
+        CGContextSaveGState(context);
+        _FillRectUsingOperation(context, aRect, kCGCompositeCopy);
+        CGContextRestoreGState(context);
+    }
+}
+
+void WKRectFillUsingOperation(CGContextRef context, CGRect aRect, CGCompositeOperation op)
+{
+    if (aRect.size.width > 0 && aRect.size.height > 0.0) {
+        CGContextSaveGState(context);
+        _FillRectUsingOperation(context, aRect, op);
+        CGContextRestoreGState(context);
+    }
+}
+
+void WKSetCurrentGraphicsContext(CGContextRef context)
+{
+    WebThreadContext* threadContext =  WebThreadCurrentContext();
+    threadContext->currentCGContext = context;
+}
+
+CGContextRef WKGetCurrentGraphicsContext(void)
+{
+    WebThreadContext* threadContext =  WebThreadCurrentContext();
+    return threadContext->currentCGContext;
+}
+
+static NSString *imageResourcePath(const char* imageFile, bool is2x)
+{
+    NSString *fileName = is2x ? [NSString stringWithFormat:@"%s@2x", imageFile] : [NSString stringWithUTF8String:imageFile];
+#if PLATFORM(IOS_SIMULATOR)
+    NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
+    return [bundle pathForResource:fileName ofType:@"png"];
+#else
+    // Workaround for <rdar://problem/7780665> CFBundleCopyResourceURL takes a long time on iPhone 3G.
+    NSString *imageDirectory = @"/System/Library/PrivateFrameworks/WebCore.framework";
+    return [NSString stringWithFormat:@"%@/%@.png", imageDirectory, fileName];
+#endif
+}
+
+CGImageRef WKGraphicsCreateImageFromBundleWithName (const char *image_file)
+{
+    if (!image_file)
+        return NULL;
+
+    CGImageRef image = nullptr;
+    NSData *imageData = nil;
+
+    if (wkGetScreenScaleFactor() == 2) {
+        NSString* full2xPath = imageResourcePath(image_file, true);
+        imageData = [NSData dataWithContentsOfFile:full2xPath];
+    }
+    if (!imageData) {
+        // We got here either because we didn't request hi-dpi or the @2x file doesn't exist.
+        NSString* full1xPath = imageResourcePath(image_file, false);
+        imageData = [NSData dataWithContentsOfFile:full1xPath];
+    }
+    
+    if (imageData) {
+        RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(reinterpret_cast<CFDataRef>(imageData)));
+        image = CGImageCreateWithPNGDataProvider(dataProvider.get(), nullptr, NO, kCGRenderingIntentDefault);
+    }
+
+    return image;
+}
+
+static void WKDrawPatternBitmap(void *info, CGContextRef c) 
+{
+    CGImageRef image = (CGImageRef)info;
+    CGFloat scale = wkGetScreenScaleFactor();
+    CGContextDrawImage(c, CGRectMake(0, 0, CGImageGetWidth(image) / scale, CGImageGetHeight(image) / scale), image);    
+}
+
+static void WKReleasePatternBitmap(void *info) 
+{
+    CGImageRelease(reinterpret_cast<CGImageRef>(info));
+}
+
+static const CGPatternCallbacks WKPatternBitmapCallbacks = 
+{
+    0, WKDrawPatternBitmap, WKReleasePatternBitmap
+};
+
+CGPatternRef WKCreatePatternFromCGImage(CGImageRef imageRef)
+{
+    // retain image since it's freed by our callback
+    CGImageRetain(imageRef);
+
+    CGFloat scale = wkGetScreenScaleFactor();
+    return CGPatternCreate((void*)imageRef, CGRectMake(0, 0, CGImageGetWidth(imageRef) / scale, CGImageGetHeight(imageRef) / scale), CGAffineTransformIdentity, CGImageGetWidth(imageRef) / scale, CGImageGetHeight(imageRef) / scale, kCGPatternTilingConstantSpacing, 1 /*isColored*/, &WKPatternBitmapCallbacks);
+}
+
+void WKSetPattern(CGContextRef context, CGPatternRef pattern, bool fill, bool stroke) 
+{
+    if (pattern == NULL)
+        return;
+
+    CGFloat patternAlpha = 1;
+    CGColorSpaceRef colorspace = CGColorSpaceCreatePattern(NULL);
+    if (fill) {
+        CGContextSetFillColorSpace(context, colorspace);
+        CGContextSetFillPattern(context, pattern, &patternAlpha);
+    }
+    if (stroke) {
+        CGContextSetStrokeColorSpace(context, colorspace);
+        CGContextSetStrokePattern(context, pattern, &patternAlpha);
+    }
+    CGColorSpaceRelease(colorspace);
+}
+
+void WKFontAntialiasingStateSaver::setup(bool isLandscapeOrientation)
+{
+#if !PLATFORM(IOS_SIMULATOR)
+    m_oldAntialiasingStyle = CGContextGetFontAntialiasingStyle(m_context);
+
+    if (m_useOrientationDependentFontAntialiasing)
+        CGContextSetFontAntialiasingStyle(m_context, isLandscapeOrientation ? kCGFontAntialiasingStyleFilterLight : kCGFontAntialiasingStyleUnfiltered);
+#else
+    UNUSED_PARAM(isLandscapeOrientation);
+#endif
+}
+
+void WKFontAntialiasingStateSaver::restore()
+{
+#if !PLATFORM(IOS_SIMULATOR)
+    if (m_useOrientationDependentFontAntialiasing)
+        CGContextSetFontAntialiasingStyle(m_context, m_oldAntialiasingStyle);
+#endif
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WKTypes.h b/Source/WebCore/platform/ios/wak/WKTypes.h
new file mode 100644 (file)
index 0000000..cd9374c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 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 WKTypes_h
+#define WKTypes_h
+
+#if TARGET_OS_IPHONE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _WKObject WKObject;
+typedef struct _WKObject *WKObjectRef;
+typedef struct WKControl* WKControlRef;
+typedef struct _WKView* WKViewRef;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WKTypes_h
diff --git a/Source/WebCore/platform/ios/wak/WKUtilities.c b/Source/WebCore/platform/ios/wak/WKUtilities.c
new file mode 100644 (file)
index 0000000..32f6364
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2005, 2006, 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 "config.h"
+#import "WKUtilities.h"
+
+#if PLATFORM(IOS)
+
+#import <wtf/Assertions.h>
+
+const CFArrayCallBacks WKCollectionArrayCallBacks = { 0, WKCollectionRetain, WKCollectionRelease, NULL, NULL };
+const CFSetCallBacks WKCollectionSetCallBacks = { 0, WKCollectionRetain, WKCollectionRelease, NULL, NULL, NULL };
+
+const void *WKCollectionRetain (CFAllocatorRef allocator, const void *value)
+{
+    UNUSED_PARAM(allocator);
+    return WKRetain (value);
+}
+
+const void *WKRetain(const void *o)
+{
+    WKObjectRef object = (WKObjectRef)o;
+    
+    object->referenceCount++;
+    
+    return object;
+}
+
+void WKCollectionRelease (CFAllocatorRef allocator, const void *value)
+{
+    UNUSED_PARAM(allocator);
+    WKRelease (value);
+}
+
+void WKRelease(const void *o)
+{
+    WKObjectRef object = (WKObjectRef)o;
+
+    if (object->referenceCount == 0) {
+        WKError ("attempt to release invalid object");
+        return;
+    }
+    
+    object->referenceCount--;
+
+    if (object->referenceCount == 0) {
+        const WKClassInfo *info = object->classInfo;
+        while (info) {
+            if (info->dealloc)
+                info->dealloc ((void *)object);
+            info = info->parent;
+        }
+    }
+}
+
+static void _WKObjectDealloc (WKObjectRef v)
+{
+    free (v);
+}
+
+WKClassInfo WKObjectClass = { 0, "WKObject", _WKObjectDealloc };
+
+const void *WKCreateObjectWithSize (size_t size, WKClassInfo *info)
+{
+    WKObjectRef object = (WKObjectRef)calloc (size, 1);
+    if (!object)
+        return 0;
+
+    object->classInfo = info;
+    
+    WKRetain(object);
+    
+    return object;
+}
+
+WTF_ATTRIBUTE_PRINTF(4, 5)
+void WKReportError(const char *file, int line, const char *function, const char *format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    fprintf(stderr, "%s:%d %s:  ", file, line, function);
+    vfprintf(stderr, format, args);
+    va_end(args);
+    fprintf(stderr, "\n");
+}
+
+CFIndex WKArrayIndexOfValue (CFArrayRef array, const void *value)
+{
+    CFIndex i, count, index = -1;
+
+    count = CFArrayGetCount (array);
+    for (i = 0; i < count; i++) {
+        if (CFArrayGetValueAtIndex (array, i) == value) {
+            index = i;
+            break;
+        }
+    }
+    
+    return index;
+}
+
+WKClassInfo *WKGetClassInfo (WKObjectRef object)
+{
+    return object->classInfo;
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WKUtilities.h b/Source/WebCore/platform/ios/wak/WKUtilities.h
new file mode 100644 (file)
index 0000000..02053f2
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 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 WKUtilities_h
+#define WKUtilities_h
+
+#if TARGET_OS_IPHONE
+
+#import "WKTypes.h"
+#import <CoreGraphics/CoreGraphics.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const CFArrayCallBacks WKCollectionArrayCallBacks;
+extern const CFSetCallBacks WKCollectionSetCallBacks;
+
+
+typedef void(*WKDeallocCallback)(WKObjectRef object);
+
+typedef struct _WKClassInfo WKClassInfo;
+
+struct _WKClassInfo
+{
+    const WKClassInfo *parent;
+    const char *name;
+    WKDeallocCallback dealloc;
+};
+
+extern WKClassInfo WKObjectClass;
+
+struct _WKObject
+{
+    unsigned referenceCount;
+    WKClassInfo *classInfo;
+};
+
+const void *WKCreateObjectWithSize (size_t size, WKClassInfo *info);
+const void *WKRetain(const void *object);
+void WKRelease(const void *object);
+
+const void *WKCollectionRetain (CFAllocatorRef allocator, const void *value);
+void WKCollectionRelease (CFAllocatorRef allocator, const void *value);
+
+void WKReportError(const char *file, int line, const char *function, const char *format, ...);
+#define WKError(formatAndArgs...) WKReportError(__FILE__, __LINE__, __PRETTY_FUNCTION__, formatAndArgs)
+
+CFIndex WKArrayIndexOfValue (CFArrayRef array, const void *value);
+
+WKClassInfo *WKGetClassInfo (WKObjectRef object);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WKUtilities_h
diff --git a/Source/WebCore/platform/ios/wak/WKView.h b/Source/WebCore/platform/ios/wak/WKView.h
new file mode 100644 (file)
index 0000000..c7c4f93
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * 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 WKView_h
+#define WKView_h
+
+#if TARGET_OS_IPHONE
+
+#import "WKUtilities.h"
+#import <CoreGraphics/CoreGraphics.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+@class WAKWindow;
+
+enum {
+    NSViewNotSizable = 0,
+    NSViewMinXMargin = 1,
+    NSViewWidthSizable = 2,
+    NSViewMaxXMargin = 4,
+    NSViewMinYMargin = 8,
+    NSViewHeightSizable = 16,
+    NSViewMaxYMargin = 32
+};    
+    
+typedef enum {
+    WKViewNotificationViewDidMoveToWindow,
+    WKViewNotificationViewFrameSizeChanged,
+    WKViewNotificationViewDidScroll
+} WKViewNotificationType;
+
+typedef enum {
+    WKViewResponderAcceptsFirstResponder,
+    WKViewResponderBecomeFirstResponder,
+    WKViewResponderResignFirstResponder,
+} WKViewResponderCallbackType;
+
+typedef void (*WKViewDrawCallback)(WKViewRef view, CGRect dirtyRect, void *userInfo); 
+typedef void (*WKViewNotificationCallback)(WKViewRef view, WKViewNotificationType type, void *userInfo);
+typedef bool (*WKViewResponderCallback)(WKViewRef view, WKViewResponderCallbackType type, void *userInfo);
+typedef void (*WKViewWillRemoveSubviewCallback)(WKViewRef view, WKViewRef subview);
+typedef void (*WKViewInvalidateGStateCallback)(WKViewRef view);
+
+typedef struct _WKViewContext {
+    WKViewNotificationCallback notificationCallback;
+    void *notificationUserInfo;
+    WKViewResponderCallback responderCallback;
+    void *responderUserInfo;
+    WKViewWillRemoveSubviewCallback willRemoveSubviewCallback;
+    WKViewInvalidateGStateCallback invalidateGStateCallback;
+} WKViewContext;
+
+struct _WKView {
+    WKObject isa;
+    
+    WKViewContext *context;
+    
+    __unsafe_unretained WAKWindow *window;
+
+    WKViewRef superview;
+    CFMutableArrayRef subviews;
+
+    CGPoint origin;
+    CGRect bounds;
+    
+    unsigned int autoresizingMask;
+    
+    float scale;
+
+    // This is really a WAKView.
+    void *wrapper;
+};
+
+extern WKClassInfo WKViewClassInfo;
+
+WKViewRef WKViewCreateWithFrame (CGRect rect, WKViewContext *context);
+void WKViewInitialize (WKViewRef view, CGRect rect, WKViewContext *context);
+
+void WKViewSetViewContext (WKViewRef view, WKViewContext *context);
+void WKViewGetViewContext (WKViewRef view, WKViewContext *context);
+
+CGRect WKViewGetBounds (WKViewRef view);
+
+void WKViewSetFrameOrigin (WKViewRef view, CGPoint newPoint);
+void WKViewSetFrameSize (WKViewRef view, CGSize newSize);
+void WKViewSetBoundsOrigin(WKViewRef view, CGPoint newOrigin);
+void WKViewSetBoundsSize (WKViewRef view, CGSize newSize);
+
+CGRect WKViewGetFrame (WKViewRef view);
+
+void WKViewSetScale (WKViewRef view, float scale);
+float WKViewGetScale (WKViewRef view);
+CGAffineTransform _WKViewGetTransform(WKViewRef view);
+
+WAKWindow *WKViewGetWindow (WKViewRef view);
+
+CFArrayRef WKViewGetSubviews (WKViewRef view);
+
+WKViewRef WKViewGetSuperview (WKViewRef view);
+
+void WKViewAddSubview (WKViewRef view, WKViewRef subview);
+void WKViewRemoveFromSuperview (WKViewRef view);
+
+CGPoint WKViewConvertPointToSuperview (WKViewRef view, CGPoint aPoint);
+CGPoint WKViewConvertPointFromSuperview (WKViewRef view, CGPoint aPoint);
+CGPoint WKViewConvertPointToBase(WKViewRef view, CGPoint aPoint);
+CGPoint WKViewConvertPointFromBase(WKViewRef view, CGPoint aPoint);
+
+CGRect WKViewConvertRectToSuperview (WKViewRef view, CGRect aRect);
+CGRect WKViewConvertRectFromSuperview (WKViewRef view, CGRect aRect);
+CGRect WKViewConvertRectToBase (WKViewRef view, CGRect r);
+CGRect WKViewConvertRectFromBase (WKViewRef view, CGRect aRect);
+
+CGRect WKViewGetVisibleRect (WKViewRef view);
+
+WKViewRef WKViewFirstChild (WKViewRef view);
+WKViewRef WKViewNextSibling (WKViewRef view);
+WKViewRef WKViewTraverseNext (WKViewRef view);
+
+bool WKViewAcceptsFirstResponder (WKViewRef view);
+bool WKViewBecomeFirstResponder (WKViewRef view);
+bool WKViewResignFirstResponder (WKViewRef view);
+
+unsigned int WKViewGetAutoresizingMask(WKViewRef view);
+void WKViewSetAutoresizingMask (WKViewRef view, unsigned int mask);
+
+void WKViewScrollToRect(WKViewRef view, CGRect rect);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WKView_h
diff --git a/Source/WebCore/platform/ios/wak/WKView.mm b/Source/WebCore/platform/ios/wak/WKView.mm
new file mode 100644 (file)
index 0000000..c11fa09
--- /dev/null
@@ -0,0 +1,737 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#import "WKViewPrivate.h"
+
+#if PLATFORM(IOS)
+
+#import "WAKViewPrivate.h"
+#import "WAKWindow.h"
+#import "WKUtilities.h"
+#import <wtf/Assertions.h>
+
+void _WKViewSetSuperview (WKViewRef view, WKViewRef superview)
+{
+    // Not retained.
+    view->superview = superview;
+}
+
+void _WKViewWillRemoveSubview(WKViewRef view, WKViewRef subview)
+{
+    if (view->context && view->context->willRemoveSubviewCallback)
+        view->context->willRemoveSubviewCallback(view, subview);
+}
+
+void _WKViewSetWindow (WKViewRef view, WAKWindow *window)
+{
+    if (view->window == window)
+        return;
+
+    [window retain];
+    [view->window release];
+
+    view->window = window;
+
+    // Set the window on all subviews.
+    WKViewRef firstChild = WKViewFirstChild(view);
+    if (firstChild) {
+        _WKViewSetWindow (firstChild, window);
+        WKViewRef nextSibling = WKViewNextSibling(firstChild);
+        while (nextSibling) {
+            _WKViewSetWindow (nextSibling, window);
+            nextSibling = WKViewNextSibling(nextSibling);
+        }
+    }
+
+    if (view->context && view->context->notificationCallback)
+        view->context->notificationCallback (view, WKViewNotificationViewDidMoveToWindow, view->context->notificationUserInfo);
+}
+
+static void _WKViewClearSuperview(const void *value, void *context)
+{
+    UNUSED_PARAM(context);
+    _WKViewSetSuperview((WKViewRef)value, 0);
+}
+
+static void _WKViewDealloc (WKObjectRef v)
+{
+    WKViewRef view = (WKViewRef)v;
+    
+    if (view->subviews) {
+        CFArrayApplyFunction(view->subviews, CFRangeMake(0, CFArrayGetCount(view->subviews)), _WKViewClearSuperview, NULL);
+        CFRelease (view->subviews);
+        view->subviews = 0;
+    }
+
+    [view->window release];
+    view->window = nil;
+}
+
+void WKViewInitialize (WKViewRef view, CGRect frame, WKViewContext *context)
+{
+    view->origin = frame.origin;
+    view->bounds.origin = CGPointZero;
+    view->bounds.size = frame.size;
+    
+    view->context = context;
+    view->autoresizingMask = NSViewNotSizable;
+    view->scale = 1.0f;
+}
+
+WKClassInfo WKViewClassInfo = { &WKObjectClass, "WKView", _WKViewDealloc };
+
+WKViewRef WKViewCreateWithFrame (CGRect frame, WKViewContext *context)
+{
+    WKViewRef view = (WKViewRef)WKCreateObjectWithSize (sizeof(struct _WKView), &WKViewClassInfo);
+    if (!view)
+        return 0;
+    
+    WKViewInitialize (view, frame, context);
+    
+    return view;
+}
+
+void _WKViewSetViewContext (WKViewRef view, WKViewContext *context)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return;
+    }
+    view->context = context;
+}
+
+CGRect WKViewGetBounds (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+    
+    return view->bounds;
+}
+
+CGRect WKViewGetFrame (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+    
+    return WKViewConvertRectToSuperview(view, view->bounds);
+}
+
+static void _WKViewRecursivelyInvalidateGState(WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return;
+    }
+
+    if (view->context && view->context->invalidateGStateCallback)
+        view->context->invalidateGStateCallback(view);
+    
+    WKViewRef subview = WKViewFirstChild(view);
+    while (subview) {
+        _WKViewRecursivelyInvalidateGState(subview);
+        subview = WKViewNextSibling(subview);
+    }
+}
+
+void WKViewSetFrameOrigin (WKViewRef view, CGPoint newOrigin)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return;
+    }
+    
+    ASSERT(!isinf(newOrigin.x));
+    ASSERT(!isnan(newOrigin.x));
+    ASSERT(!isinf(newOrigin.y));
+    ASSERT(!isnan(newOrigin.y));
+    
+    if (!CGPointEqualToPoint(view->origin, newOrigin)) {
+        view->origin = newOrigin;
+        _WKViewRecursivelyInvalidateGState(view);
+    }
+}
+
+#define XSIZING_BITS(mask)      ((mask) & 7)
+#define YSIZING_BITS(mask)      (((mask) >> 3) & 7)
+
+static void _WKViewAutoresizeCoord(bool bByHeight, unsigned int sizingMethod, const CGRect *origSuperFrame, const CGRect *newSuperFrame, CGRect *newFrame)
+{
+    CGFloat origSuperFrameWidthOrHeight;
+    CGFloat newSuperFrameWidthOrHeight;
+    CGFloat *origFrameXorY;
+    CGFloat *origFrameWidthOrHeight;
+    CGFloat prop;
+    CGFloat tmp;
+    CGFloat xOrY;
+    CGFloat widthOrHeight;
+    CGFloat origMarginsTotal;
+    CGFloat origWidthMinusMinMargin;
+    
+    if (bByHeight) {
+        sizingMethod = YSIZING_BITS(sizingMethod);
+        origSuperFrameWidthOrHeight = origSuperFrame->size.height;
+        newSuperFrameWidthOrHeight = newSuperFrame->size.height;
+        origFrameXorY = &newFrame->origin.y;
+        origFrameWidthOrHeight = &newFrame->size.height;
+    } else {
+        sizingMethod = XSIZING_BITS(sizingMethod);
+        origSuperFrameWidthOrHeight = origSuperFrame->size.width;
+        newSuperFrameWidthOrHeight = newSuperFrame->size.width;
+        origFrameXorY = &newFrame->origin.x;
+        origFrameWidthOrHeight = &newFrame->size.width;
+    }
+    
+    xOrY = *origFrameXorY;
+    widthOrHeight = *origFrameWidthOrHeight;
+    
+    switch (sizingMethod) {
+        case NSViewNotSizable:
+        case NSViewMaxXMargin:
+            break;
+        case NSViewWidthSizable:
+            widthOrHeight = newSuperFrameWidthOrHeight - (origSuperFrameWidthOrHeight - widthOrHeight);
+            if (widthOrHeight < 0.0f)
+                widthOrHeight = 0.0f;
+                break;
+        case NSViewWidthSizable | NSViewMaxXMargin:
+            origWidthMinusMinMargin = origSuperFrameWidthOrHeight - xOrY;
+            if (widthOrHeight) {
+                if (origWidthMinusMinMargin != 0.0f) {
+                    prop = widthOrHeight / origWidthMinusMinMargin;
+                } else {
+                    prop = 0.0f;
+                }
+            } else {
+                prop = 1.0f;
+            }
+                widthOrHeight = ((newSuperFrameWidthOrHeight - xOrY)) * prop;
+            if (widthOrHeight < 0.0f)
+                widthOrHeight = 0.0f;
+                break;
+        case NSViewMinXMargin:
+            xOrY = newSuperFrameWidthOrHeight - (origSuperFrameWidthOrHeight - xOrY);
+            if (xOrY < 0.0f)
+                xOrY = 0.0f;
+            break;
+        case NSViewMinXMargin | NSViewMaxXMargin:
+            origMarginsTotal = origSuperFrameWidthOrHeight - widthOrHeight;
+            if (xOrY && origMarginsTotal != 0.0f) {
+                prop = xOrY / origMarginsTotal;
+            }
+                // Do the 50/50 split even if XorY = 0 and the WidthOrHeight is only
+                // one pixel shorter...
+                else if (origMarginsTotal == 0.0f 
+                         || (abs(origMarginsTotal) == 1)) {
+                    prop = 0.5f;  // Then split it 50:50.
+                }
+                else {
+                    prop = 1.0f;
+                }
+                xOrY = ((newSuperFrameWidthOrHeight - widthOrHeight)) * prop;
+            if (xOrY < 0.0f)
+                xOrY = 0.0f;
+                break;
+        case NSViewMinXMargin | NSViewWidthSizable:
+            tmp = xOrY + widthOrHeight;
+            if (tmp)
+                prop = xOrY / tmp;
+            else
+                prop = 0.5f;
+            xOrY = ((newSuperFrameWidthOrHeight - (origSuperFrameWidthOrHeight - tmp))) * prop;
+            widthOrHeight  = newSuperFrameWidthOrHeight - (xOrY + (origSuperFrameWidthOrHeight - tmp));
+            if (xOrY < 0.0f)
+                xOrY = 0.0f;
+                if (widthOrHeight < 0.0f)
+                    widthOrHeight = 0.0f;
+                    break;
+        case NSViewMinXMargin | NSViewWidthSizable | NSViewMaxXMargin:
+            if (origSuperFrameWidthOrHeight)
+                prop = xOrY / origSuperFrameWidthOrHeight;
+            else
+                prop = 1.0f / 3.0f;
+            xOrY = (newSuperFrameWidthOrHeight * prop);
+            if (origSuperFrameWidthOrHeight)
+                prop = widthOrHeight / origSuperFrameWidthOrHeight;
+            else
+                prop = 1.0f / 3.0f;
+            widthOrHeight = (newSuperFrameWidthOrHeight * prop);
+            break;
+    }
+    
+    *origFrameXorY = floorf(xOrY);
+    *origFrameWidthOrHeight = floorf(widthOrHeight);
+}
+
+void _WKViewAutoresize(WKViewRef view, const CGRect *oldSuperFrame, const CGRect *newSuperFrame)
+{
+    if (view->autoresizingMask != NSViewNotSizable) {
+        CGRect newFrame = WKViewGetFrame(view);
+        _WKViewAutoresizeCoord(false, view->autoresizingMask, oldSuperFrame, newSuperFrame, &newFrame);
+        _WKViewAutoresizeCoord(true, view->autoresizingMask, oldSuperFrame, newSuperFrame, &newFrame);
+        WKViewSetFrameOrigin(view, newFrame.origin);
+        WKViewSetFrameSize(view, newFrame.size);
+    }
+}
+
+static void _WKViewAutoresizeChildren(WKViewRef view, const CGRect *oldSuperFrame, const CGRect *newSuperFrame)
+{
+    WKViewRef child;
+    for (child = WKViewFirstChild(view); child != NULL; child = WKViewNextSibling(child)) {
+        _WKViewAutoresize(child, oldSuperFrame, newSuperFrame);
+    }        
+}
+
+void WKViewSetFrameSize (WKViewRef view, CGSize newSize)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return;
+    }
+    
+    ASSERT(!isinf(newSize.width));
+    ASSERT(!isnan(newSize.width));
+    ASSERT(!isinf(newSize.height));
+    ASSERT(!isnan(newSize.height));
+    
+    CGRect frame;
+    frame.origin = CGPointZero;
+    frame.size = newSize;
+    CGSize boundsSize = WKViewConvertRectFromSuperview(view, frame).size;
+    WKViewSetBoundsSize(view, boundsSize);
+}
+
+void WKViewSetBoundsSize (WKViewRef view, CGSize newSize)
+{
+    if (CGSizeEqualToSize(view->bounds.size, newSize))
+        return;
+    
+    CGRect oldFrame = WKViewGetFrame(view);
+    view->bounds.size = newSize;
+    CGRect newFrame = WKViewGetFrame(view);
+    
+    if (view->context && view->context->notificationCallback)
+        view->context->notificationCallback (view, WKViewNotificationViewFrameSizeChanged, view->context->notificationUserInfo);
+    
+    _WKViewAutoresizeChildren(view, &oldFrame, &newFrame);    
+    _WKViewRecursivelyInvalidateGState(view);
+}
+
+void WKViewSetBoundsOrigin(WKViewRef view, CGPoint newOrigin)
+{
+    if (CGPointEqualToPoint(view->bounds.origin, newOrigin))
+        return;
+
+    view->bounds.origin = newOrigin;
+
+    _WKViewRecursivelyInvalidateGState(view);    
+}
+
+void WKViewSetScale(WKViewRef view, float scale)
+{
+    ASSERT(!isinf(scale));
+    ASSERT(!isnan(scale));
+    
+    if (view->scale == scale)
+        return;
+    
+    view->scale = scale;
+    
+    if (view->context && view->context->notificationCallback)
+        view->context->notificationCallback (view, WKViewNotificationViewFrameSizeChanged, view->context->notificationUserInfo);
+}
+
+float WKViewGetScale(WKViewRef view)
+{
+    return view->scale;
+}
+
+WAKWindow *WKViewGetWindow (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return 0;
+    }
+    
+    return view->window;
+}
+
+CFArrayRef WKViewGetSubviews (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return 0;
+    }
+    
+    return view->subviews;
+}
+
+void WKViewAddSubview (WKViewRef view, WKViewRef subview)
+{
+    if (!view || !subview) {
+        WKError ("invalid parameter");
+        return;
+    }
+    
+    if (!view->subviews) {
+        view->subviews = CFArrayCreateMutable(NULL, 0, &WKCollectionArrayCallBacks);
+    }
+    CFArrayAppendValue (view->subviews, subview);
+    _WKViewSetSuperview (subview, view);
+    
+    // Set the window on subview and all it's children.
+    _WKViewSetWindow (subview, view->window);
+}
+
+void WKViewRemoveFromSuperview (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return;
+    }
+
+    _WKViewSetWindow (view, 0);
+
+    if (!view->superview) {
+        return;
+    }
+    
+    CFMutableArrayRef svs = view->superview->subviews;
+    if (!svs) {
+        WKError ("superview has no subviews");
+        return;
+    }
+
+    CFIndex index = WKArrayIndexOfValue (svs, view);
+    if (index < 0) {
+        WKError ("view not in superview subviews");
+        return;
+    }
+
+    _WKViewWillRemoveSubview(view->superview, view);
+    
+    CFArrayRemoveValueAtIndex (svs, index);
+
+    _WKViewSetSuperview (view, 0);
+}
+
+WKViewRef WKViewFirstChild (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return 0;
+    }
+
+    CFArrayRef sv = view->subviews;
+    
+    if (!sv)
+        return 0;
+        
+    CFIndex count = CFArrayGetCount (sv);
+    if (!count)
+        return 0;
+        
+    return (const WKViewRef)CFArrayGetValueAtIndex (sv, 0);
+}
+
+WKViewRef WKViewNextSibling (WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return 0;
+    }
+
+    if (!view->superview)
+        return 0;
+        
+    CFArrayRef svs = view->superview->subviews;
+    if (!svs)
+        return 0;
+        
+    CFIndex thisIndex = WKArrayIndexOfValue (svs, view);
+    if (thisIndex < 0) {
+        WKError ("internal error, view is not present in superview subviews");
+        return 0;
+    }
+    
+    CFIndex count = CFArrayGetCount (svs);
+    if (thisIndex+1 >= count)
+        return 0;
+        
+    return (const WKViewRef)CFArrayGetValueAtIndex (svs, thisIndex+1);
+}
+
+// To remove, see: <rdar://problem/10360425> Remove WKViewTraverseNext from Skankphone
+WKViewRef WKViewTraverseNext(WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return 0;
+    }
+
+    WKViewRef firstChild = WKViewFirstChild(view);
+    if (firstChild)
+        return firstChild;
+
+    WKViewRef nextSibling = WKViewNextSibling(view);
+    if (nextSibling)
+        return nextSibling;
+
+    while (view && !WKViewNextSibling(view)) {
+        WAKView *wakView = WAKViewForWKViewRef(view);
+        WAKView *superView = [wakView superview];
+        view = [superView _viewRef];
+    }
+        
+    if (view)
+        return WKViewNextSibling(view);
+    
+    return 0;
+}
+
+CGAffineTransform _WKViewGetTransform(WKViewRef view)
+{
+    CGAffineTransform transform;
+    transform = CGAffineTransformMakeTranslation(view->origin.x, view->origin.y);
+    transform = CGAffineTransformScale(transform, view->scale, view->scale);
+    transform = CGAffineTransformTranslate(transform, -view->bounds.origin.x, -view->bounds.origin.y);
+    return transform;
+}
+
+CGRect WKViewGetVisibleRect(WKViewRef viewRef)
+{
+    if (!viewRef) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+
+    WKViewRef view = viewRef;
+    CGRect rect = WKViewGetBounds(view);
+    WKViewRef superview = view->superview;
+    
+    while (superview != NULL) {
+        rect = WKViewConvertRectToSuperview(view, rect);
+        rect = CGRectIntersection(WKViewGetBounds(superview), rect);
+        view = superview;
+        superview = superview->superview;
+    }
+    
+    if (view != viewRef) {
+        rect = WKViewConvertRectToBase(view, rect);
+        rect = WKViewConvertRectFromBase(viewRef, rect);
+    }
+    
+    return rect;
+}
+
+CGRect WKViewConvertRectToSuperview(WKViewRef view, CGRect r)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+    
+    return CGRectApplyAffineTransform(r, _WKViewGetTransform(view));
+}
+
+CGRect WKViewConvertRectToBase(WKViewRef view, CGRect r)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+
+    CGRect aRect = r;
+    
+    while (view) {
+        aRect = WKViewConvertRectToSuperview (view, aRect);    
+        view = view->superview;
+    }
+    
+    return aRect;
+}
+
+CGPoint WKViewConvertPointToSuperview(WKViewRef view, CGPoint p)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGPointZero;
+    }
+
+    return CGPointApplyAffineTransform(p, _WKViewGetTransform(view));
+}
+
+CGPoint WKViewConvertPointFromSuperview(WKViewRef view, CGPoint p)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGPointZero;
+    }
+    
+    CGAffineTransform transform = CGAffineTransformInvert(_WKViewGetTransform(view));
+    return CGPointApplyAffineTransform(p, transform);
+}
+
+CGPoint WKViewConvertPointToBase(WKViewRef view, CGPoint p)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGPointZero;
+    }
+
+    CGPoint aPoint = p;
+    
+    while (view) {
+        aPoint = WKViewConvertPointToSuperview (view, aPoint);    
+        view = view->superview;
+    }
+    
+    return aPoint;
+}
+
+#define VIEW_ARRAY_SIZE 128
+
+static void _WKViewGetAncestorViewsIncludingView (WKViewRef view, WKViewRef *views, unsigned maxViews, unsigned *viewCount)
+{
+    unsigned count = 0;
+    
+    views[count++] = view;
+    WKViewRef superview = view->superview;
+    while (superview) {
+        views[count++] = superview;
+        if (count >= maxViews) {
+            WKError ("Exceeded maxViews, use malloc/realloc");
+            *viewCount = 0;
+            return;
+        }
+        superview = superview->superview;
+    }
+    *viewCount = count;
+}
+
+CGPoint WKViewConvertPointFromBase(WKViewRef view, CGPoint p)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGPointZero;
+    }
+
+    WKViewRef views[VIEW_ARRAY_SIZE];
+    unsigned viewCount = 0;
+
+    _WKViewGetAncestorViewsIncludingView (view, views, VIEW_ARRAY_SIZE, &viewCount);
+    if (viewCount == 0)
+        return CGPointZero;
+
+    CGPoint aPoint = p;
+    int i;
+    for (i = viewCount-1; i >= 0; i--) {
+        aPoint = WKViewConvertPointFromSuperview (views[i], aPoint);
+    }
+        
+    return aPoint;
+}
+
+CGRect WKViewConvertRectFromSuperview(WKViewRef view, CGRect r)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+    
+    CGAffineTransform transform = CGAffineTransformInvert(_WKViewGetTransform(view));
+    return CGRectApplyAffineTransform(r, transform);
+}
+
+CGRect WKViewConvertRectFromBase(WKViewRef view, CGRect r)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return CGRectZero;
+    }
+
+    WKViewRef views[VIEW_ARRAY_SIZE];
+    unsigned viewCount = 0;
+
+    _WKViewGetAncestorViewsIncludingView (view, views, VIEW_ARRAY_SIZE, &viewCount);
+    if (viewCount == 0)
+        return CGRectZero;
+    
+    CGRect aRect = r;
+    int i;
+    for (i = viewCount-1; i >= 0; i--) {
+        aRect = WKViewConvertRectFromSuperview (views[i], aRect);
+    }
+        
+    return aRect;
+}
+
+bool WKViewAcceptsFirstResponder (WKViewRef view)
+{
+    bool result = TRUE;
+    if (view && view->context && view->context->responderCallback)
+        result = view->context->responderCallback(view, WKViewResponderAcceptsFirstResponder, view->context->responderUserInfo);
+    return result;
+}
+
+bool WKViewBecomeFirstResponder (WKViewRef view)
+{
+    bool result = TRUE;
+    if (view && view->context && view->context->responderCallback)
+        result = view->context->responderCallback(view, WKViewResponderBecomeFirstResponder, view->context->responderUserInfo);
+    return result;
+}
+
+bool WKViewResignFirstResponder (WKViewRef view)
+{
+    bool result = TRUE;
+    if (view && view->context && view->context->responderCallback)
+        result = view->context->responderCallback(view, WKViewResponderResignFirstResponder, view->context->responderUserInfo);
+    return result;
+}
+
+unsigned int WKViewGetAutoresizingMask(WKViewRef view)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return 0;
+    }    
+    return view->autoresizingMask;
+}
+
+void WKViewSetAutoresizingMask (WKViewRef view, unsigned int mask)
+{
+    if (!view) {
+        WKError ("invalid parameter");
+        return;
+    }    
+    view->autoresizingMask = mask;
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WKViewPrivate.h b/Source/WebCore/platform/ios/wak/WKViewPrivate.h
new file mode 100644 (file)
index 0000000..6f3cd56
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2005, 2006, 2007, 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 WKViewPrivate_h
+#define WKViewPrivate_h
+
+#if TARGET_OS_IPHONE
+
+#import "WKView.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif    
+
+void _WKViewSetWindow (WKViewRef view, WAKWindow *window);
+void _WKViewSetSuperview (WKViewRef view, WKViewRef superview);
+void _WKViewWillRemoveSubview(WKViewRef view, WKViewRef subview);
+WKViewRef _WKViewBaseView (WKViewRef view);
+void _WKViewAutoresize(WKViewRef view, const CGRect *oldSuperFrame, const CGRect *newSuperFrame);
+void _WKViewSetViewContext (WKViewRef view, WKViewContext *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WKViewPrivate_h
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThread.h b/Source/WebCore/platform/ios/wak/WebCoreThread.h
new file mode 100644 (file)
index 0000000..b213919
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 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 WebCoreThread_h
+#define WebCoreThread_h
+
+#if TARGET_OS_IPHONE
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <fenv.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif    
+        
+typedef struct {
+    CGContextRef currentCGContext;
+} WebThreadContext;
+    
+extern volatile bool webThreadShouldYield;
+
+extern fenv_t mainThreadFEnv;
+
+#ifdef __OBJC__
+@class NSRunLoop;
+#else
+class NSRunLoop;
+#endif
+
+// The lock is automatically freed at the bottom of the runloop. No need to unlock.
+// Note that calling this function may hang your UI for several seconds. Don't use
+// unless you have to.
+void WebThreadLock(void);
+    
+// This is a no-op for compatibility only. It will go away. Please don't use.
+void WebThreadUnlock(void);
+    
+// Please don't use anything below this line unless you know what you are doing. If unsure, ask.
+// ---------------------------------------------------------------------------------------------
+bool WebThreadIsLocked(void);
+bool WebThreadIsLockedOrDisabled(void);
+    
+void WebThreadLockPushModal(void);
+void WebThreadLockPopModal(void);
+
+void WebThreadEnable(void);
+bool WebThreadIsEnabled(void);
+bool WebThreadIsCurrent(void);
+bool WebThreadNotCurrent(void);
+    
+// These are for <rdar://problem/6817341> Many apps crashing calling -[UIFieldEditor text] in secondary thread
+// Don't use them to solve any random problems you might have.
+void WebThreadLockFromAnyThread();
+void WebThreadLockFromAnyThreadNoLog();
+void WebThreadUnlockFromAnyThread();
+
+// This is for <rdar://problem/8005192> Mail entered a state where message subject and content isn't displayed.
+// It should only be used for MobileMail to work around <rdar://problem/8005192>.
+void WebThreadUnlockGuardForMail();
+
+static inline bool WebThreadShouldYield(void) { return webThreadShouldYield; }
+static inline void WebThreadSetShouldYield() { webThreadShouldYield = true; }
+
+CFRunLoopRef WebThreadRunLoop(void);
+NSRunLoop* WebThreadNSRunLoop(void);
+WebThreadContext *WebThreadCurrentContext(void);
+bool WebThreadContextIsCurrent(void);
+
+void WebThreadSetDelegateSourceRunLoopMode(CFStringRef mode);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WebCoreThread_h
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThread.mm b/Source/WebCore/platform/ios/wak/WebCoreThread.mm
new file mode 100644 (file)
index 0000000..dcc75b2
--- /dev/null
@@ -0,0 +1,1027 @@
+/*
+ * Copyright (C) 2006, 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 "config.h"
+#import "WebCoreThread.h"
+
+#if PLATFORM(IOS)
+
+#import "JSDOMWindowBase.h"
+#import "ThreadGlobalData.h"
+#import "WebCoreThreadInternal.h"
+#import "WebCoreThreadMessage.h"
+#import "WebCoreThreadRun.h"
+#import "WebCoreThreadSafe.h"
+#import "WKUtilities.h"
+
+#import <runtime/InitializeThreading.h>
+#import <runtime/JSLock.h>
+#import <wtf/Assertions.h>
+#import <wtf/MainThread.h>
+#import <wtf/Threading.h>
+#import <wtf/text/AtomicString.h>
+
+#import <CoreFoundation/CFPriv.h>
+#import <Foundation/NSInvocation.h>
+#import <libkern/OSAtomic.h>
+#import <objc/runtime.h>
+
+#define LOG_MESSAGES 0
+#define LOG_WEB_LOCK 0
+#define LOG_MAIN_THREAD_LOCKING 0
+#define LOG_RELEASES 0
+
+#define DistantFuture   (86400.0 * 2000 * 365.2425 + 86400.0)   // same as +[NSDate distantFuture]
+#define MaxArgCount         5
+#define DrawWaitInterval     10
+#define DelegateWaitInterval 10
+
+static void _WebThreadAutoLock(void);
+static bool _WebTryThreadLock(bool shouldTry);
+static void _WebThreadLockFromAnyThread(bool shouldLog);
+static void _WebThreadUnlock(void);
+
+@interface NSObject(ForwardDeclarations)
+-(void)_webcore_releaseOnWebThread;
+-(void)_webcore_releaseWithWebThreadLock;
+@end
+
+@implementation NSObject(WebCoreThreadAdditions)
+
+- (void)releaseOnMainThread {
+    if ([NSThread isMainThread]) {
+        [self release];
+    } else {
+        [self performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
+    }
+}
+
+@end
+
+typedef void *NSAutoreleasePoolMark;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern NSAutoreleasePoolMark NSPushAutoreleasePool(unsigned ignored);
+extern void NSPopAutoreleasePool(NSAutoreleasePoolMark token);
+#ifdef __cplusplus
+}
+#endif
+
+static int WebTimedConditionLock (pthread_cond_t *condition, pthread_mutex_t *lock, CFAbsoluteTime interval);
+
+static pthread_mutex_t webLock;
+static NSAutoreleasePoolMark autoreleasePoolMark;
+static CFRunLoopRef webThreadRunLoop;
+static NSRunLoop* webThreadNSRunLoop;
+static pthread_t webThread;
+static BOOL isWebThreadLocked;
+static BOOL webThreadStarted;
+static unsigned webThreadLockCount;
+fenv_t mainThreadFEnv;
+
+static NSAutoreleasePoolMark savedAutoreleasePoolMark;
+static BOOL isNestedWebThreadRunLoop;
+typedef enum {
+    PushOrPopAutoreleasePool,
+    IgnoreAutoreleasePool
+} AutoreleasePoolOperation;
+
+static pthread_mutex_t WebThreadReleaseLock = PTHREAD_MUTEX_INITIALIZER;
+static CFRunLoopSourceRef WebThreadReleaseSource;
+static CFMutableArrayRef WebThreadReleaseObjArray;
+
+static void MainThreadAdoptAndRelease(id obj);
+
+static pthread_mutex_t delegateLock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t delegateCondition = PTHREAD_COND_INITIALIZER;
+static NSInvocation *delegateInvocation;
+static CFRunLoopSourceRef delegateSource = NULL;
+static BOOL delegateHandled;
+#if LOG_MAIN_THREAD_LOCKING
+static BOOL sendingDelegateMessage;
+#endif
+
+static CFRunLoopObserverRef mainRunLoopAutoUnlockObserver;
+
+static pthread_mutex_t startupLock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t startupCondition = PTHREAD_COND_INITIALIZER;
+
+static WebThreadContext *webThreadContext;
+static pthread_key_t threadContextKey;
+static unsigned mainThreadLockCount;
+static unsigned otherThreadLockCount;
+static unsigned sMainThreadModalCount;
+
+volatile bool webThreadShouldYield;
+
+static pthread_mutex_t WebCoreReleaseLock;
+static void WebCoreObjCDeallocOnWebThreadImpl(id self, SEL _cmd);
+static void WebCoreObjCDeallocWithWebThreadLockImpl(id self, SEL _cmd);
+
+static NSMutableArray *sAsyncDelegates = nil;
+
+static CFStringRef delegateSourceRunLoopMode;
+
+static inline void SendMessage(NSInvocation *invocation)
+{
+    [invocation invoke];
+    MainThreadAdoptAndRelease(invocation);
+}
+
+static void HandleDelegateSource(void *info)
+{
+    UNUSED_PARAM(info);
+    ASSERT(!WebThreadIsCurrent());
+
+#if LOG_MAIN_THREAD_LOCKING
+    sendingDelegateMessage = YES;
+#endif
+
+    _WebThreadAutoLock();
+
+    int result = pthread_mutex_lock(&delegateLock);
+    ASSERT_WITH_MESSAGE(result == 0, "delegate lock failed with code:%d", result);
+
+#if LOG_MESSAGES
+    if ([[delegateInvocation target] isKindOfClass:[NSNotificationCenter class]]) {
+        id argument0;
+        [delegateInvocation getArgument:&argument0 atIndex:0];
+        NSLog(@"notification receive: %@", argument0);
+    } else {
+        NSLog(@"delegate receive: %@", NSStringFromSelector([delegateInvocation selector]));
+    }
+#endif
+
+    SendMessage(delegateInvocation);
+
+    delegateHandled = YES;
+    pthread_cond_signal(&delegateCondition);
+
+    result = pthread_mutex_unlock(&delegateLock);
+    ASSERT_WITH_MESSAGE(result == 0, "delegate unlock failed with code:%d", result);
+
+#if LOG_MAIN_THREAD_LOCKING
+    sendingDelegateMessage = NO;
+#endif
+}
+
+static void SendDelegateMessage(NSInvocation *invocation)
+{
+    if (WebThreadIsCurrent()) {
+        ASSERT(delegateSource);
+        int result = pthread_mutex_lock(&delegateLock);
+        ASSERT_WITH_MESSAGE(result == 0, "delegate lock failed with code:%d", result);
+
+        delegateInvocation = invocation;
+        delegateHandled = NO;
+
+#if LOG_MESSAGES
+        if ([[delegateInvocation target] isKindOfClass:[NSNotificationCenter class]]) {
+            id argument0;
+            [delegateInvocation getArgument:&argument0 atIndex:0];
+            NSLog(@"notification send: %@", argument0);
+        } else {
+            NSLog(@"delegate send: %@", NSStringFromSelector([delegateInvocation selector]));
+        }
+#endif
+
+        {
+            // Code block created to scope JSC::JSLock::DropAllLocks outside of WebThreadLock()
+            JSC::JSLock::DropAllLocks dropAllLocks(WebCore::JSDOMWindowBase::commonVM(), JSC::JSLock::DropAllLocks::AlwaysDropLocks);
+            _WebThreadUnlock();
+
+            CFRunLoopSourceSignal(delegateSource);
+            CFRunLoopWakeUp(CFRunLoopGetMain());
+
+            while (!delegateHandled) {
+                if (WebTimedConditionLock(&delegateCondition, &delegateLock, DelegateWaitInterval) != 0) {
+                    id delegateInformation;
+                    if ([[delegateInvocation target] isKindOfClass:[NSNotificationCenter class]])
+                        [delegateInvocation getArgument:&delegateInformation atIndex:0];
+                    else
+                        delegateInformation = NSStringFromSelector([delegateInvocation selector]);
+        
+                    CFStringRef mode = CFRunLoopCopyCurrentMode(CFRunLoopGetMain());
+                    NSLog(@"%s: delegate (%@) failed to return after waiting %d seconds. main run loop mode: %@", __PRETTY_FUNCTION__, delegateInformation, DelegateWaitInterval, mode);
+                    if (mode)
+                        CFRelease(mode);
+                }
+            }
+            result = pthread_mutex_unlock(&delegateLock);
+
+            ASSERT_WITH_MESSAGE(result == 0, "delegate unlock failed with code:%d", result);
+            _WebTryThreadLock(false);
+        }
+    } else {
+        SendMessage(invocation);
+    }
+}
+
+void WebThreadRunOnMainThread(void(^delegateBlock)())
+{
+    if (!WebThreadIsCurrent()) {
+        ASSERT(pthread_main_np());
+        delegateBlock();
+        return;
+    }
+
+    JSC::JSLock::DropAllLocks dropAllLocks(WebCore::JSDOMWindowBase::commonVM(), JSC::JSLock::DropAllLocks::AlwaysDropLocks);
+    _WebThreadUnlock();
+
+    void (^delegateBlockCopy)() = Block_copy(delegateBlock);
+    dispatch_sync(dispatch_get_main_queue(), delegateBlockCopy);
+    Block_release(delegateBlockCopy);
+
+    _WebTryThreadLock(false);
+}
+
+static void MainThreadAdoptAndRelease(id obj)
+{
+    if (!WebThreadIsEnabled() || CFRunLoopGetMain() == CFRunLoopGetCurrent()) {
+        [obj release];
+        return;
+    }
+#if LOG_RELEASES
+    NSLog(@"Release send [web thread] : %@", obj);
+#endif
+    // We own obj at this point, so we don't need the block to implicitly
+    // retain it.
+    __block id objNotRetained = obj;
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [objNotRetained release];
+    });
+}
+
+void WebThreadAdoptAndRelease(id obj)
+{
+    ASSERT(!WebThreadIsCurrent());
+    ASSERT(WebThreadReleaseSource);
+
+#if LOG_RELEASES
+    NSLog(@"Release send [main thread]: %@", obj);
+#endif        
+
+    int result = pthread_mutex_lock(&WebThreadReleaseLock);
+    ASSERT_WITH_MESSAGE(result == 0, "Release lock failed with code:%d", result);
+
+    if (WebThreadReleaseObjArray == nil)
+        WebThreadReleaseObjArray = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+    CFArrayAppendValue(WebThreadReleaseObjArray, obj);
+    CFRunLoopSourceSignal(WebThreadReleaseSource);
+    CFRunLoopWakeUp(webThreadRunLoop);
+
+    result = pthread_mutex_unlock(&WebThreadReleaseLock);    
+    ASSERT_WITH_MESSAGE(result == 0, "Release unlock failed with code:%d", result);
+}
+
+static inline void lockWebCoreReleaseLock()
+{
+    int lockcode = pthread_mutex_lock(&WebCoreReleaseLock);
+#pragma unused (lockcode)
+    ASSERT_WITH_MESSAGE(lockcode == 0, "WebCoreReleaseLock lock failed with code:%d", lockcode);
+}
+
+static inline void unlockWebCoreReleaseLock()
+{
+    int lockcode = pthread_mutex_unlock(&WebCoreReleaseLock);
+#pragma unused (lockcode)
+    ASSERT_WITH_MESSAGE(lockcode == 0, "WebCoreReleaseLock unlock failed with code:%d", lockcode);
+}
+
+void WebCoreObjCDeallocOnWebThread(Class cls)
+{
+    SEL releaseSEL = @selector(release);
+    SEL webThreadReleaseSEL = @selector(_webcore_releaseOnWebThread);
+
+    // get the existing release method
+    Method releaseMethod = class_getInstanceMethod(cls, releaseSEL);
+    if (!releaseMethod) {
+        ASSERT_WITH_MESSAGE(releaseMethod, "WebCoreObjCDeallocOnWebThread() failed to find %s for %@", releaseSEL, NSStringFromClass(cls));
+        return;
+    }
+
+    // add the implementation that ensures release WebThread release/deallocation
+    if (!class_addMethod(cls, webThreadReleaseSEL, (IMP)WebCoreObjCDeallocOnWebThreadImpl, method_getTypeEncoding(releaseMethod))) {
+        ASSERT_WITH_MESSAGE(releaseMethod, "WebCoreObjCDeallocOnWebThread() failed to add %s for %@", webThreadReleaseSEL, NSStringFromClass(cls));
+        return;
+    }
+
+    // ensure the implementation exists at cls in the class hierarchy
+    if (class_addMethod(cls, releaseSEL, class_getMethodImplementation(cls, releaseSEL), method_getTypeEncoding(releaseMethod)))
+        releaseMethod = class_getInstanceMethod(cls, releaseSEL);
+
+    // swizzle the old release for the new implementation
+    method_exchangeImplementations(releaseMethod, class_getInstanceMethod(cls, webThreadReleaseSEL));
+}
+
+void WebCoreObjCDeallocWithWebThreadLock(Class cls)
+{
+    SEL releaseSEL = @selector(release);
+    SEL webThreadLockReleaseSEL = @selector(_webcore_releaseWithWebThreadLock);
+
+    // get the existing release method
+    Method releaseMethod = class_getInstanceMethod(cls, releaseSEL);
+    if (!releaseMethod) {
+        ASSERT_WITH_MESSAGE(releaseMethod, "WebCoreObjCDeallocWithWebThreadLock() failed to find %s for %@", releaseSEL, NSStringFromClass(cls));
+        return;
+    }
+
+    // add the implementation that ensures release WebThreadLock release/deallocation
+    if (!class_addMethod(cls, webThreadLockReleaseSEL, (IMP)WebCoreObjCDeallocWithWebThreadLockImpl, method_getTypeEncoding(releaseMethod))) {
+        ASSERT_WITH_MESSAGE(releaseMethod, "WebCoreObjCDeallocWithWebThreadLock() failed to add %s for %@", webThreadLockReleaseSEL, NSStringFromClass(cls));
+        return;
+    }
+
+    // ensure the implementation exists at cls in the class hierarchy
+    if (class_addMethod(cls, releaseSEL, class_getMethodImplementation(cls, releaseSEL), method_getTypeEncoding(releaseMethod)))
+        releaseMethod = class_getInstanceMethod(cls, releaseSEL);
+
+    // swizzle the old release for the new implementation
+    method_exchangeImplementations(releaseMethod, class_getInstanceMethod(cls, webThreadLockReleaseSEL));
+}
+
+void WebCoreObjCDeallocOnWebThreadImpl(id self, SEL _cmd)
+{
+    UNUSED_PARAM(_cmd);
+    if (!WebThreadIsEnabled())
+        [self _webcore_releaseOnWebThread];
+    else {
+        lockWebCoreReleaseLock();
+        if ([self retainCount] == 1) {
+            // This is the only reference retaining the object, so we can
+            // safely release the WebCoreReleaseLock now.
+            unlockWebCoreReleaseLock();
+            if (WebThreadIsCurrent())
+                [self _webcore_releaseOnWebThread];
+            else
+                WebThreadAdoptAndRelease(self);
+        } else {
+            // This is not the only reference retaining the object, so another
+            // thread could also call release - hold the lock whilst calling
+            // release to avoid a race condition.
+            [self _webcore_releaseOnWebThread];
+            unlockWebCoreReleaseLock();
+        }
+    }
+}
+
+void WebCoreObjCDeallocWithWebThreadLockImpl(id self, SEL _cmd)
+{
+    UNUSED_PARAM(_cmd);
+    lockWebCoreReleaseLock();
+    if (WebThreadIsLockedOrDisabled() || 1 != [self retainCount])
+        [self _webcore_releaseWithWebThreadLock];
+    else
+        WebThreadAdoptAndRelease(self);
+    unlockWebCoreReleaseLock();
+}
+
+static void HandleWebThreadReleaseSource(void *info)
+{
+    UNUSED_PARAM(info);
+    ASSERT(WebThreadIsCurrent());
+
+    int result = pthread_mutex_lock(&WebThreadReleaseLock);
+    ASSERT_WITH_MESSAGE(result == 0, "Release lock failed with code:%d", result);
+
+    CFMutableArrayRef objects = NULL;
+    if (CFArrayGetCount(WebThreadReleaseObjArray)) {
+        objects = CFArrayCreateMutableCopy(NULL, 0, WebThreadReleaseObjArray);
+        CFArrayRemoveAllValues(WebThreadReleaseObjArray);
+    }
+
+    result = pthread_mutex_unlock(&WebThreadReleaseLock);
+    ASSERT_WITH_MESSAGE(result == 0, "Release unlock failed with code:%d", result);
+
+    if (!objects)
+        return;
+
+    unsigned count = CFArrayGetCount(objects);
+    unsigned i;
+    for (i = 0; i < count; i++) {
+        id obj = (id)CFArrayGetValueAtIndex(objects, i);
+#if LOG_RELEASES
+        NSLog(@"Release recv [web thread] : %@", obj);
+#endif
+        [obj release];
+    }
+
+    CFRelease(objects);
+}
+
+void WebThreadCallDelegate(NSInvocation *invocation)
+{
+    // NSInvocation released in SendMessage()
+    SendDelegateMessage([invocation retain]);
+}
+
+void WebThreadPostNotification(NSString *name, id object, id userInfo)
+{
+    if (pthread_main_np())
+        [[NSNotificationCenter defaultCenter] postNotificationName:name object:object userInfo:userInfo];
+    else {
+        dispatch_async(dispatch_get_main_queue(), ^ {
+            [[NSNotificationCenter defaultCenter] postNotificationName:name object:object userInfo:userInfo];
+        });
+    }
+}
+
+void WebThreadCallDelegateAsync(NSInvocation *invocation)
+{
+    ASSERT(invocation);
+    if (WebThreadIsCurrent())
+        [sAsyncDelegates addObject:invocation];
+    else
+        WebThreadCallDelegate(invocation);
+}
+
+// Note: despite the name, returns an autoreleased object.
+NSInvocation *WebThreadMakeNSInvocation(id target, SEL selector)
+{
+    NSMethodSignature *signature = [target methodSignatureForSelector:selector];
+    ASSERT(signature);
+    if (signature) {
+        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
+        [invocation setSelector:selector];
+        [invocation setTarget:target];
+        [invocation retainArguments];
+        return invocation;
+    }
+    return nil;
+}
+
+static void MainRunLoopAutoUnlock(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *context)
+{
+    UNUSED_PARAM(observer);
+    UNUSED_PARAM(activity);
+    UNUSED_PARAM(context);
+    ASSERT(!WebThreadIsCurrent());
+
+    if (sMainThreadModalCount != 0)
+        return;
+    
+    CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), mainRunLoopAutoUnlockObserver, kCFRunLoopCommonModes);
+
+    _WebThreadUnlock();
+}
+
+static void _WebThreadAutoLock(void)
+{
+    ASSERT(!WebThreadIsCurrent());
+
+    if (mainThreadLockCount == 0) {
+        CFRunLoopAddObserver(CFRunLoopGetCurrent(), mainRunLoopAutoUnlockObserver, kCFRunLoopCommonModes);    
+        _WebTryThreadLock(false);
+        CFRunLoopWakeUp(CFRunLoopGetMain());
+    }
+}
+
+static void WebRunLoopLockInternal(AutoreleasePoolOperation poolOperation)
+{
+    _WebTryThreadLock(false);
+    if (poolOperation == PushOrPopAutoreleasePool)
+        autoreleasePoolMark = NSPushAutoreleasePool(0);
+    isWebThreadLocked = YES;
+}
+
+static void WebRunLoopUnlockInternal(AutoreleasePoolOperation poolOperation)
+{
+    ASSERT(sAsyncDelegates);
+    if ([sAsyncDelegates count]) {
+        for (NSInvocation* invocation in sAsyncDelegates)
+            SendDelegateMessage([invocation retain]);
+        [sAsyncDelegates removeAllObjects];
+    }
+
+    if (poolOperation == PushOrPopAutoreleasePool)
+        NSPopAutoreleasePool(autoreleasePoolMark);
+
+    _WebThreadUnlock();
+    isWebThreadLocked = NO;
+}
+
+static void WebRunLoopLock(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *context)
+{
+    UNUSED_PARAM(observer);
+    UNUSED_PARAM(context);
+    ASSERT(WebThreadIsCurrent());
+    ASSERT_UNUSED(activity, activity == kCFRunLoopAfterWaiting || activity == kCFRunLoopBeforeTimers || activity == kCFRunLoopBeforeSources);
+
+    // If the WebThread is locked by the main thread then we want to
+    // grab the lock ourselves when the main thread releases the lock.
+    if (isWebThreadLocked && !mainThreadLockCount)
+        return;
+    WebRunLoopLockInternal(PushOrPopAutoreleasePool);
+}
+
+static void WebRunLoopUnlock(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *context)
+{
+    UNUSED_PARAM(observer);
+    UNUSED_PARAM(context);
+    ASSERT(WebThreadIsCurrent());
+    ASSERT_UNUSED(activity, activity == kCFRunLoopBeforeWaiting || activity == kCFRunLoopExit);
+    ASSERT(!mainThreadLockCount);
+
+    if (!isWebThreadLocked)
+        return;
+    WebRunLoopUnlockInternal(PushOrPopAutoreleasePool);
+}
+
+static void MainRunLoopUnlockGuard(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *context)
+{
+    UNUSED_PARAM(observer);
+    UNUSED_PARAM(activity);
+    UNUSED_PARAM(context);
+    ASSERT(!WebThreadIsCurrent());
+
+    // We shouldn't have the web lock at this point.  However, MobileMail sometimes
+    // get to a state where the main thread has web lock but it didn't release it on last
+    // runloop exit, and web thread gets stuck at waiting for the lock. If this happens,
+    // we need to help release the lock.  See <rdar://problem/8005192>.
+    if (mainThreadLockCount != 0 && sMainThreadModalCount == 0) {
+        NSLog(@"WARNING: Main thread didn't release the lock at last runloop exit!");
+
+        MainRunLoopAutoUnlock(observer, activity, context);
+        if (mainThreadLockCount != 0)
+            mainThreadLockCount = 0;
+    }
+}
+
+static void _WebRunLoopEnableNestedFromMainThread()
+{
+    CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), mainRunLoopAutoUnlockObserver, kCFRunLoopCommonModes);
+}
+
+static void _WebRunLoopDisableNestedFromMainThread()
+{
+    CFRunLoopAddObserver(CFRunLoopGetCurrent(), mainRunLoopAutoUnlockObserver, kCFRunLoopCommonModes); 
+}
+
+void WebRunLoopEnableNested()
+{
+    if (!WebThreadIsEnabled())
+        return;
+
+    ASSERT(!isNestedWebThreadRunLoop);
+
+    if (!WebThreadIsCurrent())
+        _WebRunLoopEnableNestedFromMainThread();
+
+    savedAutoreleasePoolMark = autoreleasePoolMark;
+    autoreleasePoolMark = 0;
+    WebRunLoopUnlockInternal(IgnoreAutoreleasePool);
+    isNestedWebThreadRunLoop = YES;
+}
+
+void WebRunLoopDisableNested()
+{
+    if (!WebThreadIsEnabled())
+        return;
+
+    ASSERT(isNestedWebThreadRunLoop);
+
+    if (!WebThreadIsCurrent())
+        _WebRunLoopDisableNestedFromMainThread();
+
+    autoreleasePoolMark = savedAutoreleasePoolMark;
+    savedAutoreleasePoolMark = 0;
+    WebRunLoopLockInternal(IgnoreAutoreleasePool);
+    isNestedWebThreadRunLoop = NO;
+}
+
+static void FreeThreadContext(void *threadContext)
+{
+    if (threadContext != NULL)
+       free(threadContext);
+}
+
+static void InitThreadContextKey()
+{
+    pthread_key_create(&threadContextKey, FreeThreadContext);
+}
+
+static WebThreadContext *CurrentThreadContext(void)
+{
+    static pthread_once_t initControl = PTHREAD_ONCE_INIT; 
+    pthread_once(&initControl, InitThreadContextKey);    
+
+    WebThreadContext *threadContext = (WebThreadContext*)pthread_getspecific(threadContextKey);
+    if (threadContext == NULL) {
+        threadContext = (WebThreadContext *)calloc(sizeof(WebThreadContext), 1);
+        pthread_setspecific(threadContextKey, threadContext);
+    }        
+    return threadContext;
+}
+
+static
+#ifndef __llvm__
+NO_RETURN
+#endif
+void *RunWebThread(void *arg)
+{
+    // Propagate the mainThread's fenv to the web thread.
+    fesetenv(&mainThreadFEnv);
+
+    UNUSED_PARAM(arg);
+    // WTF::initializeMainThread() needs to be called before JSC::initializeThreading() since the
+    // code invoked by the latter needs to know if it's running on the WebThread. See
+    // <rdar://problem/8502487>.
+    WTF::initializeMainThread();
+    WTF::initializeWebThread();
+    JSC::initializeThreading();
+    
+#if ENABLE(WORKERS)
+    // Make sure that the WebThread and the main thread share the same ThreadGlobalData objects.
+    WebCore::threadGlobalData().setWebCoreThreadData();
+#endif
+    initializeWebThreadIdentifier();
+
+#if HAVE(PTHREAD_SETNAME_NP)
+    pthread_setname_np("WebThread");
+#endif
+
+    webThreadContext = CurrentThreadContext();
+    webThreadRunLoop = CFRunLoopGetCurrent();
+    webThreadNSRunLoop = [[NSRunLoop currentRunLoop] retain];
+
+    CFRunLoopObserverRef webRunLoopLockObserverRef = CFRunLoopObserverCreate(NULL, kCFRunLoopBeforeTimers|kCFRunLoopBeforeSources|kCFRunLoopAfterWaiting, YES, 0, WebRunLoopLock, NULL);
+    CFRunLoopAddObserver(webThreadRunLoop, webRunLoopLockObserverRef, kCFRunLoopCommonModes);
+    CFRelease(webRunLoopLockObserverRef);
+    
+    WebThreadInitRunQueue();
+
+    // We must have the lock when CA paints in the web thread. CA commits at 2000000 so we use larger order number than that to free the lock.
+    CFRunLoopObserverRef webRunLoopUnlockObserverRef = CFRunLoopObserverCreate(NULL, kCFRunLoopBeforeWaiting|kCFRunLoopExit, YES, 2500000, WebRunLoopUnlock, NULL);    
+    CFRunLoopAddObserver(webThreadRunLoop, webRunLoopUnlockObserverRef, kCFRunLoopCommonModes);
+    CFRelease(webRunLoopUnlockObserverRef);    
+
+    CFRunLoopSourceContext ReleaseSourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, HandleWebThreadReleaseSource};
+    WebThreadReleaseSource = CFRunLoopSourceCreate(NULL, -1, &ReleaseSourceContext);
+    CFRunLoopAddSource(webThreadRunLoop, WebThreadReleaseSource, kCFRunLoopDefaultMode);
+
+    int result = pthread_mutex_lock(&startupLock);
+    ASSERT_WITH_MESSAGE(result == 0, "startup lock failed with code:%d", result);
+
+    result = pthread_cond_signal(&startupCondition);
+    ASSERT_WITH_MESSAGE(result == 0, "startup signal failed with code:%d", result);
+
+    result = pthread_mutex_unlock(&startupLock);
+    ASSERT_WITH_MESSAGE(result == 0, "startup unlock failed with code:%d", result);
+
+    while (1)
+        CFRunLoopRunInMode(kCFRunLoopDefaultMode, DistantFuture, true);
+
+#ifdef __llvm__
+    return NULL;
+#endif  
+}
+
+static void StartWebThread()
+{
+    webThreadStarted = TRUE;
+
+#if ENABLE(WORKERS)
+    // Initialize ThreadGlobalData on the main UI thread so that the WebCore thread
+    // can later set it's thread-specific data to point to the same objects.
+    WebCore::ThreadGlobalData& unused = WebCore::threadGlobalData();
+    (void)unused;
+#endif
+
+    // Initialize AtomicString on the main thread.
+    WTF::AtomicString::init();
+
+    // register class for WebThread deallocation
+    WebCoreObjCDeallocOnWebThread([DOMObject class]);
+    WebCoreObjCDeallocOnWebThread([WAKWindow class]);
+    WebCoreObjCDeallocWithWebThreadLock([WAKView class]);
+
+    pthread_mutexattr_t mattr;
+    pthread_mutexattr_init(&mattr);
+    pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
+    pthread_mutex_init(&webLock, &mattr);
+    pthread_mutexattr_destroy(&mattr);            
+
+    pthread_mutexattr_t mutex_attr;
+    pthread_mutexattr_init(&mutex_attr);
+    pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);    
+    pthread_mutex_init(&WebCoreReleaseLock, &mutex_attr);
+    pthread_mutexattr_destroy(&mutex_attr);
+
+    CFRunLoopRef runLoop = CFRunLoopGetCurrent();
+    CFRunLoopSourceContext delegateSourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, HandleDelegateSource};
+    delegateSource = CFRunLoopSourceCreate(NULL, 0, &delegateSourceContext);
+    // We shouldn't get delegate callbacks while scrolling, but there might be
+    // one outstanding when we start.  Add the source for all common run loop
+    // modes so we don't block the web thread while scrolling.
+    if (!delegateSourceRunLoopMode)
+        delegateSourceRunLoopMode = kCFRunLoopCommonModes;
+    CFRunLoopAddSource(runLoop, delegateSource, delegateSourceRunLoopMode);
+
+    sAsyncDelegates = [[NSMutableArray alloc] init];
+
+    mainRunLoopAutoUnlockObserver = CFRunLoopObserverCreate(NULL, kCFRunLoopBeforeWaiting | kCFRunLoopExit, YES, 3000001, MainRunLoopAutoUnlock, NULL);
+
+    pthread_attr_t tattr;
+    pthread_attr_init(&tattr);
+    pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM);
+    // The web thread is a secondary thread, and secondary threads are usually given
+    // a 512 kb stack, but we need more space in order to have room for the JavaScriptCore
+    // reentrancy limit. This limit works on both the simulator and the device.
+    pthread_attr_setstacksize(&tattr, 200 * 4096);
+
+    struct sched_param param;
+    pthread_attr_getschedparam(&tattr, &param);
+    param.sched_priority--;
+    pthread_attr_setschedparam(&tattr, &param);
+
+    // Wait for the web thread to startup completely before we continue.
+    int result = pthread_mutex_lock(&startupLock);
+    ASSERT_WITH_MESSAGE(result == 0, "startup lock failed with code:%d", result);
+
+    // Propagate the mainThread's fenv to workers & the web thread.
+    fegetenv(&mainThreadFEnv);
+
+    pthread_create(&webThread, &tattr, RunWebThread, NULL);
+    pthread_attr_destroy(&tattr);
+
+    result = pthread_cond_wait(&startupCondition, &startupLock);
+    ASSERT_WITH_MESSAGE(result == 0, "startup wait failed with code:%d", result);
+
+    result = pthread_mutex_unlock(&startupLock);
+    ASSERT_WITH_MESSAGE(result == 0, "startup unlock failed with code:%d", result);
+
+    initializeApplicationUIThreadIdentifier();
+}
+
+static int WebTimedConditionLock (pthread_cond_t *condition, pthread_mutex_t *lock, CFAbsoluteTime interval)
+{
+    struct timespec time;
+    CFAbsoluteTime at = CFAbsoluteTimeGetCurrent() + interval;
+    time.tv_sec = (time_t)(floor(at) + kCFAbsoluteTimeIntervalSince1970);
+    time.tv_nsec = (int32_t)((at - floor(at)) * 1000000000.0);        
+    return pthread_cond_timedwait(condition, lock, &time);
+}
+
+
+#if LOG_WEB_LOCK || LOG_MAIN_THREAD_LOCKING
+static unsigned lockCount;
+#endif
+
+static bool _WebTryThreadLock(bool shouldTry)
+{
+    // Suspend the web thread if the main thread is trying to lock.
+    bool onMainThread = pthread_main_np();
+    if (onMainThread)
+        webThreadShouldYield = true;
+    else if (!WebThreadIsCurrent()) {
+        NSLog(@"%s, %p: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...", __PRETTY_FUNCTION__, CurrentThreadContext());
+        CRASH();
+    }
+        
+            
+    int result;
+    bool busy = false;
+    if (shouldTry) {
+        result = pthread_mutex_trylock(&webLock);
+        if (result == EBUSY) {
+            busy = true;
+        } else
+            ASSERT_WITH_MESSAGE(result == 0, "try web lock failed with code:%d", result);
+    }
+    else {
+        result = pthread_mutex_lock(&webLock);
+        ASSERT_WITH_MESSAGE(result == 0, "web lock failed with code:%d", result);
+    }
+    
+    if (!busy) {
+#if LOG_WEB_LOCK || LOG_MAIN_THREAD_LOCKING
+        lockCount++;
+#if LOG_WEB_LOCK
+        NSLog(@"lock   %d, web-thread: %d", lockCount, WebThreadIsCurrent());
+#endif
+#endif
+        if (onMainThread) {
+            ASSERT(CFRunLoopGetCurrent() == CFRunLoopGetMain());
+            webThreadShouldYield = false;
+            mainThreadLockCount++;
+#if LOG_MAIN_THREAD_LOCKING
+            if (!sendingDelegateMessage && lockCount == 1)
+                NSLog(@"Main thread locking outside of delegate messages.");
+#endif
+        } else {
+            webThreadLockCount++;
+            if (webThreadLockCount > 1) {
+                NSLog(@"%s, %p: Multiple locks on web thread not allowed! Please file a bug. Crashing now...", __PRETTY_FUNCTION__, CurrentThreadContext());
+                CRASH();
+            }
+        }
+    }
+    
+    return !busy;
+}
+
+void WebThreadLock(void)
+{
+    if (!webThreadStarted || pthread_equal(webThread, pthread_self()))
+        return;
+    _WebThreadAutoLock();
+}
+
+void WebThreadUnlock(void)
+{
+    // This is a no-op, we unlock automatically on top of the runloop
+    ASSERT(!WebThreadIsCurrent());
+}
+
+void WebThreadLockFromAnyThread()
+{
+    _WebThreadLockFromAnyThread(true);
+}
+    
+void WebThreadLockFromAnyThreadNoLog()
+{
+    _WebThreadLockFromAnyThread(false);
+}
+
+static void _WebThreadLockFromAnyThread(bool shouldLog)
+{
+    if (!webThreadStarted)
+        return;
+    ASSERT(!WebThreadIsCurrent());
+    if (pthread_main_np()) {
+        _WebThreadAutoLock();
+        return;
+    }
+    if (shouldLog)
+        NSLog(@"%s, %p: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.", __PRETTY_FUNCTION__, CurrentThreadContext());
+
+    pthread_mutex_lock(&webLock);
+    
+    // This used for any thread other than the web thread.
+    otherThreadLockCount++;
+    webThreadShouldYield = false;
+}
+
+void WebThreadUnlockFromAnyThread()
+{
+    if (!webThreadStarted)
+        return;
+    ASSERT(!WebThreadIsCurrent());
+    // No-op except from a secondary thread.
+    if (pthread_main_np())
+        return;
+    
+    ASSERT(otherThreadLockCount);
+    otherThreadLockCount--;
+    
+    int result;
+    result = pthread_mutex_unlock(&webLock); 
+    ASSERT_WITH_MESSAGE(result == 0, "web unlock failed with code:%d", result);
+}
+
+void WebThreadUnlockGuardForMail()
+{
+    ASSERT(!WebThreadIsCurrent());
+
+    CFRunLoopObserverRef mainRunLoopUnlockGuardObserver = CFRunLoopObserverCreate(NULL, kCFRunLoopEntry, YES, 0, MainRunLoopUnlockGuard, NULL);
+    CFRunLoopAddObserver(CFRunLoopGetMain(), mainRunLoopUnlockGuardObserver, kCFRunLoopCommonModes);
+    CFRelease(mainRunLoopUnlockGuardObserver);
+}
+
+void _WebThreadUnlock(void)
+{
+#if LOG_WEB_LOCK || LOG_MAIN_THREAD_LOCKING
+    lockCount--;
+#if LOG_WEB_LOCK
+    NSLog(@"unlock %d, web-thread: %d", lockCount, WebThreadIsCurrent());
+#endif
+#endif
+    
+    if (!WebThreadIsCurrent()) {
+        ASSERT(mainThreadLockCount != 0);
+        mainThreadLockCount--;
+    } else {    
+        webThreadLockCount--;
+        webThreadShouldYield = false;
+    }
+    
+    int result;
+    result = pthread_mutex_unlock(&webLock); 
+    ASSERT_WITH_MESSAGE(result == 0, "web unlock failed with code:%d", result);    
+}
+
+bool WebThreadIsLocked(void)
+{
+    if (WebThreadIsCurrent())
+        return webThreadLockCount;
+    else if (pthread_main_np())
+        return mainThreadLockCount;
+    else
+        return otherThreadLockCount;
+}
+
+bool WebThreadIsLockedOrDisabled(void)
+{
+    return !WebThreadIsEnabled() || WebThreadIsLocked();
+}
+
+void WebThreadLockPushModal(void)
+{
+    if (WebThreadIsCurrent())
+        return;
+    
+    ASSERT(WebThreadIsLocked());
+    ++sMainThreadModalCount;
+}
+
+void WebThreadLockPopModal(void)
+{
+    if (WebThreadIsCurrent())
+        return;
+    
+    ASSERT(WebThreadIsLocked());
+    ASSERT(sMainThreadModalCount != 0);
+    --sMainThreadModalCount;
+}
+
+CFRunLoopRef WebThreadRunLoop(void)
+{
+    if (webThreadStarted) {
+        ASSERT(webThreadRunLoop);
+        return webThreadRunLoop;
+    }
+    
+    return CFRunLoopGetCurrent();
+}
+
+NSRunLoop* WebThreadNSRunLoop(void)
+{
+    if (webThreadStarted) {
+        ASSERT(webThreadNSRunLoop);
+        return webThreadNSRunLoop;
+    }
+
+    return [NSRunLoop currentRunLoop];
+}
+
+WebThreadContext *WebThreadCurrentContext(void)
+{
+    return CurrentThreadContext();
+}
+
+bool WebThreadContextIsCurrent(void)
+{   
+    return WebThreadCurrentContext() == webThreadContext;
+}
+
+void WebThreadSetDelegateSourceRunLoopMode(CFStringRef mode)
+{
+    ASSERT(!webThreadStarted);
+    delegateSourceRunLoopMode = mode;
+}
+
+void WebThreadEnable(void)
+{
+    static pthread_once_t initControl = PTHREAD_ONCE_INIT; 
+    pthread_once(&initControl, StartWebThread);
+}
+
+bool WebThreadIsEnabled(void)
+{
+    return webThreadStarted;
+}
+
+bool WebThreadIsCurrent(void)
+{
+    return webThreadStarted && pthread_equal(webThread, pthread_self());
+}
+
+bool WebThreadNotCurrent(void)
+{
+    return webThreadStarted && !pthread_equal(webThread, pthread_self());
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadInternal.h b/Source/WebCore/platform/ios/wak/WebCoreThreadInternal.h
new file mode 100644 (file)
index 0000000..46566c3
--- /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.
+ */
+
+#ifndef WebCoreThreadInternal_h
+#define WebCoreThreadInternal_h
+
+#include "WebCoreThread.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif    
+
+// Sometimes, like for the Inspector, we need to pause the execution of a current run
+// loop iteration and resume it later. This handles pushing and popping the autorelease
+// pools to keep the original pool unaffected by the run loop observers. The
+// WebThreadLock is released when calling Enable, and acquired when calling Disable.
+// NOTE: Does not expect arbitrary nesting, only 1 level of nesting.
+void WebRunLoopEnableNested();
+void WebRunLoopDisableNested();
+
+void WebThreadInitRunQueue();
+
+#if defined(__cplusplus)
+} // extern "C"
+#endif
+
+#endif // WebCoreThreadInternal_h
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadMessage.h b/Source/WebCore/platform/ios/wak/WebCoreThreadMessage.h
new file mode 100644 (file)
index 0000000..427f2fb
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 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 WebCoreThreadMessage_h
+#define WebCoreThreadMessage_h
+
+#if TARGET_OS_IPHONE
+
+#import <Foundation/Foundation.h>
+
+#ifdef __OBJC__
+#import "WebCoreThread.h"
+#endif // __OBJC__
+
+#if defined(__cplusplus)
+extern "C" {
+#endif    
+
+//
+// Release an object on the main thread.
+//
+@interface NSObject(WebCoreThreadAdditions)
+- (void)releaseOnMainThread;
+@end
+
+// Register a class for deallocation on the WebThread
+void WebCoreObjCDeallocOnWebThread(Class cls);
+void WebCoreObjCDeallocWithWebThreadLock(Class cls);
+
+// Asynchronous from main thread to web thread.
+void WebThreadAdoptAndRelease(id obj);
+
+// Synchronous from web thread to main thread, or main thread to main thread.
+void WebThreadCallDelegate(NSInvocation *invocation);
+void WebThreadRunOnMainThread(void (^)(void));
+
+// Asynchronous from web thread to main thread, but synchronous when called on the main thread.
+void WebThreadCallDelegateAsync(NSInvocation *invocation);
+
+// Asynchronous from web thread to main thread, but synchronous when called on the main thread.
+void WebThreadPostNotification(NSString *name, id object, id userInfo);
+
+// Convenience method for making an NSInvocation object
+NSInvocation *WebThreadMakeNSInvocation(id target, SEL selector);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WebCoreThreadMessage_h
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp b/Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp
new file mode 100644 (file)
index 0000000..3fd9805
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCoreThreadRun.h"
+
+#if PLATFORM(IOS)
+
+#include "WebCoreThread.h"
+#include "WebCoreThreadInternal.h"
+#include <wtf/ThreadingPrimitives.h>
+#include <wtf/Vector.h>
+
+namespace {
+
+class WebThreadBlockState {
+public:
+    WebThreadBlockState()
+        : m_completed(false)
+    {
+    }
+
+    void waitForCompletion()
+    {
+        MutexLocker locker(m_stateMutex);
+        while (!m_completed)
+            m_completionCondition.wait(m_stateMutex);
+    }
+
+    void setCompleted()
+    {
+        MutexLocker locker(m_stateMutex);
+        ASSERT(!m_completed);
+        m_completed = true;
+        m_completionCondition.signal();
+    }
+private:
+    WTF::Mutex m_stateMutex;
+    WTF::ThreadCondition m_completionCondition;
+    bool m_completed;
+};
+
+class WebThreadBlock {
+public:
+    WebThreadBlock(void (^task)(), WebThreadBlockState* state)
+        : m_task(Block_copy(task))
+        , m_state(state)
+    {
+    }
+
+    WebThreadBlock(const WebThreadBlock& other)
+        : m_task(Block_copy(other.m_task))
+        , m_state(other.m_state)
+    {
+    }
+
+    WebThreadBlock& operator=(const WebThreadBlock& other)
+    {
+        void (^oldTask)() = m_task;
+        m_task = Block_copy(other.m_task);
+        Block_release(oldTask);
+        m_state = other.m_state;
+        return *this;
+    }
+
+    ~WebThreadBlock()
+    {
+        Block_release(m_task);
+    }
+
+    void operator()() const
+    {
+        m_task();
+        if (m_state)
+            m_state->setCompleted();
+    }
+
+private:
+    void (^m_task)();
+    WebThreadBlockState* m_state;
+};
+
+}
+
+extern "C" {
+
+typedef WTF::Vector<WebThreadBlock> WebThreadRunQueue;
+
+static WTF::Mutex *runQueueLock = NULL;
+static CFRunLoopSourceRef runSource = NULL;
+static WebThreadRunQueue *runQueue = NULL;
+
+static void HandleRunSource(void *info)
+{
+    UNUSED_PARAM(info);
+    ASSERT(WebThreadIsCurrent());
+    ASSERT(runQueueLock);
+    ASSERT(runSource);
+    ASSERT(runQueue);
+
+    WebThreadRunQueue queueCopy;
+    {
+        MutexLocker locker(*runQueueLock);
+        queueCopy = *runQueue;
+        runQueue->clear();
+    }
+
+    for (WebThreadRunQueue::const_iterator it = queueCopy.begin(); it != queueCopy.end(); ++it)
+        (*it)();
+}
+
+static void _WebThreadRun(void (^task)(), bool synchronous)
+{
+    if (WebThreadIsCurrent() || !WebThreadIsEnabled()) {
+        task();
+        return;
+    }
+    
+    ASSERT(runQueueLock);
+    ASSERT(runSource);
+    ASSERT(runQueue);
+
+    WebThreadBlockState* state = 0;
+    if (synchronous)
+        state = new WebThreadBlockState;
+
+    {
+        MutexLocker locker(*runQueueLock);
+        runQueue->append(WebThreadBlock(task, state));
+    }
+
+    CFRunLoopSourceSignal(runSource);
+    CFRunLoopWakeUp(WebThreadRunLoop());
+
+    if (synchronous) {
+        state->waitForCompletion();
+        delete state;
+    }
+}
+
+void WebThreadRun(void (^task)())
+{
+    _WebThreadRun(task, false);
+}
+
+void WebThreadRunSync(void (^task)())
+{
+    _WebThreadRun(task, true);
+}
+    
+void WebThreadInitRunQueue()
+{
+    ASSERT(!runQueue);
+    ASSERT(!runQueueLock);
+    ASSERT(!runSource);
+
+    static dispatch_once_t pred;
+    dispatch_once(&pred, ^{
+        runQueue = new WebThreadRunQueue;
+
+        CFRunLoopSourceContext runSourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, HandleRunSource};
+        runSource = CFRunLoopSourceCreate(NULL, -1, &runSourceContext);
+        CFRunLoopAddSource(WebThreadRunLoop(), runSource, kCFRunLoopDefaultMode);
+
+        runQueueLock = new WTF::Mutex;
+    });
+}
+
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadRun.h b/Source/WebCore/platform/ios/wak/WebCoreThreadRun.h
new file mode 100644 (file)
index 0000000..5a88e81
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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 WebCoreThreadRun_h
+#define WebCoreThreadRun_h
+
+#if TARGET_OS_IPHONE
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+// On the web thread, both
+//   WebThreadRun(^{ code; });
+// and
+//   WebThreadRunSync(^{ code; });
+// just run the block immediately.
+
+// On any other thread,
+//   WebThreadRun(^{ code; });
+// will queue the block for asynchronous execution on the web thread, and
+//   WebThreadRunSync(^{ code; });
+// will queue the block and wait for its execution to finish.
+
+void WebThreadRun(void (^block)());
+void WebThreadRunSync(void (^block)());
+
+#if defined(__cplusplus)
+} // extern "C"
+#endif
+
+#endif // TARGET_OS_IPHONE
+
+#endif // WebCoreThreadRun_h
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadSafe.h b/Source/WebCore/platform/ios/wak/WebCoreThreadSafe.h
new file mode 100644 (file)
index 0000000..896b083
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 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 WebCoreThreadSafe_h
+#define WebCoreThreadSafe_h
+
+#import <Foundation/Foundation.h>
+
+@class WebEvent;
+
+// Listing of methods that are currently thread-safe.
+
+@interface WAKView : NSObject
+@end
+
+@interface WebView : WAKView
+- (void)reload:(id)sender;
+- (void)stopLoading:(id)sender;
+- (BOOL)canGoBack;
+- (void)goBack;
+- (BOOL)canGoForward;
+- (void)goForward;
+@end
+
+@interface WebFrame : NSObject
+- (void)loadRequest:(NSURLRequest *)request;
+@end
+
+@interface WAKResponder : NSObject
+@end
+
+@interface WAKWindow : WAKResponder
+- (void)sendEvent:(WebEvent *)event;
+@end
+
+@protocol WebPolicyDecisionListener <NSObject>
+- (void)use;
+@end
+
+@interface WebScriptObject : NSObject
+@end
+
+@interface DOMObject : WebScriptObject
+@end
+
+#endif // WebCoreThreadSafe_h
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.cpp b/Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.cpp
new file mode 100644 (file)
index 0000000..c48ca48
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCoreThreadSystemInterface.h"
+
+#if PLATFORM(IOS)
+
+#include "WebCoreThread.h" 
+#include <wtf/ios/WebCoreThread.h>
+
+// "Fill In" JavaScriptCore's function pointers with ours.
+// JavaScriptCore's functions have the same name, but
+// they are prefixed with "WebCore".
+
+#define INIT(function) WebCore##function = function
+
+void InitWebCoreThreadSystemInterface(void)
+{
+    static bool didInit;
+    if (didInit)
+        return;
+
+    INIT(WebThreadIsLockedOrDisabled);
+
+    didInit = true;
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.h b/Source/WebCore/platform/ios/wak/WebCoreThreadSystemInterface.h
new file mode 100644 (file)
index 0000000..431e0ba
--- /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 TARGET_OS_IPHONE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void InitWebCoreThreadSystemInterface(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TARGET_OS_IPHONE