summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/chromium/src
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/src')
-rw-r--r--Source/WebKit/chromium/src/ApplicationCacheHost.cpp304
-rw-r--r--Source/WebKit/chromium/src/ApplicationCacheHostInternal.h86
-rw-r--r--Source/WebKit/chromium/src/AssertMatchingEnums.cpp414
-rw-r--r--Source/WebKit/chromium/src/AssociatedURLLoader.cpp133
-rw-r--r--Source/WebKit/chromium/src/AssociatedURLLoader.h77
-rw-r--r--Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp175
-rw-r--r--Source/WebKit/chromium/src/AsyncFileSystemChromium.h77
-rw-r--r--Source/WebKit/chromium/src/AsyncFileWriterChromium.cpp93
-rw-r--r--Source/WebKit/chromium/src/AsyncFileWriterChromium.h76
-rw-r--r--Source/WebKit/chromium/src/AudioDestinationChromium.cpp125
-rw-r--r--Source/WebKit/chromium/src/AudioDestinationChromium.h67
-rw-r--r--Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp376
-rw-r--r--Source/WebKit/chromium/src/AutoFillPopupMenuClient.h150
-rw-r--r--Source/WebKit/chromium/src/BackForwardListChromium.cpp131
-rw-r--r--Source/WebKit/chromium/src/BackForwardListChromium.h70
-rw-r--r--Source/WebKit/chromium/src/BlobRegistryProxy.cpp87
-rw-r--r--Source/WebKit/chromium/src/BlobRegistryProxy.h63
-rw-r--r--Source/WebKit/chromium/src/BoundObject.cpp79
-rw-r--r--Source/WebKit/chromium/src/BoundObject.h61
-rw-r--r--Source/WebKit/chromium/src/ChromeClientImpl.cpp864
-rw-r--r--Source/WebKit/chromium/src/ChromeClientImpl.h197
-rw-r--r--Source/WebKit/chromium/src/ChromiumCurrentTime.cpp44
-rw-r--r--Source/WebKit/chromium/src/ChromiumThreading.cpp46
-rw-r--r--Source/WebKit/chromium/src/CompositionUnderlineBuilder.h53
-rw-r--r--Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.cpp49
-rw-r--r--Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.h53
-rw-r--r--Source/WebKit/chromium/src/ContextMenuClientImpl.cpp324
-rw-r--r--Source/WebKit/chromium/src/ContextMenuClientImpl.h63
-rw-r--r--Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp129
-rw-r--r--Source/WebKit/chromium/src/DOMUtilitiesPrivate.h66
-rw-r--r--Source/WebKit/chromium/src/DatabaseObserver.cpp90
-rw-r--r--Source/WebKit/chromium/src/DebuggerAgentImpl.cpp70
-rw-r--r--Source/WebKit/chromium/src/DebuggerAgentImpl.h73
-rw-r--r--Source/WebKit/chromium/src/DebuggerAgentManager.cpp310
-rw-r--r--Source/WebKit/chromium/src/DebuggerAgentManager.h110
-rw-r--r--Source/WebKit/chromium/src/DeviceOrientationClientProxy.cpp79
-rw-r--r--Source/WebKit/chromium/src/DeviceOrientationClientProxy.h60
-rw-r--r--Source/WebKit/chromium/src/DragClientImpl.cpp110
-rw-r--r--Source/WebKit/chromium/src/DragClientImpl.h75
-rw-r--r--Source/WebKit/chromium/src/DragScrollTimer.cpp126
-rw-r--r--Source/WebKit/chromium/src/DragScrollTimer.h69
-rw-r--r--Source/WebKit/chromium/src/EditorClientImpl.cpp948
-rw-r--r--Source/WebKit/chromium/src/EditorClientImpl.h197
-rw-r--r--Source/WebKit/chromium/src/EventListenerWrapper.cpp72
-rw-r--r--Source/WebKit/chromium/src/EventListenerWrapper.h64
-rw-r--r--Source/WebKit/chromium/src/Extensions3DChromium.cpp92
-rw-r--r--Source/WebKit/chromium/src/ExternalPopupMenu.cpp154
-rw-r--r--Source/WebKit/chromium/src/ExternalPopupMenu.h82
-rw-r--r--Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp1561
-rw-r--r--Source/WebKit/chromium/src/FrameLoaderClientImpl.h253
-rw-r--r--Source/WebKit/chromium/src/FrameNetworkingContextImpl.h43
-rw-r--r--Source/WebKit/chromium/src/GeolocationClientProxy.cpp98
-rw-r--r--Source/WebKit/chromium/src/GeolocationClientProxy.h61
-rw-r--r--Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp1076
-rw-r--r--Source/WebKit/chromium/src/GraphicsContext3DInternal.h291
-rw-r--r--Source/WebKit/chromium/src/IDBCallbacksProxy.cpp118
-rw-r--r--Source/WebKit/chromium/src/IDBCallbacksProxy.h71
-rw-r--r--Source/WebKit/chromium/src/IDBCursorBackendProxy.cpp95
-rw-r--r--Source/WebKit/chromium/src/IDBCursorBackendProxy.h62
-rw-r--r--Source/WebKit/chromium/src/IDBDatabaseProxy.cpp116
-rw-r--r--Source/WebKit/chromium/src/IDBDatabaseProxy.h65
-rwxr-xr-xSource/WebKit/chromium/src/IDBFactoryBackendProxy.cpp71
-rwxr-xr-xSource/WebKit/chromium/src/IDBFactoryBackendProxy.h62
-rw-r--r--Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp110
-rw-r--r--Source/WebKit/chromium/src/IDBIndexBackendProxy.h64
-rwxr-xr-xSource/WebKit/chromium/src/IDBObjectStoreProxy.cpp136
-rwxr-xr-xSource/WebKit/chromium/src/IDBObjectStoreProxy.h70
-rw-r--r--Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp93
-rw-r--r--Source/WebKit/chromium/src/IDBTransactionBackendProxy.h64
-rw-r--r--Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.cpp72
-rw-r--r--Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.h63
-rw-r--r--Source/WebKit/chromium/src/InspectorClientImpl.cpp114
-rw-r--r--Source/WebKit/chromium/src/InspectorClientImpl.h71
-rw-r--r--Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp138
-rw-r--r--Source/WebKit/chromium/src/InspectorFrontendClientImpl.h82
-rw-r--r--Source/WebKit/chromium/src/LocalFileSystemChromium.cpp85
-rw-r--r--Source/WebKit/chromium/src/LocalizedStrings.cpp379
-rw-r--r--Source/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp47
-rw-r--r--Source/WebKit/chromium/src/NotificationPresenterImpl.cpp108
-rw-r--r--Source/WebKit/chromium/src/NotificationPresenterImpl.h70
-rw-r--r--Source/WebKit/chromium/src/PlatformBridge.cpp1048
-rw-r--r--Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp258
-rw-r--r--Source/WebKit/chromium/src/PlatformMessagePortChannel.h93
-rw-r--r--Source/WebKit/chromium/src/ResourceHandle.cpp336
-rw-r--r--Source/WebKit/chromium/src/SharedWorkerRepository.cpp245
-rw-r--r--Source/WebKit/chromium/src/SocketStreamHandle.cpp236
-rw-r--r--Source/WebKit/chromium/src/SpeechInputClientImpl.cpp108
-rw-r--r--Source/WebKit/chromium/src/SpeechInputClientImpl.h81
-rw-r--r--Source/WebKit/chromium/src/StorageAreaProxy.cpp156
-rw-r--r--Source/WebKit/chromium/src/StorageAreaProxy.h65
-rw-r--r--Source/WebKit/chromium/src/StorageEventDispatcherChromium.cpp56
-rw-r--r--Source/WebKit/chromium/src/StorageEventDispatcherImpl.cpp84
-rw-r--r--Source/WebKit/chromium/src/StorageEventDispatcherImpl.h61
-rw-r--r--Source/WebKit/chromium/src/StorageNamespaceProxy.cpp97
-rw-r--r--Source/WebKit/chromium/src/StorageNamespaceProxy.h56
-rw-r--r--Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp129
-rw-r--r--Source/WebKit/chromium/src/VideoFrameChromiumImpl.h68
-rw-r--r--Source/WebKit/chromium/src/WebAccessibilityCache.cpp50
-rw-r--r--Source/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp177
-rw-r--r--Source/WebKit/chromium/src/WebAccessibilityCacheImpl.h92
-rw-r--r--Source/WebKit/chromium/src/WebAccessibilityObject.cpp556
-rw-r--r--Source/WebKit/chromium/src/WebAnimationControllerImpl.cpp110
-rw-r--r--Source/WebKit/chromium/src/WebAnimationControllerImpl.h64
-rw-r--r--Source/WebKit/chromium/src/WebAttribute.cpp68
-rw-r--r--Source/WebKit/chromium/src/WebAudioBus.cpp132
-rw-r--r--Source/WebKit/chromium/src/WebBindings.cpp405
-rw-r--r--Source/WebKit/chromium/src/WebBlobData.cpp131
-rw-r--r--Source/WebKit/chromium/src/WebCString.cpp140
-rw-r--r--Source/WebKit/chromium/src/WebCache.cpp108
-rw-r--r--Source/WebKit/chromium/src/WebColor.cpp129
-rw-r--r--Source/WebKit/chromium/src/WebCommon.cpp44
-rw-r--r--Source/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp43
-rw-r--r--Source/WebKit/chromium/src/WebCursorInfo.cpp50
-rw-r--r--Source/WebKit/chromium/src/WebDOMEvent.cpp219
-rw-r--r--Source/WebKit/chromium/src/WebDOMEventListener.cpp64
-rw-r--r--Source/WebKit/chromium/src/WebDOMEventListenerPrivate.cpp87
-rw-r--r--Source/WebKit/chromium/src/WebDOMEventListenerPrivate.h95
-rw-r--r--Source/WebKit/chromium/src/WebDOMMouseEvent.cpp110
-rw-r--r--Source/WebKit/chromium/src/WebDOMMutationEvent.cpp65
-rw-r--r--Source/WebKit/chromium/src/WebDOMStringList.cpp89
-rw-r--r--Source/WebKit/chromium/src/WebData.cpp103
-rw-r--r--Source/WebKit/chromium/src/WebDataSourceImpl.cpp188
-rw-r--r--Source/WebKit/chromium/src/WebDataSourceImpl.h106
-rw-r--r--Source/WebKit/chromium/src/WebDatabase.cpp121
-rw-r--r--Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp445
-rw-r--r--Source/WebKit/chromium/src/WebDevToolsAgentImpl.h116
-rw-r--r--Source/WebKit/chromium/src/WebDevToolsAgentPrivate.h50
-rw-r--r--Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp134
-rw-r--r--Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h80
-rw-r--r--Source/WebKit/chromium/src/WebDeviceOrientation.cpp86
-rw-r--r--Source/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp76
-rw-r--r--Source/WebKit/chromium/src/WebDeviceOrientationController.cpp47
-rw-r--r--Source/WebKit/chromium/src/WebDocument.cpp148
-rw-r--r--Source/WebKit/chromium/src/WebDocumentType.cpp64
-rw-r--r--Source/WebKit/chromium/src/WebDragData.cpp239
-rw-r--r--Source/WebKit/chromium/src/WebElement.cpp114
-rw-r--r--Source/WebKit/chromium/src/WebEntities.cpp90
-rw-r--r--Source/WebKit/chromium/src/WebEntities.h76
-rw-r--r--Source/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp60
-rw-r--r--Source/WebKit/chromium/src/WebFileChooserCompletionImpl.h58
-rw-r--r--Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp102
-rw-r--r--Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h71
-rw-r--r--Source/WebKit/chromium/src/WebFontCache.cpp58
-rw-r--r--Source/WebKit/chromium/src/WebFontDescription.cpp71
-rw-r--r--Source/WebKit/chromium/src/WebFontImpl.cpp129
-rw-r--r--Source/WebKit/chromium/src/WebFontImpl.h66
-rw-r--r--Source/WebKit/chromium/src/WebFormControlElement.cpp85
-rw-r--r--Source/WebKit/chromium/src/WebFormElement.cpp121
-rw-r--r--Source/WebKit/chromium/src/WebFrameImpl.cpp2304
-rw-r--r--Source/WebKit/chromium/src/WebFrameImpl.h401
-rw-r--r--Source/WebKit/chromium/src/WebGeolocationClientMock.cpp146
-rw-r--r--Source/WebKit/chromium/src/WebGeolocationController.cpp52
-rw-r--r--Source/WebKit/chromium/src/WebGeolocationError.cpp67
-rw-r--r--Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp49
-rw-r--r--Source/WebKit/chromium/src/WebGeolocationPermissionRequestManager.cpp95
-rw-r--r--Source/WebKit/chromium/src/WebGeolocationPosition.cpp61
-rw-r--r--Source/WebKit/chromium/src/WebGlyphCache.cpp45
-rw-r--r--Source/WebKit/chromium/src/WebHTTPBody.cpp184
-rw-r--r--Source/WebKit/chromium/src/WebHTTPLoadInfo.cpp111
-rw-r--r--Source/WebKit/chromium/src/WebHistoryItem.cpp300
-rw-r--r--Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp106
-rw-r--r--Source/WebKit/chromium/src/WebIDBCallbacksImpl.h62
-rw-r--r--Source/WebKit/chromium/src/WebIDBCursorImpl.cpp88
-rw-r--r--Source/WebKit/chromium/src/WebIDBCursorImpl.h58
-rw-r--r--Source/WebKit/chromium/src/WebIDBDatabaseError.cpp86
-rw-r--r--Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp105
-rw-r--r--Source/WebKit/chromium/src/WebIDBDatabaseImpl.h64
-rwxr-xr-xSource/WebKit/chromium/src/WebIDBFactoryImpl.cpp68
-rwxr-xr-xSource/WebKit/chromium/src/WebIDBFactoryImpl.h53
-rw-r--r--Source/WebKit/chromium/src/WebIDBIndexImpl.cpp93
-rw-r--r--Source/WebKit/chromium/src/WebIDBIndexImpl.h60
-rw-r--r--Source/WebKit/chromium/src/WebIDBKey.cpp161
-rw-r--r--Source/WebKit/chromium/src/WebIDBKeyPath.cpp77
-rw-r--r--Source/WebKit/chromium/src/WebIDBKeyRange.cpp95
-rwxr-xr-xSource/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp112
-rwxr-xr-xSource/WebKit/chromium/src/WebIDBObjectStoreImpl.h66
-rw-r--r--Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.cpp61
-rw-r--r--Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.h56
-rw-r--r--Source/WebKit/chromium/src/WebIDBTransactionImpl.cpp85
-rw-r--r--Source/WebKit/chromium/src/WebIDBTransactionImpl.h60
-rw-r--r--Source/WebKit/chromium/src/WebImageCG.cpp115
-rw-r--r--Source/WebKit/chromium/src/WebImageDecoder.cpp121
-rw-r--r--Source/WebKit/chromium/src/WebImageSkia.cpp121
-rw-r--r--Source/WebKit/chromium/src/WebInputElement.cpp181
-rw-r--r--Source/WebKit/chromium/src/WebInputEvent.cpp159
-rw-r--r--Source/WebKit/chromium/src/WebInputEventConversion.cpp349
-rw-r--r--Source/WebKit/chromium/src/WebInputEventConversion.h114
-rw-r--r--Source/WebKit/chromium/src/WebKit.cpp118
-rw-r--r--Source/WebKit/chromium/src/WebLabelElement.cpp64
-rw-r--r--Source/WebKit/chromium/src/WebMediaElement.cpp64
-rw-r--r--Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp527
-rw-r--r--Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h145
-rw-r--r--Source/WebKit/chromium/src/WebMutationEvent.cpp65
-rw-r--r--Source/WebKit/chromium/src/WebNamedNodeMap.cpp69
-rw-r--r--Source/WebKit/chromium/src/WebNode.cpp208
-rw-r--r--Source/WebKit/chromium/src/WebNodeCollection.cpp85
-rw-r--r--Source/WebKit/chromium/src/WebNodeList.cpp80
-rw-r--r--Source/WebKit/chromium/src/WebNotification.cpp176
-rw-r--r--Source/WebKit/chromium/src/WebOptionElement.cpp100
-rw-r--r--Source/WebKit/chromium/src/WebPageSerializer.cpp80
-rw-r--r--Source/WebKit/chromium/src/WebPageSerializerImpl.cpp526
-rw-r--r--Source/WebKit/chromium/src/WebPageSerializerImpl.h189
-rw-r--r--Source/WebKit/chromium/src/WebPasswordFormData.cpp183
-rw-r--r--Source/WebKit/chromium/src/WebPasswordFormUtils.cpp115
-rw-r--r--Source/WebKit/chromium/src/WebPasswordFormUtils.h57
-rw-r--r--Source/WebKit/chromium/src/WebPerformance.cpp187
-rw-r--r--Source/WebKit/chromium/src/WebPluginContainerImpl.cpp708
-rw-r--r--Source/WebKit/chromium/src/WebPluginContainerImpl.h156
-rw-r--r--Source/WebKit/chromium/src/WebPluginDocument.cpp72
-rw-r--r--Source/WebKit/chromium/src/WebPluginListBuilderImpl.cpp65
-rw-r--r--Source/WebKit/chromium/src/WebPluginListBuilderImpl.h56
-rw-r--r--Source/WebKit/chromium/src/WebPluginLoadObserver.cpp57
-rw-r--r--Source/WebKit/chromium/src/WebPluginLoadObserver.h67
-rw-r--r--Source/WebKit/chromium/src/WebPopupMenuImpl.cpp361
-rw-r--r--Source/WebKit/chromium/src/WebPopupMenuImpl.h136
-rw-r--r--Source/WebKit/chromium/src/WebRange.cpp113
-rw-r--r--Source/WebKit/chromium/src/WebRegularExpression.cpp67
-rw-r--r--Source/WebKit/chromium/src/WebRuntimeFeatures.cpp307
-rw-r--r--Source/WebKit/chromium/src/WebScriptController.cpp60
-rw-r--r--Source/WebKit/chromium/src/WebScrollbarImpl.cpp314
-rw-r--r--Source/WebKit/chromium/src/WebScrollbarImpl.h85
-rw-r--r--Source/WebKit/chromium/src/WebSearchableFormData.cpp262
-rw-r--r--Source/WebKit/chromium/src/WebSecurityOrigin.cpp159
-rw-r--r--Source/WebKit/chromium/src/WebSecurityPolicy.cpp97
-rw-r--r--Source/WebKit/chromium/src/WebSelectElement.cpp80
-rw-r--r--Source/WebKit/chromium/src/WebSerializedScriptValue.cpp82
-rw-r--r--Source/WebKit/chromium/src/WebSettingsImpl.cpp342
-rw-r--r--Source/WebKit/chromium/src/WebSettingsImpl.h109
-rw-r--r--Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp127
-rw-r--r--Source/WebKit/chromium/src/WebSharedWorkerImpl.h75
-rw-r--r--Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp100
-rw-r--r--Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h75
-rw-r--r--Source/WebKit/chromium/src/WebSpeechInputResult.cpp54
-rw-r--r--Source/WebKit/chromium/src/WebStorageAreaImpl.cpp97
-rw-r--r--Source/WebKit/chromium/src/WebStorageAreaImpl.h83
-rw-r--r--Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp72
-rw-r--r--Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.h58
-rw-r--r--Source/WebKit/chromium/src/WebStorageNamespaceImpl.cpp93
-rw-r--r--Source/WebKit/chromium/src/WebStorageNamespaceImpl.h57
-rw-r--r--Source/WebKit/chromium/src/WebString.cpp139
-rw-r--r--Source/WebKit/chromium/src/WebTextRun.cpp45
-rwxr-xr-xSource/WebKit/chromium/src/WebThreadSafeData.cpp75
-rw-r--r--Source/WebKit/chromium/src/WebURL.cpp58
-rw-r--r--Source/WebKit/chromium/src/WebURLError.cpp69
-rw-r--r--Source/WebKit/chromium/src/WebURLLoadTiming.cpp192
-rw-r--r--Source/WebKit/chromium/src/WebURLRequest.cpp307
-rw-r--r--Source/WebKit/chromium/src/WebURLRequestPrivate.h57
-rw-r--r--Source/WebKit/chromium/src/WebURLResponse.cpp398
-rw-r--r--Source/WebKit/chromium/src/WebURLResponsePrivate.h55
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.cpp2441
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.h554
-rw-r--r--Source/WebKit/chromium/src/WebWorkerBase.cpp411
-rw-r--r--Source/WebKit/chromium/src/WebWorkerBase.h167
-rw-r--r--Source/WebKit/chromium/src/WebWorkerClientImpl.cpp418
-rw-r--r--Source/WebKit/chromium/src/WebWorkerClientImpl.h168
-rw-r--r--Source/WebKit/chromium/src/WebWorkerImpl.cpp158
-rw-r--r--Source/WebKit/chromium/src/WebWorkerImpl.h83
-rw-r--r--Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp225
-rw-r--r--Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h95
-rw-r--r--Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp89
-rw-r--r--Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h88
-rw-r--r--Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp392
-rw-r--r--Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h156
-rw-r--r--Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.cpp220
-rw-r--r--Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.h165
-rw-r--r--Source/WebKit/chromium/src/WrappedResourceRequest.h80
-rw-r--r--Source/WebKit/chromium/src/WrappedResourceResponse.h80
-rw-r--r--Source/WebKit/chromium/src/gtk/WebFontInfo.cpp189
-rw-r--r--Source/WebKit/chromium/src/gtk/WebInputEventFactory.cpp563
-rw-r--r--Source/WebKit/chromium/src/js/DevTools.js190
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/segmentChromium.pngbin0 -> 4272 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/segmentHoverChromium.pngbin0 -> 4160 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/segmentHoverEndChromium.pngbin0 -> 4143 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/segmentSelectedChromium.pngbin0 -> 4113 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.pngbin0 -> 4104 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/statusbarBackgroundChromium.pngbin0 -> 4116 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/statusbarBottomBackgroundChromium.pngbin0 -> 4120 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/statusbarButtonsChromium.pngbin0 -> 4313 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/statusbarMenuButtonChromium.pngbin0 -> 4654 bytes
-rwxr-xr-xSource/WebKit/chromium/src/js/Images/statusbarMenuButtonSelectedChromium.pngbin0 -> 4372 bytes
-rw-r--r--Source/WebKit/chromium/src/js/Tests.js813
-rw-r--r--Source/WebKit/chromium/src/js/devTools.css117
-rw-r--r--Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp60
-rw-r--r--Source/WebKit/chromium/src/linux/WebFontRendering.cpp70
-rw-r--r--Source/WebKit/chromium/src/linux/WebRenderTheme.cpp47
-rw-r--r--Source/WebKit/chromium/src/mac/WebInputEventFactory.mm1206
-rw-r--r--Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm94
-rw-r--r--Source/WebKit/chromium/src/win/WebInputEventFactory.cpp454
-rw-r--r--Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp72
-rw-r--r--Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp61
290 files changed, 48027 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/src/ApplicationCacheHost.cpp b/Source/WebKit/chromium/src/ApplicationCacheHost.cpp
new file mode 100644
index 0000000..2696b2c
--- /dev/null
+++ b/Source/WebKit/chromium/src/ApplicationCacheHost.cpp
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ApplicationCacheHost.h"
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+
+#include "ApplicationCacheHostInternal.h"
+#include "DocumentLoader.h"
+#include "DOMApplicationCache.h"
+#include "Frame.h"
+#include "InspectorApplicationCacheAgent.h"
+#include "InspectorInstrumentation.h"
+#include "Page.h"
+#include "ProgressEvent.h"
+#include "Settings.h"
+#include "WebURL.h"
+#include "WebURLError.h"
+#include "WebURLResponse.h"
+#include "WebVector.h"
+#include "WrappedResourceRequest.h"
+#include "WrappedResourceResponse.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+// We provide a custom implementation of this class that calls out to the
+// embedding application instead of using WebCore's built in appcache system.
+// This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build.
+
+ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader)
+ : m_domApplicationCache(0)
+ , m_documentLoader(documentLoader)
+ , m_defersEvents(true)
+{
+ ASSERT(m_documentLoader);
+}
+
+ApplicationCacheHost::~ApplicationCacheHost()
+{
+}
+
+void ApplicationCacheHost::maybeLoadMainResource(ResourceRequest& request, SubstituteData&)
+{
+ // We defer creating the outer host object to avoid spurious creation/destruction
+ // around creating empty documents. At this point, we're initiating a main resource
+ // load for the document, so its for real.
+
+ if (!isApplicationCacheEnabled())
+ return;
+
+ m_internal.set(new ApplicationCacheHostInternal(this));
+ if (m_internal->m_outerHost) {
+ WrappedResourceRequest wrapped(request);
+ m_internal->m_outerHost->willStartMainResourceRequest(wrapped);
+ } else
+ m_internal.clear();
+
+ // NOTE: The semantics of this method, and others in this interface, are subtly different
+ // than the method names would suggest. For example, in this method never returns an appcached
+ // response in the SubstituteData out argument, instead we return the appcached response thru
+ // the usual resource loading pipeline.
+}
+
+void ApplicationCacheHost::selectCacheWithoutManifest()
+{
+ if (m_internal)
+ m_internal->m_outerHost->selectCacheWithoutManifest();
+}
+
+void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL)
+{
+ if (m_internal) {
+ if (!m_internal->m_outerHost->selectCacheWithManifest(manifestURL)) {
+ // It's a foreign entry, restart the current navigation from the top
+ // of the navigation algorithm. The navigation will not result in the
+ // same resource being loaded, because "foreign" entries are never picked
+ // during navigation.
+ // see WebCore::ApplicationCacheGroup::selectCache()
+ Frame* frame = m_documentLoader->frame();
+ frame->navigationScheduler()->scheduleLocationChange(frame->document()->securityOrigin(),
+ frame->document()->url(), frame->loader()->referrer());
+ }
+ }
+}
+
+void ApplicationCacheHost::maybeLoadMainResourceForRedirect(ResourceRequest&, SubstituteData&)
+{
+ // N/A to the chromium port
+}
+
+bool ApplicationCacheHost::maybeLoadFallbackForMainResponse(const ResourceRequest&, const ResourceResponse& response)
+{
+ if (m_internal) {
+ WrappedResourceResponse wrapped(response);
+ m_internal->m_outerHost->didReceiveResponseForMainResource(wrapped);
+ }
+ return false;
+}
+
+bool ApplicationCacheHost::maybeLoadFallbackForMainError(const ResourceRequest&, const ResourceError& error)
+{
+ // N/A to the chromium port
+ return false;
+}
+
+void ApplicationCacheHost::mainResourceDataReceived(const char* data, int length, long long, bool)
+{
+ if (m_internal)
+ m_internal->m_outerHost->didReceiveDataForMainResource(data, length);
+}
+
+void ApplicationCacheHost::failedLoadingMainResource()
+{
+ if (m_internal)
+ m_internal->m_outerHost->didFinishLoadingMainResource(false);
+}
+
+void ApplicationCacheHost::finishedLoadingMainResource()
+{
+ if (m_internal)
+ m_internal->m_outerHost->didFinishLoadingMainResource(true);
+}
+
+bool ApplicationCacheHost::maybeLoadResource(ResourceLoader*, ResourceRequest& request, const KURL&)
+{
+ // FIXME: look into the purpose of the unused KURL& originalURL parameter
+ if (m_internal) {
+ WrappedResourceRequest wrapped(request);
+ m_internal->m_outerHost->willStartSubResourceRequest(wrapped);
+ }
+ return false;
+}
+
+bool ApplicationCacheHost::maybeLoadFallbackForRedirect(ResourceLoader*, ResourceRequest&, const ResourceResponse&)
+{
+ // N/A to the chromium port
+ return false;
+}
+
+bool ApplicationCacheHost::maybeLoadFallbackForResponse(ResourceLoader*, const ResourceResponse&)
+{
+ // N/A to the chromium port
+ return false;
+}
+
+bool ApplicationCacheHost::maybeLoadFallbackForError(ResourceLoader*, const ResourceError&)
+{
+ // N/A to the chromium port
+ return false;
+}
+
+bool ApplicationCacheHost::maybeLoadSynchronously(ResourceRequest& request, ResourceError&, ResourceResponse&, Vector<char>&)
+{
+ if (m_internal) {
+ WrappedResourceRequest wrapped(request);
+ m_internal->m_outerHost->willStartSubResourceRequest(wrapped);
+ }
+ return false;
+}
+
+void ApplicationCacheHost::maybeLoadFallbackSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>&)
+{
+ // N/A to the chromium port
+}
+
+bool ApplicationCacheHost::canCacheInPageCache() const
+{
+ // N/A to the chromium port which doesn't use the page cache.
+ return false;
+}
+
+void ApplicationCacheHost::setDOMApplicationCache(DOMApplicationCache* domApplicationCache)
+{
+ ASSERT(!m_domApplicationCache || !domApplicationCache);
+ m_domApplicationCache = domApplicationCache;
+}
+
+void ApplicationCacheHost::notifyDOMApplicationCache(EventID id, int total, int done)
+{
+#if ENABLE(INSPECTOR)
+ if (id != PROGRESS_EVENT)
+ InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader->frame());
+#endif
+
+ if (m_defersEvents) {
+ // Event dispatching is deferred until document.onload has fired.
+ m_deferredEvents.append(DeferredEvent(id, total, done));
+ return;
+ }
+ dispatchDOMEvent(id, total, done);
+}
+
+#if ENABLE(INSPECTOR)
+ApplicationCacheHost::CacheInfo ApplicationCacheHost::applicationCacheInfo()
+{
+ if (!m_internal)
+ return CacheInfo(KURL(), 0, 0, 0);
+
+ WebKit::WebApplicationCacheHost::CacheInfo webInfo;
+ m_internal->m_outerHost->getAssociatedCacheInfo(&webInfo);
+ return CacheInfo(webInfo.manifestURL, webInfo.creationTime, webInfo.updateTime, webInfo.totalSize);
+}
+
+void ApplicationCacheHost::fillResourceList(ResourceInfoList* resources)
+{
+ if (!m_internal)
+ return;
+
+ WebKit::WebVector<WebKit::WebApplicationCacheHost::ResourceInfo> webResources;
+ m_internal->m_outerHost->getResourceList(&webResources);
+ for (size_t i = 0; i < webResources.size(); ++i) {
+ resources->append(ResourceInfo(
+ webResources[i].url, webResources[i].isMaster, webResources[i].isManifest, webResources[i].isFallback,
+ webResources[i].isForeign, webResources[i].isExplicit, webResources[i].size));
+ }
+}
+#endif
+
+void ApplicationCacheHost::stopDeferringEvents()
+{
+ RefPtr<DocumentLoader> protect(documentLoader());
+ for (unsigned i = 0; i < m_deferredEvents.size(); ++i) {
+ const DeferredEvent& deferred = m_deferredEvents[i];
+ dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.progressDone);
+ }
+ m_deferredEvents.clear();
+ m_defersEvents = false;
+}
+
+void ApplicationCacheHost::stopLoadingInFrame(Frame* frame)
+{
+ // FIXME: Implement this method.
+}
+
+void ApplicationCacheHost::dispatchDOMEvent(EventID id, int total, int done)
+{
+ if (m_domApplicationCache) {
+ const AtomicString& eventType = DOMApplicationCache::toEventType(id);
+ ExceptionCode ec = 0;
+ RefPtr<Event> event;
+ if (id == PROGRESS_EVENT)
+ event = ProgressEvent::create(eventType, true, done, total);
+ else
+ event = Event::create(eventType, false, false);
+ m_domApplicationCache->dispatchEvent(event, ec);
+ ASSERT(!ec);
+ }
+}
+
+ApplicationCacheHost::Status ApplicationCacheHost::status() const
+{
+ return m_internal ? static_cast<Status>(m_internal->m_outerHost->status()) : UNCACHED;
+}
+
+bool ApplicationCacheHost::update()
+{
+ return m_internal ? m_internal->m_outerHost->startUpdate() : false;
+}
+
+bool ApplicationCacheHost::swapCache()
+{
+ return m_internal ? m_internal->m_outerHost->swapCache() : false;
+}
+
+bool ApplicationCacheHost::isApplicationCacheEnabled()
+{
+ ASSERT(m_documentLoader->frame());
+ return m_documentLoader->frame()->settings()
+ && m_documentLoader->frame()->settings()->offlineWebApplicationCacheEnabled();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
diff --git a/Source/WebKit/chromium/src/ApplicationCacheHostInternal.h b/Source/WebKit/chromium/src/ApplicationCacheHostInternal.h
new file mode 100644
index 0000000..c88420b
--- /dev/null
+++ b/Source/WebKit/chromium/src/ApplicationCacheHostInternal.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ApplicationCacheHost.h"
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+
+#include "DocumentLoader.h"
+#include "WebApplicationCacheHostClient.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebURL.h"
+
+namespace WebCore {
+
+class ApplicationCacheHostInternal : public WebKit::WebApplicationCacheHostClient {
+public:
+ ApplicationCacheHostInternal(ApplicationCacheHost* host)
+ : m_innerHost(host)
+ {
+ WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(host->m_documentLoader->frame());
+ ASSERT(webFrame);
+ m_outerHost.set(webFrame->client()->createApplicationCacheHost(webFrame, this));
+ }
+
+ virtual void didChangeCacheAssociation()
+ {
+ // FIXME: Prod the inspector to update it's notion of what cache the page is using.
+ }
+
+ virtual void notifyEventListener(WebKit::WebApplicationCacheHost::EventID eventID)
+ {
+ m_innerHost->notifyDOMApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID), 0, 0);
+ }
+
+ virtual void notifyProgressEventListener(const WebKit::WebURL&, int progressTotal, int progressDone)
+ {
+ m_innerHost->notifyDOMApplicationCache(ApplicationCacheHost::PROGRESS_EVENT, progressTotal, progressDone);
+ }
+
+ static WebKit::WebApplicationCacheHost* toWebApplicationCacheHost(ApplicationCacheHost* innerHost)
+ {
+ if (innerHost && innerHost->m_internal.get())
+ return innerHost->m_internal->m_outerHost.get();
+ return 0;
+ }
+
+private:
+ friend class ApplicationCacheHost;
+ ApplicationCacheHost* m_innerHost;
+ OwnPtr<WebKit::WebApplicationCacheHost> m_outerHost;
+};
+
+}
+
+#endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
new file mode 100644
index 0000000..e89fb74
--- /dev/null
+++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
@@ -0,0 +1,414 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Use this file to assert that various WebKit API enum values continue
+// matching WebCore defined enum values.
+
+#include "config.h"
+
+#include "AccessibilityObject.h"
+#include "ApplicationCacheHost.h"
+#include "AsyncFileSystem.h"
+#include "EditorInsertAction.h"
+#include "FileError.h"
+#include "FileMetadata.h"
+#include "FontDescription.h"
+#include "FontSmoothingMode.h"
+#include "GeolocationError.h"
+#include "GeolocationPosition.h"
+#include "HTMLInputElement.h"
+#include "IDBKey.h"
+#include "MediaPlayer.h"
+#include "NotificationPresenter.h"
+#include "PasteboardPrivate.h"
+#include "PlatformCursor.h"
+#include "Settings.h"
+#include "TextAffinity.h"
+#include "UserContentTypes.h"
+#include "UserScriptTypes.h"
+#include "UserStyleSheetTypes.h"
+#include "VideoFrameChromium.h"
+#include "WebAccessibilityObject.h"
+#include "WebApplicationCacheHost.h"
+#include "WebClipboard.h"
+#include "WebCursorInfo.h"
+#include "WebEditingAction.h"
+#include "WebFileError.h"
+#include "WebFileInfo.h"
+#include "WebFileSystem.h"
+#include "WebFontDescription.h"
+#include "WebGeolocationError.h"
+#include "WebGeolocationPosition.h"
+#include "WebIDBKey.h"
+#include "WebInputElement.h"
+#include "WebMediaPlayer.h"
+#include "WebNotificationPresenter.h"
+#include "WebScrollbar.h"
+#include "WebSettings.h"
+#include "WebTextAffinity.h"
+#include "WebTextCaseSensitivity.h"
+#include "WebVideoFrame.h"
+#include "WebView.h"
+#include <wtf/Assertions.h>
+#include <wtf/text/StringImpl.h>
+
+#if OS(DARWIN)
+#include "PlatformBridge.h"
+#include "mac/WebThemeEngine.h"
+#endif
+
+#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \
+ COMPILE_ASSERT(int(WebKit::webkit_name) == int(WebCore::webcore_name), mismatching_enums)
+
+// These constants are in WTF, bring them into WebCore so the ASSERT still works for them!
+namespace WebCore {
+ using WTF::TextCaseSensitive;
+ using WTF::TextCaseInsensitive;
+};
+
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleUnknown, UnknownRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleButton, ButtonRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRadioButton, RadioButtonRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleCheckBox, CheckBoxRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSlider, SliderRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabGroup, TabGroupRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTextField, TextFieldRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleStaticText, StaticTextRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTextArea, TextAreaRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleScrollArea, ScrollAreaRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRolePopUpButton, PopUpButtonRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuButton, MenuButtonRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTable, TableRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplication, ApplicationRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleGroup, GroupRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRadioGroup, RadioGroupRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleList, ListRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleScrollBar, ScrollBarRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleValueIndicator, ValueIndicatorRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleImage, ImageRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuBar, MenuBarRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenu, MenuRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuItem, MenuItemRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleColumn, ColumnRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRow, RowRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleToolbar, ToolbarRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleBusyIndicator, BusyIndicatorRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleProgressIndicator, ProgressIndicatorRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWindow, WindowRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDrawer, DrawerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSystemWide, SystemWideRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleOutline, OutlineRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleIncrementor, IncrementorRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleBrowser, BrowserRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleComboBox, ComboBoxRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSplitGroup, SplitGroupRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSplitter, SplitterRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleColorWell, ColorWellRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleGrowArea, GrowAreaRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSheet, SheetRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleHelpTag, HelpTagRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMatte, MatteRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRuler, RulerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRulerMarker, RulerMarkerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLink, LinkRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDisclosureTriangle, DisclosureTriangleRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleGrid, GridRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleCell, CellRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleColumnHeader, ColumnHeaderRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleRowHeader, RowHeaderRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWebCoreLink, WebCoreLinkRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleImageMapLink, ImageMapLinkRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleImageMap, ImageMapRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListMarker, ListMarkerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWebArea, WebAreaRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleHeading, HeadingRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListBox, ListBoxRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListBoxOption, ListBoxOptionRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuListOption, MenuListOptionRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleMenuListPopup, MenuListPopupRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTableHeaderContainer, TableHeaderContainerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDefinitionListTerm, DefinitionListTermRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDefinitionListDefinition, DefinitionListDefinitionRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleAnnotation, AnnotationRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSliderThumb, SliderThumbRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleIgnored, IgnoredRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRolePresentational, PresentationalRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTab, TabRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabList, TabListRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTabPanel, TabPanelRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeRole, TreeRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeGrid, TreeGridRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleTreeItemRole, TreeItemRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDirectory, DirectoryRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleEditableText, EditableTextRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListItem, ListItemRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkApplication, LandmarkApplicationRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkBanner, LandmarkBannerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkComplementary, LandmarkComplementaryRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkContentInfo, LandmarkContentInfoRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkMain, LandmarkMainRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkNavigation, LandmarkNavigationRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLandmarkSearch, LandmarkSearchRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationAlert, ApplicationAlertRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationAlertDialog, ApplicationAlertDialogRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationDialog, ApplicationDialogRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationLog, ApplicationLogRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationMarquee, ApplicationMarqueeRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationStatus, ApplicationStatusRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleApplicationTimer, ApplicationTimerRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocument, DocumentRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentArticle, DocumentArticleRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentMath, DocumentMathRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentNote, DocumentNoteRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDocumentRegion, DocumentRegionRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleUserInterfaceTooltip, UserInterfaceTooltipRole);
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Uncached, ApplicationCacheHost::UNCACHED);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Idle, ApplicationCacheHost::IDLE);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Checking, ApplicationCacheHost::CHECKING);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Downloading, ApplicationCacheHost::DOWNLOADING);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::UpdateReady, ApplicationCacheHost::UPDATEREADY);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::Obsolete, ApplicationCacheHost::OBSOLETE);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::CheckingEvent, ApplicationCacheHost::CHECKING_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::ErrorEvent, ApplicationCacheHost::ERROR_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::NoUpdateEvent, ApplicationCacheHost::NOUPDATE_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::DownloadingEvent, ApplicationCacheHost::DOWNLOADING_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::ProgressEvent, ApplicationCacheHost::PROGRESS_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::UpdateReadyEvent, ApplicationCacheHost::UPDATEREADY_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::CachedEvent, ApplicationCacheHost::CACHED_EVENT);
+COMPILE_ASSERT_MATCHING_ENUM(WebApplicationCacheHost::ObsoleteEvent, ApplicationCacheHost::OBSOLETE_EVENT);
+#endif
+
+COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::FormatHTML, PasteboardPrivate::HTMLFormat);
+COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::FormatBookmark, PasteboardPrivate::BookmarkFormat);
+COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::FormatSmartPaste, PasteboardPrivate::WebSmartPasteFormat);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::BufferStandard, PasteboardPrivate::StandardBuffer);
+COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::BufferSelection, PasteboardPrivate::SelectionBuffer);
+COMPILE_ASSERT_MATCHING_ENUM(WebClipboard::BufferDrag, PasteboardPrivate::DragBuffer);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypePointer, PlatformCursor::TypePointer);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCross, PlatformCursor::TypeCross);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeHand, PlatformCursor::TypeHand);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeIBeam, PlatformCursor::TypeIBeam);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWait, PlatformCursor::TypeWait);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeHelp, PlatformCursor::TypeHelp);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastResize, PlatformCursor::TypeEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthResize, PlatformCursor::TypeNorthResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastResize, PlatformCursor::TypeNorthEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestResize, PlatformCursor::TypeNorthWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthResize, PlatformCursor::TypeSouthResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthEastResize, PlatformCursor::TypeSouthEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthWestResize, PlatformCursor::TypeSouthWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWestResize, PlatformCursor::TypeWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthSouthResize, PlatformCursor::TypeNorthSouthResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastWestResize, PlatformCursor::TypeEastWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastSouthWestResize, PlatformCursor::TypeNorthEastSouthWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestSouthEastResize, PlatformCursor::TypeNorthWestSouthEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeColumnResize, PlatformCursor::TypeColumnResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeRowResize, PlatformCursor::TypeRowResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeMiddlePanning, PlatformCursor::TypeMiddlePanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastPanning, PlatformCursor::TypeEastPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthPanning, PlatformCursor::TypeNorthPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastPanning, PlatformCursor::TypeNorthEastPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestPanning, PlatformCursor::TypeNorthWestPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthPanning, PlatformCursor::TypeSouthPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthEastPanning, PlatformCursor::TypeSouthEastPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthWestPanning, PlatformCursor::TypeSouthWestPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWestPanning, PlatformCursor::TypeWestPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeMove, PlatformCursor::TypeMove);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeVerticalText, PlatformCursor::TypeVerticalText);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCell, PlatformCursor::TypeCell);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeContextMenu, PlatformCursor::TypeContextMenu);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeAlias, PlatformCursor::TypeAlias);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeProgress, PlatformCursor::TypeProgress);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNoDrop, PlatformCursor::TypeNoDrop);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCopy, PlatformCursor::TypeCopy);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNone, PlatformCursor::TypeNone);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNotAllowed, PlatformCursor::TypeNotAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeZoomIn, PlatformCursor::TypeZoomIn);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeZoomOut, PlatformCursor::TypeZoomOut);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCustom, PlatformCursor::TypeCustom);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionTyped, EditorInsertActionTyped);
+COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionPasted, EditorInsertActionPasted);
+COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyNone, FontDescription::NoFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyStandard, FontDescription::StandardFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilySerif, FontDescription::SerifFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilySansSerif, FontDescription::SansSerifFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyMonospace, FontDescription::MonospaceFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyCursive, FontDescription::CursiveFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyFantasy, FontDescription::FantasyFamily);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingAuto, AutoSmoothing);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingNone, NoSmoothing);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingGrayscale, Antialiased);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingSubpixel, SubpixelAntialiased);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight100, FontWeight100);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight200, FontWeight200);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight300, FontWeight300);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight400, FontWeight400);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight500, FontWeight500);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight600, FontWeight600);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight700, FontWeight700);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight800, FontWeight800);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight900, FontWeight900);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::WeightNormal, FontWeightNormal);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::WeightBold, FontWeightBold);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::ElementNode, Node::ELEMENT_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::AttributeNode, Node::ATTRIBUTE_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::TextNode, Node::TEXT_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::CDataSectionNode, Node::CDATA_SECTION_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::EntityReferenceNode, Node::ENTITY_REFERENCE_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::EntityNode, Node::ENTITY_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::ProcessingInstructionsNode, Node::PROCESSING_INSTRUCTION_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::CommentNode, Node::COMMENT_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::DocumentNode, Node::DOCUMENT_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::DocumentTypeNode, Node::DOCUMENT_TYPE_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::DocumentFragmentNode, Node::DOCUMENT_FRAGMENT_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::NotationNode, Node::NOTATION_NODE);
+COMPILE_ASSERT_MATCHING_ENUM(WebNode::XPathNamespaceNode, Node::XPATH_NAMESPACE_NODE);
+
+#if ENABLE(VIDEO)
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Empty, MediaPlayer::Empty);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Idle, MediaPlayer::Idle);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Loading, MediaPlayer::Loading);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Loaded, MediaPlayer::Loaded);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::FormatError, MediaPlayer::FormatError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkError, MediaPlayer::NetworkError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::DecodeError, MediaPlayer::DecodeError);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveNothing, MediaPlayer::HaveNothing);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveMetadata, MediaPlayer::HaveMetadata);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveCurrentData, MediaPlayer::HaveCurrentData);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveFutureData, MediaPlayer::HaveFutureData);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::HaveEnoughData, MediaPlayer::HaveEnoughData);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Unknown, MediaPlayer::Unknown);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Download, MediaPlayer::Download);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::StoredStream, MediaPlayer::StoredStream);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::LiveStream, MediaPlayer::LiveStream);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatInvalid, VideoFrameChromium::Invalid);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatRGB555, VideoFrameChromium::RGB555);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatRGB565, VideoFrameChromium::RGB565);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatRGB24, VideoFrameChromium::RGB24);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatRGB32, VideoFrameChromium::RGB32);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatRGBA, VideoFrameChromium::RGBA);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatYV12, VideoFrameChromium::YV12);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatYV16, VideoFrameChromium::YV16);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatNV12, VideoFrameChromium::NV12);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatEmpty, VideoFrameChromium::Empty);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::FormatASCII, VideoFrameChromium::ASCII);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::SurfaceTypeSystemMemory, VideoFrameChromium::TypeSystemMemory);
+COMPILE_ASSERT_MATCHING_ENUM(WebVideoFrame::SurfaceTypeTexture, VideoFrameChromium::TypeTexture);
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionAllowed, NotificationPresenter::PermissionAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionNotAllowed, NotificationPresenter::PermissionNotAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionDenied, NotificationPresenter::PermissionDenied);
+#endif
+
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::Horizontal, HorizontalScrollbar);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::Vertical, VerticalScrollbar);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollByLine, ScrollByLine);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollByPage, ScrollByPage);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollByDocument, ScrollByDocument);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollByPixel, ScrollByPixel);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebSettings::EditingBehaviorMac, EditingMacBehavior);
+COMPILE_ASSERT_MATCHING_ENUM(WebSettings::EditingBehaviorWin, EditingWindowsBehavior);
+COMPILE_ASSERT_MATCHING_ENUM(WebSettings::EditingBehaviorUnix, EditingUnixBehavior);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityUpstream, UPSTREAM);
+COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityDownstream, DOWNSTREAM);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebTextCaseSensitive, TextCaseSensitive);
+COMPILE_ASSERT_MATCHING_ENUM(WebTextCaseInsensitive, TextCaseInsensitive);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserScriptInjectAtDocumentStart, InjectAtDocumentStart);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserScriptInjectAtDocumentEnd, InjectAtDocumentEnd);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInAllFrames, InjectInAllFrames);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInTopFrameOnly, InjectInTopFrameOnly);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserStyleInjectInExistingDocuments, InjectInExistingDocuments);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserStyleInjectInSubsequentDocuments, InjectInSubsequentDocuments);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NullType, IDBKey::NullType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::StringType, IDBKey::StringType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::DateType, IDBKey::DateType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NumberType, IDBKey::NumberType);
+
+#if ENABLE(FILE_SYSTEM)
+COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeTemporary, AsyncFileSystem::Temporary);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypePersistent, AsyncFileSystem::Persistent);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeUnknown, FileMetadata::TypeUnknown);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeFile, FileMetadata::TypeFile);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeDirectory, FileMetadata::TypeDirectory);
+#endif
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorNotFound, FileError::NOT_FOUND_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorSecurity, FileError::SECURITY_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorAbort, FileError::ABORT_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorNotReadable, FileError::NOT_READABLE_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorEncoding, FileError::ENCODING_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorNoModificationAllowed, FileError::NO_MODIFICATION_ALLOWED_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorInvalidState, FileError::INVALID_STATE_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorSyntax, FileError::SYNTAX_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorInvalidModification, FileError::INVALID_MODIFICATION_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorQuotaExceeded, FileError::QUOTA_EXCEEDED_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorTypeMismatch, FileError::TYPE_MISMATCH_ERR);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorPathExists, FileError::PATH_EXISTS_ERR);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPermissionDenied, GeolocationError::PermissionDenied);
+COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPositionUnavailable, GeolocationError::PositionUnavailable);
+
+#if OS(DARWIN)
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateDisabled, PlatformBridge::StateDisabled);
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateInactive, PlatformBridge::StateInactive);
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StateActive, PlatformBridge::StateActive);
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::StatePressed, PlatformBridge::StatePressed);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::SizeRegular, PlatformBridge::SizeRegular);
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::SizeSmall, PlatformBridge::SizeSmall);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarOrientationHorizontal, PlatformBridge::ScrollbarOrientationHorizontal);
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarOrientationVertical, PlatformBridge::ScrollbarOrientationVertical);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarParentScrollView, PlatformBridge::ScrollbarParentScrollView);
+COMPILE_ASSERT_MATCHING_ENUM(WebThemeEngine::ScrollbarParentRenderLayer, PlatformBridge::ScrollbarParentRenderLayer);
+#endif
diff --git a/Source/WebKit/chromium/src/AssociatedURLLoader.cpp b/Source/WebKit/chromium/src/AssociatedURLLoader.cpp
new file mode 100644
index 0000000..34a4055
--- /dev/null
+++ b/Source/WebKit/chromium/src/AssociatedURLLoader.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AssociatedURLLoader.h"
+
+#include "WebApplicationCacheHost.h"
+#include "WebDataSource.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebURLRequest.h"
+
+namespace WebKit {
+
+AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl)
+ : m_frameImpl(frameImpl),
+ m_realLoader(webKitClient()->createURLLoader()),
+ m_realClient(0)
+{
+}
+
+AssociatedURLLoader::~AssociatedURLLoader()
+{
+}
+
+void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURLResponse& response, WebURLError& error, WebData& data)
+{
+ ASSERT(!m_realClient);
+
+ WebURLRequest requestCopy(request);
+ prepareRequest(requestCopy);
+
+ m_realLoader->loadSynchronously(requestCopy, response, error, data);
+}
+
+void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client)
+{
+ ASSERT(!m_realClient);
+
+ WebURLRequest requestCopy(request);
+ prepareRequest(requestCopy);
+
+ m_realClient = client;
+ m_realLoader->loadAsynchronously(requestCopy, this);
+}
+
+void AssociatedURLLoader::cancel()
+{
+ m_realLoader->cancel();
+}
+
+void AssociatedURLLoader::setDefersLoading(bool defersLoading)
+{
+ m_realLoader->setDefersLoading(defersLoading);
+}
+
+void AssociatedURLLoader::prepareRequest(WebURLRequest& request)
+{
+ WebApplicationCacheHost* applicationCacheHost = m_frameImpl->dataSource()->applicationCacheHost();
+ if (applicationCacheHost)
+ applicationCacheHost->willStartSubResourceRequest(request);
+ m_frameImpl->dispatchWillSendRequest(request);
+}
+
+void AssociatedURLLoader::willSendRequest(WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse)
+{
+ m_realClient->willSendRequest(this, newRequest, redirectResponse);
+}
+
+void AssociatedURLLoader::didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+{
+ m_realClient->didSendData(this, bytesSent, totalBytesToBeSent);
+}
+
+void AssociatedURLLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
+{
+ m_realClient->didReceiveResponse(this, response);
+}
+
+void AssociatedURLLoader::didDownloadData(WebURLLoader*, int dataLength)
+{
+ m_realClient->didDownloadData(this, dataLength);
+}
+
+void AssociatedURLLoader::didReceiveData(WebURLLoader*, const char* data, int dataLength)
+{
+ m_realClient->didReceiveData(this, data, dataLength);
+}
+
+void AssociatedURLLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength)
+{
+ m_realClient->didReceiveCachedMetadata(this, data, dataLength);
+}
+
+void AssociatedURLLoader::didFinishLoading(WebURLLoader*, double finishTime)
+{
+ m_realClient->didFinishLoading(this, finishTime);
+}
+
+void AssociatedURLLoader::didFail(WebURLLoader*, const WebURLError& error)
+{
+ m_realClient->didFail(this, error);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/AssociatedURLLoader.h b/Source/WebKit/chromium/src/AssociatedURLLoader.h
new file mode 100644
index 0000000..91cb0bf
--- /dev/null
+++ b/Source/WebKit/chromium/src/AssociatedURLLoader.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AssociatedURLLoader_h
+#define AssociatedURLLoader_h
+
+#include "WebURLLoader.h"
+#include "WebURLLoaderClient.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class WebFrameImpl;
+
+// This class is used to implement WebFrame::createAssociatedURLLoader.
+// FIXME: Implement in terms of WebCore::SubresourceLoader.
+class AssociatedURLLoader : public WebURLLoader,
+ public WebURLLoaderClient {
+public:
+ AssociatedURLLoader(PassRefPtr<WebFrameImpl>);
+ ~AssociatedURLLoader();
+
+ // WebURLLoader methods:
+ virtual void loadSynchronously(const WebURLRequest&, WebURLResponse&, WebURLError&, WebData&);
+ virtual void loadAsynchronously(const WebURLRequest&, WebURLLoaderClient*);
+ virtual void cancel();
+ virtual void setDefersLoading(bool);
+
+ // WebURLLoaderClient methods:
+ virtual void willSendRequest(WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse);
+ virtual void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
+ virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&);
+ virtual void didDownloadData(WebURLLoader*, int dataLength);
+ virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength);
+ virtual void didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength);
+ virtual void didFinishLoading(WebURLLoader*, double finishTime);
+ virtual void didFail(WebURLLoader*, const WebURLError&);
+
+private:
+ void prepareRequest(WebURLRequest&);
+
+ RefPtr<WebFrameImpl> m_frameImpl;
+ OwnPtr<WebURLLoader> m_realLoader;
+ WebURLLoaderClient* m_realClient;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp
new file mode 100644
index 0000000..5975e72
--- /dev/null
+++ b/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "AsyncFileSystemChromium.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystemCallbacks.h"
+#include "AsyncFileWriterChromium.h"
+#include "WebFileInfo.h"
+#include "WebFileSystem.h"
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebFileWriter.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+bool AsyncFileSystem::isAvailable()
+{
+ return true;
+}
+
+AsyncFileSystemChromium::AsyncFileSystemChromium(const String& rootPath)
+ : AsyncFileSystem(rootPath)
+ , m_webFileSystem(WebKit::webKitClient()->fileSystem())
+{
+ ASSERT(m_webFileSystem);
+}
+
+AsyncFileSystemChromium::~AsyncFileSystemChromium()
+{
+}
+
+void AsyncFileSystemChromium::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->move(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->copy(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->remove(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->removeRecursively(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->readMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->createFile(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->createDirectory(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->fileExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+class FileWriterHelperCallbacks : public WebKit::WebFileSystemCallbacks {
+public:
+ FileWriterHelperCallbacks(AsyncFileWriterClient* client, const String& path, WebKit::WebFileSystem* webFileSystem, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks)
+ : m_client(client)
+ , m_path(path)
+ , m_webFileSystem(webFileSystem)
+ , m_callbacks(callbacks)
+ {
+ }
+
+ virtual void didSucceed()
+ {
+ ASSERT_NOT_REACHED();
+ delete this;
+ }
+ virtual void didReadMetadata(const WebKit::WebFileInfo& info)
+ {
+ ASSERT(m_callbacks);
+ if (info.type != WebKit::WebFileInfo::TypeFile || info.length < 0)
+ m_callbacks->didFail(WebKit::WebFileErrorInvalidState);
+ else {
+ OwnPtr<AsyncFileWriterChromium> asyncFileWriterChromium = adoptPtr(new AsyncFileWriterChromium(m_client));
+ OwnPtr<WebKit::WebFileWriter> webFileWriter = adoptPtr(m_webFileSystem->createFileWriter(m_path, asyncFileWriterChromium.get()));
+ asyncFileWriterChromium->setWebFileWriter(webFileWriter.release());
+ m_callbacks->didCreateFileWriter(asyncFileWriterChromium.release(), info.length);
+ }
+ delete this;
+ }
+
+ virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemEntry>& entries, bool hasMore)
+ {
+ ASSERT_NOT_REACHED();
+ delete this;
+ }
+ virtual void didOpenFileSystem(const WebKit::WebString& name, const WebKit::WebString& rootPath)
+ {
+ ASSERT_NOT_REACHED();
+ delete this;
+ }
+
+ virtual void didFail(WebKit::WebFileError error)
+ {
+ ASSERT(m_callbacks);
+ m_callbacks->didFail(error);
+ delete this;
+ }
+
+private:
+ AsyncFileWriterClient* m_client;
+ String m_path;
+ WebKit::WebFileSystem* m_webFileSystem;
+ OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
+};
+
+void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ m_webFileSystem->readMetadata(path, new FileWriterHelperCallbacks(client, path, m_webFileSystem, callbacks));
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebKit/chromium/src/AsyncFileSystemChromium.h b/Source/WebKit/chromium/src/AsyncFileSystemChromium.h
new file mode 100644
index 0000000..6205609
--- /dev/null
+++ b/Source/WebKit/chromium/src/AsyncFileSystemChromium.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AsyncFileSystemChromium_h
+#define AsyncFileSystemChromium_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystem.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+class WebFileSystem;
+}
+
+namespace WebCore {
+
+class AsyncFileSystemCallbacks;
+
+class AsyncFileSystemChromium : public AsyncFileSystem {
+public:
+ static PassOwnPtr<AsyncFileSystem> create(const String& rootPath)
+ {
+ return adoptPtr(new AsyncFileSystemChromium(rootPath));
+ }
+
+ virtual ~AsyncFileSystemChromium();
+
+ virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+
+private:
+ explicit AsyncFileSystemChromium(const String& rootPath);
+ WebKit::WebFileSystem* m_webFileSystem;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // AsyncFileSystemChromium_h
diff --git a/Source/WebKit/chromium/src/AsyncFileWriterChromium.cpp b/Source/WebKit/chromium/src/AsyncFileWriterChromium.cpp
new file mode 100644
index 0000000..71cf3b5
--- /dev/null
+++ b/Source/WebKit/chromium/src/AsyncFileWriterChromium.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AsyncFileWriterChromium.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileWriterClient.h"
+#include "Blob.h"
+#include "WebFileWriter.h"
+#include "WebURL.h"
+
+namespace WebCore {
+
+AsyncFileWriterChromium::AsyncFileWriterChromium(AsyncFileWriterClient* client)
+ : m_client(client)
+{
+}
+
+AsyncFileWriterChromium::~AsyncFileWriterChromium()
+{
+}
+
+void AsyncFileWriterChromium::setWebFileWriter(PassOwnPtr<WebKit::WebFileWriter> writer)
+{
+ m_writer = writer;
+}
+
+void AsyncFileWriterChromium::write(long long position, Blob* data)
+{
+ ASSERT(m_writer);
+ m_writer->write(position, WebKit::WebURL(data->url()));
+}
+
+void AsyncFileWriterChromium::truncate(long long length)
+{
+ ASSERT(m_writer);
+ m_writer->truncate(length);
+}
+
+void AsyncFileWriterChromium::abort()
+{
+ ASSERT(m_writer);
+ m_writer->cancel();
+}
+
+void AsyncFileWriterChromium::didWrite(long long bytes, bool complete)
+{
+ ASSERT(m_writer);
+ m_client->didWrite(bytes, complete);
+}
+
+void AsyncFileWriterChromium::didTruncate()
+{
+ m_client->didTruncate();
+}
+
+void AsyncFileWriterChromium::didFail(WebKit::WebFileError error)
+{
+ m_client->didFail(static_cast<FileError::ErrorCode>(error));
+}
+
+} // namespace
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/AsyncFileWriterChromium.h b/Source/WebKit/chromium/src/AsyncFileWriterChromium.h
new file mode 100644
index 0000000..71a2f18
--- /dev/null
+++ b/Source/WebKit/chromium/src/AsyncFileWriterChromium.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AsyncFileWriterChromium_h
+#define AsyncFileWriterChromium_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileWriter.h"
+#include "WebFileError.h"
+#include "WebFileWriterClient.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+class WebFileWriter;
+}
+
+namespace WebCore {
+
+class Blob;
+class AsyncFileWriterClient;
+
+class AsyncFileWriterChromium : public AsyncFileWriter, public WebKit::WebFileWriterClient {
+public:
+ AsyncFileWriterChromium(AsyncFileWriterClient* client);
+ ~AsyncFileWriterChromium();
+
+ void setWebFileWriter(PassOwnPtr<WebKit::WebFileWriter> writer);
+
+ // FileWriter
+ virtual void write(long long position, Blob* data);
+ virtual void truncate(long long length);
+ virtual void abort();
+
+ // WebFileWriterClient
+ virtual void didWrite(long long bytes, bool complete);
+ virtual void didTruncate();
+ virtual void didFail(WebKit::WebFileError);
+
+private:
+ OwnPtr<WebKit::WebFileWriter> m_writer;
+ AsyncFileWriterClient* m_client;
+};
+
+} // namespace
+
+#endif // ENABLE(FILE_SYSTEM)
+
+#endif // AsyncFileWriterChromium_h
diff --git a/Source/WebKit/chromium/src/AudioDestinationChromium.cpp b/Source/WebKit/chromium/src/AudioDestinationChromium.cpp
new file mode 100644
index 0000000..bed2562
--- /dev/null
+++ b/Source/WebKit/chromium/src/AudioDestinationChromium.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AudioDestinationChromium.h"
+
+#include "AudioSourceProvider.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+// Buffer size that the Chromium audio system will call us back with.
+// This value may need to be tuned based on the OS.
+// FIXME: It may be possible to reduce this value once real-time threads
+// and other Chromium audio improvements are made.
+const unsigned callbackBufferSize = 2048;
+
+// Buffer size at which the web audio engine will render.
+const unsigned renderBufferSize = 128;
+
+const unsigned renderCountPerCallback = callbackBufferSize / renderBufferSize;
+
+// FIXME: add support for multi-channel.
+const unsigned numberOfChannels = 2;
+
+// Factory method: Chromium-implementation
+PassOwnPtr<AudioDestination> AudioDestination::create(AudioSourceProvider& provider, double sampleRate)
+{
+ return adoptPtr(new AudioDestinationChromium(provider, sampleRate));
+}
+
+AudioDestinationChromium::AudioDestinationChromium(AudioSourceProvider& provider, double sampleRate)
+ : m_provider(provider)
+ , m_renderBus(numberOfChannels, renderBufferSize, false)
+ , m_sampleRate(sampleRate)
+ , m_isPlaying(false)
+{
+ m_audioDevice = adoptPtr(webKitClient()->createAudioDevice(callbackBufferSize, numberOfChannels, sampleRate, this));
+ ASSERT(m_audioDevice.get());
+}
+
+AudioDestinationChromium::~AudioDestinationChromium()
+{
+ stop();
+}
+
+void AudioDestinationChromium::start()
+{
+ if (!m_isPlaying && m_audioDevice.get()) {
+ m_audioDevice->start();
+ m_isPlaying = true;
+ }
+}
+
+void AudioDestinationChromium::stop()
+{
+ if (m_isPlaying && m_audioDevice.get()) {
+ m_audioDevice->stop();
+ m_isPlaying = false;
+ }
+}
+
+double AudioDestination::hardwareSampleRate()
+{
+ // FIXME: implement this properly for Chromium.
+ return 44100.0;
+}
+
+// Pulls on our provider to get the rendered audio stream.
+void AudioDestinationChromium::render(const WebVector<float*>& audioData, size_t numberOfFrames)
+{
+ bool isNumberOfChannelsGood = audioData.size() == numberOfChannels;
+ if (!isNumberOfChannelsGood) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ bool isBufferSizeGood = numberOfFrames == callbackBufferSize;
+ if (!isBufferSizeGood) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ // Split up the callback buffer into smaller chunks which we'll render one after the other.
+ for (unsigned i = 0; i < renderCountPerCallback; ++i) {
+ m_renderBus.setChannelMemory(0, audioData[0] + i * renderBufferSize, renderBufferSize);
+ m_renderBus.setChannelMemory(1, audioData[1] + i * renderBufferSize, renderBufferSize);
+ m_provider.provideInput(&m_renderBus, renderBufferSize);
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/WebKit/chromium/src/AudioDestinationChromium.h b/Source/WebKit/chromium/src/AudioDestinationChromium.h
new file mode 100644
index 0000000..a2a2b58
--- /dev/null
+++ b/Source/WebKit/chromium/src/AudioDestinationChromium.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AudioDestinationChromium_h
+#define AudioDestinationChromium_h
+
+#include "AudioBus.h"
+#include "AudioDestination.h"
+#include "WebAudioDevice.h"
+#include "WebVector.h"
+
+namespace WebKit { class WebAudioDevice; }
+
+namespace WebCore {
+
+// An AudioDestination using Chromium's audio system
+
+class AudioDestinationChromium : public AudioDestination, public WebKit::WebAudioDevice::RenderCallback {
+public:
+ AudioDestinationChromium(AudioSourceProvider&, double sampleRate);
+ virtual ~AudioDestinationChromium();
+
+ virtual void start();
+ virtual void stop();
+ bool isPlaying() { return m_isPlaying; }
+
+ double sampleRate() const { return m_sampleRate; }
+
+ // WebKit::WebAudioDevice::RenderCallback
+ virtual void render(const WebKit::WebVector<float*>& audioData, size_t numberOfFrames);
+
+private:
+ AudioSourceProvider& m_provider;
+ AudioBus m_renderBus;
+ double m_sampleRate;
+ bool m_isPlaying;
+ OwnPtr<WebKit::WebAudioDevice> m_audioDevice;
+};
+
+} // namespace WebCore
+
+#endif // AudioDestinationChromium_h
diff --git a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
new file mode 100644
index 0000000..2ce31a9
--- /dev/null
+++ b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
@@ -0,0 +1,376 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AutoFillPopupMenuClient.h"
+
+#include "CSSStyleSelector.h"
+#include "CSSValueKeywords.h"
+#include "Chrome.h"
+#include "FrameView.h"
+#include "HTMLInputElement.h"
+#include "RenderTheme.h"
+#include "WebAutoFillClient.h"
+#include "WebNode.h"
+#include "WebString.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+AutoFillPopupMenuClient::AutoFillPopupMenuClient()
+ : m_separatorIndex(-1)
+ , m_selectedIndex(-1)
+ , m_textField(0)
+{
+}
+
+AutoFillPopupMenuClient::~AutoFillPopupMenuClient()
+{
+}
+
+unsigned AutoFillPopupMenuClient::getSuggestionsCount() const
+{
+ return m_names.size() + ((m_separatorIndex == -1) ? 0 : 1);
+}
+
+WebString AutoFillPopupMenuClient::getSuggestion(unsigned listIndex) const
+{
+ int index = convertListIndexToInternalIndex(listIndex);
+ if (index == -1)
+ return WebString();
+
+ ASSERT(index >= 0 && static_cast<size_t>(index) < m_names.size());
+ return m_names[index];
+}
+
+WebString AutoFillPopupMenuClient::getLabel(unsigned listIndex) const
+{
+ int index = convertListIndexToInternalIndex(listIndex);
+ if (index == -1)
+ return WebString();
+
+ ASSERT(index >= 0 && static_cast<size_t>(index) < m_labels.size());
+ return m_labels[index];
+}
+
+WebString AutoFillPopupMenuClient::getIcon(unsigned listIndex) const
+{
+ int index = convertListIndexToInternalIndex(listIndex);
+ if (index == -1)
+ return WebString();
+
+ ASSERT(index >= 0 && static_cast<size_t>(index) < m_icons.size());
+ return m_icons[index];
+}
+
+void AutoFillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex)
+{
+ if (!canRemoveSuggestionAtIndex(listIndex))
+ return;
+
+ int index = convertListIndexToInternalIndex(listIndex);
+
+ ASSERT(static_cast<unsigned>(index) < m_names.size());
+
+ m_names.remove(index);
+ m_labels.remove(index);
+ m_icons.remove(index);
+ m_uniqueIDs.remove(index);
+
+ // Shift the separator index if necessary.
+ if (m_separatorIndex != -1)
+ m_separatorIndex--;
+}
+
+bool AutoFillPopupMenuClient::canRemoveSuggestionAtIndex(unsigned listIndex)
+{
+ // Only allow deletion of items before the separator that have unique id 0
+ // (i.e. are autocomplete rather than autofill items).
+ int index = convertListIndexToInternalIndex(listIndex);
+ return !m_uniqueIDs[index] && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex));
+}
+
+void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
+{
+ WebViewImpl* webView = getWebView();
+ if (!webView)
+ return;
+
+ if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex))
+ --listIndex;
+
+ ASSERT(listIndex < m_names.size());
+
+ webView->autoFillClient()->didAcceptAutoFillSuggestion(WebNode(getTextField()),
+ m_names[listIndex],
+ m_labels[listIndex],
+ m_uniqueIDs[listIndex],
+ listIndex);
+}
+
+void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
+{
+ WebViewImpl* webView = getWebView();
+ if (!webView)
+ return;
+
+ if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex))
+ --listIndex;
+
+ ASSERT(listIndex < m_names.size());
+
+ webView->autoFillClient()->didSelectAutoFillSuggestion(WebNode(getTextField()),
+ m_names[listIndex],
+ m_labels[listIndex],
+ m_uniqueIDs[listIndex]);
+}
+
+void AutoFillPopupMenuClient::selectionCleared()
+{
+ WebViewImpl* webView = getWebView();
+ if (webView)
+ webView->autoFillClient()->didClearAutoFillSelection(WebNode(getTextField()));
+}
+
+String AutoFillPopupMenuClient::itemText(unsigned listIndex) const
+{
+ return getSuggestion(listIndex);
+}
+
+String AutoFillPopupMenuClient::itemLabel(unsigned listIndex) const
+{
+ return getLabel(listIndex);
+}
+
+String AutoFillPopupMenuClient::itemIcon(unsigned listIndex) const
+{
+ return getIcon(listIndex);
+}
+
+bool AutoFillPopupMenuClient::itemIsEnabled(unsigned listIndex) const
+{
+ return !itemIsWarning(listIndex);
+}
+
+PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const
+{
+ return itemIsWarning(listIndex) ? *m_warningStyle : *m_regularStyle;
+}
+
+PopupMenuStyle AutoFillPopupMenuClient::menuStyle() const
+{
+ return *m_regularStyle;
+}
+
+int AutoFillPopupMenuClient::clientPaddingLeft() const
+{
+ // Bug http://crbug.com/7708 seems to indicate the style can be 0.
+ RenderStyle* style = textFieldStyle();
+ if (!style)
+ return 0;
+
+ return RenderTheme::defaultTheme()->popupInternalPaddingLeft(style);
+}
+
+int AutoFillPopupMenuClient::clientPaddingRight() const
+{
+ // Bug http://crbug.com/7708 seems to indicate the style can be 0.
+ RenderStyle* style = textFieldStyle();
+ if (!style)
+ return 0;
+
+ return RenderTheme::defaultTheme()->popupInternalPaddingRight(style);
+}
+
+void AutoFillPopupMenuClient::popupDidHide()
+{
+ WebViewImpl* webView = getWebView();
+ if (!webView)
+ return;
+
+ webView->autoFillPopupDidHide();
+ webView->autoFillClient()->didClearAutoFillSelection(WebNode(getTextField()));
+}
+
+bool AutoFillPopupMenuClient::itemIsSeparator(unsigned listIndex) const
+{
+ return (m_separatorIndex != -1 && static_cast<unsigned>(m_separatorIndex) == listIndex);
+}
+
+bool AutoFillPopupMenuClient::itemIsWarning(unsigned listIndex) const
+{
+ int index = convertListIndexToInternalIndex(listIndex);
+ if (index == -1)
+ return false;
+
+ ASSERT(index >= 0 && static_cast<size_t>(index) < m_uniqueIDs.size());
+ return m_uniqueIDs[index] < 0;
+}
+
+void AutoFillPopupMenuClient::setTextFromItem(unsigned listIndex)
+{
+ m_textField->setValue(getSuggestion(listIndex));
+}
+
+FontSelector* AutoFillPopupMenuClient::fontSelector() const
+{
+ return m_textField->document()->styleSelector()->fontSelector();
+}
+
+HostWindow* AutoFillPopupMenuClient::hostWindow() const
+{
+ return m_textField->document()->view()->hostWindow();
+}
+
+PassRefPtr<Scrollbar> AutoFillPopupMenuClient::createScrollbar(
+ ScrollableArea* scrollableArea,
+ ScrollbarOrientation orientation,
+ ScrollbarControlSize size)
+{
+ return Scrollbar::createNativeScrollbar(scrollableArea, orientation, size);
+}
+
+void AutoFillPopupMenuClient::initialize(
+ HTMLInputElement* textField,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& uniqueIDs,
+ int separatorIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == icons.size());
+ ASSERT(names.size() == uniqueIDs.size());
+ ASSERT(separatorIndex < static_cast<int>(names.size()));
+
+ m_selectedIndex = -1;
+ m_textField = textField;
+
+ // The suggestions must be set before initializing the
+ // AutoFillPopupMenuClient.
+ setSuggestions(names, labels, icons, uniqueIDs, separatorIndex);
+
+ FontDescription regularFontDescription;
+ RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl,
+ regularFontDescription);
+ RenderStyle* style = m_textField->computedStyle();
+ regularFontDescription.setComputedSize(style->fontDescription().computedSize());
+
+ Font regularFont(regularFontDescription, 0, 0);
+ regularFont.update(textField->document()->styleSelector()->fontSelector());
+ // The direction of text in popup menu is set the same as the direction of
+ // the input element: textField.
+ m_regularStyle.set(new PopupMenuStyle(Color::black, Color::white, regularFont,
+ true, false, Length(WebCore::Fixed),
+ textField->renderer()->style()->direction()));
+
+ FontDescription warningFontDescription = regularFont.fontDescription();
+ warningFontDescription.setItalic(true);
+ Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing());
+ warningFont.update(regularFont.fontSelector());
+ m_warningStyle.set(new PopupMenuStyle(Color::darkGray,
+ m_regularStyle->backgroundColor(),
+ warningFont,
+ m_regularStyle->isVisible(),
+ m_regularStyle->isDisplayNone(),
+ m_regularStyle->textIndent(),
+ m_regularStyle->textDirection()));
+}
+
+void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& uniqueIDs,
+ int separatorIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == icons.size());
+ ASSERT(names.size() == uniqueIDs.size());
+ ASSERT(separatorIndex < static_cast<int>(names.size()));
+
+ m_names.clear();
+ m_labels.clear();
+ m_icons.clear();
+ m_uniqueIDs.clear();
+ for (size_t i = 0; i < names.size(); ++i) {
+ m_names.append(names[i]);
+ m_labels.append(labels[i]);
+ m_icons.append(icons[i]);
+ m_uniqueIDs.append(uniqueIDs[i]);
+ }
+
+ m_separatorIndex = separatorIndex;
+
+ // Try to preserve selection if possible.
+ if (getSelectedIndex() >= static_cast<int>(names.size()))
+ setSelectedIndex(-1);
+}
+
+int AutoFillPopupMenuClient::convertListIndexToInternalIndex(unsigned listIndex) const
+{
+ if (listIndex == static_cast<unsigned>(m_separatorIndex))
+ return -1;
+
+ if (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex))
+ return listIndex;
+ return listIndex - 1;
+}
+
+WebViewImpl* AutoFillPopupMenuClient::getWebView() const
+{
+ Frame* frame = m_textField->document()->frame();
+ if (!frame)
+ return 0;
+
+ Page* page = frame->page();
+ if (!page)
+ return 0;
+
+ return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView();
+}
+
+RenderStyle* AutoFillPopupMenuClient::textFieldStyle() const
+{
+ RenderStyle* style = m_textField->computedStyle();
+ if (!style) {
+ // It seems we can only have a 0 style in a TextField if the
+ // node is detached, in which case we the popup should not be
+ // showing. Please report this in http://crbug.com/7708 and
+ // include the page you were visiting.
+ ASSERT_NOT_REACHED();
+ }
+ return style;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h
new file mode 100644
index 0000000..0071121
--- /dev/null
+++ b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AutoFillPopupMenuClient_h
+#define AutoFillPopupMenuClient_h
+
+#include "PopupMenuClient.h"
+
+namespace WebCore {
+class HTMLInputElement;
+class PopupMenuStyle;
+class RenderStyle;
+}
+
+namespace WebKit {
+class WebString;
+class WebViewImpl;
+template <typename T> class WebVector;
+
+// The AutoFill suggestions popup menu client, used to display name suggestions
+// with right-justified labels.
+class AutoFillPopupMenuClient : public WebCore::PopupMenuClient {
+public:
+ AutoFillPopupMenuClient();
+ virtual ~AutoFillPopupMenuClient();
+
+ // Returns the number of suggestions available.
+ virtual unsigned getSuggestionsCount() const;
+
+ // Returns the suggestion at |listIndex|.
+ virtual WebString getSuggestion(unsigned listIndex) const;
+
+ // Returns the label at |listIndex|.
+ virtual WebString getLabel(unsigned listIndex) const;
+
+ // Returns the icon at |listIndex|.
+ virtual WebString getIcon(unsigned listIndex) const;
+
+ // Removes the suggestion at |listIndex| from the list of suggestions.
+ virtual void removeSuggestionAtIndex(unsigned listIndex);
+
+ // Returns true if the suggestion at |listIndex| can be removed.
+ bool canRemoveSuggestionAtIndex(unsigned listIndex);
+
+ // WebCore::PopupMenuClient methods:
+ virtual void valueChanged(unsigned listIndex, bool fireEvents = true);
+ virtual void selectionChanged(unsigned, bool);
+ virtual void selectionCleared();
+ virtual WTF::String itemText(unsigned listIndex) const;
+ virtual WTF::String itemLabel(unsigned listIndex) const;
+ virtual WTF::String itemIcon(unsigned listIndex) const;
+ virtual WTF::String itemToolTip(unsigned lastIndex) const { return WTF::String(); }
+ virtual WTF::String itemAccessibilityText(unsigned lastIndex) const { return WTF::String(); }
+ virtual bool itemIsEnabled(unsigned listIndex) const;
+ virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const;
+ virtual WebCore::PopupMenuStyle menuStyle() const;
+ virtual int clientInsetLeft() const { return 0; }
+ virtual int clientInsetRight() const { return 0; }
+ virtual int clientPaddingLeft() const;
+ virtual int clientPaddingRight() const;
+ virtual int listSize() const { return getSuggestionsCount(); }
+ virtual int selectedIndex() const { return m_selectedIndex; }
+ virtual void popupDidHide();
+ virtual bool itemIsSeparator(unsigned listIndex) const;
+ virtual bool itemIsLabel(unsigned listIndex) const { return false; }
+ virtual bool itemIsSelected(unsigned listIndex) const { return false; }
+ virtual bool shouldPopOver() const { return false; }
+ virtual bool valueShouldChangeOnHotTrack() const { return false; }
+ virtual void setTextFromItem(unsigned listIndex);
+ virtual WebCore::FontSelector* fontSelector() const;
+ virtual WebCore::HostWindow* hostWindow() const;
+ virtual PassRefPtr<WebCore::Scrollbar> createScrollbar(
+ WebCore::ScrollableArea* client,
+ WebCore::ScrollbarOrientation orientation,
+ WebCore::ScrollbarControlSize size);
+
+ void initialize(WebCore::HTMLInputElement*,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& uniqueIDs,
+ int separatorIndex);
+
+ void setSuggestions(const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& uniqueIDs,
+ int separatorIndex);
+
+private:
+ // Convert the specified index from an index into the visible list (which might
+ // include a separator entry) to an index to |m_names| and |m_labels|.
+ // Returns -1 if the given index points to the separator.
+ int convertListIndexToInternalIndex(unsigned) const;
+ WebViewImpl* getWebView() const;
+ WebCore::HTMLInputElement* getTextField() const { return m_textField.get(); }
+ WebCore::RenderStyle* textFieldStyle() const;
+
+ int getSelectedIndex() const { return m_selectedIndex; }
+ void setSelectedIndex(int index) { m_selectedIndex = index; }
+
+ bool itemIsWarning(unsigned listIndex) const;
+
+ // The names, labels and icons that make up the contents of the menu items.
+ Vector<WTF::String> m_names;
+ Vector<WTF::String> m_labels;
+ Vector<WTF::String> m_icons;
+ Vector<int> m_uniqueIDs;
+
+ // The index of the separator. -1 if there is no separator.
+ int m_separatorIndex;
+
+ // The index of the selected item. -1 if there is no selected item.
+ int m_selectedIndex;
+
+ RefPtr<WebCore::HTMLInputElement> m_textField;
+ OwnPtr<WebCore::PopupMenuStyle> m_regularStyle;
+ OwnPtr<WebCore::PopupMenuStyle> m_warningStyle;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/BackForwardListChromium.cpp b/Source/WebKit/chromium/src/BackForwardListChromium.cpp
new file mode 100644
index 0000000..be2a72b
--- /dev/null
+++ b/Source/WebKit/chromium/src/BackForwardListChromium.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BackForwardListChromium.h"
+
+#include "HistoryItem.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include <wtf/text/StringConcatenate.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const char backForwardNavigationScheme[] = "chrome-back-forward";
+
+PassRefPtr<BackForwardListChromium> BackForwardListChromium::create(WebViewImpl* webView)
+{
+ return adoptRef(new BackForwardListChromium(webView));
+}
+
+BackForwardListChromium::BackForwardListChromium(WebViewImpl* webView)
+ : m_webView(webView)
+{
+}
+
+BackForwardListChromium::~BackForwardListChromium()
+{
+}
+
+void BackForwardListChromium::addItem(PassRefPtr<HistoryItem> item)
+{
+ m_currentItem = item;
+
+ // If WebCore adds a new HistoryItem, it means this is a new navigation (ie,
+ // not a reload or back/forward).
+ m_webView->observeNewNavigation();
+
+ if (m_webView->client())
+ m_webView->client()->didAddHistoryItem();
+}
+
+void BackForwardListChromium::goToItem(HistoryItem* item)
+{
+ m_currentItem = item;
+
+ if (m_pendingHistoryItem == item)
+ m_pendingHistoryItem = 0;
+}
+
+HistoryItem* BackForwardListChromium::itemAtIndex(int index)
+{
+ if (!m_webView->client())
+ return 0;
+
+ if (!index)
+ return m_currentItem.get();
+
+ if (index > forwardListCount() || -index > backListCount())
+ return 0;
+
+ // Since we don't keep the entire back/forward list, we have no way to
+ // properly implement this method. We return a dummy entry instead that we
+ // intercept in our FrameLoaderClient implementation in case WebCore asks
+ // to navigate to this HistoryItem.
+
+ // FIXME: We should change WebCore to handle history.{back,forward,go}
+ // differently. It should perhaps just ask the FrameLoaderClient to
+ // perform those navigations.
+
+ String urlString = makeString(backForwardNavigationScheme, "://go/", String::number(index));
+ m_pendingHistoryItem = HistoryItem::create(urlString, String(), 0);
+ return m_pendingHistoryItem.get();
+}
+
+int BackForwardListChromium::backListCount()
+{
+ if (!m_webView->client())
+ return 0;
+
+ return m_webView->client()->historyBackListCount();
+}
+
+int BackForwardListChromium::forwardListCount()
+{
+ if (!m_webView->client())
+ return 0;
+
+ return m_webView->client()->historyForwardListCount();
+}
+
+bool BackForwardListChromium::isActive()
+{
+ return m_webView->client();
+}
+
+void BackForwardListChromium::close()
+{
+ m_currentItem = 0;
+ m_pendingHistoryItem = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/BackForwardListChromium.h b/Source/WebKit/chromium/src/BackForwardListChromium.h
new file mode 100644
index 0000000..c8f6f15
--- /dev/null
+++ b/Source/WebKit/chromium/src/BackForwardListChromium.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BackForwardListChromium_h
+#define BackForwardListChromium_h
+
+#include "BackForwardList.h"
+#include "HistoryItem.h"
+
+namespace WebKit {
+class WebViewImpl;
+
+extern const char backForwardNavigationScheme[];
+
+class BackForwardListChromium : public WebCore::BackForwardList {
+public:
+ static PassRefPtr<BackForwardListChromium> create(WebViewImpl*);
+ virtual ~BackForwardListChromium();
+
+private:
+ BackForwardListChromium(WebViewImpl*);
+
+ // WebCore::BackForwardList methods:
+ virtual void addItem(PassRefPtr<WebCore::HistoryItem>);
+ virtual void goToItem(WebCore::HistoryItem*);
+ virtual WebCore::HistoryItem* itemAtIndex(int index);
+ virtual int backListCount();
+ virtual int forwardListCount();
+ virtual bool isActive();
+ virtual void close();
+
+ WebViewImpl* m_webView;
+
+ RefPtr<WebCore::HistoryItem> m_currentItem;
+
+ // The last history item that was accessed via itemAtIndex(). We keep track
+ // of this until goToItem() is called, so we can track the navigation.
+ RefPtr<WebCore::HistoryItem> m_pendingHistoryItem;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/BlobRegistryProxy.cpp b/Source/WebKit/chromium/src/BlobRegistryProxy.cpp
new file mode 100644
index 0000000..84fcb4d
--- /dev/null
+++ b/Source/WebKit/chromium/src/BlobRegistryProxy.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(BLOB)
+
+#include "BlobRegistryProxy.h"
+
+#include "BlobData.h"
+#include "KURL.h"
+#include "ResourceHandle.h"
+#include "WebBlobData.h"
+#include "WebBlobRegistry.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebURL.h"
+#include <wtf/MainThread.h>
+#include <wtf/StdLibExtras.h>
+
+// We are part of the WebKit implementation.
+using namespace WebKit;
+
+namespace WebCore {
+
+BlobRegistry& blobRegistry()
+{
+ ASSERT(isMainThread());
+ DEFINE_STATIC_LOCAL(BlobRegistryProxy, instance, ());
+ return instance;
+}
+
+BlobRegistryProxy::BlobRegistryProxy()
+ : m_webBlobRegistry(WebKit::webKitClient()->blobRegistry())
+{
+}
+
+void BlobRegistryProxy::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> blobData)
+{
+ if (m_webBlobRegistry) {
+ WebBlobData webBlobData(blobData);
+ m_webBlobRegistry->registerBlobURL(url, webBlobData);
+ }
+}
+
+void BlobRegistryProxy::registerBlobURL(const KURL& url, const KURL& srcURL)
+{
+ if (m_webBlobRegistry)
+ m_webBlobRegistry->registerBlobURL(url, srcURL);
+}
+
+void BlobRegistryProxy::unregisterBlobURL(const KURL& url)
+{
+ if (m_webBlobRegistry)
+ m_webBlobRegistry->unregisterBlobURL(url);
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebKit/chromium/src/BlobRegistryProxy.h b/Source/WebKit/chromium/src/BlobRegistryProxy.h
new file mode 100644
index 0000000..6f2ebb2
--- /dev/null
+++ b/Source/WebKit/chromium/src/BlobRegistryProxy.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BlobRegistryProxy_h
+#define BlobRegistryProxy_h
+
+#if ENABLE(BLOB)
+
+#include "BlobRegistry.h"
+
+namespace WebKit { class WebBlobRegistry; }
+
+namespace WebCore {
+
+class BlobRegistryProxy : public BlobRegistry {
+public:
+ BlobRegistryProxy();
+
+ virtual void registerBlobURL(const KURL&, PassOwnPtr<BlobData>);
+ virtual void registerBlobURL(const KURL&, const KURL& srcURL);
+ virtual void unregisterBlobURL(const KURL&);
+
+ virtual PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*) { return 0; }
+ virtual bool loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data) { return false; }
+
+private:
+ virtual ~BlobRegistryProxy() { }
+
+ WebKit::WebBlobRegistry* m_webBlobRegistry;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(BLOB)
+
+#endif // BlobRegistryProxy_h
diff --git a/Source/WebKit/chromium/src/BoundObject.cpp b/Source/WebKit/chromium/src/BoundObject.cpp
new file mode 100644
index 0000000..90096c2
--- /dev/null
+++ b/Source/WebKit/chromium/src/BoundObject.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BoundObject.h"
+
+#include "V8Proxy.h"
+
+namespace WebKit {
+
+BoundObject::BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName)
+ : m_objectName(objectName)
+ , m_context(context)
+ , m_v8This(v8This)
+{
+ v8::Context::Scope contextScope(context);
+ v8::Local<v8::FunctionTemplate> localTemplate = v8::FunctionTemplate::New(WebCore::V8Proxy::checkNewLegal);
+ m_hostTemplate = v8::Persistent<v8::FunctionTemplate>::New(localTemplate);
+ m_hostTemplate->SetClassName(v8::String::New(objectName));
+}
+
+BoundObject::~BoundObject()
+{
+ m_hostTemplate.Dispose();
+}
+
+void BoundObject::addProtoFunction(const char* name, v8::InvocationCallback callback)
+{
+ v8::Context::Scope contextScope(m_context);
+ v8::Local<v8::Signature> signature = v8::Signature::New(m_hostTemplate);
+ v8::Local<v8::ObjectTemplate> proto = m_hostTemplate->PrototypeTemplate();
+ v8::Local<v8::External> v8This = v8::External::New(m_v8This);
+ proto->Set(
+ v8::String::New(name),
+ v8::FunctionTemplate::New(
+ callback,
+ v8This,
+ signature),
+ static_cast<v8::PropertyAttribute>(v8::DontDelete));
+}
+
+void BoundObject::build()
+{
+ v8::Context::Scope contextScope(m_context);
+ v8::Local<v8::Function> constructor = m_hostTemplate->GetFunction();
+ v8::Local<v8::Object> boundObject = WebCore::SafeAllocation::newInstance(constructor);
+
+ v8::Handle<v8::Object> global = m_context->Global();
+ global->Set(v8::String::New(m_objectName), boundObject);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/BoundObject.h b/Source/WebKit/chromium/src/BoundObject.h
new file mode 100644
index 0000000..394ff7c
--- /dev/null
+++ b/Source/WebKit/chromium/src/BoundObject.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BoundObject_h
+#define BoundObject_h
+
+#include <v8.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebKit {
+
+// BoundObject is a helper class that lets you map JavaScript method calls
+// directly to C++ method calls. It should be destroyed once JS object is
+// built.
+class BoundObject {
+ WTF_MAKE_NONCOPYABLE(BoundObject);
+public:
+ BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName);
+ virtual ~BoundObject();
+
+ void addProtoFunction(const char* name, v8::InvocationCallback callback);
+ void build();
+
+private:
+ v8::HandleScope m_handleScope;
+ const char* m_objectName;
+ v8::Handle<v8::Context> m_context;
+ v8::Persistent<v8::FunctionTemplate> m_hostTemplate;
+ void* m_v8This;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
new file mode 100644
index 0000000..a63a625
--- /dev/null
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
@@ -0,0 +1,864 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ChromeClientImpl.h"
+
+#include "AXObjectCache.h"
+#include "AccessibilityObject.h"
+#include "CharacterNames.h"
+#include "Console.h"
+#include "Cursor.h"
+#include "DatabaseTracker.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "ExternalPopupMenu.h"
+#include "FileChooser.h"
+#include "FloatRect.h"
+#include "FrameLoadRequest.h"
+#include "FrameView.h"
+#include "Geolocation.h"
+#include "GeolocationService.h"
+#include "GraphicsLayer.h"
+#include "HTMLNames.h"
+#include "HitTestResult.h"
+#include "IntRect.h"
+#include "NavigationAction.h"
+#include "Node.h"
+#include "NotificationPresenterImpl.h"
+#include "Page.h"
+#include "PopupMenuChromium.h"
+#include "RenderWidget.h"
+#include "ScriptController.h"
+#include "SearchPopupMenuChromium.h"
+#include "SecurityOrigin.h"
+#include "Settings.h"
+#if USE(V8)
+#include "V8Proxy.h"
+#endif
+#include "WebAccessibilityObject.h"
+#include "WebConsoleMessage.h"
+#include "WebCursorInfo.h"
+#include "WebFileChooserCompletionImpl.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebInputEvent.h"
+#include "WebKit.h"
+#include "WebNode.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPopupMenuImpl.h"
+#include "WebPopupMenuInfo.h"
+#include "WebPopupType.h"
+#include "WebRect.h"
+#include "WebTextDirection.h"
+#include "WebURLRequest.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "WebWindowFeatures.h"
+#include "WindowFeatures.h"
+#include "WrappedResourceRequest.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Converts a WebCore::PopupContainerType to a WebKit::WebPopupType.
+static WebPopupType convertPopupType(PopupContainer::PopupType type)
+{
+ switch (type) {
+ case PopupContainer::Select:
+ return WebPopupTypeSelect;
+ case PopupContainer::Suggestion:
+ return WebPopupTypeSuggestion;
+ default:
+ ASSERT_NOT_REACHED();
+ return WebPopupTypeNone;
+ }
+}
+
+// Converts a WebCore::AXObjectCache::AXNotification to a WebKit::WebAccessibilityNotification
+static WebAccessibilityNotification toWebAccessibilityNotification(AXObjectCache::AXNotification notification)
+{
+ switch (notification) {
+ case AXObjectCache::AXActiveDescendantChanged:
+ return WebAccessibilityNotificationActiveDescendantChanged;
+ case AXObjectCache::AXCheckedStateChanged:
+ return WebAccessibilityNotificationCheckedStateChanged;
+ case AXObjectCache::AXChildrenChanged:
+ return WebAccessibilityNotificationChildrenChanged;
+ case AXObjectCache::AXFocusedUIElementChanged:
+ return WebAccessibilityNotificationFocusedUIElementChanged;
+ case AXObjectCache::AXLayoutComplete:
+ return WebAccessibilityNotificationLayoutComplete;
+ case AXObjectCache::AXLoadComplete:
+ return WebAccessibilityNotificationLoadComplete;
+ case AXObjectCache::AXSelectedChildrenChanged:
+ return WebAccessibilityNotificationSelectedChildrenChanged;
+ case AXObjectCache::AXSelectedTextChanged:
+ return WebAccessibilityNotificationSelectedTextChanged;
+ case AXObjectCache::AXValueChanged:
+ return WebAccessibilityNotificationValueChanged;
+ case AXObjectCache::AXScrolledToAnchor:
+ return WebAccessibilityNotificationScrolledToAnchor;
+ case AXObjectCache::AXLiveRegionChanged:
+ return WebAccessibilityNotificationLiveRegionChanged;
+ case AXObjectCache::AXMenuListValueChanged:
+ return WebAccessibilityNotificationMenuListValueChanged;
+ case AXObjectCache::AXRowCountChanged:
+ return WebAccessibilityNotificationRowCountChanged;
+ case AXObjectCache::AXRowCollapsed:
+ return WebAccessibilityNotificationRowCollapsed;
+ case AXObjectCache::AXRowExpanded:
+ return WebAccessibilityNotificationRowExpanded;
+ default:
+ ASSERT_NOT_REACHED();
+ return WebAccessibilityNotificationInvalid;
+ }
+}
+
+ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
+ : m_webView(webView)
+ , m_toolbarsVisible(true)
+ , m_statusbarVisible(true)
+ , m_scrollbarsVisible(true)
+ , m_menubarVisible(true)
+ , m_resizable(true)
+{
+}
+
+ChromeClientImpl::~ChromeClientImpl()
+{
+}
+
+void ChromeClientImpl::chromeDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+void ChromeClientImpl::setWindowRect(const FloatRect& r)
+{
+ if (m_webView->client())
+ m_webView->client()->setWindowRect(IntRect(r));
+}
+
+FloatRect ChromeClientImpl::windowRect()
+{
+ WebRect rect;
+ if (m_webView->client())
+ rect = m_webView->client()->rootWindowRect();
+ else {
+ // These numbers will be fairly wrong. The window's x/y coordinates will
+ // be the top left corner of the screen and the size will be the content
+ // size instead of the window size.
+ rect.width = m_webView->size().width;
+ rect.height = m_webView->size().height;
+ }
+ return FloatRect(rect);
+}
+
+FloatRect ChromeClientImpl::pageRect()
+{
+ // We hide the details of the window's border thickness from the web page by
+ // simple re-using the window position here. So, from the point-of-view of
+ // the web page, the window has no border.
+ return windowRect();
+}
+
+float ChromeClientImpl::scaleFactor()
+{
+ // This is supposed to return the scale factor of the web page. It looks like
+ // the implementor of the graphics layer is responsible for doing most of the
+ // operations associated with scaling. However, this value is used ins some
+ // cases by WebCore. For example, this is used as a scaling factor in canvas
+ // so that things drawn in it are scaled just like the web page is.
+ //
+ // We don't currently implement scaling, so just return 1.0 (no scaling).
+ return 1.0;
+}
+
+void ChromeClientImpl::focus()
+{
+ if (m_webView->client())
+ m_webView->client()->didFocus();
+}
+
+void ChromeClientImpl::unfocus()
+{
+ if (m_webView->client())
+ m_webView->client()->didBlur();
+}
+
+bool ChromeClientImpl::canTakeFocus(FocusDirection)
+{
+ // For now the browser can always take focus if we're not running layout
+ // tests.
+ return !layoutTestMode();
+}
+
+void ChromeClientImpl::takeFocus(FocusDirection direction)
+{
+ if (!m_webView->client())
+ return;
+ if (direction == FocusDirectionBackward)
+ m_webView->client()->focusPrevious();
+ else
+ m_webView->client()->focusNext();
+}
+
+void ChromeClientImpl::focusedNodeChanged(Node* node)
+{
+ m_webView->client()->focusedNodeChanged(WebNode(node));
+
+ WebURL focusURL;
+ if (node && node->isLink()) {
+ // This HitTestResult hack is the easiest way to get a link URL out of a
+ // WebCore::Node.
+ HitTestResult hitTest(IntPoint(0, 0));
+ // This cast must be valid because of the isLink() check.
+ hitTest.setURLElement(static_cast<Element*>(node));
+ if (hitTest.isLiveLink())
+ focusURL = hitTest.absoluteLinkURL();
+ }
+ m_webView->client()->setKeyboardFocusURL(focusURL);
+}
+
+void ChromeClientImpl::focusedFrameChanged(Frame*)
+{
+}
+
+Page* ChromeClientImpl::createWindow(
+ Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features, const NavigationAction&)
+{
+ if (!m_webView->client())
+ return 0;
+
+ WrappedResourceRequest request;
+ if (!r.resourceRequest().isEmpty())
+ request.bind(r.resourceRequest());
+ WebViewImpl* newView = static_cast<WebViewImpl*>(
+ m_webView->client()->createView(WebFrameImpl::fromFrame(frame), request, features, r.frameName()));
+ if (!newView)
+ return 0;
+
+ return newView->page();
+}
+
+static inline bool currentEventShouldCauseBackgroundTab(const WebInputEvent* inputEvent)
+{
+ if (!inputEvent)
+ return false;
+
+ if (inputEvent->type != WebInputEvent::MouseUp)
+ return false;
+
+ const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent);
+
+ WebNavigationPolicy policy;
+ unsigned short buttonNumber;
+ switch (mouseEvent->button) {
+ case WebMouseEvent::ButtonLeft:
+ buttonNumber = 0;
+ break;
+ case WebMouseEvent::ButtonMiddle:
+ buttonNumber = 1;
+ break;
+ case WebMouseEvent::ButtonRight:
+ buttonNumber = 2;
+ break;
+ default:
+ return false;
+ }
+ bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey;
+ bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey;
+ bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey;
+ bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey;
+
+ if (!WebViewImpl::navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &policy))
+ return false;
+
+ return policy == WebNavigationPolicyNewBackgroundTab;
+}
+
+void ChromeClientImpl::show()
+{
+ if (!m_webView->client())
+ return;
+
+ // If our default configuration was modified by a script or wasn't
+ // created by a user gesture, then show as a popup. Else, let this
+ // new window be opened as a toplevel window.
+ bool asPopup = !m_toolbarsVisible
+ || !m_statusbarVisible
+ || !m_scrollbarsVisible
+ || !m_menubarVisible
+ || !m_resizable;
+
+ WebNavigationPolicy policy = WebNavigationPolicyNewForegroundTab;
+ if (asPopup)
+ policy = WebNavigationPolicyNewPopup;
+ if (currentEventShouldCauseBackgroundTab(WebViewImpl::currentInputEvent()))
+ policy = WebNavigationPolicyNewBackgroundTab;
+
+ m_webView->client()->show(policy);
+}
+
+bool ChromeClientImpl::canRunModal()
+{
+ return !!m_webView->client();
+}
+
+void ChromeClientImpl::runModal()
+{
+ if (m_webView->client())
+ m_webView->client()->runModal();
+}
+
+void ChromeClientImpl::setToolbarsVisible(bool value)
+{
+ m_toolbarsVisible = value;
+}
+
+bool ChromeClientImpl::toolbarsVisible()
+{
+ return m_toolbarsVisible;
+}
+
+void ChromeClientImpl::setStatusbarVisible(bool value)
+{
+ m_statusbarVisible = value;
+}
+
+bool ChromeClientImpl::statusbarVisible()
+{
+ return m_statusbarVisible;
+}
+
+void ChromeClientImpl::setScrollbarsVisible(bool value)
+{
+ m_scrollbarsVisible = value;
+ WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+ if (webFrame)
+ webFrame->setCanHaveScrollbars(value);
+}
+
+bool ChromeClientImpl::scrollbarsVisible()
+{
+ return m_scrollbarsVisible;
+}
+
+void ChromeClientImpl::setMenubarVisible(bool value)
+{
+ m_menubarVisible = value;
+}
+
+bool ChromeClientImpl::menubarVisible()
+{
+ return m_menubarVisible;
+}
+
+void ChromeClientImpl::setResizable(bool value)
+{
+ m_resizable = value;
+}
+
+void ChromeClientImpl::addMessageToConsole(MessageSource source,
+ MessageType type,
+ MessageLevel level,
+ const String& message,
+ unsigned lineNumber,
+ const String& sourceID)
+{
+ if (m_webView->client()) {
+ m_webView->client()->didAddMessageToConsole(
+ WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message),
+ sourceID,
+ lineNumber);
+ }
+}
+
+bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel()
+{
+ return !!m_webView->client();
+}
+
+bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->runModalBeforeUnloadDialog(
+ WebFrameImpl::fromFrame(frame), message);
+ }
+ return false;
+}
+
+void ChromeClientImpl::closeWindowSoon()
+{
+ // Make sure this Page can no longer be found by JS.
+ m_webView->page()->setGroupName(String());
+
+ // Make sure that all loading is stopped. Ensures that JS stops executing!
+ m_webView->mainFrame()->stopLoading();
+
+ if (m_webView->client())
+ m_webView->client()->closeWidgetSoon();
+}
+
+// Although a Frame is passed in, we don't actually use it, since we
+// already know our own m_webView.
+void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message)
+{
+ if (m_webView->client()) {
+ m_webView->client()->runModalAlertDialog(
+ WebFrameImpl::fromFrame(frame), message);
+ }
+}
+
+// See comments for runJavaScriptAlert().
+bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->runModalConfirmDialog(
+ WebFrameImpl::fromFrame(frame), message);
+ }
+ return false;
+}
+
+// See comments for runJavaScriptAlert().
+bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame,
+ const String& message,
+ const String& defaultValue,
+ String& result)
+{
+ if (m_webView->client()) {
+ WebString actualValue;
+ bool ok = m_webView->client()->runModalPromptDialog(
+ WebFrameImpl::fromFrame(frame),
+ message,
+ defaultValue,
+ &actualValue);
+ if (ok)
+ result = actualValue;
+ return ok;
+ }
+ return false;
+}
+
+void ChromeClientImpl::setStatusbarText(const String& message)
+{
+ if (m_webView->client())
+ m_webView->client()->setStatusText(message);
+}
+
+bool ChromeClientImpl::shouldInterruptJavaScript()
+{
+ // FIXME: implement me
+ return false;
+}
+
+bool ChromeClientImpl::tabsToLinks() const
+{
+ // Returns true if anchors should accept keyboard focus with the tab key.
+ // This method is used in a convoluted fashion by EventHandler::tabsToLinks.
+ // It's a twisted path (self-evident, but more complicated than seems
+ // necessary), but the net result is that returning true from here, on a
+ // platform other than MAC or QT, lets anchors get keyboard focus.
+ return m_webView->tabsToLinks();
+}
+
+IntRect ChromeClientImpl::windowResizerRect() const
+{
+ IntRect result;
+ if (m_webView->client())
+ result = m_webView->client()->windowResizerRect();
+ return result;
+}
+
+void ChromeClientImpl::invalidateWindow(const IntRect&, bool)
+{
+ notImplemented();
+}
+
+void ChromeClientImpl::invalidateContentsAndWindow(const IntRect& updateRect, bool /*immediate*/)
+{
+ if (updateRect.isEmpty())
+ return;
+#if USE(ACCELERATED_COMPOSITING)
+ if (!m_webView->isAcceleratedCompositingActive()) {
+#endif
+ if (m_webView->client())
+ m_webView->client()->didInvalidateRect(updateRect);
+#if USE(ACCELERATED_COMPOSITING)
+ } else
+ m_webView->invalidateRootLayerRect(updateRect);
+#endif
+}
+
+void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate)
+{
+ m_webView->hidePopups();
+ invalidateContentsAndWindow(updateRect, immediate);
+}
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void ChromeClientImpl::scheduleAnimation()
+{
+ m_webView->client()->scheduleAnimation();
+}
+#endif
+
+void ChromeClientImpl::scroll(
+ const IntSize& scrollDelta, const IntRect& scrollRect,
+ const IntRect& clipRect)
+{
+ m_webView->hidePopups();
+#if USE(ACCELERATED_COMPOSITING)
+ if (!m_webView->isAcceleratedCompositingActive()) {
+#endif
+ if (m_webView->client()) {
+ int dx = scrollDelta.width();
+ int dy = scrollDelta.height();
+ m_webView->client()->didScrollRect(dx, dy, clipRect);
+ }
+#if USE(ACCELERATED_COMPOSITING)
+ } else
+ m_webView->scrollRootLayerRect(scrollDelta, clipRect);
+#endif
+}
+
+IntPoint ChromeClientImpl::screenToWindow(const IntPoint&) const
+{
+ notImplemented();
+ return IntPoint();
+}
+
+IntRect ChromeClientImpl::windowToScreen(const IntRect& rect) const
+{
+ IntRect screenRect(rect);
+
+ if (m_webView->client()) {
+ WebRect windowRect = m_webView->client()->windowRect();
+ screenRect.move(windowRect.x, windowRect.y);
+ }
+
+ return screenRect;
+}
+
+void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const
+{
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
+ if (webframe->client())
+ webframe->client()->didChangeContentsSize(webframe, size);
+}
+
+void ChromeClientImpl::scrollbarsModeDidChange() const
+{
+}
+
+void ChromeClientImpl::mouseDidMoveOverElement(
+ const HitTestResult& result, unsigned modifierFlags)
+{
+ if (!m_webView->client())
+ return;
+
+ WebURL url;
+ // Find out if the mouse is over a link, and if so, let our UI know...
+ if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty())
+ url = result.absoluteLinkURL();
+ else if (result.innerNonSharedNode()
+ && (result.innerNonSharedNode()->hasTagName(HTMLNames::objectTag)
+ || result.innerNonSharedNode()->hasTagName(HTMLNames::embedTag))) {
+ RenderObject* object = result.innerNonSharedNode()->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer()) {
+ WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget);
+ url = plugin->plugin()->linkAtPosition(result.point());
+ }
+ }
+ }
+
+ m_webView->client()->setMouseOverURL(url);
+}
+
+void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir)
+{
+ if (!m_webView->client())
+ return;
+ WebTextDirection textDirection = (dir == RTL) ?
+ WebTextDirectionRightToLeft :
+ WebTextDirectionLeftToRight;
+ m_webView->client()->setToolTipText(
+ tooltipText, textDirection);
+}
+
+void ChromeClientImpl::print(Frame* frame)
+{
+ if (m_webView->client())
+ m_webView->client()->printPage(WebFrameImpl::fromFrame(frame));
+}
+
+void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName)
+{
+ // Chromium users cannot currently change the default quota
+}
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+void ChromeClientImpl::reachedMaxAppCacheSize(int64_t spaceNeeded)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void ChromeClientImpl::reachedApplicationCacheOriginQuota(SecurityOrigin*)
+{
+ ASSERT_NOT_REACHED();
+}
+#endif
+
+void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
+{
+ WebViewClient* client = m_webView->client();
+ if (!client)
+ return;
+
+ WebFileChooserParams params;
+ params.multiSelect = fileChooser->allowsMultipleFiles();
+#if ENABLE(DIRECTORY_UPLOAD)
+ params.directory = fileChooser->allowsDirectoryUpload();
+#else
+ params.directory = false;
+#endif
+ params.acceptTypes = fileChooser->acceptTypes();
+ params.selectedFiles = fileChooser->filenames();
+ if (params.selectedFiles.size() > 0)
+ params.initialValue = params.selectedFiles[0];
+ WebFileChooserCompletionImpl* chooserCompletion =
+ new WebFileChooserCompletionImpl(fileChooser);
+
+ if (client->runFileChooser(params, chooserCompletion))
+ return;
+
+ // Choosing failed, so do callback with an empty list.
+ chooserCompletion->didChooseFile(WebVector<WebString>());
+}
+
+void ChromeClientImpl::chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*)
+{
+ notImplemented();
+}
+
+void ChromeClientImpl::popupOpened(PopupContainer* popupContainer,
+ const IntRect& bounds,
+ bool handleExternally)
+{
+ if (!m_webView->client())
+ return;
+
+ WebWidget* webwidget;
+ if (handleExternally) {
+ WebPopupMenuInfo popupInfo;
+ getPopupMenuInfo(popupContainer, &popupInfo);
+ webwidget = m_webView->client()->createPopupMenu(popupInfo);
+ } else {
+ webwidget = m_webView->client()->createPopupMenu(
+ convertPopupType(popupContainer->popupType()));
+ // We only notify when the WebView has to handle the popup, as when
+ // the popup is handled externally, the fact that a popup is showing is
+ // transparent to the WebView.
+ m_webView->popupOpened(popupContainer);
+ }
+ static_cast<WebPopupMenuImpl*>(webwidget)->Init(popupContainer, bounds);
+}
+
+void ChromeClientImpl::popupClosed(WebCore::PopupContainer* popupContainer)
+{
+ m_webView->popupClosed(popupContainer);
+}
+
+void ChromeClientImpl::setCursor(const WebCore::Cursor& cursor)
+{
+ setCursor(WebCursorInfo(cursor));
+}
+
+void ChromeClientImpl::setCursor(const WebCursorInfo& cursor)
+{
+ if (m_webView->client())
+ m_webView->client()->didChangeCursor(cursor);
+}
+
+void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor)
+{
+ setCursor(cursor);
+}
+
+void ChromeClientImpl::formStateDidChange(const Node* node)
+{
+ // The current history item is not updated yet. That happens lazily when
+ // WebFrame::currentHistoryItem is requested.
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(node->document()->frame());
+ if (webframe->client())
+ webframe->client()->didUpdateCurrentHistoryItem(webframe);
+}
+
+void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer,
+ WebPopupMenuInfo* info)
+{
+ const Vector<PopupItem*>& inputItems = popupContainer->popupData();
+
+ WebVector<WebPopupMenuInfo::Item> outputItems(inputItems.size());
+
+ for (size_t i = 0; i < inputItems.size(); ++i) {
+ const PopupItem& inputItem = *inputItems[i];
+ WebPopupMenuInfo::Item& outputItem = outputItems[i];
+
+ outputItem.label = inputItem.label;
+ outputItem.enabled = inputItem.enabled;
+
+ switch (inputItem.type) {
+ case PopupItem::TypeOption:
+ outputItem.type = WebPopupMenuInfo::Item::Option;
+ break;
+ case PopupItem::TypeGroup:
+ outputItem.type = WebPopupMenuInfo::Item::Group;
+ break;
+ case PopupItem::TypeSeparator:
+ outputItem.type = WebPopupMenuInfo::Item::Separator;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+
+ info->itemHeight = popupContainer->menuItemHeight();
+ info->itemFontSize = popupContainer->menuItemFontSize();
+ info->selectedIndex = popupContainer->selectedIndex();
+ info->items.swap(outputItems);
+ info->rightAligned = popupContainer->menuStyle().textDirection() == RTL;
+}
+
+void ChromeClientImpl::postAccessibilityNotification(AccessibilityObject* obj, AXObjectCache::AXNotification notification)
+{
+ // Alert assistive technology about the accessibility object notification.
+ if (obj)
+ m_webView->client()->postAccessibilityNotification(WebAccessibilityObject(obj), toWebAccessibilityNotification(notification));
+}
+
+#if ENABLE(NOTIFICATIONS)
+NotificationPresenter* ChromeClientImpl::notificationPresenter() const
+{
+ return m_webView->notificationPresenterImpl();
+}
+#endif
+
+// FIXME: Remove ChromeClientImpl::requestGeolocationPermissionForFrame and ChromeClientImpl::cancelGeolocationPermissionRequestForFrame
+// once all ports have moved to client-based geolocation (see https://bugs.webkit.org/show_bug.cgi?id=40373 ).
+// For client-based geolocation, these methods are now implemented as WebGeolocationClient::requestPermission and WebGeolocationClient::cancelPermissionRequest.
+// (see https://bugs.webkit.org/show_bug.cgi?id=50061 ).
+void ChromeClientImpl::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void ChromeClientImpl::cancelGeolocationPermissionRequestForFrame(Frame* frame, Geolocation* geolocation)
+{
+ ASSERT_NOT_REACHED();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
+{
+ m_webView->setRootGraphicsLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0);
+}
+
+void ChromeClientImpl::scheduleCompositingLayerSync()
+{
+ m_webView->setRootLayerNeedsDisplay();
+}
+
+ChromeClient::CompositingTriggerFlags ChromeClientImpl::allowedCompositingTriggers() const
+{
+ if (!m_webView->allowsAcceleratedCompositing())
+ return 0;
+
+ CompositingTriggerFlags flags = 0;
+ Settings* settings = m_webView->page()->settings();
+ if (settings->acceleratedCompositingFor3DTransformsEnabled())
+ flags |= ThreeDTransformTrigger;
+ if (settings->acceleratedCompositingForVideoEnabled())
+ flags |= VideoTrigger;
+ if (settings->acceleratedCompositingForPluginsEnabled())
+ flags |= PluginTrigger;
+ if (settings->acceleratedCompositingForAnimationEnabled())
+ flags |= AnimationTrigger;
+ if (settings->acceleratedCompositingForCanvasEnabled())
+ flags |= CanvasTrigger;
+
+ return flags;
+}
+#endif
+
+bool ChromeClientImpl::supportsFullscreenForNode(const WebCore::Node* node)
+{
+ if (m_webView->client() && node->hasTagName(WebCore::HTMLNames::videoTag))
+ return m_webView->client()->supportsFullscreen();
+ return false;
+}
+
+void ChromeClientImpl::enterFullscreenForNode(WebCore::Node* node)
+{
+ if (m_webView->client())
+ m_webView->client()->enterFullscreenForNode(WebNode(node));
+}
+
+void ChromeClientImpl::exitFullscreenForNode(WebCore::Node* node)
+{
+ if (m_webView->client())
+ m_webView->client()->exitFullscreenForNode(WebNode(node));
+}
+
+bool ChromeClientImpl::selectItemWritingDirectionIsNatural()
+{
+ return false;
+}
+
+PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(PopupMenuClient* client) const
+{
+ if (WebViewImpl::useExternalPopupMenus())
+ return adoptRef(new ExternalPopupMenu(client, m_webView->client()));
+
+ return adoptRef(new PopupMenuChromium(client));
+}
+
+PassRefPtr<SearchPopupMenu> ChromeClientImpl::createSearchPopupMenu(PopupMenuClient* client) const
+{
+ return adoptRef(new SearchPopupMenuChromium(client));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.h b/Source/WebKit/chromium/src/ChromeClientImpl.h
new file mode 100644
index 0000000..07f7d1f
--- /dev/null
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.h
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ChromeClientImpl_h
+#define ChromeClientImpl_h
+
+#include "ChromeClientChromium.h"
+#include "PopupMenu.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+class AccessibilityObject;
+class FileChooser;
+class HTMLParserQuirks;
+class PopupContainer;
+class PopupMenuClient;
+class SecurityOrigin;
+struct WindowFeatures;
+}
+
+namespace WebKit {
+class WebViewImpl;
+struct WebCursorInfo;
+struct WebPopupMenuInfo;
+
+// Handles window-level notifications from WebCore on behalf of a WebView.
+class ChromeClientImpl : public WebCore::ChromeClientChromium {
+public:
+ explicit ChromeClientImpl(WebViewImpl* webView);
+ virtual ~ChromeClientImpl();
+
+ WebViewImpl* webView() const { return m_webView; }
+
+ // ChromeClient methods:
+ virtual void chromeDestroyed();
+ virtual void setWindowRect(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect windowRect();
+ virtual WebCore::FloatRect pageRect();
+ virtual float scaleFactor();
+ virtual void focus();
+ virtual void unfocus();
+ virtual bool canTakeFocus(WebCore::FocusDirection);
+ virtual void takeFocus(WebCore::FocusDirection);
+ virtual void focusedNodeChanged(WebCore::Node*);
+ virtual void focusedFrameChanged(WebCore::Frame*);
+ virtual WebCore::Page* createWindow(
+ WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&);
+ virtual void show();
+ virtual bool canRunModal();
+ virtual void runModal();
+ virtual void setToolbarsVisible(bool);
+ virtual bool toolbarsVisible();
+ virtual void setStatusbarVisible(bool);
+ virtual bool statusbarVisible();
+ virtual void setScrollbarsVisible(bool);
+ virtual bool scrollbarsVisible();
+ virtual void setMenubarVisible(bool);
+ virtual bool menubarVisible();
+ virtual void setResizable(bool);
+ virtual void addMessageToConsole(
+ WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel,
+ const WTF::String& message, unsigned lineNumber,
+ const WTF::String& sourceID);
+ virtual bool canRunBeforeUnloadConfirmPanel();
+ virtual bool runBeforeUnloadConfirmPanel(
+ const WTF::String& message, WebCore::Frame*);
+ virtual void closeWindowSoon();
+ virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&);
+ virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&);
+ virtual bool runJavaScriptPrompt(
+ WebCore::Frame*, const WTF::String& message,
+ const WTF::String& defaultValue, WTF::String& result);
+ virtual void setStatusbarText(const WTF::String& message);
+ virtual bool shouldInterruptJavaScript();
+ virtual bool tabsToLinks() const;
+ virtual WebCore::IntRect windowResizerRect() const;
+ virtual void invalidateWindow(const WebCore::IntRect&, bool);
+ virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
+ virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ virtual void scheduleAnimation();
+#endif
+ virtual void scroll(
+ const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
+ const WebCore::IntRect& clipRect);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
+ virtual PlatformPageClient platformPageClient() const { return 0; }
+ virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
+ virtual void scrollRectIntoView(
+ const WebCore::IntRect&, const WebCore::ScrollView*) const { }
+ virtual void scrollbarsModeDidChange() const;
+ virtual void mouseDidMoveOverElement(
+ const WebCore::HitTestResult& result, unsigned modifierFlags);
+ virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection);
+ virtual void print(WebCore::Frame*);
+ virtual void exceededDatabaseQuota(
+ WebCore::Frame*, const WTF::String& databaseName);
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
+ virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*);
+#endif
+#if ENABLE(NOTIFICATIONS)
+ virtual WebCore::NotificationPresenter* notificationPresenter() const;
+#endif
+ virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
+ virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
+ virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
+ virtual void chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void formStateDidChange(const WebCore::Node*);
+ virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; }
+#if ENABLE(TOUCH_EVENTS)
+ // FIXME: All touch events are forwarded regardless of whether or not they are needed.
+ virtual void needTouchEvents(bool needTouchEvents) { }
+#endif
+
+#if USE(ACCELERATED_COMPOSITING)
+ // Pass 0 as the GraphicsLayer to detatch the root layer.
+ virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
+
+ // Sets a flag to specify that the next time content is drawn to the window,
+ // the changes appear on the screen in synchrony with updates to GraphicsLayers.
+ virtual void setNeedsOneShotDrawingSynchronization() { }
+
+ // Sets a flag to specify that the view needs to be updated, so we need
+ // to do an eager layout before the drawing.
+ virtual void scheduleCompositingLayerSync();
+
+ virtual CompositingTriggerFlags allowedCompositingTriggers() const;
+#endif
+
+ virtual bool supportsFullscreenForNode(const WebCore::Node*);
+ virtual void enterFullscreenForNode(WebCore::Node*);
+ virtual void exitFullscreenForNode(WebCore::Node*);
+
+ // ChromeClientChromium methods:
+ virtual void popupOpened(WebCore::PopupContainer* popupContainer,
+ const WebCore::IntRect& bounds,
+ bool handleExternally);
+ virtual void popupClosed(WebCore::PopupContainer* popupContainer);
+ virtual void postAccessibilityNotification(WebCore::AccessibilityObject*, WebCore::AXObjectCache::AXNotification);
+
+ // ChromeClientImpl:
+ void setCursorForPlugin(const WebCursorInfo&);
+
+ virtual bool selectItemWritingDirectionIsNatural();
+ virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
+ virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
+
+#if ENABLE(CONTEXT_MENUS)
+ virtual void showContextMenu() { }
+#endif
+
+private:
+ void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
+ void setCursor(const WebCursorInfo&);
+
+ WebViewImpl* m_webView; // weak pointer
+ bool m_toolbarsVisible;
+ bool m_statusbarVisible;
+ bool m_scrollbarsVisible;
+ bool m_menubarVisible;
+ bool m_resizable;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/ChromiumCurrentTime.cpp b/Source/WebKit/chromium/src/ChromiumCurrentTime.cpp
new file mode 100644
index 0000000..1eccc41
--- /dev/null
+++ b/Source/WebKit/chromium/src/ChromiumCurrentTime.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/CurrentTime.h>
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+
+namespace WTF {
+
+double currentTime()
+{
+ return WebKit::webKitClient()->currentTime();
+}
+
+} // namespace WTF
diff --git a/Source/WebKit/chromium/src/ChromiumThreading.cpp b/Source/WebKit/chromium/src/ChromiumThreading.cpp
new file mode 100644
index 0000000..c6fefac
--- /dev/null
+++ b/Source/WebKit/chromium/src/ChromiumThreading.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/chromium/ChromiumThreading.h>
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+
+#include <wtf/MainThread.h>
+
+namespace WTF {
+
+void ChromiumThreading::callOnMainThread(void (*func)(void*), void* context)
+{
+ WebKit::webKitClient()->callOnMainThread(func, context);
+}
+
+} // namespace WTF
diff --git a/Source/WebKit/chromium/src/CompositionUnderlineBuilder.h b/Source/WebKit/chromium/src/CompositionUnderlineBuilder.h
new file mode 100644
index 0000000..ce62474
--- /dev/null
+++ b/Source/WebKit/chromium/src/CompositionUnderlineBuilder.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CompositionUnderlineBuilder_h
+#define CompositionUnderlineBuilder_h
+
+#include "Editor.h"
+#include "Vector.h"
+#include "WebCompositionUnderline.h"
+#include "WebVector.h"
+
+namespace WebKit {
+
+// This class is used for converting from WebCompositionUnderline to
+// WebCore::CompositionUnderline.
+
+class CompositionUnderlineBuilder : public WebCore::CompositionUnderline {
+public:
+ CompositionUnderlineBuilder(const WebCompositionUnderline& u)
+ : WebCore::CompositionUnderline(u.startOffset, u.endOffset,
+ WebCore::Color(u.color), u.thick) { }
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.cpp b/Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.cpp
new file mode 100644
index 0000000..55dca85
--- /dev/null
+++ b/Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CompositionUnderlineVectorBuilder.h"
+
+#include "CompositionUnderlineBuilder.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+CompositionUnderlineVectorBuilder::CompositionUnderlineVectorBuilder(
+ const WebVector<WebCompositionUnderline>& underlines)
+{
+ size_t size = underlines.size();
+ reserveCapacity(size);
+ for (size_t i = 0; i < size; ++i)
+ append(CompositionUnderlineBuilder(underlines[i]));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.h b/Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.h
new file mode 100644
index 0000000..8050f02
--- /dev/null
+++ b/Source/WebKit/chromium/src/CompositionUnderlineVectorBuilder.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CompositionUnderlineVectorBuilder_h
+#define CompositionUnderlineVectorBuilder_h
+
+#include "Editor.h"
+#include "Vector.h"
+#include "WebCompositionUnderline.h"
+#include "WebVector.h"
+
+namespace WebKit {
+
+// This classes are used for converting from std::vector<WebCompositionUnderline>
+// to Vector<WebCore::CompositionUnderline>.
+
+class CompositionUnderlineVectorBuilder :
+ public Vector<WebCore::CompositionUnderline> {
+public:
+ CompositionUnderlineVectorBuilder(
+ const WebVector<WebCompositionUnderline>&);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
new file mode 100644
index 0000000..d166d9d
--- /dev/null
+++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
@@ -0,0 +1,324 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ContextMenuClientImpl.h"
+
+#include "CSSPropertyNames.h"
+#include "CSSStyleDeclaration.h"
+#include "ContextMenu.h"
+#include "ContextMenuController.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "Editor.h"
+#include "EventHandler.h"
+#include "FrameLoader.h"
+#include "FrameView.h"
+#include "HitTestResult.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "HTMLPlugInImageElement.h"
+#include "KURL.h"
+#include "MediaError.h"
+#include "Page.h"
+#include "PlatformString.h"
+#include "RenderWidget.h"
+#include "TextBreakIterator.h"
+#include "Widget.h"
+
+#include "WebContextMenuData.h"
+#include "WebDataSourceImpl.h"
+#include "WebFrameImpl.h"
+#include "WebMenuItemInfo.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPoint.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLResponse.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Figure out the URL of a page or subframe. Returns |page_type| as the type,
+// which indicates page or subframe, or ContextNodeType::NONE if the URL could not
+// be determined for some reason.
+static WebURL urlFromFrame(Frame* frame)
+{
+ if (frame) {
+ DocumentLoader* dl = frame->loader()->documentLoader();
+ if (dl) {
+ WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl);
+ if (ds)
+ return ds->hasUnreachableURL() ? ds->unreachableURL() : ds->request().url();
+ }
+ }
+ return WebURL();
+}
+
+// Helper function to determine whether text is a single word.
+static bool isASingleWord(const String& text)
+{
+ TextBreakIterator* it = wordBreakIterator(text.characters(), text.length());
+ return it && textBreakNext(it) == static_cast<int>(text.length());
+}
+
+// Helper function to get misspelled word on which context menu
+// is to be evolked. This function also sets the word on which context menu
+// has been evoked to be the selected word, as required. This function changes
+// the selection only when there were no selected characters on OS X.
+static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame)
+{
+ // First select from selectedText to check for multiple word selection.
+ String misspelledWord = selectedFrame->editor()->selectedText().stripWhiteSpace();
+
+ // If some texts were already selected, we don't change the selection.
+ if (!misspelledWord.isEmpty()) {
+ // Don't provide suggestions for multiple words.
+ if (!isASingleWord(misspelledWord))
+ return String();
+ return misspelledWord;
+ }
+
+ // Selection is empty, so change the selection to the word under the cursor.
+ HitTestResult hitTestResult = selectedFrame->eventHandler()->
+ hitTestResultAtPoint(selectedFrame->page()->contextMenuController()->hitTestResult().point(), true);
+ Node* innerNode = hitTestResult.innerNode();
+ VisiblePosition pos(innerNode->renderer()->positionForPoint(
+ hitTestResult.localPoint()));
+
+ if (pos.isNull())
+ return misspelledWord; // It is empty.
+
+ WebFrameImpl::selectWordAroundPosition(selectedFrame, pos);
+ misspelledWord = selectedFrame->editor()->selectedText().stripWhiteSpace();
+
+#if OS(DARWIN)
+ // If misspelled word is still empty, then that portion should not be
+ // selected. Set the selection to that position only, and do not expand.
+ if (misspelledWord.isEmpty())
+ selectedFrame->selection()->setSelection(VisibleSelection(pos));
+#else
+ // On non-Mac, right-click should not make a range selection in any case.
+ selectedFrame->selection()->setSelection(VisibleSelection(pos));
+#endif
+ return misspelledWord;
+}
+
+PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
+ ContextMenu* defaultMenu)
+{
+ // Displaying the context menu in this function is a big hack as we don't
+ // have context, i.e. whether this is being invoked via a script or in
+ // response to user input (Mouse event WM_RBUTTONDOWN,
+ // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked
+ // in response to the above input events before popping up the context menu.
+ if (!m_webView->contextMenuAllowed())
+ return 0;
+
+ HitTestResult r = m_webView->page()->contextMenuController()->hitTestResult();
+ Frame* selectedFrame = r.innerNonSharedNode()->document()->frame();
+
+ WebContextMenuData data;
+ data.mousePosition = selectedFrame->view()->contentsToWindow(r.point());
+
+ // Compute edit flags.
+ data.editFlags = WebContextMenuData::CanDoNone;
+ if (m_webView->focusedWebCoreFrame()->editor()->canUndo())
+ data.editFlags |= WebContextMenuData::CanUndo;
+ if (m_webView->focusedWebCoreFrame()->editor()->canRedo())
+ data.editFlags |= WebContextMenuData::CanRedo;
+ if (m_webView->focusedWebCoreFrame()->editor()->canCut())
+ data.editFlags |= WebContextMenuData::CanCut;
+ if (m_webView->focusedWebCoreFrame()->editor()->canCopy())
+ data.editFlags |= WebContextMenuData::CanCopy;
+ if (m_webView->focusedWebCoreFrame()->editor()->canPaste())
+ data.editFlags |= WebContextMenuData::CanPaste;
+ if (m_webView->focusedWebCoreFrame()->editor()->canDelete())
+ data.editFlags |= WebContextMenuData::CanDelete;
+ // We can always select all...
+ data.editFlags |= WebContextMenuData::CanSelectAll;
+ data.editFlags |= WebContextMenuData::CanTranslate;
+
+ // Links, Images, Media tags, and Image/Media-Links take preference over
+ // all else.
+ data.linkURL = r.absoluteLinkURL();
+
+ if (!r.absoluteImageURL().isEmpty()) {
+ data.srcURL = r.absoluteImageURL();
+ data.mediaType = WebContextMenuData::MediaTypeImage;
+ } else if (!r.absoluteMediaURL().isEmpty()) {
+ data.srcURL = r.absoluteMediaURL();
+
+ // We know that if absoluteMediaURL() is not empty, then this
+ // is a media element.
+ HTMLMediaElement* mediaElement =
+ static_cast<HTMLMediaElement*>(r.innerNonSharedNode());
+ if (mediaElement->hasTagName(HTMLNames::videoTag))
+ data.mediaType = WebContextMenuData::MediaTypeVideo;
+ else if (mediaElement->hasTagName(HTMLNames::audioTag))
+ data.mediaType = WebContextMenuData::MediaTypeAudio;
+
+ if (mediaElement->error())
+ data.mediaFlags |= WebContextMenuData::MediaInError;
+ if (mediaElement->paused())
+ data.mediaFlags |= WebContextMenuData::MediaPaused;
+ if (mediaElement->muted())
+ data.mediaFlags |= WebContextMenuData::MediaMuted;
+ if (mediaElement->loop())
+ data.mediaFlags |= WebContextMenuData::MediaLoop;
+ if (mediaElement->supportsSave())
+ data.mediaFlags |= WebContextMenuData::MediaCanSave;
+ if (mediaElement->hasAudio())
+ data.mediaFlags |= WebContextMenuData::MediaHasAudio;
+ if (mediaElement->hasVideo())
+ data.mediaFlags |= WebContextMenuData::MediaHasVideo;
+ if (mediaElement->controls())
+ data.mediaFlags |= WebContextMenuData::MediaControls;
+ } else if (r.innerNonSharedNode()->hasTagName(HTMLNames::objectTag)
+ || r.innerNonSharedNode()->hasTagName(HTMLNames::embedTag)) {
+ RenderObject* object = r.innerNonSharedNode()->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer()) {
+ data.mediaType = WebContextMenuData::MediaTypePlugin;
+ WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget);
+ WebString text = plugin->plugin()->selectionAsText();
+ if (!text.isEmpty()) {
+ data.selectedText = text;
+ data.editFlags |= WebContextMenuData::CanCopy;
+ }
+ data.editFlags &= ~WebContextMenuData::CanTranslate;
+ data.linkURL = plugin->plugin()->linkAtPosition(data.mousePosition);
+ if (plugin->plugin()->supportsPaginatedPrint())
+ data.mediaFlags |= WebContextMenuData::MediaCanPrint;
+
+ HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(r.innerNonSharedNode());
+ data.srcURL = pluginElement->document()->completeURL(pluginElement->url());
+ data.mediaFlags |= WebContextMenuData::MediaCanSave;
+ }
+ }
+ }
+
+ data.isImageBlocked =
+ (data.mediaType == WebContextMenuData::MediaTypeImage) && !r.image();
+
+ // If it's not a link, an image, a media element, or an image/media link,
+ // show a selection menu or a more generic page menu.
+ data.frameEncoding = selectedFrame->loader()->writer()->encoding();
+
+ // Send the frame and page URLs in any case.
+ data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame());
+ if (selectedFrame != m_webView->mainFrameImpl()->frame())
+ data.frameURL = urlFromFrame(selectedFrame);
+
+ if (r.isSelected())
+ data.selectedText = selectedFrame->editor()->selectedText().stripWhiteSpace();
+
+ if (r.isContentEditable()) {
+ data.isEditable = true;
+ if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {
+ data.isSpellCheckingEnabled = true;
+ // Spellchecking might be enabled for the field, but could be disabled on the node.
+ if (m_webView->focusedWebCoreFrame()->editor()->isSpellCheckingEnabledInFocusedNode())
+ data.misspelledWord = selectMisspelledWord(defaultMenu, selectedFrame);
+ }
+ }
+
+#if OS(DARWIN)
+ ExceptionCode ec = 0;
+ RefPtr<CSSStyleDeclaration> style = selectedFrame->document()->createCSSStyleDeclaration();
+ style->setProperty(CSSPropertyDirection, "ltr", false, ec);
+ if (selectedFrame->editor()->selectionHasStyle(style.get()) != FalseTriState)
+ data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuItemChecked;
+ style->setProperty(CSSPropertyDirection, "rtl", false, ec);
+ if (selectedFrame->editor()->selectionHasStyle(style.get()) != FalseTriState)
+ data.writingDirectionRightToLeft |= WebContextMenuData::CheckableMenuItemChecked;
+#endif // OS(DARWIN)
+
+ // Now retrieve the security info.
+ DocumentLoader* dl = selectedFrame->loader()->documentLoader();
+ WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl);
+ if (ds)
+ data.securityInfo = ds->response().securityInfo();
+
+ // Filter out custom menu elements and add them into the data.
+ populateCustomMenuItems(defaultMenu, &data);
+
+ data.node = r.innerNonSharedNode();
+
+ WebFrame* selected_web_frame = WebFrameImpl::fromFrame(selectedFrame);
+ if (m_webView->client())
+ m_webView->client()->showContextMenu(selected_web_frame, data);
+
+ return 0;
+}
+
+void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
+{
+ Vector<WebMenuItemInfo> customItems;
+ for (size_t i = 0; i < defaultMenu->itemCount(); ++i) {
+ ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription());
+ if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() > ContextMenuItemLastCustomTag)
+ continue;
+
+ WebMenuItemInfo outputItem;
+ outputItem.label = inputItem->title();
+ outputItem.enabled = inputItem->enabled();
+ outputItem.checked = inputItem->checked();
+ outputItem.action = static_cast<unsigned>(inputItem->action() - ContextMenuItemBaseCustomTag);
+ switch (inputItem->type()) {
+ case ActionType:
+ outputItem.type = WebMenuItemInfo::Option;
+ break;
+ case CheckableActionType:
+ outputItem.type = WebMenuItemInfo::CheckableOption;
+ break;
+ case SeparatorType:
+ outputItem.type = WebMenuItemInfo::Separator;
+ break;
+ case SubmenuType:
+ outputItem.type = WebMenuItemInfo::Group;
+ break;
+ }
+ customItems.append(outputItem);
+ }
+
+ WebVector<WebMenuItemInfo> outputItems(customItems.size());
+ for (size_t i = 0; i < customItems.size(); ++i)
+ outputItems[i] = customItems[i];
+ data->customItems.swap(outputItems);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.h b/Source/WebKit/chromium/src/ContextMenuClientImpl.h
new file mode 100644
index 0000000..97ea967
--- /dev/null
+++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ContextMenuClientImpl_h
+#define ContextMenuClientImpl_h
+
+#include "ContextMenuClient.h"
+
+namespace WebKit {
+
+class WebViewImpl;
+struct WebContextMenuData;
+
+class ContextMenuClientImpl : public WebCore::ContextMenuClient {
+public:
+ ContextMenuClientImpl(WebViewImpl* webView) : m_webView(webView) {}
+ virtual ~ContextMenuClientImpl() {}
+ virtual void copyImageToClipboard(const WebCore::HitTestResult&) {}
+ virtual void contextMenuDestroyed() {}
+ virtual void contextMenuItemSelected(WebCore::ContextMenuItem*, const WebCore::ContextMenu*) {}
+ virtual void downloadURL(const WebCore::KURL&) {}
+ virtual WebCore::PlatformMenuDescription getCustomMenuFromDefaultItems(WebCore::ContextMenu*);
+ virtual bool isSpeaking() { return false; }
+ virtual void lookUpInDictionary(WebCore::Frame*) {}
+ virtual void searchWithGoogle(const WebCore::Frame*) {}
+ virtual bool shouldIncludeInspectElementItem() { return false; }
+ virtual void speak(const WTF::String&) {}
+ virtual void stopSpeaking() {}
+private:
+ void populateCustomMenuItems(WebCore::ContextMenu*, WebContextMenuData*);
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif // ContextMenuClientImpl_h
diff --git a/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp
new file mode 100644
index 0000000..e688bfa
--- /dev/null
+++ b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DOMUtilitiesPrivate.h"
+
+#include "Element.h"
+#include "HTMLInputElement.h"
+#include "HTMLLinkElement.h"
+#include "HTMLMetaElement.h"
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "Node.h"
+
+using namespace WebCore;
+
+namespace {
+
+template <class HTMLNodeType>
+HTMLNodeType* toHTMLElement(Node* node, const QualifiedName& name)
+{
+ if (node->isHTMLElement()
+ && static_cast<HTMLElement*>(node)->hasTagName(name)) {
+ return static_cast<HTMLNodeType*>(node);
+ }
+ return 0;
+}
+
+} // namespace
+
+namespace WebKit {
+
+HTMLInputElement* toHTMLInputElement(Node* node)
+{
+ return toHTMLElement<HTMLInputElement>(node, HTMLNames::inputTag);
+}
+
+HTMLLinkElement* toHTMLLinkElement(Node* node)
+{
+ return toHTMLElement<HTMLLinkElement>(node, HTMLNames::linkTag);
+}
+
+HTMLMetaElement* toHTMLMetaElement(Node* node)
+{
+ return toHTMLElement<HTMLMetaElement>(node, HTMLNames::metaTag);
+}
+
+HTMLOptionElement* toHTMLOptionElement(Node* node)
+{
+ return toHTMLElement<HTMLOptionElement>(node, HTMLNames::optionTag);
+}
+
+bool elementHasLegalLinkAttribute(const Element* element,
+ const QualifiedName& attrName)
+{
+ if (attrName == HTMLNames::srcAttr) {
+ // Check src attribute.
+ if (element->hasTagName(HTMLNames::imgTag)
+ || element->hasTagName(HTMLNames::scriptTag)
+ || element->hasTagName(HTMLNames::iframeTag)
+ || element->hasTagName(HTMLNames::frameTag))
+ return true;
+ if (element->hasTagName(HTMLNames::inputTag)) {
+ const HTMLInputElement* input =
+ static_cast<const HTMLInputElement*>(element);
+ if (input->isImageButton())
+ return true;
+ }
+ } else if (attrName == HTMLNames::hrefAttr) {
+ // Check href attribute.
+ if (element->hasTagName(HTMLNames::linkTag)
+ || element->hasTagName(HTMLNames::aTag)
+ || element->hasTagName(HTMLNames::areaTag))
+ return true;
+ } else if (attrName == HTMLNames::actionAttr) {
+ if (element->hasTagName(HTMLNames::formTag))
+ return true;
+ } else if (attrName == HTMLNames::backgroundAttr) {
+ if (element->hasTagName(HTMLNames::bodyTag)
+ || element->hasTagName(HTMLNames::tableTag)
+ || element->hasTagName(HTMLNames::trTag)
+ || element->hasTagName(HTMLNames::tdTag))
+ return true;
+ } else if (attrName == HTMLNames::citeAttr) {
+ if (element->hasTagName(HTMLNames::blockquoteTag)
+ || element->hasTagName(HTMLNames::qTag)
+ || element->hasTagName(HTMLNames::delTag)
+ || element->hasTagName(HTMLNames::insTag))
+ return true;
+ } else if (attrName == HTMLNames::classidAttr
+ || attrName == HTMLNames::dataAttr) {
+ if (element->hasTagName(HTMLNames::objectTag))
+ return true;
+ } else if (attrName == HTMLNames::codebaseAttr) {
+ if (element->hasTagName(HTMLNames::objectTag)
+ || element->hasTagName(HTMLNames::appletTag))
+ return true;
+ }
+ return false;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h
new file mode 100644
index 0000000..99e3d9c
--- /dev/null
+++ b/Source/WebKit/chromium/src/DOMUtilitiesPrivate.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DOMUtilitiesPrivate_h
+#define DOMUtilitiesPrivate_h
+
+namespace WebCore {
+class Element;
+class HTMLInputElement;
+class HTMLLinkElement;
+class HTMLMetaElement;
+class HTMLOptionElement;
+class Node;
+class QualifiedName;
+}
+
+// This file is an aggregate of useful WebCore operations.
+namespace WebKit {
+
+// If node is an HTML node with a tag name of name it is casted and returned.
+// If node is not an HTML node or the tag name is not name, 0 is returned.
+WebCore::HTMLInputElement* toHTMLInputElement(WebCore::Node*);
+WebCore::HTMLLinkElement* toHTMLLinkElement(WebCore::Node*);
+WebCore::HTMLMetaElement* toHTMLMetaElement(WebCore::Node*);
+WebCore::HTMLOptionElement* toHTMLOptionElement(WebCore::Node*);
+
+// For img, script, iframe, frame element, when attribute name is src,
+// for link, a, area element, when attribute name is href,
+// for form element, when attribute name is action,
+// for input, type=image, when attribute name is src,
+// for body, table, tr, td, when attribute name is background,
+// for blockquote, q, del, ins, when attribute name is cite,
+// we can consider the attribute value has legal link.
+bool elementHasLegalLinkAttribute(const WebCore::Element* element,
+ const WebCore::QualifiedName& attrName);
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/DatabaseObserver.cpp b/Source/WebKit/chromium/src/DatabaseObserver.cpp
new file mode 100644
index 0000000..f43c9bd
--- /dev/null
+++ b/Source/WebKit/chromium/src/DatabaseObserver.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DatabaseObserver.h"
+
+#if ENABLE(DATABASE)
+
+#include "AbstractDatabase.h"
+#include "Document.h"
+#include "ScriptExecutionContext.h"
+#include "WebDatabase.h"
+#include "WebDatabaseObserver.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebSecurityOrigin.h"
+#include "WebWorkerImpl.h"
+#include "WorkerContext.h"
+#include "WorkerThread.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize)
+{
+ ASSERT(scriptExecutionContext->isContextThread());
+ ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerContext());
+ if (scriptExecutionContext->isDocument()) {
+ Document* document = static_cast<Document*>(scriptExecutionContext);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ return webFrame->client()->allowDatabase(webFrame, name, displayName, estimatedSize);
+ } else {
+ WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
+ WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
+ WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
+ return webWorker->allowDatabase(0, name, displayName, estimatedSize);
+ }
+
+ return true;
+}
+
+void DatabaseObserver::databaseOpened(AbstractDatabase* database)
+{
+ ASSERT(database->scriptExecutionContext()->isContextThread());
+ WebDatabase::observer()->databaseOpened(WebDatabase(database));
+}
+
+void DatabaseObserver::databaseModified(AbstractDatabase* database)
+{
+ ASSERT(database->scriptExecutionContext()->isContextThread());
+ WebDatabase::observer()->databaseModified(WebDatabase(database));
+}
+
+void DatabaseObserver::databaseClosed(AbstractDatabase* database)
+{
+ ASSERT(database->scriptExecutionContext()->isContextThread());
+ WebDatabase::observer()->databaseClosed(WebDatabase(database));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DATABASE)
diff --git a/Source/WebKit/chromium/src/DebuggerAgentImpl.cpp b/Source/WebKit/chromium/src/DebuggerAgentImpl.cpp
new file mode 100644
index 0000000..5dd5c58
--- /dev/null
+++ b/Source/WebKit/chromium/src/DebuggerAgentImpl.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DebuggerAgentImpl.h"
+
+#include "DebuggerAgentManager.h"
+#include "WebDevToolsAgentClient.h"
+#include "WebDevToolsAgentImpl.h"
+#include "WebViewImpl.h"
+
+using WTF::String;
+
+namespace WebKit {
+
+DebuggerAgentImpl::DebuggerAgentImpl(
+ WebViewImpl* webViewImpl,
+ WebDevToolsAgentImpl* webdevtoolsAgent,
+ WebDevToolsAgentClient* webdevtoolsAgentClient)
+ : m_webViewImpl(webViewImpl)
+ , m_webdevtoolsAgent(webdevtoolsAgent)
+ , m_webdevtoolsAgentClient(webdevtoolsAgentClient)
+ , m_autoContinueOnException(false)
+{
+ DebuggerAgentManager::debugAttach(this);
+}
+
+DebuggerAgentImpl::~DebuggerAgentImpl()
+{
+ DebuggerAgentManager::debugDetach(this);
+}
+
+void DebuggerAgentImpl::debuggerOutput(const String& command)
+{
+ m_webdevtoolsAgentClient->sendDebuggerOutput(command);
+}
+
+WebCore::Page* DebuggerAgentImpl::page()
+{
+ return m_webViewImpl->page();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/DebuggerAgentImpl.h b/Source/WebKit/chromium/src/DebuggerAgentImpl.h
new file mode 100644
index 0000000..a8fcc4e
--- /dev/null
+++ b/Source/WebKit/chromium/src/DebuggerAgentImpl.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DebuggerAgentImpl_h
+#define DebuggerAgentImpl_h
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+class Page;
+}
+
+namespace WebKit {
+
+class WebDevToolsAgentClient;
+class WebDevToolsAgentImpl;
+class WebViewImpl;
+
+class DebuggerAgentImpl {
+public:
+ DebuggerAgentImpl(WebKit::WebViewImpl* webViewImpl,
+ WebDevToolsAgentImpl* webdevtoolsAgent,
+ WebDevToolsAgentClient* webdevtoolsAgentClient);
+ virtual ~DebuggerAgentImpl();
+
+ void debuggerOutput(const WTF::String& out);
+
+ void setAutoContinueOnException(bool autoContinue) { m_autoContinueOnException = autoContinue; }
+
+ bool autoContinueOnException() { return m_autoContinueOnException; }
+
+ WebCore::Page* page();
+ WebDevToolsAgentImpl* webdevtoolsAgent() { return m_webdevtoolsAgent; }
+
+ WebKit::WebViewImpl* webView() { return m_webViewImpl; }
+
+private:
+ WebKit::WebViewImpl* m_webViewImpl;
+ WebDevToolsAgentImpl* m_webdevtoolsAgent;
+ WebDevToolsAgentClient* m_webdevtoolsAgentClient;
+ bool m_autoContinueOnException;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/DebuggerAgentManager.cpp b/Source/WebKit/chromium/src/DebuggerAgentManager.cpp
new file mode 100644
index 0000000..b76bcfe
--- /dev/null
+++ b/Source/WebKit/chromium/src/DebuggerAgentManager.cpp
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DebuggerAgentManager.h"
+
+#include "DebuggerAgentImpl.h"
+#include "Frame.h"
+#include "PageGroupLoadDeferrer.h"
+#include "ScriptDebugServer.h"
+#include "V8Proxy.h"
+#include "WebDevToolsAgentImpl.h"
+#include "WebFrameImpl.h"
+#include "WebViewImpl.h"
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/text/StringConcatenate.h>
+
+namespace WebKit {
+
+WebDevToolsAgent::MessageLoopDispatchHandler DebuggerAgentManager::s_messageLoopDispatchHandler = 0;
+
+bool DebuggerAgentManager::s_inHostDispatchHandler = false;
+
+DebuggerAgentManager::DeferrersMap DebuggerAgentManager::s_pageDeferrers;
+
+bool DebuggerAgentManager::s_exposeV8DebuggerProtocol = false;
+
+namespace {
+
+class CallerIdWrapper : public v8::Debug::ClientData {
+ WTF_MAKE_NONCOPYABLE(CallerIdWrapper);
+public:
+ CallerIdWrapper() : m_callerIsMananager(true), m_callerId(0) { }
+ explicit CallerIdWrapper(int callerId)
+ : m_callerIsMananager(false)
+ , m_callerId(callerId) { }
+ ~CallerIdWrapper() { }
+ bool callerIsMananager() const { return m_callerIsMananager; }
+ int callerId() const { return m_callerId; }
+private:
+ bool m_callerIsMananager;
+ int m_callerId;
+};
+
+} // namespace
+
+
+void DebuggerAgentManager::debugHostDispatchHandler()
+{
+ if (!s_messageLoopDispatchHandler || !s_attachedAgentsMap)
+ return;
+
+ if (s_inHostDispatchHandler)
+ return;
+
+ s_inHostDispatchHandler = true;
+
+ Vector<WebViewImpl*> views;
+ // 1. Disable active objects and input events.
+ for (AttachedAgentsMap::iterator it = s_attachedAgentsMap->begin(); it != s_attachedAgentsMap->end(); ++it) {
+ DebuggerAgentImpl* agent = it->second;
+ s_pageDeferrers.set(agent->webView(), new WebCore::PageGroupLoadDeferrer(agent->page(), true));
+ views.append(agent->webView());
+ agent->webView()->setIgnoreInputEvents(true);
+ }
+
+ // 2. Process messages.
+ s_messageLoopDispatchHandler();
+
+ // 3. Bring things back.
+ for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) {
+ if (s_pageDeferrers.contains(*it)) {
+ // The view was not closed during the dispatch.
+ (*it)->setIgnoreInputEvents(false);
+ }
+ }
+ deleteAllValues(s_pageDeferrers);
+ s_pageDeferrers.clear();
+
+ s_inHostDispatchHandler = false;
+ if (!s_attachedAgentsMap) {
+ // Remove handlers if all agents were detached within host dispatch.
+ v8::Debug::SetMessageHandler(0);
+ v8::Debug::SetHostDispatchHandler(0);
+ }
+}
+
+DebuggerAgentManager::AttachedAgentsMap* DebuggerAgentManager::s_attachedAgentsMap = 0;
+
+void DebuggerAgentManager::debugAttach(DebuggerAgentImpl* debuggerAgent)
+{
+ if (!s_exposeV8DebuggerProtocol)
+ return;
+ if (!s_attachedAgentsMap) {
+ s_attachedAgentsMap = new AttachedAgentsMap();
+ v8::Debug::SetMessageHandler2(&DebuggerAgentManager::onV8DebugMessage);
+ v8::Debug::SetHostDispatchHandler(&DebuggerAgentManager::debugHostDispatchHandler, 100 /* ms */);
+ }
+ int hostId = debuggerAgent->webdevtoolsAgent()->hostId();
+ ASSERT(hostId);
+ s_attachedAgentsMap->set(hostId, debuggerAgent);
+}
+
+void DebuggerAgentManager::debugDetach(DebuggerAgentImpl* debuggerAgent)
+{
+ if (!s_exposeV8DebuggerProtocol)
+ return;
+ if (!s_attachedAgentsMap) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ int hostId = debuggerAgent->webdevtoolsAgent()->hostId();
+ ASSERT(s_attachedAgentsMap->get(hostId) == debuggerAgent);
+ bool isOnBreakpoint = (findAgentForCurrentV8Context() == debuggerAgent);
+ s_attachedAgentsMap->remove(hostId);
+
+ if (s_attachedAgentsMap->isEmpty()) {
+ delete s_attachedAgentsMap;
+ s_attachedAgentsMap = 0;
+ // Note that we do not empty handlers while in dispatch - we schedule
+ // continue and do removal once we are out of the dispatch. Also there is
+ // no need to send continue command in this case since removing message
+ // handler will cause debugger unload and all breakpoints will be cleared.
+ if (!s_inHostDispatchHandler) {
+ v8::Debug::SetMessageHandler2(0);
+ v8::Debug::SetHostDispatchHandler(0);
+ }
+ } else {
+ // Remove all breakpoints set by the agent.
+ String clearBreakpointGroupCmd = makeString(
+ "{\"seq\":1,\"type\":\"request\",\"command\":\"clearbreakpointgroup\","
+ "\"arguments\":{\"groupId\":", String::number(hostId), "}}");
+ sendCommandToV8(clearBreakpointGroupCmd, new CallerIdWrapper());
+
+ if (isOnBreakpoint) {
+ // Force continue if detach happened in nessted message loop while
+ // debugger was paused on a breakpoint(as long as there are other
+ // attached agents v8 will wait for explicit'continue' message).
+ sendContinueCommandToV8();
+ }
+ }
+}
+
+void DebuggerAgentManager::onV8DebugMessage(const v8::Debug::Message& message)
+{
+ v8::HandleScope scope;
+ v8::String::Value value(message.GetJSON());
+ WTF::String out(reinterpret_cast<const UChar*>(*value), value.length());
+
+ // If callerData is not 0 the message is a response to a debugger command.
+ if (v8::Debug::ClientData* callerData = message.GetClientData()) {
+ CallerIdWrapper* wrapper = static_cast<CallerIdWrapper*>(callerData);
+ if (wrapper->callerIsMananager()) {
+ // Just ignore messages sent by this manager.
+ return;
+ }
+ DebuggerAgentImpl* debuggerAgent = debuggerAgentForHostId(wrapper->callerId());
+ if (debuggerAgent)
+ debuggerAgent->debuggerOutput(out);
+ else if (!message.WillStartRunning()) {
+ // Autocontinue execution if there is no handler.
+ sendContinueCommandToV8();
+ }
+ return;
+ } // Otherwise it's an event message.
+ ASSERT(message.IsEvent());
+
+ // Ignore unsupported event types.
+ if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception)
+ return;
+
+ v8::Handle<v8::Context> context = message.GetEventContext();
+ // If the context is from one of the inpected tabs it should have its context
+ // data.
+ if (context.IsEmpty()) {
+ // Unknown context, skip the event.
+ return;
+ }
+
+ // If the context is from one of the inpected tabs or injected extension
+ // scripts it must have hostId in the data field.
+ int hostId = WebCore::V8Proxy::contextDebugId(context);
+ if (hostId != -1) {
+ DebuggerAgentImpl* agent = debuggerAgentForHostId(hostId);
+ if (agent) {
+ if (agent->autoContinueOnException()
+ && message.GetEvent() == v8::Exception) {
+ sendContinueCommandToV8();
+ return;
+ }
+
+ agent->debuggerOutput(out);
+ return;
+ }
+ }
+
+ if (!message.WillStartRunning()) {
+ // Autocontinue execution on break and exception events if there is no
+ // handler.
+ sendContinueCommandToV8();
+ }
+}
+
+void DebuggerAgentManager::pauseScript()
+{
+ v8::Debug::DebugBreak();
+}
+
+void DebuggerAgentManager::executeDebuggerCommand(const WTF::String& command, int callerId)
+{
+ sendCommandToV8(command, new CallerIdWrapper(callerId));
+}
+
+void DebuggerAgentManager::setMessageLoopDispatchHandler(WebDevToolsAgent::MessageLoopDispatchHandler handler)
+{
+ s_messageLoopDispatchHandler = handler;
+}
+
+void DebuggerAgentManager::setExposeV8DebuggerProtocol(bool value)
+{
+ s_exposeV8DebuggerProtocol = value;
+ WebCore::ScriptDebugServer::shared().setEnabled(!s_exposeV8DebuggerProtocol);
+}
+
+void DebuggerAgentManager::setHostId(WebFrameImpl* webframe, int hostId)
+{
+ ASSERT(hostId > 0);
+ WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(webframe->frame());
+ if (proxy)
+ proxy->setContextDebugId(hostId);
+}
+
+void DebuggerAgentManager::onWebViewClosed(WebViewImpl* webview)
+{
+ if (s_pageDeferrers.contains(webview)) {
+ delete s_pageDeferrers.get(webview);
+ s_pageDeferrers.remove(webview);
+ }
+}
+
+void DebuggerAgentManager::onNavigate()
+{
+ if (s_inHostDispatchHandler)
+ DebuggerAgentManager::sendContinueCommandToV8();
+}
+
+void DebuggerAgentManager::sendCommandToV8(const WTF::String& cmd, v8::Debug::ClientData* data)
+{
+ v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.characters()), cmd.length(), data);
+}
+
+void DebuggerAgentManager::sendContinueCommandToV8()
+{
+ WTF::String continueCmd("{\"seq\":1,\"type\":\"request\",\"command\":\"continue\"}");
+ sendCommandToV8(continueCmd, new CallerIdWrapper());
+}
+
+DebuggerAgentImpl* DebuggerAgentManager::findAgentForCurrentV8Context()
+{
+ if (!s_attachedAgentsMap)
+ return 0;
+ ASSERT(!s_attachedAgentsMap->isEmpty());
+
+ WebCore::Frame* frame = WebCore::V8Proxy::retrieveFrameForEnteredContext();
+ if (!frame)
+ return 0;
+ WebCore::Page* page = frame->page();
+ for (AttachedAgentsMap::iterator it = s_attachedAgentsMap->begin(); it != s_attachedAgentsMap->end(); ++it) {
+ if (it->second->page() == page)
+ return it->second;
+ }
+ return 0;
+}
+
+DebuggerAgentImpl* DebuggerAgentManager::debuggerAgentForHostId(int hostId)
+{
+ if (!s_attachedAgentsMap)
+ return 0;
+ return s_attachedAgentsMap->get(hostId);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/DebuggerAgentManager.h b/Source/WebKit/chromium/src/DebuggerAgentManager.h
new file mode 100644
index 0000000..a323311
--- /dev/null
+++ b/Source/WebKit/chromium/src/DebuggerAgentManager.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DebuggerAgentManager_h
+#define DebuggerAgentManager_h
+
+#include "WebCString.h"
+#include "WebDevToolsAgent.h"
+#include <v8-debug.h>
+#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class Page;
+class PageGroupLoadDeferrer;
+}
+
+namespace WebKit {
+
+class DebuggerAgentImpl;
+class DictionaryValue;
+class WebFrameImpl;
+class WebViewImpl;
+
+// There is single v8 instance per render process. Also there may be several
+// RenderViews and consequently devtools agents in the process that want to talk
+// to the v8 debugger. This class coordinates communication between the debug
+// agents and v8 debugger. It will set debug output handler as long as at least
+// one debugger agent is attached and remove it when last debugger agent is
+// detached. When message is received from debugger it will route it to the
+// right debugger agent if there is one otherwise the message will be ignored.
+//
+// v8 may send a message(e.g. exception event) after which it
+// would expect some actions from the handler. If there is no appropriate
+// debugger agent to handle such messages the manager will perform the action
+// itself, otherwise v8 may hang waiting for the action.
+class DebuggerAgentManager {
+ WTF_MAKE_NONCOPYABLE(DebuggerAgentManager);
+public:
+ static void debugAttach(DebuggerAgentImpl* debuggerAgent);
+ static void debugDetach(DebuggerAgentImpl* debuggerAgent);
+ static void pauseScript();
+ static void executeDebuggerCommand(const WTF::String& command, int callerId);
+ static void setMessageLoopDispatchHandler(WebDevToolsAgent::MessageLoopDispatchHandler handler);
+ static void setExposeV8DebuggerProtocol(bool);
+
+ // Sets |hostId| as the frame context data. This id is used to filter scripts
+ // related to the inspected page.
+ static void setHostId(WebFrameImpl* webframe, int hostId);
+
+ static void onWebViewClosed(WebViewImpl* webview);
+
+ static void onNavigate();
+
+private:
+ DebuggerAgentManager();
+ ~DebuggerAgentManager();
+
+ static void debugHostDispatchHandler();
+ static void onV8DebugMessage(const v8::Debug::Message& message);
+ static void sendCommandToV8(const WTF::String& cmd,
+ v8::Debug::ClientData* data);
+ static void sendContinueCommandToV8();
+
+ static DebuggerAgentImpl* findAgentForCurrentV8Context();
+ static DebuggerAgentImpl* debuggerAgentForHostId(int hostId);
+
+ typedef HashMap<int, DebuggerAgentImpl*> AttachedAgentsMap;
+ static AttachedAgentsMap* s_attachedAgentsMap;
+
+ static WebDevToolsAgent::MessageLoopDispatchHandler s_messageLoopDispatchHandler;
+ static bool s_inHostDispatchHandler;
+ typedef HashMap<WebViewImpl*, WebCore::PageGroupLoadDeferrer*> DeferrersMap;
+ static DeferrersMap s_pageDeferrers;
+
+ static bool s_exposeV8DebuggerProtocol;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/DeviceOrientationClientProxy.cpp b/Source/WebKit/chromium/src/DeviceOrientationClientProxy.cpp
new file mode 100644
index 0000000..29b43ba
--- /dev/null
+++ b/Source/WebKit/chromium/src/DeviceOrientationClientProxy.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DeviceOrientationClientProxy.h"
+
+#include "DeviceOrientation.h"
+#include "WebDeviceOrientation.h"
+#include "WebDeviceOrientationController.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class DeviceOrientationController;
+}
+
+namespace WebKit {
+
+void DeviceOrientationClientProxy::setController(WebCore::DeviceOrientationController* c)
+{
+ if (!m_client) // FIXME: Get rid of these null checks once device orientation is enabled by default.
+ return;
+ m_client->setController(new WebDeviceOrientationController(c));
+}
+
+void DeviceOrientationClientProxy::startUpdating()
+{
+ if (!m_client)
+ return;
+ m_client->startUpdating();
+}
+
+void DeviceOrientationClientProxy::stopUpdating()
+{
+ if (!m_client)
+ return;
+ m_client->stopUpdating();
+}
+
+WebCore::DeviceOrientation* DeviceOrientationClientProxy::lastOrientation() const
+{
+ if (!m_client)
+ return 0;
+
+ // Cache the DeviceOrientation pointer so its reference count does not drop to zero upon return.
+ m_lastOrientation = m_client->lastOrientation();
+
+ return m_lastOrientation.get();
+}
+
+void DeviceOrientationClientProxy::deviceOrientationControllerDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h b/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h
new file mode 100644
index 0000000..e90d77f
--- /dev/null
+++ b/Source/WebKit/chromium/src/DeviceOrientationClientProxy.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DeviceOrientationClientProxy_h
+#define DeviceOrientationClientProxy_h
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClient.h"
+#include "WebDeviceOrientationClient.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class DeviceOrientationController;
+}
+
+namespace WebKit {
+
+class DeviceOrientationClientProxy : public WebCore::DeviceOrientationClient {
+public:
+ DeviceOrientationClientProxy(WebDeviceOrientationClient* client)
+ : m_client(client)
+ {
+ }
+
+ void setController(WebCore::DeviceOrientationController*);
+ void startUpdating();
+ void stopUpdating();
+ WebCore::DeviceOrientation* lastOrientation() const;
+ virtual void deviceOrientationControllerDestroyed();
+
+private:
+ WebDeviceOrientationClient* m_client;
+ mutable RefPtr<WebCore::DeviceOrientation> m_lastOrientation;
+};
+
+} // namespace WebKit
+
+#endif // DeviceOrientationClientProxy_h
diff --git a/Source/WebKit/chromium/src/DragClientImpl.cpp b/Source/WebKit/chromium/src/DragClientImpl.cpp
new file mode 100644
index 0000000..9874401
--- /dev/null
+++ b/Source/WebKit/chromium/src/DragClientImpl.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DragClientImpl.h"
+#include "DragImageRef.h"
+#include "ChromiumDataObject.h"
+#include "ClipboardChromium.h"
+#include "Frame.h"
+#include "NativeImageSkia.h"
+#include "WebCommon.h"
+#include "WebDragData.h"
+#include "WebImage.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void DragClientImpl::willPerformDragDestinationAction(DragDestinationAction, DragData*)
+{
+ // FIXME
+}
+
+void DragClientImpl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+{
+ // FIXME
+}
+
+DragDestinationAction DragClientImpl::actionMaskForDrag(DragData*)
+{
+ if (m_webView->client() && m_webView->client()->acceptsLoadDrops())
+ return DragDestinationActionAny;
+
+ return static_cast<DragDestinationAction>(
+ DragDestinationActionDHTML | DragDestinationActionEdit);
+}
+
+DragSourceAction DragClientImpl::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
+{
+ // We want to handle drag operations for all source types.
+ return DragSourceActionAny;
+}
+
+void DragClientImpl::startDrag(DragImageRef dragImage,
+ const IntPoint& dragImageOrigin,
+ const IntPoint& eventPos,
+ Clipboard* clipboard,
+ Frame* frame,
+ bool isLinkDrag)
+{
+ // Add a ref to the frame just in case a load occurs mid-drag.
+ RefPtr<Frame> frameProtector = frame;
+
+ WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject();
+
+ DragOperation dragOperationMask = clipboard->sourceOperation();
+
+ IntSize offsetSize(eventPos - dragImageOrigin);
+ WebPoint offsetPoint(offsetSize.width(), offsetSize.height());
+ m_webView->startDragging(
+ dragData, static_cast<WebDragOperationsMask>(dragOperationMask),
+#if WEBKIT_USING_SKIA
+ dragImage ? WebImage(*dragImage) : WebImage(),
+#else
+ dragImage ? WebImage(dragImage) : WebImage(),
+#endif
+ offsetPoint);
+}
+
+DragImageRef DragClientImpl::createDragImageForLink(KURL&, const String& label, Frame*)
+{
+ // FIXME
+ return 0;
+}
+
+void DragClientImpl::dragControllerDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/DragClientImpl.h b/Source/WebKit/chromium/src/DragClientImpl.h
new file mode 100644
index 0000000..dac7acd
--- /dev/null
+++ b/Source/WebKit/chromium/src/DragClientImpl.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DragClientImpl_h
+#define DragClientImpl_h
+
+#include "DragActions.h"
+#include "DragClient.h"
+
+namespace WebCore {
+class ClipBoard;
+class DragData;
+class IntPoint;
+class KURL;
+}
+
+namespace WebKit {
+class WebViewImpl;
+
+class DragClientImpl : public WebCore::DragClient {
+public:
+ DragClientImpl(WebViewImpl* webView) : m_webView(webView) { }
+
+ virtual void willPerformDragDestinationAction(
+ WebCore::DragDestinationAction, WebCore::DragData*);
+ virtual void willPerformDragSourceAction(
+ WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
+ virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
+ virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(
+ const WebCore::IntPoint& windowPoint);
+ virtual void startDrag(
+ WebCore::DragImageRef dragImage,
+ const WebCore::IntPoint& dragImageOrigin,
+ const WebCore::IntPoint& eventPos,
+ WebCore::Clipboard* clipboard,
+ WebCore::Frame* frame,
+ bool isLinkDrag = false);
+ virtual WebCore::DragImageRef createDragImageForLink(
+ WebCore::KURL&, const WTF::String& label, WebCore::Frame*);
+ virtual void dragControllerDestroyed();
+
+private:
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/DragScrollTimer.cpp b/Source/WebKit/chromium/src/DragScrollTimer.cpp
new file mode 100644
index 0000000..83b81b7
--- /dev/null
+++ b/Source/WebKit/chromium/src/DragScrollTimer.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DragScrollTimer.h"
+
+#include "FrameView.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Computes the distance from a point outside a rect to the nearest edge of the rect.
+static IntSize distanceToRect(const IntPoint& point, const IntRect& rect)
+{
+ int dx = 0, dy = 0;
+ if (point.x() < rect.x())
+ dx = point.x() - rect.x();
+ else if (rect.right() < point.x())
+ dx = point.x() - rect.right();
+ if (point.y() < rect.y())
+ dy = point.y() - rect.y();
+ else if (rect.bottom() < point.y())
+ dy = point.y() - rect.bottom();
+ return IntSize(dx, dy);
+}
+
+DragScrollTimer::DragScrollTimer()
+ : m_timer(this, &DragScrollTimer::fired)
+ , m_view(0)
+ , m_scrolling(false)
+{
+}
+
+DragScrollTimer::~DragScrollTimer()
+{
+ // We do this for detecting dead object earlier
+ stop();
+}
+
+void DragScrollTimer::stop()
+{
+ m_timer.stop();
+ m_view = 0;
+ m_scrolling = false;
+}
+
+void DragScrollTimer::scroll()
+{
+ m_view->scrollBy(m_lastDistance);
+ m_scrolling = true;
+}
+
+void DragScrollTimer::update()
+{
+ if (shouldScroll())
+ scroll();
+ else
+ stop();
+}
+
+void DragScrollTimer::triggerScroll(FrameView* view, const WebPoint& location)
+{
+ if (!view)
+ return;
+
+ // Approximates Safari
+ static const double scrollStartDelay = 0.2;
+
+ m_view = view;
+ m_lastDistance = scrollDistanceFor(view, location);
+
+ if (m_scrolling)
+ update();
+ else if (shouldScroll() && !m_timer.isActive())
+ m_timer.startOneShot(scrollStartDelay);
+}
+
+IntSize DragScrollTimer::scrollDistanceFor(FrameView* view, const WebPoint& location) const
+{
+ static const int scrollMargin = 30;
+
+ IntRect bounds(0, 0, view->visibleWidth(), view->visibleHeight());
+ if (!bounds.contains(location))
+ return IntSize(0, 0); // The location is outside the border belt.
+
+ bounds.setY(bounds.y() + scrollMargin);
+ bounds.setHeight(bounds.height() - scrollMargin * 2);
+ bounds.setX(bounds.x() + scrollMargin);
+ bounds.setWidth(bounds.width() - scrollMargin * 2);
+
+ if (bounds.contains(location))
+ return IntSize(0, 0); // The location is inside the border belt.
+
+ // The location is over the border belt.
+ return distanceToRect(location, bounds);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/DragScrollTimer.h b/Source/WebKit/chromium/src/DragScrollTimer.h
new file mode 100644
index 0000000..a4090e0
--- /dev/null
+++ b/Source/WebKit/chromium/src/DragScrollTimer.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DragScrollTimer_h
+#define DragScrollTimer_h
+
+#include "IntSize.h"
+#include "Timer.h"
+#include "WebPoint.h"
+
+namespace WebCore { class FrameView; }
+
+namespace WebKit {
+
+//
+// Encapsulating a timer and associated state management for
+// scroll-on-drag behaviour.
+//
+class DragScrollTimer {
+public:
+ DragScrollTimer();
+ ~DragScrollTimer();
+
+ void fired(WebCore::Timer<DragScrollTimer>*) { update(); }
+ void triggerScroll(WebCore::FrameView*, const WebPoint&);
+ void stop();
+
+private:
+ void scroll();
+ void update();
+ WebCore::IntSize scrollDistanceFor(WebCore::FrameView*, const WebPoint&) const;
+ bool shouldScroll() const { return !m_lastDistance.isZero(); }
+
+ WebCore::Timer<DragScrollTimer> m_timer;
+ WebCore::FrameView* m_view;
+ WebCore::IntSize m_lastDistance;
+ bool m_scrolling;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/EditorClientImpl.cpp b/Source/WebKit/chromium/src/EditorClientImpl.cpp
new file mode 100644
index 0000000..68694c2
--- /dev/null
+++ b/Source/WebKit/chromium/src/EditorClientImpl.cpp
@@ -0,0 +1,948 @@
+/*
+ * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved.
+ * Copyright (C) 2010 Google, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 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 COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EditorClientImpl.h"
+
+#include "Document.h"
+#include "EditCommand.h"
+#include "Editor.h"
+#include "EventHandler.h"
+#include "EventNames.h"
+#include "Frame.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "KeyboardCodes.h"
+#include "KeyboardEvent.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformString.h"
+#include "RenderObject.h"
+
+#include "DOMUtilitiesPrivate.h"
+#include "WebAutoFillClient.h"
+#include "WebEditingAction.h"
+#include "WebElement.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebInputElement.h"
+#include "WebInputEventConversion.h"
+#include "WebNode.h"
+#include "WebPasswordAutocompleteListener.h"
+#include "WebRange.h"
+#include "WebTextAffinity.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Arbitrary depth limit for the undo stack, to keep it from using
+// unbounded memory. This is the maximum number of distinct undoable
+// actions -- unbroken stretches of typed characters are coalesced
+// into a single action.
+static const size_t maximumUndoStackDepth = 1000;
+
+// The size above which we stop triggering autofill for an input text field
+// (so to avoid sending long strings through IPC).
+static const size_t maximumTextSizeForAutofill = 1000;
+
+EditorClientImpl::EditorClientImpl(WebViewImpl* webview)
+ : m_webView(webview)
+ , m_inRedo(false)
+ , m_backspaceOrDeletePressed(false)
+ , m_spellCheckThisFieldStatus(SpellCheckAutomatic)
+ , m_autofillTimer(this, &EditorClientImpl::doAutofill)
+{
+}
+
+EditorClientImpl::~EditorClientImpl()
+{
+}
+
+void EditorClientImpl::pageDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+bool EditorClientImpl::shouldShowDeleteInterface(HTMLElement* elem)
+{
+ // Normally, we don't care to show WebCore's deletion UI, so we only enable
+ // it if in testing mode and the test specifically requests it by using this
+ // magic class name.
+ return layoutTestMode()
+ && elem->getAttribute(HTMLNames::classAttr) == "needsDeletionUI";
+}
+
+bool EditorClientImpl::smartInsertDeleteEnabled()
+{
+ if (m_webView->client())
+ return m_webView->client()->isSmartInsertDeleteEnabled();
+ return true;
+}
+
+bool EditorClientImpl::isSelectTrailingWhitespaceEnabled()
+{
+ if (m_webView->client())
+ return m_webView->client()->isSelectTrailingWhitespaceEnabled();
+#if OS(WINDOWS)
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool EditorClientImpl::shouldSpellcheckByDefault()
+{
+ // Spellcheck should be enabled for all editable areas (such as textareas,
+ // contentEditable regions, and designMode docs), except text inputs.
+ const Frame* frame = m_webView->focusedWebCoreFrame();
+ if (!frame)
+ return false;
+ const Editor* editor = frame->editor();
+ if (!editor)
+ return false;
+ if (editor->isSpellCheckingEnabledInFocusedNode())
+ return true;
+ const Document* document = frame->document();
+ if (!document)
+ return false;
+ const Node* node = document->focusedNode();
+ // If |node| is null, we default to allowing spellchecking. This is done in
+ // order to mitigate the issue when the user clicks outside the textbox, as a
+ // result of which |node| becomes null, resulting in all the spell check
+ // markers being deleted. Also, the Frame will decide not to do spellchecking
+ // if the user can't edit - so returning true here will not cause any problems
+ // to the Frame's behavior.
+ if (!node)
+ return true;
+ const RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return false;
+
+ return !renderer->isTextField();
+}
+
+bool EditorClientImpl::isContinuousSpellCheckingEnabled()
+{
+ if (m_spellCheckThisFieldStatus == SpellCheckForcedOff)
+ return false;
+ if (m_spellCheckThisFieldStatus == SpellCheckForcedOn)
+ return true;
+ return shouldSpellcheckByDefault();
+}
+
+void EditorClientImpl::toggleContinuousSpellChecking()
+{
+ if (isContinuousSpellCheckingEnabled())
+ m_spellCheckThisFieldStatus = SpellCheckForcedOff;
+ else
+ m_spellCheckThisFieldStatus = SpellCheckForcedOn;
+
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(
+ m_webView->focusedWebCoreFrame());
+ if (webframe)
+ webframe->client()->didToggleContinuousSpellChecking(webframe);
+}
+
+bool EditorClientImpl::isGrammarCheckingEnabled()
+{
+ return false;
+}
+
+void EditorClientImpl::toggleGrammarChecking()
+{
+ notImplemented();
+}
+
+int EditorClientImpl::spellCheckerDocumentTag()
+{
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool EditorClientImpl::isEditable()
+{
+ return false;
+}
+
+bool EditorClientImpl::shouldBeginEditing(Range* range)
+{
+ if (m_webView->client())
+ return m_webView->client()->shouldBeginEditing(WebRange(range));
+ return true;
+}
+
+bool EditorClientImpl::shouldEndEditing(Range* range)
+{
+ if (m_webView->client())
+ return m_webView->client()->shouldEndEditing(WebRange(range));
+ return true;
+}
+
+bool EditorClientImpl::shouldInsertNode(Node* node,
+ Range* range,
+ EditorInsertAction action)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->shouldInsertNode(WebNode(node),
+ WebRange(range),
+ static_cast<WebEditingAction>(action));
+ }
+ return true;
+}
+
+bool EditorClientImpl::shouldInsertText(const String& text,
+ Range* range,
+ EditorInsertAction action)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->shouldInsertText(WebString(text),
+ WebRange(range),
+ static_cast<WebEditingAction>(action));
+ }
+ return true;
+}
+
+
+bool EditorClientImpl::shouldDeleteRange(Range* range)
+{
+ if (m_webView->client())
+ return m_webView->client()->shouldDeleteRange(WebRange(range));
+ return true;
+}
+
+bool EditorClientImpl::shouldChangeSelectedRange(Range* fromRange,
+ Range* toRange,
+ EAffinity affinity,
+ bool stillSelecting)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->shouldChangeSelectedRange(WebRange(fromRange),
+ WebRange(toRange),
+ static_cast<WebTextAffinity>(affinity),
+ stillSelecting);
+ }
+ return true;
+}
+
+bool EditorClientImpl::shouldApplyStyle(CSSStyleDeclaration* style,
+ Range* range)
+{
+ if (m_webView->client()) {
+ // FIXME: Pass a reference to the CSSStyleDeclaration somehow.
+ return m_webView->client()->shouldApplyStyle(WebString(),
+ WebRange(range));
+ }
+ return true;
+}
+
+bool EditorClientImpl::shouldMoveRangeAfterDelete(Range* range,
+ Range* rangeToBeReplaced)
+{
+ return true;
+}
+
+void EditorClientImpl::didBeginEditing()
+{
+ if (m_webView->client())
+ m_webView->client()->didBeginEditing();
+}
+
+void EditorClientImpl::respondToChangedSelection()
+{
+ if (m_webView->client()) {
+ Frame* frame = m_webView->focusedWebCoreFrame();
+ if (frame)
+ m_webView->client()->didChangeSelection(!frame->selection()->isRange());
+ }
+}
+
+void EditorClientImpl::respondToChangedContents()
+{
+ if (m_webView->client())
+ m_webView->client()->didChangeContents();
+}
+
+void EditorClientImpl::didEndEditing()
+{
+ if (m_webView->client())
+ m_webView->client()->didEndEditing();
+}
+
+void EditorClientImpl::didWriteSelectionToPasteboard()
+{
+}
+
+void EditorClientImpl::didSetSelectionTypesForPasteboard()
+{
+}
+
+void EditorClientImpl::registerCommandForUndo(PassRefPtr<EditCommand> command)
+{
+ if (m_undoStack.size() == maximumUndoStackDepth)
+ m_undoStack.removeFirst(); // drop oldest item off the far end
+ if (!m_inRedo)
+ m_redoStack.clear();
+ m_undoStack.append(command);
+}
+
+void EditorClientImpl::registerCommandForRedo(PassRefPtr<EditCommand> command)
+{
+ m_redoStack.append(command);
+}
+
+void EditorClientImpl::clearUndoRedoOperations()
+{
+ m_undoStack.clear();
+ m_redoStack.clear();
+}
+
+bool EditorClientImpl::canUndo() const
+{
+ return !m_undoStack.isEmpty();
+}
+
+bool EditorClientImpl::canRedo() const
+{
+ return !m_redoStack.isEmpty();
+}
+
+void EditorClientImpl::undo()
+{
+ if (canUndo()) {
+ EditCommandStack::iterator back = --m_undoStack.end();
+ RefPtr<EditCommand> command(*back);
+ m_undoStack.remove(back);
+ command->unapply();
+ // unapply will call us back to push this command onto the redo stack.
+ }
+}
+
+void EditorClientImpl::redo()
+{
+ if (canRedo()) {
+ EditCommandStack::iterator back = --m_redoStack.end();
+ RefPtr<EditCommand> command(*back);
+ m_redoStack.remove(back);
+
+ ASSERT(!m_inRedo);
+ m_inRedo = true;
+ command->reapply();
+ // reapply will call us back to push this command onto the undo stack.
+ m_inRedo = false;
+ }
+}
+
+//
+// The below code was adapted from the WebKit file webview.cpp
+//
+
+static const unsigned CtrlKey = 1 << 0;
+static const unsigned AltKey = 1 << 1;
+static const unsigned ShiftKey = 1 << 2;
+static const unsigned MetaKey = 1 << 3;
+#if OS(DARWIN)
+// Aliases for the generic key defintions to make kbd shortcuts definitions more
+// readable on OS X.
+static const unsigned OptionKey = AltKey;
+
+// Do not use this constant for anything but cursor movement commands. Keys
+// with cmd set have their |isSystemKey| bit set, so chances are the shortcut
+// will not be executed. Another, less important, reason is that shortcuts
+// defined in the renderer do not blink the menu item that they triggered. See
+// http://crbug.com/25856 and the bugs linked from there for details.
+static const unsigned CommandKey = MetaKey;
+#endif
+
+// Keys with special meaning. These will be delegated to the editor using
+// the execCommand() method
+struct KeyDownEntry {
+ unsigned virtualKey;
+ unsigned modifiers;
+ const char* name;
+};
+
+struct KeyPressEntry {
+ unsigned charCode;
+ unsigned modifiers;
+ const char* name;
+};
+
+static const KeyDownEntry keyDownEntries[] = {
+ { VKEY_LEFT, 0, "MoveLeft" },
+ { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" },
+#if OS(DARWIN)
+ { VKEY_LEFT, OptionKey, "MoveWordLeft" },
+ { VKEY_LEFT, OptionKey | ShiftKey,
+ "MoveWordLeftAndModifySelection" },
+#else
+ { VKEY_LEFT, CtrlKey, "MoveWordLeft" },
+ { VKEY_LEFT, CtrlKey | ShiftKey,
+ "MoveWordLeftAndModifySelection" },
+#endif
+ { VKEY_RIGHT, 0, "MoveRight" },
+ { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" },
+#if OS(DARWIN)
+ { VKEY_RIGHT, OptionKey, "MoveWordRight" },
+ { VKEY_RIGHT, OptionKey | ShiftKey,
+ "MoveWordRightAndModifySelection" },
+#else
+ { VKEY_RIGHT, CtrlKey, "MoveWordRight" },
+ { VKEY_RIGHT, CtrlKey | ShiftKey,
+ "MoveWordRightAndModifySelection" },
+#endif
+ { VKEY_UP, 0, "MoveUp" },
+ { VKEY_UP, ShiftKey, "MoveUpAndModifySelection" },
+ { VKEY_PRIOR, ShiftKey, "MovePageUpAndModifySelection" },
+ { VKEY_DOWN, 0, "MoveDown" },
+ { VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" },
+ { VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" },
+#if !OS(DARWIN)
+ { VKEY_PRIOR, 0, "MovePageUp" },
+ { VKEY_NEXT, 0, "MovePageDown" },
+#endif
+ { VKEY_HOME, 0, "MoveToBeginningOfLine" },
+ { VKEY_HOME, ShiftKey,
+ "MoveToBeginningOfLineAndModifySelection" },
+#if OS(DARWIN)
+ { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" },
+ { VKEY_LEFT, CommandKey | ShiftKey,
+ "MoveToBeginningOfLineAndModifySelection" },
+ { VKEY_PRIOR, OptionKey, "MovePageUp" },
+ { VKEY_NEXT, OptionKey, "MovePageDown" },
+#endif
+#if OS(DARWIN)
+ { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" },
+ { VKEY_UP, CommandKey | ShiftKey,
+ "MoveToBeginningOfDocumentAndModifySelection" },
+#else
+ { VKEY_HOME, CtrlKey, "MoveToBeginningOfDocument" },
+ { VKEY_HOME, CtrlKey | ShiftKey,
+ "MoveToBeginningOfDocumentAndModifySelection" },
+#endif
+ { VKEY_END, 0, "MoveToEndOfLine" },
+ { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" },
+#if OS(DARWIN)
+ { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" },
+ { VKEY_DOWN, CommandKey | ShiftKey,
+ "MoveToEndOfDocumentAndModifySelection" },
+#else
+ { VKEY_END, CtrlKey, "MoveToEndOfDocument" },
+ { VKEY_END, CtrlKey | ShiftKey,
+ "MoveToEndOfDocumentAndModifySelection" },
+#endif
+#if OS(DARWIN)
+ { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" },
+ { VKEY_RIGHT, CommandKey | ShiftKey,
+ "MoveToEndOfLineAndModifySelection" },
+#endif
+ { VKEY_BACK, 0, "DeleteBackward" },
+ { VKEY_BACK, ShiftKey, "DeleteBackward" },
+ { VKEY_DELETE, 0, "DeleteForward" },
+#if OS(DARWIN)
+ { VKEY_BACK, OptionKey, "DeleteWordBackward" },
+ { VKEY_DELETE, OptionKey, "DeleteWordForward" },
+#else
+ { VKEY_BACK, CtrlKey, "DeleteWordBackward" },
+ { VKEY_DELETE, CtrlKey, "DeleteWordForward" },
+#endif
+ { 'B', CtrlKey, "ToggleBold" },
+ { 'I', CtrlKey, "ToggleItalic" },
+ { 'U', CtrlKey, "ToggleUnderline" },
+ { VKEY_ESCAPE, 0, "Cancel" },
+ { VKEY_OEM_PERIOD, CtrlKey, "Cancel" },
+ { VKEY_TAB, 0, "InsertTab" },
+ { VKEY_TAB, ShiftKey, "InsertBacktab" },
+ { VKEY_RETURN, 0, "InsertNewline" },
+ { VKEY_RETURN, CtrlKey, "InsertNewline" },
+ { VKEY_RETURN, AltKey, "InsertNewline" },
+ { VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" },
+ { VKEY_RETURN, ShiftKey, "InsertLineBreak" },
+ { VKEY_INSERT, CtrlKey, "Copy" },
+ { VKEY_INSERT, ShiftKey, "Paste" },
+ { VKEY_DELETE, ShiftKey, "Cut" },
+#if !OS(DARWIN)
+ // On OS X, we pipe these back to the browser, so that it can do menu item
+ // blinking.
+ { 'C', CtrlKey, "Copy" },
+ { 'V', CtrlKey, "Paste" },
+ { 'V', CtrlKey | ShiftKey, "PasteAndMatchStyle" },
+ { 'X', CtrlKey, "Cut" },
+ { 'A', CtrlKey, "SelectAll" },
+ { 'Z', CtrlKey, "Undo" },
+ { 'Z', CtrlKey | ShiftKey, "Redo" },
+ { 'Y', CtrlKey, "Redo" },
+#endif
+};
+
+static const KeyPressEntry keyPressEntries[] = {
+ { '\t', 0, "InsertTab" },
+ { '\t', ShiftKey, "InsertBacktab" },
+ { '\r', 0, "InsertNewline" },
+ { '\r', CtrlKey, "InsertNewline" },
+ { '\r', ShiftKey, "InsertLineBreak" },
+ { '\r', AltKey, "InsertNewline" },
+ { '\r', AltKey | ShiftKey, "InsertNewline" },
+};
+
+const char* EditorClientImpl::interpretKeyEvent(const KeyboardEvent* evt)
+{
+ const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
+ if (!keyEvent)
+ return "";
+
+ static HashMap<int, const char*>* keyDownCommandsMap = 0;
+ static HashMap<int, const char*>* keyPressCommandsMap = 0;
+
+ if (!keyDownCommandsMap) {
+ keyDownCommandsMap = new HashMap<int, const char*>;
+ keyPressCommandsMap = new HashMap<int, const char*>;
+
+ for (unsigned i = 0; i < arraysize(keyDownEntries); i++) {
+ keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey,
+ keyDownEntries[i].name);
+ }
+
+ for (unsigned i = 0; i < arraysize(keyPressEntries); i++) {
+ keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode,
+ keyPressEntries[i].name);
+ }
+ }
+
+ unsigned modifiers = 0;
+ if (keyEvent->shiftKey())
+ modifiers |= ShiftKey;
+ if (keyEvent->altKey())
+ modifiers |= AltKey;
+ if (keyEvent->ctrlKey())
+ modifiers |= CtrlKey;
+ if (keyEvent->metaKey())
+ modifiers |= MetaKey;
+
+ if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+ int mapKey = modifiers << 16 | evt->keyCode();
+ return mapKey ? keyDownCommandsMap->get(mapKey) : 0;
+ }
+
+ int mapKey = modifiers << 16 | evt->charCode();
+ return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
+}
+
+bool EditorClientImpl::handleEditingKeyboardEvent(KeyboardEvent* evt)
+{
+ const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
+ // do not treat this as text input if it's a system key event
+ if (!keyEvent || keyEvent->isSystemKey())
+ return false;
+
+ Frame* frame = evt->target()->toNode()->document()->frame();
+ if (!frame)
+ return false;
+
+ String commandName = interpretKeyEvent(evt);
+ Editor::Command command = frame->editor()->command(commandName);
+
+ if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+ // WebKit doesn't have enough information about mode to decide how
+ // commands that just insert text if executed via Editor should be treated,
+ // so we leave it upon WebCore to either handle them immediately
+ // (e.g. Tab that changes focus) or let a keypress event be generated
+ // (e.g. Tab that inserts a Tab character, or Enter).
+ if (command.isTextInsertion() || commandName.isEmpty())
+ return false;
+ if (command.execute(evt)) {
+ if (m_webView->client())
+ m_webView->client()->didExecuteCommand(WebString(commandName));
+ return true;
+ }
+ return false;
+ }
+
+ if (command.execute(evt)) {
+ if (m_webView->client())
+ m_webView->client()->didExecuteCommand(WebString(commandName));
+ return true;
+ }
+
+ // Here we need to filter key events.
+ // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>.
+ // In Webkit, EditorClient::handleKeyboardEvent in
+ // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events.
+ // On Mac, it emits key events with ASCII text and meta on for Command-<x>.
+ // These key events should not emit text insert event.
+ // Alt key would be used to insert alternative character, so we should let
+ // through. Also note that Ctrl-Alt combination equals to AltGr key which is
+ // also used to insert alternative character.
+ // http://code.google.com/p/chromium/issues/detail?id=10846
+ // Windows sets both alt and meta are on when "Alt" key pressed.
+ // http://code.google.com/p/chromium/issues/detail?id=2215
+ // Also, we should not rely on an assumption that keyboards don't
+ // send ASCII characters when pressing a control key on Windows,
+ // which may be configured to do it so by user.
+ // See also http://en.wikipedia.org/wiki/Keyboard_Layout
+ // FIXME(ukai): investigate more detail for various keyboard layout.
+ if (evt->keyEvent()->text().length() == 1) {
+ UChar ch = evt->keyEvent()->text()[0U];
+
+ // Don't insert null or control characters as they can result in
+ // unexpected behaviour
+ if (ch < ' ')
+ return false;
+#if !OS(WINDOWS)
+ // Don't insert ASCII character if ctrl w/o alt or meta is on.
+ // On Mac, we should ignore events when meta is on (Command-<x>).
+ if (ch < 0x80) {
+ if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey())
+ return false;
+#if OS(DARWIN)
+ if (evt->keyEvent()->metaKey())
+ return false;
+#endif
+ }
+#endif
+ }
+
+ if (!frame->editor()->canEdit())
+ return false;
+
+ return frame->editor()->insertText(evt->keyEvent()->text(), evt);
+}
+
+void EditorClientImpl::handleKeyboardEvent(KeyboardEvent* evt)
+{
+ if (evt->keyCode() == VKEY_DOWN
+ || evt->keyCode() == VKEY_UP) {
+ ASSERT(evt->target()->toNode());
+ showFormAutofillForNode(evt->target()->toNode());
+ }
+
+ // Give the embedder a chance to handle the keyboard event.
+ if ((m_webView->client()
+ && m_webView->client()->handleCurrentKeyboardEvent())
+ || handleEditingKeyboardEvent(evt))
+ evt->setDefaultHandled();
+}
+
+void EditorClientImpl::handleInputMethodKeydown(KeyboardEvent* keyEvent)
+{
+ // We handle IME within chrome.
+}
+
+void EditorClientImpl::textFieldDidBeginEditing(Element* element)
+{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->autoFillClient() && inputElement)
+ m_webView->autoFillClient()->textFieldDidBeginEditing(WebInputElement(inputElement));
+}
+
+void EditorClientImpl::textFieldDidEndEditing(Element* element)
+{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->autoFillClient() && inputElement)
+ m_webView->autoFillClient()->textFieldDidEndEditing(WebInputElement(inputElement));
+
+ // Notification that focus was lost. Be careful with this, it's also sent
+ // when the page is being closed.
+
+ // Cancel any pending DoAutofill call.
+ m_autofillArgs.clear();
+ m_autofillTimer.stop();
+
+ // Hide any showing popup.
+ m_webView->hideAutoFillPopup();
+
+ if (!m_webView->client())
+ return; // The page is getting closed, don't fill the password.
+
+ // Notify any password-listener of the focus change.
+ if (!inputElement)
+ return;
+
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame());
+ if (!webframe)
+ return;
+
+ WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement);
+ if (!listener)
+ return;
+
+ listener->didBlurInputElement(inputElement->value());
+}
+
+void EditorClientImpl::textDidChangeInTextField(Element* element)
+{
+ ASSERT(element->hasLocalName(HTMLNames::inputTag));
+ HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
+ if (m_webView->autoFillClient())
+ m_webView->autoFillClient()->textFieldDidChange(WebInputElement(inputElement));
+
+ // Note that we only show the autofill popup in this case if the caret is at
+ // the end. This matches FireFox and Safari but not IE.
+ autofill(inputElement, false, false, true);
+}
+
+bool EditorClientImpl::showFormAutofillForNode(Node* node)
+{
+ HTMLInputElement* inputElement = toHTMLInputElement(node);
+ if (inputElement)
+ return autofill(inputElement, true, true, false);
+ return false;
+}
+
+bool EditorClientImpl::autofill(HTMLInputElement* inputElement,
+ bool autofillFormOnly,
+ bool autofillOnEmptyValue,
+ bool requireCaretAtEnd)
+{
+ // Cancel any pending DoAutofill call.
+ m_autofillArgs.clear();
+ m_autofillTimer.stop();
+
+ // FIXME: Remove the extraneous isEnabledFormControl call below.
+ // Let's try to trigger autofill for that field, if applicable.
+ if (!inputElement->isEnabledFormControl() || !inputElement->isTextField()
+ || inputElement->isPasswordField() || !inputElement->autoComplete()
+ || !inputElement->isEnabledFormControl()
+ || inputElement->isReadOnlyFormControl())
+ return false;
+
+ WebString name = WebInputElement(inputElement).nameForAutofill();
+ if (name.isEmpty()) // If the field has no name, then we won't have values.
+ return false;
+
+ // Don't attempt to autofill with values that are too large.
+ if (inputElement->value().length() > maximumTextSizeForAutofill)
+ return false;
+
+ m_autofillArgs = new AutofillArgs();
+ m_autofillArgs->inputElement = inputElement;
+ m_autofillArgs->autofillFormOnly = autofillFormOnly;
+ m_autofillArgs->autofillOnEmptyValue = autofillOnEmptyValue;
+ m_autofillArgs->requireCaretAtEnd = requireCaretAtEnd;
+ m_autofillArgs->backspaceOrDeletePressed = m_backspaceOrDeletePressed;
+
+ if (!requireCaretAtEnd)
+ doAutofill(0);
+ else {
+ // We post a task for doing the autofill as the caret position is not set
+ // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976)
+ // and we need it to determine whether or not to trigger autofill.
+ m_autofillTimer.startOneShot(0.0);
+ }
+ return true;
+}
+
+void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer)
+{
+ OwnPtr<AutofillArgs> args(m_autofillArgs.release());
+ HTMLInputElement* inputElement = args->inputElement.get();
+
+ const String& value = inputElement->value();
+
+ // Enforce autofill_on_empty_value and caret_at_end.
+
+ bool isCaretAtEnd = true;
+ if (args->requireCaretAtEnd)
+ isCaretAtEnd = inputElement->selectionStart() == inputElement->selectionEnd()
+ && inputElement->selectionEnd() == static_cast<int>(value.length());
+
+ if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) {
+ m_webView->hideAutoFillPopup();
+ return;
+ }
+
+ // First let's see if there is a password listener for that element.
+ // We won't trigger form autofill in that case, as having both behavior on
+ // a node would be confusing.
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame());
+ if (!webframe)
+ return;
+ WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement);
+ if (listener) {
+ if (args->autofillFormOnly)
+ return;
+
+ listener->performInlineAutocomplete(value,
+ args->backspaceOrDeletePressed,
+ true);
+ return;
+ }
+}
+
+void EditorClientImpl::cancelPendingAutofill()
+{
+ m_autofillArgs.clear();
+ m_autofillTimer.stop();
+}
+
+void EditorClientImpl::onAutocompleteSuggestionAccepted(HTMLInputElement* textField)
+{
+ if (m_webView->autoFillClient())
+ m_webView->autoFillClient()->didAcceptAutocompleteSuggestion(WebInputElement(textField));
+
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(textField->document()->frame());
+ if (!webframe)
+ return;
+
+ webframe->notifiyPasswordListenerOfAutocomplete(WebInputElement(textField));
+}
+
+bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element,
+ KeyboardEvent* event)
+{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->autoFillClient() && inputElement) {
+ m_webView->autoFillClient()->textFieldDidReceiveKeyDown(WebInputElement(inputElement),
+ WebKeyboardEventBuilder(*event));
+ }
+
+ // Remember if backspace was pressed for the autofill. It is not clear how to
+ // find if backspace was pressed from textFieldDidBeginEditing and
+ // textDidChangeInTextField as when these methods are called the value of the
+ // input element already contains the type character.
+ m_backspaceOrDeletePressed = event->keyCode() == VKEY_BACK || event->keyCode() == VKEY_DELETE;
+
+ // The Mac code appears to use this method as a hook to implement special
+ // keyboard commands specific to Safari's auto-fill implementation. We
+ // just return false to allow the default action.
+ return false;
+}
+
+void EditorClientImpl::textWillBeDeletedInTextField(Element*)
+{
+}
+
+void EditorClientImpl::textDidChangeInTextArea(Element*)
+{
+}
+
+void EditorClientImpl::ignoreWordInSpellDocument(const String&)
+{
+ notImplemented();
+}
+
+void EditorClientImpl::learnWord(const String&)
+{
+ notImplemented();
+}
+
+void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
+ int* misspellingLocation,
+ int* misspellingLength)
+{
+ // SpellCheckWord will write (0, 0) into the output vars, which is what our
+ // caller expects if the word is spelled correctly.
+ int spellLocation = -1;
+ int spellLength = 0;
+
+ // Check to see if the provided text is spelled correctly.
+ if (isContinuousSpellCheckingEnabled() && m_webView->client())
+ m_webView->client()->spellCheck(WebString(text, length), spellLocation, spellLength);
+ else {
+ spellLocation = 0;
+ spellLength = 0;
+ }
+
+ // Note: the Mac code checks if the pointers are null before writing to them,
+ // so we do too.
+ if (misspellingLocation)
+ *misspellingLocation = spellLocation;
+ if (misspellingLength)
+ *misspellingLength = spellLength;
+}
+
+String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord)
+{
+ if (!(isContinuousSpellCheckingEnabled() && m_webView->client()))
+ return String();
+
+ // Do not autocorrect words with capital letters in it except the
+ // first letter. This will remove cases changing "IMB" to "IBM".
+ for (size_t i = 1; i < misspelledWord.length(); i++) {
+ if (u_isupper(static_cast<UChar32>(misspelledWord[i])))
+ return String();
+ }
+
+ return m_webView->client()->autoCorrectWord(WebString(misspelledWord));
+}
+
+void EditorClientImpl::checkGrammarOfString(const UChar*, int length,
+ WTF::Vector<GrammarDetail>&,
+ int* badGrammarLocation,
+ int* badGrammarLength)
+{
+ notImplemented();
+ if (badGrammarLocation)
+ *badGrammarLocation = 0;
+ if (badGrammarLength)
+ *badGrammarLength = 0;
+}
+
+void EditorClientImpl::updateSpellingUIWithGrammarString(const String&,
+ const GrammarDetail& detail)
+{
+ notImplemented();
+}
+
+void EditorClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ if (m_webView->client())
+ m_webView->client()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord));
+}
+
+void EditorClientImpl::showSpellingUI(bool show)
+{
+ if (m_webView->client())
+ m_webView->client()->showSpellingUI(show);
+}
+
+bool EditorClientImpl::spellingUIIsShowing()
+{
+ if (m_webView->client())
+ return m_webView->client()->isShowingSpellingUI();
+ return false;
+}
+
+void EditorClientImpl::getGuessesForWord(const String& word,
+ const String& context,
+ WTF::Vector<String>& guesses)
+{
+ notImplemented();
+}
+
+void EditorClientImpl::willSetInputMethodState()
+{
+ if (m_webView->client())
+ m_webView->client()->resetInputMethod();
+}
+
+void EditorClientImpl::setInputMethodState(bool)
+{
+}
+
+} // namesace WebKit
diff --git a/Source/WebKit/chromium/src/EditorClientImpl.h b/Source/WebKit/chromium/src/EditorClientImpl.h
new file mode 100644
index 0000000..9dbd6af
--- /dev/null
+++ b/Source/WebKit/chromium/src/EditorClientImpl.h
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EditorClientImpl_h
+#define EditorClientImpl_h
+
+#include "EditorClient.h"
+#include "Timer.h"
+#include <wtf/Deque.h>
+
+namespace WebCore {
+class HTMLInputElement;
+}
+
+namespace WebKit {
+class WebViewImpl;
+
+class EditorClientImpl : public WebCore::EditorClient {
+public:
+ EditorClientImpl(WebViewImpl* webView);
+
+ virtual ~EditorClientImpl();
+ virtual void pageDestroyed();
+
+ virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*);
+ virtual bool smartInsertDeleteEnabled();
+ virtual bool isSelectTrailingWhitespaceEnabled();
+ virtual bool isContinuousSpellCheckingEnabled();
+ virtual void toggleContinuousSpellChecking();
+ virtual bool isGrammarCheckingEnabled();
+ virtual void toggleGrammarChecking();
+ virtual int spellCheckerDocumentTag();
+ virtual bool isEditable();
+ virtual bool shouldBeginEditing(WebCore::Range*);
+ virtual bool shouldEndEditing(WebCore::Range*);
+ virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction);
+ virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction);
+ virtual bool shouldDeleteRange(WebCore::Range*);
+ virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange,
+ WebCore::Range* toRange,
+ WebCore::EAffinity,
+ bool stillSelecting);
+ virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
+ virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*);
+ virtual void didBeginEditing();
+ virtual void respondToChangedContents();
+ virtual void respondToChangedSelection();
+ virtual void didEndEditing();
+ virtual void didWriteSelectionToPasteboard();
+ virtual void didSetSelectionTypesForPasteboard();
+ virtual void registerCommandForUndo(PassRefPtr<WebCore::EditCommand>);
+ virtual void registerCommandForRedo(PassRefPtr<WebCore::EditCommand>);
+ virtual void clearUndoRedoOperations();
+ virtual bool canUndo() const;
+ virtual bool canRedo() const;
+ virtual void undo();
+ virtual void redo();
+ virtual const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
+ virtual bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
+ virtual void handleKeyboardEvent(WebCore::KeyboardEvent*);
+ virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*);
+ virtual void textFieldDidBeginEditing(WebCore::Element*);
+ virtual void textFieldDidEndEditing(WebCore::Element*);
+ virtual void textDidChangeInTextField(WebCore::Element*);
+ virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
+ virtual void textWillBeDeletedInTextField(WebCore::Element*);
+ virtual void textDidChangeInTextArea(WebCore::Element*);
+ virtual void ignoreWordInSpellDocument(const WTF::String&);
+ virtual void learnWord(const WTF::String&);
+ virtual void checkSpellingOfString(const UChar*, int length,
+ int* misspellingLocation,
+ int* misspellingLength);
+ virtual void checkGrammarOfString(const UChar*, int length,
+ WTF::Vector<WebCore::GrammarDetail>&,
+ int* badGrammarLocation,
+ int* badGrammarLength);
+ virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&);
+ virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&);
+ virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
+ virtual void showSpellingUI(bool show);
+ virtual bool spellingUIIsShowing();
+ virtual void getGuessesForWord(const WTF::String& word,
+ const WTF::String& context,
+ WTF::Vector<WTF::String>& guesses);
+ virtual void willSetInputMethodState();
+ virtual void setInputMethodState(bool enabled);
+ virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&) {}
+
+ // Shows the form autofill popup for |node| if it is an HTMLInputElement and
+ // it is empty. This is called when you press the up or down arrow in a
+ // text-field or when clicking an already focused text-field.
+ // Returns true if the autofill popup has been scheduled to be shown, false
+ // otherwise.
+ virtual bool showFormAutofillForNode(WebCore::Node*);
+
+ // Notification that the text changed due to acceptance of a suggestion
+ // provided by an Autocomplete popup. Having a separate callback in this
+ // case is a simple way to break the cycle that would otherwise occur if
+ // textDidChangeInTextField was called.
+ virtual void onAutocompleteSuggestionAccepted(WebCore::HTMLInputElement*);
+
+private:
+ void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*);
+
+ // Triggers autofill for an input element if applicable. This can be form
+ // autofill (via a popup-menu) or password autofill depending on the
+ // input element. If |formAutofillOnly| is true, password autofill is not
+ // triggered.
+ // |autofillOnEmptyValue| indicates whether the autofill should be shown
+ // when the text-field is empty.
+ // If |requiresCaretAtEnd| is true, the autofill popup is only shown if the
+ // caret is located at the end of the entered text.
+ // Returns true if the autofill popup has been scheduled to be shown, false
+ // otherwise.
+ bool autofill(WebCore::HTMLInputElement*,
+ bool formAutofillOnly, bool autofillOnEmptyValue,
+ bool requiresCaretAtEnd);
+
+ // Called to process the autofill described by m_autofillArgs.
+ // This method is invoked asynchronously if the caret position is not
+ // reflecting the last text change yet, and we need it to decide whether or
+ // not to show the autofill popup.
+ void doAutofill(WebCore::Timer<EditorClientImpl>*);
+
+ void cancelPendingAutofill();
+
+ // Returns whether or not the focused control needs spell-checking.
+ // Currently, this function just retrieves the focused node and determines
+ // whether or not it is a <textarea> element or an element whose
+ // contenteditable attribute is true.
+ // FIXME: Bug 740540: This code just implements the default behavior
+ // proposed in this issue. We should also retrieve "spellcheck" attributes
+ // for text fields and create a flag to over-write the default behavior.
+ bool shouldSpellcheckByDefault();
+
+ WebViewImpl* m_webView;
+ bool m_inRedo;
+
+ typedef Deque<RefPtr<WebCore::EditCommand> > EditCommandStack;
+ EditCommandStack m_undoStack;
+ EditCommandStack m_redoStack;
+
+ // Whether the last entered key was a backspace.
+ bool m_backspaceOrDeletePressed;
+
+ // This flag is set to false if spell check for this editor is manually
+ // turned off. The default setting is SpellCheckAutomatic.
+ enum {
+ SpellCheckAutomatic,
+ SpellCheckForcedOn,
+ SpellCheckForcedOff
+ };
+ int m_spellCheckThisFieldStatus;
+
+ // Used to delay autofill processing.
+ WebCore::Timer<EditorClientImpl> m_autofillTimer;
+
+ struct AutofillArgs {
+ RefPtr<WebCore::HTMLInputElement> inputElement;
+ bool autofillFormOnly;
+ bool autofillOnEmptyValue;
+ bool requireCaretAtEnd;
+ bool backspaceOrDeletePressed;
+ };
+ OwnPtr<AutofillArgs> m_autofillArgs;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/EventListenerWrapper.cpp b/Source/WebKit/chromium/src/EventListenerWrapper.cpp
new file mode 100644
index 0000000..6360932
--- /dev/null
+++ b/Source/WebKit/chromium/src/EventListenerWrapper.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EventListenerWrapper.h"
+
+#include "Event.h"
+#include "EventListener.h"
+
+#include "WebDOMEvent.h"
+#include "WebDOMEventListener.h"
+
+namespace WebKit {
+
+EventListenerWrapper::EventListenerWrapper(WebDOMEventListener* webDOMEventListener)
+ : EventListener(EventListener::NativeEventListenerType)
+ , m_webDOMEventListener(webDOMEventListener)
+{
+}
+
+EventListenerWrapper::~EventListenerWrapper()
+{
+ if (m_webDOMEventListener)
+ m_webDOMEventListener->notifyEventListenerDeleted(this);
+}
+
+bool EventListenerWrapper::operator==(const EventListener& listener)
+{
+ return this == &listener;
+}
+
+void EventListenerWrapper::handleEvent(ScriptExecutionContext* context, Event* event)
+{
+ if (!m_webDOMEventListener)
+ return;
+ WebDOMEvent webDOMEvent(event);
+ m_webDOMEventListener->handleEvent(webDOMEvent);
+}
+
+void EventListenerWrapper::webDOMEventListenerDeleted()
+{
+ m_webDOMEventListener = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/EventListenerWrapper.h b/Source/WebKit/chromium/src/EventListenerWrapper.h
new file mode 100644
index 0000000..75b6a95
--- /dev/null
+++ b/Source/WebKit/chromium/src/EventListenerWrapper.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EventListenerWrapper_h
+#define EventListenerWrapper_h
+
+#include "EventListener.h"
+
+namespace WebCore {
+class ScriptExecutionContext;
+}
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebDOMEventListener;
+
+// FIXME: Remove the DeprecatedEventListenerWrapper class below once Chromium
+// switched to using WebDOMEvent.
+class EventListenerWrapper : public EventListener {
+public:
+ EventListenerWrapper(WebDOMEventListener*);
+ ~EventListenerWrapper();
+
+ virtual bool operator==(const EventListener&);
+ virtual void handleEvent(ScriptExecutionContext*, Event*);
+
+ void webDOMEventListenerDeleted();
+
+private:
+ WebDOMEventListener* m_webDOMEventListener;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/Extensions3DChromium.cpp b/Source/WebKit/chromium/src/Extensions3DChromium.cpp
new file mode 100644
index 0000000..ca2215e
--- /dev/null
+++ b/Source/WebKit/chromium/src/Extensions3DChromium.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "Extensions3DChromium.h"
+
+#include "GraphicsContext3D.h"
+#include "GraphicsContext3DInternal.h"
+
+namespace WebCore {
+
+Extensions3DChromium::Extensions3DChromium(GraphicsContext3DInternal* internal)
+ : m_internal(internal)
+{
+}
+
+Extensions3DChromium::~Extensions3DChromium()
+{
+}
+
+bool Extensions3DChromium::supports(const String& name)
+{
+ return m_internal->supportsExtension(name);
+}
+
+void Extensions3DChromium::ensureEnabled(const String& name)
+{
+#ifndef NDEBUG
+ bool result =
+#endif
+ m_internal->ensureExtensionEnabled(name);
+ ASSERT(result);
+}
+
+int Extensions3DChromium::getGraphicsResetStatusARB()
+{
+ return m_internal->isContextLost() ? static_cast<int>(Extensions3D::UNKNOWN_CONTEXT_RESET_ARB) : static_cast<int>(GraphicsContext3D::NO_ERROR);
+}
+
+void* Extensions3DChromium::mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access)
+{
+ return m_internal->mapBufferSubDataCHROMIUM(target, offset, size, access);
+}
+
+void Extensions3DChromium::unmapBufferSubDataCHROMIUM(const void* data)
+{
+ m_internal->unmapBufferSubDataCHROMIUM(data);
+}
+
+void* Extensions3DChromium::mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int yoffset, int width, int height, unsigned format, unsigned type, unsigned access)
+{
+ return m_internal->mapTexSubImage2DCHROMIUM(target, level, xoffset, yoffset, width, height, format, type, access);
+}
+
+void Extensions3DChromium::unmapTexSubImage2DCHROMIUM(const void* data)
+{
+ m_internal->unmapTexSubImage2DCHROMIUM(data);
+}
+
+void Extensions3DChromium::copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture)
+{
+ m_internal->copyTextureToParentTextureCHROMIUM(texture, parentTexture);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/Source/WebKit/chromium/src/ExternalPopupMenu.cpp b/Source/WebKit/chromium/src/ExternalPopupMenu.cpp
new file mode 100644
index 0000000..f7f9862
--- /dev/null
+++ b/Source/WebKit/chromium/src/ExternalPopupMenu.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ExternalPopupMenu.h"
+
+#include "FrameView.h"
+#include "IntPoint.h"
+#include "PopupMenuClient.h"
+#include "TextDirection.h"
+#include "WebExternalPopupMenu.h"
+#include "WebMenuItemInfo.h"
+#include "WebPopupMenuInfo.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ExternalPopupMenu::ExternalPopupMenu(PopupMenuClient* popupMenuClient,
+ WebViewClient* webViewClient)
+ : m_popupMenuClient(popupMenuClient)
+ , m_webViewClient(webViewClient)
+ , m_webExternalPopupMenu(0)
+{
+}
+
+ExternalPopupMenu::~ExternalPopupMenu()
+{
+}
+
+void ExternalPopupMenu::show(const IntRect& rect, FrameView* v, int index)
+{
+ // WebCore reuses the PopupMenu of a page.
+ // For simplicity, we do recreate the actual external popup everytime.
+ hide();
+
+ WebPopupMenuInfo info;
+ getPopupMenuInfo(&info);
+ if (info.items.isEmpty())
+ return;
+ m_webExternalPopupMenu =
+ m_webViewClient->createExternalPopupMenu(info, this);
+ m_webExternalPopupMenu->show(v->contentsToWindow(rect));
+}
+
+void ExternalPopupMenu::hide()
+{
+ if (m_popupMenuClient)
+ m_popupMenuClient->popupDidHide();
+ if (!m_webExternalPopupMenu)
+ return;
+ m_webExternalPopupMenu->close();
+ m_webExternalPopupMenu = 0;
+}
+
+void ExternalPopupMenu::updateFromElement()
+{
+}
+
+void ExternalPopupMenu::disconnectClient()
+{
+ hide();
+ m_popupMenuClient = 0;
+}
+
+void ExternalPopupMenu::didChangeSelection(int index)
+{
+ if (m_popupMenuClient)
+ m_popupMenuClient->selectionChanged(index);
+}
+
+void ExternalPopupMenu::didAcceptIndex(int index)
+{
+ // Calling methods on the PopupMenuClient might lead to this object being
+ // derefed. This ensures it does not get deleted while we are running this
+ // method.
+ RefPtr<ExternalPopupMenu> guard(this);
+
+ if (m_popupMenuClient) {
+ m_popupMenuClient->valueChanged(index);
+ // The call to valueChanged above might have lead to a call to
+ // disconnectClient, so we might not have a PopupMenuClient anymore.
+ if (m_popupMenuClient)
+ m_popupMenuClient->popupDidHide();
+ }
+ m_webExternalPopupMenu = 0;
+}
+
+void ExternalPopupMenu::didCancel()
+{
+ // See comment in didAcceptIndex on why we need this.
+ RefPtr<ExternalPopupMenu> guard(this);
+
+ if (m_popupMenuClient)
+ m_popupMenuClient->popupDidHide();
+ m_webExternalPopupMenu = 0;
+}
+
+void ExternalPopupMenu::getPopupMenuInfo(WebPopupMenuInfo* info)
+{
+ int itemCount = m_popupMenuClient->listSize();
+ WebVector<WebPopupMenuInfo::Item> items(
+ static_cast<size_t>(itemCount));
+ for (int i = 0; i < itemCount; ++i) {
+ WebPopupMenuInfo::Item& popupItem = items[i];
+ popupItem.label = m_popupMenuClient->itemText(i);
+ if (m_popupMenuClient->itemIsSeparator(i))
+ popupItem.type = WebMenuItemInfo::Separator;
+ else if (m_popupMenuClient->itemIsLabel(i))
+ popupItem.type = WebMenuItemInfo::Group;
+ else
+ popupItem.type = WebMenuItemInfo::Option;
+ popupItem.enabled = m_popupMenuClient->itemIsEnabled(i);
+ }
+
+ info->itemHeight = m_popupMenuClient->menuStyle().font().height();
+ info->itemFontSize =
+ static_cast<int>(m_popupMenuClient->menuStyle().font().size());
+ info->selectedIndex = m_popupMenuClient->selectedIndex();
+ info->rightAligned =
+ m_popupMenuClient->menuStyle().textDirection() == WebCore::RTL;
+ info->items.swap(items);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/ExternalPopupMenu.h b/Source/WebKit/chromium/src/ExternalPopupMenu.h
new file mode 100644
index 0000000..6963e8d
--- /dev/null
+++ b/Source/WebKit/chromium/src/ExternalPopupMenu.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ExternalPopupMenu_h
+#define ExternalPopupMenu_h
+
+#include "PopupMenu.h"
+#include "WebExternalPopupMenuClient.h"
+
+namespace WebCore {
+class FrameView;
+class IntRect;
+class PopupMenuClient;
+}
+
+namespace WebKit {
+
+class WebExternalPopupMenu;
+class WebViewClient;
+struct WebPopupMenuInfo;
+
+// The ExternalPopupMenu connects the actual implementation of the popup menu
+// to the WebCore popup menu.
+class ExternalPopupMenu : public WebCore::PopupMenu,
+ public WebExternalPopupMenuClient {
+public:
+ ExternalPopupMenu(WebCore::PopupMenuClient*, WebViewClient*);
+ virtual ~ExternalPopupMenu();
+
+private:
+ // WebCore::PopupMenu methods:
+ virtual void show(const WebCore::IntRect&, WebCore::FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+ // WebExternalPopupClient methods:
+ virtual void didChangeSelection(int index);
+ virtual void didAcceptIndex(int index);
+ virtual void didCancel();
+
+ // Fills |info| with the popup menu information contained in the
+ // WebCore::PopupMenuClient associated with this ExternalPopupMenu.
+ void getPopupMenuInfo(WebPopupMenuInfo* info);
+
+ WebCore::PopupMenuClient* m_popupMenuClient;
+ WebViewClient* m_webViewClient;
+
+ // The actual implementor of the show menu.
+ WebExternalPopupMenu* m_webExternalPopupMenu;
+};
+
+} // namespace WebKit
+
+#endif // ExternalPopupMenu_h
diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
new file mode 100644
index 0000000..b767450
--- /dev/null
+++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
@@ -0,0 +1,1561 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FrameLoaderClientImpl.h"
+
+#include "BackForwardListChromium.h"
+#include "Chrome.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "FormState.h"
+#include "FrameLoader.h"
+#include "FrameLoadRequest.h"
+#include "FrameNetworkingContextImpl.h"
+#include "FrameView.h"
+#include "HTTPParsers.h"
+#include "HistoryItem.h"
+#include "HitTestResult.h"
+#include "HTMLAppletElement.h"
+#include "HTMLFormElement.h" // needed by FormState.h
+#include "HTMLNames.h"
+#include "MIMETypeRegistry.h"
+#include "MouseEvent.h"
+#include "Page.h"
+#include "PlatformString.h"
+#include "PluginData.h"
+#include "PluginDataChromium.h"
+#include "ProgressTracker.h"
+#include "Settings.h"
+#include "StringExtras.h"
+#include "WebDataSourceImpl.h"
+#include "WebDevToolsAgentPrivate.h"
+#include "WebFormElement.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMimeRegistry.h"
+#include "WebNode.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPluginLoadObserver.h"
+#include "WebPluginParams.h"
+#include "WebSecurityOrigin.h"
+#include "WebURL.h"
+#include "WebURLError.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "WindowFeatures.h"
+#include "WrappedResourceRequest.h"
+#include "WrappedResourceResponse.h"
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Domain for internal error codes.
+static const char internalErrorDomain[] = "WebKit";
+
+// An internal error code. Used to note a policy change error resulting from
+// dispatchDecidePolicyForMIMEType not passing the PolicyUse option.
+enum {
+ PolicyChangeError = -10000,
+};
+
+FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame)
+ : m_webFrame(frame)
+ , m_hasRepresentation(false)
+ , m_sentInitialResponseToPlugin(false)
+ , m_nextNavigationPolicy(WebNavigationPolicyIgnore)
+{
+}
+
+FrameLoaderClientImpl::~FrameLoaderClientImpl()
+{
+}
+
+void FrameLoaderClientImpl::frameLoaderDestroyed()
+{
+ // When the WebFrame was created, it had an extra reference given to it on
+ // behalf of the Frame. Since the WebFrame owns us, this extra ref also
+ // serves to keep us alive until the FrameLoader is done with us. The
+ // FrameLoader calls this method when it's going away. Therefore, we balance
+ // out that extra reference, which may cause 'this' to be deleted.
+ m_webFrame->closing();
+ m_webFrame->deref();
+}
+
+void FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didClearWindowObject(m_webFrame);
+
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview->devToolsAgentPrivate())
+ webview->devToolsAgentPrivate()->didClearWindowObject(m_webFrame);
+}
+
+void FrameLoaderClientImpl::documentElementAvailable()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didCreateDocumentElement(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didCreateScriptContextForFrame()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didCreateScriptContext(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didDestroyScriptContextForFrame()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didDestroyScriptContext(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didCreateIsolatedScriptContext()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didCreateIsolatedScriptContext(m_webFrame);
+}
+
+bool FrameLoaderClientImpl::allowScriptExtension(const String& extensionName,
+ int extensionGroup)
+{
+ if (m_webFrame->client())
+ return m_webFrame->client()->allowScriptExtension(m_webFrame, extensionName, extensionGroup);
+ return false;
+}
+
+void FrameLoaderClientImpl::didPerformFirstNavigation() const
+{
+}
+
+void FrameLoaderClientImpl::registerForIconNotification(bool)
+{
+}
+
+void FrameLoaderClientImpl::didChangeScrollOffset()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didChangeScrollOffset(m_webFrame);
+}
+
+bool FrameLoaderClientImpl::allowJavaScript(bool enabledPerSettings)
+{
+ if (m_webFrame->client())
+ return m_webFrame->client()->allowScript(m_webFrame, enabledPerSettings);
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowPlugins(bool enabledPerSettings)
+{
+ if (m_webFrame->client())
+ return m_webFrame->client()->allowPlugins(m_webFrame, enabledPerSettings);
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowImages(bool enabledPerSettings)
+{
+ if (m_webFrame->client())
+ return m_webFrame->client()->allowImages(m_webFrame, enabledPerSettings);
+
+ return enabledPerSettings;
+}
+
+void FrameLoaderClientImpl::didNotAllowScript()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didNotAllowScript(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didNotAllowPlugins()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didNotAllowPlugins(m_webFrame);
+}
+
+bool FrameLoaderClientImpl::hasWebView() const
+{
+ return m_webFrame->viewImpl();
+}
+
+bool FrameLoaderClientImpl::hasFrameView() const
+{
+ // The Mac port has this notion of a WebFrameView, which seems to be
+ // some wrapper around an NSView. Since our equivalent is HWND, I guess
+ // we have a "frameview" whenever we have the toplevel HWND.
+ return m_webFrame->viewImpl();
+}
+
+void FrameLoaderClientImpl::makeDocumentView()
+{
+ m_webFrame->createFrameView();
+}
+
+void FrameLoaderClientImpl::makeRepresentation(DocumentLoader*)
+{
+ m_hasRepresentation = true;
+}
+
+void FrameLoaderClientImpl::forceLayout()
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::forceLayoutForNonHTML()
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::setCopiesOnScroll()
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::detachedFromParent2()
+{
+ // Nothing to do here.
+}
+
+void FrameLoaderClientImpl::detachedFromParent3()
+{
+ // Close down the proxy. The purpose of this change is to make the
+ // call to ScriptController::clearWindowShell a no-op when called from
+ // Frame::pageDestroyed. Without this change, this call to clearWindowShell
+ // will cause a crash. If you remove/modify this, just ensure that you can
+ // go to a page and then navigate to a new page without getting any asserts
+ // or crashes.
+ m_webFrame->frame()->script()->proxy()->clearForClose();
+
+ // Alert the client that the frame is being detached. This is the last
+ // chance we have to communicate with the client.
+ if (m_webFrame->client())
+ m_webFrame->client()->frameDetached(m_webFrame);
+
+ // Stop communicating with the WebFrameClient at this point since we are no
+ // longer associated with the Page.
+ m_webFrame->setClient(0);
+}
+
+// This function is responsible for associating the |identifier| with a given
+// subresource load. The following functions that accept an |identifier| are
+// called for each subresource, so they should not be dispatched to the
+// WebFrame.
+void FrameLoaderClientImpl::assignIdentifierToInitialRequest(
+ unsigned long identifier, DocumentLoader* loader,
+ const ResourceRequest& request)
+{
+ if (m_webFrame->client()) {
+ WrappedResourceRequest webreq(request);
+ m_webFrame->client()->assignIdentifierToRequest(
+ m_webFrame, identifier, webreq);
+ }
+}
+
+// If the request being loaded by |loader| is a frame, update the ResourceType.
+// A subresource in this context is anything other than a frame --
+// this includes images and xmlhttp requests. It is important to note that a
+// subresource is NOT limited to stuff loaded through the frame's subresource
+// loader. Synchronous xmlhttp requests for example, do not go through the
+// subresource loader, but we still label them as TargetIsSubresource.
+//
+// The important edge cases to consider when modifying this function are
+// how synchronous resource loads are treated during load/unload threshold.
+static void setTargetTypeFromLoader(ResourceRequest& request, DocumentLoader* loader)
+{
+ if (loader == loader->frameLoader()->provisionalDocumentLoader()) {
+ ResourceRequest::TargetType type;
+ if (loader->frameLoader()->isLoadingMainFrame())
+ type = ResourceRequest::TargetIsMainFrame;
+ else
+ type = ResourceRequest::TargetIsSubframe;
+ request.setTargetType(type);
+ }
+}
+
+void FrameLoaderClientImpl::dispatchWillSendRequest(
+ DocumentLoader* loader, unsigned long identifier, ResourceRequest& request,
+ const ResourceResponse& redirectResponse)
+{
+ if (loader) {
+ // We want to distinguish between a request for a document to be loaded into
+ // the main frame, a sub-frame, or the sub-objects in that document.
+ setTargetTypeFromLoader(request, loader);
+
+ // Avoid repeating a form submission when navigating back or forward.
+ if (loader == loader->frameLoader()->provisionalDocumentLoader()
+ && request.httpMethod() == "POST"
+ && isBackForwardLoadType(loader->frameLoader()->loadType()))
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+ }
+
+ // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document
+ // with no URL. We don't like that, so we'll rename it to about:blank.
+ if (request.url().isEmpty())
+ request.setURL(KURL(ParsedURLString, "about:blank"));
+ if (request.firstPartyForCookies().isEmpty())
+ request.setFirstPartyForCookies(KURL(ParsedURLString, "about:blank"));
+
+ // Give the WebFrameClient a crack at the request.
+ if (m_webFrame->client()) {
+ WrappedResourceRequest webreq(request);
+ WrappedResourceResponse webresp(redirectResponse);
+ m_webFrame->client()->willSendRequest(
+ m_webFrame, identifier, webreq, webresp);
+ }
+}
+
+bool FrameLoaderClientImpl::shouldUseCredentialStorage(
+ DocumentLoader*, unsigned long identifier)
+{
+ // FIXME
+ // Intended to pass through to a method on the resource load delegate.
+ // If implemented, that method controls whether the browser should ask the
+ // networking layer for a stored default credential for the page (say from
+ // the Mac OS keychain). If the method returns false, the user should be
+ // presented with an authentication challenge whether or not the networking
+ // layer has a credential stored.
+ // This returns true for backward compatibility: the ability to override the
+ // system credential store is new. (Actually, not yet fully implemented in
+ // WebKit, as of this writing.)
+ return true;
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveAuthenticationChallenge(
+ DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::dispatchDidCancelAuthenticationChallenge(
+ DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveResponse(DocumentLoader* loader,
+ unsigned long identifier,
+ const ResourceResponse& response)
+{
+ if (m_webFrame->client()) {
+ WrappedResourceResponse webresp(response);
+ m_webFrame->client()->didReceiveResponse(m_webFrame, identifier, webresp);
+ }
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveContentLength(
+ DocumentLoader* loader,
+ unsigned long identifier,
+ int lengthReceived)
+{
+}
+
+// Called when a particular resource load completes
+void FrameLoaderClientImpl::dispatchDidFinishLoading(DocumentLoader* loader,
+ unsigned long identifier)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didFinishResourceLoad(m_webFrame, identifier);
+}
+
+void FrameLoaderClientImpl::dispatchDidFailLoading(DocumentLoader* loader,
+ unsigned long identifier,
+ const ResourceError& error)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didFailResourceLoad(m_webFrame, identifier, error);
+}
+
+void FrameLoaderClientImpl::dispatchDidFinishDocumentLoad()
+{
+ // A frame may be reused. This call ensures we don't hold on to our password
+ // listeners and their associated HTMLInputElements.
+ m_webFrame->clearPasswordListeners();
+
+ if (m_webFrame->client())
+ m_webFrame->client()->didFinishDocumentLoad(m_webFrame);
+}
+
+bool FrameLoaderClientImpl::dispatchDidLoadResourceFromMemoryCache(
+ DocumentLoader* loader,
+ const ResourceRequest& request,
+ const ResourceResponse& response,
+ int length)
+{
+ if (m_webFrame->client()) {
+ WrappedResourceRequest webreq(request);
+ WrappedResourceResponse webresp(response);
+ m_webFrame->client()->didLoadResourceFromMemoryCache(
+ m_webFrame, webreq, webresp);
+ }
+ return false; // Do not suppress remaining notifications
+}
+
+void FrameLoaderClientImpl::dispatchDidHandleOnloadEvents()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didHandleOnloadEvents(m_webFrame);
+}
+
+// Redirect Tracking
+// =================
+// We want to keep track of the chain of redirects that occur during page
+// loading. There are two types of redirects, server redirects which are HTTP
+// response codes, and client redirects which are document.location= and meta
+// refreshes.
+//
+// This outlines the callbacks that we get in different redirect situations,
+// and how each call modifies the redirect chain.
+//
+// Normal page load
+// ----------------
+// dispatchDidStartProvisionalLoad() -> adds URL to the redirect list
+// dispatchDidCommitLoad() -> DISPATCHES & clears list
+//
+// Server redirect (success)
+// -------------------------
+// dispatchDidStartProvisionalLoad() -> adds source URL
+// dispatchDidReceiveServerRedirectForProvisionalLoad() -> adds dest URL
+// dispatchDidCommitLoad() -> DISPATCHES
+//
+// Client redirect (success)
+// -------------------------
+// (on page)
+// dispatchWillPerformClientRedirect() -> saves expected redirect
+// dispatchDidStartProvisionalLoad() -> appends redirect source (since
+// it matches the expected redirect)
+// and the current page as the dest)
+// dispatchDidCancelClientRedirect() -> clears expected redirect
+// dispatchDidCommitLoad() -> DISPATCHES
+//
+// Client redirect (cancelled)
+// (e.g meta-refresh trumped by manual doc.location change, or just cancelled
+// because a link was clicked that requires the meta refresh to be rescheduled
+// (the SOURCE URL may have changed).
+// ---------------------------
+// dispatchDidCancelClientRedirect() -> clears expected redirect
+// dispatchDidStartProvisionalLoad() -> adds only URL to redirect list
+// dispatchDidCommitLoad() -> DISPATCHES & clears list
+// rescheduled ? dispatchWillPerformClientRedirect() -> saves expected redirect
+// : nothing
+
+// Client redirect (failure)
+// -------------------------
+// (on page)
+// dispatchWillPerformClientRedirect() -> saves expected redirect
+// dispatchDidStartProvisionalLoad() -> appends redirect source (since
+// it matches the expected redirect)
+// and the current page as the dest)
+// dispatchDidCancelClientRedirect()
+// dispatchDidFailProvisionalLoad()
+//
+// Load 1 -> Server redirect to 2 -> client redirect to 3 -> server redirect to 4
+// ------------------------------------------------------------------------------
+// dispatchDidStartProvisionalLoad() -> adds source URL 1
+// dispatchDidReceiveServerRedirectForProvisionalLoad() -> adds dest URL 2
+// dispatchDidCommitLoad() -> DISPATCHES 1+2
+// -- begin client redirect and NEW DATA SOURCE
+// dispatchWillPerformClientRedirect() -> saves expected redirect
+// dispatchDidStartProvisionalLoad() -> appends URL 2 and URL 3
+// dispatchDidReceiveServerRedirectForProvisionalLoad() -> appends destination URL 4
+// dispatchDidCancelClientRedirect() -> clears expected redirect
+// dispatchDidCommitLoad() -> DISPATCHES
+//
+// Interesting case with multiple location changes involving anchors.
+// Load page 1 containing future client-redirect (back to 1, e.g meta refresh) > Click
+// on a link back to the same page (i.e an anchor href) >
+// client-redirect finally fires (with new source, set to 1#anchor)
+// -----------------------------------------------------------------------------
+// dispatchWillPerformClientRedirect(non-zero 'interval' param) -> saves expected redirect
+// -- click on anchor href
+// dispatchDidCancelClientRedirect() -> clears expected redirect
+// dispatchDidStartProvisionalLoad() -> adds 1#anchor source
+// dispatchDidCommitLoad() -> DISPATCHES 1#anchor
+// dispatchWillPerformClientRedirect() -> saves exp. source (1#anchor)
+// -- redirect timer fires
+// dispatchDidStartProvisionalLoad() -> appends 1#anchor (src) and 1 (dest)
+// dispatchDidCancelClientRedirect() -> clears expected redirect
+// dispatchDidCommitLoad() -> DISPATCHES 1#anchor + 1
+//
+void FrameLoaderClientImpl::dispatchDidReceiveServerRedirectForProvisionalLoad()
+{
+ WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
+ if (!ds) {
+ // Got a server redirect when there is no provisional DS!
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ // The server redirect may have been blocked.
+ if (ds->request().isNull())
+ return;
+
+ // A provisional load should have started already, which should have put an
+ // entry in our redirect chain.
+ ASSERT(ds->hasRedirectChain());
+
+ // The URL of the destination is on the provisional data source. We also need
+ // to update the redirect chain to account for this addition (we do this
+ // before the callback so the callback can look at the redirect chain to see
+ // what happened).
+ ds->appendRedirect(ds->request().url());
+
+ if (m_webFrame->client())
+ m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad(m_webFrame);
+}
+
+// Called on both success and failure of a client redirect.
+void FrameLoaderClientImpl::dispatchDidCancelClientRedirect()
+{
+ // No longer expecting a client redirect.
+ if (m_webFrame->client()) {
+ m_expectedClientRedirectSrc = KURL();
+ m_expectedClientRedirectDest = KURL();
+ m_webFrame->client()->didCancelClientRedirect(m_webFrame);
+ }
+
+ // No need to clear the redirect chain, since that data source has already
+ // been deleted by the time this function is called.
+}
+
+void FrameLoaderClientImpl::dispatchWillPerformClientRedirect(
+ const KURL& url,
+ double interval,
+ double fireDate)
+{
+ // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a
+ // redirect and the source item should be added as the start of the chain.
+ m_expectedClientRedirectSrc = m_webFrame->url();
+ m_expectedClientRedirectDest = url;
+
+ // FIXME: bug 1135512. Webkit does not properly notify us of cancelling
+ // http > file client redirects. Since the FrameLoader's policy is to never
+ // carry out such a navigation anyway, the best thing we can do for now to
+ // not get confused is ignore this notification.
+ if (m_expectedClientRedirectDest.isLocalFile()
+ && m_expectedClientRedirectSrc.protocolInHTTPFamily()) {
+ m_expectedClientRedirectSrc = KURL();
+ m_expectedClientRedirectDest = KURL();
+ return;
+ }
+
+ if (m_webFrame->client()) {
+ m_webFrame->client()->willPerformClientRedirect(
+ m_webFrame,
+ m_expectedClientRedirectSrc,
+ m_expectedClientRedirectDest,
+ static_cast<unsigned int>(interval),
+ static_cast<unsigned int>(fireDate));
+ }
+}
+
+void FrameLoaderClientImpl::dispatchDidNavigateWithinPage()
+{
+ // Anchor fragment navigations are not normal loads, so we need to synthesize
+ // some events for our delegate.
+ WebViewImpl* webView = m_webFrame->viewImpl();
+
+ // Flag of whether frame loader is completed. Generate didStartLoading and
+ // didStopLoading only when loader is completed so that we don't fire
+ // them for fragment redirection that happens in window.onload handler.
+ // See https://bugs.webkit.org/show_bug.cgi?id=31838
+ bool loaderCompleted =
+ !webView->page()->mainFrame()->loader()->activeDocumentLoader()->isLoadingInAPISense();
+
+ // Generate didStartLoading if loader is completed.
+ if (webView->client() && loaderCompleted)
+ webView->client()->didStartLoading();
+
+ // We need to classify some hash changes as client redirects.
+ // FIXME: It seems wrong that the currentItem can sometimes be null.
+ HistoryItem* currentItem = m_webFrame->frame()->loader()->history()->currentItem();
+ bool isHashChange = !currentItem || !currentItem->stateObject();
+
+ WebDataSourceImpl* ds = m_webFrame->dataSourceImpl();
+ ASSERT(ds); // Should not be null when navigating to a reference fragment!
+ if (ds) {
+ KURL url = ds->request().url();
+ KURL chainEnd;
+ if (ds->hasRedirectChain()) {
+ chainEnd = ds->endOfRedirectChain();
+ ds->clearRedirectChain();
+ }
+
+ if (isHashChange) {
+ // Figure out if this location change is because of a JS-initiated
+ // client redirect (e.g onload/setTimeout document.location.href=).
+ // FIXME: (b/1085325, b/1046841) We don't get proper redirect
+ // performed/cancelled notifications across anchor navigations, so the
+ // other redirect-tracking code in this class (see
+ // dispatch*ClientRedirect() and dispatchDidStartProvisionalLoad) is
+ // insufficient to catch and properly flag these transitions. Once a
+ // proper fix for this bug is identified and applied the following
+ // block may no longer be required.
+ bool wasClientRedirect =
+ (url == m_expectedClientRedirectDest && chainEnd == m_expectedClientRedirectSrc)
+ || !m_webFrame->isProcessingUserGesture();
+
+ if (wasClientRedirect) {
+ if (m_webFrame->client())
+ m_webFrame->client()->didCompleteClientRedirect(m_webFrame, chainEnd);
+ ds->appendRedirect(chainEnd);
+ // Make sure we clear the expected redirect since we just effectively
+ // completed it.
+ m_expectedClientRedirectSrc = KURL();
+ m_expectedClientRedirectDest = KURL();
+ }
+ }
+
+ // Regardless of how we got here, we are navigating to a URL so we need to
+ // add it to the redirect chain.
+ ds->appendRedirect(url);
+ }
+
+ bool isNewNavigation;
+ webView->didCommitLoad(&isNewNavigation);
+ if (m_webFrame->client())
+ m_webFrame->client()->didNavigateWithinPage(m_webFrame, isNewNavigation);
+
+ // Generate didStopLoading if loader is completed.
+ if (webView->client() && loaderCompleted)
+ webView->client()->didStopLoading();
+}
+
+void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
+{
+ if (m_webFrame)
+ m_webFrame->client()->didChangeLocationWithinPage(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidPushStateWithinPage()
+{
+ dispatchDidNavigateWithinPage();
+}
+
+void FrameLoaderClientImpl::dispatchDidReplaceStateWithinPage()
+{
+ dispatchDidNavigateWithinPage();
+}
+
+void FrameLoaderClientImpl::dispatchDidPopStateWithinPage()
+{
+ // Ignored since dispatchDidNavigateWithinPage was already called.
+}
+
+void FrameLoaderClientImpl::dispatchWillClose()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willClose(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveIcon()
+{
+ // The icon database is disabled, so this should never be called.
+ ASSERT_NOT_REACHED();
+}
+
+void FrameLoaderClientImpl::dispatchDidStartProvisionalLoad()
+{
+ // In case a redirect occurs, we need this to be set so that the redirect
+ // handling code can tell where the redirect came from. Server redirects
+ // will occur on the provisional load, so we need to keep track of the most
+ // recent provisional load URL.
+ // See dispatchDidReceiveServerRedirectForProvisionalLoad.
+ WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
+ if (!ds) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ KURL url = ds->request().url();
+
+ // Since the provisional load just started, we should have not gotten
+ // any redirects yet.
+ ASSERT(!ds->hasRedirectChain());
+
+ // If this load is what we expected from a client redirect, treat it as a
+ // redirect from that original page. The expected redirect urls will be
+ // cleared by DidCancelClientRedirect.
+ bool completingClientRedirect = false;
+ if (m_expectedClientRedirectSrc.isValid()) {
+ // m_expectedClientRedirectDest could be something like
+ // "javascript:history.go(-1)" thus we need to exclude url starts with
+ // "javascript:". See bug: 1080873
+ ASSERT(m_expectedClientRedirectDest.protocolIs("javascript")
+ || m_expectedClientRedirectDest == url);
+ ds->appendRedirect(m_expectedClientRedirectSrc);
+ completingClientRedirect = true;
+ }
+ ds->appendRedirect(url);
+
+ if (m_webFrame->client()) {
+ // Whatever information didCompleteClientRedirect contains should only
+ // be considered relevant until the next provisional load has started.
+ // So we first tell the client that the load started, and then tell it
+ // about the client redirect the load is responsible for completing.
+ m_webFrame->client()->didStartProvisionalLoad(m_webFrame);
+ if (completingClientRedirect) {
+ m_webFrame->client()->didCompleteClientRedirect(
+ m_webFrame, m_expectedClientRedirectSrc);
+ }
+ }
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didReceiveTitle(m_webFrame, title);
+}
+
+void FrameLoaderClientImpl::dispatchDidChangeIcons()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didChangeIcons(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidCommitLoad()
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ bool isNewNavigation;
+ webview->didCommitLoad(&isNewNavigation);
+
+ if (m_webFrame->client())
+ m_webFrame->client()->didCommitProvisionalLoad(m_webFrame, isNewNavigation);
+}
+
+void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad(
+ const ResourceError& error)
+{
+
+ // If a policy change occured, then we do not want to inform the plugin
+ // delegate. See http://b/907789 for details. FIXME: This means the
+ // plugin won't receive NPP_URLNotify, which seems like it could result in
+ // a memory leak in the plugin!!
+ if (error.domain() == internalErrorDomain
+ && error.errorCode() == PolicyChangeError) {
+ m_webFrame->didFail(cancelledError(error.failingURL()), true);
+ return;
+ }
+
+ OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
+ m_webFrame->didFail(error, true);
+ if (observer)
+ observer->didFailLoading(error);
+}
+
+void FrameLoaderClientImpl::dispatchDidFailLoad(const ResourceError& error)
+{
+ OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
+ m_webFrame->didFail(error, false);
+ if (observer)
+ observer->didFailLoading(error);
+
+ // Don't clear the redirect chain, this will happen in the middle of client
+ // redirects, and we need the context. The chain will be cleared when the
+ // provisional load succeeds or fails, not the "real" one.
+}
+
+void FrameLoaderClientImpl::dispatchDidFinishLoad()
+{
+ OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
+
+ if (m_webFrame->client())
+ m_webFrame->client()->didFinishLoad(m_webFrame);
+
+ if (observer)
+ observer->didFinishLoading();
+
+ // Don't clear the redirect chain, this will happen in the middle of client
+ // redirects, and we need the context. The chain will be cleared when the
+ // provisional load succeeds or fails, not the "real" one.
+}
+
+void FrameLoaderClientImpl::dispatchDidFirstLayout()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didFirstLayout(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame);
+}
+
+Frame* FrameLoaderClientImpl::dispatchCreatePage(const NavigationAction& action)
+{
+ struct WindowFeatures features;
+ Page* newPage = m_webFrame->frame()->page()->chrome()->createWindow(
+ m_webFrame->frame(), FrameLoadRequest(m_webFrame->frame()->document()->securityOrigin()),
+ features, action);
+
+ // Make sure that we have a valid disposition. This should have been set in
+ // the preceeding call to dispatchDecidePolicyForNewWindowAction.
+ ASSERT(m_nextNavigationPolicy != WebNavigationPolicyIgnore);
+ WebNavigationPolicy policy = m_nextNavigationPolicy;
+ m_nextNavigationPolicy = WebNavigationPolicyIgnore;
+
+ // createWindow can return null (e.g., popup blocker denies the window).
+ if (!newPage)
+ return 0;
+
+ WebViewImpl::fromPage(newPage)->setInitialNavigationPolicy(policy);
+ return newPage->mainFrame();
+}
+
+void FrameLoaderClientImpl::dispatchShow()
+{
+ WebViewImpl* webView = m_webFrame->viewImpl();
+ if (webView && webView->client())
+ webView->client()->show(webView->initialNavigationPolicy());
+}
+
+void FrameLoaderClientImpl::dispatchDecidePolicyForMIMEType(
+ FramePolicyFunction function,
+ const String& mimeType,
+ const ResourceRequest&)
+{
+ const ResourceResponse& response =
+ m_webFrame->frame()->loader()->activeDocumentLoader()->response();
+
+ PolicyAction action;
+
+ int statusCode = response.httpStatusCode();
+ if (statusCode == 204 || statusCode == 205) {
+ // The server does not want us to replace the page contents.
+ action = PolicyIgnore;
+ } else if (WebCore::contentDispositionType(response.httpHeaderField("Content-Disposition")) == WebCore::ContentDispositionAttachment) {
+ // The server wants us to download instead of replacing the page contents.
+ // Downloading is handled by the embedder, but we still get the initial
+ // response so that we can ignore it and clean up properly.
+ action = PolicyIgnore;
+ } else if (!canShowMIMEType(mimeType)) {
+ // Make sure that we can actually handle this type internally.
+ action = PolicyIgnore;
+ } else {
+ // OK, we will render this page.
+ action = PolicyUse;
+ }
+
+ // NOTE: PolicyChangeError will be generated when action is not PolicyUse.
+ (m_webFrame->frame()->loader()->policyChecker()->*function)(action);
+}
+
+void FrameLoaderClientImpl::dispatchDecidePolicyForNewWindowAction(
+ FramePolicyFunction function,
+ const NavigationAction& action,
+ const ResourceRequest& request,
+ PassRefPtr<FormState> formState,
+ const String& frameName)
+{
+ WebNavigationPolicy navigationPolicy;
+ if (!actionSpecifiesNavigationPolicy(action, &navigationPolicy))
+ navigationPolicy = WebNavigationPolicyNewForegroundTab;
+
+ PolicyAction policyAction;
+ if (navigationPolicy == WebNavigationPolicyDownload)
+ policyAction = PolicyDownload;
+ else {
+ policyAction = PolicyUse;
+
+ // Remember the disposition for when dispatchCreatePage is called. It is
+ // unfortunate that WebCore does not provide us with any context when
+ // creating or showing the new window that would allow us to avoid having
+ // to keep this state.
+ m_nextNavigationPolicy = navigationPolicy;
+ }
+ (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction);
+}
+
+void FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction(
+ FramePolicyFunction function,
+ const NavigationAction& action,
+ const ResourceRequest& request,
+ PassRefPtr<FormState> formState) {
+ PolicyAction policyAction = PolicyIgnore;
+
+ // It is valid for this function to be invoked in code paths where the
+ // the webview is closed.
+ // The null check here is to fix a crash that seems strange
+ // (see - https://bugs.webkit.org/show_bug.cgi?id=23554).
+ if (m_webFrame->client() && !request.url().isNull()) {
+ WebNavigationPolicy navigationPolicy = WebNavigationPolicyCurrentTab;
+ actionSpecifiesNavigationPolicy(action, &navigationPolicy);
+
+ // Give the delegate a chance to change the navigation policy.
+ const WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
+ if (ds) {
+ KURL url = ds->request().url();
+ ASSERT(!url.protocolIs(backForwardNavigationScheme));
+
+ bool isRedirect = ds->hasRedirectChain();
+
+ WebNavigationType webnavType =
+ WebDataSourceImpl::toWebNavigationType(action.type());
+
+ RefPtr<Node> node;
+ for (const Event* event = action.event(); event; event = event->underlyingEvent()) {
+ if (event->isMouseEvent()) {
+ const MouseEvent* mouseEvent =
+ static_cast<const MouseEvent*>(event);
+ node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint(
+ mouseEvent->absoluteLocation(), false).innerNonSharedNode();
+ break;
+ }
+ }
+ WebNode originatingNode(node);
+
+ navigationPolicy = m_webFrame->client()->decidePolicyForNavigation(
+ m_webFrame, ds->request(), webnavType, originatingNode,
+ navigationPolicy, isRedirect);
+ }
+
+ if (navigationPolicy == WebNavigationPolicyCurrentTab)
+ policyAction = PolicyUse;
+ else if (navigationPolicy == WebNavigationPolicyDownload)
+ policyAction = PolicyDownload;
+ else {
+ if (navigationPolicy != WebNavigationPolicyIgnore) {
+ WrappedResourceRequest webreq(request);
+ m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navigationPolicy);
+ }
+ policyAction = PolicyIgnore;
+ }
+ }
+
+ (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction);
+}
+
+void FrameLoaderClientImpl::cancelPolicyCheck()
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::dispatchUnableToImplementPolicy(const ResourceError& error)
+{
+ m_webFrame->client()->unableToImplementPolicyWithError(m_webFrame, error);
+}
+
+void FrameLoaderClientImpl::dispatchWillSendSubmitEvent(HTMLFormElement* form)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willSendSubmitEvent(m_webFrame, WebFormElement(form));
+}
+
+void FrameLoaderClientImpl::dispatchWillSubmitForm(FramePolicyFunction function,
+ PassRefPtr<FormState> formState)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willSubmitForm(m_webFrame, WebFormElement(formState->form()));
+ (m_webFrame->frame()->loader()->policyChecker()->*function)(PolicyUse);
+}
+
+void FrameLoaderClientImpl::dispatchDidLoadMainResource(DocumentLoader*)
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::revertToProvisionalState(DocumentLoader*)
+{
+ m_hasRepresentation = true;
+}
+
+void FrameLoaderClientImpl::setMainDocumentError(DocumentLoader*,
+ const ResourceError& error)
+{
+ if (m_pluginWidget.get()) {
+ if (m_sentInitialResponseToPlugin) {
+ m_pluginWidget->didFailLoading(error);
+ m_sentInitialResponseToPlugin = false;
+ }
+ m_pluginWidget = 0;
+ }
+}
+
+void FrameLoaderClientImpl::postProgressStartedNotification()
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->client())
+ webview->client()->didStartLoading();
+}
+
+void FrameLoaderClientImpl::postProgressEstimateChangedNotification()
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->client()) {
+ webview->client()->didChangeLoadProgress(
+ m_webFrame, m_webFrame->frame()->page()->progress()->estimatedProgress());
+ }
+
+}
+
+void FrameLoaderClientImpl::postProgressFinishedNotification()
+{
+ // FIXME: why might the webview be null? http://b/1234461
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->client())
+ webview->client()->didStopLoading();
+}
+
+void FrameLoaderClientImpl::setMainFrameDocumentReady(bool ready)
+{
+ // FIXME
+}
+
+// Creates a new connection and begins downloading from that (contrast this
+// with |download|).
+void FrameLoaderClientImpl::startDownload(const ResourceRequest& request)
+{
+ if (m_webFrame->client()) {
+ WrappedResourceRequest webreq(request);
+ m_webFrame->client()->loadURLExternally(
+ m_webFrame, webreq, WebNavigationPolicyDownload);
+ }
+}
+
+void FrameLoaderClientImpl::willChangeTitle(DocumentLoader*)
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::didChangeTitle(DocumentLoader*)
+{
+ // FIXME
+}
+
+// Called whenever data is received.
+void FrameLoaderClientImpl::committedLoad(DocumentLoader* loader, const char* data, int length)
+{
+ if (!m_pluginWidget.get()) {
+ if (m_webFrame->client()) {
+ bool preventDefault = false;
+ m_webFrame->client()->didReceiveDocumentData(m_webFrame, data, length, preventDefault);
+ if (!preventDefault)
+ m_webFrame->commitDocumentData(data, length);
+ }
+ }
+
+ // If we are sending data to MediaDocument, we should stop here
+ // and cancel the request.
+ if (m_webFrame->frame()->document()->isMediaDocument())
+ loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->response()));
+
+ // The plugin widget could have been created in the m_webFrame->DidReceiveData
+ // function.
+ if (m_pluginWidget.get()) {
+ if (!m_sentInitialResponseToPlugin) {
+ m_sentInitialResponseToPlugin = true;
+ m_pluginWidget->didReceiveResponse(
+ m_webFrame->frame()->loader()->activeDocumentLoader()->response());
+ }
+
+ // It's possible that the above call removed the pointer to the plugin, so
+ // check before calling it.
+ if (m_pluginWidget.get())
+ m_pluginWidget->didReceiveData(data, length);
+ }
+}
+
+void FrameLoaderClientImpl::finishedLoading(DocumentLoader* dl)
+{
+ if (m_pluginWidget.get()) {
+ m_pluginWidget->didFinishLoading();
+ m_pluginWidget = 0;
+ m_sentInitialResponseToPlugin = false;
+ } else {
+ // This is necessary to create an empty document. See bug 634004.
+ // However, we only want to do this if makeRepresentation has been called, to
+ // match the behavior on the Mac.
+ if (m_hasRepresentation)
+ dl->frameLoader()->writer()->setEncoding("", false);
+ }
+}
+
+void FrameLoaderClientImpl::updateGlobalHistory()
+{
+}
+
+void FrameLoaderClientImpl::updateGlobalHistoryRedirectLinks()
+{
+}
+
+bool FrameLoaderClientImpl::shouldGoToHistoryItem(HistoryItem* item) const
+{
+ const KURL& url = item->url();
+ if (!url.protocolIs(backForwardNavigationScheme))
+ return true;
+
+ // Else, we'll punt this history navigation to the embedder. It is
+ // necessary that we intercept this here, well before the FrameLoader
+ // has made any state changes for this history traversal.
+
+ bool ok;
+ int offset = url.lastPathComponent().toIntStrict(&ok);
+ if (!ok) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview->client())
+ webview->client()->navigateBackForwardSoon(offset);
+
+ return false;
+}
+
+void FrameLoaderClientImpl::dispatchDidAddBackForwardItem(HistoryItem*) const
+{
+}
+
+void FrameLoaderClientImpl::dispatchDidRemoveBackForwardItem(HistoryItem*) const
+{
+}
+
+void FrameLoaderClientImpl::dispatchDidChangeBackForwardIndex() const
+{
+}
+
+void FrameLoaderClientImpl::didDisplayInsecureContent()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didDisplayInsecureContent(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didRunInsecureContent(SecurityOrigin* origin)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didRunInsecureContent(m_webFrame, WebSecurityOrigin(origin));
+}
+
+ResourceError FrameLoaderClientImpl::blockedError(const ResourceRequest&)
+{
+ // FIXME
+ return ResourceError();
+}
+
+ResourceError FrameLoaderClientImpl::cancelledError(const ResourceRequest& request)
+{
+ if (!m_webFrame->client())
+ return ResourceError();
+
+ return m_webFrame->client()->cancelledError(
+ m_webFrame, WrappedResourceRequest(request));
+}
+
+ResourceError FrameLoaderClientImpl::cannotShowURLError(const ResourceRequest& request)
+{
+ if (!m_webFrame->client())
+ return ResourceError();
+
+ return m_webFrame->client()->cannotHandleRequestError(
+ m_webFrame, WrappedResourceRequest(request));
+}
+
+ResourceError FrameLoaderClientImpl::interruptForPolicyChangeError(
+ const ResourceRequest& request)
+{
+ return ResourceError(internalErrorDomain, PolicyChangeError,
+ request.url().string(), String());
+}
+
+ResourceError FrameLoaderClientImpl::cannotShowMIMETypeError(const ResourceResponse&)
+{
+ // FIXME
+ return ResourceError();
+}
+
+ResourceError FrameLoaderClientImpl::fileDoesNotExistError(const ResourceResponse&)
+{
+ // FIXME
+ return ResourceError();
+}
+
+ResourceError FrameLoaderClientImpl::pluginWillHandleLoadError(const ResourceResponse&)
+{
+ // FIXME
+ return ResourceError();
+}
+
+bool FrameLoaderClientImpl::shouldFallBack(const ResourceError& error)
+{
+ // This method is called when we fail to load the URL for an <object> tag
+ // that has fallback content (child elements) and is being loaded as a frame.
+ // The error parameter indicates the reason for the load failure.
+ // We should let the fallback content load only if this wasn't a cancelled
+ // request.
+ // Note: The mac version also has a case for "WebKitErrorPluginWillHandleLoad"
+ ResourceError c = cancelledError(ResourceRequest());
+ return error.errorCode() != c.errorCode() || error.domain() != c.domain();
+}
+
+bool FrameLoaderClientImpl::canHandleRequest(const ResourceRequest& request) const
+{
+ return m_webFrame->client()->canHandleRequest(
+ m_webFrame, WrappedResourceRequest(request));
+}
+
+bool FrameLoaderClientImpl::canShowMIMETypeAsHTML(const String& MIMEType) const
+{
+ notImplemented();
+ return false;
+}
+
+bool FrameLoaderClientImpl::canShowMIMEType(const String& mimeType) const
+{
+ // This method is called to determine if the media type can be shown
+ // "internally" (i.e. inside the browser) regardless of whether or not the
+ // browser or a plugin is doing the rendering.
+
+ // mimeType strings are supposed to be ASCII, but if they are not for some
+ // reason, then it just means that the mime type will fail all of these "is
+ // supported" checks and go down the path of an unhandled mime type.
+ if (webKitClient()->mimeRegistry()->supportsMIMEType(mimeType) == WebMimeRegistry::IsSupported)
+ return true;
+
+ // If Chrome is started with the --disable-plugins switch, pluginData is null.
+ PluginData* pluginData = m_webFrame->frame()->page()->pluginData();
+
+ // See if the type is handled by an installed plugin, if so, we can show it.
+ // FIXME: (http://b/1085524) This is the place to stick a preference to
+ // disable full page plugins (optionally for certain types!)
+ return !mimeType.isEmpty() && pluginData && pluginData->supportsMimeType(mimeType);
+}
+
+bool FrameLoaderClientImpl::representationExistsForURLScheme(const String&) const
+{
+ // FIXME
+ return false;
+}
+
+String FrameLoaderClientImpl::generatedMIMETypeForURLScheme(const String& scheme) const
+{
+ // This appears to generate MIME types for protocol handlers that are handled
+ // internally. The only place I can find in the WebKit code that uses this
+ // function is WebView::registerViewClass, where it is used as part of the
+ // process by which custom view classes for certain document representations
+ // are registered.
+ String mimeType("x-apple-web-kit/");
+ mimeType.append(scheme.lower());
+ return mimeType;
+}
+
+void FrameLoaderClientImpl::frameLoadCompleted()
+{
+ // FIXME: the mac port also conditionally calls setDrawsBackground:YES on
+ // it's ScrollView here.
+
+ // This comment from the Mac port:
+ // Note: Can be called multiple times.
+ // Even if already complete, we might have set a previous item on a frame that
+ // didn't do any data loading on the past transaction. Make sure to clear these out.
+
+ // FIXME: setPreviousHistoryItem() no longer exists. http://crbug.com/8566
+ // m_webFrame->frame()->loader()->setPreviousHistoryItem(0);
+}
+
+void FrameLoaderClientImpl::saveViewStateToItem(HistoryItem*)
+{
+ // FIXME
+}
+
+void FrameLoaderClientImpl::restoreViewState()
+{
+ // FIXME: probably scrolls to last position when you go back or forward
+}
+
+void FrameLoaderClientImpl::provisionalLoadStarted()
+{
+ // FIXME: On mac, this does various caching stuff
+}
+
+void FrameLoaderClientImpl::didFinishLoad()
+{
+ OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
+ if (observer)
+ observer->didFinishLoading();
+}
+
+void FrameLoaderClientImpl::prepareForDataSourceReplacement()
+{
+ // FIXME
+}
+
+PassRefPtr<DocumentLoader> FrameLoaderClientImpl::createDocumentLoader(
+ const ResourceRequest& request,
+ const SubstituteData& data)
+{
+ RefPtr<WebDataSourceImpl> ds = WebDataSourceImpl::create(request, data);
+ if (m_webFrame->client())
+ m_webFrame->client()->didCreateDataSource(m_webFrame, ds.get());
+ return ds.release();
+}
+
+void FrameLoaderClientImpl::setTitle(const String& title, const KURL& url)
+{
+ // FIXME: inform consumer of changes to the title.
+}
+
+String FrameLoaderClientImpl::userAgent(const KURL& url)
+{
+ return webKitClient()->userAgent(url);
+}
+
+void FrameLoaderClientImpl::savePlatformDataToCachedFrame(CachedFrame*)
+{
+ // The page cache should be disabled.
+ ASSERT_NOT_REACHED();
+}
+
+void FrameLoaderClientImpl::transitionToCommittedFromCachedFrame(CachedFrame*)
+{
+ ASSERT_NOT_REACHED();
+}
+
+// Called when the FrameLoader goes into a state in which a new page load
+// will occur.
+void FrameLoaderClientImpl::transitionToCommittedForNewPage()
+{
+ makeDocumentView();
+}
+
+void FrameLoaderClientImpl::didSaveToPageCache()
+{
+}
+
+void FrameLoaderClientImpl::didRestoreFromPageCache()
+{
+}
+
+void FrameLoaderClientImpl::dispatchDidBecomeFrameset(bool)
+{
+}
+
+bool FrameLoaderClientImpl::canCachePage() const
+{
+ // Since we manage the cache, always report this page as non-cacheable to
+ // FrameLoader.
+ return false;
+}
+
+// Downloading is handled in the browser process, not WebKit. If we get to this
+// point, our download detection code in the ResourceDispatcherHost is broken!
+void FrameLoaderClientImpl::download(ResourceHandle* handle,
+ const ResourceRequest& request,
+ const ResourceRequest& initialRequest,
+ const ResourceResponse& response)
+{
+ ASSERT_NOT_REACHED();
+}
+
+PassRefPtr<Frame> FrameLoaderClientImpl::createFrame(
+ const KURL& url,
+ const String& name,
+ HTMLFrameOwnerElement* ownerElement,
+ const String& referrer,
+ bool allowsScrolling,
+ int marginWidth,
+ int marginHeight)
+{
+ FrameLoadRequest frameRequest(m_webFrame->frame()->document()->securityOrigin(),
+ ResourceRequest(url, referrer), name);
+ return m_webFrame->createChildFrame(frameRequest, ownerElement);
+}
+
+void FrameLoaderClientImpl::didTransferChildFrameToNewDocument(Page*)
+{
+ ASSERT(m_webFrame->frame()->ownerElement());
+
+ WebFrameImpl* newParent = static_cast<WebFrameImpl*>(m_webFrame->parent());
+ if (!newParent || !newParent->client())
+ return;
+
+ // Replace the client since the old client may be destroyed when the
+ // previous page is closed.
+ m_webFrame->setClient(newParent->client());
+}
+
+void FrameLoaderClientImpl::transferLoadingResourceFromPage(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, Page* oldPage)
+{
+ assignIdentifierToInitialRequest(identifier, loader, request);
+
+ WebFrameImpl* oldWebFrame = WebFrameImpl::fromFrame(oldPage->mainFrame());
+ if (oldWebFrame && oldWebFrame->client())
+ oldWebFrame->client()->removeIdentifierForRequest(identifier);
+}
+
+PassRefPtr<Widget> FrameLoaderClientImpl::createPlugin(
+ const IntSize& size, // FIXME: how do we use this?
+ HTMLPlugInElement* element,
+ const KURL& url,
+ const Vector<String>& paramNames,
+ const Vector<String>& paramValues,
+ const String& mimeType,
+ bool loadManually)
+{
+ if (!m_webFrame->client())
+ return 0;
+
+ WebPluginParams params;
+ params.url = url;
+ params.mimeType = mimeType;
+ params.attributeNames = paramNames;
+ params.attributeValues = paramValues;
+ params.loadManually = loadManually;
+
+ WebPlugin* webPlugin = m_webFrame->client()->createPlugin(m_webFrame, params);
+ if (!webPlugin)
+ return 0;
+
+ // The container takes ownership of the WebPlugin.
+ RefPtr<WebPluginContainerImpl> container =
+ WebPluginContainerImpl::create(element, webPlugin);
+
+ if (!webPlugin->initialize(container.get()))
+ return 0;
+
+ // The element might have been removed during plugin initialization!
+ if (!element->renderer())
+ return 0;
+
+ return container;
+}
+
+// This method gets called when a plugin is put in place of html content
+// (e.g., acrobat reader).
+void FrameLoaderClientImpl::redirectDataToPlugin(Widget* pluginWidget)
+{
+ if (pluginWidget->isPluginContainer())
+ m_pluginWidget = static_cast<WebPluginContainerImpl*>(pluginWidget);
+ ASSERT(m_pluginWidget.get());
+}
+
+PassRefPtr<Widget> FrameLoaderClientImpl::createJavaAppletWidget(
+ const IntSize& size,
+ HTMLAppletElement* element,
+ const KURL& /* baseURL */,
+ const Vector<String>& paramNames,
+ const Vector<String>& paramValues)
+{
+ return createPlugin(size, element, KURL(), paramNames, paramValues,
+ "application/x-java-applet", false);
+}
+
+ObjectContentType FrameLoaderClientImpl::objectContentType(
+ const KURL& url,
+ const String& explicitMimeType)
+{
+ // This code is based on Apple's implementation from
+ // WebCoreSupport/WebFrameBridge.mm.
+
+ String mimeType = explicitMimeType;
+ if (mimeType.isEmpty()) {
+ // Try to guess the MIME type based off the extension.
+ String filename = url.lastPathComponent();
+ int extensionPos = filename.reverseFind('.');
+ if (extensionPos >= 0) {
+ String extension = filename.substring(extensionPos + 1);
+ mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
+ if (mimeType.isEmpty()) {
+ // If there's no mimetype registered for the extension, check to see
+ // if a plugin can handle the extension.
+ mimeType = getPluginMimeTypeFromExtension(extension);
+ }
+ }
+
+ if (mimeType.isEmpty())
+ return ObjectContentFrame;
+ }
+
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
+ return ObjectContentImage;
+
+ // If Chrome is started with the --disable-plugins switch, pluginData is 0.
+ PluginData* pluginData = m_webFrame->frame()->page()->pluginData();
+ if (pluginData && pluginData->supportsMimeType(mimeType))
+ return ObjectContentNetscapePlugin;
+
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
+ return ObjectContentFrame;
+
+ return ObjectContentNone;
+}
+
+String FrameLoaderClientImpl::overrideMediaType() const
+{
+ // FIXME
+ return String();
+}
+
+bool FrameLoaderClientImpl::actionSpecifiesNavigationPolicy(
+ const NavigationAction& action,
+ WebNavigationPolicy* policy)
+{
+ const MouseEvent* event = 0;
+ if (action.type() == NavigationTypeLinkClicked
+ && action.event()->isMouseEvent())
+ event = static_cast<const MouseEvent*>(action.event());
+ else if (action.type() == NavigationTypeFormSubmitted
+ && action.event()
+ && action.event()->underlyingEvent()
+ && action.event()->underlyingEvent()->isMouseEvent())
+ event = static_cast<const MouseEvent*>(action.event()->underlyingEvent());
+
+ if (!event)
+ return false;
+
+ return WebViewImpl::navigationPolicyFromMouseEvent(
+ event->button(), event->ctrlKey(), event->shiftKey(), event->altKey(),
+ event->metaKey(), policy);
+}
+
+PassOwnPtr<WebPluginLoadObserver> FrameLoaderClientImpl::pluginLoadObserver()
+{
+ WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(
+ m_webFrame->frame()->loader()->activeDocumentLoader());
+ if (!ds) {
+ // We can arrive here if a popstate event handler detaches this frame.
+ // FIXME: Remove this code once http://webkit.org/b/36202 is fixed.
+ ASSERT(!m_webFrame->frame()->page());
+ return 0;
+ }
+ return ds->releasePluginLoadObserver();
+}
+
+PassRefPtr<FrameNetworkingContext> FrameLoaderClientImpl::createNetworkingContext()
+{
+ return FrameNetworkingContextImpl::create(m_webFrame->frame());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h
new file mode 100644
index 0000000..1d7a741
--- /dev/null
+++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FrameLoaderClientImpl_h
+#define FrameLoaderClientImpl_h
+
+#include "FrameLoaderClient.h"
+#include "KURL.h"
+#include "WebNavigationPolicy.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class WebFrameImpl;
+class WebPluginContainerImpl;
+class WebPluginLoadObserver;
+
+class FrameLoaderClientImpl : public WebCore::FrameLoaderClient {
+public:
+ FrameLoaderClientImpl(WebFrameImpl* webFrame);
+ ~FrameLoaderClientImpl();
+
+ WebFrameImpl* webFrame() const { return m_webFrame; }
+
+ // WebCore::FrameLoaderClient ----------------------------------------------
+
+ virtual void frameLoaderDestroyed();
+
+ // Notifies the WebView delegate that the JS window object has been cleared,
+ // giving it a chance to bind native objects to the window before script
+ // parsing begins.
+ virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
+ virtual void documentElementAvailable();
+
+ // A frame's V8 context was created or destroyed.
+ virtual void didCreateScriptContextForFrame();
+ virtual void didDestroyScriptContextForFrame();
+
+ // A context untied to a frame was created (through evaluateInIsolatedWorld).
+ // This context is not tied to the lifetime of its frame, and is destroyed
+ // in garbage collection.
+ virtual void didCreateIsolatedScriptContext();
+
+ // Returns true if we should allow the given V8 extension to be added to
+ // the script context at the currently loading page and given extension group.
+ virtual bool allowScriptExtension(const String& extensionName, int extensionGroup);
+
+ virtual bool hasWebView() const;
+ virtual bool hasFrameView() const;
+ virtual void makeRepresentation(WebCore::DocumentLoader*);
+ virtual void forceLayout();
+ virtual void forceLayoutForNonHTML();
+ virtual void setCopiesOnScroll();
+ virtual void detachedFromParent2();
+ virtual void detachedFromParent3();
+ virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
+ virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
+ virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier);
+ virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
+ virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
+ virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&);
+ virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived);
+ virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier);
+ virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&);
+ virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
+ virtual void dispatchDidHandleOnloadEvents();
+ virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
+ virtual void dispatchDidCancelClientRedirect();
+ virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate);
+ virtual void dispatchDidNavigateWithinPage();
+ virtual void dispatchDidChangeLocationWithinPage();
+ virtual void dispatchDidPushStateWithinPage();
+ virtual void dispatchDidReplaceStateWithinPage();
+ virtual void dispatchDidPopStateWithinPage();
+ virtual void dispatchWillClose();
+ virtual void dispatchDidReceiveIcon();
+ virtual void dispatchDidStartProvisionalLoad();
+ virtual void dispatchDidReceiveTitle(const WTF::String& title);
+ virtual void dispatchDidChangeIcons();
+ virtual void dispatchDidCommitLoad();
+ virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
+ virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
+ virtual void dispatchDidFinishDocumentLoad();
+ virtual void dispatchDidFinishLoad();
+ virtual void dispatchDidFirstLayout();
+ virtual void dispatchDidFirstVisuallyNonEmptyLayout();
+ virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&);
+ virtual void dispatchShow();
+ virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction function, const WTF::String& mime_type, const WebCore::ResourceRequest&);
+ virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state, const WTF::String& frame_name);
+ virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state);
+ virtual void cancelPolicyCheck();
+ virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
+ virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*);
+ virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>);
+ virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*);
+ virtual void revertToProvisionalState(WebCore::DocumentLoader*);
+ virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&);
+ virtual void willChangeEstimatedProgress() { }
+ virtual void didChangeEstimatedProgress() { }
+ virtual void postProgressStartedNotification();
+ virtual void postProgressEstimateChangedNotification();
+ virtual void postProgressFinishedNotification();
+ virtual void setMainFrameDocumentReady(bool);
+ virtual void startDownload(const WebCore::ResourceRequest&);
+ virtual void willChangeTitle(WebCore::DocumentLoader*);
+ virtual void didChangeTitle(WebCore::DocumentLoader*);
+ virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
+ virtual void finishedLoading(WebCore::DocumentLoader*);
+ virtual void updateGlobalHistory();
+ virtual void updateGlobalHistoryRedirectLinks();
+ virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const;
+ virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const;
+ virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const;
+ virtual void dispatchDidChangeBackForwardIndex() const;
+ virtual void didDisplayInsecureContent();
+ virtual void didRunInsecureContent(WebCore::SecurityOrigin*);
+ virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&);
+ virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&);
+ virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&);
+ virtual bool shouldFallBack(const WebCore::ResourceError&);
+ virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
+ virtual bool canShowMIMEType(const WTF::String& MIMEType) const;
+ virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
+ virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const;
+ virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const;
+ virtual void frameLoadCompleted();
+ virtual void saveViewStateToItem(WebCore::HistoryItem*);
+ virtual void restoreViewState();
+ virtual void provisionalLoadStarted();
+ virtual void didFinishLoad();
+ virtual void prepareForDataSourceReplacement();
+ virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(
+ const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
+ virtual void setTitle(const WTF::String& title, const WebCore::KURL&);
+ virtual WTF::String userAgent(const WebCore::KURL&);
+ virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
+ virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
+ virtual void transitionToCommittedForNewPage();
+ virtual void didSaveToPageCache();
+ virtual void didRestoreFromPageCache();
+ virtual void dispatchDidBecomeFrameset(bool);
+ virtual bool canCachePage() const;
+ virtual void download(
+ WebCore::ResourceHandle*, const WebCore::ResourceRequest&,
+ const WebCore::ResourceRequest& initialRequest,
+ const WebCore::ResourceResponse&);
+ virtual PassRefPtr<WebCore::Frame> createFrame(
+ const WebCore::KURL& url, const WTF::String& name,
+ WebCore::HTMLFrameOwnerElement* ownerElement,
+ const WTF::String& referrer, bool allowsScrolling,
+ int marginWidth, int marginHeight);
+ virtual void didTransferChildFrameToNewDocument(WebCore::Page*);
+ virtual void transferLoadingResourceFromPage(unsigned long, WebCore::DocumentLoader*, const WebCore::ResourceRequest&, WebCore::Page*);
+ virtual PassRefPtr<WebCore::Widget> createPlugin(
+ const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&,
+ const Vector<WTF::String>&, const Vector<WTF::String>&,
+ const WTF::String&, bool loadManually);
+ virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
+ virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(
+ const WebCore::IntSize&,
+ WebCore::HTMLAppletElement*,
+ const WebCore::KURL& /* base_url */,
+ const Vector<WTF::String>& paramNames,
+ const Vector<WTF::String>& paramValues);
+ virtual WebCore::ObjectContentType objectContentType(
+ const WebCore::KURL& url, const WTF::String& mimeType);
+ virtual WTF::String overrideMediaType() const;
+ virtual void didPerformFirstNavigation() const;
+ virtual void registerForIconNotification(bool listen = true);
+ virtual void didChangeScrollOffset();
+ virtual bool allowJavaScript(bool enabledPerSettings);
+ virtual bool allowPlugins(bool enabledPerSettings);
+ virtual bool allowImages(bool enabledPerSettings);
+ virtual void didNotAllowScript();
+ virtual void didNotAllowPlugins();
+
+ virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext();
+
+private:
+ void makeDocumentView();
+
+ // Given a NavigationAction, determine the associated WebNavigationPolicy.
+ // For example, a middle click means "open in background tab".
+ static bool actionSpecifiesNavigationPolicy(
+ const WebCore::NavigationAction& action, WebNavigationPolicy* policy);
+
+ PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver();
+
+ // The WebFrame that owns this object and manages its lifetime. Therefore,
+ // the web frame object is guaranteed to exist.
+ WebFrameImpl* m_webFrame;
+
+ // True if makeRepresentation was called. We don't actually have a concept
+ // of a "representation", but we need to know when we're expected to have one.
+ // See finishedLoading().
+ bool m_hasRepresentation;
+
+ // Used to help track client redirects. When a provisional load starts, it
+ // has no redirects in its chain. But in the case of client redirects, we want
+ // to add that initial load as a redirect. When we get a new provisional load
+ // and the dest URL matches that load, we know that it was the result of a
+ // previous client redirect and the source should be added as a redirect.
+ // Both should be empty if unused.
+ WebCore::KURL m_expectedClientRedirectSrc;
+ WebCore::KURL m_expectedClientRedirectDest;
+
+ // Contains a pointer to the plugin widget.
+ RefPtr<WebPluginContainerImpl> m_pluginWidget;
+
+ // Indicates if we need to send over the initial notification to the plugin
+ // which specifies that the plugin should be ready to accept data.
+ bool m_sentInitialResponseToPlugin;
+
+ // The navigation policy to use for the next call to dispatchCreatePage.
+ WebNavigationPolicy m_nextNavigationPolicy;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/FrameNetworkingContextImpl.h b/Source/WebKit/chromium/src/FrameNetworkingContextImpl.h
new file mode 100644
index 0000000..8670506
--- /dev/null
+++ b/Source/WebKit/chromium/src/FrameNetworkingContextImpl.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef FrameNetworkingContextImpl_h
+#define FrameNetworkingContextImpl_h
+
+#include "FrameNetworkingContext.h"
+
+namespace WebKit {
+
+class FrameNetworkingContextImpl : public WebCore::FrameNetworkingContext {
+public:
+ static PassRefPtr<FrameNetworkingContextImpl> create(WebCore::Frame* frame)
+ {
+ return adoptRef(new FrameNetworkingContextImpl(frame));
+ }
+
+private:
+ FrameNetworkingContextImpl(WebCore::Frame* frame)
+ : WebCore::FrameNetworkingContext(frame)
+ {
+ }
+};
+
+}
+
+#endif
diff --git a/Source/WebKit/chromium/src/GeolocationClientProxy.cpp b/Source/WebKit/chromium/src/GeolocationClientProxy.cpp
new file mode 100644
index 0000000..b2536dd
--- /dev/null
+++ b/Source/WebKit/chromium/src/GeolocationClientProxy.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GeolocationClientProxy.h"
+
+#include "Geolocation.h"
+#include "GeolocationPosition.h"
+#include "WebGeolocationClient.h"
+#include "WebGeolocationController.h"
+#include "WebGeolocationPermissionRequest.h"
+#include "WebGeolocationPosition.h"
+
+namespace WebKit {
+
+GeolocationClientProxy::GeolocationClientProxy(WebGeolocationClient* client)
+ : m_client(client)
+{
+}
+
+GeolocationClientProxy::~GeolocationClientProxy()
+{
+}
+
+void GeolocationClientProxy::setController(WebCore::GeolocationController* controller)
+{
+ // We support there not being a client, provided we don't do any Geolocation.
+ if (m_client) {
+ // Ownership of the WebGeolocationController is transferred to the client.
+ m_client->setController(new WebGeolocationController(controller));
+ }
+}
+
+void GeolocationClientProxy::geolocationDestroyed()
+{
+ if (m_client)
+ m_client->geolocationDestroyed();
+}
+
+void GeolocationClientProxy::startUpdating()
+{
+ m_client->startUpdating();
+}
+
+void GeolocationClientProxy::stopUpdating()
+{
+ m_client->stopUpdating();
+}
+
+void GeolocationClientProxy::setEnableHighAccuracy(bool highAccuracy)
+{
+ m_client->setEnableHighAccuracy(highAccuracy);
+}
+
+WebCore::GeolocationPosition* GeolocationClientProxy::lastPosition()
+{
+ WebGeolocationPosition webPosition;
+ if (m_client->lastPosition(webPosition))
+ m_lastPosition = webPosition;
+ else
+ m_lastPosition.clear();
+
+ return m_lastPosition.get();
+}
+
+void GeolocationClientProxy::requestPermission(WebCore::Geolocation* geolocation)
+{
+ m_client->requestPermission(WebGeolocationPermissionRequest(geolocation));
+}
+
+void GeolocationClientProxy::cancelPermissionRequest(WebCore::Geolocation* geolocation)
+{
+ m_client->cancelPermissionRequest(WebGeolocationPermissionRequest(geolocation));
+}
+
+}
diff --git a/Source/WebKit/chromium/src/GeolocationClientProxy.h b/Source/WebKit/chromium/src/GeolocationClientProxy.h
new file mode 100644
index 0000000..ee175dc
--- /dev/null
+++ b/Source/WebKit/chromium/src/GeolocationClientProxy.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GeolocationClientProxy_h
+#define GeolocationClientProxy_h
+
+#include "GeolocationClient.h"
+#include "WebGeolocationController.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class GeolocationPosition;
+}
+
+namespace WebKit {
+class WebGeolocationClient;
+
+class GeolocationClientProxy : public WebCore::GeolocationClient {
+public:
+ GeolocationClientProxy(WebGeolocationClient* client);
+ ~GeolocationClientProxy();
+ void setController(WebCore::GeolocationController *controller);
+ virtual void geolocationDestroyed();
+ virtual void startUpdating();
+ virtual void stopUpdating();
+ virtual void setEnableHighAccuracy(bool);
+ virtual WebCore::GeolocationPosition* lastPosition();
+
+ virtual void requestPermission(WebCore::Geolocation*);
+ virtual void cancelPermissionRequest(WebCore::Geolocation*);
+
+private:
+ WebGeolocationClient* m_client;
+ RefPtr<WebCore::GeolocationPosition> m_lastPosition;
+};
+
+} // namespace WebKit
+
+#endif // GeolocationClientProxy_h
diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
new file mode 100644
index 0000000..8148ff6
--- /dev/null
+++ b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
@@ -0,0 +1,1076 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "GraphicsContext3D.h"
+
+#include "CachedImage.h"
+#include "WebGLLayerChromium.h"
+#include "CanvasRenderingContext.h"
+#include "Chrome.h"
+#include "ChromeClientImpl.h"
+#include "Extensions3DChromium.h"
+#include "GraphicsContext3DInternal.h"
+#include "HTMLCanvasElement.h"
+#include "HTMLImageElement.h"
+#include "ImageBuffer.h"
+#include "ImageData.h"
+#include "WebGraphicsContext3D.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebViewImpl.h"
+
+#include <stdio.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/text/CString.h>
+
+#if PLATFORM(CG)
+#include "GraphicsContext.h"
+#include "WebGLRenderingContext.h"
+#include <CoreGraphics/CGContext.h>
+#include <CoreGraphics/CGImage.h>
+#endif
+
+// There are two levels of delegation in this file:
+//
+// 1. GraphicsContext3D delegates to GraphicsContext3DInternal. This is done
+// so that we have some place to store data members common among
+// implementations; GraphicsContext3D only provides us the m_internal
+// pointer. We always delegate to the GraphicsContext3DInternal. While we
+// could sidestep it and go directly to the WebGraphicsContext3D in some
+// cases, it is better for consistency to always delegate through it.
+//
+// 2. GraphicsContext3DInternal delegates to an implementation of
+// WebGraphicsContext3D. This is done so we have a place to inject an
+// implementation which remotes the OpenGL calls across processes.
+
+namespace WebCore {
+
+//----------------------------------------------------------------------
+// GraphicsContext3DInternal
+
+GraphicsContext3DInternal::GraphicsContext3DInternal()
+ : m_webViewImpl(0)
+ , m_initializedAvailableExtensions(false)
+#if PLATFORM(SKIA)
+#elif PLATFORM(CG)
+ , m_renderOutput(0)
+#else
+#error Must port to your platform
+#endif
+{
+}
+
+GraphicsContext3DInternal::~GraphicsContext3DInternal()
+{
+#if PLATFORM(CG)
+ if (m_renderOutput)
+ delete[] m_renderOutput;
+#endif
+}
+
+bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
+{
+ WebKit::WebGraphicsContext3D::Attributes webAttributes;
+ webAttributes.alpha = attrs.alpha;
+ webAttributes.depth = attrs.depth;
+ webAttributes.stencil = attrs.stencil;
+ webAttributes.antialias = attrs.antialias;
+ webAttributes.premultipliedAlpha = attrs.premultipliedAlpha;
+ webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss;
+ WebKit::WebGraphicsContext3D* webContext = WebKit::webKitClient()->createGraphicsContext3D();
+ if (!webContext)
+ return false;
+
+ Chrome* chrome = static_cast<Chrome*>(hostWindow);
+ WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(chrome->client());
+
+ m_webViewImpl = chromeClientImpl->webView();
+
+ if (!m_webViewImpl)
+ return false;
+ if (!webContext->initialize(webAttributes, m_webViewImpl, renderDirectlyToHostWindow)) {
+ delete webContext;
+ return false;
+ }
+ m_impl.set(webContext);
+
+#if USE(ACCELERATED_COMPOSITING)
+ m_compositingLayer = WebGLLayerChromium::create(0);
+#endif
+ return true;
+}
+
+WebKit::WebGraphicsContext3D* GraphicsContext3DInternal::extractWebGraphicsContext3D(GraphicsContext3D* context)
+{
+ if (!context)
+ return 0;
+ return context->m_internal->m_impl.get();
+}
+
+PlatformGraphicsContext3D GraphicsContext3DInternal::platformGraphicsContext3D() const
+{
+ return m_impl.get();
+}
+
+Platform3DObject GraphicsContext3DInternal::platformTexture() const
+{
+ return m_impl->getPlatformTextureId();
+}
+
+void GraphicsContext3DInternal::prepareTexture()
+{
+ m_impl->prepareTexture();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const
+{
+ return m_compositingLayer.get();
+}
+#endif
+
+void GraphicsContext3DInternal::paintRenderingResultsToCanvas(CanvasRenderingContext* context)
+{
+ HTMLCanvasElement* canvas = context->canvas();
+ ImageBuffer* imageBuffer = canvas->buffer();
+ unsigned char* pixels = 0;
+#if PLATFORM(SKIA)
+ const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap();
+ const SkBitmap* readbackBitmap = 0;
+ ASSERT(canvasBitmap->config() == SkBitmap::kARGB_8888_Config);
+ if (canvasBitmap->width() == m_impl->width() && canvasBitmap->height() == m_impl->height()) {
+ // This is the fastest and most common case. We read back
+ // directly into the canvas's backing store.
+ readbackBitmap = canvasBitmap;
+ m_resizingBitmap.reset();
+ } else {
+ // We need to allocate a temporary bitmap for reading back the
+ // pixel data. We will then use Skia to rescale this bitmap to
+ // the size of the canvas's backing store.
+ if (m_resizingBitmap.width() != m_impl->width() || m_resizingBitmap.height() != m_impl->height()) {
+ m_resizingBitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ m_impl->width(),
+ m_impl->height());
+ if (!m_resizingBitmap.allocPixels())
+ return;
+ }
+ readbackBitmap = &m_resizingBitmap;
+ }
+
+ // Read back the frame buffer.
+ SkAutoLockPixels bitmapLock(*readbackBitmap);
+ pixels = static_cast<unsigned char*>(readbackBitmap->getPixels());
+#elif PLATFORM(CG)
+ if (m_renderOutput)
+ pixels = m_renderOutput;
+#else
+#error Must port to your platform
+#endif
+
+ m_impl->readBackFramebuffer(pixels, 4 * m_impl->width() * m_impl->height());
+
+#if PLATFORM(SKIA)
+ if (m_resizingBitmap.readyToDraw()) {
+ // We need to draw the resizing bitmap into the canvas's backing store.
+ SkCanvas canvas(*canvasBitmap);
+ SkRect dst;
+ dst.set(SkIntToScalar(0), SkIntToScalar(0), canvasBitmap->width(), canvasBitmap->height());
+ canvas.drawBitmapRect(m_resizingBitmap, 0, dst);
+ }
+#elif PLATFORM(CG)
+ if (m_renderOutput && context->is3d()) {
+ WebGLRenderingContext* webGLContext = static_cast<WebGLRenderingContext*>(context);
+ webGLContext->graphicsContext3D()->paintToCanvas(m_renderOutput, m_impl->width(), m_impl->height(), canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
+ }
+#else
+#error Must port to your platform
+#endif
+}
+
+bool GraphicsContext3DInternal::paintsIntoCanvasBuffer() const
+{
+ // If the gpu compositor is on then skip the readback and software rendering path.
+ return !m_webViewImpl->isAcceleratedCompositingActive();
+}
+
+void GraphicsContext3DInternal::reshape(int width, int height)
+{
+ if (width == m_impl->width() && height == m_impl->height())
+ return;
+
+ m_impl->reshape(width, height);
+
+#if PLATFORM(CG)
+ // Need to reallocate the client-side backing store.
+ // FIXME: make this more efficient.
+ if (m_renderOutput) {
+ delete[] m_renderOutput;
+ m_renderOutput = 0;
+ }
+ int rowBytes = width * 4;
+ m_renderOutput = new unsigned char[height * rowBytes];
+#endif // PLATFORM(CG)
+}
+
+IntSize GraphicsContext3DInternal::getInternalFramebufferSize()
+{
+ return IntSize(m_impl->width(), m_impl->height());
+}
+
+bool GraphicsContext3DInternal::isContextLost()
+{
+ return m_impl->isContextLost();
+}
+
+// Macros to assist in delegating from GraphicsContext3DInternal to
+// WebGraphicsContext3D.
+
+#define DELEGATE_TO_IMPL(name) \
+void GraphicsContext3DInternal::name() \
+{ \
+ m_impl->name(); \
+}
+
+#define DELEGATE_TO_IMPL_R(name, rt) \
+rt GraphicsContext3DInternal::name() \
+{ \
+ return m_impl->name(); \
+}
+
+#define DELEGATE_TO_IMPL_1(name, t1) \
+void GraphicsContext3DInternal::name(t1 a1) \
+{ \
+ m_impl->name(a1); \
+}
+
+#define DELEGATE_TO_IMPL_1R(name, t1, rt) \
+rt GraphicsContext3DInternal::name(t1 a1) \
+{ \
+ return m_impl->name(a1); \
+}
+
+#define DELEGATE_TO_IMPL_2(name, t1, t2) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2) \
+{ \
+ m_impl->name(a1, a2); \
+}
+
+#define DELEGATE_TO_IMPL_2R(name, t1, t2, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2) \
+{ \
+ return m_impl->name(a1, a2); \
+}
+
+#define DELEGATE_TO_IMPL_3(name, t1, t2, t3) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3) \
+{ \
+ m_impl->name(a1, a2, a3); \
+}
+
+#define DELEGATE_TO_IMPL_3R(name, t1, t2, t3, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3) \
+{ \
+ return m_impl->name(a1, a2, a3); \
+}
+
+#define DELEGATE_TO_IMPL_4(name, t1, t2, t3, t4) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4) \
+{ \
+ m_impl->name(a1, a2, a3, a4); \
+}
+
+#define DELEGATE_TO_IMPL_4R(name, t1, t2, t3, t4, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4) \
+{ \
+ return m_impl->name(a1, a2, a3, a4); \
+}
+
+#define DELEGATE_TO_IMPL_5(name, t1, t2, t3, t4, t5) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \
+{ \
+ m_impl->name(a1, a2, a3, a4, a5); \
+}
+
+#define DELEGATE_TO_IMPL_5R(name, t1, t2, t3, t4, t5, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \
+{ \
+ return m_impl->name(a1, a2, a3, a4, a5); \
+}
+
+#define DELEGATE_TO_IMPL_6(name, t1, t2, t3, t4, t5, t6) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
+{ \
+ m_impl->name(a1, a2, a3, a4, a5, a6); \
+}
+
+#define DELEGATE_TO_IMPL_6R(name, t1, t2, t3, t4, t5, t6, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
+{ \
+ return m_impl->name(a1, a2, a3, a4, a5, a6); \
+}
+
+#define DELEGATE_TO_IMPL_7(name, t1, t2, t3, t4, t5, t6, t7) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
+{ \
+ m_impl->name(a1, a2, a3, a4, a5, a6, a7); \
+}
+
+#define DELEGATE_TO_IMPL_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
+{ \
+ return m_impl->name(a1, a2, a3, a4, a5, a6, a7); \
+}
+
+#define DELEGATE_TO_IMPL_8(name, t1, t2, t3, t4, t5, t6, t7, t8) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \
+{ \
+ m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8); \
+}
+
+#define DELEGATE_TO_IMPL_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \
+rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
+{ \
+ return m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
+}
+
+DELEGATE_TO_IMPL_R(makeContextCurrent, bool)
+DELEGATE_TO_IMPL_1R(sizeInBytes, GC3Denum, unsigned int)
+
+bool GraphicsContext3DInternal::isGLES2Compliant() const
+{
+ return m_impl->isGLES2Compliant();
+}
+
+DELEGATE_TO_IMPL_1(activeTexture, GC3Denum)
+DELEGATE_TO_IMPL_2(attachShader, Platform3DObject, Platform3DObject)
+
+void GraphicsContext3DInternal::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name)
+{
+ m_impl->bindAttribLocation(program, index, name.utf8().data());
+}
+
+DELEGATE_TO_IMPL_2(bindBuffer, GC3Denum, Platform3DObject)
+DELEGATE_TO_IMPL_2(bindFramebuffer, GC3Denum, Platform3DObject)
+DELEGATE_TO_IMPL_2(bindRenderbuffer, GC3Denum, Platform3DObject)
+DELEGATE_TO_IMPL_2(bindTexture, GC3Denum, Platform3DObject)
+DELEGATE_TO_IMPL_4(blendColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf)
+DELEGATE_TO_IMPL_1(blendEquation, GC3Denum)
+DELEGATE_TO_IMPL_2(blendEquationSeparate, GC3Denum, GC3Denum)
+DELEGATE_TO_IMPL_2(blendFunc, GC3Denum, GC3Denum)
+DELEGATE_TO_IMPL_4(blendFuncSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum)
+
+void GraphicsContext3DInternal::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage)
+{
+ m_impl->bufferData(target, size, 0, usage);
+}
+
+void GraphicsContext3DInternal::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage)
+{
+ m_impl->bufferData(target, size, data, usage);
+}
+
+void GraphicsContext3DInternal::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data)
+{
+ m_impl->bufferSubData(target, offset, size, data);
+}
+
+DELEGATE_TO_IMPL_1R(checkFramebufferStatus, GC3Denum, GC3Denum)
+DELEGATE_TO_IMPL_1(clear, GC3Dbitfield)
+DELEGATE_TO_IMPL_4(clearColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf)
+DELEGATE_TO_IMPL_1(clearDepth, GC3Dclampf)
+DELEGATE_TO_IMPL_1(clearStencil, GC3Dint)
+DELEGATE_TO_IMPL_4(colorMask, GC3Dboolean, GC3Dboolean, GC3Dboolean, GC3Dboolean)
+DELEGATE_TO_IMPL_1(compileShader, Platform3DObject)
+
+DELEGATE_TO_IMPL_8(copyTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Dint)
+DELEGATE_TO_IMPL_8(copyTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+DELEGATE_TO_IMPL_1(cullFace, GC3Denum)
+DELEGATE_TO_IMPL_1(depthFunc, GC3Denum)
+DELEGATE_TO_IMPL_1(depthMask, GC3Dboolean)
+DELEGATE_TO_IMPL_2(depthRange, GC3Dclampf, GC3Dclampf)
+DELEGATE_TO_IMPL_2(detachShader, Platform3DObject, Platform3DObject)
+DELEGATE_TO_IMPL_1(disable, GC3Denum)
+DELEGATE_TO_IMPL_1(disableVertexAttribArray, GC3Duint)
+DELEGATE_TO_IMPL_3(drawArrays, GC3Denum, GC3Dint, GC3Dsizei)
+DELEGATE_TO_IMPL_4(drawElements, GC3Denum, GC3Dsizei, GC3Denum, GC3Dsizeiptr)
+
+DELEGATE_TO_IMPL_1(enable, GC3Denum)
+DELEGATE_TO_IMPL_1(enableVertexAttribArray, GC3Duint)
+DELEGATE_TO_IMPL(finish)
+DELEGATE_TO_IMPL(flush)
+DELEGATE_TO_IMPL_4(framebufferRenderbuffer, GC3Denum, GC3Denum, GC3Denum, Platform3DObject)
+DELEGATE_TO_IMPL_5(framebufferTexture2D, GC3Denum, GC3Denum, GC3Denum, Platform3DObject, GC3Dint)
+DELEGATE_TO_IMPL_1(frontFace, GC3Denum)
+DELEGATE_TO_IMPL_1(generateMipmap, GC3Denum)
+
+bool GraphicsContext3DInternal::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info)
+{
+ WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
+ if (!m_impl->getActiveAttrib(program, index, webInfo))
+ return false;
+ info.name = webInfo.name;
+ info.type = webInfo.type;
+ info.size = webInfo.size;
+ return true;
+}
+
+bool GraphicsContext3DInternal::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info)
+{
+ WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
+ if (!m_impl->getActiveUniform(program, index, webInfo))
+ return false;
+ info.name = webInfo.name;
+ info.type = webInfo.type;
+ info.size = webInfo.size;
+ return true;
+}
+
+DELEGATE_TO_IMPL_4(getAttachedShaders, Platform3DObject, GC3Dsizei, GC3Dsizei*, Platform3DObject*)
+
+GC3Dint GraphicsContext3DInternal::getAttribLocation(Platform3DObject program, const String& name)
+{
+ return m_impl->getAttribLocation(program, name.utf8().data());
+}
+
+DELEGATE_TO_IMPL_2(getBooleanv, GC3Denum, GC3Dboolean*)
+
+DELEGATE_TO_IMPL_3(getBufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
+
+GraphicsContext3D::Attributes GraphicsContext3DInternal::getContextAttributes()
+{
+ WebKit::WebGraphicsContext3D::Attributes webAttributes = m_impl->getContextAttributes();
+ GraphicsContext3D::Attributes attributes;
+ attributes.alpha = webAttributes.alpha;
+ attributes.depth = webAttributes.depth;
+ attributes.stencil = webAttributes.stencil;
+ attributes.antialias = webAttributes.antialias;
+ attributes.premultipliedAlpha = webAttributes.premultipliedAlpha;
+ return attributes;
+}
+
+DELEGATE_TO_IMPL_R(getError, GC3Denum)
+
+DELEGATE_TO_IMPL_2(getFloatv, GC3Denum, GC3Dfloat*)
+
+DELEGATE_TO_IMPL_4(getFramebufferAttachmentParameteriv, GC3Denum, GC3Denum, GC3Denum, GC3Dint*)
+
+DELEGATE_TO_IMPL_2(getIntegerv, GC3Denum, GC3Dint*)
+
+DELEGATE_TO_IMPL_3(getProgramiv, Platform3DObject, GC3Denum, GC3Dint*)
+
+String GraphicsContext3DInternal::getProgramInfoLog(Platform3DObject program)
+{
+ return m_impl->getProgramInfoLog(program);
+}
+
+DELEGATE_TO_IMPL_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
+
+DELEGATE_TO_IMPL_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*)
+
+String GraphicsContext3DInternal::getShaderInfoLog(Platform3DObject shader)
+{
+ return m_impl->getShaderInfoLog(shader);
+}
+
+String GraphicsContext3DInternal::getShaderSource(Platform3DObject shader)
+{
+ return m_impl->getShaderSource(shader);
+}
+
+String GraphicsContext3DInternal::getString(GC3Denum name)
+{
+ return m_impl->getString(name);
+}
+
+DELEGATE_TO_IMPL_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*)
+DELEGATE_TO_IMPL_3(getTexParameteriv, GC3Denum, GC3Denum, GC3Dint*)
+
+DELEGATE_TO_IMPL_3(getUniformfv, Platform3DObject, GC3Dint, GC3Dfloat*)
+DELEGATE_TO_IMPL_3(getUniformiv, Platform3DObject, GC3Dint, GC3Dint*)
+
+GC3Dint GraphicsContext3DInternal::getUniformLocation(Platform3DObject program, const String& name)
+{
+ return m_impl->getUniformLocation(program, name.utf8().data());
+}
+
+DELEGATE_TO_IMPL_3(getVertexAttribfv, GC3Duint, GC3Denum, GC3Dfloat*)
+DELEGATE_TO_IMPL_3(getVertexAttribiv, GC3Duint, GC3Denum, GC3Dint*)
+
+DELEGATE_TO_IMPL_2R(getVertexAttribOffset, GC3Duint, GC3Denum, GC3Dsizeiptr)
+
+DELEGATE_TO_IMPL_2(hint, GC3Denum, GC3Denum)
+DELEGATE_TO_IMPL_1R(isBuffer, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_IMPL_1R(isEnabled, GC3Denum, GC3Dboolean)
+DELEGATE_TO_IMPL_1R(isFramebuffer, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_IMPL_1R(isProgram, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_IMPL_1R(isRenderbuffer, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_IMPL_1R(isShader, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_IMPL_1R(isTexture, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_IMPL_1(lineWidth, GC3Dfloat)
+DELEGATE_TO_IMPL_1(linkProgram, Platform3DObject)
+DELEGATE_TO_IMPL_2(pixelStorei, GC3Denum, GC3Dint)
+DELEGATE_TO_IMPL_2(polygonOffset, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_IMPL_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, void*)
+DELEGATE_TO_IMPL(releaseShaderCompiler)
+DELEGATE_TO_IMPL_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3Dsizei)
+DELEGATE_TO_IMPL_2(sampleCoverage, GC3Dclampf, GC3Dboolean)
+DELEGATE_TO_IMPL_4(scissor, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+
+void GraphicsContext3DInternal::shaderSource(Platform3DObject shader, const String& string)
+{
+ m_impl->shaderSource(shader, string.utf8().data());
+}
+
+DELEGATE_TO_IMPL_3(stencilFunc, GC3Denum, GC3Dint, GC3Duint)
+DELEGATE_TO_IMPL_4(stencilFuncSeparate, GC3Denum, GC3Denum, GC3Dint, GC3Duint)
+DELEGATE_TO_IMPL_1(stencilMask, GC3Duint)
+DELEGATE_TO_IMPL_2(stencilMaskSeparate, GC3Denum, GC3Duint)
+DELEGATE_TO_IMPL_3(stencilOp, GC3Denum, GC3Denum, GC3Denum)
+DELEGATE_TO_IMPL_4(stencilOpSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum)
+
+bool GraphicsContext3DInternal::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
+{
+ m_impl->texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+ return true;
+}
+
+DELEGATE_TO_IMPL_3(texParameterf, GC3Denum, GC3Denum, GC3Dfloat)
+DELEGATE_TO_IMPL_3(texParameteri, GC3Denum, GC3Denum, GC3Dint)
+
+void GraphicsContext3DInternal::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels)
+{
+ m_impl->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+}
+
+DELEGATE_TO_IMPL_2(uniform1f, GC3Dint, GC3Dfloat)
+
+void GraphicsContext3DInternal::uniform1fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size)
+{
+ m_impl->uniform1fv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_2(uniform1i, GC3Dint, GC3Dint)
+
+void GraphicsContext3DInternal::uniform1iv(GC3Dint location, GC3Dint* v, GC3Dsizei size)
+{
+ m_impl->uniform1iv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat)
+
+void GraphicsContext3DInternal::uniform2fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size)
+{
+ m_impl->uniform2fv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_3(uniform2i, GC3Dint, GC3Dint, GC3Dint)
+
+void GraphicsContext3DInternal::uniform2iv(GC3Dint location, GC3Dint* v, GC3Dsizei size)
+{
+ m_impl->uniform2iv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+
+void GraphicsContext3DInternal::uniform3fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size)
+{
+ m_impl->uniform3fv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
+
+void GraphicsContext3DInternal::uniform3iv(GC3Dint location, GC3Dint* v, GC3Dsizei size)
+{
+ m_impl->uniform3iv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+
+void GraphicsContext3DInternal::uniform4fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size)
+{
+ m_impl->uniform4fv(location, size, v);
+}
+
+DELEGATE_TO_IMPL_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
+
+void GraphicsContext3DInternal::uniform4iv(GC3Dint location, GC3Dint* v, GC3Dsizei size)
+{
+ m_impl->uniform4iv(location, size, v);
+}
+
+void GraphicsContext3DInternal::uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size)
+{
+ m_impl->uniformMatrix2fv(location, size, transpose, value);
+}
+
+void GraphicsContext3DInternal::uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size)
+{
+ m_impl->uniformMatrix3fv(location, size, transpose, value);
+}
+
+void GraphicsContext3DInternal::uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size)
+{
+ m_impl->uniformMatrix4fv(location, size, transpose, value);
+}
+
+DELEGATE_TO_IMPL_1(useProgram, Platform3DObject)
+DELEGATE_TO_IMPL_1(validateProgram, Platform3DObject)
+
+DELEGATE_TO_IMPL_2(vertexAttrib1f, GC3Duint, GC3Dfloat)
+DELEGATE_TO_IMPL_2(vertexAttrib1fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_IMPL_3(vertexAttrib2f, GC3Duint, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_IMPL_2(vertexAttrib2fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_IMPL_4(vertexAttrib3f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_IMPL_2(vertexAttrib3fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_IMPL_5(vertexAttrib4f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_IMPL_2(vertexAttrib4fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_IMPL_6(vertexAttribPointer, GC3Duint, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dsizeiptr)
+
+DELEGATE_TO_IMPL_4(viewport, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+
+DELEGATE_TO_IMPL_R(createBuffer, Platform3DObject)
+DELEGATE_TO_IMPL_R(createFramebuffer, Platform3DObject)
+DELEGATE_TO_IMPL_R(createProgram, Platform3DObject)
+DELEGATE_TO_IMPL_R(createRenderbuffer, Platform3DObject)
+DELEGATE_TO_IMPL_1R(createShader, GC3Denum, Platform3DObject)
+DELEGATE_TO_IMPL_R(createTexture, Platform3DObject)
+
+DELEGATE_TO_IMPL_1(deleteBuffer, Platform3DObject)
+DELEGATE_TO_IMPL_1(deleteFramebuffer, Platform3DObject)
+DELEGATE_TO_IMPL_1(deleteProgram, Platform3DObject)
+DELEGATE_TO_IMPL_1(deleteRenderbuffer, Platform3DObject)
+DELEGATE_TO_IMPL_1(deleteShader, Platform3DObject)
+DELEGATE_TO_IMPL_1(deleteTexture, Platform3DObject)
+
+DELEGATE_TO_IMPL_1(synthesizeGLError, GC3Denum)
+
+Extensions3D* GraphicsContext3DInternal::getExtensions()
+{
+ if (!m_extensions)
+ m_extensions = adoptPtr(new Extensions3DChromium(this));
+ return m_extensions.get();
+}
+
+namespace {
+
+void splitStringHelper(const String& str, HashSet<String>& set)
+{
+ Vector<String> substrings;
+ str.split(" ", substrings);
+ for (size_t i = 0; i < substrings.size(); ++i)
+ set.add(substrings[i]);
+}
+
+} // anonymous namespace
+
+void GraphicsContext3DInternal::initializeExtensions()
+{
+ if (!m_initializedAvailableExtensions) {
+ String extensionsString = getString(GraphicsContext3D::EXTENSIONS);
+ splitStringHelper(extensionsString, m_enabledExtensions);
+
+ String requestableExtensionsString = m_impl->getRequestableExtensionsCHROMIUM();
+ splitStringHelper(requestableExtensionsString, m_requestableExtensions);
+
+ m_initializedAvailableExtensions = true;
+ }
+}
+
+
+bool GraphicsContext3DInternal::supportsExtension(const String& name)
+{
+ initializeExtensions();
+ return m_enabledExtensions.contains(name) || m_requestableExtensions.contains(name);
+}
+
+bool GraphicsContext3DInternal::ensureExtensionEnabled(const String& name)
+{
+ initializeExtensions();
+
+ if (m_enabledExtensions.contains(name))
+ return true;
+
+ if (m_requestableExtensions.contains(name)) {
+ m_impl->requestExtensionCHROMIUM(name.ascii().data());
+ m_enabledExtensions.clear();
+ m_requestableExtensions.clear();
+ m_initializedAvailableExtensions = false;
+ }
+
+ initializeExtensions();
+ return m_enabledExtensions.contains(name);
+}
+
+DELEGATE_TO_IMPL_4R(mapBufferSubDataCHROMIUM, GC3Denum, GC3Dsizeiptr, GC3Dsizei, GC3Denum, void*)
+DELEGATE_TO_IMPL_1(unmapBufferSubDataCHROMIUM, const void*)
+DELEGATE_TO_IMPL_9R(mapTexSubImage2DCHROMIUM, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, GC3Denum, void*)
+DELEGATE_TO_IMPL_1(unmapTexSubImage2DCHROMIUM, const void*)
+DELEGATE_TO_IMPL_2(copyTextureToParentTextureCHROMIUM, Platform3DObject, Platform3DObject)
+
+//----------------------------------------------------------------------
+// GraphicsContext3D
+//
+
+// Macros to assist in delegating from GraphicsContext3D to
+// GraphicsContext3DInternal.
+
+#define DELEGATE_TO_INTERNAL(name) \
+void GraphicsContext3D::name() \
+{ \
+ m_internal->name(); \
+}
+
+#define DELEGATE_TO_INTERNAL_R(name, rt) \
+rt GraphicsContext3D::name() \
+{ \
+ return m_internal->name(); \
+}
+
+#define DELEGATE_TO_INTERNAL_1(name, t1) \
+void GraphicsContext3D::name(t1 a1) \
+{ \
+ m_internal->name(a1); \
+}
+
+#define DELEGATE_TO_INTERNAL_1R(name, t1, rt) \
+rt GraphicsContext3D::name(t1 a1) \
+{ \
+ return m_internal->name(a1); \
+}
+
+#define DELEGATE_TO_INTERNAL_2(name, t1, t2) \
+void GraphicsContext3D::name(t1 a1, t2 a2) \
+{ \
+ m_internal->name(a1, a2); \
+}
+
+#define DELEGATE_TO_INTERNAL_2R(name, t1, t2, rt) \
+rt GraphicsContext3D::name(t1 a1, t2 a2) \
+{ \
+ return m_internal->name(a1, a2); \
+}
+
+#define DELEGATE_TO_INTERNAL_3(name, t1, t2, t3) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \
+{ \
+ m_internal->name(a1, a2, a3); \
+}
+
+#define DELEGATE_TO_INTERNAL_3R(name, t1, t2, t3, rt) \
+rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \
+{ \
+ return m_internal->name(a1, a2, a3); \
+}
+
+#define DELEGATE_TO_INTERNAL_4(name, t1, t2, t3, t4) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \
+{ \
+ m_internal->name(a1, a2, a3, a4); \
+}
+
+#define DELEGATE_TO_INTERNAL_4R(name, t1, t2, t3, t4, rt) \
+rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \
+{ \
+ return m_internal->name(a1, a2, a3, a4); \
+}
+
+#define DELEGATE_TO_INTERNAL_5(name, t1, t2, t3, t4, t5) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \
+{ \
+ m_internal->name(a1, a2, a3, a4, a5); \
+}
+
+#define DELEGATE_TO_INTERNAL_6(name, t1, t2, t3, t4, t5, t6) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
+{ \
+ m_internal->name(a1, a2, a3, a4, a5, a6); \
+}
+
+#define DELEGATE_TO_INTERNAL_6R(name, t1, t2, t3, t4, t5, t6, rt) \
+rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
+{ \
+ return m_internal->name(a1, a2, a3, a4, a5, a6); \
+}
+
+#define DELEGATE_TO_INTERNAL_7(name, t1, t2, t3, t4, t5, t6, t7) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
+{ \
+ m_internal->name(a1, a2, a3, a4, a5, a6, a7); \
+}
+
+#define DELEGATE_TO_INTERNAL_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \
+rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
+{ \
+ return m_internal->name(a1, a2, a3, a4, a5, a6, a7); \
+}
+
+#define DELEGATE_TO_INTERNAL_8(name, t1, t2, t3, t4, t5, t6, t7, t8) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \
+{ \
+ m_internal->name(a1, a2, a3, a4, a5, a6, a7, a8); \
+}
+
+#define DELEGATE_TO_INTERNAL_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
+void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
+{ \
+ m_internal->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
+}
+
+#define DELEGATE_TO_INTERNAL_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \
+rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
+{ \
+ return m_internal->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
+}
+
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, bool)
+{
+}
+
+GraphicsContext3D::~GraphicsContext3D()
+{
+}
+
+PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
+{
+ OwnPtr<GraphicsContext3DInternal> internal = adoptPtr(new GraphicsContext3DInternal());
+ if (!internal->initialize(attrs, hostWindow, renderStyle == RenderDirectlyToHostWindow)) {
+ return 0;
+ }
+ RefPtr<GraphicsContext3D> result = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle == RenderDirectlyToHostWindow));
+ result->m_internal = internal.release();
+ return result.release();
+}
+
+PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const
+{
+ return m_internal->platformGraphicsContext3D();
+}
+
+Platform3DObject GraphicsContext3D::platformTexture() const
+{
+ return m_internal->platformTexture();
+}
+
+void GraphicsContext3D::prepareTexture()
+{
+ return m_internal->prepareTexture();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* GraphicsContext3D::platformLayer() const
+{
+ WebGLLayerChromium* canvasLayer = m_internal->platformLayer();
+ canvasLayer->setContext(this);
+ return canvasLayer;
+}
+#endif
+
+DELEGATE_TO_INTERNAL(makeContextCurrent)
+DELEGATE_TO_INTERNAL_1R(sizeInBytes, GC3Denum, unsigned int)
+DELEGATE_TO_INTERNAL_2(reshape, int, int)
+DELEGATE_TO_INTERNAL_R(getInternalFramebufferSize, IntSize)
+
+DELEGATE_TO_INTERNAL_1(activeTexture, GC3Denum)
+DELEGATE_TO_INTERNAL_2(attachShader, Platform3DObject, Platform3DObject)
+DELEGATE_TO_INTERNAL_3(bindAttribLocation, Platform3DObject, GC3Duint, const String&)
+
+DELEGATE_TO_INTERNAL_2(bindBuffer, GC3Denum, Platform3DObject)
+DELEGATE_TO_INTERNAL_2(bindFramebuffer, GC3Denum, Platform3DObject)
+DELEGATE_TO_INTERNAL_2(bindRenderbuffer, GC3Denum, Platform3DObject)
+DELEGATE_TO_INTERNAL_2(bindTexture, GC3Denum, Platform3DObject)
+DELEGATE_TO_INTERNAL_4(blendColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf)
+DELEGATE_TO_INTERNAL_1(blendEquation, GC3Denum)
+DELEGATE_TO_INTERNAL_2(blendEquationSeparate, GC3Denum, GC3Denum)
+DELEGATE_TO_INTERNAL_2(blendFunc, GC3Denum, GC3Denum)
+DELEGATE_TO_INTERNAL_4(blendFuncSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum)
+
+DELEGATE_TO_INTERNAL_3(bufferData, GC3Denum, GC3Dsizeiptr, GC3Denum)
+DELEGATE_TO_INTERNAL_4(bufferData, GC3Denum, GC3Dsizeiptr, const void*, GC3Denum)
+DELEGATE_TO_INTERNAL_4(bufferSubData, GC3Denum, GC3Dintptr, GC3Dsizeiptr, const void*)
+
+DELEGATE_TO_INTERNAL_1R(checkFramebufferStatus, GC3Denum, GC3Denum)
+DELEGATE_TO_INTERNAL_1(clear, GC3Dbitfield)
+DELEGATE_TO_INTERNAL_4(clearColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dclampf)
+DELEGATE_TO_INTERNAL_1(clearDepth, GC3Dclampf)
+DELEGATE_TO_INTERNAL_1(clearStencil, GC3Dint)
+DELEGATE_TO_INTERNAL_4(colorMask, GC3Dboolean, GC3Dboolean, GC3Dboolean, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1(compileShader, Platform3DObject)
+
+DELEGATE_TO_INTERNAL_8(copyTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Dint)
+DELEGATE_TO_INTERNAL_8(copyTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+DELEGATE_TO_INTERNAL_1(cullFace, GC3Denum)
+DELEGATE_TO_INTERNAL_1(depthFunc, GC3Denum)
+DELEGATE_TO_INTERNAL_1(depthMask, GC3Dboolean)
+DELEGATE_TO_INTERNAL_2(depthRange, GC3Dclampf, GC3Dclampf)
+DELEGATE_TO_INTERNAL_2(detachShader, Platform3DObject, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(disable, GC3Denum)
+DELEGATE_TO_INTERNAL_1(disableVertexAttribArray, GC3Duint)
+DELEGATE_TO_INTERNAL_3(drawArrays, GC3Denum, GC3Dint, GC3Dsizei)
+DELEGATE_TO_INTERNAL_4(drawElements, GC3Denum, GC3Dsizei, GC3Denum, GC3Dintptr)
+
+DELEGATE_TO_INTERNAL_1(enable, GC3Denum)
+DELEGATE_TO_INTERNAL_1(enableVertexAttribArray, GC3Duint)
+DELEGATE_TO_INTERNAL(finish)
+DELEGATE_TO_INTERNAL(flush)
+DELEGATE_TO_INTERNAL_4(framebufferRenderbuffer, GC3Denum, GC3Denum, GC3Denum, Platform3DObject)
+DELEGATE_TO_INTERNAL_5(framebufferTexture2D, GC3Denum, GC3Denum, GC3Denum, Platform3DObject, GC3Dint)
+DELEGATE_TO_INTERNAL_1(frontFace, GC3Denum)
+DELEGATE_TO_INTERNAL_1(generateMipmap, GC3Denum)
+
+DELEGATE_TO_INTERNAL_3R(getActiveAttrib, Platform3DObject, GC3Duint, ActiveInfo&, bool)
+DELEGATE_TO_INTERNAL_3R(getActiveUniform, Platform3DObject, GC3Duint, ActiveInfo&, bool)
+DELEGATE_TO_INTERNAL_4(getAttachedShaders, Platform3DObject, GC3Dsizei, GC3Dsizei*, Platform3DObject*)
+DELEGATE_TO_INTERNAL_2R(getAttribLocation, Platform3DObject, const String&, GC3Dint)
+DELEGATE_TO_INTERNAL_2(getBooleanv, GC3Denum, GC3Dboolean*)
+DELEGATE_TO_INTERNAL_3(getBufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_R(getContextAttributes, GraphicsContext3D::Attributes)
+DELEGATE_TO_INTERNAL_R(getError, GC3Denum)
+DELEGATE_TO_INTERNAL_2(getFloatv, GC3Denum, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_4(getFramebufferAttachmentParameteriv, GC3Denum, GC3Denum, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_2(getIntegerv, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_3(getProgramiv, Platform3DObject, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_1R(getProgramInfoLog, Platform3DObject, String)
+DELEGATE_TO_INTERNAL_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_1R(getShaderInfoLog, Platform3DObject, String)
+DELEGATE_TO_INTERNAL_1R(getShaderSource, Platform3DObject, String)
+DELEGATE_TO_INTERNAL_1R(getString, GC3Denum, String)
+DELEGATE_TO_INTERNAL_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_3(getTexParameteriv, GC3Denum, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_3(getUniformfv, Platform3DObject, GC3Dint, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_3(getUniformiv, Platform3DObject, GC3Dint, GC3Dint*)
+DELEGATE_TO_INTERNAL_2R(getUniformLocation, Platform3DObject, const String&, GC3Dint)
+DELEGATE_TO_INTERNAL_3(getVertexAttribfv, GC3Duint, GC3Denum, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_3(getVertexAttribiv, GC3Duint, GC3Denum, GC3Dint*)
+DELEGATE_TO_INTERNAL_2R(getVertexAttribOffset, GC3Duint, GC3Denum, GC3Dsizeiptr)
+
+DELEGATE_TO_INTERNAL_2(hint, GC3Denum, GC3Denum)
+DELEGATE_TO_INTERNAL_1R(isBuffer, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1R(isEnabled, GC3Denum, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1R(isFramebuffer, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1R(isProgram, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1R(isRenderbuffer, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1R(isShader, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1R(isTexture, Platform3DObject, GC3Dboolean)
+DELEGATE_TO_INTERNAL_1(lineWidth, GC3Dfloat)
+DELEGATE_TO_INTERNAL_1(linkProgram, Platform3DObject)
+DELEGATE_TO_INTERNAL_2(pixelStorei, GC3Denum, GC3Dint)
+DELEGATE_TO_INTERNAL_2(polygonOffset, GC3Dfloat, GC3Dfloat)
+
+DELEGATE_TO_INTERNAL_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, void*)
+
+DELEGATE_TO_INTERNAL(releaseShaderCompiler)
+DELEGATE_TO_INTERNAL_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3Dsizei)
+DELEGATE_TO_INTERNAL_2(sampleCoverage, GC3Dclampf, GC3Dboolean)
+DELEGATE_TO_INTERNAL_4(scissor, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+DELEGATE_TO_INTERNAL_2(shaderSource, Platform3DObject, const String&)
+DELEGATE_TO_INTERNAL_3(stencilFunc, GC3Denum, GC3Dint, GC3Duint)
+DELEGATE_TO_INTERNAL_4(stencilFuncSeparate, GC3Denum, GC3Denum, GC3Dint, GC3Duint)
+DELEGATE_TO_INTERNAL_1(stencilMask, GC3Duint)
+DELEGATE_TO_INTERNAL_2(stencilMaskSeparate, GC3Denum, GC3Duint)
+DELEGATE_TO_INTERNAL_3(stencilOp, GC3Denum, GC3Denum, GC3Denum)
+DELEGATE_TO_INTERNAL_4(stencilOpSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Denum)
+
+DELEGATE_TO_INTERNAL_9R(texImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dsizei, GC3Dsizei, GC3Dint, GC3Denum, GC3Denum, const void*, bool)
+DELEGATE_TO_INTERNAL_3(texParameterf, GC3Denum, GC3Denum, GC3Dfloat)
+DELEGATE_TO_INTERNAL_3(texParameteri, GC3Denum, GC3Denum, GC3Dint)
+DELEGATE_TO_INTERNAL_9(texSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, const void*)
+
+DELEGATE_TO_INTERNAL_2(uniform1f, GC3Dint, GC3Dfloat)
+DELEGATE_TO_INTERNAL_3(uniform1fv, GC3Dint, GC3Dfloat*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_2(uniform1i, GC3Dint, GC3Dint)
+DELEGATE_TO_INTERNAL_3(uniform1iv, GC3Dint, GC3Dint*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_INTERNAL_3(uniform2fv, GC3Dint, GC3Dfloat*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_3(uniform2i, GC3Dint, GC3Dint, GC3Dint)
+DELEGATE_TO_INTERNAL_3(uniform2iv, GC3Dint, GC3Dint*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_INTERNAL_3(uniform3fv, GC3Dint, GC3Dfloat*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
+DELEGATE_TO_INTERNAL_3(uniform3iv, GC3Dint, GC3Dint*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_INTERNAL_3(uniform4fv, GC3Dint, GC3Dfloat*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
+DELEGATE_TO_INTERNAL_3(uniform4iv, GC3Dint, GC3Dint*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_4(uniformMatrix2fv, GC3Dint, GC3Dboolean, GC3Dfloat*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_4(uniformMatrix3fv, GC3Dint, GC3Dboolean, GC3Dfloat*, GC3Dsizei)
+DELEGATE_TO_INTERNAL_4(uniformMatrix4fv, GC3Dint, GC3Dboolean, GC3Dfloat*, GC3Dsizei)
+
+DELEGATE_TO_INTERNAL_1(useProgram, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(validateProgram, Platform3DObject)
+
+DELEGATE_TO_INTERNAL_2(vertexAttrib1f, GC3Duint, GC3Dfloat)
+DELEGATE_TO_INTERNAL_2(vertexAttrib1fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_3(vertexAttrib2f, GC3Duint, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_INTERNAL_2(vertexAttrib2fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_4(vertexAttrib3f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_INTERNAL_2(vertexAttrib3fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_5(vertexAttrib4f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat)
+DELEGATE_TO_INTERNAL_2(vertexAttrib4fv, GC3Duint, GC3Dfloat*)
+DELEGATE_TO_INTERNAL_6(vertexAttribPointer, GC3Duint, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr)
+
+DELEGATE_TO_INTERNAL_4(viewport, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
+
+DELEGATE_TO_INTERNAL_1(paintRenderingResultsToCanvas, CanvasRenderingContext*)
+
+bool GraphicsContext3D::paintsIntoCanvasBuffer() const
+{
+ return m_internal->paintsIntoCanvasBuffer();
+}
+
+DELEGATE_TO_INTERNAL_R(createBuffer, Platform3DObject)
+DELEGATE_TO_INTERNAL_R(createFramebuffer, Platform3DObject)
+DELEGATE_TO_INTERNAL_R(createProgram, Platform3DObject)
+DELEGATE_TO_INTERNAL_R(createRenderbuffer, Platform3DObject)
+DELEGATE_TO_INTERNAL_1R(createShader, GC3Denum, Platform3DObject)
+DELEGATE_TO_INTERNAL_R(createTexture, Platform3DObject)
+
+DELEGATE_TO_INTERNAL_1(deleteBuffer, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(deleteFramebuffer, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(deleteProgram, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(deleteRenderbuffer, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(deleteShader, Platform3DObject)
+DELEGATE_TO_INTERNAL_1(deleteTexture, Platform3DObject)
+
+DELEGATE_TO_INTERNAL_1(synthesizeGLError, GC3Denum)
+DELEGATE_TO_INTERNAL_R(getExtensions, Extensions3D*)
+
+bool GraphicsContext3D::isGLES2Compliant() const
+{
+ return m_internal->isGLES2Compliant();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/Source/WebKit/chromium/src/GraphicsContext3DInternal.h b/Source/WebKit/chromium/src/GraphicsContext3DInternal.h
new file mode 100644
index 0000000..30a8e57
--- /dev/null
+++ b/Source/WebKit/chromium/src/GraphicsContext3DInternal.h
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GraphicsContext3DInternal_h
+#define GraphicsContext3DInternal_h
+
+#include "GraphicsContext3D.h"
+#include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
+#if PLATFORM(SKIA)
+#include "SkBitmap.h"
+#endif
+
+namespace WebKit {
+class WebGraphicsContext3D;
+class WebViewImpl;
+} // namespace WebKit
+
+namespace WebCore {
+
+class Extensions3DChromium;
+#if USE(ACCELERATED_COMPOSITING)
+class WebGLLayerChromium;
+#endif
+
+class GraphicsContext3DInternal {
+public:
+ GraphicsContext3DInternal();
+ ~GraphicsContext3DInternal();
+
+ bool initialize(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow);
+
+ // Helper function to provide access to the lower-level WebGraphicsContext3D,
+ // which is needed for subordinate contexts like WebGL's to share resources
+ // with the compositor's context.
+ static WebKit::WebGraphicsContext3D* extractWebGraphicsContext3D(GraphicsContext3D* context);
+
+ PlatformGraphicsContext3D platformGraphicsContext3D() const;
+ Platform3DObject platformTexture() const;
+
+ bool makeContextCurrent();
+
+ unsigned int sizeInBytes(GC3Denum type);
+
+ void reshape(int width, int height);
+ IntSize getInternalFramebufferSize();
+
+ void paintRenderingResultsToCanvas(CanvasRenderingContext*);
+ bool paintsIntoCanvasBuffer() const;
+
+ void prepareTexture();
+
+#if USE(ACCELERATED_COMPOSITING)
+ WebGLLayerChromium* platformLayer() const;
+#endif
+ bool isGLES2Compliant() const;
+
+ void releaseShaderCompiler();
+ bool isContextLost();
+
+ //----------------------------------------------------------------------
+ // Entry points for WebGL.
+ //
+ void activeTexture(GC3Denum texture);
+ void attachShader(Platform3DObject program, Platform3DObject shader);
+ void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name);
+ void bindBuffer(GC3Denum target, Platform3DObject);
+ void bindFramebuffer(GC3Denum target, Platform3DObject);
+ void bindRenderbuffer(GC3Denum target, Platform3DObject);
+ void bindTexture(GC3Denum target, Platform3DObject);
+ void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
+ void blendEquation(GC3Denum mode);
+ void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha);
+ void blendFunc(GC3Denum sfactor, GC3Denum dfactor);
+ void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha);
+
+ void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage);
+ void bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage);
+ void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data);
+
+ GC3Denum checkFramebufferStatus(GC3Denum target);
+ void clear(GC3Dbitfield mask);
+ void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
+ void clearDepth(GC3Dclampf depth);
+ void clearStencil(GC3Dint s);
+ void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha);
+ void compileShader(Platform3DObject);
+
+ void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border);
+ void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
+ void cullFace(GC3Denum mode);
+ void depthFunc(GC3Denum func);
+ void depthMask(GC3Dboolean flag);
+ void depthRange(GC3Dclampf zNear, GC3Dclampf zFar);
+ void detachShader(Platform3DObject, Platform3DObject);
+ void disable(GC3Denum cap);
+ void disableVertexAttribArray(GC3Duint index);
+ void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count);
+ void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset);
+
+ void enable(GC3Denum cap);
+ void enableVertexAttribArray(GC3Duint index);
+ void finish();
+ void flush();
+ void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject);
+ void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level);
+ void frontFace(GC3Denum mode);
+ void generateMipmap(GC3Denum target);
+
+ bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&);
+ bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&);
+ void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders);
+ GC3Dint getAttribLocation(Platform3DObject, const String& name);
+ void getBooleanv(GC3Denum pname, GC3Dboolean* value);
+ void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
+ GraphicsContext3D::Attributes getContextAttributes();
+ GC3Denum getError();
+ void getFloatv(GC3Denum pname, GC3Dfloat* value);
+ void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value);
+ void getIntegerv(GC3Denum pname, GC3Dint* value);
+ void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value);
+ String getProgramInfoLog(Platform3DObject);
+ void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
+ void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
+ String getShaderInfoLog(Platform3DObject);
+
+ String getShaderSource(Platform3DObject);
+ String getString(GC3Denum name);
+ void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value);
+ void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
+ void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value);
+ void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value);
+ GC3Dint getUniformLocation(Platform3DObject, const String& name);
+ void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value);
+ void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value);
+ GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname);
+
+ void hint(GC3Denum target, GC3Denum mode);
+ GC3Dboolean isBuffer(Platform3DObject);
+ GC3Dboolean isEnabled(GC3Denum cap);
+ GC3Dboolean isFramebuffer(Platform3DObject);
+ GC3Dboolean isProgram(Platform3DObject);
+ GC3Dboolean isRenderbuffer(Platform3DObject);
+ GC3Dboolean isShader(Platform3DObject);
+ GC3Dboolean isTexture(Platform3DObject);
+ void lineWidth(GC3Dfloat);
+ void linkProgram(Platform3DObject);
+ void pixelStorei(GC3Denum pname, GC3Dint param);
+ void polygonOffset(GC3Dfloat factor, GC3Dfloat units);
+
+ void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data);
+
+ void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height);
+ void sampleCoverage(GC3Dclampf value, GC3Dboolean invert);
+ void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
+ void shaderSource(Platform3DObject, const String& string);
+ void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask);
+ void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask);
+ void stencilMask(GC3Duint mask);
+ void stencilMaskSeparate(GC3Denum face, GC3Duint mask);
+ void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
+ void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
+
+ // texImage2D return false on any error rather than using an ExceptionCode.
+ bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels);
+ void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param);
+ void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param);
+ void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels);
+
+ void uniform1f(GC3Dint location, GC3Dfloat x);
+ void uniform1fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size);
+ void uniform1i(GC3Dint location, GC3Dint x);
+ void uniform1iv(GC3Dint location, GC3Dint* v, GC3Dsizei size);
+ void uniform2f(GC3Dint location, GC3Dfloat x, float y);
+ void uniform2fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size);
+ void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y);
+ void uniform2iv(GC3Dint location, GC3Dint* v, GC3Dsizei size);
+ void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
+ void uniform3fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size);
+ void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z);
+ void uniform3iv(GC3Dint location, GC3Dint* v, GC3Dsizei size);
+ void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
+ void uniform4fv(GC3Dint location, GC3Dfloat* v, GC3Dsizei size);
+ void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w);
+ void uniform4iv(GC3Dint location, GC3Dint* v, GC3Dsizei size);
+ void uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size);
+ void uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size);
+ void uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size);
+
+ void useProgram(Platform3DObject);
+ void validateProgram(Platform3DObject);
+
+ void vertexAttrib1f(GC3Duint index, GC3Dfloat x);
+ void vertexAttrib1fv(GC3Duint index, GC3Dfloat* values);
+ void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y);
+ void vertexAttrib2fv(GC3Duint index, GC3Dfloat* values);
+ void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
+ void vertexAttrib3fv(GC3Duint index, GC3Dfloat* values);
+ void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
+ void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values);
+ void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized,
+ GC3Dsizei stride, GC3Dintptr offset);
+
+ void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
+
+ Platform3DObject createBuffer();
+ Platform3DObject createFramebuffer();
+ Platform3DObject createProgram();
+ Platform3DObject createRenderbuffer();
+ Platform3DObject createShader(GC3Denum);
+ Platform3DObject createTexture();
+
+ void deleteBuffer(Platform3DObject);
+ void deleteFramebuffer(Platform3DObject);
+ void deleteProgram(Platform3DObject);
+ void deleteRenderbuffer(Platform3DObject);
+ void deleteShader(Platform3DObject);
+ void deleteTexture(Platform3DObject);
+
+ void synthesizeGLError(GC3Denum error);
+
+ // Extensions3D support.
+ Extensions3D* getExtensions();
+ bool supportsExtension(const String& name);
+ bool ensureExtensionEnabled(const String& name);
+
+ // EXT_texture_format_BGRA8888
+ bool supportsBGRA();
+
+ // GL_CHROMIUM_map_sub
+ bool supportsMapSubCHROMIUM();
+ void* mapBufferSubDataCHROMIUM(GC3Denum target, GC3Dsizeiptr offset, GC3Dsizei size, GC3Denum access);
+ void unmapBufferSubDataCHROMIUM(const void*);
+ void* mapTexSubImage2DCHROMIUM(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Denum access);
+ void unmapTexSubImage2DCHROMIUM(const void*);
+
+ // GL_CHROMIUM_copy_texture_to_parent_texture
+ bool supportsCopyTextureToParentTextureCHROMIUM();
+ void copyTextureToParentTextureCHROMIUM(Platform3DObject texture, Platform3DObject parentTexture);
+
+private:
+ OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
+ OwnPtr<Extensions3DChromium> m_extensions;
+ WebKit::WebViewImpl* m_webViewImpl;
+ bool m_initializedAvailableExtensions;
+ HashSet<String> m_enabledExtensions;
+ HashSet<String> m_requestableExtensions;
+#if USE(ACCELERATED_COMPOSITING)
+ RefPtr<WebGLLayerChromium> m_compositingLayer;
+#endif
+#if PLATFORM(SKIA)
+ // If the width and height of the Canvas's backing store don't
+ // match those that we were given in the most recent call to
+ // reshape(), then we need an intermediate bitmap to read back the
+ // frame buffer into. This seems to happen when CSS styles are
+ // used to resize the Canvas.
+ SkBitmap m_resizingBitmap;
+#endif
+
+#if PLATFORM(CG)
+ unsigned char* m_renderOutput;
+#endif
+
+ void initializeExtensions();
+};
+
+} // namespace WebCore
+
+#endif // GraphicsContext3D_h
diff --git a/Source/WebKit/chromium/src/IDBCallbacksProxy.cpp b/Source/WebKit/chromium/src/IDBCallbacksProxy.cpp
new file mode 100644
index 0000000..69051d0
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBCallbacksProxy.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBCallbacksProxy.h"
+
+#include "IDBDatabaseError.h"
+#include "IDBDatabaseProxy.h"
+#include "WebIDBCallbacks.h"
+#include "WebIDBCursorImpl.h"
+#include "WebIDBDatabaseImpl.h"
+#include "WebIDBDatabaseError.h"
+#include "WebIDBIndexImpl.h"
+#include "WebIDBKey.h"
+#include "WebIDBObjectStoreImpl.h"
+#include "WebIDBTransactionImpl.h"
+#include "WebSerializedScriptValue.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+PassRefPtr<IDBCallbacksProxy> IDBCallbacksProxy::create(PassOwnPtr<WebKit::WebIDBCallbacks> callbacks)
+{
+ return adoptRef(new IDBCallbacksProxy(callbacks));
+}
+
+IDBCallbacksProxy::IDBCallbacksProxy(PassOwnPtr<WebKit::WebIDBCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+}
+
+IDBCallbacksProxy::~IDBCallbacksProxy()
+{
+}
+
+void IDBCallbacksProxy::onError(PassRefPtr<IDBDatabaseError> idbDatabaseError)
+{
+ m_callbacks->onError(WebKit::WebIDBDatabaseError(idbDatabaseError));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess()
+{
+ m_callbacks->onSuccess();
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBCursorBackendInterface> idbCursorBackend)
+{
+ m_callbacks->onSuccess(new WebKit::WebIDBCursorImpl(idbCursorBackend));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBDatabaseBackendInterface> backend)
+{
+ m_callbacks->onSuccess(new WebKit::WebIDBDatabaseImpl(backend));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBIndexBackendInterface> backend)
+{
+ m_callbacks->onSuccess(new WebKit::WebIDBIndexImpl(backend));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBKey> idbKey)
+{
+ m_callbacks->onSuccess(WebKit::WebIDBKey(idbKey));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBObjectStoreBackendInterface> backend)
+{
+ m_callbacks->onSuccess(new WebKit::WebIDBObjectStoreImpl(backend));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBTransactionBackendInterface> backend)
+{
+ m_callbacks->onSuccess(new WebKit::WebIDBTransactionImpl(backend));
+ m_callbacks.clear();
+}
+
+void IDBCallbacksProxy::onSuccess(PassRefPtr<SerializedScriptValue> serializedScriptValue)
+{
+ m_callbacks->onSuccess(WebKit::WebSerializedScriptValue(serializedScriptValue));
+ m_callbacks.clear();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBCallbacksProxy.h b/Source/WebKit/chromium/src/IDBCallbacksProxy.h
new file mode 100644
index 0000000..8c26161
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBCallbacksProxy.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBCallbacksProxy_h
+#define IDBCallbacksProxy_h
+
+#include "IDBCallbacks.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit {
+class WebIDBCallbacks;
+}
+
+namespace WebCore {
+
+class IDBCallbacksProxy : public IDBCallbacks {
+public:
+ static PassRefPtr<IDBCallbacksProxy> create(PassOwnPtr<WebKit::WebIDBCallbacks>);
+ virtual ~IDBCallbacksProxy();
+
+ virtual void onError(PassRefPtr<IDBDatabaseError>);
+ virtual void onSuccess(); // For "null".
+ virtual void onSuccess(PassRefPtr<IDBCursorBackendInterface>);
+ virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>);
+ virtual void onSuccess(PassRefPtr<IDBIndexBackendInterface>);
+ virtual void onSuccess(PassRefPtr<IDBKey>);
+ virtual void onSuccess(PassRefPtr<IDBObjectStoreBackendInterface>);
+ virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>);
+ virtual void onSuccess(PassRefPtr<SerializedScriptValue>);
+
+private:
+ IDBCallbacksProxy(PassOwnPtr<WebKit::WebIDBCallbacks>);
+
+ OwnPtr<WebKit::WebIDBCallbacks> m_callbacks;
+};
+
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBCallbacksProxy_h
diff --git a/Source/WebKit/chromium/src/IDBCursorBackendProxy.cpp b/Source/WebKit/chromium/src/IDBCursorBackendProxy.cpp
new file mode 100644
index 0000000..ec7bf63
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBCursorBackendProxy.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBCursorBackendProxy.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBAny.h"
+#include "IDBCallbacks.h"
+#include "IDBKey.h"
+#include "SerializedScriptValue.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBKey.h"
+#include "WebSerializedScriptValue.h"
+
+namespace WebCore {
+
+PassRefPtr<IDBCursorBackendInterface> IDBCursorBackendProxy::create(PassOwnPtr<WebKit::WebIDBCursor> idbCursor)
+{
+ return adoptRef(new IDBCursorBackendProxy(idbCursor));
+}
+
+IDBCursorBackendProxy::IDBCursorBackendProxy(PassOwnPtr<WebKit::WebIDBCursor> idbCursor)
+ : m_idbCursor(idbCursor)
+{
+}
+
+IDBCursorBackendProxy::~IDBCursorBackendProxy()
+{
+}
+
+unsigned short IDBCursorBackendProxy::direction() const
+{
+ return m_idbCursor->direction();
+}
+
+PassRefPtr<IDBKey> IDBCursorBackendProxy::key() const
+{
+ return m_idbCursor->key();
+}
+
+PassRefPtr<IDBAny> IDBCursorBackendProxy::value() const
+{
+ WebKit::WebSerializedScriptValue webScriptValue;
+ WebKit::WebIDBKey webKey;
+ m_idbCursor->value(webScriptValue, webKey);
+ if (!webScriptValue.isNull()) {
+ ASSERT(webKey.type() == WebKit::WebIDBKey::InvalidType);
+ return IDBAny::create<SerializedScriptValue>(webScriptValue);
+ }
+ ASSERT(webKey.type() != WebKit::WebIDBKey::InvalidType);
+ return IDBAny::create<IDBKey>(webKey);
+}
+
+void IDBCursorBackendProxy::update(PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBCallbacks> callbacks, ExceptionCode& ec)
+{
+ m_idbCursor->update(value, new WebIDBCallbacksImpl(callbacks), ec);
+}
+
+void IDBCursorBackendProxy::continueFunction(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks, ExceptionCode& ec)
+{
+ m_idbCursor->continueFunction(key, new WebIDBCallbacksImpl(callbacks), ec);
+}
+
+void IDBCursorBackendProxy::deleteFunction(PassRefPtr<IDBCallbacks> callbacks, ExceptionCode& ec)
+{
+ m_idbCursor->deleteFunction(new WebIDBCallbacksImpl(callbacks), ec);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBCursorBackendProxy.h b/Source/WebKit/chromium/src/IDBCursorBackendProxy.h
new file mode 100644
index 0000000..650dded
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBCursorBackendProxy.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBCursorBackendProxy_h
+#define IDBCursorBackendProxy_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBCursorBackendInterface.h"
+#include "WebIDBCursor.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBCursorBackendProxy : public IDBCursorBackendInterface {
+public:
+ static PassRefPtr<IDBCursorBackendInterface> create(PassOwnPtr<WebKit::WebIDBCursor>);
+ virtual ~IDBCursorBackendProxy();
+
+ virtual unsigned short direction() const;
+ virtual PassRefPtr<IDBKey> key() const;
+ virtual PassRefPtr<IDBAny> value() const;
+ virtual void update(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
+ virtual void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
+ virtual void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&);
+
+private:
+ IDBCursorBackendProxy(PassOwnPtr<WebKit::WebIDBCursor>);
+
+ OwnPtr<WebKit::WebIDBCursor> m_idbCursor;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBCursorBackendProxy_h
diff --git a/Source/WebKit/chromium/src/IDBDatabaseProxy.cpp b/Source/WebKit/chromium/src/IDBDatabaseProxy.cpp
new file mode 100644
index 0000000..f070d64
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBDatabaseProxy.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBDatabaseProxy.h"
+
+#include "DOMStringList.h"
+#include "IDBCallbacks.h"
+#include "IDBObjectStoreProxy.h"
+#include "IDBTransactionBackendProxy.h"
+#include "WebDOMStringList.h"
+#include "WebFrameImpl.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBDatabase.h"
+#include "WebIDBDatabaseError.h"
+#include "WebIDBObjectStore.h"
+#include "WebIDBTransaction.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+PassRefPtr<IDBDatabaseBackendInterface> IDBDatabaseProxy::create(PassOwnPtr<WebKit::WebIDBDatabase> database)
+{
+ return adoptRef(new IDBDatabaseProxy(database));
+}
+
+IDBDatabaseProxy::IDBDatabaseProxy(PassOwnPtr<WebKit::WebIDBDatabase> database)
+ : m_webIDBDatabase(database)
+{
+}
+
+IDBDatabaseProxy::~IDBDatabaseProxy()
+{
+}
+
+String IDBDatabaseProxy::name() const
+{
+ return m_webIDBDatabase->name();
+}
+
+String IDBDatabaseProxy::version() const
+{
+ return m_webIDBDatabase->version();
+}
+
+PassRefPtr<DOMStringList> IDBDatabaseProxy::objectStoreNames() const
+{
+ return m_webIDBDatabase->objectStoreNames();
+}
+
+PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ WebKit::WebIDBObjectStore* objectStore = m_webIDBDatabase->createObjectStore(name, keyPath, autoIncrement, *transactionProxy->getWebIDBTransaction(), ec);
+ if (!objectStore)
+ return 0;
+ return IDBObjectStoreProxy::create(objectStore);
+}
+
+void IDBDatabaseProxy::deleteObjectStore(const String& name, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBDatabase->deleteObjectStore(name, *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBDatabaseProxy::setVersion(const String& version, PassRefPtr<IDBCallbacks> callbacks, ExceptionCode& ec)
+{
+ m_webIDBDatabase->setVersion(version, new WebIDBCallbacksImpl(callbacks), ec);
+}
+
+PassRefPtr<IDBTransactionBackendInterface> IDBDatabaseProxy::transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout, ExceptionCode& ec)
+{
+ WebKit::WebDOMStringList names(storeNames);
+ WebKit::WebIDBTransaction* transaction = m_webIDBDatabase->transaction(names, mode, timeout, ec);
+ if (!transaction) {
+ ASSERT(ec);
+ return 0;
+ }
+ return IDBTransactionBackendProxy::create(transaction);
+}
+
+void IDBDatabaseProxy::close()
+{
+ m_webIDBDatabase->close();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBDatabaseProxy.h b/Source/WebKit/chromium/src/IDBDatabaseProxy.h
new file mode 100644
index 0000000..c51a604
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBDatabaseProxy.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBDatabaseProxy_h
+#define IDBDatabaseProxy_h
+
+#include "IDBDatabaseBackendInterface.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit { class WebIDBDatabase; }
+
+namespace WebCore {
+
+class IDBDatabaseProxy : public IDBDatabaseBackendInterface {
+public:
+ static PassRefPtr<IDBDatabaseBackendInterface> create(PassOwnPtr<WebKit::WebIDBDatabase>);
+ virtual ~IDBDatabaseProxy();
+
+ virtual String name() const;
+ virtual String version() const;
+ virtual PassRefPtr<DOMStringList> objectStoreNames() const;
+
+ virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, ExceptionCode&);
+ virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout, ExceptionCode&);
+ virtual void close();
+
+private:
+ IDBDatabaseProxy(PassOwnPtr<WebKit::WebIDBDatabase>);
+
+ OwnPtr<WebKit::WebIDBDatabase> m_webIDBDatabase;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBDatabaseProxy_h
diff --git a/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp
new file mode 100755
index 0000000..67504a3
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBFactoryBackendProxy.h"
+
+#include "DOMStringList.h"
+#include "IDBDatabaseError.h"
+#include "IDBDatabaseProxy.h"
+#include "WebFrameImpl.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBDatabase.h"
+#include "WebIDBDatabaseError.h"
+#include "WebIDBFactory.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebVector.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendProxy::create()
+{
+ return adoptRef(new IDBFactoryBackendProxy());
+}
+
+IDBFactoryBackendProxy::IDBFactoryBackendProxy()
+ : m_webIDBFactory(WebKit::webKitClient()->idbFactory())
+{
+}
+
+IDBFactoryBackendProxy::~IDBFactoryBackendProxy()
+{
+}
+
+void IDBFactoryBackendProxy::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> origin, Frame* frame, const String& dataDir, int64_t maximumSize)
+{
+ WebKit::WebFrame* webFrame = WebKit::WebFrameImpl::fromFrame(frame);
+ m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir, maximumSize);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
diff --git a/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h
new file mode 100755
index 0000000..5950a68
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBFactoryBackendProxy_h
+#define IDBFactoryBackendProxy_h
+
+#include "IDBFactoryBackendInterface.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit { class WebIDBFactory; }
+
+namespace WebCore {
+
+class DOMStringList;
+
+class IDBFactoryBackendProxy : public IDBFactoryBackendInterface {
+public:
+ static PassRefPtr<IDBFactoryBackendInterface> create();
+ virtual ~IDBFactoryBackendProxy();
+
+ PassRefPtr<DOMStringList> databases(void) const;
+ virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize);
+
+private:
+ IDBFactoryBackendProxy();
+
+ // We don't own this pointer (unlike all the other proxy classes which do).
+ WebKit::WebIDBFactory* m_webIDBFactory;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBFactoryBackendProxy_h
+
diff --git a/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp b/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp
new file mode 100644
index 0000000..410750e
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBIndexBackendProxy.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBCallbacks.h"
+#include "IDBKeyRange.h"
+#include "IDBTransactionBackendProxy.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBDatabaseError.h"
+#include "WebIDBIndex.h"
+#include "WebIDBKey.h"
+#include "WebIDBKeyRange.h"
+
+namespace WebCore {
+
+PassRefPtr<IDBIndexBackendInterface> IDBIndexBackendProxy::create(PassOwnPtr<WebKit::WebIDBIndex> index)
+{
+ return adoptRef(new IDBIndexBackendProxy(index));
+}
+
+IDBIndexBackendProxy::IDBIndexBackendProxy(PassOwnPtr<WebKit::WebIDBIndex> index)
+ : m_webIDBIndex(index)
+{
+}
+
+IDBIndexBackendProxy::~IDBIndexBackendProxy()
+{
+}
+
+String IDBIndexBackendProxy::name()
+{
+ return m_webIDBIndex->name();
+}
+
+String IDBIndexBackendProxy::storeName()
+{
+ return m_webIDBIndex->storeName();
+}
+
+String IDBIndexBackendProxy::keyPath()
+{
+ return m_webIDBIndex->keyPath();
+}
+
+bool IDBIndexBackendProxy::unique()
+{
+ return m_webIDBIndex->unique();
+}
+
+void IDBIndexBackendProxy::openCursor(PassRefPtr<IDBKeyRange> keyRange, unsigned short direction, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBIndex->openObjectCursor(keyRange, direction, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBIndexBackendProxy::openKeyCursor(PassRefPtr<IDBKeyRange> keyRange, unsigned short direction, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBIndex->openKeyCursor(keyRange, direction, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBIndexBackendProxy::get(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBIndex->getObject(key, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBIndexBackendProxy::getKey(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBIndex->getKey(key, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBIndexBackendProxy.h b/Source/WebKit/chromium/src/IDBIndexBackendProxy.h
new file mode 100644
index 0000000..e9de05a
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBIndexBackendProxy.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBIndexBackendProxy_h
+#define IDBIndexBackendProxy_h
+
+#include "IDBIndexBackendInterface.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit { class WebIDBIndex; }
+
+namespace WebCore {
+
+class IDBIndexBackendProxy : public IDBIndexBackendInterface {
+public:
+ static PassRefPtr<IDBIndexBackendInterface> create(PassOwnPtr<WebKit::WebIDBIndex>);
+ virtual ~IDBIndexBackendProxy();
+
+ virtual String name();
+ virtual String storeName();
+ virtual String keyPath();
+ virtual bool unique();
+
+ virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void openKeyCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void get(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void getKey(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+
+private:
+ IDBIndexBackendProxy(PassOwnPtr<WebKit::WebIDBIndex>);
+
+ OwnPtr<WebKit::WebIDBIndex> m_webIDBIndex;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBIndexBackendProxy_h
diff --git a/Source/WebKit/chromium/src/IDBObjectStoreProxy.cpp b/Source/WebKit/chromium/src/IDBObjectStoreProxy.cpp
new file mode 100755
index 0000000..e03cdc8
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBObjectStoreProxy.cpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBObjectStoreProxy.h"
+
+#include "DOMStringList.h"
+#include "IDBCallbacks.h"
+#include "IDBIndexBackendProxy.h"
+#include "IDBKeyRange.h"
+#include "IDBTransactionBackendProxy.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBKeyRange.h"
+#include "WebIDBIndex.h"
+#include "WebIDBKey.h"
+#include "WebIDBObjectStore.h"
+#include "WebIDBTransactionImpl.h"
+#include "WebSerializedScriptValue.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+PassRefPtr<IDBObjectStoreBackendInterface> IDBObjectStoreProxy::create(PassOwnPtr<WebKit::WebIDBObjectStore> objectStore)
+{
+ return adoptRef(new IDBObjectStoreProxy(objectStore));
+}
+
+IDBObjectStoreProxy::IDBObjectStoreProxy(PassOwnPtr<WebKit::WebIDBObjectStore> objectStore)
+ : m_webIDBObjectStore(objectStore)
+{
+}
+
+IDBObjectStoreProxy::~IDBObjectStoreProxy()
+{
+}
+
+String IDBObjectStoreProxy::name() const
+{
+ return m_webIDBObjectStore->name();
+}
+
+String IDBObjectStoreProxy::keyPath() const
+{
+ return m_webIDBObjectStore->keyPath();
+}
+
+PassRefPtr<DOMStringList> IDBObjectStoreProxy::indexNames() const
+{
+ return m_webIDBObjectStore->indexNames();
+}
+
+void IDBObjectStoreProxy::get(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBObjectStore->get(key, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBObjectStoreProxy::put(PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, bool addOnly, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBObjectStore->put(value, key, addOnly, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBObjectStoreProxy::deleteFunction(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBObjectStore->deleteFunction(key, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreProxy::createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ WebKit::WebIDBIndex* index = m_webIDBObjectStore->createIndex(name, keyPath, unique, *transactionProxy->getWebIDBTransaction(), ec);
+ if (!index)
+ return 0;
+ return IDBIndexBackendProxy::create(index);
+}
+
+PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreProxy::index(const String& name, ExceptionCode& ec)
+{
+ WebKit::WebIDBIndex* index = m_webIDBObjectStore->index(name, ec);
+ if (!index)
+ return 0;
+ return IDBIndexBackendProxy::create(index);
+}
+
+void IDBObjectStoreProxy::deleteIndex(const String& name, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBObjectStore->deleteIndex(name, *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+void IDBObjectStoreProxy::openCursor(PassRefPtr<IDBKeyRange> range, unsigned short direction, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
+{
+ // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
+ // all implementations of IDB interfaces are proxy objects.
+ IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
+ m_webIDBObjectStore->openCursor(range, direction, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBObjectStoreProxy.h b/Source/WebKit/chromium/src/IDBObjectStoreProxy.h
new file mode 100755
index 0000000..348c794
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBObjectStoreProxy.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBObjectStoreProxy_h
+#define IDBObjectStoreProxy_h
+
+#include "IDBObjectStoreBackendInterface.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebKit { class WebIDBObjectStore; }
+
+namespace WebCore {
+
+class IDBObjectStoreProxy : public IDBObjectStoreBackendInterface {
+public:
+ static PassRefPtr<IDBObjectStoreBackendInterface> create(PassOwnPtr<WebKit::WebIDBObjectStore>);
+ virtual ~IDBObjectStoreProxy();
+
+ virtual String name() const;
+ virtual String keyPath() const;
+ virtual PassRefPtr<DOMStringList> indexNames() const;
+
+ virtual void get(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void put(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, bool addOnly, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+ virtual void deleteFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+
+ PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface*, ExceptionCode&);
+ PassRefPtr<IDBIndexBackendInterface> index(const String& name, ExceptionCode&);
+ void deleteIndex(const String& name, IDBTransactionBackendInterface*, ExceptionCode&);
+
+ virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
+
+private:
+ IDBObjectStoreProxy(PassOwnPtr<WebKit::WebIDBObjectStore>);
+
+ OwnPtr<WebKit::WebIDBObjectStore> m_webIDBObjectStore;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBObjectStoreProxy_h
+
diff --git a/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp
new file mode 100644
index 0000000..95c90d5
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBTransactionBackendProxy.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBObjectStoreProxy.h"
+#include "IDBTransactionCallbacks.h"
+#include "WebIDBDatabaseError.h"
+#include "WebIDBObjectStore.h"
+#include "WebIDBTransaction.h"
+#include "WebIDBTransactionCallbacksImpl.h"
+
+namespace WebCore {
+
+PassRefPtr<IDBTransactionBackendInterface> IDBTransactionBackendProxy::create(PassOwnPtr<WebKit::WebIDBTransaction> transaction)
+{
+ return adoptRef(new IDBTransactionBackendProxy(transaction));
+}
+
+IDBTransactionBackendProxy::IDBTransactionBackendProxy(PassOwnPtr<WebKit::WebIDBTransaction> transaction)
+ : m_webIDBTransaction(transaction)
+{
+ ASSERT(m_webIDBTransaction);
+}
+
+IDBTransactionBackendProxy::~IDBTransactionBackendProxy()
+{
+}
+
+PassRefPtr<IDBObjectStoreBackendInterface> IDBTransactionBackendProxy::objectStore(const String& name, ExceptionCode& ec)
+{
+ WebKit::WebIDBObjectStore* objectStore = m_webIDBTransaction->objectStore(name, ec);
+ if (!objectStore)
+ return 0;
+ return IDBObjectStoreProxy::create(objectStore);
+}
+
+unsigned short IDBTransactionBackendProxy::mode() const
+{
+ return m_webIDBTransaction->mode();
+}
+
+void IDBTransactionBackendProxy::abort()
+{
+ m_webIDBTransaction->abort();
+}
+
+bool IDBTransactionBackendProxy::scheduleTask(PassOwnPtr<ScriptExecutionContext::Task>, PassOwnPtr<ScriptExecutionContext::Task>)
+{
+ // This should never be reached as it's the impl objects who get to
+ // execute tasks in the browser process.
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+void IDBTransactionBackendProxy::didCompleteTaskEvents()
+{
+ m_webIDBTransaction->didCompleteTaskEvents();
+}
+
+void IDBTransactionBackendProxy::setCallbacks(IDBTransactionCallbacks* callbacks)
+{
+ m_webIDBTransaction->setCallbacks(new WebIDBTransactionCallbacksImpl(callbacks));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h
new file mode 100644
index 0000000..96d7293
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBTransactionBackendProxy.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBTransactionBackendProxy_h
+#define IDBTransactionBackendProxy_h
+
+#include "IDBTransactionBackendInterface.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit { class WebIDBTransaction; }
+
+namespace WebCore {
+
+class IDBTransactionBackendProxy : public IDBTransactionBackendInterface {
+public:
+ static PassRefPtr<IDBTransactionBackendInterface> create(PassOwnPtr<WebKit::WebIDBTransaction>);
+ virtual ~IDBTransactionBackendProxy();
+
+ virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(const String& name, ExceptionCode&);
+ virtual unsigned short mode() const;
+ virtual void abort();
+ virtual bool scheduleTask(PassOwnPtr<ScriptExecutionContext::Task>, PassOwnPtr<ScriptExecutionContext::Task>);
+ virtual void didCompleteTaskEvents();
+ virtual void setCallbacks(IDBTransactionCallbacks*);
+
+ WebKit::WebIDBTransaction* getWebIDBTransaction() const { return m_webIDBTransaction.get(); }
+
+private:
+ IDBTransactionBackendProxy(PassOwnPtr<WebKit::WebIDBTransaction>);
+
+ OwnPtr<WebKit::WebIDBTransaction> m_webIDBTransaction;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBTransactionBackendProxy_h
diff --git a/Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.cpp b/Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.cpp
new file mode 100644
index 0000000..3a19fe2
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBTransactionCallbacksProxy.h"
+
+#include "WebIDBTransactionCallbacks.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+PassRefPtr<IDBTransactionCallbacksProxy> IDBTransactionCallbacksProxy::create(PassOwnPtr<WebKit::WebIDBTransactionCallbacks> callbacks)
+{
+ return adoptRef(new IDBTransactionCallbacksProxy(callbacks));
+}
+
+IDBTransactionCallbacksProxy::IDBTransactionCallbacksProxy(PassOwnPtr<WebKit::WebIDBTransactionCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+}
+
+IDBTransactionCallbacksProxy::~IDBTransactionCallbacksProxy()
+{
+}
+
+void IDBTransactionCallbacksProxy::onAbort()
+{
+ m_callbacks->onAbort();
+ m_callbacks.clear();
+}
+
+void IDBTransactionCallbacksProxy::onComplete()
+{
+ m_callbacks->onComplete();
+ m_callbacks.clear();
+}
+
+void IDBTransactionCallbacksProxy::onTimeout()
+{
+ m_callbacks->onTimeout();
+ m_callbacks.clear();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.h b/Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.h
new file mode 100644
index 0000000..891d5c9
--- /dev/null
+++ b/Source/WebKit/chromium/src/IDBTransactionCallbacksProxy.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBTransactionCallbacksProxy_h
+#define IDBTransactionCallbacksProxy_h
+
+#include "IDBTransactionCallbacks.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit { class WebIDBTransactionCallbacks; }
+
+namespace WebCore {
+
+class IDBTransactionCallbacksProxy : public IDBTransactionCallbacks {
+public:
+ static PassRefPtr<IDBTransactionCallbacksProxy> create(PassOwnPtr<WebKit::WebIDBTransactionCallbacks>);
+ virtual ~IDBTransactionCallbacksProxy();
+
+ virtual void onAbort();
+ virtual void onComplete();
+ virtual void onTimeout();
+
+private:
+ IDBTransactionCallbacksProxy(PassOwnPtr<WebKit::WebIDBTransactionCallbacks>);
+
+ OwnPtr<WebKit::WebIDBTransactionCallbacks> m_callbacks;
+};
+
+
+} // namespace WebCore
+
+#endif
+
+#endif // IDBTransactionCallbacksProxy_h
diff --git a/Source/WebKit/chromium/src/InspectorClientImpl.cpp b/Source/WebKit/chromium/src/InspectorClientImpl.cpp
new file mode 100644
index 0000000..77150bb
--- /dev/null
+++ b/Source/WebKit/chromium/src/InspectorClientImpl.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorClientImpl.h"
+
+#include "DOMWindow.h"
+#include "FloatRect.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "WebDevToolsAgentImpl.h"
+#include "WebRect.h"
+#include "WebURL.h"
+#include "WebURLRequest.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
+ : m_inspectedWebView(webView)
+{
+ ASSERT(m_inspectedWebView);
+}
+
+InspectorClientImpl::~InspectorClientImpl()
+{
+}
+
+void InspectorClientImpl::inspectorDestroyed()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->inspectorDestroyed();
+}
+
+void InspectorClientImpl::openInspectorFrontend(InspectorController* controller)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->openInspectorFrontend(controller);
+}
+
+void InspectorClientImpl::highlight(Node* node)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->highlight(node);
+}
+
+void InspectorClientImpl::hideHighlight()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->hideHighlight();
+}
+
+void InspectorClientImpl::populateSetting(const String& key, String* value)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->populateSetting(key, value);
+}
+
+void InspectorClientImpl::storeSetting(const String& key, const String& value)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->storeSetting(key, value);
+}
+
+bool InspectorClientImpl::sendMessageToFrontend(const WTF::String& message)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ return agent->sendMessageToFrontend(message);
+ return false;
+}
+
+void InspectorClientImpl::updateInspectorStateCookie(const WTF::String& inspectorState)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->updateInspectorStateCookie(inspectorState);
+}
+
+WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
+{
+ return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/InspectorClientImpl.h b/Source/WebKit/chromium/src/InspectorClientImpl.h
new file mode 100644
index 0000000..78d34e3
--- /dev/null
+++ b/Source/WebKit/chromium/src/InspectorClientImpl.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorClientImpl_h
+#define InspectorClientImpl_h
+
+#include "InspectorClient.h"
+#include "InspectorController.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebKit {
+
+class WebDevToolsAgentClient;
+class WebDevToolsAgentImpl;
+class WebViewImpl;
+
+class InspectorClientImpl : public WebCore::InspectorClient {
+public:
+ InspectorClientImpl(WebViewImpl*);
+ ~InspectorClientImpl();
+
+ // InspectorClient methods:
+ virtual void inspectorDestroyed();
+ virtual void openInspectorFrontend(WebCore::InspectorController*);
+
+ virtual void highlight(WebCore::Node*);
+ virtual void hideHighlight();
+
+ virtual void populateSetting(const WTF::String& key, WTF::String* value);
+ virtual void storeSetting(const WTF::String& key, const WTF::String& value);
+
+ virtual bool sendMessageToFrontend(const WTF::String&);
+
+ virtual void updateInspectorStateCookie(const WTF::String&);
+private:
+ WebDevToolsAgentImpl* devToolsAgent();
+
+ // The WebViewImpl of the page being inspected; gets passed to the constructor
+ WebViewImpl* m_inspectedWebView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp
new file mode 100644
index 0000000..51864f1
--- /dev/null
+++ b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorFrontendClientImpl.h"
+
+#include "Document.h"
+#include "Frame.h"
+#include "InspectorFrontendHost.h"
+#include "Page.h"
+#include "PlatformString.h"
+#include "V8InspectorFrontendHost.h"
+#include "V8Proxy.h"
+#include "WebDevToolsFrontendClient.h"
+#include "WebDevToolsFrontendImpl.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+InspectorFrontendClientImpl::InspectorFrontendClientImpl(Page* frontendPage, WebDevToolsFrontendClient* client, WebDevToolsFrontendImpl* frontend)
+ : m_frontendPage(frontendPage)
+ , m_client(client)
+ , m_frontend(frontend)
+{
+}
+
+InspectorFrontendClientImpl::~InspectorFrontendClientImpl()
+{
+ if (m_frontendHost)
+ m_frontendHost->disconnectClient();
+ m_client = 0;
+}
+
+void InspectorFrontendClientImpl::windowObjectCleared()
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> frameContext = V8Proxy::context(m_frontendPage->mainFrame());
+ v8::Context::Scope contextScope(frameContext);
+
+ ASSERT(!m_frontendHost);
+ m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage);
+ v8::Handle<v8::Value> frontendHostObj = toV8(m_frontendHost.get());
+ v8::Handle<v8::Object> global = frameContext->Global();
+
+ global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj);
+}
+
+void InspectorFrontendClientImpl::frontendLoaded()
+{
+ m_frontend->frontendLoaded();
+}
+
+void InspectorFrontendClientImpl::moveWindowBy(float x, float y)
+{
+}
+
+String InspectorFrontendClientImpl::localizedStringsURL()
+{
+ return "";
+}
+
+String InspectorFrontendClientImpl::hiddenPanels()
+{
+ if (m_client->shouldHideScriptsPanel())
+ return "scripts";
+ return "";
+}
+
+void InspectorFrontendClientImpl::bringToFront()
+{
+ m_client->activateWindow();
+}
+
+void InspectorFrontendClientImpl::closeWindow()
+{
+ m_client->closeWindow();
+}
+
+void InspectorFrontendClientImpl::disconnectFromBackend()
+{
+ m_client->closeWindow();
+}
+
+void InspectorFrontendClientImpl::requestAttachWindow()
+{
+ m_client->requestDockWindow();
+}
+
+void InspectorFrontendClientImpl::requestDetachWindow()
+{
+ m_client->requestUndockWindow();
+}
+
+void InspectorFrontendClientImpl::changeAttachedWindowHeight(unsigned)
+{
+ // Do nothing;
+}
+
+void InspectorFrontendClientImpl::inspectedURLChanged(const String& url)
+{
+ m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url);
+}
+
+void InspectorFrontendClientImpl::sendMessageToBackend(const String& message)
+{
+ m_client->sendMessageToBackend(message);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h
new file mode 100644
index 0000000..2867917
--- /dev/null
+++ b/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorFrontendClientImpl_h
+#define InspectorFrontendClientImpl_h
+
+#include "InspectorFrontendClient.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+class InspectorFrontendHost;
+class Page;
+}
+
+namespace WebKit {
+
+class WebDevToolsFrontendClient;
+class WebDevToolsFrontendImpl;
+
+class InspectorFrontendClientImpl : public WebCore::InspectorFrontendClient {
+ WTF_MAKE_NONCOPYABLE(InspectorFrontendClientImpl);
+public:
+ InspectorFrontendClientImpl(WebCore::Page*, WebDevToolsFrontendClient*, WebDevToolsFrontendImpl*);
+ virtual ~InspectorFrontendClientImpl();
+
+ // InspectorFrontendClient methods:
+ virtual void windowObjectCleared();
+ virtual void frontendLoaded();
+
+ virtual void moveWindowBy(float x, float y);
+
+ virtual WTF::String localizedStringsURL();
+ virtual WTF::String hiddenPanels();
+
+ virtual void bringToFront();
+ virtual void closeWindow();
+ virtual void disconnectFromBackend();
+
+ virtual void requestAttachWindow();
+ virtual void requestDetachWindow();
+ virtual void changeAttachedWindowHeight(unsigned);
+
+ virtual void inspectedURLChanged(const WTF::String&);
+
+ virtual void sendMessageToBackend(const WTF::String&);
+private:
+ WebCore::Page* m_frontendPage;
+ WebDevToolsFrontendClient* m_client;
+ WebDevToolsFrontendImpl* m_frontend;
+ RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/LocalFileSystemChromium.cpp b/Source/WebKit/chromium/src/LocalFileSystemChromium.cpp
new file mode 100644
index 0000000..a9c61d0
--- /dev/null
+++ b/Source/WebKit/chromium/src/LocalFileSystemChromium.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LocalFileSystem.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystem.h"
+#include "ErrorCallback.h"
+#include "FileSystemCallback.h"
+#include "FileSystemCallbacks.h"
+#include "PlatformString.h"
+#include "WebFileSystem.h"
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebWorkerImpl.h"
+#include "WorkerContext.h"
+#include "WorkerThread.h"
+#include <wtf/Threading.h>
+
+using namespace WebKit;
+
+namespace WebCore {
+
+LocalFileSystem& LocalFileSystem::localFileSystem()
+{
+ AtomicallyInitializedStatic(LocalFileSystem*, localFileSystem = new LocalFileSystem(""));
+ return *localFileSystem;
+}
+
+void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ ASSERT(context && context->isDocument());
+ Document* document = static_cast<Document*>(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, false, new WebFileSystemCallbacksImpl(callbacks));
+}
+
+void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous)
+{
+ ASSERT(context);
+ if (context->isDocument()) {
+ Document* document = static_cast<Document*>(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, true, new WebFileSystemCallbacksImpl(callbacks));
+ } else {
+ WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+ WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
+ WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
+ webWorker->openFileSystem(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(callbacks, context, synchronous), synchronous);
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/LocalizedStrings.cpp b/Source/WebKit/chromium/src/LocalizedStrings.cpp
new file mode 100644
index 0000000..ab14009
--- /dev/null
+++ b/Source/WebKit/chromium/src/LocalizedStrings.cpp
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LocalizedStrings.h"
+
+#include "IntSize.h"
+#include "NotImplemented.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebLocalizedString.h"
+#include "WebString.h"
+
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
+using WebKit::WebLocalizedString;
+using WebKit::WebString;
+
+namespace WebCore {
+
+static String query(WebLocalizedString::Name name)
+{
+ return WebKit::webKitClient()->queryLocalizedString(name);
+}
+
+static String query(WebLocalizedString::Name name, const WebString& parameter)
+{
+ return WebKit::webKitClient()->queryLocalizedString(name, parameter);
+}
+
+static String query(WebLocalizedString::Name name, const WebString& parameter1, const WebString& parameter2)
+{
+ return WebKit::webKitClient()->queryLocalizedString(name, parameter1, parameter2);
+}
+
+String searchableIndexIntroduction()
+{
+ return query(WebLocalizedString::SearchableIndexIntroduction);
+}
+
+String submitButtonDefaultLabel()
+{
+ return query(WebLocalizedString::SubmitButtonDefaultLabel);
+}
+
+String inputElementAltText()
+{
+ return query(WebLocalizedString::InputElementAltText);
+}
+
+String resetButtonDefaultLabel()
+{
+ return query(WebLocalizedString::ResetButtonDefaultLabel);
+}
+
+String fileButtonChooseFileLabel()
+{
+ return query(WebLocalizedString::FileButtonChooseFileLabel);
+}
+
+String fileButtonNoFileSelectedLabel()
+{
+ return query(WebLocalizedString::FileButtonNoFileSelectedLabel);
+}
+
+String searchMenuNoRecentSearchesText()
+{
+ return query(WebLocalizedString::SearchMenuNoRecentSearchesText);
+}
+String searchMenuRecentSearchesText()
+{
+ return query(WebLocalizedString::SearchMenuRecentSearchesText);
+}
+
+String searchMenuClearRecentSearchesText()
+{
+ return query(WebLocalizedString::SearchMenuClearRecentSearchesText);
+}
+
+String AXWebAreaText()
+{
+ return query(WebLocalizedString::AXWebAreaText);
+}
+
+String AXLinkText()
+{
+ return query(WebLocalizedString::AXLinkText);
+}
+
+String AXListMarkerText()
+{
+ return query(WebLocalizedString::AXListMarkerText);
+}
+
+String AXImageMapText()
+{
+ return query(WebLocalizedString::AXImageMapText);
+}
+
+String AXHeadingText()
+{
+ return query(WebLocalizedString::AXHeadingText);
+}
+
+String AXDefinitionListTermText()
+{
+ notImplemented();
+ return String("term");
+}
+
+String AXDefinitionListDefinitionText()
+{
+ notImplemented();
+ return String("definition");
+}
+
+String AXButtonActionVerb()
+{
+ return query(WebLocalizedString::AXButtonActionVerb);
+}
+
+String AXRadioButtonActionVerb()
+{
+ return query(WebLocalizedString::AXRadioButtonActionVerb);
+}
+
+String AXTextFieldActionVerb()
+{
+ return query(WebLocalizedString::AXTextFieldActionVerb);
+}
+
+String AXCheckedCheckBoxActionVerb()
+{
+ return query(WebLocalizedString::AXCheckedCheckBoxActionVerb);
+}
+
+String AXUncheckedCheckBoxActionVerb()
+{
+ return query(WebLocalizedString::AXUncheckedCheckBoxActionVerb);
+}
+
+String AXLinkActionVerb()
+{
+ return query(WebLocalizedString::AXLinkActionVerb);
+}
+
+String AXMenuListPopupActionVerb()
+{
+ return String();
+}
+
+String AXMenuListActionVerb()
+{
+ return String();
+}
+
+String missingPluginText()
+{
+ notImplemented();
+ return String("Missing Plug-in");
+}
+
+String crashedPluginText()
+{
+ notImplemented();
+ return String("Plug-in Failure");
+}
+
+String multipleFileUploadText(unsigned numberOfFiles)
+{
+ return query(WebLocalizedString::MultipleFileUploadText, String::number(numberOfFiles));
+}
+
+// Used in FTPDirectoryDocument.cpp
+String unknownFileSizeText()
+{
+ return String();
+}
+
+// The following two functions are not declared in LocalizedStrings.h.
+// They are used by the menu for the HTML keygen tag.
+String keygenMenuHighGradeKeySize()
+{
+ return query(WebLocalizedString::KeygenMenuHighGradeKeySize);
+}
+
+String keygenMenuMediumGradeKeySize()
+{
+ return query(WebLocalizedString::KeygenMenuMediumGradeKeySize);
+}
+
+// Used in ImageDocument.cpp as the title for pages when that page is an image.
+String imageTitle(const String& filename, const IntSize& size)
+{
+ StringBuilder result;
+ result.append(filename);
+ result.append(" (");
+ result.append(String::number(size.width()));
+ result.append(static_cast<UChar>(0xD7)); // U+00D7 (multiplication sign)
+ result.append(String::number(size.height()));
+ result.append(')');
+ return result.toString();
+}
+
+// We don't use these strings, so they return an empty String. We can't just
+// make them asserts because webcore still calls them.
+String contextMenuItemTagOpenLinkInNewWindow() { return String(); }
+String contextMenuItemTagDownloadLinkToDisk() { return String(); }
+String contextMenuItemTagCopyLinkToClipboard() { return String(); }
+String contextMenuItemTagOpenImageInNewWindow() { return String(); }
+String contextMenuItemTagDownloadImageToDisk() { return String(); }
+String contextMenuItemTagCopyImageToClipboard() { return String(); }
+String contextMenuItemTagOpenFrameInNewWindow() { return String(); }
+String contextMenuItemTagCopy() { return String(); }
+String contextMenuItemTagGoBack() { return String(); }
+String contextMenuItemTagGoForward() { return String(); }
+String contextMenuItemTagStop() { return String(); }
+String contextMenuItemTagReload() { return String(); }
+String contextMenuItemTagCut() { return String(); }
+String contextMenuItemTagPaste() { return String(); }
+String contextMenuItemTagNoGuessesFound() { return String(); }
+String contextMenuItemTagIgnoreSpelling() { return String(); }
+String contextMenuItemTagLearnSpelling() { return String(); }
+String contextMenuItemTagSearchWeb() { return String(); }
+String contextMenuItemTagLookUpInDictionary() { return String(); }
+String contextMenuItemTagOpenLink() { return String(); }
+String contextMenuItemTagIgnoreGrammar() { return String(); }
+String contextMenuItemTagSpellingMenu() { return String(); }
+String contextMenuItemTagCheckSpelling() { return String(); }
+String contextMenuItemTagCheckSpellingWhileTyping() { return String(); }
+String contextMenuItemTagCheckGrammarWithSpelling() { return String(); }
+String contextMenuItemTagFontMenu() { return String(); }
+String contextMenuItemTagBold() { return String(); }
+String contextMenuItemTagItalic() { return String(); }
+String contextMenuItemTagUnderline() { return String(); }
+String contextMenuItemTagOutline() { return String(); }
+String contextMenuItemTagWritingDirectionMenu() { return String(); }
+String contextMenuItemTagTextDirectionMenu() { return String(); }
+String contextMenuItemTagDefaultDirection() { return String(); }
+String contextMenuItemTagLeftToRight() { return String(); }
+String contextMenuItemTagRightToLeft() { return String(); }
+String contextMenuItemTagInspectElement() { return String(); }
+String contextMenuItemTagShowSpellingPanel(bool show) { return String(); }
+String mediaElementLiveBroadcastStateText() { return String(); }
+String mediaElementLoadingStateText() { return String(); }
+String contextMenuItemTagOpenVideoInNewWindow() { return String(); }
+String contextMenuItemTagOpenAudioInNewWindow() { return String(); }
+String contextMenuItemTagCopyVideoLinkToClipboard() { return String(); }
+String contextMenuItemTagCopyAudioLinkToClipboard() { return String(); }
+String contextMenuItemTagToggleMediaControls() { return String(); }
+String contextMenuItemTagToggleMediaLoop() { return String(); }
+String contextMenuItemTagEnterVideoFullscreen() { return String(); }
+String contextMenuItemTagMediaPlay() { return String(); }
+String contextMenuItemTagMediaPause() { return String(); }
+String contextMenuItemTagMediaMute() { return String(); }
+
+String localizedMediaControlElementString(const String& /*name*/)
+{
+ // FIXME: to be fixed.
+ return String();
+}
+
+String localizedMediaControlElementHelpText(const String& /*name*/)
+{
+ // FIXME: to be fixed.
+ return String();
+}
+
+String localizedMediaTimeDescription(float /*time*/)
+{
+ // FIXME: to be fixed.
+ return String();
+}
+
+String validationMessageValueMissingText()
+{
+ return query(WebLocalizedString::ValidationValueMissing);
+}
+
+String validationMessageValueMissingForCheckboxText()
+{
+ return query(WebLocalizedString::ValidationValueMissingForCheckbox);
+}
+
+String validationMessageValueMissingForFileText()
+{
+ return query(WebLocalizedString::ValidationValueMissingForFile);
+}
+
+String validationMessageValueMissingForMultipleFileText()
+{
+ return query(WebLocalizedString::ValidationValueMissingForMultipleFile);
+}
+
+String validationMessageValueMissingForRadioText()
+{
+ return query(WebLocalizedString::ValidationValueMissingForRadio);
+}
+
+String validationMessageValueMissingForSelectText()
+{
+ return query(WebLocalizedString::ValidationValueMissingForSelect);
+}
+
+String validationMessageTypeMismatchText()
+{
+ return query(WebLocalizedString::ValidationTypeMismatch);
+}
+
+String validationMessageTypeMismatchForEmailText()
+{
+ return query(WebLocalizedString::ValidationTypeMismatchForEmail);
+}
+
+String validationMessageTypeMismatchForMultipleEmailText()
+{
+ return query(WebLocalizedString::ValidationTypeMismatchForMultipleEmail);
+}
+
+String validationMessageTypeMismatchForURLText()
+{
+ return query(WebLocalizedString::ValidationTypeMismatchForURL);
+}
+
+String validationMessagePatternMismatchText()
+{
+ return query(WebLocalizedString::ValidationPatternMismatch);
+}
+
+String validationMessageTooLongText(int valueLength, int maxLength)
+{
+ return query(WebLocalizedString::ValidationTooLong, String::number(valueLength), String::number(maxLength));
+}
+
+String validationMessageRangeUnderflowText(const String& minimum)
+{
+ return query(WebLocalizedString::ValidationRangeUnderflow, minimum);
+}
+
+String validationMessageRangeOverflowText(const String& maximum)
+{
+ return query(WebLocalizedString::ValidationRangeOverflow, maximum);
+}
+
+String validationMessageStepMismatchText(const String& base, const String& step)
+{
+ return query(WebLocalizedString::ValidationStepMismatch, base, step);
+}
+
+} // namespace WebCore
diff --git a/Source/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp b/Source/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp
new file mode 100644
index 0000000..09d33d4
--- /dev/null
+++ b/Source/WebKit/chromium/src/MediaPlayerPrivateChromium.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaPlayerPrivateChromium.h"
+
+#if ENABLE(VIDEO)
+
+#include "WebMediaPlayerClientImpl.h"
+
+namespace WebCore {
+
+void MediaPlayerPrivate::registerMediaEngine(MediaEngineRegistrar registrar)
+{
+ WebKit::WebMediaPlayerClientImpl::registerSelf(registrar);
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp b/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp
new file mode 100644
index 0000000..1931465
--- /dev/null
+++ b/Source/WebKit/chromium/src/NotificationPresenterImpl.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NotificationPresenterImpl.h"
+
+#if ENABLE(NOTIFICATIONS)
+
+#include "KURL.h"
+#include "Notification.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+
+#include "WebNotification.h"
+#include "WebNotificationPermissionCallback.h"
+#include "WebNotificationPresenter.h"
+#include "WebURL.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class VoidCallbackClient : public WebNotificationPermissionCallback {
+public:
+ VoidCallbackClient(PassRefPtr<VoidCallback> callback)
+ : m_callback(callback)
+ {
+ }
+
+ virtual void permissionRequestComplete()
+ {
+ if (m_callback)
+ m_callback->handleEvent();
+ delete this;
+ }
+
+private:
+ RefPtr<VoidCallback> m_callback;
+};
+
+void NotificationPresenterImpl::initialize(WebNotificationPresenter* presenter)
+{
+ m_presenter = presenter;
+}
+
+bool NotificationPresenterImpl::isInitialized()
+{
+ return !!m_presenter;
+}
+
+bool NotificationPresenterImpl::show(Notification* notification)
+{
+ return m_presenter->show(PassRefPtr<Notification>(notification));
+}
+
+void NotificationPresenterImpl::cancel(Notification* notification)
+{
+ m_presenter->cancel(PassRefPtr<Notification>(notification));
+}
+
+void NotificationPresenterImpl::notificationObjectDestroyed(Notification* notification)
+{
+ m_presenter->objectDestroyed(PassRefPtr<Notification>(notification));
+}
+
+NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context)
+{
+ int result = m_presenter->checkPermission(context->url());
+ return static_cast<NotificationPresenter::Permission>(result);
+}
+
+void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
+{
+ m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new VoidCallbackClient(callback));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS)
diff --git a/Source/WebKit/chromium/src/NotificationPresenterImpl.h b/Source/WebKit/chromium/src/NotificationPresenterImpl.h
new file mode 100644
index 0000000..bb156dd
--- /dev/null
+++ b/Source/WebKit/chromium/src/NotificationPresenterImpl.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NotificationPresenterImpl_h
+#define NotificationPresenterImpl_h
+
+#include "NotificationPresenter.h"
+#include "VoidCallback.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+#if ENABLE(NOTIFICATIONS)
+
+namespace WebKit {
+
+class WebNotificationPresenter;
+
+class NotificationPresenterImpl : public WebCore::NotificationPresenter {
+public:
+ NotificationPresenterImpl() : m_presenter(0) { }
+
+ void initialize(WebNotificationPresenter* presenter);
+ bool isInitialized();
+
+ // WebCore::NotificationPresenter implementation.
+ virtual bool show(WebCore::Notification* object);
+ virtual void cancel(WebCore::Notification* object);
+ virtual void notificationObjectDestroyed(WebCore::Notification* object);
+ virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::ScriptExecutionContext*);
+ virtual void requestPermission(WebCore::ScriptExecutionContext* , WTF::PassRefPtr<WebCore::VoidCallback> callback);
+ virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) {}
+
+private:
+ // WebNotificationPresenter that this object delegates to.
+ WebNotificationPresenter* m_presenter;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS)
+
+#endif
diff --git a/Source/WebKit/chromium/src/PlatformBridge.cpp b/Source/WebKit/chromium/src/PlatformBridge.cpp
new file mode 100644
index 0000000..04016fc
--- /dev/null
+++ b/Source/WebKit/chromium/src/PlatformBridge.cpp
@@ -0,0 +1,1048 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformBridge.h"
+
+#include <googleurl/src/url_util.h>
+
+#include "Chrome.h"
+#include "ChromeClientImpl.h"
+#include "WebAudioBus.h"
+#include "WebClipboard.h"
+#include "WebCookie.h"
+#include "WebCookieJar.h"
+#include "WebData.h"
+#include "WebDragData.h"
+#include "WebFileUtilities.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebIDBKey.h"
+#include "WebImage.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMimeRegistry.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPluginListBuilderImpl.h"
+#include "WebSandboxSupport.h"
+#include "WebSerializedScriptValue.h"
+#include "WebScreenInfo.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "WebWorkerClientImpl.h"
+
+#if PLATFORM(CG)
+#include <CoreGraphics/CGContext.h>
+#endif
+
+#if OS(WINDOWS)
+#include "WebRect.h"
+#include "win/WebThemeEngine.h"
+#endif
+
+#if OS(LINUX) || OS(FREEBSD)
+#include "linux/WebThemeEngine.h"
+#include "WebFontInfo.h"
+#include "WebFontRenderStyle.h"
+#endif
+
+#if OS(DARWIN)
+#include "mac/WebThemeEngine.h"
+#endif
+
+#if WEBKIT_USING_SKIA
+#include "NativeImageSkia.h"
+#endif
+
+#include "BitmapImage.h"
+#include "Cookie.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "IDBFactoryBackendProxy.h"
+#include "KURL.h"
+#include "NotImplemented.h"
+#include "PlatformContextSkia.h"
+#include "PluginData.h"
+#include "SharedBuffer.h"
+
+#include "Worker.h"
+#include "WorkerContextProxy.h"
+#include <wtf/Assertions.h>
+
+// We are part of the WebKit implementation.
+using namespace WebKit;
+
+namespace WebCore {
+
+static ChromeClientImpl* toChromeClientImpl(Widget* widget)
+{
+ if (!widget)
+ return 0;
+
+ FrameView* view;
+ if (widget->isFrameView())
+ view = static_cast<FrameView*>(widget);
+ else if (widget->parent() && widget->parent()->isFrameView())
+ view = static_cast<FrameView*>(widget->parent());
+ else
+ return 0;
+
+ Page* page = view->frame() ? view->frame()->page() : 0;
+ if (!page)
+ return 0;
+
+ return static_cast<ChromeClientImpl*>(page->chrome()->client());
+}
+
+static WebWidgetClient* toWebWidgetClient(Widget* widget)
+{
+ ChromeClientImpl* chromeClientImpl = toChromeClientImpl(widget);
+ if (!chromeClientImpl || !chromeClientImpl->webView())
+ return 0;
+ return chromeClientImpl->webView()->client();
+}
+
+static WebCookieJar* getCookieJar(const Document* document)
+{
+ WebFrameImpl* frameImpl = WebFrameImpl::fromFrame(document->frame());
+ if (!frameImpl || !frameImpl->client())
+ return 0;
+ WebCookieJar* cookieJar = frameImpl->client()->cookieJar(frameImpl);
+ if (!cookieJar)
+ cookieJar = webKitClient()->cookieJar();
+ return cookieJar;
+}
+
+// Cache ----------------------------------------------------------------------
+
+void PlatformBridge::cacheMetadata(const KURL& url, double responseTime, const Vector<char>& data)
+{
+ webKitClient()->cacheMetadata(url, responseTime, data.data(), data.size());
+}
+
+// Clipboard ------------------------------------------------------------------
+
+bool PlatformBridge::clipboardIsFormatAvailable(
+ PasteboardPrivate::ClipboardFormat format,
+ PasteboardPrivate::ClipboardBuffer buffer)
+{
+ return webKitClient()->clipboard()->isFormatAvailable(
+ static_cast<WebClipboard::Format>(format),
+ static_cast<WebClipboard::Buffer>(buffer));
+}
+
+String PlatformBridge::clipboardReadPlainText(
+ PasteboardPrivate::ClipboardBuffer buffer)
+{
+ return webKitClient()->clipboard()->readPlainText(
+ static_cast<WebClipboard::Buffer>(buffer));
+}
+
+void PlatformBridge::clipboardReadHTML(
+ PasteboardPrivate::ClipboardBuffer buffer,
+ String* htmlText, KURL* sourceURL)
+{
+ WebURL url;
+ *htmlText = webKitClient()->clipboard()->readHTML(
+ static_cast<WebClipboard::Buffer>(buffer), &url);
+ *sourceURL = url;
+}
+
+void PlatformBridge::clipboardWriteSelection(const String& htmlText,
+ const KURL& sourceURL,
+ const String& plainText,
+ bool writeSmartPaste)
+{
+ webKitClient()->clipboard()->writeHTML(
+ htmlText, sourceURL, plainText, writeSmartPaste);
+}
+
+void PlatformBridge::clipboardWritePlainText(const String& plainText)
+{
+ webKitClient()->clipboard()->writePlainText(plainText);
+}
+
+void PlatformBridge::clipboardWriteURL(const KURL& url, const String& title)
+{
+ webKitClient()->clipboard()->writeURL(url, title);
+}
+
+void PlatformBridge::clipboardWriteImage(NativeImagePtr image,
+ const KURL& sourceURL,
+ const String& title)
+{
+#if WEBKIT_USING_SKIA
+ WebImage webImage(*image);
+#else
+ WebImage webImage(image);
+#endif
+ webKitClient()->clipboard()->writeImage(webImage, sourceURL, title);
+}
+
+void PlatformBridge::clipboardWriteData(const String& type,
+ const String& data,
+ const String& metadata)
+{
+ webKitClient()->clipboard()->writeData(type, data, metadata);
+}
+
+HashSet<String> PlatformBridge::clipboardReadAvailableTypes(
+ PasteboardPrivate::ClipboardBuffer buffer, bool* containsFilenames)
+{
+ WebVector<WebString> result = webKitClient()->clipboard()->readAvailableTypes(
+ static_cast<WebClipboard::Buffer>(buffer), containsFilenames);
+ HashSet<String> types;
+ for (size_t i = 0; i < result.size(); ++i)
+ types.add(result[i]);
+ return types;
+}
+
+bool PlatformBridge::clipboardReadData(PasteboardPrivate::ClipboardBuffer buffer,
+ const String& type, String& data, String& metadata)
+{
+ WebString resultData;
+ WebString resultMetadata;
+ bool succeeded = webKitClient()->clipboard()->readData(
+ static_cast<WebClipboard::Buffer>(buffer), type, &resultData, &resultMetadata);
+ if (succeeded) {
+ data = resultData;
+ metadata = resultMetadata;
+ }
+ return succeeded;
+}
+
+Vector<String> PlatformBridge::clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer buffer)
+{
+ WebVector<WebString> result = webKitClient()->clipboard()->readFilenames(
+ static_cast<WebClipboard::Buffer>(buffer));
+ Vector<String> convertedResult;
+ for (size_t i = 0; i < result.size(); ++i)
+ convertedResult.append(result[i]);
+ return convertedResult;
+}
+
+// Cookies --------------------------------------------------------------------
+
+void PlatformBridge::setCookies(const Document* document, const KURL& url,
+ const String& value)
+{
+ WebCookieJar* cookieJar = getCookieJar(document);
+ if (cookieJar)
+ cookieJar->setCookie(url, document->firstPartyForCookies(), value);
+}
+
+String PlatformBridge::cookies(const Document* document, const KURL& url)
+{
+ String result;
+ WebCookieJar* cookieJar = getCookieJar(document);
+ if (cookieJar)
+ result = cookieJar->cookies(url, document->firstPartyForCookies());
+ return result;
+}
+
+String PlatformBridge::cookieRequestHeaderFieldValue(const Document* document,
+ const KURL& url)
+{
+ String result;
+ WebCookieJar* cookieJar = getCookieJar(document);
+ if (cookieJar)
+ result = cookieJar->cookieRequestHeaderFieldValue(url, document->firstPartyForCookies());
+ return result;
+}
+
+bool PlatformBridge::rawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies)
+{
+ rawCookies.clear();
+ WebVector<WebCookie> webCookies;
+
+ WebCookieJar* cookieJar = getCookieJar(document);
+ if (cookieJar)
+ cookieJar->rawCookies(url, document->firstPartyForCookies(), webCookies);
+
+ for (unsigned i = 0; i < webCookies.size(); ++i) {
+ const WebCookie& webCookie = webCookies[i];
+ Cookie cookie(webCookie.name,
+ webCookie.value,
+ webCookie.domain,
+ webCookie.path,
+ webCookie.expires,
+ webCookie.httpOnly,
+ webCookie.secure,
+ webCookie.session);
+ rawCookies.append(cookie);
+ }
+ return true;
+}
+
+void PlatformBridge::deleteCookie(const Document* document, const KURL& url, const String& cookieName)
+{
+ WebCookieJar* cookieJar = getCookieJar(document);
+ if (cookieJar)
+ cookieJar->deleteCookie(url, cookieName);
+}
+
+bool PlatformBridge::cookiesEnabled(const Document* document)
+{
+ bool result = false;
+ WebCookieJar* cookieJar = getCookieJar(document);
+ if (cookieJar)
+ result = cookieJar->cookiesEnabled(document->cookieURL(), document->firstPartyForCookies());
+ return result;
+}
+
+// DNS ------------------------------------------------------------------------
+
+void PlatformBridge::prefetchDNS(const String& hostname)
+{
+ webKitClient()->prefetchHostName(hostname);
+}
+
+// File ------------------------------------------------------------------------
+
+bool PlatformBridge::fileExists(const String& path)
+{
+ return webKitClient()->fileUtilities()->fileExists(path);
+}
+
+bool PlatformBridge::deleteFile(const String& path)
+{
+ return webKitClient()->fileUtilities()->deleteFile(path);
+}
+
+bool PlatformBridge::deleteEmptyDirectory(const String& path)
+{
+ return webKitClient()->fileUtilities()->deleteEmptyDirectory(path);
+}
+
+bool PlatformBridge::getFileSize(const String& path, long long& result)
+{
+ return webKitClient()->fileUtilities()->getFileSize(path, result);
+}
+
+void PlatformBridge::revealFolderInOS(const String& path)
+{
+ webKitClient()->fileUtilities()->revealFolderInOS(path);
+}
+
+bool PlatformBridge::getFileModificationTime(const String& path, time_t& result)
+{
+ double modificationTime;
+ if (!webKitClient()->fileUtilities()->getFileModificationTime(path, modificationTime))
+ return false;
+ result = static_cast<time_t>(modificationTime);
+ return true;
+}
+
+String PlatformBridge::directoryName(const String& path)
+{
+ return webKitClient()->fileUtilities()->directoryName(path);
+}
+
+String PlatformBridge::pathByAppendingComponent(const String& path, const String& component)
+{
+ return webKitClient()->fileUtilities()->pathByAppendingComponent(path, component);
+}
+
+bool PlatformBridge::makeAllDirectories(const String& path)
+{
+ return webKitClient()->fileUtilities()->makeAllDirectories(path);
+}
+
+String PlatformBridge::getAbsolutePath(const String& path)
+{
+ return webKitClient()->fileUtilities()->getAbsolutePath(path);
+}
+
+bool PlatformBridge::isDirectory(const String& path)
+{
+ return webKitClient()->fileUtilities()->isDirectory(path);
+}
+
+KURL PlatformBridge::filePathToURL(const String& path)
+{
+ return webKitClient()->fileUtilities()->filePathToURL(path);
+}
+
+PlatformFileHandle PlatformBridge::openFile(const String& path, FileOpenMode mode)
+{
+ return webKitClient()->fileUtilities()->openFile(path, mode);
+}
+
+void PlatformBridge::closeFile(PlatformFileHandle& handle)
+{
+ webKitClient()->fileUtilities()->closeFile(handle);
+}
+
+long long PlatformBridge::seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin)
+{
+ return webKitClient()->fileUtilities()->seekFile(handle, offset, origin);
+}
+
+bool PlatformBridge::truncateFile(PlatformFileHandle handle, long long offset)
+{
+ return webKitClient()->fileUtilities()->truncateFile(handle, offset);
+}
+
+int PlatformBridge::readFromFile(PlatformFileHandle handle, char* data, int length)
+{
+ return webKitClient()->fileUtilities()->readFromFile(handle, data, length);
+}
+
+int PlatformBridge::writeToFile(PlatformFileHandle handle, const char* data, int length)
+{
+ return webKitClient()->fileUtilities()->writeToFile(handle, data, length);
+}
+
+// Font -----------------------------------------------------------------------
+
+#if OS(WINDOWS)
+bool PlatformBridge::ensureFontLoaded(HFONT font)
+{
+ WebSandboxSupport* ss = webKitClient()->sandboxSupport();
+
+ // if there is no sandbox, then we can assume the font
+ // was able to be loaded successfully already
+ return ss ? ss->ensureFontLoaded(font) : true;
+}
+#endif
+
+#if OS(LINUX) || OS(FREEBSD)
+String PlatformBridge::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters)
+{
+ if (webKitClient()->sandboxSupport())
+ return webKitClient()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters);
+
+ WebCString family = WebFontInfo::familyForChars(characters, numCharacters);
+ if (family.data())
+ return WebString::fromUTF8(family.data());
+
+ return WebString();
+}
+
+void PlatformBridge::getRenderStyleForStrike(const char* font, int sizeAndStyle, FontRenderStyle* result)
+{
+ WebFontRenderStyle style;
+
+ if (webKitClient()->sandboxSupport())
+ webKitClient()->sandboxSupport()->getRenderStyleForStrike(font, sizeAndStyle, &style);
+ else
+ WebFontInfo::renderStyleForStrike(font, sizeAndStyle, &style);
+
+ style.toFontRenderStyle(result);
+}
+#endif
+
+#if OS(DARWIN)
+bool PlatformBridge::loadFont(NSFont* srcFont, ATSFontContainerRef* out)
+{
+ WebSandboxSupport* ss = webKitClient()->sandboxSupport();
+ if (ss)
+ return ss->loadFont(srcFont, out);
+
+ // This function should only be called in response to an error loading a
+ // font due to being blocked by the sandbox.
+ // This by definition shouldn't happen if there is no sandbox support.
+ ASSERT_NOT_REACHED();
+ *out = 0;
+ return false;
+}
+#endif
+
+// Databases ------------------------------------------------------------------
+
+PlatformFileHandle PlatformBridge::databaseOpenFile(const String& vfsFileName, int desiredFlags)
+{
+ return webKitClient()->databaseOpenFile(WebString(vfsFileName), desiredFlags);
+}
+
+int PlatformBridge::databaseDeleteFile(const String& vfsFileName, bool syncDir)
+{
+ return webKitClient()->databaseDeleteFile(WebString(vfsFileName), syncDir);
+}
+
+long PlatformBridge::databaseGetFileAttributes(const String& vfsFileName)
+{
+ return webKitClient()->databaseGetFileAttributes(WebString(vfsFileName));
+}
+
+long long PlatformBridge::databaseGetFileSize(const String& vfsFileName)
+{
+ return webKitClient()->databaseGetFileSize(WebString(vfsFileName));
+}
+
+// Indexed Database -----------------------------------------------------------
+
+PassRefPtr<IDBFactoryBackendInterface> PlatformBridge::idbFactory()
+{
+ // There's no reason why we need to allocate a new proxy each time, but
+ // there's also no strong reason not to.
+ return IDBFactoryBackendProxy::create();
+}
+
+void PlatformBridge::idbShutdown()
+{
+ // In the browser process, this shuts down the utility process. In the renderer process, it does nothing.
+ webKitClient()->idbShutdown();
+}
+
+void PlatformBridge::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys)
+{
+ WebVector<WebSerializedScriptValue> webValues = values;
+ WebVector<WebIDBKey> webKeys;
+ webKitClient()->createIDBKeysFromSerializedValuesAndKeyPath(webValues, WebString(keyPath), webKeys);
+
+ size_t webKeysSize = webKeys.size();
+ keys.reserveCapacity(webKeysSize);
+ for (size_t i = 0; i < webKeysSize; ++i)
+ keys.append(PassRefPtr<IDBKey>(webKeys[i]));
+}
+
+// Keygen ---------------------------------------------------------------------
+
+String PlatformBridge::signedPublicKeyAndChallengeString(
+ unsigned keySizeIndex, const String& challenge, const KURL& url)
+{
+ return webKitClient()->signedPublicKeyAndChallengeString(keySizeIndex,
+ WebString(challenge),
+ WebURL(url));
+}
+
+// Language -------------------------------------------------------------------
+
+String PlatformBridge::computedDefaultLanguage()
+{
+ return webKitClient()->defaultLocale();
+}
+
+// LayoutTestMode -------------------------------------------------------------
+
+bool PlatformBridge::layoutTestMode()
+{
+ return WebKit::layoutTestMode();
+}
+
+// MimeType -------------------------------------------------------------------
+
+bool PlatformBridge::isSupportedImageMIMEType(const String& mimeType)
+{
+ return webKitClient()->mimeRegistry()->supportsImageMIMEType(mimeType)
+ != WebMimeRegistry::IsNotSupported;
+}
+
+bool PlatformBridge::isSupportedJavaScriptMIMEType(const String& mimeType)
+{
+ return webKitClient()->mimeRegistry()->supportsJavaScriptMIMEType(mimeType)
+ != WebMimeRegistry::IsNotSupported;
+}
+
+bool PlatformBridge::isSupportedNonImageMIMEType(const String& mimeType)
+{
+ return webKitClient()->mimeRegistry()->supportsNonImageMIMEType(mimeType)
+ != WebMimeRegistry::IsNotSupported;
+}
+
+String PlatformBridge::mimeTypeForExtension(const String& extension)
+{
+ return webKitClient()->mimeRegistry()->mimeTypeForExtension(extension);
+}
+
+String PlatformBridge::mimeTypeFromFile(const String& path)
+{
+ return webKitClient()->mimeRegistry()->mimeTypeFromFile(path);
+}
+
+String PlatformBridge::preferredExtensionForMIMEType(const String& mimeType)
+{
+ return webKitClient()->mimeRegistry()->preferredExtensionForMIMEType(mimeType);
+}
+
+// Plugin ---------------------------------------------------------------------
+
+bool PlatformBridge::plugins(bool refresh, Vector<PluginInfo>* results)
+{
+ WebPluginListBuilderImpl builder(results);
+ webKitClient()->getPluginList(refresh, &builder);
+ return true; // FIXME: There is no need for this function to return a value.
+}
+
+NPObject* PlatformBridge::pluginScriptableObject(Widget* widget)
+{
+ if (!widget || !widget->isPluginContainer())
+ return 0;
+
+ return static_cast<WebPluginContainerImpl*>(widget)->scriptableObject();
+}
+
+// Resources ------------------------------------------------------------------
+
+PassRefPtr<Image> PlatformBridge::loadPlatformImageResource(const char* name)
+{
+ const WebData& resource = webKitClient()->loadResource(name);
+ if (resource.isEmpty())
+ return Image::nullImage();
+
+ RefPtr<Image> image = BitmapImage::create();
+ image->setData(resource, true);
+ return image;
+}
+
+#if ENABLE(WEB_AUDIO)
+
+PassOwnPtr<AudioBus> PlatformBridge::loadPlatformAudioResource(const char* name, double sampleRate)
+{
+ const WebData& resource = webKitClient()->loadResource(name);
+ if (resource.isEmpty())
+ return 0;
+
+ return decodeAudioFileData(resource.data(), resource.size(), sampleRate);
+}
+
+PassOwnPtr<AudioBus> PlatformBridge::decodeAudioFileData(const char* data, size_t size, double sampleRate)
+{
+ WebAudioBus webAudioBus;
+ if (webKitClient()->loadAudioResource(&webAudioBus, data, size, sampleRate))
+ return webAudioBus.release();
+ return 0;
+}
+
+#endif // ENABLE(WEB_AUDIO)
+
+// Sandbox --------------------------------------------------------------------
+
+bool PlatformBridge::sandboxEnabled()
+{
+ return webKitClient()->sandboxEnabled();
+}
+
+// SharedTimers ---------------------------------------------------------------
+
+void PlatformBridge::setSharedTimerFiredFunction(void (*func)())
+{
+ webKitClient()->setSharedTimerFiredFunction(func);
+}
+
+void PlatformBridge::setSharedTimerFireTime(double fireTime)
+{
+ webKitClient()->setSharedTimerFireTime(fireTime);
+}
+
+void PlatformBridge::stopSharedTimer()
+{
+ webKitClient()->stopSharedTimer();
+}
+
+// StatsCounters --------------------------------------------------------------
+
+void PlatformBridge::decrementStatsCounter(const char* name)
+{
+ webKitClient()->decrementStatsCounter(name);
+}
+
+void PlatformBridge::incrementStatsCounter(const char* name)
+{
+ webKitClient()->incrementStatsCounter(name);
+}
+
+void PlatformBridge::histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount)
+{
+ webKitClient()->histogramCustomCounts(name, sample, min, max, bucketCount);
+}
+
+void PlatformBridge::histogramEnumeration(const char* name, int sample, int boundaryValue)
+{
+ webKitClient()->histogramEnumeration(name, sample, boundaryValue);
+}
+
+// Sudden Termination ---------------------------------------------------------
+
+void PlatformBridge::suddenTerminationChanged(bool enabled)
+{
+ webKitClient()->suddenTerminationChanged(enabled);
+}
+
+// SystemTime -----------------------------------------------------------------
+
+double PlatformBridge::currentTime()
+{
+ return webKitClient()->currentTime();
+}
+
+// Theming --------------------------------------------------------------------
+
+#if OS(WINDOWS)
+
+void PlatformBridge::paintButton(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect)
+{
+ webKitClient()->themeEngine()->paintButton(
+ gc->platformContext()->canvas(), part, state, classicState, rect);
+}
+
+void PlatformBridge::paintMenuList(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect)
+{
+ webKitClient()->themeEngine()->paintMenuList(
+ gc->platformContext()->canvas(), part, state, classicState, rect);
+}
+
+void PlatformBridge::paintScrollbarArrow(
+ GraphicsContext* gc, int state, int classicState,
+ const IntRect& rect)
+{
+ webKitClient()->themeEngine()->paintScrollbarArrow(
+ gc->platformContext()->canvas(), state, classicState, rect);
+}
+
+void PlatformBridge::paintScrollbarThumb(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect)
+{
+ webKitClient()->themeEngine()->paintScrollbarThumb(
+ gc->platformContext()->canvas(), part, state, classicState, rect);
+}
+
+void PlatformBridge::paintScrollbarTrack(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect, const IntRect& alignRect)
+{
+ webKitClient()->themeEngine()->paintScrollbarTrack(
+ gc->platformContext()->canvas(), part, state, classicState, rect,
+ alignRect);
+}
+
+void PlatformBridge::paintSpinButton(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect)
+{
+ webKitClient()->themeEngine()->paintSpinButton(
+ gc->platformContext()->canvas(), part, state, classicState, rect);
+}
+
+void PlatformBridge::paintTextField(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect, const Color& color, bool fillContentArea,
+ bool drawEdges)
+{
+ // Fallback to white when |color| is invalid.
+ RGBA32 backgroundColor = color.isValid() ? color.rgb() : Color::white;
+
+ webKitClient()->themeEngine()->paintTextField(
+ gc->platformContext()->canvas(), part, state, classicState, rect,
+ backgroundColor, fillContentArea, drawEdges);
+}
+
+void PlatformBridge::paintTrackbar(
+ GraphicsContext* gc, int part, int state, int classicState,
+ const IntRect& rect)
+{
+ webKitClient()->themeEngine()->paintTrackbar(
+ gc->platformContext()->canvas(), part, state, classicState, rect);
+}
+
+void PlatformBridge::paintProgressBar(
+ GraphicsContext* gc, const IntRect& barRect, const IntRect& valueRect, bool determinate, double animatedSeconds)
+{
+ webKitClient()->themeEngine()->paintProgressBar(
+ gc->platformContext()->canvas(), barRect, valueRect, determinate, animatedSeconds);
+}
+
+#elif OS(LINUX)
+
+static WebThemeEngine::Part WebThemePart(PlatformBridge::ThemePart part)
+{
+ switch (part) {
+ case PlatformBridge::PartScrollbarDownArrow: return WebThemeEngine::PartScrollbarDownArrow;
+ case PlatformBridge::PartScrollbarLeftArrow: return WebThemeEngine::PartScrollbarLeftArrow;
+ case PlatformBridge::PartScrollbarRightArrow: return WebThemeEngine::PartScrollbarRightArrow;
+ case PlatformBridge::PartScrollbarUpArrow: return WebThemeEngine::PartScrollbarUpArrow;
+ case PlatformBridge::PartScrollbarHorizontalThumb: return WebThemeEngine::PartScrollbarHorizontalThumb;
+ case PlatformBridge::PartScrollbarVerticalThumb: return WebThemeEngine::PartScrollbarVerticalThumb;
+ case PlatformBridge::PartScrollbarHorizontalTrack: return WebThemeEngine::PartScrollbarHorizontalTrack;
+ case PlatformBridge::PartScrollbarVerticalTrack: return WebThemeEngine::PartScrollbarVerticalTrack;
+ case PlatformBridge::PartCheckbox: return WebThemeEngine::PartCheckbox;
+ case PlatformBridge::PartRadio: return WebThemeEngine::PartRadio;
+ case PlatformBridge::PartButton: return WebThemeEngine::PartButton;
+ case PlatformBridge::PartTextField: return WebThemeEngine::PartTextField;
+ case PlatformBridge::PartMenuList: return WebThemeEngine::PartMenuList;
+ case PlatformBridge::PartSliderTrack: return WebThemeEngine::PartSliderTrack;
+ case PlatformBridge::PartSliderThumb: return WebThemeEngine::PartSliderThumb;
+ case PlatformBridge::PartInnerSpinButton: return WebThemeEngine::PartInnerSpinButton;
+ case PlatformBridge::PartProgressBar: return WebThemeEngine::PartProgressBar;
+ }
+ ASSERT_NOT_REACHED();
+ return WebThemeEngine::PartScrollbarDownArrow;
+}
+
+static WebThemeEngine::State WebThemeState(PlatformBridge::ThemePaintState state)
+{
+ switch (state) {
+ case PlatformBridge::StateDisabled: return WebThemeEngine::StateDisabled;
+ case PlatformBridge::StateHover: return WebThemeEngine::StateHover;
+ case PlatformBridge::StateNormal: return WebThemeEngine::StateNormal;
+ case PlatformBridge::StatePressed: return WebThemeEngine::StatePressed;
+ }
+ ASSERT_NOT_REACHED();
+ return WebThemeEngine::StateDisabled;
+}
+
+static void GetWebThemeExtraParams(PlatformBridge::ThemePart part, PlatformBridge::ThemePaintState state, const PlatformBridge::ThemePaintExtraParams* extraParams, WebThemeEngine::ExtraParams* webThemeExtraParams)
+{
+ switch (part) {
+ case PlatformBridge::PartScrollbarHorizontalTrack:
+ case PlatformBridge::PartScrollbarVerticalTrack:
+ webThemeExtraParams->scrollbarTrack.trackX = extraParams->scrollbarTrack.trackX;
+ webThemeExtraParams->scrollbarTrack.trackY = extraParams->scrollbarTrack.trackY;
+ webThemeExtraParams->scrollbarTrack.trackWidth = extraParams->scrollbarTrack.trackWidth;
+ webThemeExtraParams->scrollbarTrack.trackHeight = extraParams->scrollbarTrack.trackHeight;
+ break;
+ case PlatformBridge::PartCheckbox:
+ webThemeExtraParams->button.checked = extraParams->button.checked;
+ webThemeExtraParams->button.indeterminate = extraParams->button.indeterminate;
+ break;
+ case PlatformBridge::PartRadio:
+ webThemeExtraParams->button.checked = extraParams->button.checked;
+ break;
+ case PlatformBridge::PartButton:
+ webThemeExtraParams->button.isDefault = extraParams->button.isDefault;
+ webThemeExtraParams->button.backgroundColor = extraParams->button.backgroundColor;
+ break;
+ case PlatformBridge::PartTextField:
+ webThemeExtraParams->textField.isTextArea = extraParams->textField.isTextArea;
+ webThemeExtraParams->textField.isListbox = extraParams->textField.isListbox;
+ webThemeExtraParams->textField.backgroundColor = extraParams->textField.backgroundColor;
+ break;
+ case PlatformBridge::PartMenuList:
+ webThemeExtraParams->menuList.arrowX = extraParams->menuList.arrowX;
+ webThemeExtraParams->menuList.arrowY = extraParams->menuList.arrowY;
+ webThemeExtraParams->menuList.backgroundColor = extraParams->menuList.backgroundColor;
+ break;
+ case PlatformBridge::PartSliderTrack:
+ case PlatformBridge::PartSliderThumb:
+ webThemeExtraParams->slider.vertical = extraParams->slider.vertical;
+ webThemeExtraParams->slider.inDrag = extraParams->slider.inDrag;
+ break;
+ case PlatformBridge::PartInnerSpinButton:
+ webThemeExtraParams->innerSpin.spinUp = extraParams->innerSpin.spinUp;
+ webThemeExtraParams->innerSpin.readOnly = extraParams->innerSpin.readOnly;
+ break;
+ case PlatformBridge::PartProgressBar:
+ webThemeExtraParams->progressBar.determinate = extraParams->progressBar.determinate;
+ webThemeExtraParams->progressBar.valueRectX = extraParams->progressBar.valueRectX;
+ webThemeExtraParams->progressBar.valueRectY = extraParams->progressBar.valueRectY;
+ webThemeExtraParams->progressBar.valueRectWidth = extraParams->progressBar.valueRectWidth;
+ webThemeExtraParams->progressBar.valueRectHeight = extraParams->progressBar.valueRectHeight;
+ break;
+ default:
+ break; // Parts that have no extra params get here.
+ }
+}
+
+IntSize PlatformBridge::getThemePartSize(ThemePart part)
+{
+ return webKitClient()->themeEngine()->getSize(WebThemePart(part));
+}
+
+void PlatformBridge::paintThemePart(
+ GraphicsContext* gc, ThemePart part, ThemePaintState state, const IntRect& rect, const ThemePaintExtraParams* extraParams)
+{
+ WebThemeEngine::ExtraParams webThemeExtraParams;
+ GetWebThemeExtraParams(part, state, extraParams, &webThemeExtraParams);
+ webKitClient()->themeEngine()->paint(
+ gc->platformContext()->canvas(), WebThemePart(part), WebThemeState(state), rect, &webThemeExtraParams);
+}
+
+#elif OS(DARWIN)
+
+void PlatformBridge::paintScrollbarThumb(
+ GraphicsContext* gc, ThemePaintState state, ThemePaintSize size, const IntRect& rect, const ThemePaintScrollbarInfo& scrollbarInfo)
+{
+ WebThemeEngine::ScrollbarInfo webThemeScrollbarInfo;
+
+ webThemeScrollbarInfo.orientation = static_cast<WebThemeEngine::ScrollbarOrientation>(scrollbarInfo.orientation);
+ webThemeScrollbarInfo.parent = static_cast<WebThemeEngine::ScrollbarParent>(scrollbarInfo.parent);
+ webThemeScrollbarInfo.maxValue = scrollbarInfo.maxValue;
+ webThemeScrollbarInfo.currentValue = scrollbarInfo.currentValue;
+ webThemeScrollbarInfo.visibleSize = scrollbarInfo.visibleSize;
+ webThemeScrollbarInfo.totalSize = scrollbarInfo.totalSize;
+
+ webKitClient()->themeEngine()->paintScrollbarThumb(
+ gc->platformContext(),
+ static_cast<WebThemeEngine::State>(state),
+ static_cast<WebThemeEngine::Size>(size),
+ rect,
+ webThemeScrollbarInfo);
+}
+
+#endif
+
+// Trace Event ----------------------------------------------------------------
+
+void PlatformBridge::traceEventBegin(const char* name, void* id, const char* extra)
+{
+ webKitClient()->traceEventBegin(name, id, extra);
+}
+
+void PlatformBridge::traceEventEnd(const char* name, void* id, const char* extra)
+{
+ webKitClient()->traceEventEnd(name, id, extra);
+}
+
+// Visited Links --------------------------------------------------------------
+
+LinkHash PlatformBridge::visitedLinkHash(const UChar* url, unsigned length)
+{
+ url_canon::RawCanonOutput<2048> buffer;
+ url_parse::Parsed parsed;
+ if (!url_util::Canonicalize(url, length, 0, &buffer, &parsed))
+ return 0; // Invalid URLs are unvisited.
+ return webKitClient()->visitedLinkHash(buffer.data(), buffer.length());
+}
+
+LinkHash PlatformBridge::visitedLinkHash(const KURL& base,
+ const AtomicString& attributeURL)
+{
+ // Resolve the relative URL using googleurl and pass the absolute URL up to
+ // the embedder. We could create a GURL object from the base and resolve
+ // the relative URL that way, but calling the lower-level functions
+ // directly saves us the string allocation in most cases.
+ url_canon::RawCanonOutput<2048> buffer;
+ url_parse::Parsed parsed;
+
+#if USE(GOOGLEURL)
+ const CString& cstr = base.utf8String();
+ const char* data = cstr.data();
+ int length = cstr.length();
+ const url_parse::Parsed& srcParsed = base.parsed();
+#else
+ // When we're not using GoogleURL, first canonicalize it so we can resolve it
+ // below.
+ url_canon::RawCanonOutput<2048> srcCanon;
+ url_parse::Parsed srcParsed;
+ String str = base.string();
+ if (!url_util::Canonicalize(str.characters(), str.length(), 0, &srcCanon, &srcParsed))
+ return 0;
+ const char* data = srcCanon.data();
+ int length = srcCanon.length();
+#endif
+
+ if (!url_util::ResolveRelative(data, length, srcParsed, attributeURL.characters(),
+ attributeURL.length(), 0, &buffer, &parsed))
+ return 0; // Invalid resolved URL.
+
+ return webKitClient()->visitedLinkHash(buffer.data(), buffer.length());
+}
+
+bool PlatformBridge::isLinkVisited(LinkHash visitedLinkHash)
+{
+ return webKitClient()->isLinkVisited(visitedLinkHash);
+}
+
+// These are temporary methods that the WebKit layer can use to call to the
+// Glue layer. Once the Glue layer moves entirely into the WebKit layer, these
+// methods will be deleted.
+
+void PlatformBridge::notifyJSOutOfMemory(Frame* frame)
+{
+ if (!frame)
+ return;
+
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
+ if (!webFrame->client())
+ return;
+ webFrame->client()->didExhaustMemoryAvailableForScript(webFrame);
+}
+
+int PlatformBridge::memoryUsageMB()
+{
+ return static_cast<int>(webKitClient()->memoryUsageMB());
+}
+
+int PlatformBridge::actualMemoryUsageMB()
+{
+ return static_cast<int>(webKitClient()->actualMemoryUsageMB());
+}
+
+int PlatformBridge::screenDepth(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return 0;
+ return client->screenInfo().depth;
+}
+
+int PlatformBridge::screenDepthPerComponent(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return 0;
+ return client->screenInfo().depthPerComponent;
+}
+
+bool PlatformBridge::screenIsMonochrome(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return 0;
+ return client->screenInfo().isMonochrome;
+}
+
+IntRect PlatformBridge::screenRect(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return IntRect();
+ return client->screenInfo().rect;
+}
+
+IntRect PlatformBridge::screenAvailableRect(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return IntRect();
+ return client->screenInfo().availableRect;
+}
+
+bool PlatformBridge::popupsAllowed(NPP npp)
+{
+ // FIXME: Give the embedder a way to control this.
+ return false;
+}
+
+WorkerContextProxy* WorkerContextProxy::create(Worker* worker)
+{
+ return WebWorkerClientImpl::createWorkerContextProxy(worker);
+}
+
+} // namespace WebCore
diff --git a/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp b/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp
new file mode 100644
index 0000000..aa42a10
--- /dev/null
+++ b/Source/WebKit/chromium/src/PlatformMessagePortChannel.cpp
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformMessagePortChannel.h"
+
+#include "MessagePort.h"
+#include "ScriptExecutionContext.h"
+#include "SerializedScriptValue.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMessagePortChannel.h"
+#include "WebString.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+PassOwnPtr<MessagePortChannel> MessagePortChannel::create(PassRefPtr<PlatformMessagePortChannel> channel)
+{
+ return new MessagePortChannel(channel);
+}
+
+void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2)
+{
+ PlatformMessagePortChannel::createChannel(port1, port2);
+}
+
+MessagePortChannel::MessagePortChannel(PassRefPtr<PlatformMessagePortChannel> channel)
+ : m_channel(channel)
+{
+}
+
+MessagePortChannel::~MessagePortChannel()
+{
+ // Make sure we close our platform channel when the base is freed, to keep the channel objects from leaking.
+ m_channel->close();
+}
+
+bool MessagePortChannel::entangleIfOpen(MessagePort* port)
+{
+ return m_channel->entangleIfOpen(port);
+}
+
+void MessagePortChannel::disentangle()
+{
+ m_channel->disentangle();
+}
+
+void MessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message)
+{
+ m_channel->postMessageToRemote(message);
+}
+
+bool MessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>& result)
+{
+ return m_channel->tryGetMessageFromRemote(result);
+}
+
+void MessagePortChannel::close()
+{
+ m_channel->close();
+}
+
+bool MessagePortChannel::isConnectedTo(MessagePort* port)
+{
+ return m_channel->isConnectedTo(port);
+}
+
+bool MessagePortChannel::hasPendingActivity()
+{
+ return m_channel->hasPendingActivity();
+}
+
+MessagePort* MessagePortChannel::locallyEntangledPort(const ScriptExecutionContext* context)
+{
+ // This is just an optimization, so return 0 always.
+ return 0;
+}
+
+
+PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create()
+{
+ return adoptRef(new PlatformMessagePortChannel());
+}
+
+PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::create(
+ WebMessagePortChannel* channel)
+{
+ return adoptRef(new PlatformMessagePortChannel(channel));
+}
+
+
+PlatformMessagePortChannel::PlatformMessagePortChannel()
+ : m_localPort(0)
+{
+ m_webChannel = webKitClient()->createMessagePortChannel();
+ if (m_webChannel)
+ m_webChannel->setClient(this);
+}
+
+PlatformMessagePortChannel::PlatformMessagePortChannel(WebMessagePortChannel* channel)
+ : m_localPort(0)
+ , m_webChannel(channel)
+{
+}
+
+PlatformMessagePortChannel::~PlatformMessagePortChannel()
+{
+ if (m_webChannel)
+ m_webChannel->destroy();
+}
+
+void PlatformMessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr<MessagePort> port2)
+{
+ // Create proxies for each endpoint.
+ RefPtr<PlatformMessagePortChannel> channel1 = PlatformMessagePortChannel::create();
+ RefPtr<PlatformMessagePortChannel> channel2 = PlatformMessagePortChannel::create();
+
+ // Entangle the two endpoints.
+ channel1->setEntangledChannel(channel2);
+ channel2->setEntangledChannel(channel1);
+
+ // Now entangle the proxies with the appropriate local ports.
+ port1->entangle(MessagePortChannel::create(channel2));
+ port2->entangle(MessagePortChannel::create(channel1));
+}
+
+void PlatformMessagePortChannel::messageAvailable()
+{
+ MutexLocker lock(m_mutex);
+ if (m_localPort)
+ m_localPort->messageAvailable();
+}
+
+bool PlatformMessagePortChannel::entangleIfOpen(MessagePort* port)
+{
+ MutexLocker lock(m_mutex);
+ m_localPort = port;
+ return true;
+}
+
+void PlatformMessagePortChannel::disentangle()
+{
+ MutexLocker lock(m_mutex);
+ m_localPort = 0;
+}
+
+void PlatformMessagePortChannel::postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData> message)
+{
+ if (!m_localPort || !m_webChannel)
+ return;
+
+ WebString messageString = message->message()->toWireString();
+ OwnPtr<WebCore::MessagePortChannelArray> channels = message->channels();
+ WebMessagePortChannelArray* webChannels = 0;
+ if (channels.get() && channels->size()) {
+ webChannels = new WebMessagePortChannelArray(channels->size());
+ for (size_t i = 0; i < channels->size(); ++i) {
+ WebCore::PlatformMessagePortChannel* platformChannel = (*channels)[i]->channel();
+ (*webChannels)[i] = platformChannel->webChannelRelease();
+ (*webChannels)[i]->setClient(0);
+ }
+ }
+ m_webChannel->postMessage(messageString, webChannels);
+}
+
+bool PlatformMessagePortChannel::tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>& result)
+{
+ if (!m_webChannel)
+ return false;
+
+ WebString message;
+ WebMessagePortChannelArray webChannels;
+ bool rv = m_webChannel->tryGetMessage(&message, webChannels);
+ if (rv) {
+ OwnPtr<MessagePortChannelArray> channels;
+ if (webChannels.size()) {
+ channels = new MessagePortChannelArray(webChannels.size());
+ for (size_t i = 0; i < webChannels.size(); ++i) {
+ RefPtr<PlatformMessagePortChannel> platformChannel = create(webChannels[i]);
+ webChannels[i]->setClient(platformChannel.get());
+ (*channels)[i] = MessagePortChannel::create(platformChannel);
+ }
+ }
+ RefPtr<SerializedScriptValue> serializedMessage = SerializedScriptValue::createFromWire(message);
+ result = MessagePortChannel::EventData::create(serializedMessage.release(), channels.release());
+ }
+
+ return rv;
+}
+
+void PlatformMessagePortChannel::close()
+{
+ MutexLocker lock(m_mutex);
+ // Disentangle ourselves from the other end. We still maintain a reference to m_webChannel,
+ // since previously-existing messages should still be delivered.
+ m_localPort = 0;
+ m_entangledChannel = 0;
+}
+
+bool PlatformMessagePortChannel::isConnectedTo(MessagePort* port)
+{
+ MutexLocker lock(m_mutex);
+ return m_entangledChannel && m_entangledChannel->m_localPort == port;
+}
+
+bool PlatformMessagePortChannel::hasPendingActivity()
+{
+ MutexLocker lock(m_mutex);
+ return m_localPort;
+}
+
+void PlatformMessagePortChannel::setEntangledChannel(PassRefPtr<PlatformMessagePortChannel> remote)
+{
+ if (m_webChannel)
+ m_webChannel->entangle(remote->m_webChannel);
+
+ MutexLocker lock(m_mutex);
+ m_entangledChannel = remote;
+}
+
+WebMessagePortChannel* PlatformMessagePortChannel::webChannelRelease()
+{
+ WebMessagePortChannel* rv = m_webChannel;
+ m_webChannel = 0;
+ return rv;
+}
+
+} // namespace WebCore
diff --git a/Source/WebKit/chromium/src/PlatformMessagePortChannel.h b/Source/WebKit/chromium/src/PlatformMessagePortChannel.h
new file mode 100644
index 0000000..5416145
--- /dev/null
+++ b/Source/WebKit/chromium/src/PlatformMessagePortChannel.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformMessagePortChannel_h
+#define PlatformMessagePortChannel_h
+
+#include "WebMessagePortChannelClient.h"
+
+#include "MessagePortChannel.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
+
+namespace WebKit {
+class WebMessagePortChannel;
+}
+
+namespace WebCore {
+
+class MessagePort;
+
+// PlatformMessagePortChannel is a platform-dependent interface to the remote side of a message channel.
+class PlatformMessagePortChannel : public ThreadSafeShared<PlatformMessagePortChannel>,
+ public WebKit::WebMessagePortChannelClient {
+public:
+ static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>);
+ static PassRefPtr<PlatformMessagePortChannel> create();
+ static PassRefPtr<PlatformMessagePortChannel> create(WebKit::WebMessagePortChannel*);
+
+ // APIs delegated from MessagePortChannel.h
+ bool entangleIfOpen(MessagePort*);
+ void disentangle();
+ void postMessageToRemote(PassOwnPtr<MessagePortChannel::EventData>);
+ bool tryGetMessageFromRemote(OwnPtr<MessagePortChannel::EventData>&);
+ void close();
+ bool isConnectedTo(MessagePort* port);
+ bool hasPendingActivity();
+
+ // Releases ownership of the contained web channel.
+ WebKit::WebMessagePortChannel* webChannelRelease();
+
+ ~PlatformMessagePortChannel();
+
+private:
+ PlatformMessagePortChannel();
+ PlatformMessagePortChannel(WebKit::WebMessagePortChannel*);
+
+ void setEntangledChannel(PassRefPtr<PlatformMessagePortChannel>);
+
+ // WebKit::WebMessagePortChannelClient implementation
+ virtual void messageAvailable();
+
+ // Mutex used to ensure exclusive access to the object internals.
+ Mutex m_mutex;
+
+ // Pointer to our entangled pair - cleared when close() is called.
+ RefPtr<PlatformMessagePortChannel> m_entangledChannel;
+
+ // The port we are connected to - this is the port that is notified when new messages arrive.
+ MessagePort* m_localPort;
+
+ WebKit::WebMessagePortChannel* m_webChannel;
+};
+
+} // namespace WebCore
+
+#endif // PlatformMessagePortChannel_h
diff --git a/Source/WebKit/chromium/src/ResourceHandle.cpp b/Source/WebKit/chromium/src/ResourceHandle.cpp
new file mode 100644
index 0000000..72f60bb
--- /dev/null
+++ b/Source/WebKit/chromium/src/ResourceHandle.cpp
@@ -0,0 +1,336 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ResourceHandle.h"
+
+#include "PlatformBridge.h"
+#include "ResourceHandleClient.h"
+#include "ResourceRequest.h"
+#include "SharedBuffer.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebURLError.h"
+#include "WebURLLoader.h"
+#include "WebURLLoaderClient.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+#include "WrappedResourceRequest.h"
+#include "WrappedResourceResponse.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+// ResourceHandleInternal -----------------------------------------------------
+
+class ResourceHandleInternal : public WebURLLoaderClient {
+public:
+ ResourceHandleInternal(const ResourceRequest& request, ResourceHandleClient* client)
+ : m_request(request)
+ , m_owner(0)
+ , m_client(client)
+ , m_state(ConnectionStateNew)
+ {
+ }
+
+ void start();
+ void cancel();
+ void setDefersLoading(bool);
+ bool allowStoredCredentials() const;
+
+ // WebURLLoaderClient methods:
+ virtual void willSendRequest(WebURLLoader*, WebURLRequest&, const WebURLResponse&);
+ virtual void didSendData(
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
+ virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&);
+ virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength);
+ virtual void didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength);
+ virtual void didFinishLoading(WebURLLoader*, double finishTime);
+ virtual void didFail(WebURLLoader*, const WebURLError&);
+
+ enum ConnectionState {
+ ConnectionStateNew,
+ ConnectionStateStarted,
+ ConnectionStateReceivedResponse,
+ ConnectionStateReceivingData,
+ ConnectionStateFinishedLoading,
+ ConnectionStateCanceled,
+ ConnectionStateFailed,
+ };
+
+ ResourceRequest m_request;
+ ResourceHandle* m_owner;
+ ResourceHandleClient* m_client;
+ OwnPtr<WebURLLoader> m_loader;
+
+ // Used for sanity checking to make sure we don't experience illegal state
+ // transitions.
+ ConnectionState m_state;
+};
+
+void ResourceHandleInternal::start()
+{
+ if (m_state != ConnectionStateNew)
+ CRASH();
+ m_state = ConnectionStateStarted;
+
+ m_loader.set(webKitClient()->createURLLoader());
+ ASSERT(m_loader.get());
+
+ WrappedResourceRequest wrappedRequest(m_request);
+ wrappedRequest.setAllowStoredCredentials(allowStoredCredentials());
+ m_loader->loadAsynchronously(wrappedRequest, this);
+}
+
+void ResourceHandleInternal::cancel()
+{
+ m_state = ConnectionStateCanceled;
+ m_loader->cancel();
+
+ // Do not make any further calls to the client.
+ m_client = 0;
+}
+
+void ResourceHandleInternal::setDefersLoading(bool value)
+{
+ m_loader->setDefersLoading(value);
+}
+
+bool ResourceHandleInternal::allowStoredCredentials() const
+{
+ return m_client && m_client->shouldUseCredentialStorage(m_owner);
+}
+
+void ResourceHandleInternal::willSendRequest(
+ WebURLLoader*, WebURLRequest& request, const WebURLResponse& response)
+{
+ ASSERT(m_client);
+ ASSERT(!request.isNull());
+ ASSERT(!response.isNull());
+ m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse());
+}
+
+void ResourceHandleInternal::didSendData(
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+{
+ ASSERT(m_client);
+ m_client->didSendData(m_owner, bytesSent, totalBytesToBeSent);
+}
+
+void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
+{
+ ASSERT(m_client);
+ ASSERT(!response.isNull());
+ bool isMultipart = response.isMultipartPayload();
+ bool isValidStateTransition = (m_state == ConnectionStateStarted || m_state == ConnectionStateReceivedResponse);
+ // In the case of multipart loads, calls to didReceiveData & didReceiveResponse can be interleaved.
+ if (!isMultipart && !isValidStateTransition)
+ CRASH();
+ m_state = ConnectionStateReceivedResponse;
+ m_client->didReceiveResponse(m_owner, response.toResourceResponse());
+}
+
+void ResourceHandleInternal::didReceiveData(
+ WebURLLoader*, const char* data, int dataLength)
+{
+ ASSERT(m_client);
+ if (m_state != ConnectionStateReceivedResponse && m_state != ConnectionStateReceivingData)
+ CRASH();
+ m_state = ConnectionStateReceivingData;
+
+ // FIXME(yurys): it looks like lengthReceived is always the same as
+ // dataLength and that the latter parameter can be eliminated.
+ // See WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=31019
+ m_client->didReceiveData(m_owner, data, dataLength, dataLength);
+}
+
+void ResourceHandleInternal::didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength)
+{
+ ASSERT(m_client);
+ if (m_state != ConnectionStateReceivedResponse && m_state != ConnectionStateReceivingData)
+ CRASH();
+
+ m_client->didReceiveCachedMetadata(m_owner, data, dataLength);
+}
+
+void ResourceHandleInternal::didFinishLoading(WebURLLoader*, double finishTime)
+{
+ ASSERT(m_client);
+ if (m_state != ConnectionStateReceivedResponse && m_state != ConnectionStateReceivingData)
+ CRASH();
+ m_state = ConnectionStateFinishedLoading;
+ m_client->didFinishLoading(m_owner, finishTime);
+}
+
+void ResourceHandleInternal::didFail(WebURLLoader*, const WebURLError& error)
+{
+ ASSERT(m_client);
+ m_state = ConnectionStateFailed;
+ m_client->didFail(m_owner, error);
+}
+
+// ResourceHandle -------------------------------------------------------------
+
+ResourceHandle::ResourceHandle(const ResourceRequest& request,
+ ResourceHandleClient* client,
+ bool defersLoading,
+ bool shouldContentSniff)
+ : d(new ResourceHandleInternal(request, client))
+{
+ d->m_owner = this;
+
+ // FIXME: Figure out what to do with the bool params.
+}
+
+PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context,
+ const ResourceRequest& request,
+ ResourceHandleClient* client,
+ bool defersLoading,
+ bool shouldContentSniff)
+{
+ RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle(
+ request, client, defersLoading, shouldContentSniff));
+
+ if (newHandle->start(context))
+ return newHandle.release();
+
+ return 0;
+}
+
+ResourceRequest& ResourceHandle::firstRequest()
+{
+ return d->m_request;
+}
+
+ResourceHandleClient* ResourceHandle::client() const
+{
+ return d->m_client;
+}
+
+void ResourceHandle::setClient(ResourceHandleClient* client)
+{
+ d->m_client = client;
+}
+
+void ResourceHandle::setDefersLoading(bool value)
+{
+ d->setDefersLoading(value);
+}
+
+bool ResourceHandle::start(NetworkingContext* context)
+{
+ d->start();
+ return true;
+}
+
+bool ResourceHandle::hasAuthenticationChallenge() const
+{
+ return false;
+}
+
+void ResourceHandle::clearAuthentication()
+{
+}
+
+void ResourceHandle::cancel()
+{
+ d->cancel();
+}
+
+ResourceHandle::~ResourceHandle()
+{
+ d->m_owner = 0;
+}
+
+PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
+{
+ return 0;
+}
+
+bool ResourceHandle::loadsBlocked()
+{
+ return false; // This seems to be related to sync XMLHttpRequest...
+}
+
+// static
+bool ResourceHandle::supportsBufferedData()
+{
+ return false; // The loader will buffer manually if it needs to.
+}
+
+// static
+void ResourceHandle::loadResourceSynchronously(NetworkingContext* context,
+ const ResourceRequest& request,
+ StoredCredentials storedCredentials,
+ ResourceError& error,
+ ResourceResponse& response,
+ Vector<char>& data)
+{
+ OwnPtr<WebURLLoader> loader(webKitClient()->createURLLoader());
+ ASSERT(loader.get());
+
+ WrappedResourceRequest requestIn(request);
+ requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials);
+ WrappedResourceResponse responseOut(response);
+ WebURLError errorOut;
+ WebData dataOut;
+
+ loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
+
+ error = errorOut;
+ data.clear();
+ data.append(dataOut.data(), dataOut.size());
+}
+
+// static
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
+{
+ // This method is used to determine if a POST request can be repeated from
+ // cache, but you cannot really know until you actually try to read from the
+ // cache. Even if we checked now, something else could come along and wipe
+ // out the cache entry by the time we fetch it.
+ //
+ // So, we always say yes here, to prevent the FrameLoader from initiating a
+ // reload. Then in FrameLoaderClientImpl::dispatchWillSendRequest, we
+ // fix-up the cache policy of the request to force a load from the cache.
+ //
+ ASSERT(request.httpMethod() == "POST");
+ return true;
+}
+
+// static
+void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vector<char>& data)
+{
+ PlatformBridge::cacheMetadata(response.url(), response.responseTime(), data);
+}
+
+} // namespace WebCore
diff --git a/Source/WebKit/chromium/src/SharedWorkerRepository.cpp b/Source/WebKit/chromium/src/SharedWorkerRepository.cpp
new file mode 100644
index 0000000..3d4428a
--- /dev/null
+++ b/Source/WebKit/chromium/src/SharedWorkerRepository.cpp
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "SharedWorkerRepository.h"
+
+#include "Event.h"
+#include "EventNames.h"
+#include "InspectorInstrumentation.h"
+#include "MessagePortChannel.h"
+#include "PlatformMessagePortChannel.h"
+#include "ScriptExecutionContext.h"
+#include "SharedWorker.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMessagePortChannel.h"
+#include "WebSharedWorker.h"
+#include "WebSharedWorkerRepository.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WorkerScriptLoader.h"
+#include "WorkerScriptLoaderClient.h"
+
+namespace WebCore {
+
+class Document;
+using WebKit::WebFrameImpl;
+using WebKit::WebMessagePortChannel;
+using WebKit::WebSharedWorker;
+using WebKit::WebSharedWorkerRepository;
+
+// Callback class that keeps the SharedWorker and WebSharedWorker objects alive while loads are potentially happening, and also translates load errors into error events on the worker.
+class SharedWorkerScriptLoader : private WorkerScriptLoaderClient, private WebSharedWorker::ConnectListener {
+public:
+ SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker)
+ : m_worker(worker)
+ , m_url(url)
+ , m_name(name)
+ , m_webWorker(webWorker)
+ , m_port(port)
+ , m_scriptLoader(ResourceRequestBase::TargetIsSharedWorker)
+ , m_loading(false)
+ , m_responseAppCacheID(0)
+ {
+ }
+
+ ~SharedWorkerScriptLoader();
+ void load();
+ static void stopAllLoadersForContext(ScriptExecutionContext*);
+
+private:
+ // WorkerScriptLoaderClient callback
+ virtual void didReceiveResponse(const ResourceResponse&);
+ virtual void notifyFinished();
+
+ virtual void connected();
+
+ const ScriptExecutionContext* loadingContext() { return m_worker->scriptExecutionContext(); }
+
+ void sendConnect();
+
+ RefPtr<SharedWorker> m_worker;
+ KURL m_url;
+ String m_name;
+ OwnPtr<WebSharedWorker> m_webWorker;
+ OwnPtr<MessagePortChannel> m_port;
+ WorkerScriptLoader m_scriptLoader;
+ bool m_loading;
+ long long m_responseAppCacheID;
+};
+
+static Vector<SharedWorkerScriptLoader*>& pendingLoaders()
+{
+ AtomicallyInitializedStatic(Vector<SharedWorkerScriptLoader*>&, loaders = *new Vector<SharedWorkerScriptLoader*>);
+ return loaders;
+}
+
+void SharedWorkerScriptLoader::stopAllLoadersForContext(ScriptExecutionContext* context)
+{
+ // Walk our list of pending loaders and shutdown any that belong to this context.
+ Vector<SharedWorkerScriptLoader*>& loaders = pendingLoaders();
+ for (unsigned i = 0; i < loaders.size(); ) {
+ SharedWorkerScriptLoader* loader = loaders[i];
+ if (context == loader->loadingContext()) {
+ loaders.remove(i);
+ delete loader;
+ } else
+ i++;
+ }
+}
+
+SharedWorkerScriptLoader::~SharedWorkerScriptLoader()
+{
+ if (m_loading)
+ m_worker->unsetPendingActivity(m_worker.get());
+}
+
+void SharedWorkerScriptLoader::load()
+{
+ ASSERT(!m_loading);
+ // If the shared worker is not yet running, load the script resource for it, otherwise just send it a connect event.
+ if (m_webWorker->isStarted())
+ sendConnect();
+ else {
+ m_scriptLoader.loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this);
+ // Keep the worker + JS wrapper alive until the resource load is complete in case we need to dispatch an error event.
+ m_worker->setPendingActivity(m_worker.get());
+ m_loading = true;
+ }
+}
+
+// Extracts a WebMessagePortChannel from a MessagePortChannel.
+static WebMessagePortChannel* getWebPort(PassOwnPtr<MessagePortChannel> port)
+{
+ // Extract the WebMessagePortChannel to send to the worker.
+ PlatformMessagePortChannel* platformChannel = port->channel();
+ WebMessagePortChannel* webPort = platformChannel->webChannelRelease();
+ webPort->setClient(0);
+ return webPort;
+}
+
+void SharedWorkerScriptLoader::didReceiveResponse(const ResourceResponse& response)
+{
+ m_responseAppCacheID = response.appCacheID();
+}
+
+void SharedWorkerScriptLoader::notifyFinished()
+{
+ if (m_scriptLoader.failed()) {
+ m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true));
+ delete this;
+ } else {
+ InspectorInstrumentation::scriptImported(m_worker->scriptExecutionContext(), m_scriptLoader.identifier(), m_scriptLoader.script());
+ // Pass the script off to the worker, then send a connect event.
+ m_webWorker->startWorkerContext(m_url, m_name, m_worker->scriptExecutionContext()->userAgent(m_url), m_scriptLoader.script(), m_responseAppCacheID);
+ sendConnect();
+ }
+}
+
+void SharedWorkerScriptLoader::sendConnect()
+{
+ // Send the connect event off, and linger until it is done sending.
+ m_webWorker->connect(getWebPort(m_port.release()), this);
+}
+
+void SharedWorkerScriptLoader::connected()
+{
+ // Connect event has been sent, so free ourselves (this releases the SharedWorker so it can be freed as well if unreferenced).
+ delete this;
+}
+
+bool SharedWorkerRepository::isAvailable()
+{
+ // Allow the WebKitClient to determine if SharedWorkers are available.
+ return WebKit::webKitClient()->sharedWorkerRepository();
+}
+
+static WebSharedWorkerRepository::DocumentID getId(void* document)
+{
+ ASSERT(document);
+ return reinterpret_cast<WebSharedWorkerRepository::DocumentID>(document);
+}
+
+void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionCode& ec)
+{
+ // This should not be callable unless there's a SharedWorkerRepository for
+ // this context (since isAvailable() should have returned null).
+ ASSERT(WebKit::webKitClient()->sharedWorkerRepository());
+
+ // No nested workers (for now) - connect() should only be called from document context.
+ ASSERT(worker->scriptExecutionContext()->isDocument());
+ Document* document = static_cast<Document*>(worker->scriptExecutionContext());
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ OwnPtr<WebSharedWorker> webWorker;
+ webWorker = webFrame->client()->createSharedWorker(webFrame, url, name, getId(document));
+
+ if (!webWorker) {
+ // Existing worker does not match this url, so return an error back to the caller.
+ ec = URL_MISMATCH_ERR;
+ return;
+ }
+
+ WebKit::webKitClient()->sharedWorkerRepository()->addSharedWorker(
+ webWorker.get(), getId(document));
+
+ // The loader object manages its own lifecycle (and the lifecycles of the two worker objects).
+ // It will free itself once loading is completed.
+ SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url, name, port, webWorker.release());
+ loader->load();
+}
+
+void SharedWorkerRepository::documentDetached(Document* document)
+{
+ WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository();
+ if (repo)
+ repo->documentDetached(getId(document));
+
+ // Stop the creation of any pending SharedWorkers for this context.
+ // FIXME: Need a way to invoke this for WorkerContexts as well when we support for nested workers.
+ SharedWorkerScriptLoader::stopAllLoadersForContext(document);
+}
+
+bool SharedWorkerRepository::hasSharedWorkers(Document* document)
+{
+ WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository();
+ return repo && repo->hasSharedWorkers(getId(document));
+}
+
+
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
diff --git a/Source/WebKit/chromium/src/SocketStreamHandle.cpp b/Source/WebKit/chromium/src/SocketStreamHandle.cpp
new file mode 100644
index 0000000..9f19942
--- /dev/null
+++ b/Source/WebKit/chromium/src/SocketStreamHandle.cpp
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SocketStreamHandle.h"
+
+#if ENABLE(WEB_SOCKETS)
+
+#include "Logging.h"
+#include "NotImplemented.h"
+#include "SocketStreamHandleClient.h"
+#include "WebData.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebSocketStreamHandle.h"
+#include "WebSocketStreamHandleClient.h"
+#include "WebURL.h"
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebKit;
+
+namespace WebCore {
+
+class SocketStreamHandleInternal : public WebSocketStreamHandleClient {
+public:
+ static PassOwnPtr<SocketStreamHandleInternal> create(SocketStreamHandle* handle)
+ {
+ return new SocketStreamHandleInternal(handle);
+ }
+ virtual ~SocketStreamHandleInternal();
+
+ void connect(const KURL&);
+ int send(const char*, int);
+ void close();
+
+ virtual void didOpenStream(WebSocketStreamHandle*, int);
+ virtual void didSendData(WebSocketStreamHandle*, int);
+ virtual void didReceiveData(WebSocketStreamHandle*, const WebData&);
+ virtual void didClose(WebSocketStreamHandle*);
+ virtual void didFail(WebSocketStreamHandle*, const WebSocketStreamError&);
+
+private:
+ explicit SocketStreamHandleInternal(SocketStreamHandle*);
+
+ SocketStreamHandle* m_handle;
+ OwnPtr<WebSocketStreamHandle> m_socket;
+ int m_maxPendingSendAllowed;
+ int m_pendingAmountSent;
+};
+
+SocketStreamHandleInternal::SocketStreamHandleInternal(SocketStreamHandle* handle)
+ : m_handle(handle)
+ , m_maxPendingSendAllowed(0)
+ , m_pendingAmountSent(0)
+{
+}
+
+SocketStreamHandleInternal::~SocketStreamHandleInternal()
+{
+ m_handle = 0;
+}
+
+void SocketStreamHandleInternal::connect(const KURL& url)
+{
+ m_socket.set(webKitClient()->createSocketStreamHandle());
+ LOG(Network, "connect");
+ ASSERT(m_socket.get());
+ m_socket->connect(url, this);
+}
+
+int SocketStreamHandleInternal::send(const char* data, int len)
+{
+ LOG(Network, "send len=%d", len);
+ ASSERT(m_socket.get());
+ if (m_pendingAmountSent + len >= m_maxPendingSendAllowed)
+ len = m_maxPendingSendAllowed - m_pendingAmountSent - 1;
+
+ if (len <= 0)
+ return len;
+ WebData webdata(data, len);
+ if (m_socket->send(webdata)) {
+ m_pendingAmountSent += len;
+ LOG(Network, "sent");
+ return len;
+ }
+ LOG(Network, "busy. buffering");
+ return 0;
+}
+
+void SocketStreamHandleInternal::close()
+{
+ LOG(Network, "close");
+ m_socket->close();
+}
+
+void SocketStreamHandleInternal::didOpenStream(WebSocketStreamHandle* socketHandle, int maxPendingSendAllowed)
+{
+ LOG(Network, "SocketStreamHandleInternal::didOpen %d",
+ maxPendingSendAllowed);
+ ASSERT(maxPendingSendAllowed > 0);
+ if (m_handle && m_socket.get()) {
+ ASSERT(socketHandle == m_socket.get());
+ m_maxPendingSendAllowed = maxPendingSendAllowed;
+ m_handle->m_state = SocketStreamHandleBase::Open;
+ if (m_handle->m_client) {
+ m_handle->m_client->didOpen(m_handle);
+ return;
+ }
+ }
+ LOG(Network, "no m_handle or m_socket?");
+}
+
+void SocketStreamHandleInternal::didSendData(WebSocketStreamHandle* socketHandle, int amountSent)
+{
+ LOG(Network, "SocketStreamHandleInternal::didSendData %d", amountSent);
+ ASSERT(amountSent > 0);
+ if (m_handle && m_socket.get()) {
+ ASSERT(socketHandle == m_socket.get());
+ m_pendingAmountSent -= amountSent;
+ ASSERT(m_pendingAmountSent >= 0);
+ m_handle->sendPendingData();
+ }
+}
+
+void SocketStreamHandleInternal::didReceiveData(WebSocketStreamHandle* socketHandle, const WebData& data)
+{
+ LOG(Network, "didReceiveData");
+ if (m_handle && m_socket.get()) {
+ ASSERT(socketHandle == m_socket.get());
+ if (m_handle->m_client)
+ m_handle->m_client->didReceiveData(m_handle, data.data(), data.size());
+ }
+}
+
+void SocketStreamHandleInternal::didClose(WebSocketStreamHandle* socketHandle)
+{
+ LOG(Network, "didClose");
+ if (m_handle && m_socket.get()) {
+ ASSERT(socketHandle == m_socket.get());
+ m_socket.clear();
+ SocketStreamHandle* h = m_handle;
+ m_handle = 0;
+ if (h->m_client)
+ h->m_client->didClose(h);
+ }
+}
+
+void SocketStreamHandleInternal::didFail(WebSocketStreamHandle* socketHandle, const WebSocketStreamError& err)
+{
+ LOG(Network, "didFail");
+ if (m_handle && m_socket.get()) {
+ ASSERT(socketHandle == m_socket.get());
+ m_socket.clear();
+ SocketStreamHandle* h = m_handle;
+ m_handle = 0;
+ if (h->m_client)
+ h->m_client->didClose(h); // didFail(h, err);
+ }
+}
+
+// FIXME: auth
+
+// SocketStreamHandle ----------------------------------------------------------
+
+SocketStreamHandle::SocketStreamHandle(const KURL& url, SocketStreamHandleClient* client)
+ : SocketStreamHandleBase(url, client)
+{
+ m_internal = SocketStreamHandleInternal::create(this);
+ m_internal->connect(m_url);
+}
+
+SocketStreamHandle::~SocketStreamHandle()
+{
+ setClient(0);
+ m_internal.clear();
+}
+
+int SocketStreamHandle::platformSend(const char* buf, int len)
+{
+ if (!m_internal.get())
+ return 0;
+ return m_internal->send(buf, len);
+}
+
+void SocketStreamHandle::platformClose()
+{
+ if (m_internal.get())
+ m_internal->close();
+}
+
+void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
+{
+ if (m_client)
+ m_client->didReceiveAuthenticationChallenge(this, challenge);
+}
+
+void SocketStreamHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
+{
+ notImplemented();
+}
+
+void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge)
+{
+ notImplemented();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_SOCKETS)
diff --git a/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp b/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp
new file mode 100644
index 0000000..e481f6e
--- /dev/null
+++ b/Source/WebKit/chromium/src/SpeechInputClientImpl.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SpeechInputClientImpl.h"
+
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+#include "SpeechInputListener.h"
+#include "WebSecurityOrigin.h"
+#include "WebSpeechInputController.h"
+#include "WebString.h"
+#include "WebViewClient.h"
+#include <wtf/PassOwnPtr.h>
+
+#if ENABLE(INPUT_SPEECH)
+
+namespace WebKit {
+
+PassOwnPtr<SpeechInputClientImpl> SpeechInputClientImpl::create(WebViewClient* client)
+{
+ return adoptPtr(new SpeechInputClientImpl(client));
+}
+
+SpeechInputClientImpl::SpeechInputClientImpl(WebViewClient* web_view_client)
+ : m_controller(web_view_client ? web_view_client->speechInputController(this) : 0)
+ , m_listener(0)
+{
+}
+
+SpeechInputClientImpl::~SpeechInputClientImpl()
+{
+}
+
+void SpeechInputClientImpl::setListener(WebCore::SpeechInputListener* listener)
+{
+ m_listener = listener;
+}
+
+bool SpeechInputClientImpl::startRecognition(int requestId, const WebCore::IntRect& elementRect, const AtomicString& language, const String& grammar, WebCore::SecurityOrigin* origin)
+{
+ ASSERT(m_listener);
+ return m_controller->startRecognition(requestId, elementRect, language, grammar, WebSecurityOrigin(origin));
+}
+
+void SpeechInputClientImpl::stopRecording(int requestId)
+{
+ ASSERT(m_listener);
+ m_controller->stopRecording(requestId);
+}
+
+void SpeechInputClientImpl::cancelRecognition(int requestId)
+{
+ ASSERT(m_listener);
+ m_controller->cancelRecognition(requestId);
+}
+
+void SpeechInputClientImpl::didCompleteRecording(int requestId)
+{
+ ASSERT(m_listener);
+ m_listener->didCompleteRecording(requestId);
+}
+
+void SpeechInputClientImpl::didCompleteRecognition(int requestId)
+{
+ ASSERT(m_listener);
+ m_listener->didCompleteRecognition(requestId);
+}
+
+void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebSpeechInputResultArray& results)
+{
+ ASSERT(m_listener);
+ WebCore::SpeechInputResultArray webcoreResults(results.size());
+ for (size_t i = 0; i < results.size(); ++i)
+ webcoreResults[i] = results[i];
+ m_listener->setRecognitionResult(requestId, webcoreResults);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_SPEECH)
diff --git a/Source/WebKit/chromium/src/SpeechInputClientImpl.h b/Source/WebKit/chromium/src/SpeechInputClientImpl.h
new file mode 100644
index 0000000..a81151d
--- /dev/null
+++ b/Source/WebKit/chromium/src/SpeechInputClientImpl.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SpeechInputClientImpl_h
+#define SpeechInputClientImpl_h
+
+#if ENABLE(INPUT_SPEECH)
+
+#include "SpeechInputClient.h"
+#include "WebSpeechInputListener.h"
+#include <wtf/Forward.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+class SecurityOrigin;
+class SpeechInputListener;
+}
+
+namespace WebKit {
+
+class WebSpeechInputController;
+class WebViewClient;
+
+class SpeechInputClientImpl
+ : public WebCore::SpeechInputClient,
+ public WebSpeechInputListener {
+public:
+ static PassOwnPtr<SpeechInputClientImpl> create(WebViewClient*);
+ virtual ~SpeechInputClientImpl();
+
+ // SpeechInputClient methods.
+ void setListener(WebCore::SpeechInputListener*);
+ bool startRecognition(int requestId, const WebCore::IntRect& elementRect, const AtomicString& language, const String& grammar, WebCore::SecurityOrigin*);
+ void stopRecording(int);
+ void cancelRecognition(int);
+
+ // WebSpeechInputListener methods.
+ void didCompleteRecording(int);
+ void setRecognitionResult(int, const WebSpeechInputResultArray&);
+ void didCompleteRecognition(int);
+
+private:
+ SpeechInputClientImpl(WebViewClient*);
+
+ WebSpeechInputController* m_controller; // To call into the embedder.
+ WebCore::SpeechInputListener* m_listener;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_SPEECH)
+
+#endif // SpeechInputClientImpl_h
diff --git a/Source/WebKit/chromium/src/StorageAreaProxy.cpp b/Source/WebKit/chromium/src/StorageAreaProxy.cpp
new file mode 100644
index 0000000..ed89b2c
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageAreaProxy.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2009 Google Inc. All Rights Reserved.
+ * (C) 2008 Apple Inc.
+ *
+ * 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 GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "StorageAreaProxy.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "EventNames.h"
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "SecurityOrigin.h"
+#include "StorageAreaImpl.h"
+#include "StorageEvent.h"
+
+#include "WebFrameImpl.h"
+#include "WebStorageArea.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+namespace WebCore {
+
+StorageAreaProxy::StorageAreaProxy(WebKit::WebStorageArea* storageArea, StorageType storageType)
+ : m_storageArea(storageArea)
+ , m_storageType(storageType)
+{
+}
+
+StorageAreaProxy::~StorageAreaProxy()
+{
+}
+
+unsigned StorageAreaProxy::length() const
+{
+ return m_storageArea->length();
+}
+
+String StorageAreaProxy::key(unsigned index) const
+{
+ return m_storageArea->key(index);
+}
+
+String StorageAreaProxy::getItem(const String& key) const
+{
+ return m_storageArea->getItem(key);
+}
+
+String StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
+{
+ WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK;
+ WebKit::WebString oldValue;
+ WebKit::WebFrame* webFrame = WebKit::WebFrameImpl::fromFrame(frame);
+ m_storageArea->setItem(key, value, frame->document()->url(), result, oldValue, webFrame);
+ ec = (result == WebKit::WebStorageArea::ResultOK) ? 0 : QUOTA_EXCEEDED_ERR;
+ String oldValueString = oldValue;
+ if (oldValueString != value && result == WebKit::WebStorageArea::ResultOK)
+ storageEvent(key, oldValue, value, m_storageType, frame->document()->securityOrigin(), frame);
+ return oldValue;
+}
+
+String StorageAreaProxy::removeItem(const String& key, Frame* frame)
+{
+ WebKit::WebString oldValue;
+ m_storageArea->removeItem(key, frame->document()->url(), oldValue);
+ if (!oldValue.isNull())
+ storageEvent(key, oldValue, String(), m_storageType, frame->document()->securityOrigin(), frame);
+ return oldValue;
+}
+
+bool StorageAreaProxy::clear(Frame* frame)
+{
+ bool clearedSomething;
+ m_storageArea->clear(frame->document()->url(), clearedSomething);
+ if (clearedSomething)
+ storageEvent(String(), String(), String(), m_storageType, frame->document()->securityOrigin(), frame);
+ return clearedSomething;
+}
+
+bool StorageAreaProxy::contains(const String& key) const
+{
+ return !getItem(key).isNull();
+}
+
+// Copied from WebCore/storage/StorageEventDispatcher.cpp out of necessity. It's probably best to keep it current.
+void StorageAreaProxy::storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Frame* sourceFrame)
+{
+ Page* page = sourceFrame->page();
+ if (!page)
+ return;
+
+ // We need to copy all relevant frames from every page to a vector since sending the event to one frame might mutate the frame tree
+ // of any given page in the group or mutate the page group itself.
+ Vector<RefPtr<Frame> > frames;
+ if (storageType == SessionStorage) {
+ // Send events only to our page.
+ for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin))
+ frames.append(frame);
+ }
+
+ for (unsigned i = 0; i < frames.size(); ++i) {
+ ExceptionCode ec = 0;
+ Storage* storage = frames[i]->domWindow()->sessionStorage(ec);
+ if (!ec)
+ frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
+ }
+ } else {
+ // Send events to every page.
+ const HashSet<Page*>& pages = page->group().pages();
+ HashSet<Page*>::const_iterator end = pages.end();
+ for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
+ for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin))
+ frames.append(frame);
+ }
+ }
+
+ for (unsigned i = 0; i < frames.size(); ++i) {
+ ExceptionCode ec = 0;
+ Storage* storage = frames[i]->domWindow()->localStorage(ec);
+ if (!ec)
+ frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
+ }
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/StorageAreaProxy.h b/Source/WebKit/chromium/src/StorageAreaProxy.h
new file mode 100644
index 0000000..b169828
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageAreaProxy.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 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 GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StorageAreaProxy_h
+#define StorageAreaProxy_h
+
+#if ENABLE(DOM_STORAGE)
+
+#include "StorageArea.h"
+
+namespace WebKit { class WebStorageArea; }
+
+namespace WebCore {
+
+class Frame;
+class SecurityOrigin;
+
+class StorageAreaProxy : public StorageArea {
+public:
+ StorageAreaProxy(WebKit::WebStorageArea*, StorageType);
+ virtual ~StorageAreaProxy();
+
+ // The HTML5 DOM Storage API
+ virtual unsigned length() const;
+ virtual String key(unsigned index) const;
+ virtual String getItem(const String& key) const;
+ virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame);
+ virtual String removeItem(const String& key, Frame* sourceFrame);
+ virtual bool clear(Frame* sourceFrame);
+ virtual bool contains(const String& key) const;
+
+private:
+ void storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Frame* sourceFrame);
+
+ OwnPtr<WebKit::WebStorageArea> m_storageArea;
+ StorageType m_storageType;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
+
+#endif // StorageAreaProxy_h
diff --git a/Source/WebKit/chromium/src/StorageEventDispatcherChromium.cpp b/Source/WebKit/chromium/src/StorageEventDispatcherChromium.cpp
new file mode 100644
index 0000000..3286929
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageEventDispatcherChromium.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "StorageEventDispatcher.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "SecurityOrigin.h"
+#include "StorageArea.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+namespace WebCore {
+
+void StorageEventDispatcher::dispatch(const String& key, const String& oldValue,
+ const String& newValue, StorageType storageType,
+ SecurityOrigin* origin, Frame* sourceFrame)
+{
+ ASSERT(!sourceFrame); // Sad, but true.
+ WebKit::webKitClient()->dispatchStorageEvent(key, oldValue, newValue, origin->toString(), WebKit::WebURL(), storageType == LocalStorage);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/StorageEventDispatcherImpl.cpp b/Source/WebKit/chromium/src/StorageEventDispatcherImpl.cpp
new file mode 100644
index 0000000..631753b
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageEventDispatcherImpl.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "StorageEventDispatcherImpl.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "DOMWindow.h"
+#include "EventNames.h"
+#include "Frame.h"
+#include "KURL.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "SecurityOrigin.h"
+#include "StorageEvent.h"
+
+namespace WebCore {
+
+StorageEventDispatcherImpl::StorageEventDispatcherImpl(const String& groupName)
+ : m_pageGroup(PageGroup::pageGroup(groupName))
+{
+ ASSERT(m_pageGroup);
+}
+
+void StorageEventDispatcherImpl::dispatchStorageEvent(const String& key, const String& oldValue,
+ const String& newValue, SecurityOrigin* securityOrigin,
+ const KURL& url, StorageType storageType)
+{
+ // FIXME: Implement
+ if (storageType == SessionStorage)
+ return;
+
+ // We need to copy all relevant frames from every page to a vector since sending the event to one frame might mutate the frame tree
+ // of any given page in the group or mutate the page group itself.
+ Vector<RefPtr<Frame> > frames;
+
+ const HashSet<Page*>& pages = m_pageGroup->pages();
+ HashSet<Page*>::const_iterator end = pages.end();
+ for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
+ for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ if (frame->document()->securityOrigin()->equal(securityOrigin))
+ frames.append(frame);
+ }
+ }
+
+ for (unsigned i = 0; i < frames.size(); ++i) {
+ ExceptionCode ec = 0;
+ Storage* storage = frames[i]->domWindow()->localStorage(ec);
+ if (!ec)
+ frames[i]->document()->dispatchWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/StorageEventDispatcherImpl.h b/Source/WebKit/chromium/src/StorageEventDispatcherImpl.h
new file mode 100644
index 0000000..4c2db7c
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageEventDispatcherImpl.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StorageEventDispatcherImpl_h
+#define StorageEventDispatcherImpl_h
+
+#if ENABLE(DOM_STORAGE)
+
+#include "PlatformString.h"
+#include "StorageArea.h"
+
+namespace WebCore {
+
+class KURL;
+class PageGroup;
+class SecurityOrigin;
+
+class StorageEventDispatcherImpl {
+public:
+ StorageEventDispatcherImpl(const String& groupName);
+
+ void dispatchStorageEvent(const String& key, const String& oldValue,
+ const String& newValue, SecurityOrigin*,
+ const KURL&, StorageType);
+
+private:
+ PageGroup* m_pageGroup;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
+
+#endif // StorageEventDispatcherImpl_h
diff --git a/Source/WebKit/chromium/src/StorageNamespaceProxy.cpp b/Source/WebKit/chromium/src/StorageNamespaceProxy.cpp
new file mode 100644
index 0000000..ec0dbce
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageNamespaceProxy.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2009 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 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 GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "StorageNamespaceProxy.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "Chrome.h"
+#include "ChromeClientImpl.h"
+#include "Page.h"
+#include "SecurityOrigin.h"
+#include "StorageAreaProxy.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebStorageNamespace.h"
+#include "WebString.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+
+namespace WebCore {
+
+PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(const String& path, unsigned quota)
+{
+ return adoptRef(new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota), LocalStorage));
+}
+
+PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace(Page* page, unsigned quota)
+{
+ WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(page->chrome()->client());
+ WebKit::WebViewClient* webViewClient = chromeClientImpl->webView()->client();
+ return adoptRef(new StorageNamespaceProxy(webViewClient->createSessionStorageNamespace(quota), SessionStorage));
+}
+
+StorageNamespaceProxy::StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace, StorageType storageType)
+ : m_storageNamespace(storageNamespace)
+ , m_storageType(storageType)
+{
+}
+
+StorageNamespaceProxy::~StorageNamespaceProxy()
+{
+}
+
+PassRefPtr<StorageNamespace> StorageNamespaceProxy::copy()
+{
+ ASSERT(m_storageType == SessionStorage);
+ WebKit::WebStorageNamespace* newNamespace = m_storageNamespace->copy();
+ // Some embedders hook into WebViewClient::createView to make the copy of
+ // session storage and then return the object lazily. Other embedders
+ // choose to make the copy now and return a pointer immediately. So handle
+ // both cases.
+ if (!newNamespace)
+ return 0;
+ return adoptRef(new StorageNamespaceProxy(newNamespace, m_storageType));
+}
+
+PassRefPtr<StorageArea> StorageNamespaceProxy::storageArea(PassRefPtr<SecurityOrigin> origin)
+{
+ return adoptRef(new StorageAreaProxy(m_storageNamespace->createStorageArea(origin->toString()), m_storageType));
+}
+
+void StorageNamespaceProxy::close()
+{
+ m_storageNamespace->close();
+}
+
+void StorageNamespaceProxy::unlock()
+{
+ // FIXME: Implement.
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/StorageNamespaceProxy.h b/Source/WebKit/chromium/src/StorageNamespaceProxy.h
new file mode 100644
index 0000000..28d7a23
--- /dev/null
+++ b/Source/WebKit/chromium/src/StorageNamespaceProxy.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 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 GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StorageNamespaceProxy_h
+#define StorageNamespaceProxy_h
+
+#if ENABLE(DOM_STORAGE)
+
+#include "StorageArea.h"
+#include "StorageNamespace.h"
+
+namespace WebKit { class WebStorageNamespace; }
+
+namespace WebCore {
+
+class StorageNamespaceProxy : public StorageNamespace {
+public:
+ StorageNamespaceProxy(WebKit::WebStorageNamespace*, StorageType);
+ virtual ~StorageNamespaceProxy();
+ virtual PassRefPtr<StorageArea> storageArea(PassRefPtr<SecurityOrigin>);
+ virtual PassRefPtr<StorageNamespace> copy();
+ virtual void close();
+ virtual void unlock();
+
+private:
+ OwnPtr<WebKit::WebStorageNamespace> m_storageNamespace;
+ StorageType m_storageType;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(DOM_STORAGE)
+
+#endif // StorageNamespaceProxy_h
diff --git a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp
new file mode 100644
index 0000000..86545b7
--- /dev/null
+++ b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "VideoFrameChromiumImpl.h"
+
+#include "VideoFrameChromium.h"
+#include "WebVideoFrame.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebVideoFrame* VideoFrameChromiumImpl::toWebVideoFrame(VideoFrameChromium* videoFrame)
+{
+ VideoFrameChromiumImpl* wrappedFrame = static_cast<VideoFrameChromiumImpl*>(videoFrame);
+ if (wrappedFrame)
+ return wrappedFrame->m_webVideoFrame;
+ return 0;
+}
+
+VideoFrameChromiumImpl::VideoFrameChromiumImpl(WebVideoFrame* webVideoFrame)
+ : m_webVideoFrame(webVideoFrame)
+{
+}
+
+VideoFrameChromium::SurfaceType VideoFrameChromiumImpl::surfaceType() const
+{
+ if (m_webVideoFrame)
+ return static_cast<VideoFrameChromium::SurfaceType>(m_webVideoFrame->surfaceType());
+ return TypeSystemMemory;
+}
+
+VideoFrameChromium::Format VideoFrameChromiumImpl::format() const
+{
+ if (m_webVideoFrame)
+ return static_cast<VideoFrameChromium::Format>(m_webVideoFrame->format());
+ return Invalid;
+}
+
+unsigned VideoFrameChromiumImpl::width() const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->width();
+ return 0;
+}
+
+unsigned VideoFrameChromiumImpl::height() const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->height();
+ return 0;
+}
+
+unsigned VideoFrameChromiumImpl::planes() const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->planes();
+ return 0;
+}
+
+int VideoFrameChromiumImpl::stride(unsigned plane) const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->stride(plane);
+ return 0;
+}
+
+const void* VideoFrameChromiumImpl::data(unsigned plane) const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->data(plane);
+ return 0;
+}
+
+unsigned VideoFrameChromiumImpl::texture(unsigned plane) const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->texture(plane);
+ return 0;
+}
+
+const IntSize VideoFrameChromiumImpl::requiredTextureSize(unsigned plane) const
+{
+ switch (format()) {
+ case RGBA:
+ case YV16:
+ return IntSize(stride(plane), height());
+ case YV12:
+ if (plane == static_cast<unsigned>(yPlane))
+ return IntSize(stride(plane), height());
+ else if (plane == static_cast<unsigned>(uPlane))
+ return IntSize(stride(plane), height() / 2);
+ else if (plane == static_cast<unsigned>(vPlane))
+ return IntSize(stride(plane), height() / 2);
+ default:
+ break;
+ }
+ return IntSize();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h
new file mode 100644
index 0000000..f86ee1c
--- /dev/null
+++ b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VideoFrameChromiumImpl_h
+#define VideoFrameChromiumImpl_h
+
+#include "VideoFrameChromium.h"
+#include "WebVideoFrame.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// A wrapper class for WebKit::WebVideoFrame. Objects can be created in WebKit
+// and used in WebCore because of the VideoFrameChromium interface.
+class VideoFrameChromiumImpl : public VideoFrameChromium {
+public:
+ // Converts a WebCore::VideoFrameChromium to a WebKit::WebVideoFrame.
+ static WebVideoFrame* toWebVideoFrame(VideoFrameChromium*);
+
+ // Creates a VideoFrameChromiumImpl object to wrap the given WebVideoFrame.
+ // The VideoFrameChromiumImpl does not take ownership of the WebVideoFrame
+ // and should not free the frame's memory.
+ VideoFrameChromiumImpl(WebVideoFrame*);
+ virtual SurfaceType surfaceType() const;
+ virtual Format format() const;
+ virtual unsigned width() const;
+ virtual unsigned height() const;
+ virtual unsigned planes() const;
+ virtual int stride(unsigned plane) const;
+ virtual const void* data(unsigned plane) const;
+ virtual unsigned texture(unsigned plane) const;
+ virtual const IntSize requiredTextureSize(unsigned plane) const;
+
+private:
+ WebVideoFrame* m_webVideoFrame;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebAccessibilityCache.cpp b/Source/WebKit/chromium/src/WebAccessibilityCache.cpp
new file mode 100644
index 0000000..ab8f814
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAccessibilityCache.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAccessibilityCache.h"
+
+#include "AXObjectCache.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebAccessibilityCache::enableAccessibility()
+{
+ AXObjectCache::enableAccessibility();
+}
+
+bool WebAccessibilityCache::accessibilityEnabled()
+{
+ return AXObjectCache::accessibilityEnabled();
+}
+
+}
diff --git a/Source/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp b/Source/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp
new file mode 100644
index 0000000..f91bd1c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAccessibilityCacheImpl.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAccessibilityCacheImpl.h"
+
+#include "AccessibilityObject.h"
+#include "AXObjectCache.h"
+#include "Document.h"
+#include "Frame.h"
+
+#include "WebAccessibilityObject.h"
+#include "WebFrameImpl.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const int invalidObjectId = -1;
+const int firstObjectId = 1000;
+
+static PassRefPtr<AccessibilityObject> toAccessibilityObject(const WebAccessibilityObject& object)
+{
+ return object;
+}
+
+// WebView ----------------------------------------------------------------
+
+WebAccessibilityCache* WebAccessibilityCache::create()
+{
+ return new WebAccessibilityCacheImpl();
+}
+
+// WeakHandle -------------------------------------------------------------
+
+PassRefPtr<WebAccessibilityCacheImpl::WeakHandle> WebAccessibilityCacheImpl::WeakHandle::create(AccessibilityObject* object)
+{
+ RefPtr<WebAccessibilityCacheImpl::WeakHandle> weakHandle = adoptRef(new WebAccessibilityCacheImpl::WeakHandle(object));
+ weakHandle->m_object->setWrapper(weakHandle.get());
+
+ return weakHandle.release();
+}
+
+WebAccessibilityCacheImpl::WeakHandle::WeakHandle(AccessibilityObject* object)
+ : AccessibilityObjectWrapper(object)
+{
+}
+
+// WebAccessibilityCacheImpl ----------------------------------------
+
+void WebAccessibilityCacheImpl::WeakHandle::detach()
+{
+ if (m_object)
+ m_object = 0;
+}
+
+WebAccessibilityCacheImpl::WebAccessibilityCacheImpl()
+ : m_nextNewId(firstObjectId)
+ , m_initialized(false)
+{
+}
+
+WebAccessibilityCacheImpl::~WebAccessibilityCacheImpl()
+{
+}
+
+void WebAccessibilityCacheImpl::initialize(WebView* view)
+{
+ AXObjectCache::enableAccessibility();
+ WebAccessibilityObject root = view->accessibilityObject();
+ if (root.isNull())
+ return;
+
+ RefPtr<AccessibilityObject> rootObject = toAccessibilityObject(root);
+
+ // Insert root in hashmaps.
+ m_objectMap.set(m_nextNewId, WeakHandle::create(rootObject.get()));
+ m_idMap.set(rootObject.get(), m_nextNewId++);
+
+ m_initialized = true;
+}
+
+WebAccessibilityObject WebAccessibilityCacheImpl::getObjectById(int id)
+{
+ ObjectMap::iterator it = m_objectMap.find(id);
+
+ if (it == m_objectMap.end() || !it->second)
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(it->second->accessibilityObject());
+}
+
+void WebAccessibilityCacheImpl::remove(int id)
+{
+ ObjectMap::iterator it = m_objectMap.find(id);
+
+ if (it == m_objectMap.end())
+ return;
+
+ if (it->second) {
+ // Erase element from reverse hashmap.
+ IdMap::iterator it2 = m_idMap.find(it->second->accessibilityObject());
+ if (it2 != m_idMap.end())
+ m_idMap.remove(it2);
+ }
+
+ m_objectMap.remove(it);
+}
+
+void WebAccessibilityCacheImpl::clear()
+{
+ m_objectMap.clear();
+ m_idMap.clear();
+}
+
+int WebAccessibilityCacheImpl::addOrGetId(const WebAccessibilityObject& object)
+{
+ if (!object.isValid())
+ return invalidObjectId;
+
+ RefPtr<AccessibilityObject> o = toAccessibilityObject(object);
+
+ IdMap::iterator it = m_idMap.find(o.get());
+
+ if (it != m_idMap.end())
+ return it->second;
+
+ // Insert new accessibility object in hashmaps and return its newly
+ // assigned accessibility object id.
+ m_objectMap.set(m_nextNewId, WeakHandle::create(o.get()));
+ m_idMap.set(o.get(), m_nextNewId);
+
+ return m_nextNewId++;
+}
+
+bool WebAccessibilityCacheImpl::isCached(const WebAccessibilityObject& object)
+{
+ if (!object.isValid())
+ return false;
+
+ RefPtr<AccessibilityObject> o = toAccessibilityObject(object);
+ IdMap::iterator it = m_idMap.find(o.get());
+ if (it == m_idMap.end())
+ return false;
+
+ return true;
+}
+
+}
diff --git a/Source/WebKit/chromium/src/WebAccessibilityCacheImpl.h b/Source/WebKit/chromium/src/WebAccessibilityCacheImpl.h
new file mode 100644
index 0000000..c72c0fc
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAccessibilityCacheImpl.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebAccessibilityCacheImpl_h
+#define WebAccessibilityCacheImpl_h
+
+#include "AccessibilityObjectWrapper.h"
+#include "WebAccessibilityCache.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+// FIXME: Should be eliminated to use AXObjectCache instead.
+class WebAccessibilityCacheImpl : public WebKit::WebAccessibilityCache {
+public:
+ virtual void initialize(WebView* view);
+ virtual bool isInitialized() const { return m_initialized; }
+
+ virtual WebAccessibilityObject getObjectById(int);
+ virtual int addOrGetId(const WebKit::WebAccessibilityObject&);
+ virtual bool isCached(const WebAccessibilityObject&);
+
+ virtual void remove(int);
+ virtual void clear();
+
+protected:
+ friend class WebKit::WebAccessibilityCache;
+
+ WebAccessibilityCacheImpl();
+ ~WebAccessibilityCacheImpl();
+
+private:
+ // FIXME: This can be just part of Chromium's AccessibilityObjectWrapper.
+ class WeakHandle : public WebCore::AccessibilityObjectWrapper {
+ public:
+ static PassRefPtr<WeakHandle> create(WebCore::AccessibilityObject*);
+ virtual void detach();
+ private:
+ WeakHandle(WebCore::AccessibilityObject*);
+ };
+
+ typedef HashMap<int, RefPtr<WeakHandle> > ObjectMap;
+ typedef HashMap<WebCore::AccessibilityObject*, int> IdMap;
+
+ // Hashmap for caching of elements in use by the AT, mapping id (int) to
+ // WebAccessibilityObject.
+ ObjectMap m_objectMap;
+ // Hashmap for caching of elements in use by the AT, mapping a
+ // AccessibilityObject pointer to its id (int). Needed for reverse lookup,
+ // to ensure unnecessary duplicate entries are not created in the
+ // ObjectMap and for focus changes in WebKit.
+ IdMap m_idMap;
+
+ // Unique identifier for retrieving an accessibility object from the page's
+ // hashmaps. Id is always 0 for the root of the accessibility object
+ // hierarchy (on a per-renderer process basis).
+ int m_nextNewId;
+
+ bool m_initialized;
+};
+
+}
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebAccessibilityObject.cpp b/Source/WebKit/chromium/src/WebAccessibilityObject.cpp
new file mode 100644
index 0000000..50baa27
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAccessibilityObject.cpp
@@ -0,0 +1,556 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAccessibilityObject.h"
+
+#include "AccessibilityObject.h"
+#include "CSSPrimitiveValueMappings.h"
+#include "Document.h"
+#include "EventHandler.h"
+#include "FrameView.h"
+#include "Node.h"
+#include "PlatformKeyboardEvent.h"
+#include "RenderStyle.h"
+#include "WebDocument.h"
+#include "WebNode.h"
+#include "WebPoint.h"
+#include "WebRect.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebAccessibilityObjectPrivate : public WebCore::AccessibilityObject {
+};
+
+void WebAccessibilityObject::reset()
+{
+ assign(0);
+}
+
+void WebAccessibilityObject::assign(const WebKit::WebAccessibilityObject& other)
+{
+ WebAccessibilityObjectPrivate* p = const_cast<WebAccessibilityObjectPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+WebString WebAccessibilityObject::accessibilityDescription() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->accessibilityDescription();
+}
+
+WebString WebAccessibilityObject::actionVerb() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->actionVerb();
+}
+
+bool WebAccessibilityObject::canSetFocusAttribute() const
+{
+ if (!m_private)
+ return false;
+
+ m_private->updateBackingStore();
+ return m_private->canSetFocusAttribute();
+}
+
+bool WebAccessibilityObject::canSetValueAttribute() const
+{
+ if (!m_private)
+ return false;
+
+ m_private->updateBackingStore();
+ return m_private->canSetValueAttribute();
+}
+
+bool WebAccessibilityObject::isValid() const
+{
+ if (!m_private)
+ return false;
+
+ m_private->updateBackingStore();
+ return m_private->axObjectID();
+}
+
+unsigned WebAccessibilityObject::childCount() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->children().size();
+}
+
+WebAccessibilityObject WebAccessibilityObject::childAt(unsigned index) const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ if (m_private->children().size() <= index)
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(m_private->children()[index]);
+}
+
+WebAccessibilityObject WebAccessibilityObject::firstChild() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->firstChild());
+}
+
+WebAccessibilityObject WebAccessibilityObject::focusedChild() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ RefPtr<AccessibilityObject> focused = m_private->focusedUIElement();
+ if (m_private == focused.get() || focused->parentObject() == m_private)
+ return WebAccessibilityObject(focused);
+
+ return WebAccessibilityObject();
+}
+
+WebAccessibilityObject WebAccessibilityObject::lastChild() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->lastChild());
+}
+
+
+WebAccessibilityObject WebAccessibilityObject::nextSibling() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->nextSibling());
+}
+
+WebAccessibilityObject WebAccessibilityObject::parentObject() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->parentObject());
+}
+
+
+WebAccessibilityObject WebAccessibilityObject::previousSibling() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->previousSibling());
+}
+
+bool WebAccessibilityObject::canSetSelectedAttribute() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->canSetSelectedAttribute();
+}
+
+bool WebAccessibilityObject::isAnchor() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isAnchor();
+}
+
+bool WebAccessibilityObject::isChecked() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isChecked();
+}
+
+bool WebAccessibilityObject::isCollapsed() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isCollapsed();
+}
+
+
+bool WebAccessibilityObject::isFocused() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isFocused();
+}
+
+bool WebAccessibilityObject::isEnabled() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isEnabled();
+}
+
+bool WebAccessibilityObject::isHovered() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isHovered();
+}
+
+bool WebAccessibilityObject::isIndeterminate() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isIndeterminate();
+}
+
+bool WebAccessibilityObject::isLinked() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isLinked();
+}
+
+bool WebAccessibilityObject::isMultiSelectable() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isMultiSelectable();
+}
+
+bool WebAccessibilityObject::isOffScreen() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isOffScreen();
+}
+
+bool WebAccessibilityObject::isPasswordField() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isPasswordField();
+}
+
+bool WebAccessibilityObject::isPressed() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isPressed();
+}
+
+bool WebAccessibilityObject::isReadOnly() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isReadOnly();
+}
+
+bool WebAccessibilityObject::isSelected() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isSelected();
+}
+
+bool WebAccessibilityObject::isVisible() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isVisible();
+}
+
+bool WebAccessibilityObject::isVisited() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isVisited();
+}
+
+WebRect WebAccessibilityObject::boundingBoxRect() const
+{
+ if (!m_private)
+ return WebRect();
+
+ m_private->updateBackingStore();
+ return m_private->boundingBoxRect();
+}
+
+WebString WebAccessibilityObject::helpText() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->helpText();
+}
+
+int WebAccessibilityObject::headingLevel() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->headingLevel();
+}
+
+WebAccessibilityObject WebAccessibilityObject::hitTest(const WebPoint& point) const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ IntPoint contentsPoint = m_private->documentFrameView()->windowToContents(point);
+ RefPtr<AccessibilityObject> hit = m_private->accessibilityHitTest(contentsPoint);
+
+ if (hit.get())
+ return WebAccessibilityObject(hit);
+
+ if (m_private->boundingBoxRect().contains(contentsPoint))
+ return *this;
+
+ return WebAccessibilityObject();
+}
+
+WebString WebAccessibilityObject::keyboardShortcut() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ String accessKey = m_private->accessKey();
+ if (accessKey.isNull())
+ return WebString();
+
+ static String modifierString;
+ if (modifierString.isNull()) {
+ unsigned modifiers = EventHandler::accessKeyModifiers();
+ // Follow the same order as Mozilla MSAA implementation:
+ // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings
+ // should not be localized and defines the separator as "+".
+ if (modifiers & PlatformKeyboardEvent::CtrlKey)
+ modifierString += "Ctrl+";
+ if (modifiers & PlatformKeyboardEvent::AltKey)
+ modifierString += "Alt+";
+ if (modifiers & PlatformKeyboardEvent::ShiftKey)
+ modifierString += "Shift+";
+ if (modifiers & PlatformKeyboardEvent::MetaKey)
+ modifierString += "Win+";
+ }
+
+ return modifierString + accessKey;
+}
+
+bool WebAccessibilityObject::performDefaultAction() const
+{
+ if (!m_private)
+ return false;
+
+ m_private->updateBackingStore();
+ return m_private->performDefaultAction();
+}
+
+WebAccessibilityRole WebAccessibilityObject::roleValue() const
+{
+ if (!m_private)
+ return WebKit::WebAccessibilityRoleUnknown;
+
+ m_private->updateBackingStore();
+ return static_cast<WebAccessibilityRole>(m_private->roleValue());
+}
+
+void WebAccessibilityObject::setFocused(bool on) const
+{
+ if (m_private)
+ m_private->setFocused(on);
+}
+
+WebString WebAccessibilityObject::stringValue() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->stringValue();
+}
+
+WebString WebAccessibilityObject::title() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->title();
+}
+
+WebURL WebAccessibilityObject::url() const
+{
+ if (!m_private)
+ return WebURL();
+
+ m_private->updateBackingStore();
+ return m_private->url();
+}
+
+WebNode WebAccessibilityObject::node() const
+{
+ if (!m_private)
+ return WebNode();
+
+ m_private->updateBackingStore();
+
+ Node* node = m_private->node();
+ if (!node)
+ return WebNode();
+
+ return WebNode(node);
+}
+
+WebDocument WebAccessibilityObject::document() const
+{
+ if (!m_private)
+ return WebDocument();
+
+ m_private->updateBackingStore();
+
+ Document* document = m_private->document();
+ if (!document)
+ return WebDocument();
+
+ return WebDocument(document);
+}
+
+bool WebAccessibilityObject::hasComputedStyle() const
+{
+ Document* document = m_private->document();
+ if (document)
+ document->updateStyleIfNeeded();
+
+ Node* node = m_private->node();
+ if (!node)
+ return false;
+
+ return node->computedStyle();
+}
+
+WebString WebAccessibilityObject::computedStyleDisplay() const
+{
+ Document* document = m_private->document();
+ if (document)
+ document->updateStyleIfNeeded();
+
+ Node* node = m_private->node();
+ if (!node)
+ return WebString();
+
+ RenderStyle* renderStyle = node->computedStyle();
+ if (!renderStyle)
+ return WebString();
+
+ return WebString(CSSPrimitiveValue::create(renderStyle->display())->getStringValue());
+}
+
+WebAccessibilityObject::WebAccessibilityObject(const WTF::PassRefPtr<WebCore::AccessibilityObject>& object)
+ : m_private(static_cast<WebAccessibilityObjectPrivate*>(object.releaseRef()))
+{
+}
+
+WebAccessibilityObject& WebAccessibilityObject::operator=(const WTF::PassRefPtr<WebCore::AccessibilityObject>& object)
+{
+ assign(static_cast<WebAccessibilityObjectPrivate*>(object.releaseRef()));
+ return *this;
+}
+
+WebAccessibilityObject::operator WTF::PassRefPtr<WebCore::AccessibilityObject>() const
+{
+ return PassRefPtr<WebCore::AccessibilityObject>(const_cast<WebAccessibilityObjectPrivate*>(m_private));
+}
+
+void WebAccessibilityObject::assign(WebAccessibilityObjectPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebAnimationControllerImpl.cpp b/Source/WebKit/chromium/src/WebAnimationControllerImpl.cpp
new file mode 100644
index 0000000..e6eb828
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAnimationControllerImpl.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAnimationControllerImpl.h"
+
+#include "AnimationController.h"
+#include "Element.h"
+
+#include "WebElement.h"
+#include "WebFrameImpl.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebAnimationControllerImpl::WebAnimationControllerImpl(WebFrameImpl* frameImpl)
+ : m_frameImpl(frameImpl)
+{
+ ASSERT(m_frameImpl);
+}
+
+AnimationController* WebAnimationControllerImpl::animationController() const
+{
+ if (!m_frameImpl->frame())
+ return 0;
+ return m_frameImpl->frame()->animation();
+}
+
+bool WebAnimationControllerImpl::pauseAnimationAtTime(WebElement& element,
+ const WebString& animationName,
+ double time)
+{
+ AnimationController* controller = animationController();
+ if (!controller)
+ return 0;
+ return controller->pauseAnimationAtTime(PassRefPtr<Element>(element)->renderer(),
+ animationName,
+ time);
+}
+
+bool WebAnimationControllerImpl::pauseTransitionAtTime(WebElement& element,
+ const WebString& propertyName,
+ double time)
+{
+ AnimationController* controller = animationController();
+ if (!controller)
+ return 0;
+ return controller->pauseTransitionAtTime(PassRefPtr<Element>(element)->renderer(),
+ propertyName,
+ time);
+}
+
+unsigned WebAnimationControllerImpl::numberOfActiveAnimations() const
+{
+ AnimationController* controller = animationController();
+ if (!controller)
+ return 0;
+ return controller->numberOfActiveAnimations();
+}
+
+void WebAnimationControllerImpl::suspendAnimations() const
+{
+ AnimationController* controller = animationController();
+ if (!controller)
+ return;
+ if (!m_frameImpl->frame())
+ return;
+ controller->suspendAnimations();
+}
+
+void WebAnimationControllerImpl::resumeAnimations() const
+{
+ AnimationController* controller = animationController();
+ if (!controller)
+ return;
+ if (!m_frameImpl->frame())
+ return;
+ controller->resumeAnimations();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebAnimationControllerImpl.h b/Source/WebKit/chromium/src/WebAnimationControllerImpl.h
new file mode 100644
index 0000000..62b89f0
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAnimationControllerImpl.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebAnimationControllerImpl_h
+#define WebAnimationControllerImpl_h
+
+#include "WebAnimationController.h"
+
+namespace WebCore {
+class AnimationController;
+}
+
+namespace WebKit {
+class WebFrameImpl;
+
+class WebAnimationControllerImpl : public WebAnimationController {
+public:
+ explicit WebAnimationControllerImpl(WebFrameImpl*);
+ virtual ~WebAnimationControllerImpl() { }
+
+ virtual bool pauseAnimationAtTime(WebElement&,
+ const WebString& animationName,
+ double time);
+ virtual bool pauseTransitionAtTime(WebElement&,
+ const WebString& propertyName,
+ double time);
+ virtual unsigned numberOfActiveAnimations() const;
+ virtual void suspendAnimations() const;
+ virtual void resumeAnimations() const;
+private:
+ WebFrameImpl* m_frameImpl;
+ WebCore::AnimationController* animationController() const;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebAttribute.cpp b/Source/WebKit/chromium/src/WebAttribute.cpp
new file mode 100644
index 0000000..0bc3b91
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAttribute.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAttribute.h"
+
+#include "Attribute.h"
+#include <wtf/PassRefPtr.h>
+
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebAttribute::reset()
+{
+ m_private.reset();
+}
+
+void WebAttribute::assign(const WebAttribute& other)
+{
+ m_private = other.m_private;
+}
+
+WebAttribute::WebAttribute(const PassRefPtr<Attribute>& other)
+ : m_private(other)
+{
+}
+
+WebString WebAttribute::localName() const
+{
+ return WebString(m_private->localName());
+}
+
+WebString WebAttribute::value() const
+{
+ return WebString(m_private->value());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebAudioBus.cpp b/Source/WebKit/chromium/src/WebAudioBus.cpp
new file mode 100644
index 0000000..9d4590e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebAudioBus.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2010, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 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 "WebAudioBus.h"
+
+#if ENABLE(WEB_AUDIO)
+#include "AudioBus.h"
+#else
+namespace WebCore {
+class AudioBus {
+};
+} // namespace WebCore
+#endif
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebAudioBusPrivate : public AudioBus {
+};
+
+void WebAudioBus::initialize(unsigned numberOfChannels, size_t length, double sampleRate)
+{
+#if ENABLE(WEB_AUDIO)
+ AudioBus* audioBus = new AudioBus(numberOfChannels, length);
+ audioBus->setSampleRate(sampleRate);
+
+ if (m_private)
+ delete m_private;
+ m_private = static_cast<WebAudioBusPrivate*>(audioBus);
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+void WebAudioBus::reset()
+{
+#if ENABLE(WEB_AUDIO)
+ delete m_private;
+ m_private = 0;
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+unsigned WebAudioBus::numberOfChannels() const
+{
+#if ENABLE(WEB_AUDIO)
+ if (!m_private)
+ return 0;
+ return m_private->numberOfChannels();
+#else
+ ASSERT_NOT_REACHED();
+ return 0;
+#endif
+}
+
+size_t WebAudioBus::length() const
+{
+#if ENABLE(WEB_AUDIO)
+ if (!m_private)
+ return 0;
+ return m_private->length();
+#else
+ ASSERT_NOT_REACHED();
+ return 0;
+#endif
+}
+
+double WebAudioBus::sampleRate() const
+{
+#if ENABLE(WEB_AUDIO)
+ if (!m_private)
+ return 0;
+ return m_private->sampleRate();
+#else
+ ASSERT_NOT_REACHED();
+ return 0;
+#endif
+}
+
+float* WebAudioBus::channelData(unsigned channelIndex)
+{
+#if ENABLE(WEB_AUDIO)
+ if (!m_private)
+ return 0;
+ ASSERT(channelIndex < numberOfChannels());
+ return m_private->channel(channelIndex)->data();
+#else
+ ASSERT_NOT_REACHED();
+ return 0;
+#endif
+}
+
+PassOwnPtr<AudioBus> WebAudioBus::release()
+{
+#if ENABLE(WEB_AUDIO)
+ OwnPtr<AudioBus> audioBus(adoptPtr(static_cast<AudioBus*>(m_private)));
+ m_private = 0;
+ return audioBus.release();
+#else
+ ASSERT_NOT_REACHED();
+ return 0;
+#endif
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebBindings.cpp b/Source/WebKit/chromium/src/WebBindings.cpp
new file mode 100644
index 0000000..0882e38
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebBindings.cpp
@@ -0,0 +1,405 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebBindings.h"
+
+#include "npruntime_impl.h"
+#include "npruntime_priv.h"
+
+#if USE(V8)
+#include "ChromiumDataObject.h"
+#include "ClipboardChromium.h"
+#include "EventNames.h"
+#include "MouseEvent.h"
+#include "NPV8Object.h" // for PrivateIdentifier
+#include "Range.h"
+#include "V8BindingState.h"
+#include "V8DOMWrapper.h"
+#include "V8Element.h"
+#include "V8Event.h"
+#include "V8Helpers.h"
+#include "V8HiddenPropertyName.h"
+#include "V8NPUtils.h"
+#include "V8Proxy.h"
+#include "V8Range.h"
+#elif USE(JSC)
+#include "bridge/c/c_utility.h"
+#endif
+#include "WebDragData.h"
+#include "WebElement.h"
+#include "WebRange.h"
+
+#if USE(JAVASCRIPTCORE_BINDINGS)
+using JSC::Bindings::PrivateIdentifier;
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebBindings::construct(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant* result)
+{
+ return _NPN_Construct(npp, npobj, args, argCount, result);
+}
+
+NPObject* WebBindings::createObject(NPP npp, NPClass* npClass)
+{
+ return _NPN_CreateObject(npp, npClass);
+}
+
+bool WebBindings::enumerate(NPP id, NPObject* obj, NPIdentifier** identifier, uint32_t* val)
+{
+ return _NPN_Enumerate(id, obj, identifier, val);
+}
+
+bool WebBindings::evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result)
+{
+ return _NPN_Evaluate(npp, npObject, npScript, result);
+}
+
+bool WebBindings::evaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj, NPString* npscript, NPVariant* result)
+{
+ return _NPN_EvaluateHelper(npp, popups_allowed, npobj, npscript, result);
+}
+
+NPIdentifier WebBindings::getIntIdentifier(int32_t number)
+{
+ return _NPN_GetIntIdentifier(number);
+}
+
+bool WebBindings::getProperty(NPP npp, NPObject* obj, NPIdentifier propertyName, NPVariant *result)
+{
+ return _NPN_GetProperty(npp, obj, propertyName, result);
+}
+
+NPIdentifier WebBindings::getStringIdentifier(const NPUTF8* string)
+{
+ return _NPN_GetStringIdentifier(string);
+}
+
+void WebBindings::getStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers)
+{
+ _NPN_GetStringIdentifiers(names, nameCount, identifiers);
+}
+
+bool WebBindings::hasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName)
+{
+ return _NPN_HasMethod(npp, npObject, methodName);
+}
+
+bool WebBindings::hasProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName)
+{
+ return _NPN_HasProperty(npp, npObject, propertyName);
+}
+
+bool WebBindings::identifierIsString(NPIdentifier identifier)
+{
+ return _NPN_IdentifierIsString(identifier);
+}
+
+int32_t WebBindings::intFromIdentifier(NPIdentifier identifier)
+{
+ return _NPN_IntFromIdentifier(identifier);
+}
+
+void WebBindings::initializeVariantWithStringCopy(NPVariant* variant, const NPString* value)
+{
+#if USE(V8)
+ _NPN_InitializeVariantWithStringCopy(variant, value);
+#else
+ NPN_InitializeVariantWithStringCopy(variant, value);
+#endif
+}
+
+bool WebBindings::invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
+{
+ return _NPN_Invoke(npp, npObject, methodName, arguments, argumentCount, result);
+}
+
+bool WebBindings::invokeDefault(NPP id, NPObject* obj, const NPVariant* args, uint32_t count, NPVariant* result)
+{
+ return _NPN_InvokeDefault(id, obj, args, count, result);
+}
+
+void WebBindings::releaseObject(NPObject* npObject)
+{
+ return _NPN_ReleaseObject(npObject);
+}
+
+void WebBindings::releaseVariantValue(NPVariant* variant)
+{
+ _NPN_ReleaseVariantValue(variant);
+}
+
+bool WebBindings::removeProperty(NPP id, NPObject* object, NPIdentifier identifier)
+{
+ return _NPN_RemoveProperty(id, object, identifier);
+}
+
+NPObject* WebBindings::retainObject(NPObject* npObject)
+{
+ return _NPN_RetainObject(npObject);
+}
+
+void WebBindings::setException(NPObject* obj, const NPUTF8* message)
+{
+ _NPN_SetException(obj, message);
+}
+
+bool WebBindings::setProperty(NPP id, NPObject* obj, NPIdentifier identifier, const NPVariant* variant)
+{
+ return _NPN_SetProperty(id, obj, identifier, variant);
+}
+
+void WebBindings::unregisterObject(NPObject* npObject)
+{
+#if USE(V8)
+ _NPN_UnregisterObject(npObject);
+#endif
+}
+
+NPUTF8* WebBindings::utf8FromIdentifier(NPIdentifier identifier)
+{
+ return _NPN_UTF8FromIdentifier(identifier);
+}
+
+void WebBindings::extractIdentifierData(const NPIdentifier& identifier, const NPUTF8*& string, int32_t& number, bool& isString)
+{
+ PrivateIdentifier* priv = static_cast<PrivateIdentifier*>(identifier);
+ if (!priv) {
+ isString = false;
+ number = 0;
+ return;
+ }
+
+ isString = priv->isString;
+ if (isString)
+ string = priv->value.string;
+ else
+ number = priv->value.number;
+}
+
+#if USE(V8)
+
+static v8::Local<v8::Value> getEvent(const v8::Handle<v8::Context>& context)
+{
+ return context->Global()->GetHiddenValue(V8HiddenPropertyName::event());
+}
+
+static bool getDragDataImpl(NPObject* npobj, int* eventId, WebDragData* data)
+{
+ if (!npobj)
+ return false;
+ if (npobj->_class != npScriptObjectClass)
+ return false;
+
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> context = v8::Context::GetEntered();
+ if (context.IsEmpty())
+ return false;
+
+ // Get the current WebCore event.
+ v8::Handle<v8::Value> currentEvent(getEvent(context));
+ Event* event = V8Event::toNative(v8::Handle<v8::Object>::Cast(currentEvent));
+ if (!event)
+ return false;
+
+ // Check that the given npobj is that event.
+ V8NPObject* object = reinterpret_cast<V8NPObject*>(npobj);
+ Event* given = V8Event::toNative(object->v8Object);
+ if (given != event)
+ return false;
+
+ // Check the execution frames are same origin.
+ V8Proxy* current = V8Proxy::retrieve(V8Proxy::retrieveFrameForCurrentContext());
+ Frame* frame = V8Proxy::retrieveFrame(context);
+ if (!current || !V8BindingSecurity::canAccessFrame(V8BindingState::Only(), frame, false))
+ return false;
+
+ const EventNames& names(eventNames());
+ const AtomicString& eventType(event->type());
+
+ enum DragTargetMouseEventId {
+ DragEnterId = 1, DragOverId = 2, DragLeaveId = 3, DropId = 4
+ };
+
+ // The event type should be a drag event.
+ if (eventType == names.dragenterEvent)
+ *eventId = DragEnterId;
+ else if (eventType == names.dragoverEvent)
+ *eventId = DragOverId;
+ else if (eventType == names.dragleaveEvent)
+ *eventId = DragLeaveId;
+ else if (eventType == names.dropEvent)
+ *eventId = DropId;
+ else
+ return false;
+
+ // Drag events are mouse events and should have a clipboard.
+ MouseEvent* me = static_cast<MouseEvent*>(event);
+ Clipboard* clipboard = me->clipboard();
+ if (!clipboard)
+ return false;
+
+ // And that clipboard should be accessible by WebKit policy.
+ ClipboardChromium* chrome = static_cast<ClipboardChromium*>(clipboard);
+ HashSet<String> accessible(chrome->types());
+ if (accessible.isEmpty())
+ return false;
+
+ RefPtr<ChromiumDataObject> dataObject(chrome->dataObject());
+ if (dataObject && data)
+ *data = WebDragData(dataObject);
+
+ return dataObject;
+}
+
+static bool getRangeImpl(NPObject* npobj, WebRange* range)
+{
+ V8NPObject* v8npobject = reinterpret_cast<V8NPObject*>(npobj);
+ v8::Handle<v8::Object> v8object(v8npobject->v8Object);
+ if (!V8Range::info.equals(V8DOMWrapper::domWrapperType(v8object)))
+ return false;
+
+ Range* native = V8Range::toNative(v8object);
+ if (!native)
+ return false;
+
+ *range = WebRange(native);
+ return true;
+}
+
+static bool getElementImpl(NPObject* npObj, WebElement* webElement)
+{
+ if (!npObj || (npObj->_class != npScriptObjectClass))
+ return false;
+
+ V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(npObj);
+ v8::Handle<v8::Object> v8Object(v8NPObject->v8Object);
+ Element* native = V8Element::toNative(v8Object);
+ if (!native)
+ return false;
+
+ *webElement = WebElement(native);
+ return true;
+}
+
+static NPObject* makeIntArrayImpl(const WebVector<int>& data)
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Array> result = v8::Array::New(data.size());
+ for (size_t i = 0; i < data.size(); i++)
+ result->Set(i, v8::Number::New(data[i]));
+
+ WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow(WebCore::V8Proxy::currentContext());
+ return npCreateV8ScriptObject(0, result, window);
+}
+
+static NPObject* makeStringArrayImpl(const WebVector<WebString>& data)
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Array> result = v8::Array::New(data.size());
+ for (size_t i = 0; i < data.size(); ++i)
+ result->Set(i, data[i].data() ? v8::String::New(reinterpret_cast<const uint16_t*>((data[i].data())), data[i].length()) : v8::String::New(""));
+
+ WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow(WebCore::V8Proxy::currentContext());
+ return npCreateV8ScriptObject(0, result, window);
+}
+
+#endif
+
+bool WebBindings::getDragData(NPObject* event, int* eventId, WebDragData* data)
+{
+#if USE(V8)
+ return getDragDataImpl(event, eventId, data);
+#else
+ // Not supported on other ports (JSC, etc).
+ return false;
+#endif
+}
+
+bool WebBindings::isDragEvent(NPObject* event)
+{
+ int eventId;
+ return getDragData(event, &eventId, 0);
+}
+
+bool WebBindings::getRange(NPObject* range, WebRange* webrange)
+{
+#if USE(V8)
+ return getRangeImpl(range, webrange);
+#else
+ // Not supported on other ports (JSC, etc).
+ return false;
+#endif
+}
+
+bool WebBindings::getElement(NPObject* element, WebElement* webElement)
+{
+#if USE(V8)
+ return getElementImpl(element, webElement);
+#else
+ // Not supported on other ports (JSC, etc.).
+ return false;
+#endif
+}
+
+NPObject* WebBindings::makeIntArray(const WebVector<int> & data)
+{
+#if USE(V8)
+ return makeIntArrayImpl(data);
+#else
+ // Not supported on other ports (JSC, etc.).
+ return 0;
+#endif
+}
+
+NPObject* WebBindings::makeStringArray(const WebVector<WebString>& data)
+{
+#if USE(V8)
+ return makeStringArrayImpl(data);
+#else
+ // Not supported on other ports (JSC, etc.).
+ return 0;
+#endif
+}
+
+void WebBindings::pushExceptionHandler(ExceptionHandler handler, void* data)
+{
+ WebCore::pushExceptionHandler(handler, data);
+}
+
+void WebBindings::popExceptionHandler()
+{
+ WebCore::popExceptionHandler();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebBlobData.cpp b/Source/WebKit/chromium/src/WebBlobData.cpp
new file mode 100644
index 0000000..42018dd
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebBlobData.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebBlobData.h"
+
+#include "BlobData.h"
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebBlobDataPrivate : public BlobData {
+};
+
+void WebBlobData::initialize()
+{
+ assign(BlobData::create());
+}
+
+void WebBlobData::reset()
+{
+ assign(0);
+}
+
+size_t WebBlobData::itemCount() const
+{
+ ASSERT(!isNull());
+ return m_private->items().size();
+}
+
+bool WebBlobData::itemAt(size_t index, Item& result) const
+{
+ ASSERT(!isNull());
+
+ if (index >= m_private->items().size())
+ return false;
+
+ const BlobDataItem& item = m_private->items()[index];
+ result.data.reset();
+ result.filePath.reset();
+ result.blobURL = KURL();
+ result.offset = item.offset;
+ result.length = item.length;
+ result.expectedModificationTime = item.expectedModificationTime;
+
+ switch (item.type) {
+ case BlobDataItem::Data:
+ result.type = Item::TypeData;
+ result.data = item.data;
+ return true;
+ case BlobDataItem::File:
+ result.type = Item::TypeFile;
+ result.filePath = item.path;
+ return true;
+ case BlobDataItem::Blob:
+ result.type = Item::TypeBlob;
+ result.blobURL = item.url;
+ return true;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+WebString WebBlobData::contentType() const
+{
+ ASSERT(!isNull());
+ return m_private->contentType();
+}
+
+WebString WebBlobData::contentDisposition() const
+{
+ ASSERT(!isNull());
+ return m_private->contentDisposition();
+}
+
+WebBlobData::WebBlobData(const PassOwnPtr<BlobData>& data)
+ : m_private(0)
+{
+ assign(data);
+}
+
+WebBlobData& WebBlobData::operator=(const PassOwnPtr<BlobData>& data)
+{
+ assign(data);
+ return *this;
+}
+
+WebBlobData::operator PassOwnPtr<BlobData>()
+{
+ WebBlobDataPrivate* temp = m_private;
+ m_private = 0;
+ return adoptPtr(temp);
+}
+
+void WebBlobData::assign(const PassOwnPtr<BlobData>& data)
+{
+ if (m_private)
+ delete m_private;
+ m_private = static_cast<WebBlobDataPrivate*>(data.leakPtr());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebCString.cpp b/Source/WebKit/chromium/src/WebCString.cpp
new file mode 100644
index 0000000..f81d7f4
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebCString.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCString.h"
+
+#include "TextEncoding.h"
+#include <wtf/text/CString.h>
+
+#include "WebString.h"
+
+namespace WebKit {
+
+class WebCStringPrivate : public WTF::CStringBuffer {
+};
+
+int WebCString::compare(const WebCString& other) const
+{
+ // A null string is always less than a non null one.
+ if (isNull() != other.isNull())
+ return isNull() ? -1 : 1;
+
+ if (isNull())
+ return 0; // Both WebStrings are null.
+
+ return strcmp(m_private->data(), other.m_private->data());
+}
+
+void WebCString::reset()
+{
+ if (m_private) {
+ m_private->deref();
+ m_private = 0;
+ }
+}
+
+void WebCString::assign(const WebCString& other)
+{
+ assign(const_cast<WebCStringPrivate*>(other.m_private));
+}
+
+void WebCString::assign(const char* data, size_t length)
+{
+ char* newData;
+ RefPtr<WTF::CStringBuffer> buffer =
+ WTF::CString::newUninitialized(length, newData).buffer();
+ memcpy(newData, data, length);
+ assign(static_cast<WebCStringPrivate*>(buffer.get()));
+}
+
+size_t WebCString::length() const
+{
+ if (!m_private)
+ return 0;
+ // NOTE: The buffer's length includes the null byte.
+ return const_cast<WebCStringPrivate*>(m_private)->length() - 1;
+}
+
+const char* WebCString::data() const
+{
+ if (!m_private)
+ return 0;
+ return const_cast<WebCStringPrivate*>(m_private)->data();
+}
+
+WebString WebCString::utf16() const
+{
+ return WebCore::UTF8Encoding().decode(data(), length());
+}
+
+WebCString WebCString::fromUTF16(const WebUChar* data, size_t length)
+{
+ return WebCore::UTF8Encoding().encode(
+ data, length, WebCore::QuestionMarksForUnencodables);
+}
+
+WebCString WebCString::fromUTF16(const WebUChar* data)
+{
+ size_t len = 0;
+ while (data[len] != WebUChar(0))
+ len++;
+ return fromUTF16(data, len);
+}
+
+WebCString::WebCString(const WTF::CString& s)
+ : m_private(static_cast<WebCStringPrivate*>(s.buffer()))
+{
+ if (m_private)
+ m_private->ref();
+}
+
+WebCString& WebCString::operator=(const WTF::CString& s)
+{
+ assign(static_cast<WebCStringPrivate*>(s.buffer()));
+ return *this;
+}
+
+WebCString::operator WTF::CString() const
+{
+ return m_private;
+}
+
+void WebCString::assign(WebCStringPrivate* p)
+{
+ // Take care to handle the case where m_private == p
+ if (p)
+ p->ref();
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebCache.cpp b/Source/WebKit/chromium/src/WebCache.cpp
new file mode 100644
index 0000000..7df4c66
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebCache.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCache.h"
+
+// Instead of providing accessors, we make all members of MemoryCache public.
+// This will make it easier to track WebCore changes to the MemoryCache class.
+// FIXME: We should introduce public getters on the MemoryCache class.
+#define private public
+#include "MemoryCache.h"
+#undef private
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// A helper method for coverting a MemoryCache::TypeStatistic to a
+// WebCache::ResourceTypeStat.
+static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from,
+ WebCache::ResourceTypeStat& to)
+{
+ to.count = static_cast<size_t>(from.count);
+ to.size = static_cast<size_t>(from.size);
+ to.liveSize = static_cast<size_t>(from.liveSize);
+ to.decodedSize = static_cast<size_t>(from.decodedSize);
+}
+
+void WebCache::setCapacities(
+ size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity)
+{
+ MemoryCache* cache = WebCore::memoryCache();
+ if (cache)
+ cache->setCapacities(static_cast<unsigned int>(minDeadCapacity),
+ static_cast<unsigned int>(maxDeadCapacity),
+ static_cast<unsigned int>(capacity));
+}
+
+void WebCache::clear()
+{
+ MemoryCache* cache = WebCore::memoryCache();
+ if (cache && !cache->disabled()) {
+ cache->setDisabled(true);
+ cache->setDisabled(false);
+ }
+}
+
+void WebCache::getUsageStats(UsageStats* result)
+{
+ ASSERT(result);
+
+ MemoryCache* cache = WebCore::memoryCache();
+ if (cache) {
+ result->minDeadCapacity = cache->m_minDeadCapacity;
+ result->maxDeadCapacity = cache->m_maxDeadCapacity;
+ result->capacity = cache->m_capacity;
+ result->liveSize = cache->m_liveSize;
+ result->deadSize = cache->m_deadSize;
+ } else
+ memset(result, 0, sizeof(UsageStats));
+}
+
+void WebCache::getResourceTypeStats(ResourceTypeStats* result)
+{
+ MemoryCache* cache = WebCore::memoryCache();
+ if (cache) {
+ MemoryCache::Statistics stats = cache->getStatistics();
+ ToResourceTypeStat(stats.images, result->images);
+ ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets);
+ ToResourceTypeStat(stats.scripts, result->scripts);
+#if ENABLE(XSLT)
+ ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets);
+#else
+ memset(&result->xslStyleSheets, 0, sizeof(result->xslStyleSheets));
+#endif
+ ToResourceTypeStat(stats.fonts, result->fonts);
+ } else
+ memset(result, 0, sizeof(WebCache::ResourceTypeStats));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebColor.cpp b/Source/WebKit/chromium/src/WebColor.cpp
new file mode 100644
index 0000000..9323433
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebColor.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebColor.h"
+
+#include "Color.h"
+#include "CSSValueKeywords.h"
+#include "RenderTheme.h"
+#include "UnusedParam.h"
+#include "WebColorName.h"
+
+using namespace::WebCore;
+
+namespace WebKit {
+
+static int toCSSValueKeyword(WebColorName in_value)
+{
+ switch (in_value) {
+ case WebColorActiveBorder:
+ return CSSValueActiveborder;
+ case WebColorActiveCaption:
+ return CSSValueActivecaption;
+ case WebColorAppworkspace:
+ return CSSValueAppworkspace;
+ case WebColorBackground:
+ return CSSValueBackground;
+ case WebColorButtonFace:
+ return CSSValueButtonface;
+ case WebColorButtonHighlight:
+ return CSSValueButtonhighlight;
+ case WebColorButtonShadow:
+ return CSSValueButtonshadow;
+ case WebColorButtonText:
+ return CSSValueButtontext;
+ case WebColorCaptionText:
+ return CSSValueCaptiontext;
+ case WebColorGrayText:
+ return CSSValueGraytext;
+ case WebColorHighlight:
+ return CSSValueHighlight;
+ case WebColorHighlightText:
+ return CSSValueHighlighttext;
+ case WebColorInactiveBorder:
+ return CSSValueInactiveborder;
+ case WebColorInactiveCaption:
+ return CSSValueInactivecaption;
+ case WebColorInactiveCaptionText:
+ return CSSValueInactivecaptiontext;
+ case WebColorInfoBackground:
+ return CSSValueInfobackground;
+ case WebColorInfoText:
+ return CSSValueInfotext;
+ case WebColorMenu:
+ return CSSValueMenu;
+ case WebColorMenuText:
+ return CSSValueMenutext;
+ case WebColorScrollbar:
+ return CSSValueScrollbar;
+ case WebColorText:
+ return CSSValueText;
+ case WebColorThreedDarkShadow:
+ return CSSValueThreeddarkshadow;
+ case WebColorThreedShadow:
+ return CSSValueThreedshadow;
+ case WebColorThreedFace:
+ return CSSValueThreedface;
+ case WebColorThreedHighlight:
+ return CSSValueThreedhighlight;
+ case WebColorThreedLightShadow:
+ return CSSValueThreedlightshadow;
+ case WebColorWebkitFocusRingColor:
+ return CSSValueWebkitFocusRingColor;
+ case WebColorWindow:
+ return CSSValueWindow;
+ case WebColorWindowFrame:
+ return CSSValueWindowframe;
+ case WebColorWindowText:
+ return CSSValueWindowtext;
+ default:
+ return CSSValueInvalid;
+ }
+}
+
+void setNamedColors(const WebColorName* colorNames, const WebColor* colors, size_t length)
+{
+ for (size_t i = 0; i < length; ++i) {
+ WebColorName colorName = colorNames[i];
+ WebColor color = colors[i];
+
+ // Convert color to internal value identifier.
+ int internalColorName = toCSSValueKeyword(colorName);
+ if (internalColorName == CSSValueWebkitFocusRingColor) {
+ RenderTheme::setCustomFocusRingColor(color);
+ continue;
+ }
+ }
+
+ // TODO(jeremy): Tell RenderTheme to update colors.
+}
+
+} // WebKit
diff --git a/Source/WebKit/chromium/src/WebCommon.cpp b/Source/WebKit/chromium/src/WebCommon.cpp
new file mode 100644
index 0000000..f9457fb
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebCommon.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCommon.h"
+
+#include <wtf/Assertions.h>
+
+namespace WebKit {
+
+void failedAssertion(const char* file, int line, const char* function, const char* assertion)
+{
+ WTFReportAssertionFailure(file, line, function, assertion);
+ CRASH();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp b/Source/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp
new file mode 100644
index 0000000..719316d
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebCrossOriginPreflightResultCache.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCrossOriginPreflightResultCache.h"
+
+#include "CrossOriginPreflightResultCache.h"
+
+namespace WebKit {
+
+void WebCrossOriginPreflightResultCache::clear()
+{
+ WebCore::CrossOriginPreflightResultCache::shared().empty();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebCursorInfo.cpp b/Source/WebKit/chromium/src/WebCursorInfo.cpp
new file mode 100644
index 0000000..d4b0f81
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebCursorInfo.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCursorInfo.h"
+
+#include "Cursor.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebCursorInfo::WebCursorInfo(const Cursor& cursor)
+{
+ type = static_cast<Type>(cursor.impl().type());
+ hotSpot = cursor.impl().hotSpot();
+ customImage = cursor.impl().customImage();
+#ifdef WIN32
+ externalHandle = 0;
+#endif
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDOMEvent.cpp b/Source/WebKit/chromium/src/WebDOMEvent.cpp
new file mode 100644
index 0000000..48e5268
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMEvent.cpp
@@ -0,0 +1,219 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMEvent.h"
+
+#include "Event.h"
+#include "Node.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class WebDOMEventPrivate : public WebCore::Event {
+};
+
+void WebDOMEvent::reset()
+{
+ assign(0);
+}
+
+void WebDOMEvent::assign(const WebDOMEvent& other)
+{
+ WebDOMEventPrivate* p = const_cast<WebDOMEventPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+void WebDOMEvent::assign(WebDOMEventPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+WebDOMEvent::WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>& event)
+ : m_private(static_cast<WebDOMEventPrivate*>(event.releaseRef()))
+{
+}
+
+WebString WebDOMEvent::type() const
+{
+ ASSERT(m_private);
+ return m_private->type();
+}
+
+WebNode WebDOMEvent::target() const
+{
+ ASSERT(m_private);
+ return WebNode(m_private->target()->toNode());
+}
+
+WebNode WebDOMEvent::currentTarget() const
+{
+ ASSERT(m_private);
+ return WebNode(m_private->currentTarget()->toNode());
+}
+
+WebDOMEvent::PhaseType WebDOMEvent::eventPhase() const
+{
+ ASSERT(m_private);
+ return static_cast<WebDOMEvent::PhaseType>(m_private->eventPhase());
+}
+
+bool WebDOMEvent::bubbles() const
+{
+ ASSERT(m_private);
+ return m_private->bubbles();
+}
+
+bool WebDOMEvent::cancelable() const
+{
+ ASSERT(m_private);
+ return m_private->cancelable();
+}
+
+bool WebDOMEvent::isUIEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isUIEvent();
+}
+
+bool WebDOMEvent::isMouseEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isMouseEvent();
+}
+
+bool WebDOMEvent::isMutationEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isMutationEvent();
+}
+
+bool WebDOMEvent::isKeyboardEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isKeyboardEvent();
+}
+
+bool WebDOMEvent::isTextEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isTextEvent();
+}
+
+bool WebDOMEvent::isCompositionEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isCompositionEvent();
+}
+
+bool WebDOMEvent::isDragEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isDragEvent();
+}
+
+bool WebDOMEvent::isClipboardEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isClipboardEvent();
+}
+
+bool WebDOMEvent::isMessageEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isMessageEvent();
+}
+
+bool WebDOMEvent::isWheelEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isWheelEvent();
+}
+
+bool WebDOMEvent::isBeforeTextInsertedEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isBeforeTextInsertedEvent();
+}
+
+bool WebDOMEvent::isOverflowEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isOverflowEvent();
+}
+
+bool WebDOMEvent::isPageTransitionEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isPageTransitionEvent();
+}
+
+bool WebDOMEvent::isPopStateEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isPopStateEvent();
+}
+
+bool WebDOMEvent::isProgressEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isProgressEvent();
+}
+
+bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isXMLHttpRequestProgressEvent();
+}
+
+bool WebDOMEvent::isWebKitAnimationEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isWebKitAnimationEvent();
+}
+
+bool WebDOMEvent::isWebKitTransitionEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isWebKitTransitionEvent();
+}
+
+bool WebDOMEvent::isBeforeLoadEvent() const
+{
+ ASSERT(m_private);
+ return m_private->isBeforeLoadEvent();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDOMEventListener.cpp b/Source/WebKit/chromium/src/WebDOMEventListener.cpp
new file mode 100644
index 0000000..93c1640
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMEventListener.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMEventListener.h"
+
+#include "WebDOMEventListenerPrivate.h"
+
+namespace WebKit {
+
+WebDOMEventListener::WebDOMEventListener()
+ : m_private(new WebDOMEventListenerPrivate(this))
+{
+}
+
+WebDOMEventListener::~WebDOMEventListener()
+{
+ m_private->webDOMEventListenerDeleted();
+ delete m_private;
+}
+
+void WebDOMEventListener::notifyEventListenerDeleted(EventListenerWrapper* wrapper)
+{
+ m_private->eventListenerDeleted(wrapper);
+}
+
+EventListenerWrapper* WebDOMEventListener::createEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ return m_private->createEventListenerWrapper(eventType, useCapture, node);
+}
+
+EventListenerWrapper* WebDOMEventListener::getEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ return m_private->getEventListenerWrapper(eventType, useCapture, node);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDOMEventListenerPrivate.cpp b/Source/WebKit/chromium/src/WebDOMEventListenerPrivate.cpp
new file mode 100644
index 0000000..4edbeef
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMEventListenerPrivate.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMEventListenerPrivate.h"
+
+#include "EventListenerWrapper.h"
+#include "WebDOMEventListener.h"
+
+namespace WebKit {
+
+WebDOMEventListenerPrivate::WebDOMEventListenerPrivate(WebDOMEventListener* webDOMEventListener)
+ : m_webDOMEventListener(webDOMEventListener)
+{
+}
+
+WebDOMEventListenerPrivate::~WebDOMEventListenerPrivate()
+{
+}
+
+EventListenerWrapper* WebDOMEventListenerPrivate::createEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ EventListenerWrapper* listenerWrapper = new EventListenerWrapper(m_webDOMEventListener);
+ WebDOMEventListenerPrivate::ListenerInfo listenerInfo(eventType, useCapture, listenerWrapper, node);
+ m_listenerWrappers.append(listenerInfo);
+ return listenerWrapper;
+}
+
+EventListenerWrapper* WebDOMEventListenerPrivate::getEventListenerWrapper(const WebString& eventType, bool useCapture, Node* node)
+{
+ Vector<WebDOMEventListenerPrivate::ListenerInfo>::const_iterator iter;
+ for (iter = m_listenerWrappers.begin(); iter != m_listenerWrappers.end(); ++iter) {
+ if (iter->node == node)
+ return iter->eventListenerWrapper;
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void WebDOMEventListenerPrivate::webDOMEventListenerDeleted()
+{
+ // Notifies all WebDOMEventListenerWrappers that we are going away so they can
+ // invalidate their pointer to us.
+ Vector<WebDOMEventListenerPrivate::ListenerInfo>::const_iterator iter;
+ for (iter = m_listenerWrappers.begin(); iter != m_listenerWrappers.end(); ++iter)
+ iter->eventListenerWrapper->webDOMEventListenerDeleted();
+}
+
+void WebDOMEventListenerPrivate::eventListenerDeleted(EventListenerWrapper* eventListener)
+{
+ for (size_t i = 0; i < m_listenerWrappers.size(); ++i) {
+ if (m_listenerWrappers[i].eventListenerWrapper == eventListener) {
+ m_listenerWrappers.remove(i);
+ return;
+ }
+ }
+ ASSERT_NOT_REACHED();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDOMEventListenerPrivate.h b/Source/WebKit/chromium/src/WebDOMEventListenerPrivate.h
new file mode 100644
index 0000000..c86f427
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMEventListenerPrivate.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDOMEventListenerPrivate_h
+#define WebDOMEventListenerPrivate_h
+
+#include "WebString.h"
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class Node;
+}
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class EventListenerWrapper;
+class WebDOMEventListener;
+
+class WebDOMEventListenerPrivate {
+public:
+ WebDOMEventListenerPrivate(WebDOMEventListener* webDOMEventListener);
+ ~WebDOMEventListenerPrivate();
+
+ EventListenerWrapper* createEventListenerWrapper(
+ const WebString& eventType, bool useCapture, Node* node);
+
+ // Gets the ListenerEventWrapper for a specific node.
+ // Used by WebNode::removeDOMEventListener().
+ EventListenerWrapper* getEventListenerWrapper(
+ const WebString& eventType, bool useCapture, Node* node);
+
+ // Called by the WebDOMEventListener when it is about to be deleted.
+ void webDOMEventListenerDeleted();
+
+ // Called by the EventListenerWrapper when it is about to be deleted.
+ void eventListenerDeleted(EventListenerWrapper* eventListener);
+
+ struct ListenerInfo {
+ ListenerInfo(const WebString& eventType, bool useCapture,
+ EventListenerWrapper* eventListenerWrapper,
+ Node* node)
+ : eventType(eventType)
+ , useCapture(useCapture)
+ , eventListenerWrapper(eventListenerWrapper)
+ , node(node)
+ {
+ }
+
+ WebString eventType;
+ bool useCapture;
+ EventListenerWrapper* eventListenerWrapper;
+ Node* node;
+ };
+
+private:
+ WebDOMEventListener* m_webDOMEventListener;
+
+ // We keep a list of the wrapper for the WebKit EventListener, it is needed
+ // to implement WebNode::removeEventListener().
+ Vector<ListenerInfo> m_listenerWrappers;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebDOMMouseEvent.cpp b/Source/WebKit/chromium/src/WebDOMMouseEvent.cpp
new file mode 100644
index 0000000..bfeae37
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMMouseEvent.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMMouseEvent.h"
+
+#include "MouseEvent.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+int WebDOMMouseEvent::screenX() const
+{
+ return constUnwrap<MouseEvent>()->screenX();
+}
+
+int WebDOMMouseEvent::screenY() const
+{
+ return constUnwrap<MouseEvent>()->screenY();
+}
+
+int WebDOMMouseEvent::clientX() const
+{
+ return constUnwrap<MouseEvent>()->clientX();
+}
+
+int WebDOMMouseEvent::clientY() const
+{
+ return constUnwrap<MouseEvent>()->clientY();
+}
+
+int WebDOMMouseEvent::layerX() const
+{
+ return constUnwrap<MouseEvent>()->layerX();
+}
+
+int WebDOMMouseEvent::layerY() const
+{
+ return constUnwrap<MouseEvent>()->layerY();
+}
+
+int WebDOMMouseEvent::offsetX() const
+{
+ return constUnwrap<MouseEvent>()->offsetX();
+}
+
+int WebDOMMouseEvent::offsetY() const
+{
+ return constUnwrap<MouseEvent>()->offsetY();
+}
+
+int WebDOMMouseEvent::pageX() const
+{
+ return constUnwrap<MouseEvent>()->pageX();
+}
+
+int WebDOMMouseEvent::pageY() const
+{
+ return constUnwrap<MouseEvent>()->pageY();
+}
+
+int WebDOMMouseEvent::x() const
+{
+ return constUnwrap<MouseEvent>()->x();
+}
+
+int WebDOMMouseEvent::y() const
+{
+ return constUnwrap<MouseEvent>()->y();
+}
+
+int WebDOMMouseEvent::button() const
+{
+ return constUnwrap<MouseEvent>()->button();
+}
+
+bool WebDOMMouseEvent::buttonDown() const
+{
+ return constUnwrap<MouseEvent>()->buttonDown();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDOMMutationEvent.cpp b/Source/WebKit/chromium/src/WebDOMMutationEvent.cpp
new file mode 100644
index 0000000..8a6e592
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMMutationEvent.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMMutationEvent.h"
+
+#include "MutationEvent.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebNode WebDOMMutationEvent::relatedNode() const
+{
+ return WebNode(constUnwrap<MutationEvent>()->relatedNode());
+}
+
+WebString WebDOMMutationEvent::prevValue() const
+{
+ return WebString(constUnwrap<MutationEvent>()->prevValue());
+}
+
+WebString WebDOMMutationEvent::newValue() const
+{
+ return WebString(constUnwrap<MutationEvent>()->newValue());
+}
+
+WebString WebDOMMutationEvent::attrName() const
+{
+ return WebString(constUnwrap<MutationEvent>()->attrName());
+}
+
+WebDOMMutationEvent::AttrChangeType WebDOMMutationEvent::attrChange() const
+{
+ return static_cast<AttrChangeType>(constUnwrap<MutationEvent>()->attrChange());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDOMStringList.cpp b/Source/WebKit/chromium/src/WebDOMStringList.cpp
new file mode 100644
index 0000000..dc82331
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDOMStringList.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMStringList.h"
+
+#include "DOMStringList.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebDOMStringList::WebDOMStringList()
+{
+ m_private = WebCore::DOMStringList::create();
+}
+
+void WebDOMStringList::reset()
+{
+ m_private.reset();
+}
+
+void WebDOMStringList::assign(const WebDOMStringList& other)
+{
+ m_private = other.m_private;
+}
+
+void WebDOMStringList::append(const WebString& string)
+{
+ m_private->append(string);
+}
+
+unsigned WebDOMStringList::length() const
+{
+ if (m_private.isNull())
+ return 0;
+ return m_private->length();
+}
+
+WebString WebDOMStringList::item(unsigned index) const
+{
+ return m_private->item(index);
+}
+
+WebDOMStringList::WebDOMStringList(const WTF::PassRefPtr<WebCore::DOMStringList>& item)
+ : m_private(item)
+{
+}
+
+WebDOMStringList& WebDOMStringList::operator=(const WTF::PassRefPtr<WebCore::DOMStringList>& item)
+{
+ m_private = item;
+ return *this;
+}
+
+WebDOMStringList::operator WTF::PassRefPtr<WebCore::DOMStringList>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebData.cpp b/Source/WebKit/chromium/src/WebData.cpp
new file mode 100644
index 0000000..6aafe79
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebData.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebData.h"
+
+#include "SharedBuffer.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebDataPrivate : public SharedBuffer {
+};
+
+void WebData::reset()
+{
+ if (m_private) {
+ m_private->deref();
+ m_private = 0;
+ }
+}
+
+void WebData::assign(const WebData& other)
+{
+ WebDataPrivate* p = const_cast<WebDataPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+void WebData::assign(const char* data, size_t size)
+{
+ assign(static_cast<WebDataPrivate*>(
+ SharedBuffer::create(data, size).releaseRef()));
+}
+
+size_t WebData::size() const
+{
+ if (!m_private)
+ return 0;
+ return const_cast<WebDataPrivate*>(m_private)->size();
+}
+
+const char* WebData::data() const
+{
+ if (!m_private)
+ return 0;
+ return const_cast<WebDataPrivate*>(m_private)->data();
+}
+
+WebData::WebData(const PassRefPtr<SharedBuffer>& buffer)
+ : m_private(static_cast<WebDataPrivate*>(buffer.releaseRef()))
+{
+}
+
+WebData& WebData::operator=(const PassRefPtr<SharedBuffer>& buffer)
+{
+ assign(static_cast<WebDataPrivate*>(buffer.releaseRef()));
+ return *this;
+}
+
+WebData::operator PassRefPtr<SharedBuffer>() const
+{
+ return PassRefPtr<SharedBuffer>(const_cast<WebDataPrivate*>(m_private));
+}
+
+void WebData::assign(WebDataPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDataSourceImpl.cpp b/Source/WebKit/chromium/src/WebDataSourceImpl.cpp
new file mode 100644
index 0000000..65147fa
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDataSourceImpl.cpp
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDataSourceImpl.h"
+
+#include "ApplicationCacheHostInternal.h"
+#include "WebURL.h"
+#include "WebURLError.h"
+#include "WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPluginLoadObserver* WebDataSourceImpl::m_nextPluginLoadObserver = 0;
+
+PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::create(const ResourceRequest& request, const SubstituteData& data)
+{
+ return adoptRef(new WebDataSourceImpl(request, data));
+}
+
+const WebURLRequest& WebDataSourceImpl::originalRequest() const
+{
+ m_originalRequestWrapper.bind(DocumentLoader::originalRequest());
+ return m_originalRequestWrapper;
+}
+
+const WebURLRequest& WebDataSourceImpl::request() const
+{
+ m_requestWrapper.bind(DocumentLoader::request());
+ return m_requestWrapper;
+}
+
+const WebURLResponse& WebDataSourceImpl::response() const
+{
+ m_responseWrapper.bind(DocumentLoader::response());
+ return m_responseWrapper;
+}
+
+bool WebDataSourceImpl::hasUnreachableURL() const
+{
+ return !DocumentLoader::unreachableURL().isEmpty();
+}
+
+WebURL WebDataSourceImpl::unreachableURL() const
+{
+ return DocumentLoader::unreachableURL();
+}
+
+void WebDataSourceImpl::redirectChain(WebVector<WebURL>& result) const
+{
+ result.assign(m_redirectChain);
+}
+
+WebString WebDataSourceImpl::pageTitle() const
+{
+ return title();
+}
+
+WebNavigationType WebDataSourceImpl::navigationType() const
+{
+ return toWebNavigationType(triggeringAction().type());
+}
+
+double WebDataSourceImpl::triggeringEventTime() const
+{
+ if (!triggeringAction().event())
+ return 0.0;
+
+ // DOMTimeStamp uses units of milliseconds.
+ return convertDOMTimeStampToSeconds(triggeringAction().event()->timeStamp());
+}
+
+WebDataSource::ExtraData* WebDataSourceImpl::extraData() const
+{
+ return m_extraData.get();
+}
+
+void WebDataSourceImpl::setExtraData(ExtraData* extraData)
+{
+ m_extraData.set(extraData);
+}
+
+WebApplicationCacheHost* WebDataSourceImpl::applicationCacheHost()
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ return ApplicationCacheHostInternal::toWebApplicationCacheHost(DocumentLoader::applicationCacheHost());
+#else
+ return 0;
+#endif
+}
+
+void WebDataSourceImpl::setDeferMainResourceDataLoad(bool defer)
+{
+ DocumentLoader::setDeferMainResourceDataLoad(defer);
+}
+
+WebNavigationType WebDataSourceImpl::toWebNavigationType(NavigationType type)
+{
+ switch (type) {
+ case NavigationTypeLinkClicked:
+ return WebNavigationTypeLinkClicked;
+ case NavigationTypeFormSubmitted:
+ return WebNavigationTypeFormSubmitted;
+ case NavigationTypeBackForward:
+ return WebNavigationTypeBackForward;
+ case NavigationTypeReload:
+ return WebNavigationTypeReload;
+ case NavigationTypeFormResubmitted:
+ return WebNavigationTypeFormResubmitted;
+ case NavigationTypeOther:
+ default:
+ return WebNavigationTypeOther;
+ }
+}
+
+const KURL& WebDataSourceImpl::endOfRedirectChain() const
+{
+ ASSERT(!m_redirectChain.isEmpty());
+ return m_redirectChain.last();
+}
+
+void WebDataSourceImpl::clearRedirectChain()
+{
+ m_redirectChain.clear();
+}
+
+void WebDataSourceImpl::appendRedirect(const KURL& url)
+{
+ m_redirectChain.append(url);
+}
+
+void WebDataSourceImpl::setNextPluginLoadObserver(PassOwnPtr<WebPluginLoadObserver> observer)
+{
+ // This call should always be followed up with the creation of a
+ // WebDataSourceImpl, so we should never leak this object.
+ m_nextPluginLoadObserver = observer.leakPtr();
+}
+
+WebDataSourceImpl::WebDataSourceImpl(const ResourceRequest& request, const SubstituteData& data)
+ : DocumentLoader(request, data)
+{
+ if (m_nextPluginLoadObserver) {
+ // When a new frame is created, it initially gets a data source for an
+ // empty document. Then it is navigated to the source URL of the
+ // frame, which results in a second data source being created. We want
+ // to wait to attach the WebPluginLoadObserver to that data source.
+ if (!request.url().isEmpty()) {
+ ASSERT(m_nextPluginLoadObserver->url() == request.url());
+ m_pluginLoadObserver.set(m_nextPluginLoadObserver);
+ m_nextPluginLoadObserver = 0;
+ }
+ }
+}
+
+WebDataSourceImpl::~WebDataSourceImpl()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDataSourceImpl.h b/Source/WebKit/chromium/src/WebDataSourceImpl.h
new file mode 100644
index 0000000..05329ff
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDataSourceImpl.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDataSourceImpl_h
+#define WebDataSourceImpl_h
+
+#include "DocumentLoader.h"
+#include "KURL.h"
+#include "WebDataSource.h"
+#include "WebPluginLoadObserver.h"
+#include "WrappedResourceRequest.h"
+#include "WrappedResourceResponse.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class WebPluginLoadObserver;
+
+class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource {
+public:
+ static PassRefPtr<WebDataSourceImpl> create(const WebCore::ResourceRequest&,
+ const WebCore::SubstituteData&);
+
+ static WebDataSourceImpl* fromDocumentLoader(WebCore::DocumentLoader* loader)
+ {
+ return static_cast<WebDataSourceImpl*>(loader);
+ }
+
+ // WebDataSource methods:
+ virtual const WebURLRequest& originalRequest() const;
+ virtual const WebURLRequest& request() const;
+ virtual const WebURLResponse& response() const;
+ virtual bool hasUnreachableURL() const;
+ virtual WebURL unreachableURL() const;
+ virtual void redirectChain(WebVector<WebURL>&) const;
+ virtual WebString pageTitle() const;
+ virtual WebNavigationType navigationType() const;
+ virtual double triggeringEventTime() const;
+ virtual ExtraData* extraData() const;
+ virtual void setExtraData(ExtraData*);
+ virtual WebApplicationCacheHost* applicationCacheHost();
+ virtual void setDeferMainResourceDataLoad(bool);
+
+ static WebNavigationType toWebNavigationType(WebCore::NavigationType type);
+
+ bool hasRedirectChain() const { return !m_redirectChain.isEmpty(); }
+ const WebCore::KURL& endOfRedirectChain() const;
+ void clearRedirectChain();
+ void appendRedirect(const WebCore::KURL& url);
+
+ PassOwnPtr<WebPluginLoadObserver> releasePluginLoadObserver() { return m_pluginLoadObserver.release(); }
+ static void setNextPluginLoadObserver(PassOwnPtr<WebPluginLoadObserver>);
+
+private:
+ WebDataSourceImpl(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
+ ~WebDataSourceImpl();
+
+ // Mutable because the const getters will magically sync these to the
+ // latest version from WebKit.
+ mutable WrappedResourceRequest m_originalRequestWrapper;
+ mutable WrappedResourceRequest m_requestWrapper;
+ mutable WrappedResourceResponse m_responseWrapper;
+
+ // Lists all intermediate URLs that have redirected for the current provisional load.
+ // See WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad for a
+ // description of who modifies this when to keep it up to date.
+ Vector<WebCore::KURL> m_redirectChain;
+
+ OwnPtr<ExtraData> m_extraData;
+ OwnPtr<WebPluginLoadObserver> m_pluginLoadObserver;
+
+ static WebPluginLoadObserver* m_nextPluginLoadObserver;
+};
+
+} // namespace WebKit
+
+#endif // WebDataSourceImpl_h
diff --git a/Source/WebKit/chromium/src/WebDatabase.cpp b/Source/WebKit/chromium/src/WebDatabase.cpp
new file mode 100644
index 0000000..561d7c4
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDatabase.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDatabase.h"
+
+#include "AbstractDatabase.h"
+#include "DatabaseTracker.h"
+#include "QuotaTracker.h"
+#include "SecurityOrigin.h"
+#include "WebDatabaseObserver.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+#if !ENABLE(DATABASE)
+namespace WebCore {
+class AbstractDatabase {
+public:
+ String stringIdentifier() const { return String(); }
+ String displayName() const { return String(); }
+ unsigned long long estimatedSize() const { return 0; }
+ SecurityOrigin* securityOrigin() const { return 0; }
+};
+}
+#endif // !ENABLE(DATABASE)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static WebDatabaseObserver* databaseObserver = 0;
+
+WebString WebDatabase::name() const
+{
+ ASSERT(m_database);
+ return m_database->stringIdentifier();
+}
+
+WebString WebDatabase::displayName() const
+{
+ ASSERT(m_database);
+ return m_database->displayName();
+}
+
+unsigned long WebDatabase::estimatedSize() const
+{
+ ASSERT(m_database);
+ return m_database->estimatedSize();
+}
+
+WebSecurityOrigin WebDatabase::securityOrigin() const
+{
+ ASSERT(m_database);
+ return WebSecurityOrigin(m_database->securityOrigin());
+}
+
+void WebDatabase::setObserver(WebDatabaseObserver* observer)
+{
+ databaseObserver = observer;
+}
+
+WebDatabaseObserver* WebDatabase::observer()
+{
+ return databaseObserver;
+}
+
+void WebDatabase::updateDatabaseSize(
+ const WebString& originIdentifier, const WebString& databaseName,
+ unsigned long long databaseSize, unsigned long long spaceAvailable)
+{
+#if ENABLE(DATABASE)
+ WebCore::QuotaTracker::instance().updateDatabaseSizeAndSpaceAvailableToOrigin(
+ originIdentifier, databaseName, databaseSize, spaceAvailable);
+#endif // ENABLE(DATABASE)
+}
+
+void WebDatabase::closeDatabaseImmediately(const WebString& originIdentifier, const WebString& databaseName)
+{
+#if ENABLE(DATABASE)
+ HashSet<RefPtr<AbstractDatabase> > databaseHandles;
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
+ DatabaseTracker::tracker().getOpenDatabases(origin.get(), databaseName, &databaseHandles);
+ for (HashSet<RefPtr<AbstractDatabase> >::iterator it = databaseHandles.begin(); it != databaseHandles.end(); ++it)
+ it->get()->closeImmediately();
+#endif // ENABLE(DATABASE)
+}
+
+WebDatabase::WebDatabase(const AbstractDatabase* database)
+ : m_database(database)
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
new file mode 100644
index 0000000..11ce797
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
@@ -0,0 +1,445 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDevToolsAgentImpl.h"
+
+#include "DebuggerAgentImpl.h"
+#include "DebuggerAgentManager.h"
+#include "ExceptionCode.h"
+#include "InjectedScriptHost.h"
+#include "InspectorBackendDispatcher.h"
+#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "PlatformString.h"
+#include "ResourceError.h"
+#include "ResourceRequest.h"
+#include "ResourceResponse.h"
+#include "ScriptDebugServer.h"
+#include "V8Binding.h"
+#include "V8Node.h"
+#include "V8Proxy.h"
+#include "V8Utilities.h"
+#include "WebDataSource.h"
+#include "WebDevToolsAgentClient.h"
+#include "WebFrameImpl.h"
+#include "WebRect.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLError.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+
+using WebCore::DocumentLoader;
+using WebCore::FrameLoader;
+using WebCore::InjectedScriptHost;
+using WebCore::InspectorArray;
+using WebCore::InspectorBackendDispatcher;
+using WebCore::InspectorController;
+using WebCore::InspectorInstrumentation;
+using WebCore::InspectorInstrumentationCookie;
+using WebCore::Node;
+using WebCore::Page;
+using WebCore::ResourceError;
+using WebCore::ResourceRequest;
+using WebCore::ResourceResponse;
+using WTF::String;
+using WebCore::V8DOMWrapper;
+using WebCore::V8Node;
+using WebCore::V8Proxy;
+
+namespace WebKit {
+
+namespace {
+
+static const char kFrontendConnectedFeatureName[] = "frontend-connected";
+static const char kInspectorStateFeatureName[] = "inspector-state";
+
+class ClientMessageLoopAdapter : public WebCore::ScriptDebugServer::ClientMessageLoop {
+public:
+ static void ensureClientMessageLoopCreated(WebDevToolsAgentClient* client)
+ {
+ if (s_instance)
+ return;
+ s_instance = new ClientMessageLoopAdapter(client->createClientMessageLoop());
+ WebCore::ScriptDebugServer::shared().setClientMessageLoop(s_instance);
+ }
+
+ static void inspectedViewClosed(WebViewImpl* view)
+ {
+ if (s_instance)
+ s_instance->m_frozenViews.remove(view);
+ }
+
+ static void didNavigate()
+ {
+ // Release render thread if necessary.
+ if (s_instance && s_instance->m_running)
+ WebCore::ScriptDebugServer::shared().continueProgram();
+ }
+
+private:
+ ClientMessageLoopAdapter(PassOwnPtr<WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop> messageLoop)
+ : m_running(false)
+ , m_messageLoop(messageLoop) { }
+
+
+ virtual void run(Page* page)
+ {
+ if (m_running)
+ return;
+ m_running = true;
+
+ Vector<WebViewImpl*> views;
+
+ // 1. Disable input events.
+ HashSet<Page*>::const_iterator end = page->group().pages().end();
+ for (HashSet<Page*>::const_iterator it = page->group().pages().begin(); it != end; ++it) {
+ WebViewImpl* view = WebViewImpl::fromPage(*it);
+ m_frozenViews.add(view);
+ views.append(view);
+ view->setIgnoreInputEvents(true);
+ }
+
+ // 2. Disable active objects
+ WebView::willEnterModalLoop();
+
+ // 3. Process messages until quitNow is called.
+ m_messageLoop->run();
+
+ // 4. Resume active objects
+ WebView::didExitModalLoop();
+
+ // 5. Resume input events.
+ for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) {
+ if (m_frozenViews.contains(*it)) {
+ // The view was not closed during the dispatch.
+ (*it)->setIgnoreInputEvents(false);
+ }
+ }
+
+ // 6. All views have been resumed, clear the set.
+ m_frozenViews.clear();
+
+ m_running = false;
+ }
+
+ virtual void quitNow()
+ {
+ m_messageLoop->quitNow();
+ }
+
+ bool m_running;
+ OwnPtr<WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLoop;
+ typedef HashSet<WebViewImpl*> FrozenViewsSet;
+ FrozenViewsSet m_frozenViews;
+ static ClientMessageLoopAdapter* s_instance;
+
+};
+
+ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = 0;
+
+} // namespace
+
+WebDevToolsAgentImpl::WebDevToolsAgentImpl(
+ WebViewImpl* webViewImpl,
+ WebDevToolsAgentClient* client)
+ : m_hostId(client->hostIdentifier())
+ , m_client(client)
+ , m_webViewImpl(webViewImpl)
+ , m_attached(false)
+{
+ DebuggerAgentManager::setExposeV8DebuggerProtocol(
+ client->exposeV8DebuggerProtocol());
+}
+
+WebDevToolsAgentImpl::~WebDevToolsAgentImpl()
+{
+ DebuggerAgentManager::onWebViewClosed(m_webViewImpl);
+ ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl);
+}
+
+void WebDevToolsAgentImpl::attach()
+{
+ if (m_attached)
+ return;
+
+ if (!m_client->exposeV8DebuggerProtocol())
+ ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client);
+
+ m_debuggerAgentImpl.set(
+ new DebuggerAgentImpl(m_webViewImpl, this, m_client));
+ WebCString debuggerScriptJs = m_client->debuggerScriptSource();
+ WebCore::ScriptDebugServer::shared().setDebuggerScriptSource(
+ WTF::String(debuggerScriptJs.data(), debuggerScriptJs.length()));
+ m_attached = true;
+}
+
+void WebDevToolsAgentImpl::detach()
+{
+ // Prevent controller from sending messages to the frontend.
+ InspectorController* ic = inspectorController();
+ ic->disconnectFrontend();
+ ic->hideHighlight();
+ ic->close();
+ m_debuggerAgentImpl.set(0);
+ m_attached = false;
+}
+
+void WebDevToolsAgentImpl::frontendLoaded()
+{
+ inspectorController()->connectFrontend();
+}
+
+void WebDevToolsAgentImpl::didNavigate()
+{
+ ClientMessageLoopAdapter::didNavigate();
+ DebuggerAgentManager::onNavigate();
+}
+
+void WebDevToolsAgentImpl::didClearWindowObject(WebFrameImpl* webframe)
+{
+ DebuggerAgentManager::setHostId(webframe, m_hostId);
+}
+
+void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message)
+{
+ inspectorController()->inspectorBackendDispatcher()->dispatch(message);
+}
+
+void WebDevToolsAgentImpl::inspectElementAt(const WebPoint& point)
+{
+ m_webViewImpl->inspectElementAt(point);
+}
+
+void WebDevToolsAgentImpl::inspectNode(v8::Handle<v8::Value> node)
+{
+ if (!V8Node::HasInstance(node))
+ V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);
+ else
+ inspectorController()->inspect(V8Node::toNative(v8::Handle<v8::Object>::Cast(node)));
+}
+
+void WebDevToolsAgentImpl::setRuntimeProperty(const WebString& name, const WebString& value)
+{
+ if (name == kInspectorStateFeatureName) {
+ InspectorController* ic = inspectorController();
+ ic->restoreInspectorStateFromCookie(value);
+ }
+}
+
+WebCore::InspectorController* WebDevToolsAgentImpl::inspectorController()
+{
+ if (Page* page = m_webViewImpl->page())
+ return page->inspectorController();
+ return 0;
+}
+
+WebCore::Frame* WebDevToolsAgentImpl::mainFrame()
+{
+ if (Page* page = m_webViewImpl->page())
+ return page->mainFrame();
+ return 0;
+}
+
+
+//------- plugin resource load notifications ---------------
+void WebDevToolsAgentImpl::identifierForInitialRequest(
+ unsigned long resourceId,
+ WebFrame* webFrame,
+ const WebURLRequest& request)
+{
+ WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(webFrame);
+ WebCore::Frame* frame = webFrameImpl->frame();
+ DocumentLoader* loader = frame->loader()->activeDocumentLoader();
+ InspectorInstrumentation::identifierForInitialRequest(frame, resourceId, loader, request.toResourceRequest());
+}
+
+void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, WebURLRequest& request)
+{
+ if (InspectorController* ic = inspectorController()) {
+ InspectorInstrumentation::willSendRequest(mainFrame(), resourceId, request.toMutableResourceRequest(), ResourceResponse());
+ if (ic->hasFrontend() && request.reportLoadTiming())
+ request.setReportRawHeaders(true);
+ }
+}
+
+void WebDevToolsAgentImpl::didReceiveData(unsigned long resourceId, int length)
+{
+ InspectorInstrumentation::didReceiveContentLength(mainFrame(), resourceId, length);
+}
+
+void WebDevToolsAgentImpl::didReceiveResponse(unsigned long resourceId, const WebURLResponse& response)
+{
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(mainFrame(), resourceId, response.toResourceResponse());
+ InspectorInstrumentation::didReceiveResourceResponse(cookie, resourceId, 0, response.toResourceResponse());
+}
+
+void WebDevToolsAgentImpl::didFinishLoading(unsigned long resourceId)
+{
+ InspectorInstrumentation::didFinishLoading(mainFrame(), resourceId, 0);
+}
+
+void WebDevToolsAgentImpl::didFailLoading(unsigned long resourceId, const WebURLError& error)
+{
+ InspectorInstrumentation::didFailLoading(mainFrame(), resourceId, error);
+}
+
+void WebDevToolsAgentImpl::inspectorDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+void WebDevToolsAgentImpl::openInspectorFrontend(InspectorController*)
+{
+}
+
+void WebDevToolsAgentImpl::highlight(Node* node)
+{
+ // InspectorController does the actuall tracking of the highlighted node
+ // and the drawing of the highlight. Here we just make sure to invalidate
+ // the rects of the old and new nodes.
+ hideHighlight();
+}
+
+void WebDevToolsAgentImpl::hideHighlight()
+{
+ // FIXME: able to invalidate a smaller rect.
+ // FIXME: Is it important to just invalidate the rect of the node region
+ // given that this is not on a critical codepath? In order to do so, we'd
+ // have to take scrolling into account.
+ const WebSize& size = m_webViewImpl->size();
+ WebRect damagedRect(0, 0, size.width, size.height);
+ if (m_webViewImpl->client())
+ m_webViewImpl->client()->didInvalidateRect(damagedRect);
+}
+
+void WebDevToolsAgentImpl::populateSetting(const String& key, String* value)
+{
+ WebString string;
+ m_webViewImpl->inspectorSetting(key, &string);
+ *value = string;
+}
+
+void WebDevToolsAgentImpl::storeSetting(const String& key, const String& value)
+{
+ m_webViewImpl->setInspectorSetting(key, value);
+}
+
+bool WebDevToolsAgentImpl::sendMessageToFrontend(const WTF::String& message)
+{
+ WebDevToolsAgentImpl* devToolsAgent = static_cast<WebDevToolsAgentImpl*>(m_webViewImpl->devToolsAgent());
+ if (!devToolsAgent)
+ return false;
+
+ m_client->sendMessageToInspectorFrontend(message);
+ return true;
+}
+
+void WebDevToolsAgentImpl::updateInspectorStateCookie(const WTF::String& state)
+{
+ m_client->runtimePropertyChanged(kInspectorStateFeatureName, state);
+}
+
+void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString& script)
+{
+ InspectorController* ic = inspectorController();
+ ic->evaluateForTestInFrontend(callId, script);
+}
+
+void WebDevToolsAgentImpl::setTimelineProfilingEnabled(bool enabled)
+{
+ InspectorController* ic = inspectorController();
+ if (enabled)
+ ic->startTimelineProfiler();
+ else
+ ic->stopTimelineProfiler();
+}
+
+void WebDevToolsAgent::executeDebuggerCommand(const WebString& command, int callerId)
+{
+ DebuggerAgentManager::executeDebuggerCommand(command, callerId);
+}
+
+void WebDevToolsAgent::debuggerPauseScript()
+{
+ DebuggerAgentManager::pauseScript();
+}
+
+void WebDevToolsAgent::interruptAndDispatch(MessageDescriptor* d)
+{
+ class DebuggerTask : public WebCore::ScriptDebugServer::Task {
+ public:
+ DebuggerTask(WebDevToolsAgent::MessageDescriptor* descriptor) : m_descriptor(descriptor) { }
+ virtual ~DebuggerTask() { }
+ virtual void run()
+ {
+ if (WebDevToolsAgent* webagent = m_descriptor->agent())
+ webagent->dispatchOnInspectorBackend(m_descriptor->message());
+ }
+ private:
+ OwnPtr<WebDevToolsAgent::MessageDescriptor> m_descriptor;
+ };
+ WebCore::ScriptDebugServer::interruptAndRun(new DebuggerTask(d));
+}
+
+bool WebDevToolsAgent::shouldInterruptForMessage(const WebString& message)
+{
+ String commandName;
+ if (!InspectorBackendDispatcher::getCommandName(message, &commandName))
+ return false;
+ return commandName == InspectorBackendDispatcher::pauseCmd
+ || commandName == InspectorBackendDispatcher::setBreakpointCmd
+ || commandName == InspectorBackendDispatcher::removeBreakpointCmd
+ || commandName == InspectorBackendDispatcher::activateBreakpointsCmd
+ || commandName == InspectorBackendDispatcher::deactivateBreakpointsCmd
+ || commandName == InspectorBackendDispatcher::startProfilingCmd
+ || commandName == InspectorBackendDispatcher::stopProfilingCmd
+ || commandName == InspectorBackendDispatcher::getProfileCmd;
+}
+
+void WebDevToolsAgent::processPendingMessages()
+{
+ WebCore::ScriptDebugServer::shared().runPendingTasks();
+}
+
+void WebDevToolsAgent::setMessageLoopDispatchHandler(MessageLoopDispatchHandler handler)
+{
+ DebuggerAgentManager::setMessageLoopDispatchHandler(handler);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h
new file mode 100644
index 0000000..681eedb
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDevToolsAgentImpl_h
+#define WebDevToolsAgentImpl_h
+
+#include "InspectorClient.h"
+
+#include "WebDevToolsAgentPrivate.h"
+
+#include <v8.h>
+#include <wtf/Forward.h>
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+class Document;
+class Frame;
+class InspectorClient;
+class InspectorController;
+class Node;
+}
+
+namespace WebKit {
+
+class DebuggerAgentImpl;
+class WebDevToolsAgentClient;
+class WebFrame;
+class WebFrameImpl;
+class WebString;
+class WebURLRequest;
+class WebURLResponse;
+class WebViewImpl;
+struct WebURLError;
+struct WebDevToolsMessageData;
+
+class WebDevToolsAgentImpl : public WebDevToolsAgentPrivate,
+ public WebCore::InspectorClient {
+public:
+ WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client);
+ virtual ~WebDevToolsAgentImpl();
+
+ // WebDevToolsAgentPrivate implementation.
+ virtual void didClearWindowObject(WebFrameImpl* frame);
+
+ // WebDevToolsAgent implementation.
+ virtual void attach();
+ virtual void detach();
+ virtual void frontendLoaded();
+ virtual void didNavigate();
+ virtual void dispatchOnInspectorBackend(const WebString& message);
+ virtual void inspectElementAt(const WebPoint& point);
+ virtual void inspectNode(v8::Handle<v8::Value> node);
+ virtual void evaluateInWebInspector(long callId, const WebString& script);
+ virtual void setRuntimeProperty(const WebString& name, const WebString& value);
+ virtual void setTimelineProfilingEnabled(bool enable);
+
+ virtual void identifierForInitialRequest(unsigned long, WebFrame*, const WebURLRequest&);
+ virtual void willSendRequest(unsigned long, WebURLRequest&);
+ virtual void didReceiveData(unsigned long, int length);
+ virtual void didReceiveResponse(unsigned long, const WebURLResponse&);
+ virtual void didFinishLoading(unsigned long);
+ virtual void didFailLoading(unsigned long, const WebURLError&);
+
+ // InspectorClient implementation.
+ virtual void inspectorDestroyed();
+ virtual void openInspectorFrontend(WebCore::InspectorController*);
+ virtual void highlight(WebCore::Node*);
+ virtual void hideHighlight();
+ virtual void populateSetting(const WTF::String& key, WTF::String* value);
+ virtual void storeSetting(const WTF::String& key, const WTF::String& value);
+ virtual void updateInspectorStateCookie(const WTF::String&);
+ virtual bool sendMessageToFrontend(const WTF::String&);
+
+ int hostId() { return m_hostId; }
+
+private:
+ WebCore::InspectorController* inspectorController();
+ WebCore::Frame* mainFrame();
+
+ int m_hostId;
+ WebDevToolsAgentClient* m_client;
+ WebViewImpl* m_webViewImpl;
+ OwnPtr<DebuggerAgentImpl> m_debuggerAgentImpl;
+ bool m_attached;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebDevToolsAgentPrivate.h b/Source/WebKit/chromium/src/WebDevToolsAgentPrivate.h
new file mode 100644
index 0000000..7038a5e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDevToolsAgentPrivate.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDevToolsAgentPrivate_h
+#define WebDevToolsAgentPrivate_h
+
+#include "WebDevToolsAgent.h"
+
+namespace WebKit {
+class WebFrameImpl;
+
+class WebDevToolsAgentPrivate : public WebDevToolsAgent {
+public:
+ // Notifications from FrameLoaderClientImpl:
+
+ // The window object for the frame has been cleared of any extra properties
+ // that may have been set by script from the previously loaded document.
+ virtual void didClearWindowObject(WebFrameImpl*) = 0;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp
new file mode 100644
index 0000000..caeffb6
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDevToolsFrontendImpl.h"
+
+#include "BoundObject.h"
+#include "ContextMenuController.h"
+#include "ContextMenuItem.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Event.h"
+#include "Frame.h"
+#include "InspectorController.h"
+#include "InspectorFrontendClientImpl.h"
+#include "InspectorFrontendHost.h"
+#include "Node.h"
+#include "Page.h"
+#include "Pasteboard.h"
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+#include "Settings.h"
+#include "V8Binding.h"
+#include "V8DOMWrapper.h"
+#include "V8InspectorFrontendHost.h"
+#include "V8MouseEvent.h"
+#include "V8Node.h"
+#include "V8Proxy.h"
+#include "V8Utilities.h"
+#include "WebDevToolsFrontendClient.h"
+#include "WebFrameImpl.h"
+#include "WebScriptSource.h"
+#include "WebViewImpl.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static v8::Local<v8::String> ToV8String(const String& s)
+{
+ if (s.isNull())
+ return v8::Local<v8::String>();
+
+ return v8::String::New(reinterpret_cast<const uint16_t*>(s.characters()), s.length());
+}
+
+WebDevToolsFrontend* WebDevToolsFrontend::create(
+ WebView* view,
+ WebDevToolsFrontendClient* client,
+ const WebString& applicationLocale)
+{
+ return new WebDevToolsFrontendImpl(
+ static_cast<WebViewImpl*>(view),
+ client,
+ applicationLocale);
+}
+
+WebDevToolsFrontendImpl::WebDevToolsFrontendImpl(
+ WebViewImpl* webViewImpl,
+ WebDevToolsFrontendClient* client,
+ const String& applicationLocale)
+ : m_webViewImpl(webViewImpl)
+ , m_client(client)
+ , m_applicationLocale(applicationLocale)
+{
+ InspectorController* ic = m_webViewImpl->page()->inspectorController();
+ ic->setInspectorFrontendClient(new InspectorFrontendClientImpl(m_webViewImpl->page(), m_client, this));
+
+ // Put each DevTools frontend Page into its own (single page) group so that it's not
+ // deferred along with the inspected page.
+ m_webViewImpl->page()->setGroupName(String());
+}
+
+WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl()
+{
+}
+
+void WebDevToolsFrontendImpl::dispatchOnInspectorFrontend(const WebString& message)
+{
+ WebFrameImpl* frame = m_webViewImpl->mainFrameImpl();
+ v8::HandleScope scope;
+ v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame());
+ v8::Context::Scope contextScope(frameContext);
+ v8::Handle<v8::Value> inspectorBackendValue = frameContext->Global()->Get(v8::String::New("InspectorBackend"));
+ if (!inspectorBackendValue->IsObject())
+ return;
+ v8::Handle<v8::Object> inspectorBackend = v8::Handle<v8::Object>::Cast(inspectorBackendValue);
+ v8::Handle<v8::Value> dispatchFunction = inspectorBackend->Get(v8::String::New("dispatch"));
+ // The frame might have navigated away from the front-end page (which is still weird).
+ if (!dispatchFunction->IsFunction())
+ return;
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatchFunction);
+ Vector< v8::Handle<v8::Value> > args;
+ args.append(ToV8String(message));
+ v8::TryCatch tryCatch;
+ tryCatch.SetVerbose(true);
+ function->Call(inspectorBackend, args.size(), args.data());
+}
+
+void WebDevToolsFrontendImpl::frontendLoaded()
+{
+ m_client->sendFrontendLoaded();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h
new file mode 100644
index 0000000..dc7d2df
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDevToolsFrontendImpl_h
+#define WebDevToolsFrontendImpl_h
+
+#include "PlatformString.h"
+#include "WebDevToolsFrontend.h"
+#include <v8.h>
+#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class ContextMenuItem;
+class Node;
+class Page;
+}
+
+namespace WebKit {
+
+class WebDevToolsClientDelegate;
+class WebViewImpl;
+struct WebDevToolsMessageData;
+
+using WTF::String;
+
+class WebDevToolsFrontendImpl : public WebKit::WebDevToolsFrontend {
+ WTF_MAKE_NONCOPYABLE(WebDevToolsFrontendImpl);
+public:
+ WebDevToolsFrontendImpl(
+ WebKit::WebViewImpl* webViewImpl,
+ WebKit::WebDevToolsFrontendClient* client,
+ const String& applicationLocale);
+ virtual ~WebDevToolsFrontendImpl();
+
+ // WebDevToolsFrontend implementation.
+ virtual void dispatchOnInspectorFrontend(const WebString& message);
+
+ void frontendLoaded();
+
+private:
+ WebKit::WebViewImpl* m_webViewImpl;
+ WebKit::WebDevToolsFrontendClient* m_client;
+ String m_applicationLocale;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebDeviceOrientation.cpp b/Source/WebKit/chromium/src/WebDeviceOrientation.cpp
new file mode 100644
index 0000000..47f6bd1
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDeviceOrientation.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDeviceOrientation.h"
+
+#include "DeviceOrientation.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+WebDeviceOrientation::WebDeviceOrientation(const PassRefPtr<WebCore::DeviceOrientation>& orientation)
+{
+ if (!orientation) {
+ m_isNull = true;
+ m_canProvideAlpha = false;
+ m_alpha = 0;
+ m_canProvideBeta = false;
+ m_beta = 0;
+ m_canProvideGamma = false;
+ m_gamma = 0;
+ return;
+ }
+
+ m_isNull = false;
+ m_canProvideAlpha = orientation->canProvideAlpha();
+ m_alpha = orientation->alpha();
+ m_canProvideBeta = orientation->canProvideBeta();
+ m_beta = orientation->beta();
+ m_canProvideGamma = orientation->canProvideGamma();
+ m_gamma = orientation->gamma();
+}
+
+WebDeviceOrientation& WebDeviceOrientation::operator=(const PassRefPtr<WebCore::DeviceOrientation>& orientation)
+{
+ if (!orientation) {
+ m_isNull = true;
+ m_canProvideAlpha = false;
+ m_alpha = 0;
+ m_canProvideBeta = false;
+ m_beta = 0;
+ m_canProvideGamma = false;
+ m_gamma = 0;
+ return *this;
+ }
+
+ m_isNull = false;
+ m_canProvideAlpha = orientation->canProvideAlpha();
+ m_alpha = orientation->alpha();
+ m_canProvideBeta = orientation->canProvideBeta();
+ m_beta = orientation->beta();
+ m_canProvideGamma = orientation->canProvideGamma();
+ m_gamma = orientation->gamma();
+ return *this;
+}
+
+WebDeviceOrientation::operator PassRefPtr<WebCore::DeviceOrientation>() const
+{
+ if (m_isNull)
+ return 0;
+ return WebCore::DeviceOrientation::create(m_canProvideAlpha, m_alpha, m_canProvideBeta, m_beta, m_canProvideGamma, m_gamma);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp b/Source/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp
new file mode 100644
index 0000000..8a75ca1
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDeviceOrientationClientMock.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDeviceOrientationClientMock.h"
+
+#include "DeviceOrientationClientMock.h"
+#include "WebDeviceOrientation.h"
+#include "WebDeviceOrientationController.h"
+
+namespace WebKit {
+
+WebDeviceOrientationClientMock* WebDeviceOrientationClientMock::create()
+{
+ return new WebDeviceOrientationClientMock();
+}
+
+void WebDeviceOrientationClientMock::setController(WebDeviceOrientationController* controller)
+{
+ m_clientMock->setController(controller->controller());
+ delete controller;
+}
+
+void WebDeviceOrientationClientMock::startUpdating()
+{
+ m_clientMock->startUpdating();
+}
+
+void WebDeviceOrientationClientMock::stopUpdating()
+{
+ m_clientMock->stopUpdating();
+}
+
+WebDeviceOrientation WebDeviceOrientationClientMock::lastOrientation() const
+{
+ return WebDeviceOrientation(m_clientMock->lastOrientation());
+}
+
+void WebDeviceOrientationClientMock::setOrientation(WebDeviceOrientation& orientation)
+{
+ m_clientMock->setOrientation(orientation);
+}
+
+void WebDeviceOrientationClientMock::initialize()
+{
+ m_clientMock.reset(new WebCore::DeviceOrientationClientMock());
+}
+
+void WebDeviceOrientationClientMock::reset()
+{
+ m_clientMock.reset(0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp b/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp
new file mode 100644
index 0000000..aa9249f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDeviceOrientationController.h"
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationController.h"
+#include "WebDeviceOrientation.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+void WebDeviceOrientationController::didChangeDeviceOrientation(const WebDeviceOrientation& orientation)
+{
+ PassRefPtr<WebCore::DeviceOrientation> deviceOrientation(orientation);
+ m_controller->didChangeDeviceOrientation(deviceOrientation.get());
+}
+
+WebCore::DeviceOrientationController* WebDeviceOrientationController::controller() const
+{
+ return m_controller;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDocument.cpp b/Source/WebKit/chromium/src/WebDocument.cpp
new file mode 100644
index 0000000..a983bf7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDocument.cpp
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDocument.h"
+
+#include "Document.h"
+#include "DocumentType.h"
+#include "Element.h"
+#include "HTMLAllCollection.h"
+#include "HTMLBodyElement.h"
+#include "HTMLCollection.h"
+#include "HTMLElement.h"
+#include "HTMLHeadElement.h"
+#include "NodeList.h"
+
+#include "WebDocumentType.h"
+#include "WebElement.h"
+#include "WebFrameImpl.h"
+#include "WebNodeCollection.h"
+#include "WebNodeList.h"
+#include "WebURL.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFrame* WebDocument::frame() const
+{
+ return WebFrameImpl::fromFrame(constUnwrap<Document>()->frame());
+}
+
+bool WebDocument::isHTMLDocument() const
+{
+ return constUnwrap<Document>()->isHTMLDocument();
+}
+
+bool WebDocument::isXHTMLDocument() const
+{
+ return constUnwrap<Document>()->isXHTMLDocument();
+}
+
+bool WebDocument::isPluginDocument() const
+{
+ return constUnwrap<Document>()->isPluginDocument();
+}
+
+WebURL WebDocument::baseURL() const
+{
+ return constUnwrap<Document>()->baseURL();
+}
+
+WebURL WebDocument::firstPartyForCookies() const
+{
+ return constUnwrap<Document>()->firstPartyForCookies();
+}
+
+WebElement WebDocument::documentElement() const
+{
+ return WebElement(constUnwrap<Document>()->documentElement());
+}
+
+WebElement WebDocument::body() const
+{
+ return WebElement(constUnwrap<Document>()->body());
+}
+
+WebElement WebDocument::head()
+{
+ return WebElement(unwrap<Document>()->head());
+}
+
+WebString WebDocument::title() const
+{
+ return WebString(constUnwrap<Document>()->title());
+}
+
+WebNodeCollection WebDocument::all()
+{
+ return WebNodeCollection(unwrap<Document>()->all());
+}
+
+WebURL WebDocument::completeURL(const WebString& partialURL) const
+{
+ return constUnwrap<Document>()->completeURL(partialURL);
+}
+
+WebElement WebDocument::getElementById(const WebString& id) const
+{
+ return WebElement(constUnwrap<Document>()->getElementById(id));
+}
+
+WebNode WebDocument::focusedNode() const
+{
+ return WebNode(constUnwrap<Document>()->focusedNode());
+}
+
+WebDocumentType WebDocument::doctype() const
+{
+ return WebDocumentType(constUnwrap<Document>()->doctype());
+}
+
+WebDocument::WebDocument(const PassRefPtr<Document>& elem)
+ : WebNode(elem)
+{
+}
+
+WebDocument& WebDocument::operator=(const PassRefPtr<Document>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebDocument::operator PassRefPtr<Document>() const
+{
+ return static_cast<Document*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDocumentType.cpp b/Source/WebKit/chromium/src/WebDocumentType.cpp
new file mode 100644
index 0000000..bbf28e7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDocumentType.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDocumentType.h"
+
+#include "DocumentType.h"
+#include "WebString.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebString WebDocumentType::name() const
+{
+ return WebString(constUnwrap<DocumentType>()->name());
+}
+
+WebDocumentType::WebDocumentType(const PassRefPtr<DocumentType>& elem)
+ : WebNode(elem)
+{
+}
+
+WebDocumentType& WebDocumentType::operator=(const PassRefPtr<DocumentType>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebDocumentType::operator PassRefPtr<DocumentType>() const
+{
+ return static_cast<DocumentType*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebDragData.cpp b/Source/WebKit/chromium/src/WebDragData.cpp
new file mode 100644
index 0000000..9167c69
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebDragData.cpp
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDragData.h"
+
+#include "ChromiumDataObject.h"
+#include "ChromiumDataObjectLegacy.h"
+#include "ClipboardMimeTypes.h"
+#include "WebData.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebVector.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebDragDataPrivate : public ChromiumDataObject {
+};
+
+void WebDragData::initialize()
+{
+ assign(static_cast<WebDragDataPrivate*>(ChromiumDataObject::create(ChromiumDataObjectLegacy::create(Clipboard::DragAndDrop)).releaseRef()));
+}
+
+void WebDragData::reset()
+{
+ assign(0);
+}
+
+void WebDragData::assign(const WebDragData& other)
+{
+ WebDragDataPrivate* p = const_cast<WebDragDataPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+WebString WebDragData::url() const
+{
+ ASSERT(!isNull());
+ bool ignoredSuccess;
+ return m_private->getData(mimeTypeURL, ignoredSuccess);
+}
+
+void WebDragData::setURL(const WebURL& url)
+{
+ ensureMutable();
+ m_private->setData(mimeTypeURL, KURL(url).string());
+}
+
+WebString WebDragData::urlTitle() const
+{
+ ASSERT(!isNull());
+ return m_private->urlTitle();
+}
+
+void WebDragData::setURLTitle(const WebString& urlTitle)
+{
+ ensureMutable();
+ m_private->setUrlTitle(urlTitle);
+}
+
+WebString WebDragData::downloadMetadata() const
+{
+ ASSERT(!isNull());
+ bool ignoredSuccess;
+ return m_private->getData(mimeTypeDownloadURL, ignoredSuccess);
+}
+
+void WebDragData::setDownloadMetadata(const WebString& downloadMetadata)
+{
+ ensureMutable();
+ m_private->setData(mimeTypeDownloadURL, downloadMetadata);
+}
+
+WebString WebDragData::fileExtension() const
+{
+ ASSERT(!isNull());
+ return m_private->fileExtension();
+}
+
+void WebDragData::setFileExtension(const WebString& fileExtension)
+{
+ ensureMutable();
+ m_private->setFileExtension(fileExtension);
+}
+
+bool WebDragData::containsFilenames() const
+{
+ ASSERT(!isNull());
+ return m_private->containsFilenames();
+}
+
+void WebDragData::filenames(WebVector<WebString>& filenames) const
+{
+ ASSERT(!isNull());
+ filenames = m_private->filenames();
+}
+
+void WebDragData::setFilenames(const WebVector<WebString>& filenames)
+{
+ ensureMutable();
+ Vector<String> filenamesCopy;
+ filenamesCopy.append(filenames.data(), filenames.size());
+ m_private->setFilenames(filenamesCopy);
+}
+
+void WebDragData::appendToFilenames(const WebString& filename)
+{
+ ensureMutable();
+ Vector<String> filenames = m_private->filenames();
+ filenames.append(filename);
+ m_private->setFilenames(filenames);
+}
+
+WebString WebDragData::plainText() const
+{
+ ASSERT(!isNull());
+ bool ignoredSuccess;
+ return m_private->getData(mimeTypeTextPlain, ignoredSuccess);
+}
+
+void WebDragData::setPlainText(const WebString& plainText)
+{
+ ensureMutable();
+ m_private->setData(mimeTypeTextPlain, plainText);
+}
+
+WebString WebDragData::htmlText() const
+{
+ ASSERT(!isNull());
+ bool ignoredSuccess;
+ return m_private->getData(mimeTypeTextHTML, ignoredSuccess);
+}
+
+void WebDragData::setHTMLText(const WebString& htmlText)
+{
+ ensureMutable();
+ m_private->setData(mimeTypeTextHTML, htmlText);
+}
+
+WebURL WebDragData::htmlBaseURL() const
+{
+ ASSERT(!isNull());
+ return m_private->htmlBaseUrl();
+}
+
+void WebDragData::setHTMLBaseURL(const WebURL& htmlBaseURL)
+{
+ ensureMutable();
+ m_private->setHtmlBaseUrl(htmlBaseURL);
+}
+
+WebString WebDragData::fileContentFilename() const
+{
+ ASSERT(!isNull());
+ return m_private->fileContentFilename();
+}
+
+void WebDragData::setFileContentFilename(const WebString& filename)
+{
+ ensureMutable();
+ m_private->setFileContentFilename(filename);
+}
+
+WebData WebDragData::fileContent() const
+{
+ ASSERT(!isNull());
+ return WebData(m_private->fileContent());
+}
+
+void WebDragData::setFileContent(const WebData& fileContent)
+{
+ ensureMutable();
+ m_private->setFileContent(fileContent);
+}
+
+WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data)
+ : m_private(static_cast<WebDragDataPrivate*>(data.releaseRef()))
+{
+}
+
+WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data)
+{
+ assign(static_cast<WebDragDataPrivate*>(data.releaseRef()));
+ return *this;
+}
+
+WebDragData::operator WTF::PassRefPtr<WebCore::ChromiumDataObject>() const
+{
+ return PassRefPtr<ChromiumDataObject>(const_cast<WebDragDataPrivate*>(m_private));
+}
+
+void WebDragData::assign(WebDragDataPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+void WebDragData::ensureMutable()
+{
+ ASSERT(!isNull());
+ ASSERT(m_private->hasOneRef());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebElement.cpp b/Source/WebKit/chromium/src/WebElement.cpp
new file mode 100644
index 0000000..34daa34
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebElement.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebElement.h"
+
+#include "Element.h"
+#include "RenderBoxModelObject.h"
+#include "RenderObject.h"
+#include <wtf/PassRefPtr.h>
+
+#include "WebNamedNodeMap.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebElement::isFormControlElement() const
+{
+ return constUnwrap<Element>()->isFormControlElement();
+}
+
+bool WebElement::isTextFormControlElement() const
+{
+ return constUnwrap<Element>()->isTextFormControl();
+}
+
+WebString WebElement::tagName() const
+{
+ return constUnwrap<Element>()->tagName();
+}
+
+bool WebElement::hasTagName(const WebString& tagName) const
+{
+ return equalIgnoringCase(constUnwrap<Element>()->tagName(),
+ tagName.operator String());
+}
+
+bool WebElement::hasAttribute(const WebString& attrName) const
+{
+ return constUnwrap<Element>()->hasAttribute(attrName);
+}
+
+WebString WebElement::getAttribute(const WebString& attrName) const
+{
+ return constUnwrap<Element>()->getAttribute(attrName);
+}
+
+bool WebElement::setAttribute(const WebString& attrName, const WebString& attrValue)
+{
+ ExceptionCode exceptionCode = 0;
+ unwrap<Element>()->setAttribute(attrName, attrValue, exceptionCode);
+ return !exceptionCode;
+}
+
+WebNamedNodeMap WebElement::attributes() const
+{
+ return WebNamedNodeMap(m_private->attributes());
+}
+
+WebString WebElement::innerText() const
+{
+ return constUnwrap<Element>()->innerText();
+}
+
+WebString WebElement::computeInheritedLanguage() const
+{
+ return WebString(constUnwrap<Element>()->computeInheritedLanguage());
+}
+
+WebElement::WebElement(const PassRefPtr<Element>& elem)
+ : WebNode(elem)
+{
+}
+
+WebElement& WebElement::operator=(const PassRefPtr<Element>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebElement::operator PassRefPtr<Element>() const
+{
+ return static_cast<Element*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebEntities.cpp b/Source/WebKit/chromium/src/WebEntities.cpp
new file mode 100644
index 0000000..4e37dde
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebEntities.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebEntities.h"
+
+#include "WebString.h"
+
+#include <string.h>
+#include <wtf/HashMap.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+WebEntities::WebEntities(bool xmlEntities)
+{
+ ASSERT(m_entitiesMap.isEmpty());
+ m_entitiesMap.set(0x003c, "lt");
+ m_entitiesMap.set(0x003e, "gt");
+ m_entitiesMap.set(0x0026, "amp");
+ m_entitiesMap.set(0x0027, "apos");
+ m_entitiesMap.set(0x0022, "quot");
+ // We add #39 for test-compatibility reason.
+ if (!xmlEntities)
+ m_entitiesMap.set(0x0027, String("#39"));
+}
+
+String WebEntities::entityNameByCode(int code) const
+{
+ if (m_entitiesMap.contains(code))
+ return m_entitiesMap.get(code);
+ return "";
+}
+
+String WebEntities::convertEntitiesInString(const String& value) const
+{
+ unsigned len = value.length();
+ const UChar* startPos = value.characters();
+ const UChar* curPos = startPos;
+
+ // FIXME: Optimize - create StringBuilder only if value has any entities.
+ StringBuilder result;
+ while (len--) {
+ if (m_entitiesMap.contains(*curPos)) {
+ // Append content before entity code.
+ if (curPos > startPos)
+ result.append(String(startPos, curPos - startPos));
+ result.append('&');
+ result.append(m_entitiesMap.get(*curPos));
+ result.append(';');
+ startPos = ++curPos;
+ } else
+ curPos++;
+ }
+ // Append the remaining content.
+ if (curPos > startPos)
+ result.append(String(startPos, curPos - startPos));
+
+ return result.toString();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebEntities.h b/Source/WebKit/chromium/src/WebEntities.h
new file mode 100644
index 0000000..f210566
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebEntities.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebEntities_h
+#define WebEntities_h
+
+#include "PlatformString.h"
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+// FIXME: This class is wrong and needs to be removed.
+class WebEntities {
+public:
+ // &apos;, &percnt;, &nsup;, &supl; are not defined by the HTML standards.
+ // - IE does not support &apos; as an HTML entity (but support it as an XML
+ // entity.)
+ // - Firefox supports &apos; as an HTML entity.
+ // - Both of IE and Firefox don't support &percnt;, &nsup; and &supl;.
+ //
+ // A web page saved by Chromium should be able to be read by other browsers
+ // such as IE and Firefox. Chromium should produce only the standard entity
+ // references which other browsers can recognize.
+ // So if standard_html_entities_ is true, we will use a numeric character
+ // reference for &apos;, and don't use entity references for &percnt;, &nsup;
+ // and &supl; for serialization.
+ //
+ // If xmlEntities is true, WebEntities will only contain standard XML
+ // entities.
+ explicit WebEntities(bool xmlEntities);
+
+ // Check whether specified unicode has corresponding html or xml built-in
+ // entity name. If yes, return the entity notation. If not, returns an
+ // empty string. Parameter isHTML indicates check the code in html entity
+ // map or in xml entity map.
+ WTF::String entityNameByCode(int code) const;
+
+ // Returns a new string with corresponding entity names replaced.
+ WTF::String convertEntitiesInString(const WTF::String&) const;
+private:
+ typedef HashMap<int, WTF::String> EntitiesMapType;
+ // An internal object that maps the Unicode character to corresponding
+ // entity notation.
+ EntitiesMapType m_entitiesMap;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp b/Source/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp
new file mode 100644
index 0000000..ef2409c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFileChooserCompletionImpl.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFileChooserCompletionImpl.h"
+
+namespace WebKit {
+
+WebFileChooserCompletionImpl::WebFileChooserCompletionImpl(PassRefPtr<WebCore::FileChooser> chooser)
+ : m_fileChooser(chooser)
+{
+}
+
+WebFileChooserCompletionImpl::~WebFileChooserCompletionImpl()
+{
+}
+
+void WebFileChooserCompletionImpl::didChooseFile(const WebVector<WebString>& fileNames)
+{
+ if (fileNames.size() == 1)
+ m_fileChooser->chooseFile(fileNames[0]);
+ else {
+ // This clause handles a case of file_names.size()==0 too.
+ Vector<WTF::String> paths;
+ for (size_t i = 0; i < fileNames.size(); ++i)
+ paths.append(fileNames[i]);
+ m_fileChooser->chooseFiles(paths);
+ }
+ // This object is no longer needed.
+ delete this;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFileChooserCompletionImpl.h b/Source/WebKit/chromium/src/WebFileChooserCompletionImpl.h
new file mode 100644
index 0000000..147d1f7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFileChooserCompletionImpl.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFileChooserCompletionImpl_h
+#define WebFileChooserCompletionImpl_h
+
+#include "WebFileChooserCompletion.h"
+#include "WebString.h"
+#include "WebVector.h"
+
+#include "FileChooser.h"
+#include <wtf/PassRefPtr.h>
+
+using WebKit::WebFileChooserCompletion;
+using WebKit::WebString;
+using WebKit::WebVector;
+
+namespace WebKit {
+
+class WebFileChooserCompletionImpl : public WebFileChooserCompletion {
+public:
+ WebFileChooserCompletionImpl(PassRefPtr<WebCore::FileChooser> chooser);
+ ~WebFileChooserCompletionImpl();
+ virtual void didChooseFile(const WebVector<WebString>& fileNames);
+private:
+ RefPtr<WebCore::FileChooser> m_fileChooser;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp b/Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp
new file mode 100644
index 0000000..52a4032
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "WebFileSystemCallbacksImpl.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystemCallbacks.h"
+#include "AsyncFileSystemChromium.h"
+#include "FileMetadata.h"
+#include "ScriptExecutionContext.h"
+#include "WebFileSystemEntry.h"
+#include "WebFileInfo.h"
+#include "WebString.h"
+#include "WorkerAsyncFileSystemChromium.h"
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WebCore::ScriptExecutionContext* context, bool synchronous)
+ : m_callbacks(callbacks)
+ , m_context(context)
+ , m_synchronous(synchronous)
+{
+ ASSERT(m_callbacks);
+}
+
+WebFileSystemCallbacksImpl::~WebFileSystemCallbacksImpl()
+{
+}
+
+void WebFileSystemCallbacksImpl::didSucceed()
+{
+ m_callbacks->didSucceed();
+ delete this;
+}
+
+void WebFileSystemCallbacksImpl::didReadMetadata(const WebFileInfo& webFileInfo)
+{
+ FileMetadata fileMetadata;
+ fileMetadata.modificationTime = webFileInfo.modificationTime;
+ fileMetadata.length = webFileInfo.length;
+ fileMetadata.type = static_cast<FileMetadata::Type>(webFileInfo.type);
+ m_callbacks->didReadMetadata(fileMetadata);
+ delete this;
+}
+
+void WebFileSystemCallbacksImpl::didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
+{
+ for (size_t i = 0; i < entries.size(); ++i)
+ m_callbacks->didReadDirectoryEntry(entries[i].name, entries[i].isDirectory);
+ m_callbacks->didReadDirectoryEntries(hasMore);
+ delete this;
+}
+
+void WebFileSystemCallbacksImpl::didOpenFileSystem(const WebString& name, const WebString& path)
+{
+ if (m_context && m_context->isWorkerContext())
+ m_callbacks->didOpenFileSystem(name, WorkerAsyncFileSystemChromium::create(m_context, path, m_synchronous));
+ else
+ m_callbacks->didOpenFileSystem(name, AsyncFileSystemChromium::create(path));
+ delete this;
+}
+
+void WebFileSystemCallbacksImpl::didFail(WebFileError error)
+{
+ m_callbacks->didFail(error);
+ delete this;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h b/Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h
new file mode 100644
index 0000000..75fa2bb
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFileSystemCallbacksImpl_h
+#define WebFileSystemCallbacksImpl_h
+
+#include "WebFileSystemCallbacks.h"
+#include "WebVector.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+class AsyncFileSystemCallbacks;
+class ScriptExecutionContext;
+}
+
+namespace WebKit {
+
+struct WebFileInfo;
+struct WebFileSystemEntry;
+class WebString;
+
+class WebFileSystemCallbacksImpl : public WebFileSystemCallbacks {
+public:
+ WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::ScriptExecutionContext* = 0, bool synchronous = false);
+ virtual ~WebFileSystemCallbacksImpl();
+
+ virtual void didSucceed();
+ virtual void didReadMetadata(const WebFileInfo& info);
+ virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore);
+ virtual void didOpenFileSystem(const WebString& name, const WebString& rootPath);
+ virtual void didFail(WebFileError error);
+
+private:
+ OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
+
+ // Used for worker's openFileSystem callbacks.
+ WebCore::ScriptExecutionContext* m_context;
+ bool m_synchronous;
+};
+
+} // namespace WebKit
+
+#endif // WebFileSystemCallbacksImpl_h
diff --git a/Source/WebKit/chromium/src/WebFontCache.cpp b/Source/WebKit/chromium/src/WebFontCache.cpp
new file mode 100644
index 0000000..52358ec
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFontCache.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFontCache.h"
+
+#include "FontCache.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// static
+size_t WebFontCache::fontDataCount()
+{
+ return fontCache()->fontDataCount();
+}
+
+// static
+size_t WebFontCache::inactiveFontDataCount()
+{
+ return fontCache()->inactiveFontDataCount();
+}
+
+// static
+void WebFontCache::clear()
+{
+ fontCache()->invalidate();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFontDescription.cpp b/Source/WebKit/chromium/src/WebFontDescription.cpp
new file mode 100644
index 0000000..18f6830
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFontDescription.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFontDescription.h"
+
+#include "FontDescription.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFontDescription::WebFontDescription(const FontDescription& desc,
+ short fontLetterSpacing, short fontWordSpacing)
+{
+ family = desc.family().family();
+ genericFamily = static_cast<GenericFamily>(desc.genericFamily());
+ size = desc.specifiedSize();
+ italic = desc.italic();
+ smallCaps = desc.smallCaps();
+ weight = static_cast<Weight>(desc.weight());
+ smoothing = static_cast<Smoothing>(desc.fontSmoothing());
+ letterSpacing = fontLetterSpacing;
+ wordSpacing = fontWordSpacing;
+}
+
+WebFontDescription::operator WebCore::FontDescription() const
+{
+ FontFamily fontFamily;
+ fontFamily.setFamily(family);
+
+ FontDescription desc;
+ desc.setFamily(fontFamily);
+ desc.setGenericFamily(static_cast<FontDescription::GenericFamilyType>(genericFamily));
+ desc.setSpecifiedSize(size);
+ desc.setComputedSize(size);
+ desc.setItalic(italic);
+ desc.setSmallCaps(smallCaps);
+ desc.setWeight(static_cast<FontWeight>(weight));
+ desc.setFontSmoothing(static_cast<FontSmoothingMode>(smoothing));
+ return desc;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFontImpl.cpp b/Source/WebKit/chromium/src/WebFontImpl.cpp
new file mode 100644
index 0000000..e1fa0e7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFontImpl.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFontImpl.h"
+
+#include "Font.h"
+#include "FontDescription.h"
+#include "GraphicsContext.h"
+#include "PlatformContextSkia.h"
+#include "TextRun.h"
+#include "WebFloatPoint.h"
+#include "WebFloatRect.h"
+#include "WebFontDescription.h"
+#include "WebRect.h"
+#include "WebTextRun.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFont* WebFont::create(const WebFontDescription& desc)
+{
+ return new WebFontImpl(desc, desc.letterSpacing, desc.wordSpacing);
+}
+
+WebFontImpl::WebFontImpl(const FontDescription& desc, short letterSpacing, short wordSpacing)
+ : m_font(desc, letterSpacing, wordSpacing)
+{
+ m_font.update(0);
+}
+
+WebFontDescription WebFontImpl::fontDescription() const
+{
+ return WebFontDescription(m_font.fontDescription(), m_font.letterSpacing(), m_font.wordSpacing());
+}
+
+int WebFontImpl::ascent() const
+{
+ return m_font.ascent();
+}
+
+int WebFontImpl::descent() const
+{
+ return m_font.descent();
+}
+
+int WebFontImpl::height() const
+{
+ return m_font.height();
+}
+
+int WebFontImpl::lineSpacing() const
+{
+ return m_font.lineSpacing();
+}
+
+float WebFontImpl::xHeight() const
+{
+ return m_font.xHeight();
+}
+
+void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
+ WebColor color, const WebRect& clip, bool canvasIsOpaque,
+ int from, int to) const
+{
+ // FIXME hook canvasIsOpaque up to the platform-specific indicators for
+ // whether subpixel AA can be used for this draw. On Windows, this is
+ // PlatformContextSkia::setDrawingToImageBuffer.
+#if WEBKIT_USING_CG
+ GraphicsContext gc(canvas);
+#elif WEBKIT_USING_SKIA
+ PlatformContextSkia context(canvas);
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+ notImplemented();
+#endif
+
+ gc.save();
+ gc.setFillColor(color, ColorSpaceDeviceRGB);
+ gc.clip(WebCore::FloatRect(clip));
+ m_font.drawText(&gc, run, leftBaseline, from, to);
+ gc.restore();
+}
+
+int WebFontImpl::calculateWidth(const WebTextRun& run) const
+{
+ return m_font.width(run, 0);
+}
+
+int WebFontImpl::offsetForPosition(const WebTextRun& run, float position) const
+{
+ return m_font.offsetForPosition(run, position, true);
+}
+
+WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebFloatPoint& leftBaseline, int height, int from, int to) const
+{
+ return m_font.selectionRectForText(run, leftBaseline, height, from, to);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFontImpl.h b/Source/WebKit/chromium/src/WebFontImpl.h
new file mode 100644
index 0000000..3ac9031
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFontImpl.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFontImpl_h
+#define WebFontImpl_h
+
+#include "Font.h"
+#include "WebFont.h"
+
+namespace WebCore { class FontDescription; }
+
+namespace WebKit {
+
+class WebFontImpl : public WebFont {
+public:
+ WebFontImpl(const WebCore::FontDescription&, short letterSpacing, short wordSpacing);
+
+ virtual WebFontDescription fontDescription() const;
+
+ virtual int ascent() const;
+ virtual int descent() const;
+ virtual int height() const;
+ virtual int lineSpacing() const;
+ virtual float xHeight() const;
+
+ virtual void drawText(WebCanvas*, const WebTextRun&, const WebFloatPoint& leftBaseline, WebColor,
+ const WebRect& clip, bool canvasIsOpaque, int from = 0, int to = -1) const;
+ virtual int calculateWidth(const WebTextRun&) const;
+ virtual int offsetForPosition(const WebTextRun&, float position) const;
+ virtual WebFloatRect selectionRectForText(const WebTextRun&, const WebFloatPoint& leftBaseline,
+ int height, int from = 0, int to = -1) const;
+
+private:
+ WebCore::Font m_font;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebFormControlElement.cpp b/Source/WebKit/chromium/src/WebFormControlElement.cpp
new file mode 100644
index 0000000..a75fe5c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFormControlElement.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFormControlElement.h"
+
+#include "HTMLFormControlElement.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebFormControlElement::isEnabled() const
+{
+ return constUnwrap<HTMLFormControlElement>()->isEnabledFormControl();
+}
+
+WebString WebFormControlElement::formControlName() const
+{
+ return constUnwrap<HTMLFormControlElement>()->name();
+}
+
+WebString WebFormControlElement::formControlType() const
+{
+ return constUnwrap<HTMLFormControlElement>()->type();
+}
+
+WebString WebFormControlElement::nameForAutofill() const
+{
+ String name = constUnwrap<HTMLFormControlElement>()->name();
+ String trimmedName = name.stripWhiteSpace();
+ if (!trimmedName.isEmpty())
+ return trimmedName;
+ name = constUnwrap<HTMLFormControlElement>()->getIdAttribute();
+ trimmedName = name.stripWhiteSpace();
+ if (!trimmedName.isEmpty())
+ return trimmedName;
+ return String();
+}
+
+WebFormControlElement::WebFormControlElement(const PassRefPtr<HTMLFormControlElement>& elem)
+ : WebElement(elem)
+{
+}
+
+WebFormControlElement& WebFormControlElement::operator=(const PassRefPtr<HTMLFormControlElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebFormControlElement::operator PassRefPtr<HTMLFormControlElement>() const
+{
+ return static_cast<HTMLFormControlElement*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFormElement.cpp b/Source/WebKit/chromium/src/WebFormElement.cpp
new file mode 100644
index 0000000..6b6e9be
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFormElement.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFormElement.h"
+
+#include "FormState.h"
+#include "HTMLFormControlElement.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "WebFormControlElement.h"
+#include "WebInputElement.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebFormElement::autoComplete() const
+{
+ return constUnwrap<HTMLFormElement>()->autoComplete();
+}
+
+WebString WebFormElement::action() const
+{
+ return constUnwrap<HTMLFormElement>()->action();
+}
+
+WebString WebFormElement::name() const
+{
+ return constUnwrap<HTMLFormElement>()->name();
+}
+
+WebString WebFormElement::method() const
+{
+ return constUnwrap<HTMLFormElement>()->method();
+}
+
+bool WebFormElement::wasUserSubmitted() const
+{
+ return constUnwrap<HTMLFormElement>()->wasUserSubmitted();
+}
+
+void WebFormElement::submit()
+{
+ unwrap<HTMLFormElement>()->submit();
+}
+
+void WebFormElement::getNamedElements(const WebString& name,
+ WebVector<WebNode>& result)
+{
+ Vector<RefPtr<Node> > tempVector;
+ unwrap<HTMLFormElement>()->getNamedElements(name, tempVector);
+ result.assign(tempVector);
+}
+
+void WebFormElement::getFormControlElements(WebVector<WebFormControlElement>& result) const
+{
+ const HTMLFormElement* form = constUnwrap<HTMLFormElement>();
+ Vector<RefPtr<HTMLFormControlElement> > tempVector;
+ // FIXME: We should move the for-loop condition into a variable instead of
+ // re-evaluating size each time. Also, consider refactoring this code so that
+ // we don't call form->associatedElements() multiple times.
+ for (size_t i = 0; i < form->associatedElements().size(); i++) {
+ if (!form->associatedElements()[i]->isFormControlElement())
+ continue;
+ HTMLFormControlElement* element = static_cast<HTMLFormControlElement*>(form->associatedElements()[i]);
+ if (element->hasLocalName(HTMLNames::inputTag)
+ || element->hasLocalName(HTMLNames::selectTag))
+ tempVector.append(element);
+ }
+ result.assign(tempVector);
+}
+
+WebFormElement::WebFormElement(const PassRefPtr<HTMLFormElement>& e)
+ : WebElement(e)
+{
+}
+
+WebFormElement& WebFormElement::operator=(const PassRefPtr<HTMLFormElement>& e)
+{
+ m_private = e;
+ return *this;
+}
+
+WebFormElement::operator PassRefPtr<HTMLFormElement>() const
+{
+ return static_cast<HTMLFormElement*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp
new file mode 100644
index 0000000..8651fa8
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp
@@ -0,0 +1,2304 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// How ownership works
+// -------------------
+//
+// Big oh represents a refcounted relationship: owner O--- ownee
+//
+// WebView (for the toplevel frame only)
+// O
+// |
+// Page O------- Frame (m_mainFrame) O-------O FrameView
+// ||
+// ||
+// FrameLoader O-------- WebFrame (via FrameLoaderClient)
+//
+// FrameLoader and Frame are formerly one object that was split apart because
+// it got too big. They basically have the same lifetime, hence the double line.
+//
+// WebFrame is refcounted and has one ref on behalf of the FrameLoader/Frame.
+// This is not a normal reference counted pointer because that would require
+// changing WebKit code that we don't control. Instead, it is created with this
+// ref initially and it is removed when the FrameLoader is getting destroyed.
+//
+// WebFrames are created in two places, first in WebViewImpl when the root
+// frame is created, and second in WebFrame::CreateChildFrame when sub-frames
+// are created. WebKit will hook up this object to the FrameLoader/Frame
+// and the refcount will be correct.
+//
+// How frames are destroyed
+// ------------------------
+//
+// The main frame is never destroyed and is re-used. The FrameLoader is re-used
+// and a reference to the main frame is kept by the Page.
+//
+// When frame content is replaced, all subframes are destroyed. This happens
+// in FrameLoader::detachFromParent for each subframe.
+//
+// Frame going away causes the FrameLoader to get deleted. In FrameLoader's
+// destructor, it notifies its client with frameLoaderDestroyed. This calls
+// WebFrame::Closing and then derefs the WebFrame and will cause it to be
+// deleted (unless an external someone is also holding a reference).
+
+#include "config.h"
+#include "WebFrameImpl.h"
+
+#include "AssociatedURLLoader.h"
+#include "BackForwardController.h"
+#include "Chrome.h"
+#include "ClipboardUtilitiesChromium.h"
+#include "Console.h"
+#include "DOMUtilitiesPrivate.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "DocumentFragment.h" // Only needed for ReplaceSelectionCommand.h :(
+#include "DocumentLoader.h"
+#include "DocumentMarker.h"
+#include "DocumentMarkerController.h"
+#include "Editor.h"
+#include "EventHandler.h"
+#include "FormState.h"
+#include "FrameLoadRequest.h"
+#include "FrameLoader.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "HTMLCollection.h"
+#include "HTMLFormElement.h"
+#include "HTMLFrameOwnerElement.h"
+#include "HTMLHeadElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLLinkElement.h"
+#include "HTMLNames.h"
+#include "HistoryItem.h"
+#include "InspectorController.h"
+#include "Page.h"
+#include "Performance.h"
+#include "PlatformBridge.h"
+#include "PlatformContextSkia.h"
+#include "PluginDocument.h"
+#include "PrintContext.h"
+#include "RenderFrame.h"
+#include "RenderObject.h"
+#include "RenderTreeAsText.h"
+#include "RenderView.h"
+#include "RenderWidget.h"
+#include "ReplaceSelectionCommand.h"
+#include "ResourceHandle.h"
+#include "ResourceRequest.h"
+#include "SVGDocumentExtensions.h"
+#include "SVGSMILElement.h"
+#include "ScriptController.h"
+#include "ScriptSourceCode.h"
+#include "ScriptValue.h"
+#include "ScrollTypes.h"
+#include "ScrollbarTheme.h"
+#include "SelectionController.h"
+#include "Settings.h"
+#include "SkiaUtils.h"
+#include "SubstituteData.h"
+#include "TextAffinity.h"
+#include "TextIterator.h"
+#include "WebAnimationControllerImpl.h"
+#include "WebConsoleMessage.h"
+#include "WebDataSourceImpl.h"
+#include "WebDocument.h"
+#include "WebFindOptions.h"
+#include "WebFormElement.h"
+#include "WebFrameClient.h"
+#include "WebHistoryItem.h"
+#include "WebInputElement.h"
+#include "WebNode.h"
+#include "WebPasswordAutocompleteListener.h"
+#include "WebPerformance.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebRange.h"
+#include "WebRect.h"
+#include "WebScriptSource.h"
+#include "WebSecurityOrigin.h"
+#include "WebSize.h"
+#include "WebURLError.h"
+#include "WebVector.h"
+#include "WebViewImpl.h"
+#include "XPathResult.h"
+#include "markup.h"
+
+#include <algorithm>
+#include <wtf/CurrentTime.h>
+
+#if OS(DARWIN)
+#include "LocalCurrentGraphicsContext.h"
+#endif
+
+#if OS(LINUX) || OS(FREEBSD)
+#include <gdk/gdk.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static int frameCount = 0;
+
+// Key for a StatsCounter tracking how many WebFrames are active.
+static const char* const webFrameActiveCount = "WebFrameActiveCount";
+
+static const char* const osdType = "application/opensearchdescription+xml";
+static const char* const osdRel = "search";
+
+// Backend for contentAsPlainText, this is a recursive function that gets
+// the text for the current frame and all of its subframes. It will append
+// the text of each frame in turn to the |output| up to |maxChars| length.
+//
+// The |frame| must be non-null.
+static void frameContentAsPlainText(size_t maxChars, Frame* frame,
+ Vector<UChar>* output)
+{
+ Document* doc = frame->document();
+ if (!doc)
+ return;
+
+ if (!frame->view())
+ return;
+
+ // TextIterator iterates over the visual representation of the DOM. As such,
+ // it requires you to do a layout before using it (otherwise it'll crash).
+ if (frame->view()->needsLayout())
+ frame->view()->layout();
+
+ // Select the document body.
+ RefPtr<Range> range(doc->createRange());
+ ExceptionCode exception = 0;
+ range->selectNodeContents(doc->body(), exception);
+
+ if (!exception) {
+ // The text iterator will walk nodes giving us text. This is similar to
+ // the plainText() function in TextIterator.h, but we implement the maximum
+ // size and also copy the results directly into a wstring, avoiding the
+ // string conversion.
+ for (TextIterator it(range.get()); !it.atEnd(); it.advance()) {
+ const UChar* chars = it.characters();
+ if (!chars) {
+ if (it.length()) {
+ // It appears from crash reports that an iterator can get into a state
+ // where the character count is nonempty but the character pointer is
+ // null. advance()ing it will then just add that many to the null
+ // pointer which won't be caught in a null check but will crash.
+ //
+ // A null pointer and 0 length is common for some nodes.
+ //
+ // IF YOU CATCH THIS IN A DEBUGGER please let brettw know. We don't
+ // currently understand the conditions for this to occur. Ideally, the
+ // iterators would never get into the condition so we should fix them
+ // if we can.
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ // Just got a null node, we can forge ahead!
+ continue;
+ }
+ size_t toAppend =
+ std::min(static_cast<size_t>(it.length()), maxChars - output->size());
+ output->append(chars, toAppend);
+ if (output->size() >= maxChars)
+ return; // Filled up the buffer.
+ }
+ }
+
+ // The separator between frames when the frames are converted to plain text.
+ const UChar frameSeparator[] = { '\n', '\n' };
+ const size_t frameSeparatorLen = 2;
+
+ // Recursively walk the children.
+ FrameTree* frameTree = frame->tree();
+ for (Frame* curChild = frameTree->firstChild(); curChild; curChild = curChild->tree()->nextSibling()) {
+ // Ignore the text of non-visible frames.
+ RenderView* contentRenderer = curChild->contentRenderer();
+ RenderPart* ownerRenderer = curChild->ownerRenderer();
+ if (!contentRenderer || !contentRenderer->width() || !contentRenderer->height()
+ || (contentRenderer->x() + contentRenderer->width() <= 0) || (contentRenderer->y() + contentRenderer->height() <= 0)
+ || (ownerRenderer && ownerRenderer->style() && ownerRenderer->style()->visibility() != VISIBLE)) {
+ continue;
+ }
+
+ // Make sure the frame separator won't fill up the buffer, and give up if
+ // it will. The danger is if the separator will make the buffer longer than
+ // maxChars. This will cause the computation above:
+ // maxChars - output->size()
+ // to be a negative number which will crash when the subframe is added.
+ if (output->size() >= maxChars - frameSeparatorLen)
+ return;
+
+ output->append(frameSeparator, frameSeparatorLen);
+ frameContentAsPlainText(maxChars, curChild, output);
+ if (output->size() >= maxChars)
+ return; // Filled up the buffer.
+ }
+}
+
+static long long generateFrameIdentifier()
+{
+ static long long next = 0;
+ return ++next;
+}
+
+WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(Frame* frame)
+{
+ if (!frame)
+ return 0;
+ if (!frame->document() || !frame->document()->isPluginDocument())
+ return 0;
+ PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->document());
+ return static_cast<WebPluginContainerImpl *>(pluginDocument->pluginWidget());
+}
+
+// Simple class to override some of PrintContext behavior. Some of the methods
+// made virtual so that they can be overriden by ChromePluginPrintContext.
+class ChromePrintContext : public PrintContext {
+ WTF_MAKE_NONCOPYABLE(ChromePrintContext);
+public:
+ ChromePrintContext(Frame* frame)
+ : PrintContext(frame)
+ , m_printedPageWidth(0)
+ {
+ }
+
+ virtual void begin(float width, float height)
+ {
+ ASSERT(!m_printedPageWidth);
+ m_printedPageWidth = width;
+ PrintContext::begin(m_printedPageWidth, height);
+ }
+
+ virtual void end()
+ {
+ PrintContext::end();
+ }
+
+ virtual float getPageShrink(int pageNumber) const
+ {
+ IntRect pageRect = m_pageRects[pageNumber];
+ return m_printedPageWidth / pageRect.width();
+ }
+
+ // Spools the printed page, a subrect of m_frame. Skip the scale step.
+ // NativeTheme doesn't play well with scaling. Scaling is done browser side
+ // instead. Returns the scale to be applied.
+ // On Linux, we don't have the problem with NativeTheme, hence we let WebKit
+ // do the scaling and ignore the return value.
+ virtual float spoolPage(GraphicsContext& ctx, int pageNumber)
+ {
+ IntRect pageRect = m_pageRects[pageNumber];
+ float scale = m_printedPageWidth / pageRect.width();
+
+ ctx.save();
+#if OS(LINUX) || OS(FREEBSD)
+ ctx.scale(WebCore::FloatSize(scale, scale));
+#endif
+ ctx.translate(static_cast<float>(-pageRect.x()),
+ static_cast<float>(-pageRect.y()));
+ ctx.clip(pageRect);
+ m_frame->view()->paintContents(&ctx, pageRect);
+ ctx.restore();
+ return scale;
+ }
+
+ virtual void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
+ {
+ return PrintContext::computePageRects(printRect, headerHeight, footerHeight, userScaleFactor, outPageHeight);
+ }
+
+ virtual int pageCount() const
+ {
+ return PrintContext::pageCount();
+ }
+
+ virtual bool shouldUseBrowserOverlays() const
+ {
+ return true;
+ }
+
+private:
+ // Set when printing.
+ float m_printedPageWidth;
+};
+
+// Simple class to override some of PrintContext behavior. This is used when
+// the frame hosts a plugin that supports custom printing. In this case, we
+// want to delegate all printing related calls to the plugin.
+class ChromePluginPrintContext : public ChromePrintContext {
+public:
+ ChromePluginPrintContext(Frame* frame, WebPluginContainerImpl* plugin, int printerDPI)
+ : ChromePrintContext(frame), m_plugin(plugin), m_pageCount(0), m_printerDPI(printerDPI)
+ {
+ }
+
+ virtual void begin(float width)
+ {
+ }
+
+ virtual void end()
+ {
+ m_plugin->printEnd();
+ }
+
+ virtual float getPageShrink(int pageNumber) const
+ {
+ // We don't shrink the page (maybe we should ask the widget ??)
+ return 1.0;
+ }
+
+ virtual void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
+ {
+ m_pageCount = m_plugin->printBegin(IntRect(printRect), m_printerDPI);
+ }
+
+ virtual int pageCount() const
+ {
+ return m_pageCount;
+ }
+
+ // Spools the printed page, a subrect of m_frame. Skip the scale step.
+ // NativeTheme doesn't play well with scaling. Scaling is done browser side
+ // instead. Returns the scale to be applied.
+ virtual float spoolPage(GraphicsContext& ctx, int pageNumber)
+ {
+ m_plugin->printPage(pageNumber, &ctx);
+ return 1.0;
+ }
+
+ virtual bool shouldUseBrowserOverlays() const
+ {
+ return false;
+ }
+
+private:
+ // Set when printing.
+ WebPluginContainerImpl* m_plugin;
+ int m_pageCount;
+ int m_printerDPI;
+};
+
+static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader)
+{
+ return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0;
+}
+
+
+// WebFrame -------------------------------------------------------------------
+
+class WebFrameImpl::DeferredScopeStringMatches {
+public:
+ DeferredScopeStringMatches(WebFrameImpl* webFrame,
+ int identifier,
+ const WebString& searchText,
+ const WebFindOptions& options,
+ bool reset)
+ : m_timer(this, &DeferredScopeStringMatches::doTimeout)
+ , m_webFrame(webFrame)
+ , m_identifier(identifier)
+ , m_searchText(searchText)
+ , m_options(options)
+ , m_reset(reset)
+ {
+ m_timer.startOneShot(0.0);
+ }
+
+private:
+ void doTimeout(Timer<DeferredScopeStringMatches>*)
+ {
+ m_webFrame->callScopeStringMatches(
+ this, m_identifier, m_searchText, m_options, m_reset);
+ }
+
+ Timer<DeferredScopeStringMatches> m_timer;
+ RefPtr<WebFrameImpl> m_webFrame;
+ int m_identifier;
+ WebString m_searchText;
+ WebFindOptions m_options;
+ bool m_reset;
+};
+
+
+// WebFrame -------------------------------------------------------------------
+
+int WebFrame::instanceCount()
+{
+ return frameCount;
+}
+
+WebFrame* WebFrame::frameForEnteredContext()
+{
+ Frame* frame =
+ ScriptController::retrieveFrameForEnteredContext();
+ return WebFrameImpl::fromFrame(frame);
+}
+
+WebFrame* WebFrame::frameForCurrentContext()
+{
+ Frame* frame =
+ ScriptController::retrieveFrameForCurrentContext();
+ return WebFrameImpl::fromFrame(frame);
+}
+
+WebFrame* WebFrame::fromFrameOwnerElement(const WebElement& element)
+{
+ return WebFrameImpl::fromFrameOwnerElement(
+ PassRefPtr<Element>(element).get());
+}
+
+WebString WebFrameImpl::name() const
+{
+ return m_frame->tree()->uniqueName();
+}
+
+void WebFrameImpl::setName(const WebString& name)
+{
+ m_frame->tree()->setName(name);
+}
+
+long long WebFrameImpl::identifier() const
+{
+ return m_identifier;
+}
+
+WebURL WebFrameImpl::url() const
+{
+ const WebDataSource* ds = dataSource();
+ if (!ds)
+ return WebURL();
+ return ds->request().url();
+}
+
+WebURL WebFrameImpl::favIconURL() const
+{
+ FrameLoader* frameLoader = m_frame->loader();
+ // The URL to the favicon may be in the header. As such, only
+ // ask the loader for the favicon if it's finished loading.
+ if (frameLoader->state() == FrameStateComplete) {
+ const KURL& url = frameLoader->iconURL();
+ if (!url.isEmpty())
+ return url;
+ }
+ return WebURL();
+}
+
+WebURL WebFrameImpl::openSearchDescriptionURL() const
+{
+ FrameLoader* frameLoader = m_frame->loader();
+ if (frameLoader->state() == FrameStateComplete
+ && m_frame->document() && m_frame->document()->head()
+ && !m_frame->tree()->parent()) {
+ HTMLHeadElement* head = m_frame->document()->head();
+ if (head) {
+ RefPtr<HTMLCollection> children = head->children();
+ for (Node* child = children->firstItem(); child; child = children->nextItem()) {
+ HTMLLinkElement* linkElement = toHTMLLinkElement(child);
+ if (linkElement
+ && linkElement->type() == osdType
+ && linkElement->rel() == osdRel
+ && !linkElement->href().isEmpty())
+ return linkElement->href();
+ }
+ }
+ }
+ return WebURL();
+}
+
+WebString WebFrameImpl::encoding() const
+{
+ return frame()->loader()->writer()->encoding();
+}
+
+WebSize WebFrameImpl::scrollOffset() const
+{
+ FrameView* view = frameView();
+ if (view)
+ return view->scrollOffset();
+
+ return WebSize();
+}
+
+WebSize WebFrameImpl::contentsSize() const
+{
+ return frame()->view()->contentsSize();
+}
+
+int WebFrameImpl::contentsPreferredWidth() const
+{
+ if (m_frame->document() && m_frame->document()->renderView())
+ return m_frame->document()->renderView()->minPreferredLogicalWidth();
+ return 0;
+}
+
+int WebFrameImpl::documentElementScrollHeight() const
+{
+ if (m_frame->document() && m_frame->document()->documentElement())
+ return m_frame->document()->documentElement()->scrollHeight();
+ return 0;
+}
+
+bool WebFrameImpl::hasVisibleContent() const
+{
+ return frame()->view()->visibleWidth() > 0 && frame()->view()->visibleHeight() > 0;
+}
+
+WebView* WebFrameImpl::view() const
+{
+ return viewImpl();
+}
+
+WebFrame* WebFrameImpl::opener() const
+{
+ Frame* opener = 0;
+ if (m_frame)
+ opener = m_frame->loader()->opener();
+ return fromFrame(opener);
+}
+
+WebFrame* WebFrameImpl::parent() const
+{
+ Frame* parent = 0;
+ if (m_frame)
+ parent = m_frame->tree()->parent();
+ return fromFrame(parent);
+}
+
+WebFrame* WebFrameImpl::top() const
+{
+ if (m_frame)
+ return fromFrame(m_frame->tree()->top());
+
+ return 0;
+}
+
+WebFrame* WebFrameImpl::firstChild() const
+{
+ return fromFrame(frame()->tree()->firstChild());
+}
+
+WebFrame* WebFrameImpl::lastChild() const
+{
+ return fromFrame(frame()->tree()->lastChild());
+}
+
+WebFrame* WebFrameImpl::nextSibling() const
+{
+ return fromFrame(frame()->tree()->nextSibling());
+}
+
+WebFrame* WebFrameImpl::previousSibling() const
+{
+ return fromFrame(frame()->tree()->previousSibling());
+}
+
+WebFrame* WebFrameImpl::traverseNext(bool wrap) const
+{
+ return fromFrame(frame()->tree()->traverseNextWithWrap(wrap));
+}
+
+WebFrame* WebFrameImpl::traversePrevious(bool wrap) const
+{
+ return fromFrame(frame()->tree()->traversePreviousWithWrap(wrap));
+}
+
+WebFrame* WebFrameImpl::findChildByName(const WebString& name) const
+{
+ return fromFrame(frame()->tree()->child(name));
+}
+
+WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const
+{
+ if (xpath.isEmpty())
+ return 0;
+
+ Document* document = m_frame->document();
+
+ ExceptionCode ec = 0;
+ PassRefPtr<XPathResult> xpathResult =
+ document->evaluate(xpath,
+ document,
+ 0, // namespace
+ XPathResult::ORDERED_NODE_ITERATOR_TYPE,
+ 0, // XPathResult object
+ ec);
+ if (!xpathResult.get())
+ return 0;
+
+ Node* node = xpathResult->iterateNext(ec);
+
+ if (!node || !node->isFrameOwnerElement())
+ return 0;
+ HTMLFrameOwnerElement* frameElement =
+ static_cast<HTMLFrameOwnerElement*>(node);
+ return fromFrame(frameElement->contentFrame());
+}
+
+WebDocument WebFrameImpl::document() const
+{
+ if (!m_frame || !m_frame->document())
+ return WebDocument();
+ return WebDocument(m_frame->document());
+}
+
+void WebFrameImpl::forms(WebVector<WebFormElement>& results) const
+{
+ if (!m_frame)
+ return;
+
+ RefPtr<HTMLCollection> forms = m_frame->document()->forms();
+ size_t formCount = 0;
+ for (size_t i = 0; i < forms->length(); ++i) {
+ Node* node = forms->item(i);
+ if (node && node->isHTMLElement())
+ ++formCount;
+ }
+
+ WebVector<WebFormElement> temp(formCount);
+ for (size_t i = 0; i < formCount; ++i) {
+ Node* node = forms->item(i);
+ // Strange but true, sometimes item can be 0.
+ if (node && node->isHTMLElement())
+ temp[i] = static_cast<HTMLFormElement*>(node);
+ }
+ results.swap(temp);
+}
+
+WebAnimationController* WebFrameImpl::animationController()
+{
+ return &m_animationController;
+}
+
+WebPerformance WebFrameImpl::performance() const
+{
+ if (!m_frame || !m_frame->domWindow())
+ return WebPerformance();
+
+ return WebPerformance(m_frame->domWindow()->performance());
+}
+
+WebSecurityOrigin WebFrameImpl::securityOrigin() const
+{
+ if (!m_frame || !m_frame->document())
+ return WebSecurityOrigin();
+
+ return WebSecurityOrigin(m_frame->document()->securityOrigin());
+}
+
+void WebFrameImpl::grantUniversalAccess()
+{
+ ASSERT(m_frame && m_frame->document());
+ if (m_frame && m_frame->document())
+ m_frame->document()->securityOrigin()->grantUniversalAccess();
+}
+
+NPObject* WebFrameImpl::windowObject() const
+{
+ if (!m_frame)
+ return 0;
+
+ return m_frame->script()->windowScriptNPObject();
+}
+
+void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object)
+{
+ ASSERT(m_frame);
+ if (!m_frame || !m_frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+ return;
+
+ String key = name;
+#if USE(V8)
+ m_frame->script()->bindToWindowObject(m_frame, key, object);
+#else
+ notImplemented();
+#endif
+}
+
+void WebFrameImpl::executeScript(const WebScriptSource& source)
+{
+ TextPosition1 position(WTF::OneBasedNumber::fromOneBasedInt(source.startLine), WTF::OneBasedNumber::base());
+ m_frame->script()->executeScript(
+ ScriptSourceCode(source.code, source.url, position));
+}
+
+void WebFrameImpl::executeScriptInIsolatedWorld(
+ int worldId, const WebScriptSource* sourcesIn, unsigned numSources,
+ int extensionGroup)
+{
+ Vector<ScriptSourceCode> sources;
+
+ for (unsigned i = 0; i < numSources; ++i) {
+ TextPosition1 position(WTF::OneBasedNumber::fromOneBasedInt(sourcesIn[i].startLine), WTF::OneBasedNumber::base());
+ sources.append(ScriptSourceCode(
+ sourcesIn[i].code, sourcesIn[i].url, position));
+ }
+
+ m_frame->script()->evaluateInIsolatedWorld(worldId, sources, extensionGroup);
+}
+
+void WebFrameImpl::addMessageToConsole(const WebConsoleMessage& message)
+{
+ ASSERT(frame());
+
+ MessageLevel webCoreMessageLevel;
+ switch (message.level) {
+ case WebConsoleMessage::LevelTip:
+ webCoreMessageLevel = TipMessageLevel;
+ break;
+ case WebConsoleMessage::LevelLog:
+ webCoreMessageLevel = LogMessageLevel;
+ break;
+ case WebConsoleMessage::LevelWarning:
+ webCoreMessageLevel = WarningMessageLevel;
+ break;
+ case WebConsoleMessage::LevelError:
+ webCoreMessageLevel = ErrorMessageLevel;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ frame()->domWindow()->console()->addMessage(
+ OtherMessageSource, LogMessageType, webCoreMessageLevel, message.text,
+ 1, String());
+}
+
+void WebFrameImpl::collectGarbage()
+{
+ if (!m_frame)
+ return;
+ if (!m_frame->settings()->isJavaScriptEnabled())
+ return;
+ // FIXME: Move this to the ScriptController and make it JS neutral.
+#if USE(V8)
+ m_frame->script()->collectGarbage();
+#else
+ notImplemented();
+#endif
+}
+
+#if USE(V8)
+v8::Handle<v8::Value> WebFrameImpl::executeScriptAndReturnValue(
+ const WebScriptSource& source)
+{
+ TextPosition1 position(WTF::OneBasedNumber::fromOneBasedInt(source.startLine), WTF::OneBasedNumber::base());
+ return m_frame->script()->executeScript(
+ ScriptSourceCode(source.code, source.url, position)).v8Value();
+}
+
+// Returns the V8 context for this frame, or an empty handle if there is none.
+v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const
+{
+ if (!m_frame)
+ return v8::Local<v8::Context>();
+
+ return V8Proxy::mainWorldContext(m_frame);
+}
+#endif
+
+bool WebFrameImpl::insertStyleText(
+ const WebString& css, const WebString& id) {
+ Document* document = frame()->document();
+ if (!document)
+ return false;
+ Element* documentElement = document->documentElement();
+ if (!documentElement)
+ return false;
+
+ ExceptionCode err = 0;
+
+ if (!id.isEmpty()) {
+ Element* oldElement = document->getElementById(id);
+ if (oldElement) {
+ Node* parent = oldElement->parentNode();
+ if (!parent)
+ return false;
+ parent->removeChild(oldElement, err);
+ }
+ }
+
+ RefPtr<Element> stylesheet = document->createElement(
+ HTMLNames::styleTag, false);
+ if (!id.isEmpty())
+ stylesheet->setAttribute(HTMLNames::idAttr, id);
+ stylesheet->setTextContent(css, err);
+ ASSERT(!err);
+ Node* first = documentElement->firstChild();
+ bool success = documentElement->insertBefore(stylesheet, first, err);
+ ASSERT(success);
+ return success;
+}
+
+void WebFrameImpl::reload(bool ignoreCache)
+{
+ m_frame->loader()->history()->saveDocumentAndScrollState();
+ m_frame->loader()->reload(ignoreCache);
+}
+
+void WebFrameImpl::loadRequest(const WebURLRequest& request)
+{
+ ASSERT(!request.isNull());
+ const ResourceRequest& resourceRequest = request.toResourceRequest();
+
+ if (resourceRequest.url().protocolIs("javascript")) {
+ loadJavaScriptURL(resourceRequest.url());
+ return;
+ }
+
+ m_frame->loader()->load(resourceRequest, false);
+}
+
+void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item)
+{
+ RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item);
+ ASSERT(historyItem.get());
+
+ // Sanity check for http://webkit.org/b/52819. It appears that some child
+ // items of this item might be null. Try validating just the first set of
+ // children in an attempt to catch it early.
+ const HistoryItemVector& childItems = historyItem->children();
+ int size = childItems.size();
+ for (int i = 0; i < size; ++i) {
+ RefPtr<HistoryItem> childItem = childItems[i].get();
+ if (!childItem.get())
+ CRASH();
+ }
+
+ // If there is no currentItem, which happens when we are navigating in
+ // session history after a crash, we need to manufacture one otherwise WebKit
+ // hoarks. This is probably the wrong thing to do, but it seems to work.
+ RefPtr<HistoryItem> currentItem = m_frame->loader()->history()->currentItem();
+ if (!currentItem) {
+ currentItem = HistoryItem::create();
+ currentItem->setLastVisitWasFailure(true);
+ m_frame->loader()->history()->setCurrentItem(currentItem.get());
+ m_frame->page()->backForward()->setCurrentItem(currentItem.get());
+ }
+
+ m_frame->loader()->history()->goToItem(
+ historyItem.get(), FrameLoadTypeIndexedBackForward);
+}
+
+void WebFrameImpl::loadData(const WebData& data,
+ const WebString& mimeType,
+ const WebString& textEncoding,
+ const WebURL& baseURL,
+ const WebURL& unreachableURL,
+ bool replace)
+{
+ SubstituteData substData(data, mimeType, textEncoding, unreachableURL);
+ ASSERT(substData.isValid());
+
+ // If we are loading substitute data to replace an existing load, then
+ // inherit all of the properties of that original request. This way,
+ // reload will re-attempt the original request. It is essential that
+ // we only do this when there is an unreachableURL since a non-empty
+ // unreachableURL informs FrameLoader::reload to load unreachableURL
+ // instead of the currently loaded URL.
+ ResourceRequest request;
+ if (replace && !unreachableURL.isEmpty())
+ request = m_frame->loader()->originalRequest();
+ request.setURL(baseURL);
+
+ m_frame->loader()->load(request, substData, false);
+ if (replace) {
+ // Do this to force WebKit to treat the load as replacing the currently
+ // loaded page.
+ m_frame->loader()->setReplacing();
+ }
+}
+
+void WebFrameImpl::loadHTMLString(const WebData& data,
+ const WebURL& baseURL,
+ const WebURL& unreachableURL,
+ bool replace)
+{
+ loadData(data,
+ WebString::fromUTF8("text/html"),
+ WebString::fromUTF8("UTF-8"),
+ baseURL,
+ unreachableURL,
+ replace);
+}
+
+bool WebFrameImpl::isLoading() const
+{
+ if (!m_frame)
+ return false;
+ return m_frame->loader()->isLoading();
+}
+
+void WebFrameImpl::stopLoading()
+{
+ if (!m_frame)
+ return;
+
+ // FIXME: Figure out what we should really do here. It seems like a bug
+ // that FrameLoader::stopLoading doesn't call stopAllLoaders.
+ m_frame->loader()->stopAllLoaders();
+ m_frame->loader()->stopLoading(UnloadEventPolicyNone);
+}
+
+WebDataSource* WebFrameImpl::provisionalDataSource() const
+{
+ FrameLoader* frameLoader = m_frame->loader();
+
+ // We regard the policy document loader as still provisional.
+ DocumentLoader* docLoader = frameLoader->provisionalDocumentLoader();
+ if (!docLoader)
+ docLoader = frameLoader->policyDocumentLoader();
+
+ return DataSourceForDocLoader(docLoader);
+}
+
+WebDataSource* WebFrameImpl::dataSource() const
+{
+ return DataSourceForDocLoader(m_frame->loader()->documentLoader());
+}
+
+WebHistoryItem WebFrameImpl::previousHistoryItem() const
+{
+ // We use the previous item here because documentState (filled-out forms)
+ // only get saved to history when it becomes the previous item. The caller
+ // is expected to query the history item after a navigation occurs, after
+ // the desired history item has become the previous entry.
+ return WebHistoryItem(m_frame->loader()->history()->previousItem());
+}
+
+WebHistoryItem WebFrameImpl::currentHistoryItem() const
+{
+ // If we are still loading, then we don't want to clobber the current
+ // history item as this could cause us to lose the scroll position and
+ // document state. However, it is OK for new navigations.
+ if (m_frame->loader()->loadType() == FrameLoadTypeStandard
+ || !m_frame->loader()->activeDocumentLoader()->isLoadingInAPISense())
+ m_frame->loader()->history()->saveDocumentAndScrollState();
+
+ return WebHistoryItem(m_frame->page()->backForward()->currentItem());
+}
+
+void WebFrameImpl::enableViewSourceMode(bool enable)
+{
+ if (m_frame)
+ m_frame->setInViewSourceMode(enable);
+}
+
+bool WebFrameImpl::isViewSourceModeEnabled() const
+{
+ if (m_frame)
+ return m_frame->inViewSourceMode();
+
+ return false;
+}
+
+void WebFrameImpl::setReferrerForRequest(
+ WebURLRequest& request, const WebURL& referrerURL) {
+ String referrer;
+ if (referrerURL.isEmpty())
+ referrer = m_frame->loader()->outgoingReferrer();
+ else
+ referrer = referrerURL.spec().utf16();
+ if (SecurityOrigin::shouldHideReferrer(request.url(), referrer))
+ return;
+ request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer);
+}
+
+void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request)
+{
+ ResourceResponse response;
+ m_frame->loader()->client()->dispatchWillSendRequest(
+ 0, 0, request.toMutableResourceRequest(), response);
+}
+
+WebURLLoader* WebFrameImpl::createAssociatedURLLoader()
+{
+ return new AssociatedURLLoader(this);
+}
+
+void WebFrameImpl::commitDocumentData(const char* data, size_t length)
+{
+ m_frame->loader()->documentLoader()->commitData(data, length);
+}
+
+unsigned WebFrameImpl::unloadListenerCount() const
+{
+ return frame()->domWindow()->pendingUnloadEventListeners();
+}
+
+bool WebFrameImpl::isProcessingUserGesture() const
+{
+ return frame()->loader()->isProcessingUserGesture();
+}
+
+bool WebFrameImpl::willSuppressOpenerInNewFrame() const
+{
+ return frame()->loader()->suppressOpenerInNewFrame();
+}
+
+void WebFrameImpl::replaceSelection(const WebString& text)
+{
+ RefPtr<DocumentFragment> fragment = createFragmentFromText(
+ frame()->selection()->toNormalizedRange().get(), text);
+ applyCommand(ReplaceSelectionCommand::create(
+ frame()->document(), fragment.get(), false, true, true));
+}
+
+void WebFrameImpl::insertText(const WebString& text)
+{
+ Editor* editor = frame()->editor();
+
+ if (editor->hasComposition())
+ editor->confirmComposition(text);
+ else
+ editor->insertText(text, 0);
+}
+
+void WebFrameImpl::setMarkedText(
+ const WebString& text, unsigned location, unsigned length)
+{
+ Editor* editor = frame()->editor();
+
+ Vector<CompositionUnderline> decorations;
+ editor->setComposition(text, decorations, location, length);
+}
+
+void WebFrameImpl::unmarkText()
+{
+ frame()->editor()->confirmCompositionWithoutDisturbingSelection();
+}
+
+bool WebFrameImpl::hasMarkedText() const
+{
+ return frame()->editor()->hasComposition();
+}
+
+WebRange WebFrameImpl::markedRange() const
+{
+ return frame()->editor()->compositionRange();
+}
+
+bool WebFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length, WebRect& rect) const
+{
+ if ((location + length < location) && (location + length))
+ length = 0;
+
+ Element* selectionRoot = frame()->selection()->rootEditableElement();
+ Element* scope = selectionRoot ? selectionRoot : frame()->document()->documentElement();
+ RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, location, length);
+ if (!range)
+ return false;
+ IntRect intRect = frame()->editor()->firstRectForRange(range.get());
+ rect = WebRect(intRect.x(), intRect.y(), intRect.width(), intRect.height());
+
+ return true;
+}
+
+bool WebFrameImpl::executeCommand(const WebString& name)
+{
+ ASSERT(frame());
+
+ if (name.length() <= 2)
+ return false;
+
+ // Since we don't have NSControl, we will convert the format of command
+ // string and call the function on Editor directly.
+ String command = name;
+
+ // Make sure the first letter is upper case.
+ command.replace(0, 1, command.substring(0, 1).upper());
+
+ // Remove the trailing ':' if existing.
+ if (command[command.length() - 1] == UChar(':'))
+ command = command.substring(0, command.length() - 1);
+
+ if (command == "Copy") {
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
+ if (pluginContainer) {
+ pluginContainer->copy();
+ return true;
+ }
+ }
+
+ bool rv = true;
+
+ // Specially handling commands that Editor::execCommand does not directly
+ // support.
+ if (command == "DeleteToEndOfParagraph") {
+ Editor* editor = frame()->editor();
+ if (!editor->deleteWithDirection(DirectionForward,
+ ParagraphBoundary,
+ true,
+ false)) {
+ editor->deleteWithDirection(DirectionForward,
+ CharacterGranularity,
+ true,
+ false);
+ }
+ } else if (command == "Indent")
+ frame()->editor()->indent();
+ else if (command == "Outdent")
+ frame()->editor()->outdent();
+ else if (command == "DeleteBackward")
+ rv = frame()->editor()->command(AtomicString("BackwardDelete")).execute();
+ else if (command == "DeleteForward")
+ rv = frame()->editor()->command(AtomicString("ForwardDelete")).execute();
+ else if (command == "AdvanceToNextMisspelling") {
+ // False must be passed here, or the currently selected word will never be
+ // skipped.
+ frame()->editor()->advanceToNextMisspelling(false);
+ } else if (command == "ToggleSpellPanel")
+ frame()->editor()->showSpellingGuessPanel();
+ else
+ rv = frame()->editor()->command(command).execute();
+ return rv;
+}
+
+bool WebFrameImpl::executeCommand(const WebString& name, const WebString& value)
+{
+ ASSERT(frame());
+ String webName = name;
+
+ // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebKit
+ // for editable nodes.
+ if (!frame()->editor()->canEdit() && webName == "moveToBeginningOfDocument")
+ return viewImpl()->propagateScroll(ScrollUp, ScrollByDocument);
+
+ if (!frame()->editor()->canEdit() && webName == "moveToEndOfDocument")
+ return viewImpl()->propagateScroll(ScrollDown, ScrollByDocument);
+
+ return frame()->editor()->command(webName).execute(value);
+}
+
+bool WebFrameImpl::isCommandEnabled(const WebString& name) const
+{
+ ASSERT(frame());
+ return frame()->editor()->command(name).isEnabled();
+}
+
+void WebFrameImpl::enableContinuousSpellChecking(bool enable)
+{
+ if (enable == isContinuousSpellCheckingEnabled())
+ return;
+ // Note, the editor will will notify the client that the continuous spell
+ // checking state has changed by calling
+ // WebFrameClient::didToggleContinuousSpellChecking().
+ frame()->editor()->toggleContinuousSpellChecking();
+}
+
+bool WebFrameImpl::isContinuousSpellCheckingEnabled() const
+{
+ return frame()->editor()->isContinuousSpellCheckingEnabled();
+}
+
+bool WebFrameImpl::hasSelection() const
+{
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
+ if (pluginContainer)
+ return pluginContainer->plugin()->hasSelection();
+
+ // frame()->selection()->isNone() never returns true.
+ return (frame()->selection()->start() != frame()->selection()->end());
+}
+
+WebRange WebFrameImpl::selectionRange() const
+{
+ return frame()->selection()->toNormalizedRange();
+}
+
+WebString WebFrameImpl::selectionAsText() const
+{
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
+ if (pluginContainer)
+ return pluginContainer->plugin()->selectionAsText();
+
+ RefPtr<Range> range = frame()->selection()->toNormalizedRange();
+ if (!range.get())
+ return WebString();
+
+ String text = range->text();
+#if OS(WINDOWS)
+ replaceNewlinesWithWindowsStyleNewlines(text);
+#endif
+ replaceNBSPWithSpace(text);
+ return text;
+}
+
+WebString WebFrameImpl::selectionAsMarkup() const
+{
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
+ if (pluginContainer)
+ return pluginContainer->plugin()->selectionAsMarkup();
+
+ RefPtr<Range> range = frame()->selection()->toNormalizedRange();
+ if (!range.get())
+ return WebString();
+
+ return createMarkup(range.get(), 0);
+}
+
+void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition pos)
+{
+ VisibleSelection selection(pos);
+ selection.expandUsingGranularity(WordGranularity);
+
+ if (frame->selection()->shouldChangeSelection(selection)) {
+ TextGranularity granularity = selection.isRange() ? WordGranularity : CharacterGranularity;
+ frame->selection()->setSelection(selection, granularity);
+ }
+}
+
+bool WebFrameImpl::selectWordAroundCaret()
+{
+ SelectionController* controller = frame()->selection();
+ ASSERT(!controller->isNone());
+ if (controller->isNone() || controller->isRange())
+ return false;
+ selectWordAroundPosition(frame(), controller->selection().visibleStart());
+ return true;
+}
+
+int WebFrameImpl::printBegin(const WebSize& pageSize,
+ const WebNode& constrainToNode,
+ int printerDPI,
+ bool* useBrowserOverlays)
+{
+ ASSERT(!frame()->document()->isFrameSet());
+ WebPluginContainerImpl* pluginContainer = 0;
+ if (constrainToNode.isNull()) {
+ // If this is a plugin document, check if the plugin supports its own
+ // printing. If it does, we will delegate all printing to that.
+ pluginContainer = pluginContainerFromFrame(frame());
+ } else {
+ // We only support printing plugin nodes for now.
+ const Node* coreNode = constrainToNode.constUnwrap<Node>();
+ if (coreNode->hasTagName(HTMLNames::objectTag) || coreNode->hasTagName(HTMLNames::embedTag)) {
+ RenderObject* object = coreNode->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer())
+ pluginContainer = static_cast<WebPluginContainerImpl*>(widget);
+ }
+ }
+ }
+
+ if (pluginContainer && pluginContainer->supportsPaginatedPrint())
+ m_printContext.set(new ChromePluginPrintContext(frame(), pluginContainer, printerDPI));
+ else
+ m_printContext.set(new ChromePrintContext(frame()));
+
+ FloatRect rect(0, 0, static_cast<float>(pageSize.width),
+ static_cast<float>(pageSize.height));
+ m_printContext->begin(rect.width(), rect.height());
+ float pageHeight;
+ // We ignore the overlays calculation for now since they are generated in the
+ // browser. pageHeight is actually an output parameter.
+ m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight);
+ if (useBrowserOverlays)
+ *useBrowserOverlays = m_printContext->shouldUseBrowserOverlays();
+
+ return m_printContext->pageCount();
+}
+
+float WebFrameImpl::getPrintPageShrink(int page)
+{
+ // Ensure correct state.
+ if (!m_printContext.get() || page < 0) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+
+ return m_printContext->getPageShrink(page);
+}
+
+float WebFrameImpl::printPage(int page, WebCanvas* canvas)
+{
+ // Ensure correct state.
+ if (!m_printContext.get() || page < 0 || !frame() || !frame()->document()) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+
+#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD) || OS(SOLARIS)
+ PlatformContextSkia context(canvas);
+ GraphicsContext spool(&context);
+#elif OS(DARWIN)
+ GraphicsContext spool(canvas);
+ LocalCurrentGraphicsContext localContext(&spool);
+#endif
+
+ return m_printContext->spoolPage(spool, page);
+}
+
+void WebFrameImpl::printEnd()
+{
+ ASSERT(m_printContext.get());
+ if (m_printContext.get())
+ m_printContext->end();
+ m_printContext.clear();
+}
+
+bool WebFrameImpl::isPageBoxVisible(int pageIndex)
+{
+ return frame()->document()->isPageBoxVisible(pageIndex);
+}
+
+void WebFrameImpl::pageSizeAndMarginsInPixels(int pageIndex,
+ WebSize& pageSize,
+ int& marginTop,
+ int& marginRight,
+ int& marginBottom,
+ int& marginLeft)
+{
+ IntSize size(pageSize.width, pageSize.height);
+ frame()->document()->pageSizeAndMarginsInPixels(pageIndex,
+ size,
+ marginTop,
+ marginRight,
+ marginBottom,
+ marginLeft);
+ pageSize = size;
+}
+
+bool WebFrameImpl::find(int identifier,
+ const WebString& searchText,
+ const WebFindOptions& options,
+ bool wrapWithinFrame,
+ WebRect* selectionRect)
+{
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+
+ if (!options.findNext)
+ frame()->page()->unmarkAllTextMatches();
+ else
+ setMarkerActive(m_activeMatch.get(), false); // Active match is changing.
+
+ // Starts the search from the current selection.
+ bool startInSelection = true;
+
+ // If the user has selected something since the last Find operation we want
+ // to start from there. Otherwise, we start searching from where the last Find
+ // operation left off (either a Find or a FindNext operation).
+ VisibleSelection selection(frame()->selection()->selection());
+ bool activeSelection = !selection.isNone();
+ if (!activeSelection && m_activeMatch) {
+ selection = VisibleSelection(m_activeMatch.get());
+ frame()->selection()->setSelection(selection);
+ }
+
+ ASSERT(frame() && frame()->view());
+ bool found = frame()->editor()->findString(
+ searchText, options.forward, options.matchCase, wrapWithinFrame,
+ startInSelection);
+ if (found) {
+ // Store which frame was active. This will come in handy later when we
+ // change the active match ordinal below.
+ WebFrameImpl* oldActiveFrame = mainFrameImpl->m_activeMatchFrame;
+ // Set this frame as the active frame (the one with the active highlight).
+ mainFrameImpl->m_activeMatchFrame = this;
+
+ // We found something, so we can now query the selection for its position.
+ VisibleSelection newSelection(frame()->selection()->selection());
+ IntRect currSelectionRect;
+
+ // If we thought we found something, but it couldn't be selected (perhaps
+ // because it was marked -webkit-user-select: none), we can't set it to
+ // be active but we still continue searching. This matches Safari's
+ // behavior, including some oddities when selectable and un-selectable text
+ // are mixed on a page: see https://bugs.webkit.org/show_bug.cgi?id=19127.
+ if (newSelection.isNone() || (newSelection.start() == newSelection.end()))
+ m_activeMatch = 0;
+ else {
+ m_activeMatch = newSelection.toNormalizedRange();
+ currSelectionRect = m_activeMatch->boundingBox();
+ setMarkerActive(m_activeMatch.get(), true); // Active.
+ // WebKit draws the highlighting for all matches.
+ executeCommand(WebString::fromUTF8("Unselect"));
+ }
+
+ // Make sure no node is focused. See http://crbug.com/38700.
+ frame()->document()->setFocusedNode(0);
+
+ if (!options.findNext || activeSelection) {
+ // This is either a Find operation or a Find-next from a new start point
+ // due to a selection, so we set the flag to ask the scoping effort
+ // to find the active rect for us so we can update the ordinal (n of m).
+ m_locatingActiveRect = true;
+ } else {
+ if (oldActiveFrame != this) {
+ // If the active frame has changed it means that we have a multi-frame
+ // page and we just switch to searching in a new frame. Then we just
+ // want to reset the index.
+ if (options.forward)
+ m_activeMatchIndex = 0;
+ else
+ m_activeMatchIndex = m_lastMatchCount - 1;
+ } else {
+ // We are still the active frame, so increment (or decrement) the
+ // |m_activeMatchIndex|, wrapping if needed (on single frame pages).
+ options.forward ? ++m_activeMatchIndex : --m_activeMatchIndex;
+ if (m_activeMatchIndex + 1 > m_lastMatchCount)
+ m_activeMatchIndex = 0;
+ if (m_activeMatchIndex == -1)
+ m_activeMatchIndex = m_lastMatchCount - 1;
+ }
+ if (selectionRect) {
+ WebRect rect = frame()->view()->convertToContainingWindow(currSelectionRect);
+ rect.x -= frameView()->scrollOffset().width();
+ rect.y -= frameView()->scrollOffset().height();
+ *selectionRect = rect;
+
+ reportFindInPageSelection(rect, m_activeMatchIndex + 1, identifier);
+ }
+ }
+ } else {
+ // Nothing was found in this frame.
+ m_activeMatch = 0;
+
+ // Erase all previous tickmarks and highlighting.
+ invalidateArea(InvalidateAll);
+ }
+
+ return found;
+}
+
+void WebFrameImpl::stopFinding(bool clearSelection)
+{
+ if (!clearSelection)
+ setFindEndstateFocusAndSelection();
+ cancelPendingScopingEffort();
+
+ // Remove all markers for matches found and turn off the highlighting.
+ frame()->document()->markers()->removeMarkers(DocumentMarker::TextMatch);
+ frame()->editor()->setMarkedTextMatchesAreHighlighted(false);
+
+ // Let the frame know that we don't want tickmarks or highlighting anymore.
+ invalidateArea(InvalidateAll);
+}
+
+void WebFrameImpl::scopeStringMatches(int identifier,
+ const WebString& searchText,
+ const WebFindOptions& options,
+ bool reset)
+{
+ if (!shouldScopeMatches(searchText))
+ return;
+
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+
+ if (reset) {
+ // This is a brand new search, so we need to reset everything.
+ // Scoping is just about to begin.
+ m_scopingComplete = false;
+ // Clear highlighting for this frame.
+ if (frame()->editor()->markedTextMatchesAreHighlighted())
+ frame()->page()->unmarkAllTextMatches();
+ // Clear the counters from last operation.
+ m_lastMatchCount = 0;
+ m_nextInvalidateAfter = 0;
+
+ m_resumeScopingFromRange = 0;
+
+ mainFrameImpl->m_framesScopingCount++;
+
+ // Now, defer scoping until later to allow find operation to finish quickly.
+ scopeStringMatchesSoon(
+ identifier,
+ searchText,
+ options,
+ false); // false=we just reset, so don't do it again.
+ return;
+ }
+
+ RefPtr<Range> searchRange(rangeOfContents(frame()->document()));
+
+ ExceptionCode ec = 0, ec2 = 0;
+ if (m_resumeScopingFromRange.get()) {
+ // This is a continuation of a scoping operation that timed out and didn't
+ // complete last time around, so we should start from where we left off.
+ searchRange->setStart(m_resumeScopingFromRange->startContainer(),
+ m_resumeScopingFromRange->startOffset(ec2) + 1,
+ ec);
+ if (ec || ec2) {
+ if (ec2) // A non-zero |ec| happens when navigating during search.
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ }
+
+ Node* originalEndContainer = searchRange->endContainer();
+ int originalEndOffset = searchRange->endOffset();
+
+ // This timeout controls how long we scope before releasing control. This
+ // value does not prevent us from running for longer than this, but it is
+ // periodically checked to see if we have exceeded our allocated time.
+ const double maxScopingDuration = 0.1; // seconds
+
+ int matchCount = 0;
+ bool timedOut = false;
+ double startTime = currentTime();
+ do {
+ // Find next occurrence of the search string.
+ // FIXME: (http://b/1088245) This WebKit operation may run for longer
+ // than the timeout value, and is not interruptible as it is currently
+ // written. We may need to rewrite it with interruptibility in mind, or
+ // find an alternative.
+ RefPtr<Range> resultRange(findPlainText(searchRange.get(),
+ searchText,
+ true,
+ options.matchCase));
+ if (resultRange->collapsed(ec)) {
+ if (!resultRange->startContainer()->isInShadowTree())
+ break;
+
+ searchRange->setStartAfter(
+ resultRange->startContainer()->shadowAncestorNode(), ec);
+ searchRange->setEnd(originalEndContainer, originalEndOffset, ec);
+ continue;
+ }
+
+ // Only treat the result as a match if it is visible
+ if (frame()->editor()->insideVisibleArea(resultRange.get())) {
+ ++matchCount;
+
+ // Catch a special case where Find found something but doesn't know what
+ // the bounding box for it is. In this case we set the first match we find
+ // as the active rect.
+ IntRect resultBounds = resultRange->boundingBox();
+ IntRect activeSelectionRect;
+ if (m_locatingActiveRect) {
+ activeSelectionRect = m_activeMatch.get() ?
+ m_activeMatch->boundingBox() : resultBounds;
+ }
+
+ // If the Find function found a match it will have stored where the
+ // match was found in m_activeSelectionRect on the current frame. If we
+ // find this rect during scoping it means we have found the active
+ // tickmark.
+ bool foundActiveMatch = false;
+ if (m_locatingActiveRect && (activeSelectionRect == resultBounds)) {
+ // We have found the active tickmark frame.
+ mainFrameImpl->m_activeMatchFrame = this;
+ foundActiveMatch = true;
+ // We also know which tickmark is active now.
+ m_activeMatchIndex = matchCount - 1;
+ // To stop looking for the active tickmark, we set this flag.
+ m_locatingActiveRect = false;
+
+ // Notify browser of new location for the selected rectangle.
+ resultBounds.move(-frameView()->scrollOffset().width(),
+ -frameView()->scrollOffset().height());
+ reportFindInPageSelection(
+ frame()->view()->convertToContainingWindow(resultBounds),
+ m_activeMatchIndex + 1,
+ identifier);
+ }
+
+ addMarker(resultRange.get(), foundActiveMatch);
+ }
+
+ // Set the new start for the search range to be the end of the previous
+ // result range. There is no need to use a VisiblePosition here,
+ // since findPlainText will use a TextIterator to go over the visible
+ // text nodes.
+ searchRange->setStart(resultRange->endContainer(ec), resultRange->endOffset(ec), ec);
+
+ Node* shadowTreeRoot = searchRange->shadowTreeRootNode();
+ if (searchRange->collapsed(ec) && shadowTreeRoot)
+ searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount(), ec);
+
+ m_resumeScopingFromRange = resultRange;
+ timedOut = (currentTime() - startTime) >= maxScopingDuration;
+ } while (!timedOut);
+
+ // Remember what we search for last time, so we can skip searching if more
+ // letters are added to the search string (and last outcome was 0).
+ m_lastSearchString = searchText;
+
+ if (matchCount > 0) {
+ frame()->editor()->setMarkedTextMatchesAreHighlighted(true);
+
+ m_lastMatchCount += matchCount;
+
+ // Let the mainframe know how much we found during this pass.
+ mainFrameImpl->increaseMatchCount(matchCount, identifier);
+ }
+
+ if (timedOut) {
+ // If we found anything during this pass, we should redraw. However, we
+ // don't want to spam too much if the page is extremely long, so if we
+ // reach a certain point we start throttling the redraw requests.
+ if (matchCount > 0)
+ invalidateIfNecessary();
+
+ // Scoping effort ran out of time, lets ask for another time-slice.
+ scopeStringMatchesSoon(
+ identifier,
+ searchText,
+ options,
+ false); // don't reset.
+ return; // Done for now, resume work later.
+ }
+
+ // This frame has no further scoping left, so it is done. Other frames might,
+ // of course, continue to scope matches.
+ m_scopingComplete = true;
+ mainFrameImpl->m_framesScopingCount--;
+
+ // If this is the last frame to finish scoping we need to trigger the final
+ // update to be sent.
+ if (!mainFrameImpl->m_framesScopingCount)
+ mainFrameImpl->increaseMatchCount(0, identifier);
+
+ // This frame is done, so show any scrollbar tickmarks we haven't drawn yet.
+ invalidateArea(InvalidateScrollbar);
+}
+
+void WebFrameImpl::cancelPendingScopingEffort()
+{
+ deleteAllValues(m_deferredScopingWork);
+ m_deferredScopingWork.clear();
+
+ m_activeMatchIndex = -1;
+}
+
+void WebFrameImpl::increaseMatchCount(int count, int identifier)
+{
+ // This function should only be called on the mainframe.
+ ASSERT(!parent());
+
+ m_totalMatchCount += count;
+
+ // Update the UI with the latest findings.
+ if (client())
+ client()->reportFindInPageMatchCount(identifier, m_totalMatchCount, !m_framesScopingCount);
+}
+
+void WebFrameImpl::reportFindInPageSelection(const WebRect& selectionRect,
+ int activeMatchOrdinal,
+ int identifier)
+{
+ // Update the UI with the latest selection rect.
+ if (client())
+ client()->reportFindInPageSelection(identifier, ordinalOfFirstMatchForFrame(this) + activeMatchOrdinal, selectionRect);
+}
+
+void WebFrameImpl::resetMatchCount()
+{
+ m_totalMatchCount = 0;
+ m_framesScopingCount = 0;
+}
+
+WebString WebFrameImpl::contentAsText(size_t maxChars) const
+{
+ if (!m_frame)
+ return WebString();
+
+ Vector<UChar> text;
+ frameContentAsPlainText(maxChars, m_frame, &text);
+ return String::adopt(text);
+}
+
+WebString WebFrameImpl::contentAsMarkup() const
+{
+ return createFullMarkup(m_frame->document());
+}
+
+WebString WebFrameImpl::renderTreeAsText() const
+{
+ return externalRepresentation(m_frame);
+}
+
+WebString WebFrameImpl::counterValueForElementById(const WebString& id) const
+{
+ if (!m_frame)
+ return WebString();
+
+ Element* element = m_frame->document()->getElementById(id);
+ if (!element)
+ return WebString();
+
+ return counterValueForElement(element);
+}
+
+WebString WebFrameImpl::markerTextForListItem(const WebElement& webElement) const
+{
+ return WebCore::markerTextForListItem(const_cast<Element*>(webElement.constUnwrap<Element>()));
+}
+
+int WebFrameImpl::pageNumberForElementById(const WebString& id,
+ float pageWidthInPixels,
+ float pageHeightInPixels) const
+{
+ if (!m_frame)
+ return -1;
+
+ Element* element = m_frame->document()->getElementById(id);
+ if (!element)
+ return -1;
+
+ FloatSize pageSize(pageWidthInPixels, pageHeightInPixels);
+ return PrintContext::pageNumberForElement(element, pageSize);
+}
+
+WebRect WebFrameImpl::selectionBoundsRect() const
+{
+ if (hasSelection())
+ return IntRect(frame()->selection()->bounds(false));
+
+ return WebRect();
+}
+
+bool WebFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const
+{
+ if (!m_frame)
+ return false;
+ return m_frame->editor()->selectionStartHasSpellingMarkerFor(from, length);
+}
+
+bool WebFrameImpl::pauseSVGAnimation(const WebString& animationId, double time, const WebString& elementId)
+{
+#if !ENABLE(SVG)
+ return false;
+#else
+ if (!m_frame)
+ return false;
+
+ Document* document = m_frame->document();
+ if (!document || !document->svgExtensions())
+ return false;
+
+ Node* coreNode = document->getElementById(animationId);
+ if (!coreNode || !SVGSMILElement::isSMILElement(coreNode))
+ return false;
+
+ return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreNode), time);
+#endif
+}
+
+WebString WebFrameImpl::layerTreeAsText() const
+{
+ if (!m_frame)
+ return WebString();
+ return WebString(m_frame->layerTreeAsText());
+}
+
+// WebFrameImpl public ---------------------------------------------------------
+
+PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client)
+{
+ return adoptRef(new WebFrameImpl(client));
+}
+
+WebFrameImpl::WebFrameImpl(WebFrameClient* client)
+ : m_frameLoaderClient(this)
+ , m_client(client)
+ , m_activeMatchFrame(0)
+ , m_activeMatchIndex(-1)
+ , m_locatingActiveRect(false)
+ , m_resumeScopingFromRange(0)
+ , m_lastMatchCount(-1)
+ , m_totalMatchCount(-1)
+ , m_framesScopingCount(-1)
+ , m_scopingComplete(false)
+ , m_nextInvalidateAfter(0)
+ , m_animationController(this)
+ , m_identifier(generateFrameIdentifier())
+{
+ PlatformBridge::incrementStatsCounter(webFrameActiveCount);
+ frameCount++;
+}
+
+WebFrameImpl::~WebFrameImpl()
+{
+ PlatformBridge::decrementStatsCounter(webFrameActiveCount);
+ frameCount--;
+
+ cancelPendingScopingEffort();
+ clearPasswordListeners();
+}
+
+void WebFrameImpl::initializeAsMainFrame(WebViewImpl* webViewImpl)
+{
+ RefPtr<Frame> frame = Frame::create(webViewImpl->page(), 0, &m_frameLoaderClient);
+ m_frame = frame.get();
+
+ // Add reference on behalf of FrameLoader. See comments in
+ // WebFrameLoaderClient::frameLoaderDestroyed for more info.
+ ref();
+
+ // We must call init() after m_frame is assigned because it is referenced
+ // during init().
+ m_frame->init();
+}
+
+PassRefPtr<Frame> WebFrameImpl::createChildFrame(
+ const FrameLoadRequest& request, HTMLFrameOwnerElement* ownerElement)
+{
+ RefPtr<WebFrameImpl> webframe(adoptRef(new WebFrameImpl(m_client)));
+
+ // Add an extra ref on behalf of the Frame/FrameLoader, which references the
+ // WebFrame via the FrameLoaderClient interface. See the comment at the top
+ // of this file for more info.
+ webframe->ref();
+
+ RefPtr<Frame> childFrame = Frame::create(
+ m_frame->page(), ownerElement, &webframe->m_frameLoaderClient);
+ webframe->m_frame = childFrame.get();
+
+ childFrame->tree()->setName(request.frameName());
+
+ m_frame->tree()->appendChild(childFrame);
+
+ // Frame::init() can trigger onload event in the parent frame,
+ // which may detach this frame and trigger a null-pointer access
+ // in FrameTree::removeChild. Move init() after appendChild call
+ // so that webframe->mFrame is in the tree before triggering
+ // onload event handler.
+ // Because the event handler may set webframe->mFrame to null,
+ // it is necessary to check the value after calling init() and
+ // return without loading URL.
+ // (b:791612)
+ childFrame->init(); // create an empty document
+ if (!childFrame->tree()->parent())
+ return 0;
+
+ m_frame->loader()->loadURLIntoChildFrame(
+ request.resourceRequest().url(),
+ request.resourceRequest().httpReferrer(),
+ childFrame.get());
+
+ // A synchronous navigation (about:blank) would have already processed
+ // onload, so it is possible for the frame to have already been destroyed by
+ // script in the page.
+ if (!childFrame->tree()->parent())
+ return 0;
+
+ return childFrame.release();
+}
+
+void WebFrameImpl::layout()
+{
+ // layout this frame
+ FrameView* view = m_frame->view();
+ if (view)
+ view->updateLayoutAndStyleIfNeededRecursive();
+}
+
+void WebFrameImpl::paintWithContext(GraphicsContext& gc, const WebRect& rect)
+{
+ IntRect dirtyRect(rect);
+ gc.save();
+ if (m_frame->document() && frameView()) {
+ gc.clip(dirtyRect);
+ frameView()->paint(&gc, dirtyRect);
+ m_frame->page()->inspectorController()->drawNodeHighlight(gc);
+ } else
+ gc.fillRect(dirtyRect, Color::white, ColorSpaceDeviceRGB);
+ gc.restore();
+}
+
+void WebFrameImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ if (rect.isEmpty())
+ return;
+#if WEBKIT_USING_CG
+ GraphicsContext gc(canvas);
+ LocalCurrentGraphicsContext localContext(&gc);
+#elif WEBKIT_USING_SKIA
+ PlatformContextSkia context(canvas);
+
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+ notImplemented();
+#endif
+ paintWithContext(gc, rect);
+}
+
+void WebFrameImpl::createFrameView()
+{
+ ASSERT(m_frame); // If m_frame doesn't exist, we probably didn't init properly.
+
+ Page* page = m_frame->page();
+ ASSERT(page);
+ ASSERT(page->mainFrame());
+
+ bool isMainFrame = m_frame == page->mainFrame();
+ if (isMainFrame && m_frame->view())
+ m_frame->view()->setParentVisible(false);
+
+ m_frame->setView(0);
+
+ WebViewImpl* webView = viewImpl();
+
+ RefPtr<FrameView> view;
+ if (isMainFrame)
+ view = FrameView::create(m_frame, webView->size());
+ else
+ view = FrameView::create(m_frame);
+
+ m_frame->setView(view);
+
+ if (webView->isTransparent())
+ view->setTransparent(true);
+
+ // FIXME: The Mac code has a comment about this possibly being unnecessary.
+ // See installInFrame in WebCoreFrameBridge.mm
+ if (m_frame->ownerRenderer())
+ m_frame->ownerRenderer()->setWidget(view.get());
+
+ if (HTMLFrameOwnerElement* owner = m_frame->ownerElement())
+ view->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOff);
+
+ if (isMainFrame)
+ view->setParentVisible(true);
+}
+
+WebFrameImpl* WebFrameImpl::fromFrame(Frame* frame)
+{
+ if (!frame)
+ return 0;
+
+ return static_cast<FrameLoaderClientImpl*>(frame->loader()->client())->webFrame();
+}
+
+WebFrameImpl* WebFrameImpl::fromFrameOwnerElement(Element* element)
+{
+ if (!element
+ || !element->isFrameOwnerElement()
+ || (!element->hasTagName(HTMLNames::iframeTag)
+ && !element->hasTagName(HTMLNames::frameTag)))
+ return 0;
+
+ HTMLFrameOwnerElement* frameElement =
+ static_cast<HTMLFrameOwnerElement*>(element);
+ return fromFrame(frameElement->contentFrame());
+}
+
+WebViewImpl* WebFrameImpl::viewImpl() const
+{
+ if (!m_frame)
+ return 0;
+
+ return WebViewImpl::fromPage(m_frame->page());
+}
+
+WebDataSourceImpl* WebFrameImpl::dataSourceImpl() const
+{
+ return static_cast<WebDataSourceImpl*>(dataSource());
+}
+
+WebDataSourceImpl* WebFrameImpl::provisionalDataSourceImpl() const
+{
+ return static_cast<WebDataSourceImpl*>(provisionalDataSource());
+}
+
+void WebFrameImpl::setFindEndstateFocusAndSelection()
+{
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+
+ if (this == mainFrameImpl->activeMatchFrame() && m_activeMatch.get()) {
+ // If the user has set the selection since the match was found, we
+ // don't focus anything.
+ VisibleSelection selection(frame()->selection()->selection());
+ if (!selection.isNone())
+ return;
+
+ // Try to find the first focusable node up the chain, which will, for
+ // example, focus links if we have found text within the link.
+ Node* node = m_activeMatch->firstNode();
+ while (node && !node->isFocusable() && node != frame()->document())
+ node = node->parentNode();
+
+ if (node && node != frame()->document()) {
+ // Found a focusable parent node. Set focus to it.
+ frame()->document()->setFocusedNode(node);
+ return;
+ }
+
+ // Iterate over all the nodes in the range until we find a focusable node.
+ // This, for example, sets focus to the first link if you search for
+ // text and text that is within one or more links.
+ node = m_activeMatch->firstNode();
+ while (node && node != m_activeMatch->pastLastNode()) {
+ if (node->isFocusable()) {
+ frame()->document()->setFocusedNode(node);
+ return;
+ }
+ node = node->traverseNextNode();
+ }
+
+ // No node related to the active match was focusable, so set the
+ // active match as the selection (so that when you end the Find session,
+ // you'll have the last thing you found highlighted) and make sure that
+ // we have nothing focused (otherwise you might have text selected but
+ // a link focused, which is weird).
+ frame()->selection()->setSelection(m_activeMatch.get());
+ frame()->document()->setFocusedNode(0);
+ }
+}
+
+void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional)
+{
+ if (!client())
+ return;
+ WebURLError webError = error;
+ if (wasProvisional)
+ client()->didFailProvisionalLoad(this, webError);
+ else
+ client()->didFailLoad(this, webError);
+}
+
+void WebFrameImpl::setCanHaveScrollbars(bool canHaveScrollbars)
+{
+ m_frame->view()->setCanHaveScrollbars(canHaveScrollbars);
+}
+
+bool WebFrameImpl::registerPasswordListener(
+ WebInputElement inputElement,
+ WebPasswordAutocompleteListener* listener)
+{
+ RefPtr<HTMLInputElement> element(inputElement.unwrap<HTMLInputElement>());
+ if (!m_passwordListeners.add(element, listener).second) {
+ delete listener;
+ return false;
+ }
+ return true;
+}
+
+void WebFrameImpl::notifiyPasswordListenerOfAutocomplete(
+ const WebInputElement& inputElement)
+{
+ const HTMLInputElement* element = inputElement.constUnwrap<HTMLInputElement>();
+ WebPasswordAutocompleteListener* listener = getPasswordListener(element);
+ // Password listeners need to autocomplete other fields that depend on the
+ // input element with autofill suggestions.
+ if (listener)
+ listener->performInlineAutocomplete(element->value(), false, false);
+}
+
+WebPasswordAutocompleteListener* WebFrameImpl::getPasswordListener(
+ const HTMLInputElement* inputElement)
+{
+ return m_passwordListeners.get(RefPtr<HTMLInputElement>(const_cast<HTMLInputElement*>(inputElement)));
+}
+
+// WebFrameImpl private --------------------------------------------------------
+
+void WebFrameImpl::closing()
+{
+ m_frame = 0;
+}
+
+void WebFrameImpl::invalidateArea(AreaToInvalidate area)
+{
+ ASSERT(frame() && frame()->view());
+ FrameView* view = frame()->view();
+
+ if ((area & InvalidateAll) == InvalidateAll)
+ view->invalidateRect(view->frameRect());
+ else {
+ if ((area & InvalidateContentArea) == InvalidateContentArea) {
+ IntRect contentArea(
+ view->x(), view->y(), view->visibleWidth(), view->visibleHeight());
+ IntRect frameRect = view->frameRect();
+ contentArea.move(-frameRect.topLeft().x(), -frameRect.topLeft().y());
+ view->invalidateRect(contentArea);
+ }
+
+ if ((area & InvalidateScrollbar) == InvalidateScrollbar) {
+ // Invalidate the vertical scroll bar region for the view.
+ IntRect scrollBarVert(
+ view->x() + view->visibleWidth(), view->y(),
+ ScrollbarTheme::nativeTheme()->scrollbarThickness(),
+ view->visibleHeight());
+ IntRect frameRect = view->frameRect();
+ scrollBarVert.move(-frameRect.topLeft().x(), -frameRect.topLeft().y());
+ view->invalidateRect(scrollBarVert);
+ }
+ }
+}
+
+void WebFrameImpl::addMarker(Range* range, bool activeMatch)
+{
+ // Use a TextIterator to visit the potentially multiple nodes the range
+ // covers.
+ TextIterator markedText(range);
+ for (; !markedText.atEnd(); markedText.advance()) {
+ RefPtr<Range> textPiece = markedText.range();
+ int exception = 0;
+
+ DocumentMarker marker = {
+ DocumentMarker::TextMatch,
+ textPiece->startOffset(exception),
+ textPiece->endOffset(exception),
+ "",
+ activeMatch
+ };
+
+ if (marker.endOffset > marker.startOffset) {
+ // Find the node to add a marker to and add it.
+ Node* node = textPiece->startContainer(exception);
+ frame()->document()->markers()->addMarker(node, marker);
+
+ // Rendered rects for markers in WebKit are not populated until each time
+ // the markers are painted. However, we need it to happen sooner, because
+ // the whole purpose of tickmarks on the scrollbar is to show where
+ // matches off-screen are (that haven't been painted yet).
+ Vector<DocumentMarker> markers = frame()->document()->markers()->markersForNode(node);
+ frame()->document()->markers()->setRenderedRectForMarker(
+ textPiece->startContainer(exception),
+ markers[markers.size() - 1],
+ range->boundingBox());
+ }
+ }
+}
+
+void WebFrameImpl::setMarkerActive(Range* range, bool active)
+{
+ WebCore::ExceptionCode ec;
+ if (!range || range->collapsed(ec))
+ return;
+
+ frame()->document()->markers()->setMarkersActive(range, active);
+}
+
+int WebFrameImpl::ordinalOfFirstMatchForFrame(WebFrameImpl* frame) const
+{
+ int ordinal = 0;
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+ // Iterate from the main frame up to (but not including) |frame| and
+ // add up the number of matches found so far.
+ for (WebFrameImpl* it = mainFrameImpl;
+ it != frame;
+ it = static_cast<WebFrameImpl*>(it->traverseNext(true))) {
+ if (it->m_lastMatchCount > 0)
+ ordinal += it->m_lastMatchCount;
+ }
+ return ordinal;
+}
+
+bool WebFrameImpl::shouldScopeMatches(const String& searchText)
+{
+ // Don't scope if we can't find a frame or a view or if the frame is not visible.
+ // The user may have closed the tab/application, so abort.
+ if (!frame() || !frame()->view() || !hasVisibleContent())
+ return false;
+
+ ASSERT(frame()->document() && frame()->view());
+
+ // If the frame completed the scoping operation and found 0 matches the last
+ // time it was searched, then we don't have to search it again if the user is
+ // just adding to the search string or sending the same search string again.
+ if (m_scopingComplete && !m_lastSearchString.isEmpty() && !m_lastMatchCount) {
+ // Check to see if the search string prefixes match.
+ String previousSearchPrefix =
+ searchText.substring(0, m_lastSearchString.length());
+
+ if (previousSearchPrefix == m_lastSearchString)
+ return false; // Don't search this frame, it will be fruitless.
+ }
+
+ return true;
+}
+
+void WebFrameImpl::scopeStringMatchesSoon(int identifier, const WebString& searchText,
+ const WebFindOptions& options, bool reset)
+{
+ m_deferredScopingWork.append(new DeferredScopeStringMatches(
+ this, identifier, searchText, options, reset));
+}
+
+void WebFrameImpl::callScopeStringMatches(DeferredScopeStringMatches* caller,
+ int identifier, const WebString& searchText,
+ const WebFindOptions& options, bool reset)
+{
+ m_deferredScopingWork.remove(m_deferredScopingWork.find(caller));
+
+ scopeStringMatches(identifier, searchText, options, reset);
+
+ // This needs to happen last since searchText is passed by reference.
+ delete caller;
+}
+
+void WebFrameImpl::invalidateIfNecessary()
+{
+ if (m_lastMatchCount > m_nextInvalidateAfter) {
+ // FIXME: (http://b/1088165) Optimize the drawing of the tickmarks and
+ // remove this. This calculation sets a milestone for when next to
+ // invalidate the scrollbar and the content area. We do this so that we
+ // don't spend too much time drawing the scrollbar over and over again.
+ // Basically, up until the first 500 matches there is no throttle.
+ // After the first 500 matches, we set set the milestone further and
+ // further out (750, 1125, 1688, 2K, 3K).
+ static const int startSlowingDownAfter = 500;
+ static const int slowdown = 750;
+ int i = (m_lastMatchCount / startSlowingDownAfter);
+ m_nextInvalidateAfter += i * slowdown;
+
+ invalidateArea(InvalidateScrollbar);
+ }
+}
+
+void WebFrameImpl::clearPasswordListeners()
+{
+ deleteAllValues(m_passwordListeners);
+ m_passwordListeners.clear();
+}
+
+void WebFrameImpl::loadJavaScriptURL(const KURL& url)
+{
+ // This is copied from ScriptController::executeIfJavaScriptURL.
+ // Unfortunately, we cannot just use that method since it is private, and
+ // it also doesn't quite behave as we require it to for bookmarklets. The
+ // key difference is that we need to suppress loading the string result
+ // from evaluating the JS URL if executing the JS URL resulted in a
+ // location change. We also allow a JS URL to be loaded even if scripts on
+ // the page are otherwise disabled.
+
+ if (!m_frame->document() || !m_frame->page())
+ return;
+
+ String script = decodeURLEscapeSequences(url.string().substring(strlen("javascript:")));
+ ScriptValue result = m_frame->script()->executeScript(script, true);
+
+ String scriptResult;
+ if (!result.getString(scriptResult))
+ return;
+
+ if (!m_frame->navigationScheduler()->locationChangePending())
+ m_frame->loader()->writer()->replaceDocument(scriptResult);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebFrameImpl.h b/Source/WebKit/chromium/src/WebFrameImpl.h
new file mode 100644
index 0000000..b7ac100
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebFrameImpl.h
@@ -0,0 +1,401 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFrameImpl_h
+#define WebFrameImpl_h
+
+#include "WebAnimationControllerImpl.h"
+#include "WebFrame.h"
+
+#include "Frame.h"
+#include "FrameLoaderClientImpl.h"
+#include "PlatformString.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class GraphicsContext;
+class HistoryItem;
+class KURL;
+class Node;
+class Range;
+class SubstituteData;
+struct WindowFeatures;
+}
+
+namespace WebKit {
+class ChromePrintContext;
+class WebDataSourceImpl;
+class WebInputElement;
+class WebFrameClient;
+class WebPasswordAutocompleteListener;
+class WebPerformance;
+class WebPluginContainerImpl;
+class WebView;
+class WebViewImpl;
+
+// Implementation of WebFrame, note that this is a reference counted object.
+class WebFrameImpl : public WebFrame, public RefCounted<WebFrameImpl> {
+public:
+ // WebFrame methods:
+ virtual WebString name() const;
+ virtual void setName(const WebString&);
+ virtual long long identifier() const;
+ virtual WebURL url() const;
+ virtual WebURL favIconURL() const;
+ virtual WebURL openSearchDescriptionURL() const;
+ virtual WebString encoding() const;
+ virtual WebSize scrollOffset() const;
+ virtual WebSize contentsSize() const;
+ virtual int contentsPreferredWidth() const;
+ virtual int documentElementScrollHeight() const;
+ virtual bool hasVisibleContent() const;
+ virtual WebView* view() const;
+ virtual WebFrame* opener() const;
+ virtual WebFrame* parent() const;
+ virtual WebFrame* top() const;
+ virtual WebFrame* firstChild() const;
+ virtual WebFrame* lastChild() const;
+ virtual WebFrame* nextSibling() const;
+ virtual WebFrame* previousSibling() const;
+ virtual WebFrame* traverseNext(bool wrap) const;
+ virtual WebFrame* traversePrevious(bool wrap) const;
+ virtual WebFrame* findChildByName(const WebString&) const;
+ virtual WebFrame* findChildByExpression(const WebString&) const;
+ virtual WebDocument document() const;
+ virtual void forms(WebVector<WebFormElement>&) const;
+ virtual WebAnimationController* animationController();
+ virtual WebPerformance performance() const;
+ virtual WebSecurityOrigin securityOrigin() const;
+ virtual void grantUniversalAccess();
+ virtual NPObject* windowObject() const;
+ virtual void bindToWindowObject(const WebString& name, NPObject*);
+ virtual void executeScript(const WebScriptSource&);
+ virtual void executeScriptInIsolatedWorld(
+ int worldId, const WebScriptSource* sources, unsigned numSources,
+ int extensionGroup);
+ virtual void addMessageToConsole(const WebConsoleMessage&);
+ virtual void collectGarbage();
+#if WEBKIT_USING_V8
+ virtual v8::Handle<v8::Value> executeScriptAndReturnValue(
+ const WebScriptSource&);
+ virtual v8::Local<v8::Context> mainWorldScriptContext() const;
+#endif
+ virtual bool insertStyleText(const WebString& css, const WebString& id);
+ virtual void reload(bool ignoreCache);
+ virtual void loadRequest(const WebURLRequest&);
+ virtual void loadHistoryItem(const WebHistoryItem&);
+ virtual void loadData(
+ const WebData&, const WebString& mimeType, const WebString& textEncoding,
+ const WebURL& baseURL, const WebURL& unreachableURL, bool replace);
+ virtual void loadHTMLString(
+ const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL,
+ bool replace);
+ virtual bool isLoading() const;
+ virtual void stopLoading();
+ virtual WebDataSource* provisionalDataSource() const;
+ virtual WebDataSource* dataSource() const;
+ virtual WebHistoryItem previousHistoryItem() const;
+ virtual WebHistoryItem currentHistoryItem() const;
+ virtual void enableViewSourceMode(bool enable);
+ virtual bool isViewSourceModeEnabled() const;
+ virtual void setReferrerForRequest(WebURLRequest&, const WebURL& referrer);
+ virtual void dispatchWillSendRequest(WebURLRequest&);
+ virtual WebURLLoader* createAssociatedURLLoader();
+ virtual void commitDocumentData(const char* data, size_t length);
+ virtual unsigned unloadListenerCount() const;
+ virtual bool isProcessingUserGesture() const;
+ virtual bool willSuppressOpenerInNewFrame() const;
+ virtual void replaceSelection(const WebString&);
+ virtual void insertText(const WebString&);
+ virtual void setMarkedText(const WebString&, unsigned location, unsigned length);
+ virtual void unmarkText();
+ virtual bool hasMarkedText() const;
+ virtual WebRange markedRange() const;
+ virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const;
+ virtual bool executeCommand(const WebString&);
+ virtual bool executeCommand(const WebString&, const WebString& value);
+ virtual bool isCommandEnabled(const WebString&) const;
+ virtual void enableContinuousSpellChecking(bool);
+ virtual bool isContinuousSpellCheckingEnabled() const;
+ virtual bool hasSelection() const;
+ virtual WebRange selectionRange() const;
+ virtual WebString selectionAsText() const;
+ virtual WebString selectionAsMarkup() const;
+ virtual bool selectWordAroundCaret();
+ virtual int printBegin(const WebSize& pageSize,
+ const WebNode& constrainToNode,
+ int printerDPI,
+ bool* useBrowserOverlays);
+ virtual float printPage(int pageToPrint, WebCanvas*);
+ virtual float getPrintPageShrink(int page);
+ virtual void printEnd();
+ virtual bool isPageBoxVisible(int pageIndex);
+ virtual void pageSizeAndMarginsInPixels(int pageIndex,
+ WebSize& pageSize,
+ int& marginTop,
+ int& marginRight,
+ int& marginBottom,
+ int& marginLeft);
+ virtual bool find(
+ int identifier, const WebString& searchText, const WebFindOptions&,
+ bool wrapWithinFrame, WebRect* selectionRect);
+ virtual void stopFinding(bool clearSelection);
+ virtual void scopeStringMatches(
+ int identifier, const WebString& searchText, const WebFindOptions&,
+ bool reset);
+ virtual void cancelPendingScopingEffort();
+ virtual void increaseMatchCount(int count, int identifier);
+ virtual void resetMatchCount();
+ virtual bool registerPasswordListener(
+ WebInputElement, WebPasswordAutocompleteListener*);
+ virtual void notifiyPasswordListenerOfAutocomplete(
+ const WebInputElement&);
+
+ virtual WebString contentAsText(size_t maxChars) const;
+ virtual WebString contentAsMarkup() const;
+ virtual WebString renderTreeAsText() const;
+ virtual WebString counterValueForElementById(const WebString& id) const;
+ virtual WebString markerTextForListItem(const WebElement&) const;
+ virtual int pageNumberForElementById(const WebString& id,
+ float pageWidthInPixels,
+ float pageHeightInPixels) const;
+ virtual WebRect selectionBoundsRect() const;
+
+ virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const;
+ virtual bool pauseSVGAnimation(const WebString& animationId,
+ double time,
+ const WebString& elementId);
+ virtual WebString layerTreeAsText() const;
+
+ static PassRefPtr<WebFrameImpl> create(WebFrameClient* client);
+ ~WebFrameImpl();
+
+ // Called by the WebViewImpl to initialize its main frame:
+ void initializeAsMainFrame(WebViewImpl*);
+
+ PassRefPtr<WebCore::Frame> createChildFrame(
+ const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*);
+
+ void layout();
+ void paint(WebCanvas*, const WebRect&);
+ void paintWithContext(WebCore::GraphicsContext&, const WebRect&);
+ void createFrameView();
+
+ static WebFrameImpl* fromFrame(WebCore::Frame* frame);
+ static WebFrameImpl* fromFrameOwnerElement(WebCore::Element* element);
+
+ // If the frame hosts a PluginDocument, this method returns the WebPluginContainerImpl
+ // that hosts the plugin.
+ static WebPluginContainerImpl* pluginContainerFromFrame(WebCore::Frame*);
+
+ WebViewImpl* viewImpl() const;
+
+ WebCore::Frame* frame() const { return m_frame; }
+ WebCore::FrameView* frameView() const { return m_frame ? m_frame->view() : 0; }
+
+ // Getters for the impls corresponding to Get(Provisional)DataSource. They
+ // may return 0 if there is no corresponding data source.
+ WebDataSourceImpl* dataSourceImpl() const;
+ WebDataSourceImpl* provisionalDataSourceImpl() const;
+
+ // Returns which frame has an active match. This function should only be
+ // called on the main frame, as it is the only frame keeping track. Returned
+ // value can be 0 if no frame has an active match.
+ const WebFrameImpl* activeMatchFrame() const { return m_activeMatchFrame; }
+
+ // When a Find operation ends, we want to set the selection to what was active
+ // and set focus to the first focusable node we find (starting with the first
+ // node in the matched range and going up the inheritance chain). If we find
+ // nothing to focus we focus the first focusable node in the range. This
+ // allows us to set focus to a link (when we find text inside a link), which
+ // allows us to navigate by pressing Enter after closing the Find box.
+ void setFindEndstateFocusAndSelection();
+
+ void didFail(const WebCore::ResourceError&, bool wasProvisional);
+
+ // Sets whether the WebFrameImpl allows its document to be scrolled.
+ // If the parameter is true, allow the document to be scrolled.
+ // Otherwise, disallow scrolling.
+ void setCanHaveScrollbars(bool);
+
+ // Returns the password autocomplete listener associated with the passed
+ // user name input element, or 0 if none available.
+ // Note that the returned listener is owner by the WebFrameImpl and should not
+ // be kept around as it is deleted when the page goes away.
+ WebPasswordAutocompleteListener* getPasswordListener(const WebCore::HTMLInputElement*);
+
+ WebFrameClient* client() const { return m_client; }
+ void setClient(WebFrameClient* client) { m_client = client; }
+
+ static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition);
+
+private:
+ class DeferredScopeStringMatches;
+ friend class DeferredScopeStringMatches;
+ friend class FrameLoaderClientImpl;
+
+ // A bit mask specifying area of the frame to invalidate.
+ enum AreaToInvalidate {
+ InvalidateNothing,
+ InvalidateContentArea,
+ InvalidateScrollbar, // Vertical scrollbar only.
+ InvalidateAll // Both content area and the scrollbar.
+ };
+
+ WebFrameImpl(WebFrameClient*);
+
+ // Informs the WebFrame that the Frame is being closed, called by the
+ // WebFrameLoaderClient
+ void closing();
+
+ // Notifies the delegate about a new selection rect.
+ void reportFindInPageSelection(
+ const WebRect& selectionRect, int activeMatchOrdinal, int identifier);
+
+ // Invalidates a certain area within the frame.
+ void invalidateArea(AreaToInvalidate);
+
+ // Add a WebKit TextMatch-highlight marker to nodes in a range.
+ void addMarker(WebCore::Range*, bool activeMatch);
+
+ // Sets the markers within a range as active or inactive.
+ void setMarkerActive(WebCore::Range*, bool active);
+
+ // Returns the ordinal of the first match in the frame specified. This
+ // function enumerates the frames, starting with the main frame and up to (but
+ // not including) the frame passed in as a parameter and counts how many
+ // matches have been found.
+ int ordinalOfFirstMatchForFrame(WebFrameImpl*) const;
+
+ // Determines whether the scoping effort is required for a particular frame.
+ // It is not necessary if the frame is invisible, for example, or if this
+ // is a repeat search that already returned nothing last time the same prefix
+ // was searched.
+ bool shouldScopeMatches(const WTF::String& searchText);
+
+ // Queue up a deferred call to scopeStringMatches.
+ void scopeStringMatchesSoon(
+ int identifier, const WebString& searchText, const WebFindOptions&,
+ bool reset);
+
+ // Called by a DeferredScopeStringMatches instance.
+ void callScopeStringMatches(
+ DeferredScopeStringMatches*, int identifier, const WebString& searchText,
+ const WebFindOptions&, bool reset);
+
+ // Determines whether to invalidate the content area and scrollbar.
+ void invalidateIfNecessary();
+
+ // Clears the map of password listeners.
+ void clearPasswordListeners();
+
+ void loadJavaScriptURL(const WebCore::KURL&);
+
+ FrameLoaderClientImpl m_frameLoaderClient;
+
+ WebFrameClient* m_client;
+
+ // This is a weak pointer to our corresponding WebCore frame. A reference to
+ // ourselves is held while frame_ is valid. See our Closing method.
+ WebCore::Frame* m_frame;
+
+ // A way for the main frame to keep track of which frame has an active
+ // match. Should be 0 for all other frames.
+ WebFrameImpl* m_activeMatchFrame;
+
+ // The range of the active match for the current frame.
+ RefPtr<WebCore::Range> m_activeMatch;
+
+ // The index of the active match.
+ int m_activeMatchIndex;
+
+ // This flag is used by the scoping effort to determine if we need to figure
+ // out which rectangle is the active match. Once we find the active
+ // rectangle we clear this flag.
+ bool m_locatingActiveRect;
+
+ // The scoping effort can time out and we need to keep track of where we
+ // ended our last search so we can continue from where we left of.
+ RefPtr<WebCore::Range> m_resumeScopingFromRange;
+
+ // Keeps track of the last string this frame searched for. This is used for
+ // short-circuiting searches in the following scenarios: When a frame has
+ // been searched and returned 0 results, we don't need to search that frame
+ // again if the user is just adding to the search (making it more specific).
+ WTF::String m_lastSearchString;
+
+ // Keeps track of how many matches this frame has found so far, so that we
+ // don't loose count between scoping efforts, and is also used (in conjunction
+ // with m_lastSearchString and m_scopingComplete) to figure out if we need to
+ // search the frame again.
+ int m_lastMatchCount;
+
+ // This variable keeps a cumulative total of matches found so far for ALL the
+ // frames on the page, and is only incremented by calling IncreaseMatchCount
+ // (on the main frame only). It should be -1 for all other frames.
+ size_t m_totalMatchCount;
+
+ // This variable keeps a cumulative total of how many frames are currently
+ // scoping, and is incremented/decremented on the main frame only.
+ // It should be -1 for all other frames.
+ int m_framesScopingCount;
+
+ // Keeps track of whether the scoping effort was completed (the user may
+ // interrupt it before it completes by submitting a new search).
+ bool m_scopingComplete;
+
+ // Keeps track of when the scoping effort should next invalidate the scrollbar
+ // and the frame area.
+ int m_nextInvalidateAfter;
+
+ // A list of all of the pending calls to scopeStringMatches.
+ Vector<DeferredScopeStringMatches*> m_deferredScopingWork;
+
+ // Valid between calls to BeginPrint() and EndPrint(). Containts the print
+ // information. Is used by PrintPage().
+ OwnPtr<ChromePrintContext> m_printContext;
+
+ // The input fields that are interested in edit events and their associated
+ // listeners.
+ typedef HashMap<RefPtr<WebCore::HTMLInputElement>,
+ WebPasswordAutocompleteListener*> PasswordListenerMap;
+ PasswordListenerMap m_passwordListeners;
+
+ // Keeps a reference to the frame's WebAnimationController.
+ WebAnimationControllerImpl m_animationController;
+
+ // The identifier of this frame.
+ long long m_identifier;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebGeolocationClientMock.cpp b/Source/WebKit/chromium/src/WebGeolocationClientMock.cpp
new file mode 100644
index 0000000..1ec3dd1
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGeolocationClientMock.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2010, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGeolocationClientMock.h"
+
+#include "CurrentTime.h"
+#include "Geolocation.h"
+#include "GeolocationClientMock.h"
+#include "GeolocationError.h"
+#include "GeolocationPosition.h"
+#include "PositionError.h"
+#include "WebGeolocationController.h"
+#include "WebGeolocationError.h"
+#include "WebGeolocationPermissionRequest.h"
+#include "WebGeolocationPosition.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebGeolocationClientMock* WebGeolocationClientMock::create()
+{
+ return new WebGeolocationClientMock();
+}
+
+void WebGeolocationClientMock::setPosition(double latitude, double longitude, double accuracy)
+{
+ WebGeolocationPosition webPosition(currentTime(), latitude, longitude, accuracy,
+ false, 0, false, 0, false, 0, false, 0);
+ m_clientMock->setPosition(webPosition);
+}
+
+void WebGeolocationClientMock::setError(int errorCode, const WebString& message)
+{
+ WebGeolocationError::Error code;
+ switch (errorCode) {
+ case PositionError::PERMISSION_DENIED:
+ code = WebGeolocationError::ErrorPermissionDenied;
+ break;
+ case PositionError::POSITION_UNAVAILABLE:
+ code = WebGeolocationError::ErrorPositionUnavailable;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ WebGeolocationError webError(code, message);
+ m_clientMock->setError(webError);
+}
+
+void WebGeolocationClientMock::setPermission(bool allowed)
+{
+ m_clientMock->setPermission(allowed);
+}
+
+void WebGeolocationClientMock::resetMock()
+{
+ m_clientMock->reset();
+}
+
+void WebGeolocationClientMock::startUpdating()
+{
+ m_clientMock->startUpdating();
+}
+
+void WebGeolocationClientMock::stopUpdating()
+{
+ m_clientMock->stopUpdating();
+}
+
+void WebGeolocationClientMock::setEnableHighAccuracy(bool accuracy)
+{
+ m_clientMock->setEnableHighAccuracy(accuracy);
+}
+
+void WebGeolocationClientMock::geolocationDestroyed()
+{
+ m_clientMock->geolocationDestroyed();
+}
+
+void WebGeolocationClientMock::setController(WebGeolocationController* controller)
+{
+ m_clientMock->setController(controller->controller());
+ delete controller;
+}
+
+void WebGeolocationClientMock::requestPermission(const WebGeolocationPermissionRequest& request)
+{
+ m_clientMock->requestPermission(request.geolocation());
+}
+
+void WebGeolocationClientMock::cancelPermissionRequest(const WebGeolocationPermissionRequest& request)
+{
+ m_clientMock->cancelPermissionRequest(request.geolocation());
+}
+
+bool WebGeolocationClientMock::lastPosition(WebGeolocationPosition& webPosition)
+{
+ RefPtr<GeolocationPosition> position = m_clientMock->lastPosition();
+ if (!position)
+ return false;
+
+ webPosition = position.release();
+ return true;
+}
+
+WebGeolocationClientMock::WebGeolocationClientMock()
+{
+ m_clientMock.reset(new GeolocationClientMock());
+}
+
+void WebGeolocationClientMock::reset()
+{
+ m_clientMock.reset(0);
+}
+
+} // WebKit
diff --git a/Source/WebKit/chromium/src/WebGeolocationController.cpp b/Source/WebKit/chromium/src/WebGeolocationController.cpp
new file mode 100644
index 0000000..12cbaa0
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGeolocationController.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGeolocationController.h"
+
+#include "GeolocationController.h"
+#include "GeolocationError.h"
+#include "GeolocationPosition.h"
+#include "WebGeolocationError.h"
+#include "WebGeolocationPosition.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebGeolocationController::positionChanged(const WebGeolocationPosition& webPosition)
+{
+ m_private->positionChanged(PassRefPtr<GeolocationPosition>(webPosition).get());
+}
+
+void WebGeolocationController::errorOccurred(const WebGeolocationError& webError)
+{
+ m_private->errorOccurred(PassRefPtr<GeolocationError>(webError).get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebGeolocationError.cpp b/Source/WebKit/chromium/src/WebGeolocationError.cpp
new file mode 100644
index 0000000..9acb676
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGeolocationError.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGeolocationError.h"
+
+#include "GeolocationError.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebGeolocationError::assign(Error code, const WebString& message)
+{
+ m_private = GeolocationError::create(static_cast<GeolocationError::ErrorCode>(code), message);
+}
+
+void WebGeolocationError::assign(const WebGeolocationError& other)
+{
+ m_private = other.m_private;
+}
+
+void WebGeolocationError::reset()
+{
+ m_private.reset();
+}
+
+WebGeolocationError::WebGeolocationError(PassRefPtr<GeolocationError> error)
+{
+ m_private = error;
+}
+
+WebGeolocationError& WebGeolocationError::operator=(PassRefPtr<GeolocationError> error)
+{
+ m_private = error;
+ return *this;
+}
+
+WebGeolocationError::operator PassRefPtr<GeolocationError>() const
+{
+ return m_private.get();
+}
+
+}
diff --git a/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp b/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp
new file mode 100644
index 0000000..53eca19
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGeolocationPermissionRequest.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGeolocationPermissionRequest.h"
+
+#include "Document.h"
+#include "Frame.h"
+#include "Geolocation.h"
+#include "WebSecurityOrigin.h"
+#include "WebURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSecurityOrigin WebGeolocationPermissionRequest::securityOrigin() const
+{
+ return WebSecurityOrigin(m_private->frame()->document()->securityOrigin());
+}
+
+void WebGeolocationPermissionRequest::setIsAllowed(bool allowed)
+{
+ m_private->setIsAllowed(allowed);
+}
+
+}
diff --git a/Source/WebKit/chromium/src/WebGeolocationPermissionRequestManager.cpp b/Source/WebKit/chromium/src/WebGeolocationPermissionRequestManager.cpp
new file mode 100644
index 0000000..4c0ed9c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGeolocationPermissionRequestManager.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGeolocationPermissionRequestManager.h"
+
+#include "WebGeolocationPermissionRequest.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+class Geolocation;
+}
+
+using namespace WebCore;
+
+typedef HashMap<Geolocation*, int> GeolocationIdMap;
+typedef HashMap<int, Geolocation*> IdGeolocationMap;
+
+namespace WebKit {
+class WebGeolocationPermissionRequestManagerPrivate {
+public:
+ GeolocationIdMap m_geolocationIdMap;
+ IdGeolocationMap m_idGeolocationMap;
+};
+}
+
+using namespace WebKit;
+
+int WebGeolocationPermissionRequestManager::add(const WebKit::WebGeolocationPermissionRequest& permissionRequest)
+{
+ Geolocation* geolocation = permissionRequest.geolocation();
+ ASSERT(!m_private->m_geolocationIdMap.contains(geolocation));
+ int id = ++m_lastId;
+ m_private->m_geolocationIdMap.add(geolocation, id);
+ m_private->m_idGeolocationMap.add(id, geolocation);
+ return id;
+}
+
+bool WebGeolocationPermissionRequestManager::remove(const WebKit::WebGeolocationPermissionRequest& permissionRequest, int& id)
+{
+ Geolocation* geolocation = permissionRequest.geolocation();
+ GeolocationIdMap::iterator it = m_private->m_geolocationIdMap.find(geolocation);
+ if (it == m_private->m_geolocationIdMap.end())
+ return false;
+ id = it->second;
+ m_private->m_geolocationIdMap.remove(it);
+ m_private->m_idGeolocationMap.remove(id);
+ return true;
+}
+
+bool WebGeolocationPermissionRequestManager::remove(int id, WebKit::WebGeolocationPermissionRequest& permissionRequest)
+{
+ IdGeolocationMap::iterator it = m_private->m_idGeolocationMap.find(id);
+ if (it == m_private->m_idGeolocationMap.end())
+ return false;
+ Geolocation* geolocation = it->second;
+ permissionRequest = WebGeolocationPermissionRequest(geolocation);
+ m_private->m_idGeolocationMap.remove(it);
+ m_private->m_geolocationIdMap.remove(geolocation);
+ return true;
+}
+
+void WebGeolocationPermissionRequestManager::init()
+{
+ m_lastId = 0;
+ m_private.reset(new WebGeolocationPermissionRequestManagerPrivate);
+}
+
+void WebGeolocationPermissionRequestManager::reset()
+{
+ m_private.reset(0);
+}
+
diff --git a/Source/WebKit/chromium/src/WebGeolocationPosition.cpp b/Source/WebKit/chromium/src/WebGeolocationPosition.cpp
new file mode 100644
index 0000000..75b3306
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGeolocationPosition.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGeolocationPosition.h"
+
+#include "GeolocationPosition.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebGeolocationPosition::assign(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
+{
+ m_private = GeolocationPosition::create(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
+}
+
+void WebGeolocationPosition::assign(const WebGeolocationPosition& other)
+{
+ m_private = other.m_private;
+}
+
+void WebGeolocationPosition::reset()
+{
+ m_private.reset();
+}
+
+WebGeolocationPosition& WebGeolocationPosition::operator=(PassRefPtr<GeolocationPosition> position)
+{
+ m_private = position;
+ return *this;
+}
+
+WebGeolocationPosition::operator PassRefPtr<GeolocationPosition>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebGlyphCache.cpp b/Source/WebKit/chromium/src/WebGlyphCache.cpp
new file mode 100644
index 0000000..272c6cd
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebGlyphCache.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGlyphCache.h"
+
+#include "GlyphPageTreeNode.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+size_t WebGlyphCache::pageCount()
+{
+ return GlyphPageTreeNode::treeGlyphPageCount();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebHTTPBody.cpp b/Source/WebKit/chromium/src/WebHTTPBody.cpp
new file mode 100644
index 0000000..f32b64f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebHTTPBody.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebHTTPBody.h"
+
+#include "FormData.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebHTTPBodyPrivate : public FormData {
+};
+
+void WebHTTPBody::initialize()
+{
+ assign(static_cast<WebHTTPBodyPrivate*>(FormData::create().releaseRef()));
+}
+
+void WebHTTPBody::reset()
+{
+ assign(0);
+}
+
+void WebHTTPBody::assign(const WebHTTPBody& other)
+{
+ WebHTTPBodyPrivate* p = const_cast<WebHTTPBodyPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+size_t WebHTTPBody::elementCount() const
+{
+ ASSERT(!isNull());
+ return m_private->elements().size();
+}
+
+bool WebHTTPBody::elementAt(size_t index, Element& result) const
+{
+ ASSERT(!isNull());
+
+ if (index >= m_private->elements().size())
+ return false;
+
+ const FormDataElement& element = m_private->elements()[index];
+
+ result.data.reset();
+ result.filePath.reset();
+ result.fileStart = 0;
+ result.fileLength = 0;
+ result.modificationTime = 0.0;
+ result.blobURL = KURL();
+
+ switch (element.m_type) {
+ case FormDataElement::data:
+ result.type = Element::TypeData;
+ result.data.assign(element.m_data.data(), element.m_data.size());
+ break;
+ case FormDataElement::encodedFile:
+ result.type = Element::TypeFile;
+ result.filePath = element.m_filename;
+#if ENABLE(BLOB)
+ result.fileStart = element.m_fileStart;
+ result.fileLength = element.m_fileLength;
+ result.modificationTime = element.m_expectedFileModificationTime;
+#endif
+ break;
+#if ENABLE(BLOB)
+ case FormDataElement::encodedBlob:
+ result.type = Element::TypeBlob;
+ result.blobURL = element.m_blobURL;
+ break;
+#endif
+ default:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ return true;
+}
+
+void WebHTTPBody::appendData(const WebData& data)
+{
+ ensureMutable();
+ // FIXME: FormDataElement::m_data should be a SharedBuffer<char>. Then we
+ // could avoid this buffer copy.
+ m_private->appendData(data.data(), data.size());
+}
+
+void WebHTTPBody::appendFile(const WebString& filePath)
+{
+ ensureMutable();
+ m_private->appendFile(filePath);
+}
+
+void WebHTTPBody::appendFileRange(const WebString& filePath, long long fileStart, long long fileLength, double modificationTime)
+{
+#if ENABLE(BLOB)
+ ensureMutable();
+ m_private->appendFileRange(filePath, fileStart, fileLength, modificationTime);
+#endif
+}
+
+void WebHTTPBody::appendBlob(const WebURL& blobURL)
+{
+#if ENABLE(BLOB)
+ ensureMutable();
+ m_private->appendBlob(blobURL);
+#endif
+}
+
+long long WebHTTPBody::identifier() const
+{
+ ASSERT(!isNull());
+ return m_private->identifier();
+}
+
+void WebHTTPBody::setIdentifier(long long identifier)
+{
+ ensureMutable();
+ return m_private->setIdentifier(identifier);
+}
+
+WebHTTPBody::WebHTTPBody(const PassRefPtr<FormData>& data)
+ : m_private(static_cast<WebHTTPBodyPrivate*>(data.releaseRef()))
+{
+}
+
+WebHTTPBody& WebHTTPBody::operator=(const PassRefPtr<FormData>& data)
+{
+ assign(static_cast<WebHTTPBodyPrivate*>(data.releaseRef()));
+ return *this;
+}
+
+WebHTTPBody::operator PassRefPtr<FormData>() const
+{
+ return m_private;
+}
+
+void WebHTTPBody::assign(WebHTTPBodyPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+void WebHTTPBody::ensureMutable()
+{
+ ASSERT(!isNull());
+ if (!m_private->hasOneRef())
+ assign(static_cast<WebHTTPBodyPrivate*>(m_private->copy().releaseRef()));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebHTTPLoadInfo.cpp b/Source/WebKit/chromium/src/WebHTTPLoadInfo.cpp
new file mode 100644
index 0000000..876a489
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebHTTPLoadInfo.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebHTTPLoadInfo.h"
+
+#include "ResourceLoadInfo.h"
+#include "ResourceResponse.h"
+#include "WebHTTPHeaderVisitor.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebHTTPLoadInfo::initialize()
+{
+ m_private = adoptRef(new ResourceLoadInfo());
+}
+
+void WebHTTPLoadInfo::reset()
+{
+ m_private.reset();
+}
+
+void WebHTTPLoadInfo::assign(const WebHTTPLoadInfo& r)
+{
+ m_private = r.m_private;
+}
+
+WebHTTPLoadInfo::WebHTTPLoadInfo(WTF::PassRefPtr<WebCore::ResourceLoadInfo> value)
+{
+ m_private = value;
+}
+
+WebHTTPLoadInfo::operator WTF::PassRefPtr<WebCore::ResourceLoadInfo>() const
+{
+ return m_private.get();
+}
+
+int WebHTTPLoadInfo::httpStatusCode() const
+{
+ ASSERT(!m_private.isNull());
+ return m_private->httpStatusCode;
+}
+
+void WebHTTPLoadInfo::setHTTPStatusCode(int statusCode)
+{
+ ASSERT(!m_private.isNull());
+ m_private->httpStatusCode = statusCode;
+}
+
+WebString WebHTTPLoadInfo::httpStatusText() const
+{
+ ASSERT(!m_private.isNull());
+ return m_private->httpStatusText;
+}
+
+void WebHTTPLoadInfo::setHTTPStatusText(const WebString& statusText)
+{
+ ASSERT(!m_private.isNull());
+ m_private->httpStatusText = statusText;
+}
+
+static void addHeader(HTTPHeaderMap* map, const WebString& name, const WebString& value)
+{
+ pair<HTTPHeaderMap::iterator, bool> result = map->add(name, value);
+ if (!result.second)
+ result.first->second += String("\n") + value;
+}
+
+void WebHTTPLoadInfo::addRequestHeader(const WebString& name, const WebString& value)
+{
+ ASSERT(!m_private.isNull());
+ addHeader(&m_private->requestHeaders, name, value);
+}
+
+void WebHTTPLoadInfo::addResponseHeader(const WebString& name, const WebString& value)
+{
+ ASSERT(!m_private.isNull());
+ addHeader(&m_private->responseHeaders, name, value);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebHistoryItem.cpp b/Source/WebKit/chromium/src/WebHistoryItem.cpp
new file mode 100644
index 0000000..99ebce8
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebHistoryItem.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebHistoryItem.h"
+
+#include "FormData.h"
+#include "HistoryItem.h"
+#include "KURL.h"
+
+#include "WebHTTPBody.h"
+#include "WebPoint.h"
+#include "WebSerializedScriptValue.h"
+#include "WebString.h"
+#include "WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebHistoryItem::initialize()
+{
+ m_private = HistoryItem::create();
+}
+
+void WebHistoryItem::reset()
+{
+ m_private.reset();
+}
+
+void WebHistoryItem::assign(const WebHistoryItem& other)
+{
+ m_private = other.m_private;
+}
+
+WebString WebHistoryItem::urlString() const
+{
+ return m_private->urlString();
+}
+
+void WebHistoryItem::setURLString(const WebString& url)
+{
+ ensureMutable();
+ m_private->setURLString(KURL(ParsedURLString, url).string());
+}
+
+WebString WebHistoryItem::originalURLString() const
+{
+ return m_private->originalURLString();
+}
+
+void WebHistoryItem::setOriginalURLString(const WebString& originalURLString)
+{
+ ensureMutable();
+ m_private->setOriginalURLString(originalURLString);
+}
+
+WebString WebHistoryItem::referrer() const
+{
+ return m_private->referrer();
+}
+
+void WebHistoryItem::setReferrer(const WebString& referrer)
+{
+ ensureMutable();
+ m_private->setReferrer(referrer);
+}
+
+WebString WebHistoryItem::target() const
+{
+ return m_private->target();
+}
+
+void WebHistoryItem::setTarget(const WebString& target)
+{
+ ensureMutable();
+ m_private->setTarget(target);
+}
+
+WebString WebHistoryItem::parent() const
+{
+ return m_private->parent();
+}
+
+void WebHistoryItem::setParent(const WebString& parent)
+{
+ ensureMutable();
+ m_private->setParent(parent);
+}
+
+WebString WebHistoryItem::title() const
+{
+ return m_private->title();
+}
+
+void WebHistoryItem::setTitle(const WebString& title)
+{
+ ensureMutable();
+ m_private->setTitle(title);
+}
+
+WebString WebHistoryItem::alternateTitle() const
+{
+ return m_private->alternateTitle();
+}
+
+void WebHistoryItem::setAlternateTitle(const WebString& alternateTitle)
+{
+ ensureMutable();
+ m_private->setAlternateTitle(alternateTitle);
+}
+
+double WebHistoryItem::lastVisitedTime() const
+{
+ return m_private->lastVisitedTime();
+}
+
+void WebHistoryItem::setLastVisitedTime(double lastVisitedTime)
+{
+ ensureMutable();
+ // FIXME: setLastVisitedTime increments the visit count, so we have to
+ // correct for that. Instead, we should have a back-door to just mutate
+ // the last visited time directly.
+ int count = m_private->visitCount();
+ m_private->setLastVisitedTime(lastVisitedTime);
+ m_private->setVisitCount(count);
+}
+
+WebPoint WebHistoryItem::scrollOffset() const
+{
+ return m_private->scrollPoint();
+}
+
+void WebHistoryItem::setScrollOffset(const WebPoint& scrollOffset)
+{
+ ensureMutable();
+ m_private->setScrollPoint(scrollOffset);
+}
+
+bool WebHistoryItem::isTargetItem() const
+{
+ return m_private->isTargetItem();
+}
+
+void WebHistoryItem::setIsTargetItem(bool isTargetItem)
+{
+ ensureMutable();
+ m_private->setIsTargetItem(isTargetItem);
+}
+
+int WebHistoryItem::visitCount() const
+{
+ return m_private->visitCount();
+}
+
+void WebHistoryItem::setVisitCount(int count)
+{
+ ensureMutable();
+ m_private->setVisitCount(count);
+}
+
+WebVector<WebString> WebHistoryItem::documentState() const
+{
+ return m_private->documentState();
+}
+
+void WebHistoryItem::setDocumentState(const WebVector<WebString>& state)
+{
+ ensureMutable();
+ // FIXME: would be nice to avoid the intermediate copy
+ Vector<String> ds;
+ for (size_t i = 0; i < state.size(); ++i)
+ ds.append(state[i]);
+ m_private->setDocumentState(ds);
+}
+
+long long WebHistoryItem::itemSequenceNumber() const
+{
+ return m_private->itemSequenceNumber();
+}
+
+void WebHistoryItem::setItemSequenceNumber(long long itemSequenceNumber)
+{
+ ensureMutable();
+ m_private->setItemSequenceNumber(itemSequenceNumber);
+}
+
+long long WebHistoryItem::documentSequenceNumber() const
+{
+ return m_private->documentSequenceNumber();
+}
+
+void WebHistoryItem::setDocumentSequenceNumber(long long documentSequenceNumber)
+{
+ ensureMutable();
+ m_private->setDocumentSequenceNumber(documentSequenceNumber);
+}
+
+WebSerializedScriptValue WebHistoryItem::stateObject() const
+{
+ return WebSerializedScriptValue(m_private->stateObject());
+}
+
+void WebHistoryItem::setStateObject(const WebSerializedScriptValue& object)
+{
+ ensureMutable();
+ m_private->setStateObject(object);
+}
+
+WebString WebHistoryItem::httpContentType() const
+{
+ return m_private->formContentType();
+}
+
+void WebHistoryItem::setHTTPContentType(const WebString& httpContentType)
+{
+ ensureMutable();
+ m_private->setFormContentType(httpContentType);
+}
+
+WebHTTPBody WebHistoryItem::httpBody() const
+{
+ return WebHTTPBody(m_private->formData());
+}
+
+void WebHistoryItem::setHTTPBody(const WebHTTPBody& httpBody)
+{
+ ensureMutable();
+ m_private->setFormData(httpBody);
+}
+
+WebVector<WebHistoryItem> WebHistoryItem::children() const
+{
+ return m_private->children();
+}
+
+void WebHistoryItem::setChildren(const WebVector<WebHistoryItem>& items)
+{
+ ensureMutable();
+ m_private->clearChildren();
+ for (size_t i = 0; i < items.size(); ++i)
+ m_private->addChildItem(items[i]);
+}
+
+void WebHistoryItem::appendToChildren(const WebHistoryItem& item)
+{
+ ensureMutable();
+ m_private->addChildItem(item);
+}
+
+WebHistoryItem::WebHistoryItem(const PassRefPtr<HistoryItem>& item)
+ : m_private(item)
+{
+}
+
+WebHistoryItem& WebHistoryItem::operator=(const PassRefPtr<HistoryItem>& item)
+{
+ m_private = item;
+ return *this;
+}
+
+WebHistoryItem::operator PassRefPtr<HistoryItem>() const
+{
+ return m_private.get();
+}
+
+void WebHistoryItem::ensureMutable()
+{
+ if (!m_private->hasOneRef())
+ m_private = m_private->copy();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp b/Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp
new file mode 100644
index 0000000..14ed02e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBCallbacksImpl.h"
+
+#include "IDBCallbacks.h"
+#include "IDBCursorBackendProxy.h"
+#include "IDBDatabaseError.h"
+#include "IDBDatabaseProxy.h"
+#include "IDBIndexBackendProxy.h"
+#include "IDBKey.h"
+#include "IDBObjectStoreProxy.h"
+#include "IDBTransactionBackendProxy.h"
+#include "WebIDBCallbacks.h"
+#include "WebIDBDatabase.h"
+#include "WebIDBDatabaseError.h"
+#include "WebIDBIndex.h"
+#include "WebIDBKey.h"
+#include "WebIDBObjectStore.h"
+#include "WebIDBTransaction.h"
+#include "WebSerializedScriptValue.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtr<IDBCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+}
+
+WebIDBCallbacksImpl::~WebIDBCallbacksImpl()
+{
+}
+
+void WebIDBCallbacksImpl::onError(const WebKit::WebIDBDatabaseError& error)
+{
+ m_callbacks->onError(error);
+}
+
+void WebIDBCallbacksImpl::onSuccess()
+{
+ m_callbacks->onSuccess();
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebKit::WebIDBCursor* cursor)
+{
+ m_callbacks->onSuccess(IDBCursorBackendProxy::create(cursor));
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebKit::WebIDBDatabase* webKitInstance)
+{
+ m_callbacks->onSuccess(IDBDatabaseProxy::create(webKitInstance));
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebKit::WebIDBKey& key)
+{
+ m_callbacks->onSuccess(key);
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebKit::WebIDBIndex* webKitInstance)
+{
+ m_callbacks->onSuccess(IDBIndexBackendProxy::create(webKitInstance));
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebKit::WebIDBObjectStore* webKitInstance)
+{
+ m_callbacks->onSuccess(IDBObjectStoreProxy::create(webKitInstance));
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebKit::WebIDBTransaction* webKitInstance)
+{
+ m_callbacks->onSuccess(IDBTransactionBackendProxy::create(webKitInstance));
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebKit::WebSerializedScriptValue& serializedScriptValue)
+{
+ m_callbacks->onSuccess(serializedScriptValue);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBCallbacksImpl.h b/Source/WebKit/chromium/src/WebIDBCallbacksImpl.h
new file mode 100644
index 0000000..33a72f4
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBCallbacksImpl.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBCallbacksImpl_h
+#define WebIDBCallbacksImpl_h
+
+#include "WebIDBCallbacks.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+class IDBCallbacks;
+
+class WebIDBCallbacksImpl : public WebKit::WebIDBCallbacks {
+public:
+ WebIDBCallbacksImpl(PassRefPtr<IDBCallbacks>);
+ virtual ~WebIDBCallbacksImpl();
+
+ virtual void onError(const WebKit::WebIDBDatabaseError&);
+ virtual void onSuccess(); // For "null".
+ virtual void onSuccess(WebKit::WebIDBCursor*);
+ virtual void onSuccess(WebKit::WebIDBDatabase*);
+ virtual void onSuccess(const WebKit::WebIDBKey&);
+ virtual void onSuccess(WebKit::WebIDBIndex*);
+ virtual void onSuccess(WebKit::WebIDBObjectStore*);
+ virtual void onSuccess(WebKit::WebIDBTransaction*);
+ virtual void onSuccess(const WebKit::WebSerializedScriptValue&);
+
+private:
+ RefPtr<IDBCallbacks> m_callbacks;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // WebIDBCallbacksImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBCursorImpl.cpp b/Source/WebKit/chromium/src/WebIDBCursorImpl.cpp
new file mode 100644
index 0000000..5165574
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBCursorImpl.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBCursorImpl.h"
+
+#include "IDBAny.h"
+#include "IDBCallbacksProxy.h"
+#include "IDBCursorBackendInterface.h"
+#include "IDBKey.h"
+#include "WebIDBKey.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBCursorImpl::WebIDBCursorImpl(PassRefPtr<IDBCursorBackendInterface> idbCursorBackend)
+ : m_idbCursorBackend(idbCursorBackend)
+{
+}
+
+WebIDBCursorImpl::~WebIDBCursorImpl()
+{
+}
+
+unsigned short WebIDBCursorImpl::direction() const
+{
+ return m_idbCursorBackend->direction();
+}
+
+WebIDBKey WebIDBCursorImpl::key() const
+{
+ return WebIDBKey(m_idbCursorBackend->key());
+}
+
+void WebIDBCursorImpl::value(WebSerializedScriptValue& serializedScriptValue, WebIDBKey& idbKey) const
+{
+ // Verify we're starting off with blank slates.
+ ASSERT(serializedScriptValue.isNull());
+ ASSERT(idbKey.type() == WebIDBKey::InvalidType);
+
+ RefPtr<IDBAny> any = m_idbCursorBackend->value();
+ if (any->type() == IDBAny::SerializedScriptValueType)
+ serializedScriptValue.assign(any->serializedScriptValue());
+ else if (any->type() == IDBAny::IDBKeyType)
+ idbKey.assign(any->idbKey());
+ else
+ ASSERT_NOT_REACHED();
+}
+
+void WebIDBCursorImpl::update(const WebSerializedScriptValue& value, WebIDBCallbacks* callbacks, WebExceptionCode& ec)
+{
+ m_idbCursorBackend->update(value, IDBCallbacksProxy::create(callbacks), ec);
+}
+
+void WebIDBCursorImpl::continueFunction(const WebIDBKey& key, WebIDBCallbacks* callbacks, WebExceptionCode& ec)
+{
+ m_idbCursorBackend->continueFunction(key, IDBCallbacksProxy::create(callbacks), ec);
+}
+
+void WebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, WebExceptionCode& ec)
+{
+ m_idbCursorBackend->deleteFunction(IDBCallbacksProxy::create(callbacks), ec);
+}
+
+} // namespace WebCore
diff --git a/Source/WebKit/chromium/src/WebIDBCursorImpl.h b/Source/WebKit/chromium/src/WebIDBCursorImpl.h
new file mode 100644
index 0000000..7f8ebd7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBCursorImpl.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBCursorImpl_h
+#define WebIDBCursorImpl_h
+
+#include "WebCommon.h"
+#include "WebExceptionCode.h"
+#include "WebIDBCursor.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore { class IDBCursorBackendInterface; }
+
+namespace WebKit {
+
+// See comment in WebIndexedObjectStore for a high level overview these classes.
+class WebIDBCursorImpl : public WebIDBCursor {
+public:
+ WebIDBCursorImpl(WTF::PassRefPtr<WebCore::IDBCursorBackendInterface>);
+ virtual ~WebIDBCursorImpl();
+
+ virtual unsigned short direction() const;
+ virtual WebIDBKey key() const;
+ virtual void value(WebSerializedScriptValue&, WebIDBKey&) const;
+ virtual void update(const WebSerializedScriptValue&, WebIDBCallbacks*, WebExceptionCode&);
+ virtual void continueFunction(const WebIDBKey&, WebIDBCallbacks*, WebExceptionCode&);
+ virtual void deleteFunction(WebIDBCallbacks*, WebExceptionCode&);
+
+ private:
+ WTF::RefPtr<WebCore::IDBCursorBackendInterface> m_idbCursorBackend;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBCursorImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseError.cpp b/Source/WebKit/chromium/src/WebIDBDatabaseError.cpp
new file mode 100644
index 0000000..7413ae6
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBDatabaseError.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBDatabaseError.h"
+
+#include "IDBDatabaseError.h"
+#include "WebString.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebIDBDatabaseError::assign(const WebIDBDatabaseError& value)
+{
+ m_private = value.m_private;
+}
+
+void WebIDBDatabaseError::assign(unsigned short code, const WebString& message)
+{
+ m_private = IDBDatabaseError::createWithoutOffset(code, message);
+}
+
+void WebIDBDatabaseError::reset()
+{
+ m_private.reset();
+}
+
+unsigned short WebIDBDatabaseError::code() const
+{
+ return m_private->code();
+}
+
+WebString WebIDBDatabaseError::message() const
+{
+ return m_private->message();
+}
+
+WebIDBDatabaseError::WebIDBDatabaseError(const PassRefPtr<IDBDatabaseError>& value)
+ : m_private(value)
+{
+}
+
+WebIDBDatabaseError& WebIDBDatabaseError::operator=(const PassRefPtr<IDBDatabaseError>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebIDBDatabaseError::operator PassRefPtr<IDBDatabaseError>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp
new file mode 100644
index 0000000..fa7a200
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBDatabaseImpl.h"
+
+#include "DOMStringList.h"
+#include "IDBCallbacksProxy.h"
+#include "IDBDatabaseBackendInterface.h"
+#include "IDBTransactionBackendInterface.h"
+#include "WebIDBCallbacks.h"
+#include "WebIDBObjectStoreImpl.h"
+#include "WebIDBTransactionImpl.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBDatabaseImpl::WebIDBDatabaseImpl(PassRefPtr<IDBDatabaseBackendInterface> databaseBackend)
+ : m_databaseBackend(databaseBackend)
+{
+}
+
+WebIDBDatabaseImpl::~WebIDBDatabaseImpl()
+{
+}
+
+WebString WebIDBDatabaseImpl::name() const
+{
+ return m_databaseBackend->name();
+}
+
+WebString WebIDBDatabaseImpl::version() const
+{
+ return m_databaseBackend->version();
+}
+
+WebDOMStringList WebIDBDatabaseImpl::objectStoreNames() const
+{
+ return m_databaseBackend->objectStoreNames();
+}
+
+WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ RefPtr<IDBObjectStoreBackendInterface> objectStore = m_databaseBackend->createObjectStore(name, keyPath, autoIncrement, transaction.getIDBTransactionBackendInterface(), ec);
+ if (!objectStore) {
+ ASSERT(ec);
+ return 0;
+ }
+ return new WebIDBObjectStoreImpl(objectStore);
+}
+
+void WebIDBDatabaseImpl::deleteObjectStore(const WebString& name, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_databaseBackend->deleteObjectStore(name, transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBDatabaseImpl::setVersion(const WebString& version, WebIDBCallbacks* callbacks, WebExceptionCode& ec)
+{
+ m_databaseBackend->setVersion(version, IDBCallbacksProxy::create(callbacks), ec);
+}
+
+WebIDBTransaction* WebIDBDatabaseImpl::transaction(const WebDOMStringList& names, unsigned short mode, unsigned long timeout, WebExceptionCode& ec)
+{
+ RefPtr<DOMStringList> nameList = PassRefPtr<DOMStringList>(names);
+ RefPtr<IDBTransactionBackendInterface> transaction = m_databaseBackend->transaction(nameList.get(), mode, timeout, ec);
+ if (!transaction) {
+ ASSERT(ec);
+ return 0;
+ }
+ return new WebIDBTransactionImpl(transaction);
+}
+
+void WebIDBDatabaseImpl::close()
+{
+ m_databaseBackend->close();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h
new file mode 100644
index 0000000..64e0b2e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBDatabaseImpl_h
+#define WebIDBDatabaseImpl_h
+
+#include "WebCommon.h"
+#include "WebExceptionCode.h"
+#include "WebIDBDatabase.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore { class IDBDatabaseBackendInterface; }
+
+namespace WebKit {
+
+class WebIDBObjectStore;
+class WebIDBTransaction;
+
+// See comment in WebIDBFactory for a high level overview these classes.
+class WebIDBDatabaseImpl : public WebIDBDatabase {
+public:
+ WebIDBDatabaseImpl(WTF::PassRefPtr<WebCore::IDBDatabaseBackendInterface>);
+ virtual ~WebIDBDatabaseImpl();
+
+ virtual WebString name() const;
+ virtual WebString version() const;
+ virtual WebDOMStringList objectStoreNames() const;
+
+ virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction&, WebExceptionCode&);
+ virtual void deleteObjectStore(const WebString& name, const WebIDBTransaction&, WebExceptionCode&);
+ virtual void setVersion(const WebString& version, WebIDBCallbacks* callbacks, WebExceptionCode&);
+ virtual WebIDBTransaction* transaction(const WebDOMStringList& names, unsigned short mode, unsigned long timeout, WebExceptionCode&);
+ virtual void close();
+
+private:
+ WTF::RefPtr<WebCore::IDBDatabaseBackendInterface> m_databaseBackend;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBDatabaseImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp b/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp
new file mode 100755
index 0000000..a509076
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBFactoryImpl.h"
+
+#include "DOMStringList.h"
+#include "IDBCallbacksProxy.h"
+#include "IDBFactoryBackendImpl.h"
+#include "SecurityOrigin.h"
+#include "WebIDBDatabaseError.h"
+#include <wtf/OwnPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBFactory* WebIDBFactory::create()
+{
+ return new WebIDBFactoryImpl();
+}
+
+WebIDBFactoryImpl::WebIDBFactoryImpl()
+ : m_idbFactoryBackend(WebCore::IDBFactoryBackendImpl::create())
+{
+}
+
+WebIDBFactoryImpl::~WebIDBFactoryImpl()
+{
+}
+
+void WebIDBFactoryImpl::open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame*, const WebString& dataDir, unsigned long long maximumSize)
+{
+ m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(callbacks), origin, 0, dataDir, maximumSize);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBFactoryImpl.h b/Source/WebKit/chromium/src/WebIDBFactoryImpl.h
new file mode 100755
index 0000000..9ed6e3f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBFactoryImpl.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBFactoryImpl_h
+#define WebIDBFactoryImpl_h
+
+#include "WebDOMStringList.h"
+#include "WebIDBFactory.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore { class IDBFactoryBackendInterface; }
+
+namespace WebKit {
+
+class WebIDBFactoryImpl : public WebIDBFactory {
+public:
+ WebIDBFactoryImpl();
+ virtual ~WebIDBFactoryImpl();
+
+ virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize);
+
+private:
+ WTF::RefPtr<WebCore::IDBFactoryBackendInterface> m_idbFactoryBackend;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBFactoryImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp b/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp
new file mode 100644
index 0000000..6e8e1f2
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBIndexImpl.h"
+
+#include "IDBCallbacksProxy.h"
+#include "IDBIndex.h"
+#include "IDBKeyRange.h"
+#include "WebIDBCallbacks.h"
+#include "WebIDBKey.h"
+#include "WebIDBKeyRange.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBIndexImpl::WebIDBIndexImpl(PassRefPtr<IDBIndexBackendInterface> backend)
+ : m_backend(backend)
+{
+}
+
+WebIDBIndexImpl::~WebIDBIndexImpl()
+{
+}
+
+WebString WebIDBIndexImpl::name() const
+{
+ return m_backend->name();
+}
+
+WebString WebIDBIndexImpl::storeName() const
+{
+ return m_backend->storeName();
+}
+
+WebString WebIDBIndexImpl::keyPath() const
+{
+ return m_backend->keyPath();
+}
+
+bool WebIDBIndexImpl::unique() const
+{
+ return m_backend->unique();
+}
+
+void WebIDBIndexImpl::openObjectCursor(const WebIDBKeyRange& keyRange, unsigned short direction, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_backend->openCursor(keyRange, direction, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBIndexImpl::openKeyCursor(const WebIDBKeyRange& keyRange, unsigned short direction, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_backend->openKeyCursor(keyRange, direction, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBIndexImpl::getObject(const WebIDBKey& keyRange, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_backend->get(keyRange, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBIndexImpl::getKey(const WebIDBKey& keyRange, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_backend->getKey(keyRange, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBIndexImpl.h b/Source/WebKit/chromium/src/WebIDBIndexImpl.h
new file mode 100644
index 0000000..f68da7f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBIndexImpl.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBIndexImpl_h
+#define WebIDBIndexImpl_h
+
+#include "WebCommon.h"
+#include "WebIDBIndex.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore { class IDBIndexBackendInterface; }
+
+namespace WebKit {
+
+// See comment in WebIndexedDatabase for a high level overview these classes.
+class WebIDBIndexImpl : public WebIDBIndex {
+public:
+ WebIDBIndexImpl(WTF::PassRefPtr<WebCore::IDBIndexBackendInterface>);
+ virtual ~WebIDBIndexImpl();
+
+ virtual WebString name() const;
+ virtual WebString storeName() const;
+ virtual WebString keyPath() const;
+ virtual bool unique() const;
+
+ virtual void openObjectCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+ virtual void openKeyCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+ virtual void getObject(const WebIDBKey&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+ virtual void getKey(const WebIDBKey&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+
+private:
+ WTF::RefPtr<WebCore::IDBIndexBackendInterface> m_backend;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBIndexImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBKey.cpp b/Source/WebKit/chromium/src/WebIDBKey.cpp
new file mode 100644
index 0000000..7e84df1
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBKey.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBKey.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBBindingUtilities.h"
+#include "IDBKey.h"
+#include "IDBKeyPath.h"
+#include "SerializedScriptValue.h"
+#include "WebIDBKeyPath.h"
+#include "WebSerializedScriptValue.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBKey WebIDBKey::createNull()
+{
+ WebIDBKey key;
+ key.assignNull();
+ return key;
+}
+
+WebIDBKey WebIDBKey::createString(const WebString& string)
+{
+ WebIDBKey key;
+ key.assignString(string);
+ return key;
+}
+
+WebIDBKey WebIDBKey::createDate(double date)
+{
+ WebIDBKey key;
+ key.assignDate(date);
+ return key;
+}
+
+WebIDBKey WebIDBKey::createNumber(double number)
+{
+ WebIDBKey key;
+ key.assignNumber(number);
+ return key;
+}
+
+WebIDBKey WebIDBKey::createInvalid()
+{
+ WebIDBKey key;
+ key.assignInvalid();
+ return key;
+}
+
+WebIDBKey WebIDBKey::createFromValueAndKeyPath(const WebSerializedScriptValue& serializedScriptValue, const WebIDBKeyPath& idbKeyPath)
+{
+ if (serializedScriptValue.isNull())
+ return WebIDBKey::createInvalid();
+ return WebCore::createIDBKeyFromSerializedValueAndKeyPath(serializedScriptValue, idbKeyPath);
+}
+
+void WebIDBKey::assign(const WebIDBKey& value)
+{
+ m_private = value.m_private;
+}
+
+void WebIDBKey::assignNull()
+{
+ m_private = IDBKey::createNull();
+}
+
+void WebIDBKey::assignString(const WebString& string)
+{
+ m_private = IDBKey::createString(string);
+}
+
+void WebIDBKey::assignDate(double date)
+{
+ m_private = IDBKey::createDate(date);
+}
+
+void WebIDBKey::assignNumber(double number)
+{
+ m_private = IDBKey::createNumber(number);
+}
+
+void WebIDBKey::assignInvalid()
+{
+ m_private = 0;
+}
+
+void WebIDBKey::reset()
+{
+ m_private.reset();
+}
+
+WebIDBKey::Type WebIDBKey::type() const
+{
+ if (!m_private.get())
+ return InvalidType;
+ return Type(m_private->type());
+}
+
+WebString WebIDBKey::string() const
+{
+ return m_private->string();
+}
+
+double WebIDBKey::date() const
+{
+ return m_private->date();
+}
+
+double WebIDBKey::number() const
+{
+ return m_private->number();
+}
+
+WebIDBKey::WebIDBKey(const PassRefPtr<IDBKey>& value)
+ : m_private(value)
+{
+}
+
+WebIDBKey& WebIDBKey::operator=(const PassRefPtr<IDBKey>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebIDBKey::operator PassRefPtr<IDBKey>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBKeyPath.cpp b/Source/WebKit/chromium/src/WebIDBKeyPath.cpp
new file mode 100644
index 0000000..9eb33d6
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBKeyPath.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBKeyPath.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBKeyPath.h"
+#include "WebString.h"
+#include "WebVector.h"
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath)
+{
+ WTF::Vector<IDBKeyPathElement> idbElements;
+ IDBKeyPathParseError idbError;
+ IDBParseKeyPath(keyPath, idbElements, idbError);
+ return WebIDBKeyPath(idbElements, static_cast<int>(idbError));
+}
+
+WebIDBKeyPath::WebIDBKeyPath(const WTF::Vector<IDBKeyPathElement>& elements, int parseError)
+ : m_private(new WTF::Vector<IDBKeyPathElement>(elements))
+ , m_parseError(parseError)
+{
+}
+
+int WebIDBKeyPath::parseError() const
+{
+ return m_parseError;
+}
+
+void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath)
+{
+ m_parseError = keyPath.m_parseError;
+ m_private.reset(new WTF::Vector<IDBKeyPathElement>(keyPath));
+}
+
+void WebIDBKeyPath::reset()
+{
+ m_private.reset(0);
+}
+
+WebIDBKeyPath::operator const WTF::Vector<WebCore::IDBKeyPathElement, 0>&() const
+{
+ return *m_private.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBKeyRange.cpp b/Source/WebKit/chromium/src/WebIDBKeyRange.cpp
new file mode 100644
index 0000000..517ff00
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBKeyRange.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBKeyRange.h"
+
+#include "IDBKey.h"
+#include "IDBKeyRange.h"
+#include "WebIDBKey.h"
+
+using WebCore::IDBKeyRange;
+
+namespace WebKit {
+
+void WebIDBKeyRange::assign(const WebIDBKeyRange& other)
+{
+ m_private = other.m_private;
+}
+
+void WebIDBKeyRange::assign(const WebIDBKey& lower, const WebIDBKey& upper, bool lowerOpen, bool upperOpen)
+{
+ if (lower.type() == WebIDBKey::InvalidType && upper.type() == WebIDBKey::InvalidType)
+ m_private = 0;
+ else
+ m_private = IDBKeyRange::create(lower, upper, lowerOpen, upperOpen);
+}
+
+void WebIDBKeyRange::reset()
+{
+ m_private.reset();
+}
+
+WebIDBKey WebIDBKeyRange::lower() const
+{
+ if (!m_private.get())
+ return WebIDBKey::createInvalid();
+ return m_private->lower();
+}
+
+WebIDBKey WebIDBKeyRange::upper() const
+{
+ if (!m_private.get())
+ return WebIDBKey::createInvalid();
+ return m_private->upper();
+}
+
+bool WebIDBKeyRange::lowerOpen() const
+{
+ return m_private.get() && m_private->lowerOpen();
+}
+
+bool WebIDBKeyRange::upperOpen() const
+{
+ return m_private.get() && m_private->upperOpen();
+}
+
+WebIDBKeyRange::WebIDBKeyRange(const PassRefPtr<IDBKeyRange>& value)
+ : m_private(value)
+{
+}
+
+WebIDBKeyRange& WebIDBKeyRange::operator=(const PassRefPtr<IDBKeyRange>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebIDBKeyRange::operator PassRefPtr<IDBKeyRange>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp
new file mode 100755
index 0000000..0503ede
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBObjectStoreImpl.h"
+
+#include "DOMStringList.h"
+#include "IDBCallbacksProxy.h"
+#include "IDBKeyRange.h"
+#include "IDBObjectStoreBackendInterface.h"
+#include "WebIDBIndexImpl.h"
+#include "WebIDBKey.h"
+#include "WebIDBKeyRange.h"
+#include "WebIDBTransaction.h"
+#include "WebSerializedScriptValue.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBObjectStoreImpl::WebIDBObjectStoreImpl(PassRefPtr<IDBObjectStoreBackendInterface> objectStore)
+ : m_objectStore(objectStore)
+{
+}
+
+WebIDBObjectStoreImpl::~WebIDBObjectStoreImpl()
+{
+}
+
+WebString WebIDBObjectStoreImpl::name() const
+{
+ return m_objectStore->name();
+}
+
+WebString WebIDBObjectStoreImpl::keyPath() const
+{
+ return m_objectStore->keyPath();
+}
+
+WebDOMStringList WebIDBObjectStoreImpl::indexNames() const
+{
+ return m_objectStore->indexNames();
+}
+
+void WebIDBObjectStoreImpl::get(const WebIDBKey& key, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_objectStore->get(key, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBObjectStoreImpl::put(const WebSerializedScriptValue& value, const WebIDBKey& key, bool addOnly, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_objectStore->put(value, key, addOnly, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBObjectStoreImpl::deleteFunction(const WebIDBKey& key, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_objectStore->deleteFunction(key, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, transaction.getIDBTransactionBackendInterface(), ec);
+ if (!index)
+ return 0;
+ return new WebIDBIndexImpl(index);
+}
+
+WebIDBIndex* WebIDBObjectStoreImpl::index(const WebString& name, WebExceptionCode& ec)
+{
+ RefPtr<IDBIndexBackendInterface> index = m_objectStore->index(name, ec);
+ if (!index)
+ return 0;
+ return new WebIDBIndexImpl(index);
+}
+
+void WebIDBObjectStoreImpl::deleteIndex(const WebString& name, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_objectStore->deleteIndex(name, transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+void WebIDBObjectStoreImpl::openCursor(const WebIDBKeyRange& keyRange, unsigned short direction, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec)
+{
+ m_objectStore->openCursor(keyRange, direction, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface(), ec);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h
new file mode 100755
index 0000000..f9cd776
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBObjectStoreImpl_h
+#define WebIDBObjectStoreImpl_h
+
+#include "WebCommon.h"
+#include "WebIDBObjectStore.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore { class IDBObjectStoreBackendInterface; }
+
+namespace WebKit {
+
+class WebIDBIndex;
+
+// See comment in WebIndexedObjectStore for a high level overview these classes.
+class WebIDBObjectStoreImpl : public WebIDBObjectStore {
+public:
+ WebIDBObjectStoreImpl(WTF::PassRefPtr<WebCore::IDBObjectStoreBackendInterface>);
+ ~WebIDBObjectStoreImpl();
+
+ WebString name() const;
+ WebString keyPath() const;
+ WebDOMStringList indexNames() const;
+
+ void get(const WebIDBKey& key, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+ void put(const WebSerializedScriptValue&, const WebIDBKey& key, bool addOnly, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+ void deleteFunction(const WebIDBKey& key, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+
+ WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction&, WebExceptionCode&);
+ WebIDBIndex* index(const WebString& name, WebExceptionCode&);
+ void deleteIndex(const WebString& name, const WebIDBTransaction&, WebExceptionCode&);
+
+ void openCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
+
+ private:
+ WTF::RefPtr<WebCore::IDBObjectStoreBackendInterface> m_objectStore;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBObjectStoreImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.cpp b/Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.cpp
new file mode 100644
index 0000000..96924cf
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBTransactionCallbacksImpl.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBTransactionCallbacks.h"
+
+namespace WebCore {
+
+WebIDBTransactionCallbacksImpl::WebIDBTransactionCallbacksImpl(PassRefPtr<IDBTransactionCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+}
+
+WebIDBTransactionCallbacksImpl::~WebIDBTransactionCallbacksImpl()
+{
+}
+
+void WebIDBTransactionCallbacksImpl::onAbort()
+{
+ m_callbacks->onAbort();
+}
+
+void WebIDBTransactionCallbacksImpl::onComplete()
+{
+ m_callbacks->onComplete();
+}
+
+void WebIDBTransactionCallbacksImpl::onTimeout()
+{
+ m_callbacks->onTimeout();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.h b/Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.h
new file mode 100644
index 0000000..89b9cbe
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBTransactionCallbacksImpl.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBTransactionCallbacksImpl_h
+#define WebIDBTransactionCallbacksImpl_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "WebIDBTransactionCallbacks.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBTransactionCallbacks;
+
+class WebIDBTransactionCallbacksImpl : public WebKit::WebIDBTransactionCallbacks {
+public:
+ WebIDBTransactionCallbacksImpl(PassRefPtr<IDBTransactionCallbacks>);
+ virtual ~WebIDBTransactionCallbacksImpl();
+
+ virtual void onAbort();
+ virtual void onComplete();
+ virtual void onTimeout();
+
+private:
+ RefPtr<IDBTransactionCallbacks> m_callbacks;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // WebIDBTransactionCallbacksImpl_h
diff --git a/Source/WebKit/chromium/src/WebIDBTransactionImpl.cpp b/Source/WebKit/chromium/src/WebIDBTransactionImpl.cpp
new file mode 100644
index 0000000..1ed6f4b
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBTransactionImpl.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebIDBTransactionImpl.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBTransaction.h"
+#include "IDBTransactionCallbacksProxy.h"
+#include "WebIDBObjectStoreImpl.h"
+#include "WebIDBTransactionCallbacks.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBTransactionImpl::WebIDBTransactionImpl(PassRefPtr<IDBTransactionBackendInterface> backend)
+ : m_backend(backend)
+{
+}
+
+WebIDBTransactionImpl::~WebIDBTransactionImpl()
+{
+}
+
+int WebIDBTransactionImpl::mode() const
+{
+ return m_backend->mode();
+}
+
+WebIDBObjectStore* WebIDBTransactionImpl::objectStore(const WebString& name, ExceptionCode& ec)
+{
+ RefPtr<IDBObjectStoreBackendInterface> objectStore = m_backend->objectStore(name, ec);
+ if (!objectStore)
+ return 0;
+ return new WebIDBObjectStoreImpl(objectStore);
+}
+
+void WebIDBTransactionImpl::abort()
+{
+ m_backend->abort();
+}
+
+void WebIDBTransactionImpl::didCompleteTaskEvents()
+{
+ m_backend->didCompleteTaskEvents();
+}
+
+void WebIDBTransactionImpl::setCallbacks(WebIDBTransactionCallbacks* callbacks)
+{
+ RefPtr<IDBTransactionCallbacks> idbCallbacks = IDBTransactionCallbacksProxy::create(callbacks);
+ m_backend->setCallbacks(idbCallbacks.get());
+}
+
+IDBTransactionBackendInterface* WebIDBTransactionImpl::getIDBTransactionBackendInterface() const
+{
+ return m_backend.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/src/WebIDBTransactionImpl.h b/Source/WebKit/chromium/src/WebIDBTransactionImpl.h
new file mode 100644
index 0000000..d26fc37
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebIDBTransactionImpl.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebIDBTransactionImpl_h
+#define WebIDBTransactionImpl_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "WebCommon.h"
+#include "WebIDBTransaction.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+// See comment in WebIndexedDatabase for a high level overview these classes.
+class WebIDBTransactionImpl: public WebIDBTransaction {
+public:
+ WebIDBTransactionImpl(WTF::PassRefPtr<WebCore::IDBTransactionBackendInterface>);
+ virtual ~WebIDBTransactionImpl();
+
+ virtual int mode() const;
+ virtual WebIDBObjectStore* objectStore(const WebString& name, WebExceptionCode&);
+ virtual void abort();
+ virtual void didCompleteTaskEvents();
+ virtual void setCallbacks(WebIDBTransactionCallbacks*);
+
+ virtual WebCore::IDBTransactionBackendInterface* getIDBTransactionBackendInterface() const;
+
+private:
+ WTF::RefPtr<WebCore::IDBTransactionBackendInterface> m_backend;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // WebIDBTransactionImpl_h
diff --git a/Source/WebKit/chromium/src/WebImageCG.cpp b/Source/WebKit/chromium/src/WebImageCG.cpp
new file mode 100644
index 0000000..045c8be
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebImageCG.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebImage.h"
+
+#include "Image.h"
+#include "ImageSource.h"
+#include "SharedBuffer.h"
+
+#include "WebData.h"
+#include "WebSize.h"
+
+#include <CoreGraphics/CGImage.h>
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize)
+{
+ // FIXME: Do something like what WebImageSkia.cpp does to enumerate frames.
+ // Not sure whether the CG decoder uses the same frame ordering rules (if so
+ // we can just use the same logic).
+
+ ImageSource source;
+ source.setData(PassRefPtr<SharedBuffer>(data).get(), true);
+ if (!source.isSizeAvailable())
+ return WebImage();
+
+ RetainPtr<CGImageRef> frame0(AdoptCF, source.createFrameAtIndex(0));
+ if (!frame0)
+ return WebImage();
+
+ return WebImage(frame0.get());
+}
+
+void WebImage::reset()
+{
+ CGImageRelease(m_imageRef);
+ m_imageRef = 0;
+}
+
+void WebImage::assign(const WebImage& image)
+{
+ assign(image.m_imageRef);
+}
+
+bool WebImage::isNull() const
+{
+ return !m_imageRef;
+}
+
+WebSize WebImage::size() const
+{
+ return WebSize(CGImageGetWidth(m_imageRef), CGImageGetHeight(m_imageRef));
+}
+
+WebImage::WebImage(const PassRefPtr<Image>& image)
+ : m_imageRef(0)
+{
+ NativeImagePtr p;
+ if (image.get() && (p = image->nativeImageForCurrentFrame()))
+ assign(p);
+}
+
+WebImage& WebImage::operator=(const PassRefPtr<Image>& image)
+{
+ NativeImagePtr p;
+ if (image.get() && (p = image->nativeImageForCurrentFrame()))
+ assign(p);
+ else
+ reset();
+ return *this;
+}
+
+void WebImage::assign(CGImageRef imageRef)
+{
+ // Make sure to retain the imageRef first incase m_imageRef == imageRef.
+ CGImageRetain(imageRef);
+ CGImageRelease(m_imageRef);
+ m_imageRef = imageRef;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebImageDecoder.cpp b/Source/WebKit/chromium/src/WebImageDecoder.cpp
new file mode 100644
index 0000000..87cf8e3
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebImageDecoder.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebImageDecoder.h"
+
+#include "BMPImageDecoder.h"
+#include "ICOImageDecoder.h"
+#include "SharedBuffer.h"
+#include "WebData.h"
+#include "WebImage.h"
+#include "WebSize.h"
+
+#if WEBKIT_USING_SKIA
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebImageDecoder::reset()
+{
+ delete m_private;
+}
+
+void WebImageDecoder::init(Type type)
+{
+ switch (type) {
+ case TypeBMP:
+ m_private = new BMPImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied);
+ break;
+ case TypeICO:
+ m_private = new ICOImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied);
+ break;
+ }
+}
+
+void WebImageDecoder::setData(const WebData& data, bool allDataReceived)
+{
+ ASSERT(m_private);
+ m_private->setData(PassRefPtr<SharedBuffer>(data).get(), allDataReceived);
+}
+
+bool WebImageDecoder::isFailed() const
+{
+ ASSERT(m_private);
+ return m_private->failed();
+}
+
+bool WebImageDecoder::isSizeAvailable() const
+{
+ ASSERT(m_private);
+ return m_private->isSizeAvailable();
+}
+
+WebSize WebImageDecoder::size() const
+{
+ ASSERT(m_private);
+ return m_private->size();
+}
+
+size_t WebImageDecoder::frameCount() const
+{
+ ASSERT(m_private);
+ return m_private->frameCount();
+}
+
+bool WebImageDecoder::isFrameCompleteAtIndex(int index) const
+{
+ ASSERT(m_private);
+ ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index);
+ if (!frameBuffer)
+ return false;
+ return (frameBuffer->status() == ImageFrame::FrameComplete);
+}
+
+WebImage WebImageDecoder::getFrameAtIndex(int index = 0) const
+{
+ ASSERT(m_private);
+ ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index);
+ if (!frameBuffer)
+ return WebImage();
+#if WEBKIT_USING_SKIA
+ OwnPtr<NativeImageSkia>image(frameBuffer->asNewNativeImage());
+ return WebImage(*image);
+#elif WEBKIT_USING_CG
+ // FIXME: Implement CG side of this.
+ return WebImage(frameBuffer->asNewNativeImage());
+#endif
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebImageSkia.cpp b/Source/WebKit/chromium/src/WebImageSkia.cpp
new file mode 100644
index 0000000..0684b58
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebImageSkia.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebImage.h"
+
+#include "Image.h"
+#include "ImageSource.h"
+#include "NativeImageSkia.h"
+#include "SharedBuffer.h"
+
+#include "WebData.h"
+#include "WebSize.h"
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize)
+{
+ ImageSource source;
+ source.setData(PassRefPtr<SharedBuffer>(data).get(), true);
+ if (!source.isSizeAvailable())
+ return WebImage();
+
+ // Frames are arranged by decreasing size, then decreasing bit depth.
+ // Pick the frame closest to |desiredSize|'s area without being smaller,
+ // which has the highest bit depth.
+ const size_t frameCount = source.frameCount();
+ size_t index = 0; // Default to first frame if none are large enough.
+ int frameAreaAtIndex = 0;
+ for (size_t i = 0; i < frameCount; ++i) {
+ const IntSize frameSize = source.frameSizeAtIndex(i);
+ if (WebSize(frameSize) == desiredSize) {
+ index = i;
+ break; // Perfect match.
+ }
+
+ const int frameArea = frameSize.width() * frameSize.height();
+ if (frameArea < (desiredSize.width * desiredSize.height))
+ break; // No more frames that are large enough.
+
+ if (!i || (frameArea < frameAreaAtIndex)) {
+ index = i; // Closer to desired area than previous best match.
+ frameAreaAtIndex = frameArea;
+ }
+ }
+
+ OwnPtr<NativeImageSkia> frame(source.createFrameAtIndex(index));
+ if (!frame.get())
+ return WebImage();
+
+ return WebImage(*frame);
+}
+
+void WebImage::reset()
+{
+ m_bitmap.reset();
+}
+
+void WebImage::assign(const WebImage& image)
+{
+ m_bitmap = image.m_bitmap;
+}
+
+bool WebImage::isNull() const
+{
+ return m_bitmap.isNull();
+}
+
+WebSize WebImage::size() const
+{
+ return WebSize(m_bitmap.width(), m_bitmap.height());
+}
+
+WebImage::WebImage(const PassRefPtr<Image>& image)
+{
+ operator=(image);
+}
+
+WebImage& WebImage::operator=(const PassRefPtr<Image>& image)
+{
+ NativeImagePtr p;
+ if (image.get() && (p = image->nativeImageForCurrentFrame()))
+ assign(*p);
+ else
+ reset();
+ return *this;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebInputElement.cpp b/Source/WebKit/chromium/src/WebInputElement.cpp
new file mode 100644
index 0000000..8d89c60
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebInputElement.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputElement.h"
+
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebInputElement::isTextField() const
+{
+ return constUnwrap<HTMLInputElement>()->isTextField();
+}
+
+bool WebInputElement::isText() const
+{
+ return constUnwrap<HTMLInputElement>()->isText();
+}
+
+bool WebInputElement::isPasswordField() const
+{
+ return constUnwrap<HTMLInputElement>()->isPasswordField();
+}
+
+bool WebInputElement::isImageButton() const
+{
+ return constUnwrap<HTMLInputElement>()->isImageButton();
+}
+
+bool WebInputElement::autoComplete() const
+{
+ return constUnwrap<HTMLInputElement>()->autoComplete();
+}
+
+bool WebInputElement::isReadOnly() const
+{
+ return constUnwrap<HTMLInputElement>()->readOnly();
+}
+
+bool WebInputElement::isEnabledFormControl() const
+{
+ return constUnwrap<HTMLInputElement>()->isEnabledFormControl();
+}
+
+int WebInputElement::maxLength() const
+{
+ return constUnwrap<HTMLInputElement>()->maxLength();
+}
+
+bool WebInputElement::isActivatedSubmit() const
+{
+ return constUnwrap<HTMLInputElement>()->isActivatedSubmit();
+}
+
+void WebInputElement::setActivatedSubmit(bool activated)
+{
+ unwrap<HTMLInputElement>()->setActivatedSubmit(activated);
+}
+
+int WebInputElement::size() const
+{
+ return constUnwrap<HTMLInputElement>()->size();
+}
+
+void WebInputElement::setValue(const WebString& value, bool sendChangeEvent)
+{
+ unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent);
+}
+
+WebString WebInputElement::value() const
+{
+ return constUnwrap<HTMLInputElement>()->value();
+}
+
+void WebInputElement::setSuggestedValue(const WebString& value)
+{
+ unwrap<HTMLInputElement>()->setSuggestedValue(value);
+}
+
+WebString WebInputElement::suggestedValue() const
+{
+ return constUnwrap<HTMLInputElement>()->suggestedValue();
+}
+
+void WebInputElement::setPlaceholder(const WebString& value)
+{
+ unwrap<HTMLInputElement>()->setPlaceholder(value);
+}
+
+WebString WebInputElement::placeholder() const
+{
+ return constUnwrap<HTMLInputElement>()->placeholder();
+}
+
+bool WebInputElement::isAutofilled() const
+{
+ return constUnwrap<HTMLInputElement>()->isAutofilled();
+}
+
+void WebInputElement::setAutofilled(bool autoFilled)
+{
+ unwrap<HTMLInputElement>()->setAutofilled(autoFilled);
+}
+
+void WebInputElement::dispatchFormControlChangeEvent()
+{
+ unwrap<HTMLInputElement>()->dispatchFormControlChangeEvent();
+}
+
+void WebInputElement::setSelectionRange(int start, int end)
+{
+ unwrap<HTMLInputElement>()->setSelectionRange(start, end);
+}
+
+int WebInputElement::selectionStart() const
+{
+ return constUnwrap<HTMLInputElement>()->selectionStart();
+}
+
+int WebInputElement::selectionEnd() const
+{
+ return constUnwrap<HTMLInputElement>()->selectionEnd();
+}
+
+bool WebInputElement::isValidValue(const WebString& value) const
+{
+ return constUnwrap<HTMLInputElement>()->isValidValue(value);
+}
+
+const int WebInputElement::defaultMaxLength = HTMLInputElement::s_maximumLength;
+
+WebInputElement::WebInputElement(const PassRefPtr<HTMLInputElement>& elem)
+ : WebFormControlElement(elem)
+{
+}
+
+WebInputElement& WebInputElement::operator=(const PassRefPtr<HTMLInputElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebInputElement::operator PassRefPtr<HTMLInputElement>() const
+{
+ return static_cast<HTMLInputElement*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebInputEvent.cpp b/Source/WebKit/chromium/src/WebInputEvent.cpp
new file mode 100644
index 0000000..c00200e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebInputEvent.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputEvent.h"
+
+#include "KeyboardCodes.h"
+
+#include <ctype.h>
+#include <stdio.h>
+
+#include <wtf/Assertions.h>
+#include <wtf/StringExtras.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const char* staticKeyIdentifiers(unsigned short keyCode)
+{
+ switch (keyCode) {
+ case VKEY_MENU:
+ return "Alt";
+ case VKEY_CONTROL:
+ return "Control";
+ case VKEY_SHIFT:
+ return "Shift";
+ case VKEY_CAPITAL:
+ return "CapsLock";
+ case VKEY_LWIN:
+ case VKEY_RWIN:
+ return "Win";
+ case VKEY_CLEAR:
+ return "Clear";
+ case VKEY_DOWN:
+ return "Down";
+ case VKEY_END:
+ return "End";
+ case VKEY_RETURN:
+ return "Enter";
+ case VKEY_EXECUTE:
+ return "Execute";
+ case VKEY_F1:
+ return "F1";
+ case VKEY_F2:
+ return "F2";
+ case VKEY_F3:
+ return "F3";
+ case VKEY_F4:
+ return "F4";
+ case VKEY_F5:
+ return "F5";
+ case VKEY_F6:
+ return "F6";
+ case VKEY_F7:
+ return "F7";
+ case VKEY_F8:
+ return "F8";
+ case VKEY_F9:
+ return "F9";
+ case VKEY_F10:
+ return "F10";
+ case VKEY_F11:
+ return "F11";
+ case VKEY_F12:
+ return "F12";
+ case VKEY_F13:
+ return "F13";
+ case VKEY_F14:
+ return "F14";
+ case VKEY_F15:
+ return "F15";
+ case VKEY_F16:
+ return "F16";
+ case VKEY_F17:
+ return "F17";
+ case VKEY_F18:
+ return "F18";
+ case VKEY_F19:
+ return "F19";
+ case VKEY_F20:
+ return "F20";
+ case VKEY_F21:
+ return "F21";
+ case VKEY_F22:
+ return "F22";
+ case VKEY_F23:
+ return "F23";
+ case VKEY_F24:
+ return "F24";
+ case VKEY_HELP:
+ return "Help";
+ case VKEY_HOME:
+ return "Home";
+ case VKEY_INSERT:
+ return "Insert";
+ case VKEY_LEFT:
+ return "Left";
+ case VKEY_NEXT:
+ return "PageDown";
+ case VKEY_PRIOR:
+ return "PageUp";
+ case VKEY_PAUSE:
+ return "Pause";
+ case VKEY_SNAPSHOT:
+ return "PrintScreen";
+ case VKEY_RIGHT:
+ return "Right";
+ case VKEY_SCROLL:
+ return "Scroll";
+ case VKEY_SELECT:
+ return "Select";
+ case VKEY_UP:
+ return "Up";
+ case VKEY_DELETE:
+ return "U+007F"; // Standard says that DEL becomes U+007F.
+ default:
+ return 0;
+ }
+}
+
+void WebKeyboardEvent::setKeyIdentifierFromWindowsKeyCode()
+{
+ const char* id = staticKeyIdentifiers(windowsKeyCode);
+ if (id) {
+ strncpy(keyIdentifier, id, sizeof(keyIdentifier) - 1);
+ keyIdentifier[sizeof(keyIdentifier) - 1] = '\0';
+ } else
+ snprintf(keyIdentifier, sizeof(keyIdentifier), "U+%04X", toupper(windowsKeyCode));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebInputEventConversion.cpp b/Source/WebKit/chromium/src/WebInputEventConversion.cpp
new file mode 100644
index 0000000..24eb372
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebInputEventConversion.cpp
@@ -0,0 +1,349 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputEventConversion.h"
+
+#include "EventNames.h"
+#include "KeyboardCodes.h"
+#include "KeyboardEvent.h"
+#include "MouseEvent.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "ScrollView.h"
+#include "WebInputEvent.h"
+#include "WheelEvent.h"
+#include "Widget.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// MakePlatformMouseEvent -----------------------------------------------------
+
+PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e)
+{
+ // FIXME: widget is always toplevel, unless it's a popup. We may be able
+ // to get rid of this once we abstract popups into a WebKit API.
+ m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
+ m_globalPosition = IntPoint(e.globalX, e.globalY);
+ m_button = static_cast<MouseButton>(e.button);
+ m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey);
+ m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey);
+ m_altKey = (e.modifiers & WebInputEvent::AltKey);
+ m_metaKey = (e.modifiers & WebInputEvent::MetaKey);
+ m_modifierFlags = e.modifiers;
+ m_timestamp = e.timeStampSeconds;
+ m_clickCount = e.clickCount;
+
+ switch (e.type) {
+ case WebInputEvent::MouseMove:
+ case WebInputEvent::MouseLeave: // synthesize a move event
+ m_eventType = MouseEventMoved;
+ break;
+
+ case WebInputEvent::MouseDown:
+ m_eventType = MouseEventPressed;
+ break;
+
+ case WebInputEvent::MouseUp:
+ m_eventType = MouseEventReleased;
+ break;
+
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+// PlatformWheelEventBuilder --------------------------------------------------
+
+PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e)
+{
+ m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
+ m_globalPosition = IntPoint(e.globalX, e.globalY);
+ m_deltaX = e.deltaX;
+ m_deltaY = e.deltaY;
+ m_wheelTicksX = e.wheelTicksX;
+ m_wheelTicksY = e.wheelTicksY;
+ m_isAccepted = false;
+ m_granularity = e.scrollByPage ?
+ ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
+ m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey);
+ m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey);
+ m_altKey = (e.modifiers & WebInputEvent::AltKey);
+ m_metaKey = (e.modifiers & WebInputEvent::MetaKey);
+}
+
+// MakePlatformKeyboardEvent --------------------------------------------------
+
+static inline PlatformKeyboardEvent::Type toPlatformKeyboardEventType(WebInputEvent::Type type)
+{
+ switch (type) {
+ case WebInputEvent::KeyUp:
+ return PlatformKeyboardEvent::KeyUp;
+ case WebInputEvent::KeyDown:
+ return PlatformKeyboardEvent::KeyDown;
+ case WebInputEvent::RawKeyDown:
+ return PlatformKeyboardEvent::RawKeyDown;
+ case WebInputEvent::Char:
+ return PlatformKeyboardEvent::Char;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return PlatformKeyboardEvent::KeyDown;
+}
+
+PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEvent& e)
+{
+ m_type = toPlatformKeyboardEventType(e.type);
+ m_text = String(e.text);
+ m_unmodifiedText = String(e.unmodifiedText);
+ m_keyIdentifier = String(e.keyIdentifier);
+ m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat);
+ m_windowsVirtualKeyCode = e.windowsKeyCode;
+ m_nativeVirtualKeyCode = e.nativeKeyCode;
+ m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad);
+ m_shiftKey = (e.modifiers & WebInputEvent::ShiftKey);
+ m_ctrlKey = (e.modifiers & WebInputEvent::ControlKey);
+ m_altKey = (e.modifiers & WebInputEvent::AltKey);
+ m_metaKey = (e.modifiers & WebInputEvent::MetaKey);
+ m_isSystemKey = e.isSystemKey;
+}
+
+void PlatformKeyboardEventBuilder::setKeyType(Type type)
+{
+ // According to the behavior of Webkit in Windows platform,
+ // we need to convert KeyDown to RawKeydown and Char events
+ // See WebKit/WebKit/Win/WebView.cpp
+ ASSERT(m_type == KeyDown);
+ ASSERT(type == RawKeyDown || type == Char);
+ m_type = type;
+
+ if (type == RawKeyDown) {
+ m_text = String();
+ m_unmodifiedText = String();
+ } else {
+ m_keyIdentifier = String();
+ m_windowsVirtualKeyCode = 0;
+ }
+}
+
+// Please refer to bug http://b/issue?id=961192, which talks about Webkit
+// keyboard event handling changes. It also mentions the list of keys
+// which don't have associated character events.
+bool PlatformKeyboardEventBuilder::isCharacterKey() const
+{
+ switch (windowsVirtualKeyCode()) {
+ case VKEY_BACK:
+ case VKEY_ESCAPE:
+ return false;
+ }
+ return true;
+}
+
+#if ENABLE(TOUCH_EVENTS)
+static inline TouchEventType toPlatformTouchEventType(const WebInputEvent::Type type)
+{
+ switch (type) {
+ case WebInputEvent::TouchStart:
+ return TouchStart;
+ case WebInputEvent::TouchMove:
+ return TouchMove;
+ case WebInputEvent::TouchEnd:
+ return TouchEnd;
+ case WebInputEvent::TouchCancel:
+ return TouchCancel;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return TouchStart;
+}
+
+static inline PlatformTouchPoint::State toPlatformTouchPointState(const WebTouchPoint::State state)
+{
+ switch (state) {
+ case WebTouchPoint::StateReleased:
+ return PlatformTouchPoint::TouchReleased;
+ case WebTouchPoint::StatePressed:
+ return PlatformTouchPoint::TouchPressed;
+ case WebTouchPoint::StateMoved:
+ return PlatformTouchPoint::TouchMoved;
+ case WebTouchPoint::StateStationary:
+ return PlatformTouchPoint::TouchStationary;
+ case WebTouchPoint::StateCancelled:
+ return PlatformTouchPoint::TouchCancelled;
+ case WebTouchPoint::StateUndefined:
+ ASSERT_NOT_REACHED();
+ }
+ return PlatformTouchPoint::TouchReleased;
+}
+
+PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point)
+{
+ m_id = point.id;
+ m_state = toPlatformTouchPointState(point.state);
+ m_pos = widget->convertFromContainingWindow(point.position);
+ m_screenPos = point.screenPosition;
+}
+
+PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTouchEvent& event)
+{
+ m_type = toPlatformTouchEventType(event.type);
+ m_ctrlKey = event.modifiers & WebInputEvent::ControlKey;
+ m_altKey = event.modifiers & WebInputEvent::AltKey;
+ m_shiftKey = event.modifiers & WebInputEvent::ShiftKey;
+ m_metaKey = event.modifiers & WebInputEvent::MetaKey;
+
+ for (int i = 0; i < event.touchPointsLength; ++i)
+ m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touchPoints[i]));
+}
+#endif
+
+static int getWebInputModifiers(const UIEventWithKeyState& event)
+{
+ int modifiers = 0;
+ if (event.ctrlKey())
+ modifiers |= WebInputEvent::ControlKey;
+ if (event.shiftKey())
+ modifiers |= WebInputEvent::ShiftKey;
+ if (event.altKey())
+ modifiers |= WebInputEvent::AltKey;
+ if (event.metaKey())
+ modifiers |= WebInputEvent::MetaKey;
+ return modifiers;
+}
+
+WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const MouseEvent& event)
+{
+ if (event.type() == eventNames().mousemoveEvent)
+ type = WebInputEvent::MouseMove;
+ else if (event.type() == eventNames().mouseoutEvent)
+ type = WebInputEvent::MouseLeave;
+ else if (event.type() == eventNames().mouseoverEvent)
+ type = WebInputEvent::MouseEnter;
+ else if (event.type() == eventNames().mousedownEvent)
+ type = WebInputEvent::MouseDown;
+ else if (event.type() == eventNames().mouseupEvent)
+ type = WebInputEvent::MouseUp;
+ else if (event.type() == eventNames().contextmenuEvent)
+ type = WebInputEvent::ContextMenu;
+ else
+ return; // Skip all other mouse events.
+ timeStampSeconds = event.timeStamp() * 1.0e-3;
+ switch (event.button()) {
+ case LeftButton:
+ button = WebMouseEvent::ButtonLeft;
+ break;
+ case MiddleButton:
+ button = WebMouseEvent::ButtonMiddle;
+ break;
+ case RightButton:
+ button = WebMouseEvent::ButtonRight;
+ break;
+ }
+ modifiers = getWebInputModifiers(event);
+ if (event.buttonDown()) {
+ switch (event.button()) {
+ case LeftButton:
+ modifiers |= WebInputEvent::LeftButtonDown;
+ break;
+ case MiddleButton:
+ modifiers |= WebInputEvent::MiddleButtonDown;
+ break;
+ case RightButton:
+ modifiers |= WebInputEvent::RightButtonDown;
+ break;
+ }
+ }
+ ScrollView* view = widget->parent();
+ IntPoint p = view->contentsToWindow(
+ IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y()));
+ globalX = event.screenX();
+ globalY = event.screenY();
+ windowX = p.x();
+ windowY = p.y();
+ x = event.absoluteLocation().x() - widget->pos().x();
+ y = event.absoluteLocation().y() - widget->pos().y();
+ clickCount = event.detail();
+}
+
+WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WheelEvent& event)
+{
+ if (event.type() != eventNames().mousewheelEvent)
+ return;
+ type = WebInputEvent::MouseWheel;
+ timeStampSeconds = event.timeStamp() * 1.0e-3;
+ modifiers = getWebInputModifiers(event);
+ ScrollView* view = widget->parent();
+ IntPoint p = view->contentsToWindow(
+ IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y()));
+ globalX = event.screenX();
+ globalY = event.screenY();
+ windowX = p.x();
+ windowY = p.y();
+ x = event.absoluteLocation().x() - widget->pos().x();
+ y = event.absoluteLocation().y() - widget->pos().y();
+ deltaX = static_cast<float>(event.rawDeltaX());
+ deltaY = static_cast<float>(event.rawDeltaY());
+ // The 120 is from WheelEvent::initWheelEvent().
+ wheelTicksX = static_cast<float>(event.wheelDeltaX()) / 120;
+ wheelTicksY = static_cast<float>(event.wheelDeltaY()) / 120;
+ scrollByPage = event.granularity() == WheelEvent::Page;
+}
+
+WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event)
+{
+ if (event.type() == eventNames().keydownEvent)
+ type = KeyDown;
+ else if (event.type() == eventNames().keyupEvent)
+ type = WebInputEvent::KeyUp;
+ else if (event.type() == eventNames().keypressEvent)
+ type = WebInputEvent::Char;
+ else
+ return; // Skip all other keyboard events.
+ modifiers = getWebInputModifiers(event);
+ timeStampSeconds = event.timeStamp() * 1.0e-3;
+ windowsKeyCode = event.keyCode();
+
+ // The platform keyevent does not exist if the event was created using
+ // initKeyboardEvent.
+ if (!event.keyEvent())
+ return;
+ nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
+ unsigned int numChars = std::min(event.keyEvent()->text().length(),
+ static_cast<unsigned int>(WebKeyboardEvent::textLengthCap));
+ for (unsigned int i = 0; i < numChars; i++) {
+ text[i] = event.keyEvent()->text()[i];
+ unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebInputEventConversion.h b/Source/WebKit/chromium/src/WebInputEventConversion.h
new file mode 100644
index 0000000..63991a9
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebInputEventConversion.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebInputEventConversion_h
+#define WebInputEventConversion_h
+
+#include "WebInputEvent.h"
+
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformTouchEvent.h"
+#include "PlatformWheelEvent.h"
+
+namespace WebCore {
+class KeyboardEvent;
+class MouseEvent;
+class ScrollView;
+class WheelEvent;
+class Widget;
+}
+
+namespace WebKit {
+
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebKeyboardEvent;
+
+// These classes are used to convert from WebInputEvent subclasses to
+// corresponding WebCore events.
+
+class PlatformMouseEventBuilder : public WebCore::PlatformMouseEvent {
+public:
+ PlatformMouseEventBuilder(WebCore::Widget*, const WebMouseEvent&);
+};
+
+class PlatformWheelEventBuilder : public WebCore::PlatformWheelEvent {
+public:
+ PlatformWheelEventBuilder(WebCore::Widget*, const WebMouseWheelEvent&);
+};
+
+class PlatformKeyboardEventBuilder : public WebCore::PlatformKeyboardEvent {
+public:
+ PlatformKeyboardEventBuilder(const WebKeyboardEvent&);
+ void setKeyType(Type);
+ bool isCharacterKey() const;
+};
+
+#if ENABLE(TOUCH_EVENTS)
+class PlatformTouchPointBuilder : public WebCore::PlatformTouchPoint {
+public:
+ PlatformTouchPointBuilder(WebCore::Widget*, const WebTouchPoint&);
+};
+
+class PlatformTouchEventBuilder : public WebCore::PlatformTouchEvent {
+public:
+ PlatformTouchEventBuilder(WebCore::Widget*, const WebTouchEvent&);
+};
+#endif
+
+// Converts a WebCore::MouseEvent to a corresponding WebMouseEvent. view is
+// the ScrollView corresponding to the event.
+// NOTE: This is only implemented for mousemove, mouseover, mouseout,
+// mousedown and mouseup. If the event mapping fails, the event type will
+// be set to Undefined.
+class WebMouseEventBuilder : public WebMouseEvent {
+public:
+ WebMouseEventBuilder(const WebCore::Widget*, const WebCore::MouseEvent&);
+};
+
+// Converts a WebCore::WheelEvent to a corresponding WebMouseWheelEvent.
+// If the event mapping fails, the event type will be set to Undefined.
+class WebMouseWheelEventBuilder : public WebMouseWheelEvent {
+public:
+ WebMouseWheelEventBuilder(const WebCore::Widget*, const WebCore::WheelEvent&);
+};
+
+// Converts a WebCore::KeyboardEvent to a corresponding WebKeyboardEvent.
+// NOTE: This is only implemented for keydown and keyup. If the event mapping
+// fails, the event type will be set to Undefined.
+class WebKeyboardEventBuilder : public WebKeyboardEvent {
+public:
+ WebKeyboardEventBuilder(const WebCore::KeyboardEvent&);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebKit.cpp b/Source/WebKit/chromium/src/WebKit.cpp
new file mode 100644
index 0000000..cadcb6c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebKit.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebKit.h"
+
+#include "DOMTimer.h"
+#include "Logging.h"
+#include "Page.h"
+#include "RuntimeEnabledFeatures.h"
+#include "TextEncoding.h"
+#include "WebMediaPlayerClientImpl.h"
+#include "WebSocket.h"
+#include "WorkerContextExecutionProxy.h"
+
+#include <wtf/Assertions.h>
+#include <wtf/Threading.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebKit {
+
+// Make sure we are not re-initialized in the same address space.
+// Doing so may cause hard to reproduce crashes.
+static bool s_webKitInitialized = false;
+
+static WebKitClient* s_webKitClient = 0;
+static bool s_layoutTestMode = false;
+
+void initialize(WebKitClient* webKitClient)
+{
+ ASSERT(!s_webKitInitialized);
+ s_webKitInitialized = true;
+
+ ASSERT(webKitClient);
+ ASSERT(!s_webKitClient);
+ s_webKitClient = webKitClient;
+
+ WTF::initializeThreading();
+ WTF::initializeMainThread();
+ WTF::AtomicString::init();
+
+ // Chromium sets the minimum interval timeout to 4ms, overriding the
+ // default of 10ms. We'd like to go lower, however there are poorly
+ // coded websites out there which do create CPU-spinning loops. Using
+ // 4ms prevents the CPU from spinning too busily and provides a balance
+ // between CPU spinning and the smallest possible interval timer.
+ WebCore::DOMTimer::setMinTimerInterval(0.004);
+
+ // There are some code paths (for example, running WebKit in the browser
+ // process and calling into LocalStorage before anything else) where the
+ // UTF8 string encoding tables are used on a background thread before
+ // they're set up. This is a problem because their set up routines assert
+ // they're running on the main WebKitThread. It might be possible to make
+ // the initialization thread-safe, but given that so many code paths use
+ // this, initializing this lazily probably doesn't buy us much.
+ WebCore::UTF8Encoding();
+}
+
+void shutdown()
+{
+ s_webKitClient = 0;
+}
+
+WebKitClient* webKitClient()
+{
+ return s_webKitClient;
+}
+
+void setLayoutTestMode(bool value)
+{
+ s_layoutTestMode = value;
+}
+
+bool layoutTestMode()
+{
+ return s_layoutTestMode;
+}
+
+void enableLogChannel(const char* name)
+{
+ WTFLogChannel* channel = WebCore::getChannelFromName(name);
+ if (channel)
+ channel->state = WTFLogChannelOn;
+}
+
+void resetPluginCache(bool reloadPages)
+{
+ WebCore::Page::refreshPlugins(reloadPages);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebLabelElement.cpp b/Source/WebKit/chromium/src/WebLabelElement.cpp
new file mode 100644
index 0000000..ef2c698
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebLabelElement.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebLabelElement.h"
+
+#include "HTMLLabelElement.h"
+#include "HTMLNames.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebElement WebLabelElement::correspondingControl()
+{
+ return WebElement(unwrap<HTMLLabelElement>()->control());
+}
+
+WebLabelElement::WebLabelElement(const PassRefPtr<HTMLLabelElement>& elem)
+ : WebElement(elem)
+{
+}
+
+WebLabelElement& WebLabelElement::operator=(const PassRefPtr<HTMLLabelElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebLabelElement::operator PassRefPtr<HTMLLabelElement>() const
+{
+ return static_cast<HTMLLabelElement*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebMediaElement.cpp b/Source/WebKit/chromium/src/WebMediaElement.cpp
new file mode 100644
index 0000000..4adda1e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebMediaElement.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebMediaElement.h"
+
+#include "HTMLMediaElement.h"
+#include "MediaPlayer.h"
+#include "WebMediaPlayer.h"
+#include "WebMediaPlayerClientImpl.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebMediaPlayer* WebMediaElement::player() const
+{
+ return WebMediaPlayerClientImpl::fromMediaElement(this)->mediaPlayer();
+}
+
+WebMediaElement::WebMediaElement(const PassRefPtr<HTMLMediaElement>& elem)
+ : WebElement(elem)
+{
+}
+
+WebMediaElement& WebMediaElement::operator=(const PassRefPtr<HTMLMediaElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebMediaElement::operator PassRefPtr<HTMLMediaElement>() const
+{
+ return static_cast<HTMLMediaElement*>(m_private.get());
+}
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
new file mode 100644
index 0000000..65f0fde
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
@@ -0,0 +1,527 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "WebMediaPlayerClientImpl.h"
+
+#if ENABLE(VIDEO)
+
+#include "Frame.h"
+#include "GraphicsContext.h"
+#include "HTMLMediaElement.h"
+#include "IntSize.h"
+#include "KURL.h"
+#include "MediaPlayer.h"
+#include "NotImplemented.h"
+#include "RenderView.h"
+#include "TimeRanges.h"
+#include "VideoLayerChromium.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "RenderLayerCompositor.h"
+#endif
+
+#include "VideoFrameChromium.h"
+#include "VideoFrameChromiumImpl.h"
+#include "WebCanvas.h"
+#include "WebCString.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMediaElement.h"
+#include "WebMediaPlayer.h"
+#include "WebMimeRegistry.h"
+#include "WebRect.h"
+#include "WebSize.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebViewImpl.h"
+
+// WebCommon.h defines WEBKIT_USING_SKIA so this has to be included last.
+#if WEBKIT_USING_SKIA
+#include "PlatformContextSkia.h"
+#endif
+
+#include <wtf/Assertions.h>
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static WebMediaPlayer* createWebMediaPlayer(
+ WebMediaPlayerClient* client, Frame* frame)
+{
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
+
+ if (!webFrame->client())
+ return 0;
+ return webFrame->client()->createMediaPlayer(webFrame, client);
+}
+
+bool WebMediaPlayerClientImpl::m_isEnabled = false;
+
+bool WebMediaPlayerClientImpl::isEnabled()
+{
+ return m_isEnabled;
+}
+
+void WebMediaPlayerClientImpl::setIsEnabled(bool isEnabled)
+{
+ m_isEnabled = isEnabled;
+}
+
+void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar)
+{
+ if (m_isEnabled) {
+ registrar(WebMediaPlayerClientImpl::create,
+ WebMediaPlayerClientImpl::getSupportedTypes,
+ WebMediaPlayerClientImpl::supportsType);
+ }
+}
+
+WebMediaPlayerClientImpl* WebMediaPlayerClientImpl::fromMediaElement(const WebMediaElement* element)
+{
+ PlatformMedia pm = element->constUnwrap<HTMLMediaElement>()->platformMedia();
+ return static_cast<WebMediaPlayerClientImpl*>(pm.media.chromiumMediaPlayer);
+}
+
+WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const
+{
+ return m_webMediaPlayer.get();
+}
+
+// WebMediaPlayerClient --------------------------------------------------------
+
+WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl()
+{
+ // VideoLayerChromium may outlive this object so make sure all frames are
+ // released.
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_videoLayer.get())
+ m_videoLayer->releaseCurrentFrame();
+#endif
+}
+
+void WebMediaPlayerClientImpl::networkStateChanged()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->networkStateChanged();
+}
+
+void WebMediaPlayerClientImpl::readyStateChanged()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->readyStateChanged();
+#if USE(ACCELERATED_COMPOSITING)
+ if (hasVideo() && supportsAcceleratedRendering() && !m_videoLayer.get())
+ m_videoLayer = VideoLayerChromium::create(0, this);
+#endif
+}
+
+void WebMediaPlayerClientImpl::volumeChanged(float newVolume)
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->volumeChanged(newVolume);
+}
+
+void WebMediaPlayerClientImpl::muteChanged(bool newMute)
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->muteChanged(newMute);
+}
+
+void WebMediaPlayerClientImpl::timeChanged()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->timeChanged();
+}
+
+void WebMediaPlayerClientImpl::repaint()
+{
+ ASSERT(m_mediaPlayer);
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_videoLayer.get() && supportsAcceleratedRendering())
+ m_videoLayer->setNeedsDisplay(FloatRect(0, 0, m_videoLayer->bounds().width(), m_videoLayer->bounds().height()));
+#endif
+ m_mediaPlayer->repaint();
+}
+
+void WebMediaPlayerClientImpl::durationChanged()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->durationChanged();
+}
+
+void WebMediaPlayerClientImpl::rateChanged()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->rateChanged();
+}
+
+void WebMediaPlayerClientImpl::sizeChanged()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->sizeChanged();
+}
+
+void WebMediaPlayerClientImpl::sawUnsupportedTracks()
+{
+ ASSERT(m_mediaPlayer);
+ m_mediaPlayer->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks(m_mediaPlayer);
+}
+
+float WebMediaPlayerClientImpl::volume() const
+{
+ if (m_mediaPlayer)
+ return m_mediaPlayer->volume();
+ return 0.0f;
+}
+
+// MediaPlayerPrivateInterface -------------------------------------------------
+
+void WebMediaPlayerClientImpl::load(const String& url)
+{
+ Frame* frame = static_cast<HTMLMediaElement*>(
+ m_mediaPlayer->mediaPlayerClient())->document()->frame();
+
+ // Video frame object is owned by WebMediaPlayer. Before destroying
+ // WebMediaPlayer all frames need to be released.
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_videoLayer.get())
+ m_videoLayer->releaseCurrentFrame();
+#endif
+
+ m_webMediaPlayer.set(createWebMediaPlayer(this, frame));
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->load(KURL(ParsedURLString, url));
+}
+
+void WebMediaPlayerClientImpl::cancelLoad()
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->cancelLoad();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* WebMediaPlayerClientImpl::platformLayer() const
+{
+ ASSERT(m_supportsAcceleratedCompositing);
+ return m_videoLayer.get();
+}
+#endif
+
+PlatformMedia WebMediaPlayerClientImpl::platformMedia() const
+{
+ PlatformMedia pm;
+ pm.type = PlatformMedia::ChromiumMediaPlayerType;
+ pm.media.chromiumMediaPlayer = const_cast<WebMediaPlayerClientImpl*>(this);
+ return pm;
+}
+
+void WebMediaPlayerClientImpl::play()
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->play();
+}
+
+void WebMediaPlayerClientImpl::pause()
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->pause();
+}
+
+IntSize WebMediaPlayerClientImpl::naturalSize() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->naturalSize();
+ return IntSize();
+}
+
+bool WebMediaPlayerClientImpl::hasVideo() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->hasVideo();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::hasAudio() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->hasAudio();
+ return false;
+}
+
+void WebMediaPlayerClientImpl::setVisible(bool visible)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->setVisible(visible);
+}
+
+float WebMediaPlayerClientImpl::duration() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->duration();
+ return 0.0f;
+}
+
+float WebMediaPlayerClientImpl::currentTime() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->currentTime();
+ return 0.0f;
+}
+
+void WebMediaPlayerClientImpl::seek(float time)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->seek(time);
+}
+
+bool WebMediaPlayerClientImpl::seeking() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->seeking();
+ return false;
+}
+
+void WebMediaPlayerClientImpl::setEndTime(float time)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->setEndTime(time);
+}
+
+void WebMediaPlayerClientImpl::setRate(float rate)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->setRate(rate);
+}
+
+bool WebMediaPlayerClientImpl::paused() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->paused();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::supportsFullscreen() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->supportsFullscreen();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::supportsSave() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->supportsSave();
+ return false;
+}
+
+void WebMediaPlayerClientImpl::setVolume(float volume)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->setVolume(volume);
+}
+
+MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const
+{
+ if (m_webMediaPlayer.get())
+ return static_cast<MediaPlayer::NetworkState>(m_webMediaPlayer->networkState());
+ return MediaPlayer::Empty;
+}
+
+MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const
+{
+ if (m_webMediaPlayer.get())
+ return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState());
+ return MediaPlayer::HaveNothing;
+}
+
+float WebMediaPlayerClientImpl::maxTimeSeekable() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->maxTimeSeekable();
+ return 0.0f;
+}
+
+PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::buffered() const
+{
+ if (m_webMediaPlayer.get()) {
+ const WebTimeRanges& webRanges = m_webMediaPlayer->buffered();
+
+ // FIXME: Save the time ranges in a member variable and update it when needed.
+ RefPtr<TimeRanges> ranges = TimeRanges::create();
+ for (size_t i = 0; i < webRanges.size(); ++i)
+ ranges->add(webRanges[i].start, webRanges[i].end);
+ return ranges.release();
+ }
+ return TimeRanges::create();
+}
+
+int WebMediaPlayerClientImpl::dataRate() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->dataRate();
+ return 0;
+}
+
+bool WebMediaPlayerClientImpl::totalBytesKnown() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->totalBytesKnown();
+ return false;
+}
+
+unsigned WebMediaPlayerClientImpl::totalBytes() const
+{
+ if (m_webMediaPlayer.get())
+ return static_cast<unsigned>(m_webMediaPlayer->totalBytes());
+ return 0;
+}
+
+unsigned WebMediaPlayerClientImpl::bytesLoaded() const
+{
+ if (m_webMediaPlayer.get())
+ return static_cast<unsigned>(m_webMediaPlayer->bytesLoaded());
+ return 0;
+}
+
+void WebMediaPlayerClientImpl::setSize(const IntSize& size)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->setSize(WebSize(size.width(), size.height()));
+}
+
+void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& rect)
+{
+ // Normally GraphicsContext operations do nothing when painting is disabled.
+ // Since we're accessing platformContext() directly we have to manually
+ // check.
+ if (m_webMediaPlayer.get() && !context->paintingDisabled()) {
+#if WEBKIT_USING_SKIA
+ PlatformGraphicsContext* platformContext = context->platformContext();
+ WebCanvas* canvas = platformContext->canvas();
+
+ canvas->saveLayerAlpha(0, platformContext->getNormalizedAlpha());
+
+ m_webMediaPlayer->paint(canvas, rect);
+
+ canvas->restore();
+#elif WEBKIT_USING_CG
+ m_webMediaPlayer->paint(context->platformContext(), rect);
+#else
+ notImplemented();
+#endif
+ }
+}
+
+void WebMediaPlayerClientImpl::setAutobuffer(bool autoBuffer)
+{
+ if (m_webMediaPlayer.get())
+ m_webMediaPlayer->setAutoBuffer(autoBuffer);
+}
+
+bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const
+{
+ if (m_webMediaPlayer.get())
+ return m_webMediaPlayer->hasSingleSecurityOrigin();
+ return false;
+}
+
+MediaPlayer::MovieLoadType WebMediaPlayerClientImpl::movieLoadType() const
+{
+ if (m_webMediaPlayer.get())
+ return static_cast<MediaPlayer::MovieLoadType>(
+ m_webMediaPlayer->movieLoadType());
+ return MediaPlayer::Unknown;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+bool WebMediaPlayerClientImpl::supportsAcceleratedRendering() const
+{
+ return m_supportsAcceleratedCompositing;
+}
+
+VideoFrameChromium* WebMediaPlayerClientImpl::getCurrentFrame()
+{
+ VideoFrameChromium* videoFrame = 0;
+ if (m_webMediaPlayer.get()) {
+ WebVideoFrame* webkitVideoFrame = m_webMediaPlayer->getCurrentFrame();
+ if (webkitVideoFrame)
+ videoFrame = new VideoFrameChromiumImpl(webkitVideoFrame);
+ }
+ return videoFrame;
+}
+
+void WebMediaPlayerClientImpl::putCurrentFrame(VideoFrameChromium* videoFrame)
+{
+ if (videoFrame) {
+ if (m_webMediaPlayer.get()) {
+ m_webMediaPlayer->putCurrentFrame(
+ VideoFrameChromiumImpl::toWebVideoFrame(videoFrame));
+ }
+ delete videoFrame;
+ }
+}
+#endif
+
+MediaPlayerPrivateInterface* WebMediaPlayerClientImpl::create(MediaPlayer* player)
+{
+ WebMediaPlayerClientImpl* client = new WebMediaPlayerClientImpl();
+ client->m_mediaPlayer = player;
+
+#if USE(ACCELERATED_COMPOSITING)
+ Frame* frame = static_cast<HTMLMediaElement*>(
+ client->m_mediaPlayer->mediaPlayerClient())->document()->frame();
+
+ // This does not actually check whether the hardware can support accelerated
+ // compositing, but only if the flag is set. However, this is checked lazily
+ // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there
+ // if necessary.
+ client->m_supportsAcceleratedCompositing =
+ frame->contentRenderer()->compositor()->hasAcceleratedCompositing();
+#endif
+
+ return client;
+}
+
+void WebMediaPlayerClientImpl::getSupportedTypes(HashSet<String>& supportedTypes)
+{
+ // FIXME: integrate this list with WebMediaPlayerClientImpl::supportsType.
+ notImplemented();
+}
+
+MediaPlayer::SupportsType WebMediaPlayerClientImpl::supportsType(const String& type,
+ const String& codecs)
+{
+ WebMimeRegistry::SupportsType supportsType =
+ webKitClient()->mimeRegistry()->supportsMediaMIMEType(type, codecs);
+
+ switch (supportsType) {
+ default:
+ ASSERT_NOT_REACHED();
+ case WebMimeRegistry::IsNotSupported:
+ return MediaPlayer::IsNotSupported;
+ case WebMimeRegistry::IsSupported:
+ return MediaPlayer::IsSupported;
+ case WebMimeRegistry::MayBeSupported:
+ return MediaPlayer::MayBeSupported;
+ }
+ return MediaPlayer::IsNotSupported;
+}
+
+WebMediaPlayerClientImpl::WebMediaPlayerClientImpl()
+ : m_mediaPlayer(0)
+#if USE(ACCELERATED_COMPOSITING)
+ , m_videoLayer(0)
+ , m_supportsAcceleratedCompositing(false)
+#endif
+{
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(VIDEO)
diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h
new file mode 100644
index 0000000..ca7c43c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebMediaPlayerClientImpl_h
+#define WebMediaPlayerClientImpl_h
+
+#if ENABLE(VIDEO)
+
+#include "MediaPlayerPrivate.h"
+#include "VideoFrameChromium.h"
+#include "VideoFrameProvider.h"
+#include "VideoLayerChromium.h"
+#include "WebMediaPlayerClient.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebKit {
+
+class WebMediaElement;
+class WebMediaPlayer;
+
+// This class serves as a bridge between WebCore::MediaPlayer and
+// WebKit::WebMediaPlayer.
+class WebMediaPlayerClientImpl : public WebCore::MediaPlayerPrivateInterface
+#if USE(ACCELERATED_COMPOSITING)
+ , public WebCore::VideoFrameProvider
+#endif
+ , public WebMediaPlayerClient {
+
+public:
+ static bool isEnabled();
+ static void setIsEnabled(bool);
+ static void registerSelf(WebCore::MediaEngineRegistrar);
+
+ static WebMediaPlayerClientImpl* fromMediaElement(const WebMediaElement* element);
+
+ // Returns the encapsulated WebKit::WebMediaPlayer.
+ WebMediaPlayer* mediaPlayer() const;
+
+ // WebMediaPlayerClient methods:
+ virtual ~WebMediaPlayerClientImpl();
+ virtual void networkStateChanged();
+ virtual void readyStateChanged();
+ virtual void volumeChanged(float);
+ virtual void muteChanged(bool);
+ virtual void timeChanged();
+ virtual void repaint();
+ virtual void durationChanged();
+ virtual void rateChanged();
+ virtual void sizeChanged();
+ virtual void sawUnsupportedTracks();
+ virtual float volume() const;
+
+ // MediaPlayerPrivateInterface methods:
+ virtual void load(const WTF::String& url);
+ virtual void cancelLoad();
+#if USE(ACCELERATED_COMPOSITING)
+ virtual WebCore::PlatformLayer* platformLayer() const;
+#endif
+ virtual WebCore::PlatformMedia platformMedia() const;
+ virtual void play();
+ virtual void pause();
+ virtual bool supportsFullscreen() const;
+ virtual bool supportsSave() const;
+ virtual WebCore::IntSize naturalSize() const;
+ virtual bool hasVideo() const;
+ virtual bool hasAudio() const;
+ virtual void setVisible(bool);
+ virtual float duration() const;
+ virtual float currentTime() const;
+ virtual void seek(float time);
+ virtual bool seeking() const;
+ virtual void setEndTime(float time);
+ virtual void setRate(float);
+ virtual bool paused() const;
+ virtual void setVolume(float);
+ virtual WebCore::MediaPlayer::NetworkState networkState() const;
+ virtual WebCore::MediaPlayer::ReadyState readyState() const;
+ virtual float maxTimeSeekable() const;
+ virtual WTF::PassRefPtr<WebCore::TimeRanges> buffered() const;
+ virtual int dataRate() const;
+ virtual void setAutobuffer(bool);
+ virtual bool totalBytesKnown() const;
+ virtual unsigned totalBytes() const;
+ virtual unsigned bytesLoaded() const;
+ virtual void setSize(const WebCore::IntSize&);
+ virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
+ virtual bool hasSingleSecurityOrigin() const;
+ virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const;
+#if USE(ACCELERATED_COMPOSITING)
+ virtual bool supportsAcceleratedRendering() const;
+
+ // VideoFrameProvider methods:
+ virtual WebCore::VideoFrameChromium* getCurrentFrame();
+ virtual void putCurrentFrame(WebCore::VideoFrameChromium*);
+#endif
+
+private:
+ WebMediaPlayerClientImpl();
+
+ static WebCore::MediaPlayerPrivateInterface* create(WebCore::MediaPlayer*);
+ static void getSupportedTypes(WTF::HashSet<WTF::String>&);
+ static WebCore::MediaPlayer::SupportsType supportsType(
+ const WTF::String& type, const WTF::String& codecs);
+
+ WebCore::MediaPlayer* m_mediaPlayer;
+ OwnPtr<WebMediaPlayer> m_webMediaPlayer;
+#if USE(ACCELERATED_COMPOSITING)
+ RefPtr<WebCore::VideoLayerChromium> m_videoLayer;
+ bool m_supportsAcceleratedCompositing;
+#endif
+ static bool m_isEnabled;
+};
+
+} // namespace WebKit
+
+#endif
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebMutationEvent.cpp b/Source/WebKit/chromium/src/WebMutationEvent.cpp
new file mode 100644
index 0000000..511b615
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebMutationEvent.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebMutationEvent.h"
+
+#include "MutationEvent.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebNode WebMutationEvent::relatedNode() const
+{
+ return WebNode(constUnwrap<MutationEvent>()->relatedNode());
+}
+
+WebString WebMutationEvent::prevValue() const
+{
+ return WebString(constUnwrap<MutationEvent>()->prevValue());
+}
+
+WebString WebMutationEvent::newValue() const
+{
+ return WebString(constUnwrap<MutationEvent>()->newValue());
+}
+
+WebString WebMutationEvent::attrName() const
+{
+ return WebString(constUnwrap<MutationEvent>()->attrName());
+}
+
+WebMutationEvent::AttrChangeType WebMutationEvent::attrChange() const
+{
+ return static_cast<AttrChangeType>(constUnwrap<MutationEvent>()->attrChange());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebNamedNodeMap.cpp b/Source/WebKit/chromium/src/WebNamedNodeMap.cpp
new file mode 100644
index 0000000..e2455e6
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebNamedNodeMap.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebNamedNodeMap.h"
+
+#include "NamedNodeMap.h"
+#include "Node.h"
+#include "WebAttribute.h"
+#include "WebNode.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebNamedNodeMap::reset()
+{
+ m_private.reset();
+}
+
+void WebNamedNodeMap::assign(const WebNamedNodeMap& other)
+{
+ m_private = other.m_private;
+}
+
+WebNamedNodeMap::WebNamedNodeMap(const PassRefPtr<NamedNodeMap>& other)
+ : m_private(other)
+{
+}
+
+unsigned WebNamedNodeMap::length() const
+{
+ return m_private->length();
+}
+
+WebAttribute WebNamedNodeMap::attributeItem(unsigned index) const
+{
+ return WebAttribute(m_private->attributeItem(index));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebNode.cpp b/Source/WebKit/chromium/src/WebNode.cpp
new file mode 100644
index 0000000..e91d1ee
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebNode.cpp
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebNode.h"
+
+#include "Document.h"
+#include "Element.h"
+#include "Frame.h"
+#include "FrameLoaderClientImpl.h"
+#include "Node.h"
+#include "NodeList.h"
+
+#include "EventListenerWrapper.h"
+#include "WebDOMEvent.h"
+#include "WebDOMEventListener.h"
+#include "WebDocument.h"
+#include "WebFrameImpl.h"
+#include "WebNodeList.h"
+#include "WebString.h"
+#include "WebVector.h"
+
+#include "markup.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebNode::reset()
+{
+ m_private.reset();
+}
+
+void WebNode::assign(const WebNode& other)
+{
+ m_private = other.m_private;
+}
+
+bool WebNode::equals(const WebNode& n) const
+{
+ return (m_private.get() == n.m_private.get());
+}
+
+bool WebNode::lessThan(const WebNode& n) const
+{
+ return (m_private.get() < n.m_private.get());
+}
+
+WebNode::NodeType WebNode::nodeType() const
+{
+ return static_cast<NodeType>(m_private->nodeType());
+}
+
+WebNode WebNode::parentNode() const
+{
+ return WebNode(const_cast<ContainerNode*>(m_private->parentNode()));
+}
+
+WebString WebNode::nodeName() const
+{
+ return m_private->nodeName();
+}
+
+WebString WebNode::nodeValue() const
+{
+ return m_private->nodeValue();
+}
+
+bool WebNode::setNodeValue(const WebString& value)
+{
+ ExceptionCode exceptionCode = 0;
+ m_private->setNodeValue(value, exceptionCode);
+ return !exceptionCode;
+}
+
+WebDocument WebNode::document() const
+{
+ return WebDocument(m_private->document());
+}
+
+WebNode WebNode::firstChild() const
+{
+ return WebNode(m_private->firstChild());
+}
+
+WebNode WebNode::lastChild() const
+{
+ return WebNode(m_private->lastChild());
+}
+
+WebNode WebNode::previousSibling() const
+{
+ return WebNode(m_private->previousSibling());
+}
+
+WebNode WebNode::nextSibling() const
+{
+ return WebNode(m_private->nextSibling());
+}
+
+bool WebNode::hasChildNodes() const
+{
+ return m_private->hasChildNodes();
+}
+
+WebNodeList WebNode::childNodes()
+{
+ return WebNodeList(m_private->childNodes());
+}
+
+WebString WebNode::createMarkup() const
+{
+ return WebCore::createMarkup(m_private.get());
+}
+
+bool WebNode::isTextNode() const
+{
+ return m_private->isTextNode();
+}
+
+bool WebNode::isContentEditable() const
+{
+ return m_private->isContentEditable();
+}
+
+bool WebNode::isElementNode() const
+{
+ return m_private->isElementNode();
+}
+
+void WebNode::addEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture)
+{
+ EventListenerWrapper* listenerWrapper =
+ listener->createEventListenerWrapper(eventType, useCapture, m_private.get());
+ // The listenerWrapper is only referenced by the actual Node. Once it goes
+ // away, the wrapper notifies the WebEventListener so it can clear its
+ // pointer to it.
+ m_private->addEventListener(eventType, adoptRef(listenerWrapper), useCapture);
+}
+
+void WebNode::removeEventListener(const WebString& eventType, WebDOMEventListener* listener, bool useCapture)
+{
+ EventListenerWrapper* listenerWrapper =
+ listener->getEventListenerWrapper(eventType, useCapture, m_private.get());
+ m_private->removeEventListener(eventType, listenerWrapper, useCapture);
+ // listenerWrapper is now deleted.
+}
+
+void WebNode::simulateClick()
+{
+ RefPtr<Event> noEvent;
+ m_private->dispatchSimulatedClick(noEvent);
+}
+
+WebNodeList WebNode::getElementsByTagName(const WebString& tag) const
+{
+ return WebNodeList(m_private->getElementsByTagName(tag));
+}
+
+bool WebNode::hasNonEmptyBoundingBox() const
+{
+ return m_private->hasNonEmptyBoundingBox();
+}
+
+WebNode::WebNode(const PassRefPtr<Node>& node)
+ : m_private(node)
+{
+}
+
+WebNode& WebNode::operator=(const PassRefPtr<Node>& node)
+{
+ m_private = node;
+ return *this;
+}
+
+WebNode::operator PassRefPtr<Node>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebNodeCollection.cpp b/Source/WebKit/chromium/src/WebNodeCollection.cpp
new file mode 100644
index 0000000..a9e532f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebNodeCollection.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebNodeCollection.h"
+
+#include "HTMLCollection.h"
+#include "Node.h"
+#include <wtf/PassRefPtr.h>
+
+#include "WebNode.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebNodeCollection::reset()
+{
+ assign(0);
+}
+
+void WebNodeCollection::assign(const WebNodeCollection& other)
+{
+ HTMLCollection* p = const_cast<HTMLCollection*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+WebNodeCollection::WebNodeCollection(const PassRefPtr<HTMLCollection>& col)
+ : m_private(static_cast<HTMLCollection*>(col.releaseRef()))
+{
+}
+
+void WebNodeCollection::assign(HTMLCollection* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+unsigned WebNodeCollection::length() const
+{
+ return m_private->length();
+}
+
+WebNode WebNodeCollection::nextItem() const
+{
+ return WebNode(m_private->nextItem());
+}
+
+WebNode WebNodeCollection::firstItem() const
+{
+ return WebNode(m_private->firstItem());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebNodeList.cpp b/Source/WebKit/chromium/src/WebNodeList.cpp
new file mode 100644
index 0000000..f68f961
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebNodeList.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebNodeList.h"
+
+#include "Node.h"
+#include "NodeList.h"
+#include <wtf/PassRefPtr.h>
+
+#include "WebNode.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebNodeList::reset()
+{
+ assign(0);
+}
+
+void WebNodeList::assign(const WebNodeList& other)
+{
+ NodeList* p = const_cast<NodeList*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+WebNodeList::WebNodeList(const PassRefPtr<NodeList>& col)
+ : m_private(static_cast<NodeList*>(col.releaseRef()))
+{
+}
+
+void WebNodeList::assign(NodeList* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+unsigned WebNodeList::length() const
+{
+ return m_private->length();
+}
+
+WebNode WebNodeList::item(size_t index) const
+{
+ return WebNode(m_private->item(index));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebNotification.cpp b/Source/WebKit/chromium/src/WebNotification.cpp
new file mode 100644
index 0000000..c3b1f51
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebNotification.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebNotification.h"
+
+#if ENABLE(NOTIFICATIONS)
+
+#include "Notification.h"
+#include "UserGestureIndicator.h"
+
+#include "WebString.h"
+#include "WebTextDirection.h"
+#include "WebURL.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebNotificationPrivate : public Notification {
+};
+
+void WebNotification::reset()
+{
+ assign(0);
+}
+
+void WebNotification::assign(const WebNotification& other)
+{
+ WebNotificationPrivate* p = const_cast<WebNotificationPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+bool WebNotification::lessThan(const WebNotification& other) const
+{
+ return reinterpret_cast<uintptr_t>(m_private) < reinterpret_cast<uintptr_t>(other.m_private);
+}
+
+bool WebNotification::isHTML() const
+{
+ return m_private->isHTML();
+}
+
+WebURL WebNotification::url() const
+{
+ ASSERT(isHTML());
+ return m_private->url();
+}
+
+WebURL WebNotification::iconURL() const
+{
+ ASSERT(!isHTML());
+ return m_private->iconURL();
+}
+
+WebString WebNotification::title() const
+{
+ ASSERT(!isHTML());
+ return m_private->contents().title();
+}
+
+WebString WebNotification::body() const
+{
+ ASSERT(!isHTML());
+ return m_private->contents().body();
+}
+
+// FIXME: remove dir() when unreferenced. Being replaced by direction().
+WebString WebNotification::dir() const
+{
+ return m_private->dir();
+}
+
+WebTextDirection WebNotification::direction() const
+{
+ return (m_private->direction() == RTL) ?
+ WebTextDirectionRightToLeft :
+ WebTextDirectionLeftToRight;
+}
+
+WebString WebNotification::replaceId() const
+{
+ return m_private->replaceId();
+}
+
+void WebNotification::detachPresenter()
+{
+ m_private->detachPresenter();
+}
+
+void WebNotification::dispatchDisplayEvent()
+{
+ RefPtr<Event> event = Event::create("display", false, true);
+ m_private->dispatchEvent(event.release());
+}
+
+void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */)
+{
+ // FIXME: errorMessage not supported by WebCore yet
+ RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true);
+ m_private->dispatchEvent(event.release());
+}
+
+void WebNotification::dispatchCloseEvent(bool /* byUser */)
+{
+ // FIXME: byUser flag not supported by WebCore yet
+ RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true);
+ m_private->dispatchEvent(event.release());
+}
+
+void WebNotification::dispatchClickEvent()
+{
+ // Make sure clicks on notifications are treated as user gestures.
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
+ RefPtr<Event> event = Event::create(eventNames().clickEvent, false, true);
+ m_private->dispatchEvent(event.release());
+}
+
+WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notification)
+ : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef()))
+{
+}
+
+WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification)
+{
+ assign(static_cast<WebNotificationPrivate*>(notification.releaseRef()));
+ return *this;
+}
+
+WebNotification::operator WTF::PassRefPtr<Notification>() const
+{
+ return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_private));
+}
+
+void WebNotification::assign(WebNotificationPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS)
diff --git a/Source/WebKit/chromium/src/WebOptionElement.cpp b/Source/WebKit/chromium/src/WebOptionElement.cpp
new file mode 100644
index 0000000..49bff3b
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebOptionElement.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebOptionElement.h"
+
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "HTMLSelectElement.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebOptionElement::setValue(const WebString& newValue)
+{
+ return unwrap<HTMLOptionElement>()->setValue(newValue);
+}
+
+WebString WebOptionElement::value() const
+{
+ return constUnwrap<HTMLOptionElement>()->value();
+}
+
+int WebOptionElement::index() const
+{
+ return constUnwrap<HTMLOptionElement>()->index();
+}
+
+WebString WebOptionElement::text() const
+{
+ return constUnwrap<HTMLOptionElement>()->text();
+}
+
+bool WebOptionElement::defaultSelected() const
+{
+ return constUnwrap<HTMLOptionElement>()->defaultSelected();
+}
+
+void WebOptionElement::setDefaultSelected(bool newSelected)
+{
+ return unwrap<HTMLOptionElement>()->setDefaultSelected(newSelected);
+}
+
+WebString WebOptionElement::label() const
+{
+ return constUnwrap<HTMLOptionElement>()->label();
+}
+
+bool WebOptionElement::isEnabled() const
+{
+ return !(constUnwrap<HTMLOptionElement>()->disabled());
+}
+
+WebOptionElement::WebOptionElement(const PassRefPtr<HTMLOptionElement>& elem)
+ : WebFormControlElement(elem)
+{
+}
+
+WebOptionElement& WebOptionElement::operator=(const PassRefPtr<HTMLOptionElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebOptionElement::operator PassRefPtr<HTMLOptionElement>() const
+{
+ return static_cast<HTMLOptionElement*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPageSerializer.cpp b/Source/WebKit/chromium/src/WebPageSerializer.cpp
new file mode 100644
index 0000000..1fda484
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPageSerializer.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPageSerializer.h"
+
+#include "KURL.h"
+
+#include "WebFrame.h"
+#include "WebPageSerializerClient.h"
+#include "WebPageSerializerImpl.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebVector.h"
+
+#include <wtf/text/StringConcatenate.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebPageSerializer::serialize(WebFrame* frame,
+ bool recursive,
+ WebPageSerializerClient* client,
+ const WebVector<WebURL>& links,
+ const WebVector<WebString>& localPaths,
+ const WebString& localDirectoryName)
+{
+ WebPageSerializerImpl serializerImpl(
+ frame, recursive, client, links, localPaths, localDirectoryName);
+ return serializerImpl.serialize();
+}
+
+WebString WebPageSerializer::generateMetaCharsetDeclaration(const WebString& charset)
+{
+ return makeString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=", static_cast<const String&>(charset), "\">");
+}
+
+WebString WebPageSerializer::generateMarkOfTheWebDeclaration(const WebURL& url)
+{
+ return String::format("\n<!-- saved from url=(%04d)%s -->\n",
+ static_cast<int>(url.spec().length()),
+ url.spec().data());
+}
+
+WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTarget)
+{
+ if (baseTarget.isEmpty())
+ return makeString("<base href=\".\">");
+ return makeString("<base href=\".\" target=\"", static_cast<const String&>(baseTarget), "\">");
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp b/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp
new file mode 100644
index 0000000..0d85d78
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp
@@ -0,0 +1,526 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// How we handle the base tag better.
+// Current status:
+// At now the normal way we use to handling base tag is
+// a) For those links which have corresponding local saved files, such as
+// savable CSS, JavaScript files, they will be written to relative URLs which
+// point to local saved file. Why those links can not be resolved as absolute
+// file URLs, because if they are resolved as absolute URLs, after moving the
+// file location from one directory to another directory, the file URLs will
+// be dead links.
+// b) For those links which have not corresponding local saved files, such as
+// links in A, AREA tags, they will be resolved as absolute URLs.
+// c) We comment all base tags when serialzing DOM for the page.
+// FireFox also uses above way to handle base tag.
+//
+// Problem:
+// This way can not handle the following situation:
+// the base tag is written by JavaScript.
+// For example. The page "www.yahoo.com" use
+// "document.write('<base href="http://www.yahoo.com/"...');" to setup base URL
+// of page when loading page. So when saving page as completed-HTML, we assume
+// that we save "www.yahoo.com" to "c:\yahoo.htm". After then we load the saved
+// completed-HTML page, then the JavaScript will insert a base tag
+// <base href="http://www.yahoo.com/"...> to DOM, so all URLs which point to
+// local saved resource files will be resolved as
+// "http://www.yahoo.com/yahoo_files/...", which will cause all saved resource
+// files can not be loaded correctly. Also the page will be rendered ugly since
+// all saved sub-resource files (such as CSS, JavaScript files) and sub-frame
+// files can not be fetched.
+// Now FireFox, IE and WebKit based Browser all have this problem.
+//
+// Solution:
+// My solution is that we comment old base tag and write new base tag:
+// <base href="." ...> after the previous commented base tag. In WebKit, it
+// always uses the latest "href" attribute of base tag to set document's base
+// URL. Based on this behavior, when we encounter a base tag, we comment it and
+// write a new base tag <base href="."> after the previous commented base tag.
+// The new added base tag can help engine to locate correct base URL for
+// correctly loading local saved resource files. Also I think we need to inherit
+// the base target value from document object when appending new base tag.
+// If there are multiple base tags in original document, we will comment all old
+// base tags and append new base tag after each old base tag because we do not
+// know those old base tags are original content or added by JavaScript. If
+// they are added by JavaScript, it means when loading saved page, the script(s)
+// will still insert base tag(s) to DOM, so the new added base tag(s) can
+// override the incorrect base URL and make sure we alway load correct local
+// saved resource files.
+
+#include "config.h"
+#include "WebPageSerializerImpl.h"
+
+#include "Document.h"
+#include "DocumentType.h"
+#include "Element.h"
+#include "FrameLoader.h"
+#include "HTMLAllCollection.h"
+#include "HTMLElement.h"
+#include "HTMLFormElement.h"
+#include "HTMLMetaElement.h"
+#include "HTMLNames.h"
+#include "KURL.h"
+#include "TextEncoding.h"
+#include "markup.h"
+
+#include "DOMUtilitiesPrivate.h"
+#include "WebFrameImpl.h"
+#include "WebURL.h"
+#include "WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Maximum length of data buffer which is used to temporary save generated
+// html content data. This is a soft limit which might be passed if a very large
+// contegious string is found in the page.
+static const unsigned dataBufferCapacity = 65536;
+
+WebPageSerializerImpl::SerializeDomParam::SerializeDomParam(const KURL& url,
+ const TextEncoding& textEncoding,
+ Document* document,
+ const String& directoryName)
+ : url(url)
+ , textEncoding(textEncoding)
+ , document(document)
+ , directoryName(directoryName)
+ , isHTMLDocument(document->isHTMLDocument())
+ , haveSeenDocType(false)
+ , haveAddedCharsetDeclaration(false)
+ , skipMetaElement(0)
+ , isInScriptOrStyleTag(false)
+ , haveAddedXMLProcessingDirective(false)
+ , haveAddedContentsBeforeEnd(false)
+{
+}
+
+String WebPageSerializerImpl::preActionBeforeSerializeOpenTag(
+ const Element* element, SerializeDomParam* param, bool* needSkip)
+{
+ StringBuilder result;
+
+ *needSkip = false;
+ if (param->isHTMLDocument) {
+ // Skip the open tag of original META tag which declare charset since we
+ // have overrided the META which have correct charset declaration after
+ // serializing open tag of HEAD element.
+ if (element->hasTagName(HTMLNames::metaTag)) {
+ const HTMLMetaElement* meta = static_cast<const HTMLMetaElement*>(element);
+ // Check whether the META tag has declared charset or not.
+ String equiv = meta->httpEquiv();
+ if (equalIgnoringCase(equiv, "content-type")) {
+ String content = meta->content();
+ if (content.length() && content.contains("charset", false)) {
+ // Find META tag declared charset, we need to skip it when
+ // serializing DOM.
+ param->skipMetaElement = element;
+ *needSkip = true;
+ }
+ }
+ } else if (element->hasTagName(HTMLNames::htmlTag)) {
+ // Check something before processing the open tag of HEAD element.
+ // First we add doc type declaration if original document has it.
+ if (!param->haveSeenDocType) {
+ param->haveSeenDocType = true;
+ result.append(createMarkup(param->document->doctype()));
+ }
+
+ // Add MOTW declaration before html tag.
+ // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx.
+ result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(param->url));
+ } else if (element->hasTagName(HTMLNames::baseTag)) {
+ // Comment the BASE tag when serializing dom.
+ result.append("<!--");
+ }
+ } else {
+ // Write XML declaration.
+ if (!param->haveAddedXMLProcessingDirective) {
+ param->haveAddedXMLProcessingDirective = true;
+ // Get encoding info.
+ String xmlEncoding = param->document->xmlEncoding();
+ if (xmlEncoding.isEmpty())
+ xmlEncoding = param->document->frame()->loader()->writer()->encoding();
+ if (xmlEncoding.isEmpty())
+ xmlEncoding = UTF8Encoding().name();
+ result.append("<?xml version=\"");
+ result.append(param->document->xmlVersion());
+ result.append("\" encoding=\"");
+ result.append(xmlEncoding);
+ if (param->document->xmlStandalone())
+ result.append("\" standalone=\"yes");
+ result.append("\"?>\n");
+ }
+ // Add doc type declaration if original document has it.
+ if (!param->haveSeenDocType) {
+ param->haveSeenDocType = true;
+ result.append(createMarkup(param->document->doctype()));
+ }
+ }
+ return result.toString();
+}
+
+String WebPageSerializerImpl::postActionAfterSerializeOpenTag(
+ const Element* element, SerializeDomParam* param)
+{
+ StringBuilder result;
+
+ param->haveAddedContentsBeforeEnd = false;
+ if (!param->isHTMLDocument)
+ return result.toString();
+ // Check after processing the open tag of HEAD element
+ if (!param->haveAddedCharsetDeclaration
+ && element->hasTagName(HTMLNames::headTag)) {
+ param->haveAddedCharsetDeclaration = true;
+ // Check meta element. WebKit only pre-parse the first 512 bytes
+ // of the document. If the whole <HEAD> is larger and meta is the
+ // end of head part, then this kind of pages aren't decoded correctly
+ // because of this issue. So when we serialize the DOM, we need to
+ // make sure the meta will in first child of head tag.
+ // See http://bugs.webkit.org/show_bug.cgi?id=16621.
+ // First we generate new content for writing correct META element.
+ result.append(WebPageSerializer::generateMetaCharsetDeclaration(
+ String(param->textEncoding.name())));
+
+ param->haveAddedContentsBeforeEnd = true;
+ // Will search each META which has charset declaration, and skip them all
+ // in PreActionBeforeSerializeOpenTag.
+ } else if (element->hasTagName(HTMLNames::scriptTag)
+ || element->hasTagName(HTMLNames::styleTag)) {
+ param->isInScriptOrStyleTag = true;
+ }
+
+ return result.toString();
+}
+
+String WebPageSerializerImpl::preActionBeforeSerializeEndTag(
+ const Element* element, SerializeDomParam* param, bool* needSkip)
+{
+ String result;
+
+ *needSkip = false;
+ if (!param->isHTMLDocument)
+ return result;
+ // Skip the end tag of original META tag which declare charset.
+ // Need not to check whether it's META tag since we guarantee
+ // skipMetaElement is definitely META tag if it's not 0.
+ if (param->skipMetaElement == element)
+ *needSkip = true;
+ else if (element->hasTagName(HTMLNames::scriptTag)
+ || element->hasTagName(HTMLNames::styleTag)) {
+ ASSERT(param->isInScriptOrStyleTag);
+ param->isInScriptOrStyleTag = false;
+ }
+
+ return result;
+}
+
+// After we finish serializing end tag of a element, we give the target
+// element a chance to do some post work to add some additional data.
+String WebPageSerializerImpl::postActionAfterSerializeEndTag(
+ const Element* element, SerializeDomParam* param)
+{
+ StringBuilder result;
+
+ if (!param->isHTMLDocument)
+ return result.toString();
+ // Comment the BASE tag when serializing DOM.
+ if (element->hasTagName(HTMLNames::baseTag)) {
+ result.append("-->");
+ // Append a new base tag declaration.
+ result.append(WebPageSerializer::generateBaseTagDeclaration(
+ param->document->baseTarget()));
+ }
+
+ return result.toString();
+}
+
+void WebPageSerializerImpl::saveHTMLContentToBuffer(
+ const String& result, SerializeDomParam* param)
+{
+ m_dataBuffer.append(result);
+ encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsNotFinished,
+ param,
+ DoNotForceFlush);
+}
+
+void WebPageSerializerImpl::encodeAndFlushBuffer(
+ WebPageSerializerClient::PageSerializationStatus status,
+ SerializeDomParam* param,
+ FlushOption flushOption)
+{
+ // Data buffer is not full nor do we want to force flush.
+ if (flushOption != ForceFlush && m_dataBuffer.length() <= dataBufferCapacity)
+ return;
+
+ String content = m_dataBuffer.toString();
+ m_dataBuffer = StringBuilder();
+
+ // Convert the unicode content to target encoding
+ CString encodedContent = param->textEncoding.encode(
+ content.characters(), content.length(), EntitiesForUnencodables);
+
+ // Send result to the client.
+ m_client->didSerializeDataForFrame(param->url,
+ WebCString(encodedContent.data(), encodedContent.length()),
+ status);
+}
+
+void WebPageSerializerImpl::openTagToString(const Element* element,
+ SerializeDomParam* param)
+{
+ // FIXME: use StringBuilder instead of String.
+ bool needSkip;
+ // Do pre action for open tag.
+ String result = preActionBeforeSerializeOpenTag(element, param, &needSkip);
+ if (needSkip)
+ return;
+ // Add open tag
+ result += "<" + element->nodeName().lower();
+ // Go through all attributes and serialize them.
+ const NamedNodeMap *attrMap = element->attributes(true);
+ if (attrMap) {
+ unsigned numAttrs = attrMap->length();
+ for (unsigned i = 0; i < numAttrs; i++) {
+ result += " ";
+ // Add attribute pair
+ const Attribute *attribute = attrMap->attributeItem(i);
+ result += attribute->name().toString();
+ result += "=\"";
+ if (!attribute->value().isEmpty()) {
+ const String& attrValue = attribute->value();
+
+ // Check whether we need to replace some resource links
+ // with local resource paths.
+ const QualifiedName& attrName = attribute->name();
+ if (elementHasLegalLinkAttribute(element, attrName)) {
+ // For links start with "javascript:", we do not change it.
+ if (attrValue.startsWith("javascript:", false))
+ result += attrValue;
+ else {
+ // Get the absolute link
+ String completeURL = param->document->completeURL(attrValue);
+ // Check whether we have local files for those link.
+ if (m_localLinks.contains(completeURL)) {
+ if (!m_localDirectoryName.isEmpty())
+ result += "./" + m_localDirectoryName + "/";
+ result += m_localLinks.get(completeURL);
+ } else
+ result += completeURL;
+ }
+ } else {
+ if (param->isHTMLDocument)
+ result += m_htmlEntities.convertEntitiesInString(attrValue);
+ else
+ result += m_xmlEntities.convertEntitiesInString(attrValue);
+ }
+ }
+ result += "\"";
+ }
+ }
+
+ // Do post action for open tag.
+ String addedContents = postActionAfterSerializeOpenTag(element, param);
+ // Complete the open tag for element when it has child/children.
+ if (element->hasChildNodes() || param->haveAddedContentsBeforeEnd)
+ result += ">";
+ // Append the added contents generate in post action of open tag.
+ result += addedContents;
+ // Save the result to data buffer.
+ saveHTMLContentToBuffer(result, param);
+}
+
+// Serialize end tag of an specified element.
+void WebPageSerializerImpl::endTagToString(const Element* element,
+ SerializeDomParam* param)
+{
+ bool needSkip;
+ // Do pre action for end tag.
+ String result = preActionBeforeSerializeEndTag(element,
+ param,
+ &needSkip);
+ if (needSkip)
+ return;
+ // Write end tag when element has child/children.
+ if (element->hasChildNodes() || param->haveAddedContentsBeforeEnd) {
+ result += "</";
+ result += element->nodeName().lower();
+ result += ">";
+ } else {
+ // Check whether we have to write end tag for empty element.
+ if (param->isHTMLDocument) {
+ result += ">";
+ // FIXME: This code is horribly wrong. WebPageSerializerImpl must die.
+ if (!static_cast<const HTMLElement*>(element)->ieForbidsInsertHTML()) {
+ // We need to write end tag when it is required.
+ result += "</";
+ result += element->nodeName().lower();
+ result += ">";
+ }
+ } else {
+ // For xml base document.
+ result += " />";
+ }
+ }
+ // Do post action for end tag.
+ result += postActionAfterSerializeEndTag(element, param);
+ // Save the result to data buffer.
+ saveHTMLContentToBuffer(result, param);
+}
+
+void WebPageSerializerImpl::buildContentForNode(const Node* node,
+ SerializeDomParam* param)
+{
+ switch (node->nodeType()) {
+ case Node::ELEMENT_NODE:
+ // Process open tag of element.
+ openTagToString(static_cast<const Element*>(node), param);
+ // Walk through the children nodes and process it.
+ for (const Node *child = node->firstChild(); child; child = child->nextSibling())
+ buildContentForNode(child, param);
+ // Process end tag of element.
+ endTagToString(static_cast<const Element*>(node), param);
+ break;
+ case Node::TEXT_NODE:
+ saveHTMLContentToBuffer(createMarkup(node), param);
+ break;
+ case Node::ATTRIBUTE_NODE:
+ case Node::DOCUMENT_NODE:
+ case Node::DOCUMENT_FRAGMENT_NODE:
+ // Should not exist.
+ ASSERT_NOT_REACHED();
+ break;
+ // Document type node can be in DOM?
+ case Node::DOCUMENT_TYPE_NODE:
+ param->haveSeenDocType = true;
+ default:
+ // For other type node, call default action.
+ saveHTMLContentToBuffer(createMarkup(node), param);
+ break;
+ }
+}
+
+WebPageSerializerImpl::WebPageSerializerImpl(WebFrame* frame,
+ bool recursiveSerialization,
+ WebPageSerializerClient* client,
+ const WebVector<WebURL>& links,
+ const WebVector<WebString>& localPaths,
+ const WebString& localDirectoryName)
+ : m_client(client)
+ , m_recursiveSerialization(recursiveSerialization)
+ , m_framesCollected(false)
+ , m_localDirectoryName(localDirectoryName)
+ , m_htmlEntities(false)
+ , m_xmlEntities(true)
+{
+ // Must specify available webframe.
+ ASSERT(frame);
+ m_specifiedWebFrameImpl = static_cast<WebFrameImpl*>(frame);
+ // Make sure we have non 0 client.
+ ASSERT(client);
+ // Build local resources map.
+ ASSERT(links.size() == localPaths.size());
+ for (size_t i = 0; i < links.size(); i++) {
+ KURL url = links[i];
+ ASSERT(!m_localLinks.contains(url.string()));
+ m_localLinks.set(url.string(), localPaths[i]);
+ }
+
+ ASSERT(m_dataBuffer.isEmpty());
+}
+
+void WebPageSerializerImpl::collectTargetFrames()
+{
+ ASSERT(!m_framesCollected);
+ m_framesCollected = true;
+
+ // First, process main frame.
+ m_frames.append(m_specifiedWebFrameImpl);
+ // Return now if user only needs to serialize specified frame, not including
+ // all sub-frames.
+ if (!m_recursiveSerialization)
+ return;
+ // Collect all frames inside the specified frame.
+ for (int i = 0; i < static_cast<int>(m_frames.size()); ++i) {
+ WebFrameImpl* currentFrame = m_frames[i];
+ // Get current using document.
+ Document* currentDoc = currentFrame->frame()->document();
+ // Go through sub-frames.
+ RefPtr<HTMLAllCollection> all = currentDoc->all();
+ for (Node* node = all->firstItem(); node; node = all->nextItem()) {
+ if (!node->isHTMLElement())
+ continue;
+ Element* element = static_cast<Element*>(node);
+ WebFrameImpl* webFrame =
+ WebFrameImpl::fromFrameOwnerElement(element);
+ if (webFrame)
+ m_frames.append(webFrame);
+ }
+ }
+}
+
+bool WebPageSerializerImpl::serialize()
+{
+ if (!m_framesCollected)
+ collectTargetFrames();
+
+ bool didSerialization = false;
+ KURL mainURL = m_specifiedWebFrameImpl->frame()->document()->url();
+
+ for (unsigned i = 0; i < m_frames.size(); ++i) {
+ WebFrameImpl* webFrame = m_frames[i];
+ Document* document = webFrame->frame()->document();
+ const KURL& url = document->url();
+
+ if (!url.isValid() || !m_localLinks.contains(url.string()))
+ continue;
+
+ didSerialization = true;
+
+ String encoding = webFrame->frame()->loader()->writer()->encoding();
+ const TextEncoding& textEncoding = encoding.isEmpty() ? UTF8Encoding() : TextEncoding(encoding);
+ String directoryName = url == mainURL ? m_localDirectoryName : "";
+
+ SerializeDomParam param(url, textEncoding, document, directoryName);
+
+ Element* documentElement = document->documentElement();
+ if (documentElement)
+ buildContentForNode(documentElement, &param);
+
+ encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &param, ForceFlush);
+ }
+
+ ASSERT(m_dataBuffer.isEmpty());
+ m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSerializerClient::AllFramesAreFinished);
+ return didSerialization;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPageSerializerImpl.h b/Source/WebKit/chromium/src/WebPageSerializerImpl.h
new file mode 100644
index 0000000..5ee8805
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPageSerializerImpl.h
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPageSerializerImpl_h
+#define WebPageSerializerImpl_h
+
+#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+#include "WebEntities.h"
+#include "WebPageSerializer.h"
+#include "WebPageSerializerClient.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+namespace WebCore {
+class Document;
+class Element;
+class Node;
+class TextEncoding;
+}
+
+namespace WebKit {
+class WebFrameImpl;
+
+// Get html data by serializing all frames of current page with lists
+// which contain all resource links that have local copy.
+// contain all saved auxiliary files included all sub frames and resources.
+// This function will find out all frames and serialize them to HTML data.
+// We have a data buffer to temporary saving generated html data. We will
+// sequentially call WebViewDelegate::SendSerializedHtmlData once the data
+// buffer is full. See comments of WebViewDelegate::SendSerializedHtmlData
+// for getting more information.
+class WebPageSerializerImpl {
+public:
+ // Do serialization action. Return false means no available frame has been
+ // serialized, otherwise return true.
+ bool serialize();
+
+ // The parameter specifies which frame need to be serialized.
+ // The parameter recursive_serialization specifies whether we need to
+ // serialize all sub frames of the specified frame or not.
+ // The parameter delegate specifies the pointer of interface
+ // DomSerializerDelegate provide sink interface which can receive the
+ // individual chunks of data to be saved.
+ // The parameter links contain original URLs of all saved links.
+ // The parameter local_paths contain corresponding local file paths of all
+ // saved links, which matched with vector:links one by one.
+ // The parameter local_directory_name is relative path of directory which
+ // contain all saved auxiliary files included all sub frames and resources.
+ WebPageSerializerImpl(WebFrame* frame,
+ bool recursive,
+ WebPageSerializerClient* client,
+ const WebVector<WebURL>& links,
+ const WebVector<WebString>& localPaths,
+ const WebString& localDirectoryName);
+
+private:
+ // Specified frame which need to be serialized;
+ WebFrameImpl* m_specifiedWebFrameImpl;
+ // Pointer of WebPageSerializerClient
+ WebPageSerializerClient* m_client;
+ // This hash map is used to map resource URL of original link to its local
+ // file path.
+ typedef HashMap<WTF::String, WTF::String> LinkLocalPathMap;
+ // local_links_ include all pair of local resource path and corresponding
+ // original link.
+ LinkLocalPathMap m_localLinks;
+ // Data buffer for saving result of serialized DOM data.
+ StringBuilder m_dataBuffer;
+ // Passing true to recursive_serialization_ indicates we will serialize not
+ // only the specified frame but also all sub-frames in the specific frame.
+ // Otherwise we only serialize the specified frame excluded all sub-frames.
+ bool m_recursiveSerialization;
+ // Flag indicates whether we have collected all frames which need to be
+ // serialized or not;
+ bool m_framesCollected;
+ // Local directory name of all local resource files.
+ WTF::String m_localDirectoryName;
+ // Vector for saving all frames which need to be serialized.
+ Vector<WebFrameImpl*> m_frames;
+
+ // Web entities conversion maps.
+ WebEntities m_htmlEntities;
+ WebEntities m_xmlEntities;
+
+ struct SerializeDomParam {
+ const WebCore::KURL& url;
+ const WebCore::TextEncoding& textEncoding;
+ WebCore::Document* document;
+ const WTF::String& directoryName;
+ bool isHTMLDocument; // document.isHTMLDocument()
+ bool haveSeenDocType;
+ bool haveAddedCharsetDeclaration;
+ // This meta element need to be skipped when serializing DOM.
+ const WebCore::Element* skipMetaElement;
+ // Flag indicates we are in script or style tag.
+ bool isInScriptOrStyleTag;
+ bool haveAddedXMLProcessingDirective;
+ // Flag indicates whether we have added additional contents before end tag.
+ // This flag will be re-assigned in each call of function
+ // PostActionAfterSerializeOpenTag and it could be changed in function
+ // PreActionBeforeSerializeEndTag if the function adds new contents into
+ // serialization stream.
+ bool haveAddedContentsBeforeEnd;
+
+ SerializeDomParam(const WebCore::KURL&, const WebCore::TextEncoding&, WebCore::Document*, const WTF::String& directoryName);
+ };
+
+ // Collect all target frames which need to be serialized.
+ void collectTargetFrames();
+ // Before we begin serializing open tag of a element, we give the target
+ // element a chance to do some work prior to add some additional data.
+ WTF::String preActionBeforeSerializeOpenTag(const WebCore::Element* element,
+ SerializeDomParam* param,
+ bool* needSkip);
+ // After we finish serializing open tag of a element, we give the target
+ // element a chance to do some post work to add some additional data.
+ WTF::String postActionAfterSerializeOpenTag(const WebCore::Element* element,
+ SerializeDomParam* param);
+ // Before we begin serializing end tag of a element, we give the target
+ // element a chance to do some work prior to add some additional data.
+ WTF::String preActionBeforeSerializeEndTag(const WebCore::Element* element,
+ SerializeDomParam* param,
+ bool* needSkip);
+ // After we finish serializing end tag of a element, we give the target
+ // element a chance to do some post work to add some additional data.
+ WTF::String postActionAfterSerializeEndTag(const WebCore::Element* element,
+ SerializeDomParam* param);
+ // Save generated html content to data buffer.
+ void saveHTMLContentToBuffer(const WTF::String& content,
+ SerializeDomParam* param);
+
+ enum FlushOption {
+ ForceFlush,
+ DoNotForceFlush,
+ };
+
+ // Flushes the content buffer by encoding and sending the content to the
+ // WebPageSerializerClient. Content is not flushed if the buffer is not full
+ // unless force is 1.
+ void encodeAndFlushBuffer(WebPageSerializerClient::PageSerializationStatus status,
+ SerializeDomParam* param,
+ FlushOption);
+ // Serialize open tag of an specified element.
+ void openTagToString(const WebCore::Element* element,
+ SerializeDomParam* param);
+ // Serialize end tag of an specified element.
+ void endTagToString(const WebCore::Element* element,
+ SerializeDomParam* param);
+ // Build content for a specified node
+ void buildContentForNode(const WebCore::Node* node,
+ SerializeDomParam* param);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebPasswordFormData.cpp b/Source/WebKit/chromium/src/WebPasswordFormData.cpp
new file mode 100644
index 0000000..eb230d5
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPasswordFormData.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPasswordFormData.h"
+
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "KURL.h"
+
+#include "DOMUtilitiesPrivate.h"
+#include "WebPasswordFormUtils.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+namespace {
+
+// Helper to determine which password is the main one, and which is
+// an old password (e.g on a "make new password" form), if any.
+bool locateSpecificPasswords(PasswordFormFields* fields,
+ HTMLInputElement** password,
+ HTMLInputElement** oldPassword)
+{
+ ASSERT(fields);
+ ASSERT(password);
+ ASSERT(oldPassword);
+ switch (fields->passwords.size()) {
+ case 1:
+ // Single password, easy.
+ *password = fields->passwords[0];
+ break;
+ case 2:
+ if (fields->passwords[0]->value() == fields->passwords[1]->value())
+ // Treat two identical passwords as a single password.
+ *password = fields->passwords[0];
+ else {
+ // Assume first is old password, second is new (no choice but to guess).
+ *oldPassword = fields->passwords[0];
+ *password = fields->passwords[1];
+ }
+ break;
+ case 3:
+ if (fields->passwords[0]->value() == fields->passwords[1]->value()
+ && fields->passwords[0]->value() == fields->passwords[2]->value()) {
+ // All three passwords the same? Just treat as one and hope.
+ *password = fields->passwords[0];
+ } else if (fields->passwords[0]->value() == fields->passwords[1]->value()) {
+ // Two the same and one different -> old password is duplicated one.
+ *oldPassword = fields->passwords[0];
+ *password = fields->passwords[2];
+ } else if (fields->passwords[1]->value() == fields->passwords[2]->value()) {
+ *oldPassword = fields->passwords[0];
+ *password = fields->passwords[1];
+ } else {
+ // Three different passwords, or first and last match with middle
+ // different. No idea which is which, so no luck.
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+// Helped method to clear url of unneeded parts.
+KURL stripURL(const KURL& url)
+{
+ KURL strippedURL = url;
+ strippedURL.setUser(String());
+ strippedURL.setPass(String());
+ strippedURL.setQuery(String());
+ strippedURL.setFragmentIdentifier(String());
+ return strippedURL;
+}
+
+// Helper to gather up the final form data and create a PasswordForm.
+void assemblePasswordFormResult(const KURL& fullOrigin,
+ const KURL& fullAction,
+ HTMLFormControlElement* submit,
+ HTMLInputElement* userName,
+ HTMLInputElement* oldPassword,
+ HTMLInputElement* password,
+ WebPasswordFormData* result)
+{
+ // We want to keep the path but strip any authentication data, as well as
+ // query and ref portions of URL, for the form action and form origin.
+ result->action = stripURL(fullAction);
+ result->origin = stripURL(fullOrigin);
+
+ // Naming is confusing here because we have both the HTML form origin URL
+ // the page where the form was seen), and the "origin" components of the url
+ // (scheme, host, and port).
+ KURL signonRealmURL = stripURL(fullOrigin);
+ signonRealmURL.setPath("");
+ result->signonRealm = signonRealmURL;
+
+ if (submit)
+ result->submitElement = submit->name();
+ if (userName) {
+ result->userNameElement = userName->name();
+ result->userNameValue = userName->value();
+ }
+ if (password) {
+ result->passwordElement = password->name();
+ result->passwordValue = password->value();
+ }
+ if (oldPassword) {
+ result->oldPasswordElement = oldPassword->name();
+ result->oldPasswordValue = oldPassword->value();
+ }
+}
+
+} // namespace
+
+WebPasswordFormData::WebPasswordFormData(const WebFormElement& webForm)
+{
+ RefPtr<HTMLFormElement> form = webForm.operator PassRefPtr<HTMLFormElement>();
+
+ Frame* frame = form->document()->frame();
+ if (!frame)
+ return;
+
+ PasswordFormFields fields;
+ findPasswordFormFields(form.get(), &fields);
+
+ // Get the document URL
+ KURL fullOrigin(ParsedURLString, form->document()->documentURI());
+
+ // Calculate the canonical action URL
+ String action = form->action();
+ if (action.isNull())
+ action = ""; // missing 'action' attribute implies current URL
+ KURL fullAction = frame->loader()->completeURL(action);
+ if (!fullAction.isValid())
+ return;
+
+ // Determine the types of the password fields
+ HTMLInputElement* password = 0;
+ HTMLInputElement* oldPassword = 0;
+ if (!locateSpecificPasswords(&fields, &password, &oldPassword))
+ return;
+
+ assemblePasswordFormResult(fullOrigin, fullAction,
+ fields.submit, fields.userName,
+ oldPassword, password, this);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPasswordFormUtils.cpp b/Source/WebKit/chromium/src/WebPasswordFormUtils.cpp
new file mode 100644
index 0000000..5f8a1ec
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPasswordFormUtils.cpp
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is Mozilla Password Manager.
+*
+* The Initial Developer of the Original Code is
+* Brian Ryner.
+* Portions created by the Initial Developer are Copyright (C) 2003
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Brian Ryner <bryner@brianryner.com>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+// Helper to WebPasswordFormData to do the locating of username/password
+// fields.
+// This method based on Firefox2 code in
+// toolkit/components/passwordmgr/base/nsPasswordManager.cpp
+
+#include "config.h"
+#include "WebPasswordFormUtils.h"
+
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "KURL.h"
+
+#include "DOMUtilitiesPrivate.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Maximum number of password fields we will observe before throwing our
+// hands in the air and giving up with a given form.
+static const size_t maxPasswords = 3;
+
+void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields)
+{
+ ASSERT(form);
+ ASSERT(fields);
+
+ int firstPasswordIndex = 0;
+ // First, find the password fields and activated submit button
+ const Vector<FormAssociatedElement*>& formElements = form->associatedElements();
+ for (size_t i = 0; i < formElements.size(); i++) {
+ if (!formElements[i]->isFormControlElement())
+ continue;
+ HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(formElements[i]);
+ if (formElement->isActivatedSubmit())
+ fields->submit = formElement;
+
+ if (!formElement->hasLocalName(HTMLNames::inputTag))
+ continue;
+
+ HTMLInputElement* inputElement = toHTMLInputElement(formElement);
+ if (!inputElement->isEnabledFormControl())
+ continue;
+
+ if ((fields->passwords.size() < maxPasswords)
+ && inputElement->isPasswordField()
+ && inputElement->autoComplete()) {
+ if (fields->passwords.isEmpty())
+ firstPasswordIndex = i;
+ fields->passwords.append(inputElement);
+ }
+ }
+
+ if (!fields->passwords.isEmpty()) {
+ // Then, search backwards for the username field
+ for (int i = firstPasswordIndex - 1; i >= 0; i--) {
+ if (!formElements[i]->isFormControlElement())
+ continue;
+ HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(formElements[i]);
+ if (!formElement->hasLocalName(HTMLNames::inputTag))
+ continue;
+
+ HTMLInputElement* inputElement = toHTMLInputElement(formElement);
+ if (!inputElement->isEnabledFormControl())
+ continue;
+
+ // Various input types such as text, url, email can be a username field.
+ if ((inputElement->isTextField() && !inputElement->isPasswordField())
+ && (inputElement->autoComplete())) {
+ fields->userName = inputElement;
+ break;
+ }
+ }
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPasswordFormUtils.h b/Source/WebKit/chromium/src/WebPasswordFormUtils.h
new file mode 100644
index 0000000..fd503b4
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPasswordFormUtils.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPasswordFormUtils_h
+#define WebPasswordFormUtils_h
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class HTMLInputElement;
+class HTMLFormControlElement;
+class HTMLFormElement;
+}
+
+namespace WebKit {
+
+// Helper structure to locate username, passwords and submit fields.
+struct PasswordFormFields {
+ WebCore::HTMLInputElement* userName;
+ Vector<WebCore::HTMLInputElement*> passwords;
+ WebCore::HTMLFormControlElement* submit;
+ PasswordFormFields() : userName(0), submit(0) { }
+};
+
+void findPasswordFormFields(WebCore::HTMLFormElement* form,
+ PasswordFormFields* fields);
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebPerformance.cpp b/Source/WebKit/chromium/src/WebPerformance.cpp
new file mode 100644
index 0000000..8c377db
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPerformance.cpp
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPerformance.h"
+
+#include "Performance.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static double millisecondsToSeconds(unsigned long long milliseconds)
+{
+ return static_cast<double>(milliseconds / 1000.0);
+}
+
+void WebPerformance::reset()
+{
+ m_private.reset();
+}
+
+void WebPerformance::assign(const WebPerformance& other)
+{
+ m_private = other.m_private;
+}
+
+WebNavigationType WebPerformance::navigationType() const
+{
+ switch (m_private->navigation()->type()) {
+ case PerformanceNavigation::TYPE_NAVIGATE:
+ return WebNavigationTypeOther;
+ case PerformanceNavigation::TYPE_RELOAD:
+ return WebNavigationTypeReload;
+ case PerformanceNavigation::TYPE_BACK_FORWARD:
+ return WebNavigationTypeBackForward;
+ case PerformanceNavigation::TYPE_RESERVED:
+ return WebNavigationTypeOther;
+ }
+ ASSERT_NOT_REACHED();
+ return WebNavigationTypeOther;
+}
+
+double WebPerformance::navigationStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->navigationStart());
+}
+
+double WebPerformance::unloadEventEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->unloadEventEnd());
+}
+
+double WebPerformance::redirectStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->redirectStart());
+}
+
+double WebPerformance::redirectEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->redirectEnd());
+}
+
+unsigned short WebPerformance::redirectCount() const
+{
+ return m_private->navigation()->redirectCount();
+}
+
+double WebPerformance::fetchStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->fetchStart());
+}
+
+double WebPerformance::domainLookupStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->domainLookupStart());
+}
+
+double WebPerformance::domainLookupEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->domainLookupEnd());
+}
+
+double WebPerformance::connectStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->connectStart());
+}
+
+double WebPerformance::connectEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->connectEnd());
+}
+
+double WebPerformance::requestStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->requestStart());
+}
+
+double WebPerformance::responseStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->responseStart());
+}
+
+double WebPerformance::responseEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->responseEnd());
+}
+
+double WebPerformance::domLoading() const
+{
+ return millisecondsToSeconds(m_private->timing()->domLoading());
+}
+
+double WebPerformance::domInteractive() const
+{
+ return millisecondsToSeconds(m_private->timing()->domInteractive());
+}
+
+double WebPerformance::domContentLoadedEventStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->domContentLoadedEventStart());
+}
+
+double WebPerformance::domContentLoadedEventEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->domContentLoadedEventEnd());
+}
+
+double WebPerformance::domComplete() const
+{
+ return millisecondsToSeconds(m_private->timing()->domComplete());
+}
+
+double WebPerformance::loadEventStart() const
+{
+ return millisecondsToSeconds(m_private->timing()->loadEventStart());
+}
+
+double WebPerformance::loadEventEnd() const
+{
+ return millisecondsToSeconds(m_private->timing()->loadEventEnd());
+}
+
+WebPerformance::WebPerformance(const PassRefPtr<Performance>& performance)
+ : m_private(performance)
+{
+}
+
+WebPerformance& WebPerformance::operator=(const PassRefPtr<Performance>& performance)
+{
+ m_private = performance;
+ return *this;
+}
+
+WebPerformance::operator PassRefPtr<Performance>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp
new file mode 100644
index 0000000..5f62077
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp
@@ -0,0 +1,708 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPluginContainerImpl.h"
+
+#include "Chrome.h"
+#include "ChromeClientImpl.h"
+#include "PluginLayerChromium.h"
+#include "WebClipboard.h"
+#include "WebCursorInfo.h"
+#include "WebDataSourceImpl.h"
+#include "WebElement.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebPlugin.h"
+#include "WebRect.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLError.h"
+#include "WebURLRequest.h"
+#include "WebVector.h"
+#include "WebViewImpl.h"
+#include "WrappedResourceResponse.h"
+
+#include "EventNames.h"
+#include "FocusController.h"
+#include "FormState.h"
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "HostWindow.h"
+#include "HTMLFormElement.h"
+#include "HTMLNames.h"
+#include "HTMLPlugInElement.h"
+#include "KeyboardCodes.h"
+#include "KeyboardEvent.h"
+#include "MouseEvent.h"
+#include "Page.h"
+#include "RenderBox.h"
+#include "ScrollView.h"
+#include "WheelEvent.h"
+
+#if WEBKIT_USING_SKIA
+#include "PlatformContextSkia.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Public methods --------------------------------------------------------------
+
+void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect)
+{
+ Widget::setFrameRect(frameRect);
+ reportGeometry();
+}
+
+void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRect)
+{
+ if (gc->paintingDisabled())
+ return;
+
+ if (!parent())
+ return;
+
+ // Don't paint anything if the plugin doesn't intersect the damage rect.
+ if (!frameRect().intersects(damageRect))
+ return;
+
+ gc->save();
+
+ ASSERT(parent()->isFrameView());
+ ScrollView* view = parent();
+
+ // The plugin is positioned in window coordinates, so it needs to be painted
+ // in window coordinates.
+ IntPoint origin = view->windowToContents(IntPoint(0, 0));
+ gc->translate(static_cast<float>(origin.x()), static_cast<float>(origin.y()));
+
+#if WEBKIT_USING_SKIA
+ WebCanvas* canvas = gc->platformContext()->canvas();
+#elif WEBKIT_USING_CG
+ WebCanvas* canvas = gc->platformContext();
+#endif
+
+ IntRect windowRect =
+ IntRect(view->contentsToWindow(damageRect.location()), damageRect.size());
+ m_webPlugin->paint(canvas, windowRect);
+
+ gc->restore();
+}
+
+void WebPluginContainerImpl::invalidateRect(const IntRect& rect)
+{
+ if (!parent())
+ return;
+
+ IntRect damageRect = convertToContainingWindow(rect);
+
+ // Get our clip rect and intersect with it to ensure we don't invalidate
+ // too much.
+ IntRect clipRect = parent()->windowClipRect();
+ damageRect.intersect(clipRect);
+
+ parent()->hostWindow()->invalidateContentsAndWindow(damageRect, false /*immediate*/);
+}
+
+void WebPluginContainerImpl::setFocus(bool focused)
+{
+ Widget::setFocus(focused);
+ m_webPlugin->updateFocus(focused);
+}
+
+void WebPluginContainerImpl::show()
+{
+ setSelfVisible(true);
+ m_webPlugin->updateVisibility(true);
+
+ Widget::show();
+}
+
+void WebPluginContainerImpl::hide()
+{
+ setSelfVisible(false);
+ m_webPlugin->updateVisibility(false);
+
+ Widget::hide();
+}
+
+void WebPluginContainerImpl::handleEvent(Event* event)
+{
+ if (!m_webPlugin->acceptsInputEvents())
+ return;
+
+ // The events we pass are defined at:
+ // http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/structures5.html#1000000
+ // Don't take the documentation as truth, however. There are many cases
+ // where mozilla behaves differently than the spec.
+ if (event->isMouseEvent())
+ handleMouseEvent(static_cast<MouseEvent*>(event));
+ else if (event->isWheelEvent())
+ handleWheelEvent(static_cast<WheelEvent*>(event));
+ else if (event->isKeyboardEvent())
+ handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
+
+ // FIXME: it would be cleaner if Widget::handleEvent returned true/false and
+ // HTMLPluginElement called setDefaultHandled or defaultEventHandler.
+ if (!event->defaultHandled())
+ m_element->Node::defaultEventHandler(event);
+}
+
+void WebPluginContainerImpl::frameRectsChanged()
+{
+ Widget::frameRectsChanged();
+ reportGeometry();
+}
+
+void WebPluginContainerImpl::widgetPositionsUpdated()
+{
+ Widget::widgetPositionsUpdated();
+ reportGeometry();
+}
+
+void WebPluginContainerImpl::setParentVisible(bool parentVisible)
+{
+ // We override this function to make sure that geometry updates are sent
+ // over to the plugin. For e.g. when a plugin is instantiated it does not
+ // have a valid parent. As a result the first geometry update from webkit
+ // is ignored. This function is called when the plugin eventually gets a
+ // parent.
+
+ if (isParentVisible() == parentVisible)
+ return; // No change.
+
+ Widget::setParentVisible(parentVisible);
+ if (!isSelfVisible())
+ return; // This widget has explicitely been marked as not visible.
+
+ m_webPlugin->updateVisibility(isVisible());
+}
+
+void WebPluginContainerImpl::setParent(ScrollView* view)
+{
+ // We override this function so that if the plugin is windowed, we can call
+ // NPP_SetWindow at the first possible moment. This ensures that
+ // NPP_SetWindow is called before the manual load data is sent to a plugin.
+ // If this order is reversed, Flash won't load videos.
+
+ Widget::setParent(view);
+ if (view)
+ reportGeometry();
+}
+
+bool WebPluginContainerImpl::supportsPaginatedPrint() const
+{
+ return m_webPlugin->supportsPaginatedPrint();
+}
+
+int WebPluginContainerImpl::printBegin(const IntRect& printableArea,
+ int printerDPI) const
+{
+ return m_webPlugin->printBegin(printableArea, printerDPI);
+}
+
+bool WebPluginContainerImpl::printPage(int pageNumber,
+ WebCore::GraphicsContext* gc)
+{
+ gc->save();
+#if WEBKIT_USING_SKIA
+ WebCanvas* canvas = gc->platformContext()->canvas();
+#elif WEBKIT_USING_CG
+ WebCanvas* canvas = gc->platformContext();
+#endif
+ bool ret = m_webPlugin->printPage(pageNumber, canvas);
+ gc->restore();
+ return ret;
+}
+
+void WebPluginContainerImpl::printEnd()
+{
+ return m_webPlugin->printEnd();
+}
+
+void WebPluginContainerImpl::copy()
+{
+ if (!m_webPlugin->hasSelection())
+ return;
+
+ webKitClient()->clipboard()->writeHTML(m_webPlugin->selectionAsMarkup(), WebURL(), m_webPlugin->selectionAsText(), false);
+}
+
+WebElement WebPluginContainerImpl::element()
+{
+ return WebElement(m_element);
+}
+
+void WebPluginContainerImpl::invalidate()
+{
+ Widget::invalidate();
+}
+
+void WebPluginContainerImpl::invalidateRect(const WebRect& rect)
+{
+ invalidateRect(static_cast<IntRect>(rect));
+}
+
+void WebPluginContainerImpl::scrollRect(int dx, int dy, const WebRect& rect)
+{
+ Widget* parentWidget = parent();
+ if (parentWidget->isFrameView()) {
+ FrameView* parentFrameView = static_cast<FrameView*>(parentWidget);
+ if (!parentFrameView->isOverlapped()) {
+ IntRect damageRect = convertToContainingWindow(static_cast<IntRect>(rect));
+ IntSize scrollDelta(dx, dy);
+ // scroll() only uses the second rectangle, clipRect, and ignores the first
+ // rectangle.
+ parent()->hostWindow()->scroll(scrollDelta, damageRect, damageRect);
+ return;
+ }
+ }
+
+ // Use slow scrolling instead.
+ invalidateRect(rect);
+}
+
+void WebPluginContainerImpl::reportGeometry()
+{
+ if (!parent())
+ return;
+
+ IntRect windowRect, clipRect;
+ Vector<IntRect> cutOutRects;
+ calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects);
+
+ m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible());
+}
+
+void WebPluginContainerImpl::commitBackingTexture()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ if (platformLayer())
+ platformLayer()->setNeedsDisplay();
+#endif
+}
+
+void WebPluginContainerImpl::clearScriptObjects()
+{
+ Frame* frame = m_element->document()->frame();
+ if (!frame)
+ return;
+ frame->script()->cleanupScriptObjectsForPlugin(this);
+}
+
+NPObject* WebPluginContainerImpl::scriptableObjectForElement()
+{
+ return m_element->getNPObject();
+}
+
+WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed)
+{
+ Frame* frame = m_element->document()->frame();
+ if (!frame)
+ return WebString();
+
+ const KURL& kurl = url;
+ ASSERT(kurl.protocolIs("javascript"));
+
+ String script = decodeURLEscapeSequences(
+ kurl.string().substring(strlen("javascript:")));
+
+ ScriptValue result = frame->script()->executeScript(script, popupsAllowed);
+
+ // Failure is reported as a null string.
+ String resultStr;
+ result.getString(resultStr);
+ return resultStr;
+}
+
+void WebPluginContainerImpl::loadFrameRequest(
+ const WebURLRequest& request, const WebString& target, bool notifyNeeded, void* notifyData)
+{
+ Frame* frame = m_element->document()->frame();
+ if (!frame)
+ return; // FIXME: send a notification in this case?
+
+ if (notifyNeeded) {
+ // FIXME: This is a bit of hack to allow us to observe completion of
+ // our frame request. It would be better to evolve FrameLoader to
+ // support a completion callback instead.
+ WebPluginLoadObserver* observer =
+ new WebPluginLoadObserver(this, request.url(), notifyData);
+ m_pluginLoadObservers.append(observer);
+ WebDataSourceImpl::setNextPluginLoadObserver(observer);
+ }
+
+ FrameLoadRequest frameRequest(frame->document()->securityOrigin(),
+ request.toResourceRequest(), target);
+
+ frame->loader()->loadFrameRequest(
+ frameRequest,
+ false, // lock history
+ false, // lock back forward list
+ 0, // event
+ 0, // form state
+ SendReferrer);
+}
+
+void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel)
+{
+ WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page());
+ view->fullFramePluginZoomLevelChanged(zoomLevel);
+}
+
+void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response)
+{
+ // Make sure that the plugin receives window geometry before data, or else
+ // plugins misbehave.
+ frameRectsChanged();
+
+ WrappedResourceResponse urlResponse(response);
+ m_webPlugin->didReceiveResponse(urlResponse);
+}
+
+void WebPluginContainerImpl::didReceiveData(const char *data, int dataLength)
+{
+ m_webPlugin->didReceiveData(data, dataLength);
+}
+
+void WebPluginContainerImpl::didFinishLoading()
+{
+ m_webPlugin->didFinishLoading();
+}
+
+void WebPluginContainerImpl::didFailLoading(const ResourceError& error)
+{
+ m_webPlugin->didFailLoading(error);
+}
+
+NPObject* WebPluginContainerImpl::scriptableObject()
+{
+ return m_webPlugin->scriptableObject();
+}
+
+void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver* observer)
+{
+ size_t pos = m_pluginLoadObservers.find(observer);
+ if (pos == notFound)
+ return;
+ m_pluginLoadObservers.remove(pos);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+WebCore::LayerChromium* WebPluginContainerImpl::platformLayer() const
+{
+ // FIXME: In the event of a context lost, the texture needs to be recreated on the compositor's
+ // context and rebound to the platform layer here.
+ unsigned backingTextureId = m_webPlugin->getBackingTextureId();
+ if (!backingTextureId)
+ return 0;
+
+ m_platformLayer->setTextureId(backingTextureId);
+
+ return m_platformLayer.get();
+}
+#endif
+
+// Private methods -------------------------------------------------------------
+
+WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
+ : WebCore::PluginViewBase(0)
+ , m_element(element)
+ , m_webPlugin(webPlugin)
+#if USE(ACCELERATED_COMPOSITING)
+ , m_platformLayer(PluginLayerChromium::create(0))
+#endif
+{
+}
+
+WebPluginContainerImpl::~WebPluginContainerImpl()
+{
+ for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
+ m_pluginLoadObservers[i]->clearPluginContainer();
+ m_webPlugin->destroy();
+}
+
+void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
+{
+ ASSERT(parent()->isFrameView());
+
+ // We cache the parent FrameView here as the plugin widget could be deleted
+ // in the call to HandleEvent. See http://b/issue?id=1362948
+ FrameView* parentView = static_cast<FrameView*>(parent());
+
+ WebMouseEventBuilder webEvent(this, *event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+
+ if (event->type() == eventNames().mousedownEvent) {
+ // Ensure that the frame containing the plugin has focus.
+ Frame* containingFrame = parentView->frame();
+ if (Page* currentPage = containingFrame->page())
+ currentPage->focusController()->setFocusedFrame(containingFrame);
+ // Give focus to our containing HTMLPluginElement.
+ containingFrame->document()->setFocusedNode(m_element);
+ }
+
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ event->setDefaultHandled();
+
+ // A windowless plugin can change the cursor in response to a mouse move
+ // event. We need to reflect the changed cursor in the frame view as the
+ // mouse is moved in the boundaries of the windowless plugin.
+ Page* page = parentView->frame()->page();
+ if (!page)
+ return;
+ ChromeClientImpl* chromeClient =
+ static_cast<ChromeClientImpl*>(page->chrome()->client());
+ chromeClient->setCursorForPlugin(cursorInfo);
+}
+
+void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event)
+{
+ WebMouseWheelEventBuilder webEvent(this, *event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ event->setDefaultHandled();
+}
+
+void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event)
+{
+ WebKeyboardEventBuilder webEvent(*event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+
+ if (webEvent.type == WebInputEvent::KeyDown) {
+#if defined(OS_MACOSX)
+ if (webEvent.modifiers == WebInputEvent::MetaKey
+#else
+ if (webEvent.modifiers == WebInputEvent::ControlKey
+#endif
+ && webEvent.windowsKeyCode == VKEY_C
+ // Only copy if there's a selection, so that we only ever do this
+ // for Pepper plugins that support copying. Windowless NPAPI
+ // plugins will get the event as before.
+ && m_webPlugin->hasSelection()) {
+ copy();
+ event->setDefaultHandled();
+ return;
+ }
+ }
+
+ const WebInputEvent* currentInputEvent = WebViewImpl::currentInputEvent();
+
+ // Copy stashed info over, and only copy here in order not to interfere
+ // the ctrl-c logic above.
+ if (currentInputEvent
+ && WebInputEvent::isKeyboardEventType(currentInputEvent->type)) {
+ webEvent.modifiers |= currentInputEvent->modifiers &
+ (WebInputEvent::CapsLockOn | WebInputEvent::NumLockOn);
+ }
+
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ event->setDefaultHandled();
+}
+
+void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect,
+ IntRect& windowRect,
+ IntRect& clipRect,
+ Vector<IntRect>& cutOutRects)
+{
+ windowRect = IntRect(
+ parent()->contentsToWindow(frameRect.location()), frameRect.size());
+
+ // Calculate a clip-rect so that we don't overlap the scrollbars, etc.
+ clipRect = windowClipRect();
+ clipRect.move(-windowRect.x(), -windowRect.y());
+
+ windowCutOutRects(frameRect, cutOutRects);
+ // Convert to the plugin position.
+ for (size_t i = 0; i < cutOutRects.size(); i++)
+ cutOutRects[i].move(-frameRect.x(), -frameRect.y());
+}
+
+WebCore::IntRect WebPluginContainerImpl::windowClipRect() const
+{
+ // Start by clipping to our bounds.
+ IntRect clipRect =
+ convertToContainingWindow(IntRect(0, 0, width(), height()));
+
+ // document()->renderer() can be 0 when we receive messages from the
+ // plugins while we are destroying a frame.
+ if (m_element->renderer()->document()->renderer()) {
+ // Take our element and get the clip rect from the enclosing layer and
+ // frame view.
+ RenderLayer* layer = m_element->renderer()->enclosingLayer();
+ clipRect.intersect(
+ m_element->document()->view()->windowClipRectForLayer(layer, true));
+ }
+
+ return clipRect;
+}
+
+static void getObjectStack(const RenderObject* ro,
+ Vector<const RenderObject*>* roStack)
+{
+ roStack->clear();
+ while (ro) {
+ roStack->append(ro);
+ ro = ro->parent();
+ }
+}
+
+// Returns true if stack1 is at or above stack2
+static bool checkStackOnTop(
+ const Vector<const RenderObject*>& iframeZstack,
+ const Vector<const RenderObject*>& pluginZstack)
+{
+ for (size_t i1 = 0, i2 = 0;
+ i1 < iframeZstack.size() && i2 < pluginZstack.size();
+ i1++, i2++) {
+ // The root is at the end of these stacks. We want to iterate
+ // root-downwards so we index backwards from the end.
+ const RenderObject* ro1 = iframeZstack[iframeZstack.size() - 1 - i1];
+ const RenderObject* ro2 = pluginZstack[pluginZstack.size() - 1 - i2];
+
+ if (ro1 != ro2) {
+ // When we find nodes in the stack that are not the same, then
+ // we've found the nodes just below the lowest comment ancestor.
+ // Determine which should be on top.
+
+ // See if z-index determines an order.
+ if (ro1->style() && ro2->style()) {
+ int z1 = ro1->style()->zIndex();
+ int z2 = ro2->style()->zIndex();
+ if (z1 > z2)
+ return true;
+ if (z1 < z2)
+ return false;
+ }
+
+ // If the plugin does not have an explicit z-index it stacks behind the iframe.
+ // This is for maintaining compatibility with IE.
+ if (ro2->style()->position() == StaticPosition) {
+ // The 0'th elements of these RenderObject arrays represent the plugin node and
+ // the iframe.
+ const RenderObject* pluginRenderObject = pluginZstack[0];
+ const RenderObject* iframeRenderObject = iframeZstack[0];
+
+ if (pluginRenderObject->style() && iframeRenderObject->style()) {
+ if (pluginRenderObject->style()->zIndex() > iframeRenderObject->style()->zIndex())
+ return false;
+ }
+ return true;
+ }
+
+ // Inspect the document order. Later order means higher
+ // stacking.
+ const RenderObject* parent = ro1->parent();
+ if (!parent)
+ return false;
+ ASSERT(parent == ro2->parent());
+
+ for (const RenderObject* ro = parent->firstChild(); ro; ro = ro->nextSibling()) {
+ if (ro == ro1)
+ return false;
+ if (ro == ro2)
+ return true;
+ }
+ ASSERT(false); // We should have seen ro1 and ro2 by now.
+ return false;
+ }
+ }
+ return true;
+}
+
+// Return a set of rectangles that should not be overdrawn by the
+// plugin ("cutouts"). This helps implement the "iframe shim"
+// technique of overlaying a windowed plugin with content from the
+// page. In a nutshell, iframe elements should occlude plugins when
+// they occur higher in the stacking order.
+void WebPluginContainerImpl::windowCutOutRects(const IntRect& frameRect,
+ Vector<IntRect>& cutOutRects)
+{
+ RenderObject* pluginNode = m_element->renderer();
+ ASSERT(pluginNode);
+ if (!pluginNode->style())
+ return;
+ Vector<const RenderObject*> pluginZstack;
+ Vector<const RenderObject*> iframeZstack;
+ getObjectStack(pluginNode, &pluginZstack);
+
+ // Get the parent widget
+ Widget* parentWidget = this->parent();
+ if (!parentWidget->isFrameView())
+ return;
+
+ FrameView* parentFrameView = static_cast<FrameView*>(parentWidget);
+
+ const HashSet<RefPtr<Widget> >* children = parentFrameView->children();
+ for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != children->end(); ++it) {
+ // We only care about FrameView's because iframes show up as FrameViews.
+ if (!(*it)->isFrameView())
+ continue;
+
+ const FrameView* frameView =
+ static_cast<const FrameView*>((*it).get());
+ // Check to make sure we can get both the element and the RenderObject
+ // for this FrameView, if we can't just move on to the next object.
+ if (!frameView->frame() || !frameView->frame()->ownerElement()
+ || !frameView->frame()->ownerElement()->renderer())
+ continue;
+
+ HTMLElement* element = frameView->frame()->ownerElement();
+ RenderObject* iframeRenderer = element->renderer();
+
+ if (element->hasTagName(HTMLNames::iframeTag)
+ && iframeRenderer->absoluteBoundingBoxRect().intersects(frameRect)
+ && (!iframeRenderer->style() || iframeRenderer->style()->visibility() == VISIBLE)) {
+ getObjectStack(iframeRenderer, &iframeZstack);
+ if (checkStackOnTop(iframeZstack, pluginZstack)) {
+ IntPoint point =
+ roundedIntPoint(iframeRenderer->localToAbsolute());
+ RenderBox* rbox = toRenderBox(iframeRenderer);
+ IntSize size(rbox->width(), rbox->height());
+ cutOutRects.append(IntRect(point, size));
+ }
+ }
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.h b/Source/WebKit/chromium/src/WebPluginContainerImpl.h
new file mode 100644
index 0000000..ebe6983
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPluginContainerImpl_h
+#define WebPluginContainerImpl_h
+
+#include "PluginViewBase.h"
+#include "WebPluginContainer.h"
+#include "Widget.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
+
+struct NPObject;
+
+namespace WebCore {
+class HTMLPlugInElement;
+class IntRect;
+class KeyboardEvent;
+class LayerChromium;
+class MouseEvent;
+class PluginLayerChromium;
+class ResourceError;
+class ResourceResponse;
+class WheelEvent;
+}
+
+namespace WebKit {
+
+class WebPlugin;
+class WebPluginLoadObserver;
+
+class WebPluginContainerImpl : public WebCore::PluginViewBase, public WebPluginContainer {
+public:
+ static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
+ {
+ return adoptRef(new WebPluginContainerImpl(element, webPlugin));
+ }
+
+ // Widget methods
+ virtual void setFrameRect(const WebCore::IntRect&);
+ virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
+ virtual void invalidateRect(const WebCore::IntRect&);
+ virtual void setFocus(bool);
+ virtual void show();
+ virtual void hide();
+ virtual void handleEvent(WebCore::Event*);
+ virtual void frameRectsChanged();
+ virtual void setParentVisible(bool);
+ virtual void setParent(WebCore::ScrollView*);
+ virtual void widgetPositionsUpdated();
+ virtual bool isPluginContainer() const { return true; }
+
+ // WebPluginContainer methods
+ virtual WebElement element();
+ virtual void invalidate();
+ virtual void invalidateRect(const WebRect&);
+ virtual void scrollRect(int dx, int dy, const WebRect&);
+ virtual void reportGeometry();
+ virtual void commitBackingTexture();
+ virtual void clearScriptObjects();
+ virtual NPObject* scriptableObjectForElement();
+ virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
+ virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
+ virtual void zoomLevelChanged(double zoomLevel);
+
+ // This cannot be null.
+ WebPlugin* plugin() { return m_webPlugin; }
+ void setPlugin(WebPlugin* plugin) { m_webPlugin = plugin; }
+
+ // Printing interface. The plugin can support custom printing
+ // (which means it controls the layout, number of pages etc).
+ // Whether the plugin supports its own paginated print. The other print
+ // interface methods are called only if this method returns true.
+ bool supportsPaginatedPrint() const;
+ // Sets up printing at the given print rect and printer DPI. printableArea
+ // is in points (a point is 1/72 of an inch).Returns the number of pages to
+ // be printed at these settings.
+ int printBegin(const WebCore::IntRect& printableArea, int printerDPI) const;
+ // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
+ bool printPage(int pageNumber, WebCore::GraphicsContext* gc);
+ // Ends the print operation.
+ void printEnd();
+
+ // Copy the selected text.
+ void copy();
+
+ // Resource load events for the plugin's source data:
+ void didReceiveResponse(const WebCore::ResourceResponse&);
+ void didReceiveData(const char *data, int dataLength);
+ void didFinishLoading();
+ void didFailLoading(const WebCore::ResourceError&);
+
+ NPObject* scriptableObject();
+
+ void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual WebCore::LayerChromium* platformLayer() const;
+#endif
+
+private:
+ WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
+ ~WebPluginContainerImpl();
+
+ void handleMouseEvent(WebCore::MouseEvent*);
+ void handleWheelEvent(WebCore::WheelEvent*);
+ void handleKeyboardEvent(WebCore::KeyboardEvent*);
+
+ void calculateGeometry(const WebCore::IntRect& frameRect,
+ WebCore::IntRect& windowRect,
+ WebCore::IntRect& clipRect,
+ Vector<WebCore::IntRect>& cutOutRects);
+ WebCore::IntRect windowClipRect() const;
+ void windowCutOutRects(const WebCore::IntRect& frameRect,
+ Vector<WebCore::IntRect>& cutOutRects);
+
+ WebCore::HTMLPlugInElement* m_element;
+ WebPlugin* m_webPlugin;
+ Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
+
+#if USE(ACCELERATED_COMPOSITING)
+ RefPtr<WebCore::PluginLayerChromium> m_platformLayer;
+#endif
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebPluginDocument.cpp b/Source/WebKit/chromium/src/WebPluginDocument.cpp
new file mode 100644
index 0000000..8f794ad
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginDocument.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPluginDocument.h"
+
+#include "Document.h"
+#include "PluginDocument.h"
+
+#include "WebPluginContainerImpl.h"
+
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+
+WebPlugin* WebPluginDocument::plugin()
+{
+ if (!isPluginDocument())
+ return 0;
+ PluginDocument* doc = unwrap<PluginDocument>();
+ WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(static_cast<PluginDocument*>(doc)->pluginWidget());
+ return container->plugin();
+}
+
+
+WebPluginDocument::WebPluginDocument(const PassRefPtr<PluginDocument>& elem)
+ : WebDocument(elem)
+{
+}
+
+WebPluginDocument& WebPluginDocument::operator=(const PassRefPtr<PluginDocument>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebPluginDocument::operator PassRefPtr<PluginDocument>() const
+{
+ return static_cast<PluginDocument*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPluginListBuilderImpl.cpp b/Source/WebKit/chromium/src/WebPluginListBuilderImpl.cpp
new file mode 100644
index 0000000..d0f7324
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginListBuilderImpl.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPluginListBuilderImpl.h"
+
+#include "PluginData.h"
+#include "WebString.h"
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPluginListBuilderImpl::addPlugin(const WebString& name, const WebString& description, const WebString& fileName)
+{
+ PluginInfo info;
+ info.name = name;
+ info.desc = description;
+ info.file = fileName;
+ m_results->append(info);
+}
+
+void WebPluginListBuilderImpl::addMediaTypeToLastPlugin(const WebString& name, const WebString& description)
+{
+ MimeClassInfo info;
+ info.type = name;
+ info.desc = description;
+ m_results->last().mimes.append(info);
+}
+
+void WebPluginListBuilderImpl::addFileExtensionToLastMediaType(const WebString& extension)
+{
+ MimeClassInfo& info = m_results->last().mimes.last();
+ info.extensions.append(extension);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPluginListBuilderImpl.h b/Source/WebKit/chromium/src/WebPluginListBuilderImpl.h
new file mode 100644
index 0000000..3d7977a
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginListBuilderImpl.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPluginListBuilderImpl_h
+#define WebPluginListBuilderImpl_h
+
+#include "WebPluginListBuilder.h"
+
+#include "PluginData.h"
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class WebPluginListBuilderImpl : public WebPluginListBuilder {
+public:
+ WebPluginListBuilderImpl(Vector<WebCore::PluginInfo>* results) : m_results(results) { }
+
+ // WebPluginListBuilder methods:
+ virtual void addPlugin(const WebString& name, const WebString& description, const WebString& fileName);
+ virtual void addMediaTypeToLastPlugin(const WebString& name, const WebString& description);
+ virtual void addFileExtensionToLastMediaType(const WebString& extension);
+
+private:
+ Vector<WebCore::PluginInfo>* m_results;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebPluginLoadObserver.cpp b/Source/WebKit/chromium/src/WebPluginLoadObserver.cpp
new file mode 100644
index 0000000..5ec59a6
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginLoadObserver.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPluginLoadObserver.h"
+
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+
+namespace WebKit {
+
+WebPluginLoadObserver::~WebPluginLoadObserver()
+{
+ if (m_pluginContainer)
+ m_pluginContainer->willDestroyPluginLoadObserver(this);
+}
+
+void WebPluginLoadObserver::didFinishLoading()
+{
+ if (m_pluginContainer)
+ m_pluginContainer->plugin()->didFinishLoadingFrameRequest(m_notifyURL, m_notifyData);
+}
+
+void WebPluginLoadObserver::didFailLoading(const WebURLError& error)
+{
+ if (m_pluginContainer)
+ m_pluginContainer->plugin()->didFailLoadingFrameRequest(m_notifyURL, m_notifyData, error);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPluginLoadObserver.h b/Source/WebKit/chromium/src/WebPluginLoadObserver.h
new file mode 100644
index 0000000..7bd06eb
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPluginLoadObserver.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPluginLoadObserver_h
+#define WebPluginLoadObserver_h
+
+#include "WebURL.h"
+
+namespace WebKit {
+
+class WebPluginContainerImpl;
+struct WebURLError;
+
+class WebPluginLoadObserver {
+public:
+ WebPluginLoadObserver(WebPluginContainerImpl* pluginContainer,
+ const WebURL& notifyURL, void* notifyData)
+ : m_pluginContainer(pluginContainer)
+ , m_notifyURL(notifyURL)
+ , m_notifyData(notifyData)
+ {
+ }
+
+ ~WebPluginLoadObserver();
+
+ const WebURL& url() const { return m_notifyURL; }
+
+ void clearPluginContainer() { m_pluginContainer = 0; }
+ void didFinishLoading();
+ void didFailLoading(const WebURLError&);
+
+private:
+ WebPluginContainerImpl* m_pluginContainer;
+ WebURL m_notifyURL;
+ void* m_notifyData;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
new file mode 100644
index 0000000..a209e6a
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
@@ -0,0 +1,361 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPopupMenuImpl.h"
+
+#include "Cursor.h"
+#include "FramelessScrollView.h"
+#include "FrameView.h"
+#include "IntRect.h"
+#include "PlatformContextSkia.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "SkiaUtils.h"
+
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebRect.h"
+#include "WebWidgetClient.h"
+
+#include <skia/ext/platform_canvas.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// WebPopupMenu ---------------------------------------------------------------
+
+WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client)
+{
+ // Pass the WebPopupMenuImpl's self-reference to the caller.
+ return adoptRef(new WebPopupMenuImpl(client)).leakRef();
+}
+
+// WebWidget ------------------------------------------------------------------
+
+WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client)
+ : m_client(client)
+ , m_widget(0)
+{
+ // set to impossible point so we always get the first mouse pos
+ m_lastMousePosition = WebPoint(-1, -1);
+}
+
+WebPopupMenuImpl::~WebPopupMenuImpl()
+{
+ if (m_widget)
+ m_widget->setClient(0);
+}
+
+void WebPopupMenuImpl::Init(FramelessScrollView* widget, const WebRect& bounds)
+{
+ m_widget = widget;
+ m_widget->setClient(this);
+
+ if (m_client) {
+ m_client->setWindowRect(bounds);
+ m_client->show(WebNavigationPolicy()); // Policy is ignored
+ }
+}
+
+void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event)
+{
+ // don't send mouse move messages if the mouse hasn't moved.
+ if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) {
+ m_lastMousePosition = WebPoint(event.x, event.y);
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+ }
+}
+
+void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event)
+{
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event)
+{
+ m_widget->handleMouseDownEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event)
+{
+ mouseCaptureLost();
+ m_widget->handleMouseReleaseEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event)
+{
+ m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event));
+}
+
+bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event)
+{
+ return m_widget->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+}
+
+// WebWidget -------------------------------------------------------------------
+
+void WebPopupMenuImpl::close()
+{
+ if (m_widget)
+ m_widget->hide();
+
+ m_client = 0;
+
+ deref(); // Balances ref() from WebWidget::Create
+}
+
+void WebPopupMenuImpl::resize(const WebSize& newSize)
+{
+ if (m_size == newSize)
+ return;
+ m_size = newSize;
+
+ if (m_widget) {
+ IntRect newGeometry(0, 0, m_size.width, m_size.height);
+ m_widget->setFrameRect(newGeometry);
+ }
+
+ if (m_client) {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ m_client->didInvalidateRect(damagedRect);
+ }
+}
+
+void WebPopupMenuImpl::animate()
+{
+}
+
+void WebPopupMenuImpl::layout()
+{
+}
+
+void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ if (!m_widget)
+ return;
+
+ if (!rect.isEmpty()) {
+#if WEBKIT_USING_CG
+ GraphicsContext gc(canvas);
+#elif WEBKIT_USING_SKIA
+ PlatformContextSkia context(canvas);
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+ notImplemented();
+#endif
+ m_widget->paint(&gc, rect);
+ }
+}
+
+void WebPopupMenuImpl::themeChanged()
+{
+ notImplemented();
+}
+
+void WebPopupMenuImpl::composite(bool finish)
+{
+ notImplemented();
+}
+
+bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ if (!m_widget)
+ return false;
+
+ // TODO (jcampan): WebKit seems to always return false on mouse events
+ // methods. For now we'll assume it has processed them (as we are only
+ // interested in whether keyboard events are processed).
+ switch (inputEvent.type) {
+ case WebInputEvent::MouseMove:
+ MouseMove(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseLeave:
+ MouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseWheel:
+ MouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseDown:
+ MouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseUp:
+ MouseUp(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ // In Windows, RawKeyDown only has information about the physical key, but
+ // for "selection", we need the information about the character the key
+ // translated into. For English, the physical key value and the character
+ // value are the same, hence, "selection" works for English. But for other
+ // languages, such as Hebrew, the character value is different from the
+ // physical key value. Thus, without accepting Char event type which
+ // contains the key's character value, the "selection" won't work for
+ // non-English languages, such as Hebrew.
+ case WebInputEvent::RawKeyDown:
+ case WebInputEvent::KeyDown:
+ case WebInputEvent::KeyUp:
+ case WebInputEvent::Char:
+ return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+
+ default:
+ break;
+ }
+ return false;
+}
+
+void WebPopupMenuImpl::mouseCaptureLost()
+{
+}
+
+void WebPopupMenuImpl::setFocus(bool enable)
+{
+}
+
+bool WebPopupMenuImpl::setComposition(
+ const WebString& text, const WebVector<WebCompositionUnderline>& underlines,
+ int selectionStart, int selectionEnd)
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::confirmComposition()
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::confirmComposition(const WebString& text)
+{
+ return false;
+}
+
+WebTextInputType WebPopupMenuImpl::textInputType()
+{
+ return WebTextInputTypeNone;
+}
+
+WebRect WebPopupMenuImpl::caretOrSelectionBounds()
+{
+ return WebRect();
+}
+
+void WebPopupMenuImpl::setTextDirection(WebTextDirection direction)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// WebCore::HostWindow
+
+void WebPopupMenuImpl::invalidateContents(const IntRect&, bool)
+{
+ notImplemented();
+}
+
+void WebPopupMenuImpl::invalidateWindow(const IntRect&, bool)
+{
+ notImplemented();
+}
+
+void WebPopupMenuImpl::invalidateContentsAndWindow(const IntRect& paintRect, bool /*immediate*/)
+{
+ if (paintRect.isEmpty())
+ return;
+ if (m_client)
+ m_client->didInvalidateRect(paintRect);
+}
+
+void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate)
+{
+ invalidateContentsAndWindow(updateRect, immediate);
+}
+
+void WebPopupMenuImpl::scheduleAnimation()
+{
+}
+
+void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
+ const IntRect& scrollRect,
+ const IntRect& clipRect)
+{
+ if (m_client) {
+ int dx = scrollDelta.width();
+ int dy = scrollDelta.height();
+ m_client->didScrollRect(dx, dy, clipRect);
+ }
+}
+
+IntPoint WebPopupMenuImpl::screenToWindow(const IntPoint& point) const
+{
+ notImplemented();
+ return IntPoint();
+}
+
+IntRect WebPopupMenuImpl::windowToScreen(const IntRect& rect) const
+{
+ notImplemented();
+ return IntRect();
+}
+
+void WebPopupMenuImpl::scrollRectIntoView(const IntRect&, const ScrollView*) const
+{
+ // Nothing to be done here since we do not have the concept of a container
+ // that implements its own scrolling.
+}
+
+void WebPopupMenuImpl::scrollbarsModeDidChange() const
+{
+ // Nothing to be done since we have no concept of different scrollbar modes.
+}
+
+void WebPopupMenuImpl::setCursor(const WebCore::Cursor&)
+{
+}
+
+//-----------------------------------------------------------------------------
+// WebCore::FramelessScrollViewClient
+
+void WebPopupMenuImpl::popupClosed(FramelessScrollView* widget)
+{
+ ASSERT(widget == m_widget);
+ if (m_widget) {
+ m_widget->setClient(0);
+ m_widget = 0;
+ }
+ m_client->closeWidgetSoon();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.h b/Source/WebKit/chromium/src/WebPopupMenuImpl.h
new file mode 100644
index 0000000..7bb9f7e
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPopupMenuImpl_h
+#define WebPopupMenuImpl_h
+
+#include "FramelessScrollViewClient.h"
+#include "WebPoint.h"
+#include "WebPopupMenu.h"
+#include "WebSize.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class Frame;
+class FramelessScrollView;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class Range;
+class Widget;
+}
+
+namespace WebKit {
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+struct WebRect;
+
+class WebPopupMenuImpl : public WebPopupMenu,
+ public WebCore::FramelessScrollViewClient,
+ public RefCounted<WebPopupMenuImpl> {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ // WebWidget
+ virtual void close();
+ virtual WebSize size() { return m_size; }
+ virtual void resize(const WebSize&);
+ virtual void animate();
+ virtual void layout();
+ virtual void paint(WebCanvas* canvas, const WebRect& rect);
+ virtual void themeChanged();
+ virtual void composite(bool finish);
+ virtual bool handleInputEvent(const WebInputEvent&);
+ virtual void mouseCaptureLost();
+ virtual void setFocus(bool enable);
+ virtual bool setComposition(
+ const WebString& text,
+ const WebVector<WebCompositionUnderline>& underlines,
+ int selectionStart, int selectionEnd);
+ virtual bool confirmComposition();
+ virtual bool confirmComposition(const WebString& text);
+ virtual WebTextInputType textInputType();
+ virtual WebRect caretOrSelectionBounds();
+ virtual void setTextDirection(WebTextDirection direction);
+ virtual bool isAcceleratedCompositingActive() const { return false; }
+
+ // WebPopupMenuImpl
+ void Init(WebCore::FramelessScrollView* widget,
+ const WebRect& bounds);
+
+ WebWidgetClient* client() { return m_client; }
+
+ void MouseMove(const WebMouseEvent&);
+ void MouseLeave(const WebMouseEvent&);
+ void MouseDown(const WebMouseEvent&);
+ void MouseUp(const WebMouseEvent&);
+ void MouseDoubleClick(const WebMouseEvent&);
+ void MouseWheel(const WebMouseWheelEvent&);
+ bool KeyEvent(const WebKeyboardEvent&);
+
+ protected:
+ friend class WebPopupMenu; // For WebPopupMenu::create
+ friend class WTF::RefCounted<WebPopupMenuImpl>;
+
+ WebPopupMenuImpl(WebWidgetClient* client);
+ ~WebPopupMenuImpl();
+
+ // WebCore::HostWindow methods:
+ virtual void invalidateContents(const WebCore::IntRect&, bool);
+ virtual void invalidateWindow(const WebCore::IntRect&, bool);
+ virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
+ virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
+ virtual void scheduleAnimation();
+ virtual void scroll(
+ const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
+ const WebCore::IntRect& clipRect);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
+ virtual PlatformPageClient platformPageClient() const { return 0; }
+ virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const;
+ virtual void scrollbarsModeDidChange() const;
+ virtual void setCursor(const WebCore::Cursor&);
+
+ // WebCore::FramelessScrollViewClient methods:
+ virtual void popupClosed(WebCore::FramelessScrollView*);
+
+ WebWidgetClient* m_client;
+ WebSize m_size;
+
+ WebPoint m_lastMousePosition;
+
+ // This is a non-owning ref. The popup will notify us via popupClosed()
+ // before it is destroyed.
+ WebCore::FramelessScrollView* m_widget;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebRange.cpp b/Source/WebKit/chromium/src/WebRange.cpp
new file mode 100644
index 0000000..3dd000d
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebRange.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebRange.h"
+
+#include "Range.h"
+#include "WebNode.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebRangePrivate : public Range {
+};
+
+void WebRange::reset()
+{
+ assign(0);
+}
+
+void WebRange::assign(const WebRange& other)
+{
+ WebRangePrivate* p = const_cast<WebRangePrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+int WebRange::startOffset() const
+{
+ return m_private->startOffset();
+}
+
+int WebRange::endOffset() const
+{
+ return m_private->endOffset();
+}
+
+WebNode WebRange::startContainer(int& exceptionCode) const
+{
+ return PassRefPtr<Node>(m_private->startContainer(exceptionCode));
+}
+
+WebNode WebRange::endContainer(int& exceptionCode) const
+{
+ return PassRefPtr<Node>(m_private->endContainer(exceptionCode));
+}
+
+WebString WebRange::toHTMLText() const
+{
+ return m_private->toHTML();
+}
+
+WebString WebRange::toPlainText() const
+{
+ return m_private->text();
+}
+
+WebRange::WebRange(const WTF::PassRefPtr<WebCore::Range>& range)
+ : m_private(static_cast<WebRangePrivate*>(range.releaseRef()))
+{
+}
+
+WebRange& WebRange::operator=(const WTF::PassRefPtr<WebCore::Range>& range)
+{
+ assign(static_cast<WebRangePrivate*>(range.releaseRef()));
+ return *this;
+}
+
+WebRange::operator WTF::PassRefPtr<WebCore::Range>() const
+{
+ return PassRefPtr<Range>(const_cast<WebRangePrivate*>(m_private));
+}
+
+void WebRange::assign(WebRangePrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebRegularExpression.cpp b/Source/WebKit/chromium/src/WebRegularExpression.cpp
new file mode 100644
index 0000000..558b750
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebRegularExpression.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebRegularExpression.h"
+
+#include "RegularExpression.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebRegularExpressionPrivate : public RegularExpression {
+};
+
+WebRegularExpression::WebRegularExpression(const WebString& pattern,
+ WebTextCaseSensitivity caseSensitivity)
+{
+ TextCaseSensitivity sensitivity = static_cast<TextCaseSensitivity>(caseSensitivity);
+ RegularExpression* re = new RegularExpression(pattern, sensitivity);
+ m_private = static_cast<WebRegularExpressionPrivate*>(re);
+}
+
+WebRegularExpression::~WebRegularExpression()
+{
+ delete m_private;
+}
+
+int WebRegularExpression::match(const WebString& str,
+ int startFrom,
+ int* matchLength) const
+{
+ if (!m_private)
+ return -1;
+
+ return m_private->match(str, startFrom, matchLength);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp
new file mode 100644
index 0000000..0b5d397
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp
@@ -0,0 +1,307 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebRuntimeFeatures.h"
+
+#include "AbstractDatabase.h"
+#include "RuntimeEnabledFeatures.h"
+#include "WebMediaPlayerClientImpl.h"
+#include "WebSocket.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebRuntimeFeatures::enableDatabase(bool enable)
+{
+#if ENABLE(DATABASE)
+ AbstractDatabase::setIsAvailable(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isDatabaseEnabled()
+{
+#if ENABLE(DATABASE)
+ return AbstractDatabase::isAvailable();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableLocalStorage(bool enable)
+{
+#if ENABLE(DOM_STORAGE)
+ RuntimeEnabledFeatures::setLocalStorageEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isLocalStorageEnabled()
+{
+#if ENABLE(DOM_STORAGE)
+ return RuntimeEnabledFeatures::localStorageEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableSessionStorage(bool enable)
+{
+#if ENABLE(DOM_STORAGE)
+ RuntimeEnabledFeatures::setSessionStorageEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isSessionStorageEnabled()
+{
+#if ENABLE(DOM_STORAGE)
+ return RuntimeEnabledFeatures::sessionStorageEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableMediaPlayer(bool enable)
+{
+#if ENABLE(VIDEO)
+ WebMediaPlayerClientImpl::setIsEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isMediaPlayerEnabled()
+{
+#if ENABLE(VIDEO)
+ return WebMediaPlayerClientImpl::isEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableSockets(bool enable)
+{
+#if ENABLE(WEB_SOCKETS)
+ WebSocket::setIsAvailable(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isSocketsEnabled()
+{
+#if ENABLE(WEB_SOCKETS)
+ return WebSocket::isAvailable();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableNotifications(bool enable)
+{
+#if ENABLE(NOTIFICATIONS)
+ RuntimeEnabledFeatures::setWebkitNotificationsEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isNotificationsEnabled()
+{
+#if ENABLE(NOTIFICATIONS)
+ return RuntimeEnabledFeatures::webkitNotificationsEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableApplicationCache(bool enable)
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ RuntimeEnabledFeatures::setApplicationCacheEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isApplicationCacheEnabled()
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ return RuntimeEnabledFeatures::applicationCacheEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableGeolocation(bool enable)
+{
+#if ENABLE(GEOLOCATION)
+ RuntimeEnabledFeatures::setGeolocationEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isGeolocationEnabled()
+{
+#if ENABLE(GEOLOCATION)
+ return RuntimeEnabledFeatures::geolocationEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableIndexedDatabase(bool enable)
+{
+#if ENABLE(INDEXED_DATABASE)
+ RuntimeEnabledFeatures::setWebkitIndexedDBEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isIndexedDatabaseEnabled()
+{
+#if ENABLE(INDEXED_DATABASE)
+ return RuntimeEnabledFeatures::webkitIndexedDBEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableWebAudio(bool enable)
+{
+#if ENABLE(WEB_AUDIO)
+ RuntimeEnabledFeatures::setWebkitAudioContextEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isWebAudioEnabled()
+{
+#if ENABLE(WEB_AUDIO)
+ return RuntimeEnabledFeatures::webkitAudioContextEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableWebGL(bool enable)
+{
+#if ENABLE(3D_CANVAS)
+ RuntimeEnabledFeatures::setWebGLEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isWebGLEnabled()
+{
+#if ENABLE(3D_CANVAS)
+ return RuntimeEnabledFeatures::webGLRenderingContextEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enablePushState(bool enable)
+{
+ RuntimeEnabledFeatures::setPushStateEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isPushStateEnabled(bool enable)
+{
+ return RuntimeEnabledFeatures::pushStateEnabled();
+}
+
+void WebRuntimeFeatures::enableTouch(bool enable)
+{
+#if ENABLE(TOUCH_EVENTS)
+ RuntimeEnabledFeatures::setTouchEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isTouchEnabled()
+{
+#if ENABLE(TOUCH_EVENTS)
+ return RuntimeEnabledFeatures::touchEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableDeviceMotion(bool enable)
+{
+ RuntimeEnabledFeatures::setDeviceMotionEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isDeviceMotionEnabled()
+{
+ return RuntimeEnabledFeatures::deviceMotionEnabled();
+}
+
+void WebRuntimeFeatures::enableDeviceOrientation(bool enable)
+{
+ RuntimeEnabledFeatures::setDeviceOrientationEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isDeviceOrientationEnabled()
+{
+ return RuntimeEnabledFeatures::deviceOrientationEnabled();
+}
+
+void WebRuntimeFeatures::enableSpeechInput(bool enable)
+{
+ RuntimeEnabledFeatures::setSpeechInputEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isSpeechInputEnabled()
+{
+ return RuntimeEnabledFeatures::speechInputEnabled();
+}
+
+void WebRuntimeFeatures::enableXHRResponseBlob(bool enable)
+{
+#if ENABLE(XHR_RESPONSE_BLOB)
+ RuntimeEnabledFeatures::setXHRResponseBlobEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isXHRResponseBlobEnabled()
+{
+#if ENABLE(XHR_RESPONSE_BLOB)
+ return RuntimeEnabledFeatures::xhrResponseBlobEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableFileSystem(bool enable)
+{
+#if ENABLE(FILE_SYSTEM)
+ RuntimeEnabledFeatures::setFileSystemEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isFileSystemEnabled()
+{
+#if ENABLE(FILE_SYSTEM)
+ return RuntimeEnabledFeatures::fileSystemEnabled();
+#else
+ return false;
+#endif
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebScriptController.cpp b/Source/WebKit/chromium/src/WebScriptController.cpp
new file mode 100644
index 0000000..10bc68f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebScriptController.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebScriptController.h"
+
+#include "V8Binding.h"
+#include "V8DOMMap.h"
+#include "V8Proxy.h"
+
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebScriptController::registerExtension(v8::Extension* extension)
+{
+ V8Proxy::registerExtension(extension);
+}
+
+void WebScriptController::enableV8SingleThreadMode()
+{
+ enableStringImplCache();
+ enableFasterDOMStoreAccess();
+}
+
+void WebScriptController::flushConsoleMessages()
+{
+ // FIXME: remove this method after all it's usages are gone.
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebScrollbarImpl.cpp b/Source/WebKit/chromium/src/WebScrollbarImpl.cpp
new file mode 100644
index 0000000..05d2d1f
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebScrollbarImpl.cpp
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebScrollbarImpl.h"
+
+#include "GraphicsContext.h"
+#include "KeyboardCodes.h"
+#include "PlatformContextSkia.h"
+#include "Scrollbar.h"
+#include "ScrollbarTheme.h"
+#include "ScrollTypes.h"
+#include "WebCanvas.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebRect.h"
+#include "WebScrollbarClient.h"
+#include "WebVector.h"
+#include "WebViewImpl.h"
+
+using namespace std;
+using namespace WebCore;
+
+namespace WebKit {
+
+WebScrollbar* WebScrollbar::create(WebScrollbarClient* client, Orientation orientation)
+{
+ return new WebScrollbarImpl(client, orientation);
+}
+
+int WebScrollbar::defaultThickness()
+{
+ return ScrollbarTheme::nativeTheme()->scrollbarThickness();
+}
+
+WebScrollbarImpl::WebScrollbarImpl(WebScrollbarClient* client, Orientation orientation)
+ : m_client(client)
+ , m_scrollOffset(0)
+{
+ m_scrollbar = Scrollbar::createNativeScrollbar(
+ static_cast<ScrollableArea*>(this),
+ static_cast<ScrollbarOrientation>(orientation),
+ RegularScrollbar);
+}
+
+WebScrollbarImpl::~WebScrollbarImpl()
+{
+}
+
+void WebScrollbarImpl::setLocation(const WebRect& rect)
+{
+ WebCore::IntRect oldRect = m_scrollbar->frameRect();
+ m_scrollbar->setFrameRect(rect);
+ if (WebRect(oldRect) != rect)
+ m_scrollbar->invalidate();
+
+ int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar->width() : m_scrollbar->height();
+ int pageStep = max(max(static_cast<int>(static_cast<float>(length) * Scrollbar::minFractionToStepWhenPaging()), length - Scrollbar::maxOverlapBetweenPages()), 1);
+ m_scrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+ m_scrollbar->setEnabled(m_scrollbar->totalSize() > length);
+ m_scrollbar->setProportion(length, m_scrollbar->totalSize());
+}
+
+int WebScrollbarImpl::value() const
+{
+ return m_scrollOffset;
+}
+
+void WebScrollbarImpl::setValue(int position)
+{
+ WebCore::ScrollableArea::scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), position);
+}
+
+void WebScrollbarImpl::setDocumentSize(int size)
+{
+ int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar->width() : m_scrollbar->height();
+ m_scrollbar->setEnabled(size > length);
+ m_scrollbar->setProportion(length, size);
+}
+
+void WebScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
+{
+ WebCore::ScrollDirection dir;
+ bool horizontal = m_scrollbar->orientation() == HorizontalScrollbar;
+ if (direction == ScrollForward)
+ dir = horizontal ? ScrollRight : ScrollDown;
+ else
+ dir = horizontal ? ScrollLeft : ScrollUp;
+
+ WebCore::ScrollableArea::scroll(dir, static_cast<WebCore::ScrollGranularity>(granularity), multiplier);
+}
+
+void WebScrollbarImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+#if WEBKIT_USING_CG
+ GraphicsContext gc(canvas);
+#elif WEBKIT_USING_SKIA
+ PlatformContextSkia context(canvas);
+
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+ notImplemented();
+#endif
+
+ m_scrollbar->paint(&gc, rect);
+}
+
+bool WebScrollbarImpl::handleInputEvent(const WebInputEvent& event)
+{
+ switch (event.type) {
+ case WebInputEvent::MouseDown:
+ return onMouseDown(event);
+ case WebInputEvent::MouseUp:
+ return onMouseUp(event);
+ case WebInputEvent::MouseMove:
+ return onMouseMove(event);
+ case WebInputEvent::MouseLeave:
+ return onMouseLeave(event);
+ case WebInputEvent::MouseWheel:
+ return onMouseWheel(event);
+ case WebInputEvent::KeyDown:
+ return onKeyDown(event);
+ case WebInputEvent::Undefined:
+ case WebInputEvent::MouseEnter:
+ case WebInputEvent::RawKeyDown:
+ case WebInputEvent::KeyUp:
+ case WebInputEvent::Char:
+ case WebInputEvent::TouchStart:
+ case WebInputEvent::TouchMove:
+ case WebInputEvent::TouchEnd:
+ case WebInputEvent::TouchCancel:
+ default:
+ break;
+ }
+ return false;
+}
+
+bool WebScrollbarImpl::onMouseDown(const WebInputEvent& event)
+{
+ WebMouseEvent mousedown = *static_cast<const WebMouseEvent*>(&event);
+ if (!m_scrollbar->frameRect().contains(mousedown.x, mousedown.y))
+ return false;
+
+ mousedown.x -= m_scrollbar->x();
+ mousedown.y -= m_scrollbar->y();
+ m_scrollbar->mouseDown(PlatformMouseEventBuilder(m_scrollbar.get(), mousedown));
+ return true;
+}
+
+bool WebScrollbarImpl::onMouseUp(const WebInputEvent& event)
+{
+ if (m_scrollbar->pressedPart() == NoPart)
+ return false;
+
+ return m_scrollbar->mouseUp();
+}
+
+bool WebScrollbarImpl::onMouseMove(const WebInputEvent& event)
+{
+ WebMouseEvent mousemove = *static_cast<const WebMouseEvent*>(&event);
+ if (m_scrollbar->frameRect().contains(mousemove.x, mousemove.y)
+ || m_scrollbar->pressedPart() != NoPart) {
+ mousemove.x -= m_scrollbar->x();
+ mousemove.y -= m_scrollbar->y();
+ return m_scrollbar->mouseMoved(PlatformMouseEventBuilder(m_scrollbar.get(), mousemove));
+ }
+
+ if (m_scrollbar->hoveredPart() != NoPart)
+ m_scrollbar->mouseExited();
+ return false;
+}
+
+bool WebScrollbarImpl::onMouseLeave(const WebInputEvent& event)
+{
+ if (m_scrollbar->hoveredPart() == NoPart)
+ return false;
+
+ return m_scrollbar->mouseExited();
+}
+
+bool WebScrollbarImpl::onMouseWheel(const WebInputEvent& event)
+{
+ // Same logic as in Scrollview.cpp. If we can move at all, we'll accept the event.
+ WebMouseWheelEvent mousewheel = *static_cast<const WebMouseWheelEvent*>(&event);
+ int maxScrollDelta = m_scrollbar->maximum() - m_scrollbar->value();
+ float delta = m_scrollbar->orientation() == HorizontalScrollbar ? mousewheel.deltaX : mousewheel.deltaY;
+ if ((delta < 0 && maxScrollDelta > 0) || (delta > 0 && m_scrollbar->value() > 0)) {
+ if (mousewheel.scrollByPage) {
+ ASSERT(m_scrollbar->orientation() == VerticalScrollbar);
+ bool negative = delta < 0;
+ delta = max(max(static_cast<float>(m_scrollbar->visibleSize()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollbar->visibleSize() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
+ if (negative)
+ delta *= -1;
+ }
+ WebCore::ScrollableArea::scroll((m_scrollbar->orientation() == HorizontalScrollbar) ? WebCore::ScrollLeft : WebCore::ScrollUp, WebCore::ScrollByPixel, delta);
+ return true;
+ }
+
+ return false;
+ }
+
+bool WebScrollbarImpl::onKeyDown(const WebInputEvent& event)
+{
+ WebKeyboardEvent keyboard = *static_cast<const WebKeyboardEvent*>(&event);
+ int keyCode;
+ // We have to duplicate this logic from WebViewImpl because there it uses
+ // Char and RawKeyDown events, which don't exist at this point.
+ if (keyboard.windowsKeyCode == VKEY_SPACE)
+ keyCode = ((keyboard.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT);
+ else {
+ if (keyboard.modifiers == WebInputEvent::ControlKey) {
+ // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl
+ // key combinations which affect scrolling. Safari is buggy in the
+ // sense that it scrolls the page for all Ctrl+scrolling key
+ // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc.
+ switch (keyboard.windowsKeyCode) {
+ case VKEY_HOME:
+ case VKEY_END:
+ break;
+ default:
+ return false;
+ }
+ }
+
+ if (keyboard.isSystemKey || (keyboard.modifiers & WebInputEvent::ShiftKey))
+ return false;
+
+ keyCode = keyboard.windowsKeyCode;
+ }
+ WebCore::ScrollDirection scrollDirection;
+ WebCore::ScrollGranularity scrollGranularity;
+ if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranularity)) {
+ // Will return false if scroll direction wasn't compatible with this scrollbar.
+ return WebCore::ScrollableArea::scroll(scrollDirection, scrollGranularity);
+ }
+ return false;
+}
+
+int WebScrollbarImpl::scrollSize(WebCore::ScrollbarOrientation orientation) const
+{
+ return (orientation == m_scrollbar->orientation()) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0;
+}
+
+int WebScrollbarImpl::scrollPosition(WebCore::Scrollbar*) const
+{
+ return m_scrollOffset;
+}
+
+void WebScrollbarImpl::setScrollOffset(const WebCore::IntPoint& offset)
+{
+ if (m_scrollbar->orientation() == HorizontalScrollbar)
+ m_scrollOffset = offset.x();
+ else
+ m_scrollOffset = offset.y();
+
+ m_client->valueChanged(this);
+}
+
+void WebScrollbarImpl::invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect& rect)
+{
+ WebRect webrect(rect);
+ webrect.x += m_scrollbar->x();
+ webrect.y += m_scrollbar->y();
+ m_client->invalidateScrollbarRect(this, webrect);
+}
+
+bool WebScrollbarImpl::isActive() const
+{
+ return true;
+}
+
+bool WebScrollbarImpl::scrollbarCornerPresent() const
+{
+ return false;
+}
+
+void WebScrollbarImpl::getTickmarks(Vector<WebCore::IntRect>& tickmarks) const
+{
+ WebVector<WebRect> ticks;
+ m_client->getTickmarks(const_cast<WebScrollbarImpl*>(this), &ticks);
+ tickmarks.resize(ticks.size());
+ for (size_t i = 0; i < ticks.size(); ++i)
+ tickmarks[i] = ticks[i];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebScrollbarImpl.h b/Source/WebKit/chromium/src/WebScrollbarImpl.h
new file mode 100644
index 0000000..4dcfd5d
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebScrollbarImpl.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebScrollbarImpl_h
+#define WebScrollbarImpl_h
+
+#include "ScrollableArea.h"
+#include "WebScrollbar.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class Scrollbar;
+}
+
+namespace WebKit {
+
+class WebScrollbarImpl : public WebScrollbar,
+ public WebCore::ScrollableArea {
+public:
+ WebScrollbarImpl(WebScrollbarClient*, Orientation orientation);
+ ~WebScrollbarImpl();
+
+ // WebKit::WebScrollbar methods
+ virtual void setLocation(const WebRect&);
+ virtual int value() const;
+ virtual void setValue(int position);
+ virtual void setDocumentSize(int size);
+ virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier);
+ virtual void paint(WebCanvas*, const WebRect&);
+ virtual bool handleInputEvent(const WebInputEvent&);
+
+ // WebCore::ScrollableArea methods
+ virtual int scrollSize(WebCore::ScrollbarOrientation) const;
+ virtual int scrollPosition(WebCore::Scrollbar*) const;
+ virtual void setScrollOffset(const WebCore::IntPoint&);
+ virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&);
+ virtual bool isActive() const;
+ virtual bool scrollbarCornerPresent() const;
+ virtual void getTickmarks(Vector<WebCore::IntRect>&) const;
+
+private:
+ bool onMouseDown(const WebInputEvent& event);
+ bool onMouseUp(const WebInputEvent& event);
+ bool onMouseMove(const WebInputEvent& event);
+ bool onMouseLeave(const WebInputEvent& event);
+ bool onMouseWheel(const WebInputEvent& event);
+ bool onKeyDown(const WebInputEvent& event);
+
+ WebScrollbarClient* m_client;
+
+ int m_scrollOffset;
+ RefPtr<WebCore::Scrollbar> m_scrollbar;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebSearchableFormData.cpp b/Source/WebKit/chromium/src/WebSearchableFormData.cpp
new file mode 100644
index 0000000..8e27a67
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSearchableFormData.cpp
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSearchableFormData.h"
+
+#include "Document.h"
+#include "FormDataBuilder.h"
+#include "FormDataList.h"
+#include "Frame.h"
+#include "HTMLFormControlElement.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "HTMLOptionsCollection.h"
+#include "HTMLSelectElement.h"
+#include "TextEncoding.h"
+#include "WebFormElement.h"
+
+using namespace WebCore;
+using namespace HTMLNames;
+
+namespace {
+
+// Gets the encoding for the form.
+void GetFormEncoding(const HTMLFormElement* form, TextEncoding* encoding)
+{
+ String str(form->getAttribute(HTMLNames::accept_charsetAttr));
+ str.replace(',', ' ');
+ Vector<String> charsets;
+ str.split(' ', charsets);
+ for (Vector<String>::const_iterator i(charsets.begin()); i != charsets.end(); ++i) {
+ *encoding = TextEncoding(*i);
+ if (encoding->isValid())
+ return;
+ }
+ const Frame* frame = form->document()->frame();
+ *encoding = frame ? TextEncoding(frame->loader()->writer()->encoding()) : Latin1Encoding();
+}
+
+// Returns true if the submit request results in an HTTP URL.
+bool IsHTTPFormSubmit(const HTMLFormElement* form)
+{
+ String action(form->action());
+ return form->document()->frame()->loader()->completeURL(action.isNull() ? "" : action).protocol() == "http";
+}
+
+// If the form does not have an activated submit button, the first submit
+// button is returned.
+HTMLFormControlElement* GetButtonToActivate(HTMLFormElement* form)
+{
+ HTMLFormControlElement* firstSubmitButton = 0;
+ // FIXME: Consider refactoring this code so that we don't call form->associatedElements() twice.
+ for (Vector<FormAssociatedElement*>::const_iterator i(form->associatedElements().begin()); i != form->associatedElements().end(); ++i) {
+ if (!(*i)->isFormControlElement())
+ continue;
+ HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(*i);
+ if (formElement->isActivatedSubmit())
+ // There's a button that is already activated for submit, return 0.
+ return 0;
+ if (!firstSubmitButton && formElement->isSuccessfulSubmitButton())
+ firstSubmitButton = formElement;
+ }
+ return firstSubmitButton;
+}
+
+// Returns true if the selected state of all the options matches the default
+// selected state.
+bool IsSelectInDefaultState(const HTMLSelectElement* select)
+{
+ const Vector<Element*>& listItems = select->listItems();
+ if (select->multiple() || select->size() > 1) {
+ for (Vector<Element*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) {
+ if (!(*i)->hasLocalName(HTMLNames::optionTag))
+ continue;
+ const HTMLOptionElement* optionElement = static_cast<const HTMLOptionElement*>(*i);
+ if (optionElement->selected() != optionElement->defaultSelected())
+ return false;
+ }
+ return true;
+ }
+
+ // The select is rendered as a combobox (called menulist in WebKit). At
+ // least one item is selected, determine which one.
+ const HTMLOptionElement* initialSelected = 0;
+ for (Vector<Element*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) {
+ if (!(*i)->hasLocalName(HTMLNames::optionTag))
+ continue;
+ const HTMLOptionElement* optionElement = static_cast<const HTMLOptionElement*>(*i);
+ if (optionElement->defaultSelected()) {
+ // The page specified the option to select.
+ initialSelected = optionElement;
+ break;
+ }
+ if (!initialSelected)
+ initialSelected = optionElement;
+ }
+ return initialSelected ? initialSelected->selected() : true;
+}
+
+// Returns true if the form element is in its default state, false otherwise.
+// The default state is the state of the form element on initial load of the
+// page, and varies depending upon the form element. For example, a checkbox is
+// in its default state if the checked state matches the state of the checked attribute.
+bool IsInDefaultState(const HTMLFormControlElement* formElement)
+{
+ if (formElement->hasTagName(HTMLNames::inputTag)) {
+ const HTMLInputElement* inputElement = static_cast<const HTMLInputElement*>(formElement);
+ if (inputElement->isCheckbox() || inputElement->isRadioButton())
+ return inputElement->checked() == inputElement->hasAttribute(checkedAttr);
+ } else if (formElement->hasTagName(HTMLNames::selectTag))
+ return IsSelectInDefaultState(static_cast<const HTMLSelectElement*>(formElement));
+ return true;
+}
+
+// If form has only one text input element, return true. If a valid input
+// element is not found, return false. Additionally, the form data for all
+// elements is added to enc_string and the encoding used is set in
+// encoding_name.
+bool HasSuitableTextElement(const HTMLFormElement* form, Vector<char>* encodedString, String* encodingName)
+{
+ TextEncoding encoding;
+ GetFormEncoding(form, &encoding);
+ if (!encoding.isValid()) {
+ // Need a valid encoding to encode the form elements.
+ // If the encoding isn't found webkit ends up replacing the params with
+ // empty strings. So, we don't try to do anything here.
+ return 0;
+ }
+ *encodingName = encoding.name();
+
+ HTMLInputElement* textElement = 0;
+ // FIXME: Consider refactoring this code so that we don't call form->associatedElements() twice.
+ for (Vector<FormAssociatedElement*>::const_iterator i(form->associatedElements().begin()); i != form->associatedElements().end(); ++i) {
+ if (!(*i)->isFormControlElement())
+ continue;
+ HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(*i);
+ if (formElement->disabled() || formElement->name().isNull())
+ continue;
+
+ if (!IsInDefaultState(formElement) || formElement->hasTagName(HTMLNames::textareaTag))
+ return 0;
+
+ bool isTextElement = false;
+ if (formElement->hasTagName(HTMLNames::inputTag)) {
+ const HTMLInputElement* input = static_cast<const HTMLInputElement*>(formElement);
+ if (input->isFileUpload()) {
+ // Too big, don't try to index this.
+ return 0;
+ }
+
+ if (input->isPasswordField()) {
+ // Don't store passwords! This is most likely an https anyway.
+ return 0;
+ }
+
+ if (input->isTextField())
+ isTextElement = true;
+ }
+
+ FormDataList dataList(encoding);
+ if (!formElement->appendFormData(dataList, false))
+ continue;
+
+ const Vector<FormDataList::Item>& items = dataList.items();
+ if (isTextElement && !items.isEmpty()) {
+ if (textElement) {
+ // The auto-complete bar only knows how to fill in one value.
+ // This form has multiple fields; don't treat it as searchable.
+ return false;
+ }
+ textElement = static_cast<HTMLInputElement*>(formElement);
+ }
+ for (Vector<FormDataList::Item>::const_iterator j(items.begin()); j != items.end(); ++j) {
+ // Handle ISINDEX / <input name=isindex> specially, but only if it's
+ // the first entry.
+ if (!encodedString->isEmpty() || j->data() != "isindex") {
+ if (!encodedString->isEmpty())
+ encodedString->append('&');
+ FormDataBuilder::encodeStringAsFormData(*encodedString, j->data());
+ encodedString->append('=');
+ }
+ ++j;
+ if (formElement == textElement)
+ encodedString->append("{searchTerms}", 13);
+ else
+ FormDataBuilder::encodeStringAsFormData(*encodedString, j->data());
+ }
+ }
+
+ return textElement;
+}
+
+} // namespace
+
+namespace WebKit {
+
+WebSearchableFormData::WebSearchableFormData(const WebFormElement& form)
+{
+ RefPtr<HTMLFormElement> formElement = form.operator PassRefPtr<HTMLFormElement>();
+ const Frame* frame = formElement->document()->frame();
+ if (!frame)
+ return;
+
+ // Only consider forms that GET data and the action targets an http page.
+ if (equalIgnoringCase(formElement->getAttribute(HTMLNames::methodAttr), "post") || !IsHTTPFormSubmit(formElement.get()))
+ return;
+
+ HTMLFormControlElement* firstSubmitButton = GetButtonToActivate(formElement.get());
+ if (firstSubmitButton) {
+ // The form does not have an active submit button, make the first button
+ // active. We need to do this, otherwise the URL will not contain the
+ // name of the submit button.
+ firstSubmitButton->setActivatedSubmit(true);
+ }
+ Vector<char> encodedString;
+ String encoding;
+ bool hasElement = HasSuitableTextElement(formElement.get(), &encodedString, &encoding);
+ if (firstSubmitButton)
+ firstSubmitButton->setActivatedSubmit(false);
+ if (!hasElement) {
+ // Not a searchable form.
+ return;
+ }
+
+ String action(formElement->action());
+ KURL url(frame->loader()->completeURL(action.isNull() ? "" : action));
+ RefPtr<FormData> formData = FormData::create(encodedString);
+ url.setQuery(formData->flattenToString());
+ m_url = url;
+ m_encoding = encoding;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSecurityOrigin.cpp b/Source/WebKit/chromium/src/WebSecurityOrigin.cpp
new file mode 100644
index 0000000..adccb31
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSecurityOrigin.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSecurityOrigin.h"
+
+#include "KURL.h"
+#include "SecurityOrigin.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebSecurityOriginPrivate : public SecurityOrigin {
+};
+
+WebSecurityOrigin WebSecurityOrigin::createFromDatabaseIdentifier(const WebString& databaseIdentifier)
+{
+ return WebSecurityOrigin(SecurityOrigin::createFromDatabaseIdentifier(databaseIdentifier));
+}
+
+WebSecurityOrigin WebSecurityOrigin::createFromString(const WebString& origin)
+{
+ return WebSecurityOrigin(SecurityOrigin::createFromString(origin));
+}
+
+WebSecurityOrigin WebSecurityOrigin::create(const WebURL& url)
+{
+ return WebSecurityOrigin(SecurityOrigin::create(url));
+}
+
+void WebSecurityOrigin::reset()
+{
+ assign(0);
+}
+
+void WebSecurityOrigin::assign(const WebSecurityOrigin& other)
+{
+ WebSecurityOriginPrivate* p = const_cast<WebSecurityOriginPrivate*>(other.m_private);
+ if (p)
+ p->ref();
+ assign(p);
+}
+
+WebString WebSecurityOrigin::protocol() const
+{
+ ASSERT(m_private);
+ return m_private->protocol();
+}
+
+WebString WebSecurityOrigin::host() const
+{
+ ASSERT(m_private);
+ return m_private->host();
+}
+
+unsigned short WebSecurityOrigin::port() const
+{
+ ASSERT(m_private);
+ return m_private->port();
+}
+
+bool WebSecurityOrigin::isEmpty() const
+{
+ ASSERT(m_private);
+ return m_private->isEmpty();
+}
+
+bool WebSecurityOrigin::canAccess(const WebSecurityOrigin& other) const
+{
+ ASSERT(m_private);
+ ASSERT(other.m_private);
+ return m_private->canAccess(other.m_private);
+}
+
+bool WebSecurityOrigin::canRequest(const WebURL& url) const
+{
+ ASSERT(m_private);
+ return m_private->canRequest(url);
+}
+
+WebString WebSecurityOrigin::toString() const
+{
+ ASSERT(m_private);
+ return m_private->toString();
+}
+
+WebString WebSecurityOrigin::databaseIdentifier() const
+{
+ ASSERT(m_private);
+ return m_private->databaseIdentifier();
+}
+
+bool WebSecurityOrigin::canAccessPasswordManager() const
+{
+ ASSERT(m_private);
+ return m_private->canAccessPasswordManager();
+}
+
+WebSecurityOrigin::WebSecurityOrigin(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin)
+ : m_private(static_cast<WebSecurityOriginPrivate*>(origin.releaseRef()))
+{
+}
+
+WebSecurityOrigin& WebSecurityOrigin::operator=(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin)
+{
+ assign(static_cast<WebSecurityOriginPrivate*>(origin.releaseRef()));
+ return *this;
+}
+
+WebSecurityOrigin::operator WTF::PassRefPtr<WebCore::SecurityOrigin>() const
+{
+ return PassRefPtr<SecurityOrigin>(const_cast<WebSecurityOriginPrivate*>(m_private));
+}
+
+SecurityOrigin* WebSecurityOrigin::get() const
+{
+ return m_private;
+}
+
+void WebSecurityOrigin::assign(WebSecurityOriginPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSecurityPolicy.cpp b/Source/WebKit/chromium/src/WebSecurityPolicy.cpp
new file mode 100644
index 0000000..8e4e702
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSecurityPolicy.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSecurityPolicy.h"
+
+#include "FrameLoader.h"
+#include "SchemeRegistry.h"
+#include "SecurityOrigin.h"
+
+#include "WebString.h"
+#include "WebURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebSecurityPolicy::registerURLSchemeAsLocal(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsLocal(scheme);
+}
+
+void WebSecurityPolicy::registerURLSchemeAsNoAccess(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsNoAccess(scheme);
+}
+
+void WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsDisplayIsolated(scheme);
+}
+
+void WebSecurityPolicy::registerURLSchemeAsSecure(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsSecure(scheme);
+}
+
+void WebSecurityPolicy::addOriginAccessWhitelistEntry(
+ const WebURL& sourceOrigin,
+ const WebString& destinationProtocol,
+ const WebString& destinationHost,
+ bool allowDestinationSubdomains)
+{
+ SecurityOrigin::addOriginAccessWhitelistEntry(
+ *SecurityOrigin::create(sourceOrigin), destinationProtocol,
+ destinationHost, allowDestinationSubdomains);
+}
+
+void WebSecurityPolicy::removeOriginAccessWhitelistEntry(
+ const WebURL& sourceOrigin,
+ const WebString& destinationProtocol,
+ const WebString& destinationHost,
+ bool allowDestinationSubdomains)
+{
+ SecurityOrigin::removeOriginAccessWhitelistEntry(
+ *SecurityOrigin::create(sourceOrigin), destinationProtocol,
+ destinationHost, allowDestinationSubdomains);
+}
+
+void WebSecurityPolicy::resetOriginAccessWhitelists()
+{
+ SecurityOrigin::resetOriginAccessWhitelists();
+}
+
+bool WebSecurityPolicy::shouldHideReferrer(const WebURL& url, const WebString& referrer)
+{
+ return SecurityOrigin::shouldHideReferrer(url, referrer);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSelectElement.cpp b/Source/WebKit/chromium/src/WebSelectElement.cpp
new file mode 100644
index 0000000..79a4d85
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSelectElement.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSelectElement.h"
+
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "HTMLSelectElement.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebSelectElement::setValue(const WebString& value)
+{
+ unwrap<HTMLSelectElement>()->setValue(value);
+}
+
+WebString WebSelectElement::value()
+{
+ return unwrap<HTMLSelectElement>()->value();
+}
+
+WebVector<WebElement> WebSelectElement::listItems()
+{
+ const Vector<Element*>& sourceItems = unwrap<HTMLSelectElement>()->listItems();
+ WebVector<WebElement> items(sourceItems.size());
+ for (size_t i = 0; i < sourceItems.size(); ++i)
+ items[i] = WebElement(static_cast<HTMLElement*>(sourceItems[i]));
+
+ return items;
+}
+
+WebSelectElement::WebSelectElement(const PassRefPtr<HTMLSelectElement>& elem)
+ : WebFormControlElement(elem)
+{
+}
+
+WebSelectElement& WebSelectElement::operator=(const PassRefPtr<HTMLSelectElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebSelectElement::operator PassRefPtr<HTMLSelectElement>() const
+{
+ return static_cast<HTMLSelectElement*>(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSerializedScriptValue.cpp b/Source/WebKit/chromium/src/WebSerializedScriptValue.cpp
new file mode 100644
index 0000000..7149a4d
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSerializedScriptValue.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSerializedScriptValue.h"
+
+#include "SerializedScriptValue.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSerializedScriptValue WebSerializedScriptValue::fromString(const WebString& s)
+{
+ return SerializedScriptValue::createFromWire(s);
+}
+
+WebSerializedScriptValue WebSerializedScriptValue::createInvalid()
+{
+ return SerializedScriptValue::create();
+}
+
+void WebSerializedScriptValue::reset()
+{
+ m_private.reset();
+}
+
+void WebSerializedScriptValue::assign(const WebSerializedScriptValue& other)
+{
+ m_private = other.m_private;
+}
+
+WebString WebSerializedScriptValue::toString() const
+{
+ return m_private->toWireString();
+}
+
+WebSerializedScriptValue::WebSerializedScriptValue(const PassRefPtr<SerializedScriptValue>& value)
+ : m_private(value)
+{
+}
+
+WebSerializedScriptValue& WebSerializedScriptValue::operator=(const PassRefPtr<SerializedScriptValue>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebSerializedScriptValue::operator PassRefPtr<SerializedScriptValue>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/Source/WebKit/chromium/src/WebSettingsImpl.cpp
new file mode 100644
index 0000000..0457f77
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSettingsImpl.h"
+
+#include "FontRenderingMode.h"
+#include "Settings.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+#if defined(OS_WIN)
+#include "RenderThemeChromiumWin.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSettingsImpl::WebSettingsImpl(Settings* settings)
+ : m_settings(settings)
+{
+ ASSERT(settings);
+}
+
+void WebSettingsImpl::setStandardFontFamily(const WebString& font)
+{
+ m_settings->setStandardFontFamily(font);
+}
+
+void WebSettingsImpl::setFixedFontFamily(const WebString& font)
+{
+ m_settings->setFixedFontFamily((String)font);
+}
+
+void WebSettingsImpl::setSerifFontFamily(const WebString& font)
+{
+ m_settings->setSerifFontFamily((String)font);
+}
+
+void WebSettingsImpl::setSansSerifFontFamily(const WebString& font)
+{
+ m_settings->setSansSerifFontFamily((String)font);
+}
+
+void WebSettingsImpl::setCursiveFontFamily(const WebString& font)
+{
+ m_settings->setCursiveFontFamily((String)font);
+}
+
+void WebSettingsImpl::setFantasyFontFamily(const WebString& font)
+{
+ m_settings->setFantasyFontFamily((String)font);
+}
+
+void WebSettingsImpl::setDefaultFontSize(int size)
+{
+ m_settings->setDefaultFontSize(size);
+#if defined(OS_WIN)
+ // RenderTheme is a singleton that needs to know the default font size to
+ // draw some form controls. We let it know each time the size changes.
+ WebCore::RenderThemeChromiumWin::setDefaultFontSize(size);
+#endif
+}
+
+void WebSettingsImpl::setDefaultFixedFontSize(int size)
+{
+ m_settings->setDefaultFixedFontSize(size);
+}
+
+void WebSettingsImpl::setMinimumFontSize(int size)
+{
+ m_settings->setMinimumFontSize(size);
+}
+
+void WebSettingsImpl::setMinimumLogicalFontSize(int size)
+{
+ m_settings->setMinimumLogicalFontSize(size);
+}
+
+void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding)
+{
+ m_settings->setDefaultTextEncodingName((String)encoding);
+}
+
+void WebSettingsImpl::setJavaScriptEnabled(bool enabled)
+{
+ m_settings->setJavaScriptEnabled(enabled);
+}
+
+void WebSettingsImpl::setWebSecurityEnabled(bool enabled)
+{
+ m_settings->setWebSecurityEnabled(enabled);
+}
+
+void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows)
+{
+ m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows);
+}
+
+void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
+{
+ m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically);
+}
+
+void WebSettingsImpl::setImagesEnabled(bool enabled)
+{
+ m_settings->setImagesEnabled(enabled);
+}
+
+void WebSettingsImpl::setPluginsEnabled(bool enabled)
+{
+ m_settings->setPluginsEnabled(enabled);
+}
+
+void WebSettingsImpl::setDOMPasteAllowed(bool enabled)
+{
+ m_settings->setDOMPasteAllowed(enabled);
+}
+
+void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled)
+{
+ m_settings->setDeveloperExtrasEnabled(enabled);
+}
+
+void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled)
+{
+ m_settings->setNeedsSiteSpecificQuirks(enabled);
+}
+
+void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages)
+{
+ m_settings->setShrinksStandaloneImagesToFit(shrinkImages);
+}
+
+void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector)
+{
+ m_settings->setUsesEncodingDetector(usesDetector);
+}
+
+void WebSettingsImpl::setTextAreasAreResizable(bool areResizable)
+{
+ m_settings->setTextAreasAreResizable(areResizable);
+}
+
+void WebSettingsImpl::setJavaEnabled(bool enabled)
+{
+ m_settings->setJavaEnabled(enabled);
+}
+
+void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow)
+{
+ m_settings->setAllowScriptsToCloseWindows(allow);
+}
+
+void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location)
+{
+ m_settings->setUserStyleSheetLocation(location);
+}
+
+void WebSettingsImpl::setAuthorAndUserStylesEnabled(bool enabled)
+{
+ m_settings->setAuthorAndUserStylesEnabled(enabled);
+}
+
+void WebSettingsImpl::setUsesPageCache(bool usesPageCache)
+{
+ m_settings->setUsesPageCache(usesPageCache);
+}
+
+void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled)
+{
+ m_settings->setDownloadableBinaryFontsEnabled(enabled);
+}
+
+void WebSettingsImpl::setJavaScriptCanAccessClipboard(bool enabled)
+{
+ m_settings->setJavaScriptCanAccessClipboard(enabled);
+}
+
+void WebSettingsImpl::setXSSAuditorEnabled(bool enabled)
+{
+ m_settings->setXSSAuditorEnabled(enabled);
+}
+
+void WebSettingsImpl::setLocalStorageEnabled(bool enabled)
+{
+ m_settings->setLocalStorageEnabled(enabled);
+}
+
+void WebSettingsImpl::setEditableLinkBehaviorNeverLive()
+{
+ // FIXME: If you ever need more behaviors than this, then we should probably
+ // define an enum in WebSettings.h and have a switch statement that
+ // translates. Until then, this is probably fine, though.
+ m_settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive);
+}
+
+void WebSettingsImpl::setFrameFlatteningEnabled(bool enabled)
+{
+ m_settings->setFrameFlatteningEnabled(enabled);
+}
+
+void WebSettingsImpl::setFontRenderingModeNormal()
+{
+ // FIXME: If you ever need more behaviors than this, then we should probably
+ // define an enum in WebSettings.h and have a switch statement that
+ // translates. Until then, this is probably fine, though.
+ m_settings->setFontRenderingMode(WebCore::NormalRenderingMode);
+}
+
+void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled)
+{
+ m_settings->setShouldPaintCustomScrollbars(enabled);
+}
+
+void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow)
+{
+ m_settings->setAllowUniversalAccessFromFileURLs(allow);
+}
+
+void WebSettingsImpl::setAllowFileAccessFromFileURLs(bool allow)
+{
+ m_settings->setAllowFileAccessFromFileURLs(allow);
+}
+
+void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded()
+{
+ // FIXME: If you ever need more behaviors than this, then we should probably
+ // define an enum in WebSettings.h and have a switch statement that
+ // translates. Until then, this is probably fine, though.
+ m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded);
+}
+
+void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled)
+{
+ m_settings->setOfflineWebApplicationCacheEnabled(enabled);
+}
+
+void WebSettingsImpl::setWebAudioEnabled(bool enabled)
+{
+ m_settings->setWebAudioEnabled(enabled);
+}
+
+void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled)
+{
+ m_settings->setWebGLEnabled(enabled);
+}
+
+void WebSettingsImpl::setShowDebugBorders(bool show)
+{
+ m_settings->setShowDebugBorders(show);
+}
+
+void WebSettingsImpl::setEditingBehavior(EditingBehavior behavior)
+{
+ m_settings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(behavior));
+}
+
+void WebSettingsImpl::setAcceleratedCompositingEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingFor3DTransformsEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForVideoEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForVideoEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForPluginsEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForPluginsEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForCanvasEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForCanvasEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForAnimationEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForAnimationEnabled(enabled);
+}
+
+void WebSettingsImpl::setAccelerated2dCanvasEnabled(bool enabled)
+{
+ m_settings->setAccelerated2dCanvasEnabled(enabled);
+}
+
+void WebSettingsImpl::setMemoryInfoEnabled(bool enabled)
+{
+ m_settings->setMemoryInfoEnabled(enabled);
+}
+
+void WebSettingsImpl::setHyperlinkAuditingEnabled(bool enabled)
+{
+ m_settings->setHyperlinkAuditingEnabled(enabled);
+}
+
+void WebSettingsImpl::setCaretBrowsingEnabled(bool enabled)
+{
+ m_settings->setCaretBrowsingEnabled(enabled);
+}
+
+void WebSettingsImpl::setInteractiveFormValidationEnabled(bool enabled)
+{
+ m_settings->setInteractiveFormValidationEnabled(enabled);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.h b/Source/WebKit/chromium/src/WebSettingsImpl.h
new file mode 100644
index 0000000..4960bb9
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSettingsImpl.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSettingsImpl_h
+#define WebSettingsImpl_h
+
+#include "WebSettings.h"
+
+namespace WebCore {
+class Settings;
+}
+
+namespace WebKit {
+
+class WebSettingsImpl : public WebSettings {
+public:
+ explicit WebSettingsImpl(WebCore::Settings*);
+ virtual ~WebSettingsImpl() { }
+
+ virtual void setStandardFontFamily(const WebString&);
+ virtual void setFixedFontFamily(const WebString&);
+ virtual void setSerifFontFamily(const WebString&);
+ virtual void setSansSerifFontFamily(const WebString&);
+ virtual void setCursiveFontFamily(const WebString&);
+ virtual void setFantasyFontFamily(const WebString&);
+ virtual void setDefaultFontSize(int);
+ virtual void setDefaultFixedFontSize(int);
+ virtual void setMinimumFontSize(int);
+ virtual void setMinimumLogicalFontSize(int);
+ virtual void setDefaultTextEncodingName(const WebString&);
+ virtual void setJavaScriptEnabled(bool);
+ virtual void setWebSecurityEnabled(bool);
+ virtual void setJavaScriptCanOpenWindowsAutomatically(bool);
+ virtual void setLoadsImagesAutomatically(bool);
+ virtual void setImagesEnabled(bool);
+ virtual void setPluginsEnabled(bool);
+ virtual void setDOMPasteAllowed(bool);
+ virtual void setDeveloperExtrasEnabled(bool);
+ virtual void setNeedsSiteSpecificQuirks(bool);
+ virtual void setShrinksStandaloneImagesToFit(bool);
+ virtual void setUsesEncodingDetector(bool);
+ virtual void setTextAreasAreResizable(bool);
+ virtual void setJavaEnabled(bool);
+ virtual void setAllowScriptsToCloseWindows(bool);
+ virtual void setUserStyleSheetLocation(const WebURL&);
+ virtual void setAuthorAndUserStylesEnabled(bool);
+ virtual void setUsesPageCache(bool);
+ virtual void setDownloadableBinaryFontsEnabled(bool);
+ virtual void setJavaScriptCanAccessClipboard(bool);
+ virtual void setXSSAuditorEnabled(bool);
+ virtual void setLocalStorageEnabled(bool);
+ virtual void setEditableLinkBehaviorNeverLive();
+ virtual void setFrameFlatteningEnabled(bool);
+ virtual void setFontRenderingModeNormal();
+ virtual void setShouldPaintCustomScrollbars(bool);
+ virtual void setAllowUniversalAccessFromFileURLs(bool);
+ virtual void setAllowFileAccessFromFileURLs(bool);
+ virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
+ virtual void setOfflineWebApplicationCacheEnabled(bool);
+ virtual void setWebAudioEnabled(bool);
+ virtual void setExperimentalWebGLEnabled(bool);
+ virtual void setShowDebugBorders(bool);
+ virtual void setEditingBehavior(EditingBehavior);
+ virtual void setAcceleratedCompositingEnabled(bool);
+ virtual void setAcceleratedCompositingFor3DTransformsEnabled(bool);
+ virtual void setAcceleratedCompositingForVideoEnabled(bool);
+ virtual void setAcceleratedCompositingForPluginsEnabled(bool);
+ virtual void setAcceleratedCompositingForCanvasEnabled(bool);
+ virtual void setAcceleratedCompositingForAnimationEnabled(bool);
+ virtual void setAccelerated2dCanvasEnabled(bool);
+ virtual void setMemoryInfoEnabled(bool);
+ virtual void setHyperlinkAuditingEnabled(bool);
+ virtual void setCaretBrowsingEnabled(bool);
+ virtual void setInteractiveFormValidationEnabled(bool);
+
+private:
+ WebCore::Settings* m_settings;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp b/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp
new file mode 100644
index 0000000..e73c0f4
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSharedWorkerImpl.h"
+
+#include "CrossThreadTask.h"
+#include "KURL.h"
+#include "MessageEvent.h"
+#include "MessagePortChannel.h"
+#include "PlatformMessagePortChannel.h"
+#include "ScriptExecutionContext.h"
+#include "SharedWorkerContext.h"
+#include "SharedWorkerThread.h"
+
+#include "WebMessagePortChannel.h"
+#include "WebString.h"
+#include "WebURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if ENABLE(SHARED_WORKERS)
+
+WebSharedWorkerImpl::WebSharedWorkerImpl(WebCommonWorkerClient* client)
+ : m_client(client)
+{
+}
+
+WebSharedWorkerImpl::~WebSharedWorkerImpl()
+{
+}
+
+bool WebSharedWorkerImpl::isStarted()
+{
+ // Should not ever be called from the worker thread (this API is only called on WebSharedWorkerProxy on the renderer thread).
+ ASSERT_NOT_REACHED();
+ return workerThread();
+}
+
+void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel, ConnectListener* listener)
+{
+ // Convert the WebMessagePortChanel to a WebCore::MessagePortChannel.
+ RefPtr<PlatformMessagePortChannel> platform_channel =
+ PlatformMessagePortChannel::create(webChannel);
+ webChannel->setClient(platform_channel.get());
+ OwnPtr<MessagePortChannel> channel =
+ MessagePortChannel::create(platform_channel);
+
+ workerThread()->runLoop().postTask(
+ createCallbackTask(&connectTask, this, channel.release()));
+ if (listener)
+ listener->connected();
+}
+
+void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, WebSharedWorkerImpl* worker, PassOwnPtr<MessagePortChannel> channel)
+{
+ // Wrap the passed-in channel in a MessagePort, and send it off via a connect event.
+ RefPtr<MessagePort> port = MessagePort::create(*context);
+ port->entangle(channel);
+ ASSERT(context->isWorkerContext());
+ WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+ ASSERT(workerContext->isSharedWorkerContext());
+ workerContext->toSharedWorkerContext()->dispatchEvent(createConnectEvent(port));
+}
+
+void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, long long)
+{
+ initializeLoader(url);
+ setWorkerThread(SharedWorkerThread::create(name, url, userAgent, sourceCode, *this, *this));
+ workerThread()->start();
+}
+
+void WebSharedWorkerImpl::terminateWorkerContext()
+{
+ stopWorkerThread();
+}
+
+void WebSharedWorkerImpl::clientDestroyed()
+{
+ m_client = 0;
+}
+
+WebWorkerClient* WebSharedWorkerImpl::client()
+{
+ // We should never be asked for a WebWorkerClient (only dedicated workers have an associated WebWorkerClient).
+ // It should not be possible for SharedWorkerContext to generate an API call outside those supported by WebCommonWorkerClient.
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+WebSharedWorker* WebSharedWorker::create(WebCommonWorkerClient* client)
+{
+ return new WebSharedWorkerImpl(client);
+}
+
+#endif // ENABLE(SHARED_WORKERS)
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSharedWorkerImpl.h b/Source/WebKit/chromium/src/WebSharedWorkerImpl.h
new file mode 100644
index 0000000..b591c7b
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSharedWorkerImpl.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSharedWorkerImpl_h
+#define WebSharedWorkerImpl_h
+
+#include "WebSharedWorker.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "ScriptExecutionContext.h"
+
+#include "WebWorkerBase.h"
+
+namespace WebKit {
+
+// This class is used by the worker process code to talk to the WebCore::SharedWorker implementation.
+// It can't use it directly since it uses WebKit types, so this class converts the data types.
+// When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingProxy, this class will
+// convert to Chrome data types first and then call the supplied WebCommonWorkerClient.
+class WebSharedWorkerImpl : public WebWorkerBase, public WebSharedWorker {
+public:
+ explicit WebSharedWorkerImpl(WebCommonWorkerClient* client);
+
+ // WebSharedWorker methods:
+ virtual bool isStarted();
+ virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& userAgent, const WebString& sourceCode, long long);
+ virtual void connect(WebMessagePortChannel*, ConnectListener*);
+ virtual void terminateWorkerContext();
+ virtual void clientDestroyed();
+
+ // WebWorkerBase methods:
+ WebWorkerClient* client();
+ WebCommonWorkerClient* commonClient() { return m_client; }
+
+private:
+ virtual ~WebSharedWorkerImpl();
+
+ static void connectTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl*, PassOwnPtr<WebCore::MessagePortChannel>);
+
+ WebCommonWorkerClient* m_client;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(SHARED_WORKERS)
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
new file mode 100644
index 0000000..3beb785
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSpeechInputControllerMockImpl.h"
+
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+#include "SpeechInputClientMock.h"
+#include "WebRect.h"
+#include "WebSecurityOrigin.h"
+
+namespace WebKit {
+
+WebSpeechInputControllerMock* WebSpeechInputControllerMock::create(WebSpeechInputListener* listener)
+{
+ return new WebSpeechInputControllerMockImpl(listener);
+}
+
+WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl(
+ WebSpeechInputListener* listener)
+ : m_webcoreMock(new WebCore::SpeechInputClientMock())
+ , m_listener(listener)
+{
+ m_webcoreMock->setListener(this);
+}
+
+WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl()
+{
+ m_webcoreMock->setListener(0);
+}
+
+void WebSpeechInputControllerMockImpl::addMockRecognitionResult(const WebString& result, double confidence, const WebString &language)
+{
+ m_webcoreMock->addRecognitionResult(result, confidence, language);
+}
+
+void WebSpeechInputControllerMockImpl::clearResults()
+{
+ m_webcoreMock->clearResults();
+}
+
+void WebSpeechInputControllerMockImpl::didCompleteRecording(int requestId)
+{
+ m_listener->didCompleteRecording(requestId);
+}
+
+void WebSpeechInputControllerMockImpl::didCompleteRecognition(int requestId)
+{
+ m_listener->didCompleteRecognition(requestId);
+}
+
+void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result)
+{
+ m_listener->setRecognitionResult(requestId, result);
+}
+
+bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin)
+{
+ return m_webcoreMock->startRecognition(requestId, elementRect, language, grammar, origin.get());
+}
+
+void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId)
+{
+ m_webcoreMock->cancelRecognition(requestId);
+}
+
+void WebSpeechInputControllerMockImpl::stopRecording(int requestId)
+{
+ m_webcoreMock->stopRecording(requestId);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
new file mode 100644
index 0000000..4c8fee7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSpeechInputControllerMockImpl_h
+#define WebSpeechInputControllerMockImpl_h
+
+#include "SpeechInputListener.h"
+#include "WebSpeechInputControllerMock.h"
+#include "WebSpeechInputListener.h"
+#include "WebString.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+class SpeechInputClientMock;
+}
+
+namespace WebKit {
+
+struct WebRect;
+
+class WebSpeechInputControllerMockImpl : public WebCore::SpeechInputListener
+ , public WebSpeechInputControllerMock {
+public:
+ WebSpeechInputControllerMockImpl(WebSpeechInputListener*);
+ virtual ~WebSpeechInputControllerMockImpl();
+
+ // WebCore::SpeechInputListener methods.
+ void didCompleteRecording(int requestId);
+ void didCompleteRecognition(int requestId);
+ void setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result);
+
+ // WebSpeechInputController methods.
+ bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin&);
+ void cancelRecognition(int requestId);
+ void stopRecording(int requestId);
+
+ // WebSpeechInputControllerMock methods.
+ void addMockRecognitionResult(const WebString& result, double confidence, const WebString& language);
+ void clearResults();
+
+private:
+ OwnPtr<WebCore::SpeechInputClientMock> m_webcoreMock;
+ WebSpeechInputListener* m_listener;
+};
+
+} // namespace WebKit
+
+#endif // WebSpeechInputControllerMockImpl_h
diff --git a/Source/WebKit/chromium/src/WebSpeechInputResult.cpp b/Source/WebKit/chromium/src/WebSpeechInputResult.cpp
new file mode 100644
index 0000000..1cafc84
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebSpeechInputResult.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 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 AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSpeechInputResult.h"
+
+#include "SpeechInputResult.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+void WebSpeechInputResult::reset()
+{
+ m_private.reset();
+}
+
+WebSpeechInputResult::WebSpeechInputResult(const PassRefPtr<WebCore::SpeechInputResult>& value)
+ : m_private(value)
+{
+}
+
+void WebSpeechInputResult::set(const WebString& utterance, double confidence)
+{
+ m_private = WebCore::SpeechInputResult::create(utterance, confidence);
+}
+
+WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp b/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp
new file mode 100644
index 0000000..2cecfe9
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebStorageAreaImpl.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "ExceptionCode.h"
+
+#include "WebString.h"
+#include "WebURL.h"
+
+namespace WebKit {
+
+const WebURL* WebStorageAreaImpl::storageEventURL = 0;
+
+WebStorageAreaImpl::WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea)
+ : m_storageArea(storageArea)
+{
+}
+
+WebStorageAreaImpl::~WebStorageAreaImpl()
+{
+}
+
+unsigned WebStorageAreaImpl::length()
+{
+ return m_storageArea->length();
+}
+
+WebString WebStorageAreaImpl::key(unsigned index)
+{
+ return m_storageArea->key(index);
+}
+
+WebString WebStorageAreaImpl::getItem(const WebString& key)
+{
+ return m_storageArea->getItem(key);
+}
+
+void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, const WebURL& url, Result& result, WebString& oldValue, WebFrame*)
+{
+ int exceptionCode = 0;
+
+ ScopedStorageEventURL scope(url);
+ oldValue = m_storageArea->setItem(key, value, exceptionCode, 0);
+
+ if (exceptionCode) {
+ ASSERT(exceptionCode == WebCore::QUOTA_EXCEEDED_ERR);
+ result = ResultBlockedByQuota;
+ } else
+ result = ResultOK;
+}
+
+void WebStorageAreaImpl::removeItem(const WebString& key, const WebURL& url, WebString& oldValue)
+{
+ ScopedStorageEventURL scope(url);
+ oldValue = m_storageArea->removeItem(key, 0);
+}
+
+void WebStorageAreaImpl::clear(const WebURL& url, bool& somethingCleared)
+{
+ ScopedStorageEventURL scope(url);
+ somethingCleared = m_storageArea->clear(0);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/WebStorageAreaImpl.h b/Source/WebKit/chromium/src/WebStorageAreaImpl.h
new file mode 100644
index 0000000..2869fc9
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebStorageAreaImpl.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebStorageAreaImpl_h
+#define WebStorageAreaImpl_h
+
+#if ENABLE(DOM_STORAGE)
+
+#include "StorageAreaImpl.h"
+#include "WebStorageArea.h"
+
+namespace WebKit {
+
+class WebStorageAreaImpl : public WebStorageArea {
+public:
+ WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea);
+ virtual ~WebStorageAreaImpl();
+ virtual unsigned length();
+ virtual WebString key(unsigned index);
+ virtual WebString getItem(const WebString& key);
+ virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, Result& result, WebString& oldValue, WebFrame*);
+ virtual void removeItem(const WebString& key, const WebURL& url, WebString& oldValue);
+ virtual void clear(const WebURL& url, bool& somethingCleared);
+
+ // For storage events in single-process mode and test shell.
+ static const WebURL* currentStorageEventURL() { return storageEventURL; }
+
+private:
+ class ScopedStorageEventURL {
+ public:
+ ScopedStorageEventURL(const WebURL& url)
+ {
+ // FIXME: Once storage events are fired async in WebKit (as they should
+ // be) this can be ASSERTed to be 0 rather than saved.
+ m_existingStorageEventURL = storageEventURL;
+ storageEventURL = &url;
+ }
+ ~ScopedStorageEventURL()
+ {
+ storageEventURL = m_existingStorageEventURL;
+ }
+
+ private:
+ const WebURL* m_existingStorageEventURL;
+ };
+
+ static const WebURL* storageEventURL;
+
+ RefPtr<WebCore::StorageArea> m_storageArea;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DOM_STORAGE)
+
+#endif // WebStorageAreaImpl_h
diff --git a/Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp b/Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp
new file mode 100644
index 0000000..515a423
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebStorageEventDispatcherImpl.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "KURL.h"
+#include "SecurityOrigin.h"
+
+#include "WebStorageAreaImpl.h"
+#include "WebURL.h"
+
+namespace WebKit {
+
+extern const char* pageGroupName;
+
+WebStorageEventDispatcher* WebStorageEventDispatcher::create()
+{
+ return new WebStorageEventDispatcherImpl();
+}
+
+WebStorageEventDispatcherImpl::WebStorageEventDispatcherImpl()
+ : m_eventDispatcher(new WebCore::StorageEventDispatcherImpl(pageGroupName))
+{
+ ASSERT(m_eventDispatcher);
+}
+
+void WebStorageEventDispatcherImpl::dispatchStorageEvent(const WebString& key, const WebString& oldValue,
+ const WebString& newValue, const WebString& origin,
+ const WebURL& passedInURL, bool isLocalStorage)
+{
+ // Hack for single-process mode and test shell.
+ const WebURL* storageAreaImplURL = WebStorageAreaImpl::currentStorageEventURL();
+ const WebURL& url = storageAreaImplURL ? *storageAreaImplURL : passedInURL;
+
+ WebCore::StorageType storageType = isLocalStorage ? WebCore::LocalStorage : WebCore::SessionStorage;
+ RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(origin);
+ m_eventDispatcher->dispatchStorageEvent(key, oldValue, newValue, securityOrigin.get(), url, storageType);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.h b/Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.h
new file mode 100644
index 0000000..6848b99
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebStorageEventDispatcherImpl.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebStorageEventDispatcherImpl_h
+#define WebStorageEventDispatcherImpl_h
+
+#if ENABLE(DOM_STORAGE)
+
+#include "StorageEventDispatcherImpl.h"
+#include "WebStorageEventDispatcher.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebKit {
+
+class WebStorageEventDispatcherImpl : public WebStorageEventDispatcher {
+public:
+ WebStorageEventDispatcherImpl();
+
+ virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue,
+ const WebString& newValue, const WebString& origin,
+ const WebURL&, bool isLocalStorage);
+
+private:
+ OwnPtr<WebCore::StorageEventDispatcherImpl> m_eventDispatcher;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DOM_STORAGE)
+
+#endif // WebStorageEventDispatcherImpl_h
diff --git a/Source/WebKit/chromium/src/WebStorageNamespaceImpl.cpp b/Source/WebKit/chromium/src/WebStorageNamespaceImpl.cpp
new file mode 100644
index 0000000..53b4a75
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebStorageNamespaceImpl.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebStorageNamespaceImpl.h"
+
+#if ENABLE(DOM_STORAGE)
+
+#include "SecurityOrigin.h"
+
+#include "WebStorageAreaImpl.h"
+#include "WebString.h"
+
+namespace WebKit {
+
+WebStorageNamespace* WebStorageNamespace::createLocalStorageNamespace(const WebString& path, unsigned quota)
+{
+ return new WebStorageNamespaceImpl(WebCore::StorageNamespaceImpl::localStorageNamespace(path, quota));
+}
+
+WebStorageNamespace* WebStorageNamespace::createSessionStorageNamespace(unsigned quota)
+{
+ return new WebStorageNamespaceImpl(WebCore::StorageNamespaceImpl::sessionStorageNamespace(quota));
+}
+
+WebStorageNamespaceImpl::WebStorageNamespaceImpl(PassRefPtr<WebCore::StorageNamespace> storageNamespace)
+ : m_storageNamespace(storageNamespace)
+{
+}
+
+WebStorageNamespaceImpl::~WebStorageNamespaceImpl()
+{
+}
+
+WebStorageArea* WebStorageNamespaceImpl::createStorageArea(const WebString& originString)
+{
+ WTF::String originWebCoreString = originString;
+ if (originWebCoreString == "file://") {
+ // FIXME: We should really be passing around WebSecurityOrigin objects
+ // to represent security origins instead of strings. One issue
+ // with using strings is that createFromString(toString) does
+ // not round-trip for file URLs because file:// looks like a
+ // directory (which is sandboxed).
+ //
+ // For the time being, we work around this issue by using "file:///a",
+ // which does not look like a directory. We should fix this when
+ // jorlow gets back from vactation.
+ originWebCoreString = "file:///a";
+ }
+ RefPtr<WebCore::SecurityOrigin> origin = WebCore::SecurityOrigin::createFromString(originWebCoreString);
+ return new WebStorageAreaImpl(m_storageNamespace->storageArea(origin.release()));
+}
+
+WebStorageNamespace* WebStorageNamespaceImpl::copy()
+{
+ return new WebStorageNamespaceImpl(m_storageNamespace->copy());
+}
+
+void WebStorageNamespaceImpl::close()
+{
+ m_storageNamespace->close();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DOM_STORAGE)
diff --git a/Source/WebKit/chromium/src/WebStorageNamespaceImpl.h b/Source/WebKit/chromium/src/WebStorageNamespaceImpl.h
new file mode 100644
index 0000000..4e82c21
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebStorageNamespaceImpl.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebStorageNamespaceImpl_h
+#define WebStorageNamespaceImpl_h
+
+#if ENABLE(DOM_STORAGE)
+
+#include "StorageNamespaceImpl.h"
+#include "WebStorageNamespace.h"
+
+namespace WebKit {
+
+class WebStorageNamespaceImpl : public WebStorageNamespace {
+public:
+ WebStorageNamespaceImpl(PassRefPtr<WebCore::StorageNamespace> storageNamespace);
+ virtual ~WebStorageNamespaceImpl();
+ virtual WebStorageArea* createStorageArea(const WebString& origin);
+ virtual WebStorageNamespace* copy();
+ virtual void close();
+
+private:
+ RefPtr<WebCore::StorageNamespace> m_storageNamespace;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DOM_STORAGE)
+
+#endif // WebStorageNamespaceImpl_h
diff --git a/Source/WebKit/chromium/src/WebString.cpp b/Source/WebKit/chromium/src/WebString.cpp
new file mode 100644
index 0000000..a091ef4
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebString.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebString.h"
+
+#include "PlatformString.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/AtomicString.h>
+
+#include "WebCString.h"
+
+namespace WebKit {
+
+class WebStringPrivate : public WTF::StringImpl {
+};
+
+void WebString::reset()
+{
+ if (m_private) {
+ m_private->deref();
+ m_private = 0;
+ }
+}
+
+void WebString::assign(const WebString& other)
+{
+ assign(const_cast<WebStringPrivate*>(other.m_private));
+}
+
+void WebString::assign(const WebUChar* data, size_t length)
+{
+ assign(static_cast<WebStringPrivate*>(
+ WTF::StringImpl::create(data, length).get()));
+}
+
+size_t WebString::length() const
+{
+ return m_private ? const_cast<WebStringPrivate*>(m_private)->length() : 0;
+}
+
+const WebUChar* WebString::data() const
+{
+ return m_private ? const_cast<WebStringPrivate*>(m_private)->characters() : 0;
+}
+
+WebCString WebString::utf8() const
+{
+ return WTF::String(m_private).utf8();
+}
+
+WebString WebString::fromUTF8(const char* data, size_t length)
+{
+ return WTF::String::fromUTF8(data, length);
+}
+
+WebString WebString::fromUTF8(const char* data)
+{
+ return WTF::String::fromUTF8(data);
+}
+
+bool WebString::equals(const WebString& s) const
+{
+ return equal(m_private, s.m_private);
+}
+
+WebString::WebString(const WTF::String& s)
+ : m_private(static_cast<WebStringPrivate*>(s.impl()))
+{
+ if (m_private)
+ m_private->ref();
+}
+
+WebString& WebString::operator=(const WTF::String& s)
+{
+ assign(static_cast<WebStringPrivate*>(s.impl()));
+ return *this;
+}
+
+WebString::operator WTF::String() const
+{
+ return m_private;
+}
+
+WebString::WebString(const WTF::AtomicString& s)
+ : m_private(0)
+{
+ assign(s.string());
+}
+
+WebString& WebString::operator=(const WTF::AtomicString& s)
+{
+ assign(s.string());
+ return *this;
+}
+
+WebString::operator WTF::AtomicString() const
+{
+ return WTF::AtomicString(static_cast<WTF::StringImpl *>(m_private));
+}
+
+void WebString::assign(WebStringPrivate* p)
+{
+ // Take care to handle the case where m_private == p
+ if (p)
+ p->ref();
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebTextRun.cpp b/Source/WebKit/chromium/src/WebTextRun.cpp
new file mode 100644
index 0000000..58d9fac
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebTextRun.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebTextRun.h"
+
+#include "TextRun.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebTextRun::operator WebCore::TextRun() const
+{
+ return TextRun(text, false, 0, 0, rtl, directionalOverride);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebThreadSafeData.cpp b/Source/WebKit/chromium/src/WebThreadSafeData.cpp
new file mode 100755
index 0000000..facaba3
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebThreadSafeData.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebThreadSafeData.h"
+
+#include "BlobData.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebThreadSafeData::reset()
+{
+ m_private.reset();
+}
+
+void WebThreadSafeData::assign(const WebThreadSafeData& other)
+{
+ m_private = other.m_private;
+}
+
+size_t WebThreadSafeData::size() const
+{
+ if (m_private.isNull())
+ return 0;
+ return m_private->length();
+}
+
+const char* WebThreadSafeData::data() const
+{
+ if (m_private.isNull())
+ return 0;
+ return m_private->data();
+}
+
+WebThreadSafeData::WebThreadSafeData(const PassRefPtr<RawData>& data)
+ : m_private(data.releaseRef())
+{
+}
+
+WebThreadSafeData& WebThreadSafeData::operator=(const PassRefPtr<RawData>& data)
+{
+ m_private = data;
+ return *this;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebURL.cpp b/Source/WebKit/chromium/src/WebURL.cpp
new file mode 100644
index 0000000..feb92c1
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURL.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebURL.h"
+
+#include "KURL.h"
+
+namespace WebKit {
+
+WebURL::WebURL(const WebCore::KURL& url)
+ : m_spec(url.utf8String())
+ , m_parsed(url.parsed())
+ , m_isValid(url.isValid())
+{
+}
+
+WebURL& WebURL::operator=(const WebCore::KURL& url)
+{
+ m_spec = url.utf8String();
+ m_parsed = url.parsed();
+ m_isValid = url.isValid();
+ return *this;
+}
+
+WebURL::operator WebCore::KURL() const
+{
+ return WebCore::KURL(m_spec, m_parsed, m_isValid);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebURLError.cpp b/Source/WebKit/chromium/src/WebURLError.cpp
new file mode 100644
index 0000000..ef32b5c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURLError.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebURLError.h"
+
+#include "KURL.h"
+#include "ResourceError.h"
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebURLError::WebURLError(const ResourceError& error)
+{
+ *this = error;
+}
+
+WebURLError& WebURLError::operator=(const ResourceError& error)
+{
+ if (error.isNull())
+ *this = WebURLError();
+ else {
+ domain = error.domain();
+ reason = error.errorCode();
+ unreachableURL = KURL(ParsedURLString, error.failingURL());
+ }
+ return *this;
+}
+
+WebURLError::operator ResourceError() const
+{
+ if (!reason)
+ return ResourceError();
+ CString spec = unreachableURL.spec();
+ return ResourceError(domain, reason,
+ String::fromUTF8(spec.data(), spec.length()),
+ String());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebURLLoadTiming.cpp b/Source/WebKit/chromium/src/WebURLLoadTiming.cpp
new file mode 100644
index 0000000..27ed362
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURLLoadTiming.cpp
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebURLLoadTiming.h"
+
+#include "ResourceLoadTiming.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebURLLoadTiming::initialize()
+{
+ m_private = ResourceLoadTiming::create();
+}
+
+void WebURLLoadTiming::reset()
+{
+ m_private.reset();
+}
+
+void WebURLLoadTiming::assign(const WebURLLoadTiming& other)
+{
+ m_private = other.m_private;
+}
+
+double WebURLLoadTiming::requestTime() const
+{
+ return m_private->requestTime;
+}
+
+void WebURLLoadTiming::setRequestTime(double time)
+{
+ m_private->requestTime = time;
+}
+
+int WebURLLoadTiming::proxyStart() const
+{
+ return m_private->proxyStart;
+}
+
+void WebURLLoadTiming::setProxyStart(int start)
+{
+ m_private->proxyStart = start;
+}
+
+int WebURLLoadTiming::proxyEnd() const
+{
+ return m_private->proxyEnd;
+}
+
+void WebURLLoadTiming::setProxyEnd(int end)
+{
+ m_private->proxyEnd = end;
+}
+
+int WebURLLoadTiming::dnsStart() const
+{
+ return m_private->dnsStart;
+}
+
+void WebURLLoadTiming::setDNSStart(int start)
+{
+ m_private->dnsStart = start;
+}
+
+int WebURLLoadTiming::dnsEnd() const
+{
+ return m_private->dnsEnd;
+}
+
+void WebURLLoadTiming::setDNSEnd(int end)
+{
+ m_private->dnsEnd = end;
+}
+
+int WebURLLoadTiming::connectStart() const
+{
+ return m_private->connectStart;
+}
+
+void WebURLLoadTiming::setConnectStart(int start)
+{
+ m_private->connectStart = start;
+}
+
+int WebURLLoadTiming::connectEnd() const
+{
+ return m_private->connectEnd;
+}
+
+void WebURLLoadTiming::setConnectEnd(int end)
+{
+ m_private->connectEnd = end;
+}
+
+int WebURLLoadTiming::sendStart() const
+{
+ return m_private->sendStart;
+}
+
+void WebURLLoadTiming::setSendStart(int start)
+{
+ m_private->sendStart = start;
+}
+
+int WebURLLoadTiming::sendEnd() const
+{
+ return m_private->sendEnd;
+}
+
+void WebURLLoadTiming::setSendEnd(int end)
+{
+ m_private->sendEnd = end;
+}
+
+int WebURLLoadTiming::receiveHeadersEnd() const
+{
+ return m_private->receiveHeadersEnd;
+}
+
+void WebURLLoadTiming::setReceiveHeadersEnd(int end)
+{
+ m_private->receiveHeadersEnd = end;
+}
+
+int WebURLLoadTiming::sslStart() const
+{
+ return m_private->sslStart;
+}
+
+void WebURLLoadTiming::setSSLStart(int start)
+{
+ m_private->sslStart = start;
+}
+
+int WebURLLoadTiming::sslEnd() const
+{
+ return m_private->sslEnd;
+}
+
+void WebURLLoadTiming::setSSLEnd(int end)
+{
+ m_private->sslEnd = end;
+}
+
+WebURLLoadTiming::WebURLLoadTiming(const PassRefPtr<ResourceLoadTiming>& value)
+ : m_private(value)
+{
+}
+
+WebURLLoadTiming& WebURLLoadTiming::operator=(const PassRefPtr<ResourceLoadTiming>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebURLLoadTiming::operator PassRefPtr<ResourceLoadTiming>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebURLRequest.cpp b/Source/WebKit/chromium/src/WebURLRequest.cpp
new file mode 100644
index 0000000..7a77ca3
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURLRequest.cpp
@@ -0,0 +1,307 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebURLRequest.h"
+
+#include "ResourceRequest.h"
+
+#include "WebHTTPBody.h"
+#include "WebHTTPHeaderVisitor.h"
+#include "WebURL.h"
+#include "WebURLRequestPrivate.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// The standard implementation of WebURLRequestPrivate, which maintains
+// ownership of a ResourceRequest instance.
+class WebURLRequestPrivateImpl : public WebURLRequestPrivate {
+public:
+ WebURLRequestPrivateImpl()
+ {
+ m_resourceRequest = &m_resourceRequestAllocation;
+ }
+
+ WebURLRequestPrivateImpl(const WebURLRequestPrivate* p)
+ : m_resourceRequestAllocation(*p->m_resourceRequest)
+ {
+ m_resourceRequest = &m_resourceRequestAllocation;
+ m_allowStoredCredentials = p->m_allowStoredCredentials;
+ m_downloadToFile = p->m_downloadToFile;
+ }
+
+ virtual void dispose() { delete this; }
+
+ ResourceRequest m_resourceRequestAllocation;
+};
+
+void WebURLRequest::initialize()
+{
+ assign(new WebURLRequestPrivateImpl());
+}
+
+void WebURLRequest::reset()
+{
+ assign(0);
+}
+
+void WebURLRequest::assign(const WebURLRequest& r)
+{
+ if (&r != this)
+ assign(r.m_private ? new WebURLRequestPrivateImpl(r.m_private) : 0);
+}
+
+bool WebURLRequest::isNull() const
+{
+ return !m_private || m_private->m_resourceRequest->isNull();
+}
+
+WebURL WebURLRequest::url() const
+{
+ return m_private->m_resourceRequest->url();
+}
+
+void WebURLRequest::setURL(const WebURL& url)
+{
+ m_private->m_resourceRequest->setURL(url);
+}
+
+WebURL WebURLRequest::firstPartyForCookies() const
+{
+ return m_private->m_resourceRequest->firstPartyForCookies();
+}
+
+void WebURLRequest::setFirstPartyForCookies(const WebURL& firstPartyForCookies)
+{
+ m_private->m_resourceRequest->setFirstPartyForCookies(firstPartyForCookies);
+}
+
+bool WebURLRequest::allowCookies() const
+{
+ return m_private->m_resourceRequest->allowCookies();
+}
+
+void WebURLRequest::setAllowCookies(bool allowCookies)
+{
+ m_private->m_resourceRequest->setAllowCookies(allowCookies);
+}
+
+bool WebURLRequest::allowStoredCredentials() const
+{
+ return m_private->m_allowStoredCredentials;
+}
+
+void WebURLRequest::setAllowStoredCredentials(bool allowStoredCredentials)
+{
+ m_private->m_allowStoredCredentials = allowStoredCredentials;
+}
+
+WebURLRequest::CachePolicy WebURLRequest::cachePolicy() const
+{
+ return static_cast<WebURLRequest::CachePolicy>(
+ m_private->m_resourceRequest->cachePolicy());
+}
+
+void WebURLRequest::setCachePolicy(CachePolicy cachePolicy)
+{
+ m_private->m_resourceRequest->setCachePolicy(
+ static_cast<ResourceRequestCachePolicy>(cachePolicy));
+}
+
+WebString WebURLRequest::httpMethod() const
+{
+ return m_private->m_resourceRequest->httpMethod();
+}
+
+void WebURLRequest::setHTTPMethod(const WebString& httpMethod)
+{
+ m_private->m_resourceRequest->setHTTPMethod(httpMethod);
+}
+
+WebString WebURLRequest::httpHeaderField(const WebString& name) const
+{
+ return m_private->m_resourceRequest->httpHeaderField(name);
+}
+
+void WebURLRequest::setHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceRequest->setHTTPHeaderField(name, value);
+}
+
+void WebURLRequest::addHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceRequest->addHTTPHeaderField(name, value);
+}
+
+void WebURLRequest::clearHTTPHeaderField(const WebString& name)
+{
+ // FIXME: Add a clearHTTPHeaderField method to ResourceRequest.
+ const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields();
+ const_cast<HTTPHeaderMap*>(&map)->remove(name);
+}
+
+void WebURLRequest::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const
+{
+ const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields();
+ for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ visitor->visitHeader(it->first, it->second);
+}
+
+WebHTTPBody WebURLRequest::httpBody() const
+{
+ return WebHTTPBody(m_private->m_resourceRequest->httpBody());
+}
+
+void WebURLRequest::setHTTPBody(const WebHTTPBody& httpBody)
+{
+ m_private->m_resourceRequest->setHTTPBody(httpBody);
+}
+
+bool WebURLRequest::reportUploadProgress() const
+{
+ return m_private->m_resourceRequest->reportUploadProgress();
+}
+
+void WebURLRequest::setReportUploadProgress(bool reportUploadProgress)
+{
+ m_private->m_resourceRequest->setReportUploadProgress(reportUploadProgress);
+}
+
+bool WebURLRequest::reportLoadTiming() const
+{
+ return m_private->m_resourceRequest->reportLoadTiming();
+}
+
+void WebURLRequest::setReportRawHeaders(bool reportRawHeaders)
+{
+ m_private->m_resourceRequest->setReportRawHeaders(reportRawHeaders);
+}
+
+bool WebURLRequest::reportRawHeaders() const
+{
+ return m_private->m_resourceRequest->reportRawHeaders();
+}
+
+void WebURLRequest::setReportLoadTiming(bool reportLoadTiming)
+{
+ m_private->m_resourceRequest->setReportLoadTiming(reportLoadTiming);
+}
+
+WebURLRequest::TargetType WebURLRequest::targetType() const
+{
+ return static_cast<TargetType>(m_private->m_resourceRequest->targetType());
+}
+
+bool WebURLRequest::hasUserGesture() const
+{
+ return m_private->m_resourceRequest->hasUserGesture();
+}
+
+void WebURLRequest::setHasUserGesture(bool hasUserGesture)
+{
+ m_private->m_resourceRequest->setHasUserGesture(hasUserGesture);
+}
+
+void WebURLRequest::setTargetType(TargetType targetType)
+{
+ m_private->m_resourceRequest->setTargetType(
+ static_cast<ResourceRequest::TargetType>(targetType));
+}
+
+int WebURLRequest::requestorID() const
+{
+ return m_private->m_resourceRequest->requestorID();
+}
+
+void WebURLRequest::setRequestorID(int requestorID)
+{
+ m_private->m_resourceRequest->setRequestorID(requestorID);
+}
+
+int WebURLRequest::requestorProcessID() const
+{
+ return m_private->m_resourceRequest->requestorProcessID();
+}
+
+void WebURLRequest::setRequestorProcessID(int requestorProcessID)
+{
+ m_private->m_resourceRequest->setRequestorProcessID(requestorProcessID);
+}
+
+int WebURLRequest::appCacheHostID() const
+{
+ return m_private->m_resourceRequest->appCacheHostID();
+}
+
+void WebURLRequest::setAppCacheHostID(int appCacheHostID)
+{
+ m_private->m_resourceRequest->setAppCacheHostID(appCacheHostID);
+}
+
+bool WebURLRequest::downloadToFile() const
+{
+ return m_private->m_downloadToFile;
+}
+
+void WebURLRequest::setDownloadToFile(bool downloadToFile)
+{
+ m_private->m_downloadToFile = downloadToFile;
+}
+
+ResourceRequest& WebURLRequest::toMutableResourceRequest()
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceRequest);
+
+ return *m_private->m_resourceRequest;
+}
+
+const ResourceRequest& WebURLRequest::toResourceRequest() const
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceRequest);
+
+ return *m_private->m_resourceRequest;
+}
+
+void WebURLRequest::assign(WebURLRequestPrivate* p)
+{
+ // Subclasses may call this directly so a self-assignment check is needed
+ // here as well as in the public assign method.
+ if (m_private == p)
+ return;
+ if (m_private)
+ m_private->dispose();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebURLRequestPrivate.h b/Source/WebKit/chromium/src/WebURLRequestPrivate.h
new file mode 100644
index 0000000..79f6451
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURLRequestPrivate.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebURLRequestPrivate_h
+#define WebURLRequestPrivate_h
+
+namespace WebCore { class ResourceRequest; }
+
+namespace WebKit {
+
+class WebURLRequestPrivate {
+public:
+ WebURLRequestPrivate()
+ : m_resourceRequest(0)
+ , m_allowStoredCredentials(true)
+ , m_downloadToFile(false) { }
+
+ // Called by WebURLRequest when it no longer needs this object.
+ virtual void dispose() = 0;
+
+ WebCore::ResourceRequest* m_resourceRequest;
+ bool m_allowStoredCredentials;
+
+ // FIXME: Move this to ResourceRequest once we have an internal consumer.
+ bool m_downloadToFile;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebURLResponse.cpp b/Source/WebKit/chromium/src/WebURLResponse.cpp
new file mode 100644
index 0000000..bf3c521
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURLResponse.cpp
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebURLResponse.h"
+
+#include "ResourceResponse.h"
+#include "ResourceLoadTiming.h"
+
+#include "WebHTTPHeaderVisitor.h"
+#include "WebHTTPLoadInfo.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLLoadTiming.h"
+#include "WebURLResponsePrivate.h"
+
+#include <wtf/RefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// The standard implementation of WebURLResponsePrivate, which maintains
+// ownership of a ResourceResponse instance.
+class WebURLResponsePrivateImpl : public WebURLResponsePrivate {
+public:
+ WebURLResponsePrivateImpl()
+ {
+ m_resourceResponse = &m_resourceResponseAllocation;
+ }
+
+ WebURLResponsePrivateImpl(const WebURLResponsePrivate* p)
+ : m_resourceResponseAllocation(*p->m_resourceResponse)
+ {
+ m_resourceResponse = &m_resourceResponseAllocation;
+ m_downloadFilePath = p->m_downloadFilePath;
+ }
+
+ virtual void dispose() { delete this; }
+
+ ResourceResponse m_resourceResponseAllocation;
+};
+
+void WebURLResponse::initialize()
+{
+ assign(new WebURLResponsePrivateImpl());
+}
+
+void WebURLResponse::reset()
+{
+ assign(0);
+}
+
+void WebURLResponse::assign(const WebURLResponse& r)
+{
+ if (&r != this)
+ assign(r.m_private ? new WebURLResponsePrivateImpl(r.m_private) : 0);
+}
+
+bool WebURLResponse::isNull() const
+{
+ return !m_private || m_private->m_resourceResponse->isNull();
+}
+
+WebURL WebURLResponse::url() const
+{
+ return m_private->m_resourceResponse->url();
+}
+
+void WebURLResponse::setURL(const WebURL& url)
+{
+ m_private->m_resourceResponse->setURL(url);
+}
+
+unsigned WebURLResponse::connectionID() const
+{
+ return m_private->m_resourceResponse->connectionID();
+}
+
+void WebURLResponse::setConnectionID(unsigned connectionID)
+{
+ m_private->m_resourceResponse->setConnectionID(connectionID);
+}
+
+bool WebURLResponse::connectionReused() const
+{
+ return m_private->m_resourceResponse->connectionReused();
+}
+
+void WebURLResponse::setConnectionReused(bool connectionReused)
+{
+ m_private->m_resourceResponse->setConnectionReused(connectionReused);
+}
+
+WebURLLoadTiming WebURLResponse::loadTiming()
+{
+ return WebURLLoadTiming(m_private->m_resourceResponse->resourceLoadTiming());
+}
+
+void WebURLResponse::setLoadTiming(const WebURLLoadTiming& timing)
+{
+ RefPtr<ResourceLoadTiming> loadTiming = PassRefPtr<ResourceLoadTiming>(timing);
+ m_private->m_resourceResponse->setResourceLoadTiming(loadTiming.release());
+}
+
+WebHTTPLoadInfo WebURLResponse::httpLoadInfo()
+{
+ return WebHTTPLoadInfo(m_private->m_resourceResponse->resourceLoadInfo());
+}
+
+void WebURLResponse::setHTTPLoadInfo(const WebHTTPLoadInfo& value)
+{
+ m_private->m_resourceResponse->setResourceLoadInfo(value);
+}
+
+double WebURLResponse::responseTime() const
+{
+ return m_private->m_resourceResponse->responseTime();
+}
+
+void WebURLResponse::setResponseTime(double responseTime)
+{
+ m_private->m_resourceResponse->setResponseTime(responseTime);
+}
+
+WebString WebURLResponse::mimeType() const
+{
+ return m_private->m_resourceResponse->mimeType();
+}
+
+void WebURLResponse::setMIMEType(const WebString& mimeType)
+{
+ m_private->m_resourceResponse->setMimeType(mimeType);
+}
+
+long long WebURLResponse::expectedContentLength() const
+{
+ return m_private->m_resourceResponse->expectedContentLength();
+}
+
+void WebURLResponse::setExpectedContentLength(long long expectedContentLength)
+{
+ m_private->m_resourceResponse->setExpectedContentLength(expectedContentLength);
+}
+
+WebString WebURLResponse::textEncodingName() const
+{
+ return m_private->m_resourceResponse->textEncodingName();
+}
+
+void WebURLResponse::setTextEncodingName(const WebString& textEncodingName)
+{
+ m_private->m_resourceResponse->setTextEncodingName(textEncodingName);
+}
+
+WebString WebURLResponse::suggestedFileName() const
+{
+ return m_private->m_resourceResponse->suggestedFilename();
+}
+
+void WebURLResponse::setSuggestedFileName(const WebString& suggestedFileName)
+{
+ m_private->m_resourceResponse->setSuggestedFilename(suggestedFileName);
+}
+
+int WebURLResponse::httpStatusCode() const
+{
+ return m_private->m_resourceResponse->httpStatusCode();
+}
+
+void WebURLResponse::setHTTPStatusCode(int httpStatusCode)
+{
+ m_private->m_resourceResponse->setHTTPStatusCode(httpStatusCode);
+}
+
+WebString WebURLResponse::httpStatusText() const
+{
+ return m_private->m_resourceResponse->httpStatusText();
+}
+
+void WebURLResponse::setHTTPStatusText(const WebString& httpStatusText)
+{
+ m_private->m_resourceResponse->setHTTPStatusText(httpStatusText);
+}
+
+WebString WebURLResponse::httpHeaderField(const WebString& name) const
+{
+ return m_private->m_resourceResponse->httpHeaderField(name);
+}
+
+void WebURLResponse::setHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceResponse->setHTTPHeaderField(name, value);
+}
+
+void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ if (name.isNull() || value.isNull())
+ return;
+ // FIXME: Add an addHTTPHeaderField method to ResourceResponse.
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ String valueStr(value);
+ pair<HTTPHeaderMap::iterator, bool> result =
+ const_cast<HTTPHeaderMap*>(&map)->add(name, valueStr);
+ if (!result.second)
+ result.first->second += ", " + valueStr;
+}
+
+void WebURLResponse::clearHTTPHeaderField(const WebString& name)
+{
+ // FIXME: Add a clearHTTPHeaderField method to ResourceResponse.
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ const_cast<HTTPHeaderMap*>(&map)->remove(name);
+}
+
+void WebURLResponse::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const
+{
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ visitor->visitHeader(it->first, it->second);
+}
+
+double WebURLResponse::lastModifiedDate() const
+{
+ return static_cast<double>(m_private->m_resourceResponse->lastModifiedDate());
+}
+
+void WebURLResponse::setLastModifiedDate(double lastModifiedDate)
+{
+ m_private->m_resourceResponse->setLastModifiedDate(static_cast<time_t>(lastModifiedDate));
+}
+
+bool WebURLResponse::isContentFiltered() const
+{
+ return m_private->m_resourceResponse->isContentFiltered();
+}
+
+void WebURLResponse::setIsContentFiltered(bool isContentFiltered)
+{
+ m_private->m_resourceResponse->setIsContentFiltered(isContentFiltered);
+}
+
+long long WebURLResponse::appCacheID() const
+{
+ return m_private->m_resourceResponse->appCacheID();
+}
+
+void WebURLResponse::setAppCacheID(long long appCacheID)
+{
+ m_private->m_resourceResponse->setAppCacheID(appCacheID);
+}
+
+WebURL WebURLResponse::appCacheManifestURL() const
+{
+ return m_private->m_resourceResponse->appCacheManifestURL();
+}
+
+void WebURLResponse::setAppCacheManifestURL(const WebURL& url)
+{
+ m_private->m_resourceResponse->setAppCacheManifestURL(url);
+}
+
+WebCString WebURLResponse::securityInfo() const
+{
+ // FIXME: getSecurityInfo is misnamed.
+ return m_private->m_resourceResponse->getSecurityInfo();
+}
+
+void WebURLResponse::setSecurityInfo(const WebCString& securityInfo)
+{
+ m_private->m_resourceResponse->setSecurityInfo(securityInfo);
+}
+
+ResourceResponse& WebURLResponse::toMutableResourceResponse()
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceResponse);
+
+ return *m_private->m_resourceResponse;
+}
+
+const ResourceResponse& WebURLResponse::toResourceResponse() const
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceResponse);
+
+ return *m_private->m_resourceResponse;
+}
+
+bool WebURLResponse::wasCached() const
+{
+ return m_private->m_resourceResponse->wasCached();
+}
+
+void WebURLResponse::setWasCached(bool value)
+{
+ m_private->m_resourceResponse->setWasCached(value);
+}
+
+bool WebURLResponse::wasFetchedViaSPDY() const
+{
+ return m_private->m_resourceResponse->wasFetchedViaSPDY();
+}
+
+void WebURLResponse::setWasFetchedViaSPDY(bool value)
+{
+ m_private->m_resourceResponse->setWasFetchedViaSPDY(value);
+}
+
+bool WebURLResponse::wasNpnNegotiated() const
+{
+ return m_private->m_resourceResponse->wasNpnNegotiated();
+}
+
+void WebURLResponse::setWasNpnNegotiated(bool value)
+{
+ m_private->m_resourceResponse->setWasNpnNegotiated(value);
+}
+
+bool WebURLResponse::wasAlternateProtocolAvailable() const
+{
+ return m_private->m_resourceResponse->wasAlternateProtocolAvailable();
+}
+
+void WebURLResponse::setWasAlternateProtocolAvailable(bool value)
+{
+ m_private->m_resourceResponse->setWasAlternateProtocolAvailable(value);
+}
+
+bool WebURLResponse::wasFetchedViaProxy() const
+{
+ return m_private->m_resourceResponse->wasFetchedViaProxy();
+}
+
+void WebURLResponse::setWasFetchedViaProxy(bool value)
+{
+ m_private->m_resourceResponse->setWasFetchedViaProxy(value);
+}
+
+bool WebURLResponse::isMultipartPayload() const
+{
+ return m_private->m_resourceResponse->isMultipartPayload();
+}
+
+void WebURLResponse::setIsMultipartPayload(bool value)
+{
+ m_private->m_resourceResponse->setIsMultipartPayload(value);
+}
+
+WebString WebURLResponse::downloadFilePath() const
+{
+ return m_private->m_downloadFilePath;
+}
+
+void WebURLResponse::setDownloadFilePath(const WebString& downloadFilePath)
+{
+ m_private->m_downloadFilePath = downloadFilePath;
+}
+
+void WebURLResponse::assign(WebURLResponsePrivate* p)
+{
+ // Subclasses may call this directly so a self-assignment check is needed
+ // here as well as in the public assign method.
+ if (m_private == p)
+ return;
+ if (m_private)
+ m_private->dispose();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebURLResponsePrivate.h b/Source/WebKit/chromium/src/WebURLResponsePrivate.h
new file mode 100644
index 0000000..dc5ce22
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebURLResponsePrivate.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebURLResponsePrivate_h
+#define WebURLResponsePrivate_h
+
+#include "WebString.h"
+
+namespace WebCore { class ResourceResponse; }
+
+namespace WebKit {
+
+class WebURLResponsePrivate {
+public:
+ WebURLResponsePrivate() : m_resourceResponse(0) { }
+
+ // Called by WebURLResponse when it no longer needs this object.
+ virtual void dispose() = 0;
+
+ WebCore::ResourceResponse* m_resourceResponse;
+
+ // FIXME: Move this to ResourceResponse once we have an internal consumer.
+ WebString m_downloadFilePath;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
new file mode 100644
index 0000000..798e5ff
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -0,0 +1,2441 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebViewImpl.h"
+
+#include "AutoFillPopupMenuClient.h"
+#include "AXObjectCache.h"
+#include "BackForwardListChromium.h"
+#include "CSSStyleSelector.h"
+#include "CSSValueKeywords.h"
+#include "Chrome.h"
+#include "ColorSpace.h"
+#include "CompositionUnderlineVectorBuilder.h"
+#include "ContextMenu.h"
+#include "ContextMenuController.h"
+#include "ContextMenuItem.h"
+#include "Cursor.h"
+#include "DOMUtilitiesPrivate.h"
+#include "DeviceOrientationClientProxy.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "DragController.h"
+#include "DragData.h"
+#include "DragScrollTimer.h"
+#include "Editor.h"
+#include "EventHandler.h"
+#include "Extensions3D.h"
+#include "FocusController.h"
+#include "FontDescription.h"
+#include "FrameLoader.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "GeolocationClientProxy.h"
+#include "GraphicsContext.h"
+#include "GraphicsContext3D.h"
+#include "GraphicsContext3DInternal.h"
+#include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "HitTestResult.h"
+#include "Image.h"
+#include "ImageBuffer.h"
+#include "InspectorController.h"
+#include "KeyboardCodes.h"
+#include "KeyboardEvent.h"
+#include "MIMETypeRegistry.h"
+#include "NodeRenderStyle.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "PageGroupLoadDeferrer.h"
+#include "Pasteboard.h"
+#include "PlatformBridge.h"
+#include "PlatformContextSkia.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformThemeChromiumGtk.h"
+#include "PlatformWheelEvent.h"
+#include "PopupMenuChromium.h"
+#include "PopupMenuClient.h"
+#include "ProgressTracker.h"
+#include "RenderView.h"
+#include "ResourceHandle.h"
+#include "SecurityOrigin.h"
+#include "SelectionController.h"
+#include "Settings.h"
+#include "SpeechInputClientImpl.h"
+#include "Timer.h"
+#include "TypingCommand.h"
+#include "UserGestureIndicator.h"
+#include "Vector.h"
+#include "WebAccessibilityObject.h"
+#include "WebAutoFillClient.h"
+#include "WebDevToolsAgentImpl.h"
+#include "WebDevToolsAgentPrivate.h"
+#include "WebDragData.h"
+#include "WebFrameImpl.h"
+#include "WebImage.h"
+#include "WebInputElement.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMediaPlayerAction.h"
+#include "WebNode.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPoint.h"
+#include "WebPopupMenuImpl.h"
+#include "WebRect.h"
+#include "WebRuntimeFeatures.h"
+#include "WebSettingsImpl.h"
+#include "WebString.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+#include <wtf/ByteArray.h>
+#include <wtf/RefPtr.h>
+
+#if PLATFORM(CG)
+#include <CoreGraphics/CGContext.h>
+#endif
+
+#if OS(WINDOWS)
+#include "RenderThemeChromiumWin.h"
+#else
+#if OS(LINUX) || OS(FREEBSD)
+#include "RenderThemeChromiumLinux.h"
+#endif
+#include "RenderTheme.h"
+#endif
+
+// Get rid of WTF's pow define so we can use std::pow.
+#undef pow
+#include <cmath> // for std::pow
+
+using namespace WebCore;
+
+namespace {
+
+GraphicsContext3D::Attributes getCompositorContextAttributes()
+{
+ // Explicitly disable antialiasing for the compositor. As of the time of
+ // this writing, the only platform that supported antialiasing for the
+ // compositor was Mac OS X, because the on-screen OpenGL context creation
+ // code paths on Windows and Linux didn't yet have multisampling support.
+ // Mac OS X essentially always behaves as though it's rendering offscreen.
+ // Multisampling has a heavy cost especially on devices with relatively low
+ // fill rate like most notebooks, and the Mac implementation would need to
+ // be optimized to resolve directly into the IOSurface shared between the
+ // GPU and browser processes. For these reasons and to avoid platform
+ // disparities we explicitly disable antialiasing.
+ GraphicsContext3D::Attributes attributes;
+ attributes.antialias = false;
+ return attributes;
+}
+
+} // anonymous namespace
+
+namespace WebKit {
+
+// Change the text zoom level by kTextSizeMultiplierRatio each time the user
+// zooms text in or out (ie., change by 20%). The min and max values limit
+// text zoom to half and 3x the original text size. These three values match
+// those in Apple's port in WebKit/WebKit/WebView/WebView.mm
+const double WebView::textSizeMultiplierRatio = 1.2;
+const double WebView::minTextSizeMultiplier = 0.5;
+const double WebView::maxTextSizeMultiplier = 3.0;
+
+
+// The group name identifies a namespace of pages. Page group is used on OSX
+// for some programs that use HTML views to display things that don't seem like
+// web pages to the user (so shouldn't have visited link coloring). We only use
+// one page group.
+const char* pageGroupName = "default";
+
+// Used to defer all page activity in cases where the embedder wishes to run
+// a nested event loop. Using a stack enables nesting of message loop invocations.
+static Vector<PageGroupLoadDeferrer*> pageGroupLoadDeferrerStack;
+
+// Ensure that the WebDragOperation enum values stay in sync with the original
+// DragOperation constants.
+#define COMPILE_ASSERT_MATCHING_ENUM(coreName) \
+ COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName)
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationPrivate);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
+
+static const PopupContainerSettings autoFillPopupSettings = {
+ false, // setTextOnIndexChange
+ false, // acceptOnAbandon
+ true, // loopSelectionNavigation
+ false, // restrictWidthOfListBox (For security reasons show the entire entry
+ // so the user doesn't enter information he did not intend to.)
+ // For suggestions, we use the direction of the input field as the direction
+ // of the popup items. The main reason is to keep the display of items in
+ // drop-down the same as the items in the input field.
+ PopupContainerSettings::DOMElementDirection,
+};
+
+static bool shouldUseExternalPopupMenus = false;
+
+// WebView ----------------------------------------------------------------
+
+WebView* WebView::create(WebViewClient* client, WebDevToolsAgentClient* devToolsClient, WebAutoFillClient* autoFillClient)
+{
+ // Keep runtime flag for device motion turned off until it's implemented.
+ WebRuntimeFeatures::enableDeviceMotion(false);
+
+ // Pass the WebViewImpl's self-reference to the caller.
+ return adoptRef(new WebViewImpl(client, devToolsClient, autoFillClient)).leakRef();
+}
+
+void WebView::setUseExternalPopupMenus(bool useExternalPopupMenus)
+{
+ shouldUseExternalPopupMenus = useExternalPopupMenus;
+}
+
+void WebView::updateVisitedLinkState(unsigned long long linkHash)
+{
+ Page::visitedStateChanged(PageGroup::pageGroup(pageGroupName), linkHash);
+}
+
+void WebView::resetVisitedLinkState()
+{
+ Page::allVisitedStateChanged(PageGroup::pageGroup(pageGroupName));
+}
+
+void WebView::willEnterModalLoop()
+{
+ PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
+ ASSERT(pageGroup);
+
+ if (pageGroup->pages().isEmpty())
+ pageGroupLoadDeferrerStack.append(static_cast<PageGroupLoadDeferrer*>(0));
+ else {
+ // Pick any page in the page group since we are deferring all pages.
+ pageGroupLoadDeferrerStack.append(new PageGroupLoadDeferrer(*pageGroup->pages().begin(), true));
+ }
+}
+
+void WebView::didExitModalLoop()
+{
+ ASSERT(pageGroupLoadDeferrerStack.size());
+
+ delete pageGroupLoadDeferrerStack.last();
+ pageGroupLoadDeferrerStack.removeLast();
+}
+
+void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient)
+{
+ // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame
+ // and releases that reference once the corresponding Frame is destroyed.
+ RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient);
+
+ frame->initializeAsMainFrame(this);
+
+ // Restrict the access to the local file system
+ // (see WebView.mm WebView::_commonInitializationWithFrameName).
+ SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly);
+}
+
+WebViewImpl::WebViewImpl(WebViewClient* client, WebDevToolsAgentClient* devToolsClient, WebAutoFillClient* autoFillClient)
+ : m_client(client)
+ , m_autoFillClient(autoFillClient)
+ , m_chromeClientImpl(this)
+ , m_contextMenuClientImpl(this)
+ , m_dragClientImpl(this)
+ , m_editorClientImpl(this)
+ , m_inspectorClientImpl(this)
+ , m_observedNewNavigation(false)
+#ifndef NDEBUG
+ , m_newNavigationLoader(0)
+#endif
+ , m_zoomLevel(0)
+ , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
+ , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
+ , m_contextMenuAllowed(false)
+ , m_doingDragAndDrop(false)
+ , m_ignoreInputEvents(false)
+ , m_suppressNextKeypressEvent(false)
+ , m_initialNavigationPolicy(WebNavigationPolicyIgnore)
+ , m_imeAcceptEvents(true)
+ , m_dragTargetDispatch(false)
+ , m_dragIdentity(0)
+ , m_dropEffect(DropEffectDefault)
+ , m_operationsAllowed(WebDragOperationNone)
+ , m_dragOperation(WebDragOperationNone)
+ , m_autoFillPopupShowing(false)
+ , m_autoFillPopupClient(0)
+ , m_autoFillPopup(0)
+ , m_isTransparent(false)
+ , m_tabsToLinks(false)
+ , m_dragScrollTimer(new DragScrollTimer())
+#if USE(ACCELERATED_COMPOSITING)
+ , m_layerRenderer(0)
+ , m_isAcceleratedCompositingActive(false)
+ , m_compositorCreationFailed(false)
+#endif
+#if ENABLE(INPUT_SPEECH)
+ , m_speechInputClient(SpeechInputClientImpl::create(client))
+#endif
+ , m_deviceOrientationClientProxy(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))
+ , m_geolocationClientProxy(new GeolocationClientProxy(client ? client->geolocationClient() : 0))
+{
+ // WebKit/win/WebView.cpp does the same thing, except they call the
+ // KJS specific wrapper around this method. We need to have threading
+ // initialized because CollatorICU requires it.
+ WTF::initializeThreading();
+ WTF::initializeMainThread();
+
+ // set to impossible point so we always get the first mouse pos
+ m_lastMousePosition = WebPoint(-1, -1);
+
+ if (devToolsClient)
+ m_devToolsAgent = new WebDevToolsAgentImpl(this, devToolsClient);
+
+ Page::PageClients pageClients;
+ pageClients.chromeClient = &m_chromeClientImpl;
+ pageClients.contextMenuClient = &m_contextMenuClientImpl;
+ pageClients.editorClient = &m_editorClientImpl;
+ pageClients.dragClient = &m_dragClientImpl;
+ pageClients.inspectorClient = &m_inspectorClientImpl;
+#if ENABLE(INPUT_SPEECH)
+ pageClients.speechInputClient = m_speechInputClient.get();
+#endif
+ pageClients.deviceOrientationClient = m_deviceOrientationClientProxy.get();
+ pageClients.geolocationClient = m_geolocationClientProxy.get();
+ pageClients.backForwardClient = BackForwardListChromium::create(this);
+
+ m_page.set(new Page(pageClients));
+
+ m_geolocationClientProxy->setController(m_page->geolocationController());
+
+ m_page->setGroupName(pageGroupName);
+
+ m_inspectorSettingsMap.set(new SettingsMap);
+}
+
+WebViewImpl::~WebViewImpl()
+{
+ ASSERT(!m_page);
+}
+
+RenderTheme* WebViewImpl::theme() const
+{
+ return m_page.get() ? m_page->theme() : RenderTheme::defaultTheme().get();
+}
+
+WebFrameImpl* WebViewImpl::mainFrameImpl()
+{
+ return m_page.get() ? WebFrameImpl::fromFrame(m_page->mainFrame()) : 0;
+}
+
+bool WebViewImpl::tabKeyCyclesThroughElements() const
+{
+ ASSERT(m_page.get());
+ return m_page->tabKeyCyclesThroughElements();
+}
+
+void WebViewImpl::setTabKeyCyclesThroughElements(bool value)
+{
+ if (m_page)
+ m_page->setTabKeyCyclesThroughElements(value);
+}
+
+void WebViewImpl::mouseMove(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_lastMousePosition = WebPoint(event.x, event.y);
+
+ // We call mouseMoved here instead of handleMouseMovedEvent because we need
+ // our ChromeClientImpl to receive changes to the mouse position and
+ // tooltip text, and mouseMoved handles all of that.
+ mainFrameImpl()->frame()->eventHandler()->mouseMoved(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+}
+
+void WebViewImpl::mouseLeave(const WebMouseEvent& event)
+{
+ // This event gets sent as the main frame is closing. In that case, just
+ // ignore it.
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_client->setMouseOverURL(WebURL());
+
+ mainFrameImpl()->frame()->eventHandler()->handleMouseMoveEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+}
+
+void WebViewImpl::mouseDown(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ // If there is a select popup open, close it as the user is clicking on
+ // the page (outside of the popup). We also save it so we can prevent a
+ // click on the select element from immediately reopening the popup.
+ RefPtr<WebCore::PopupContainer> selectPopup;
+ if (event.button == WebMouseEvent::ButtonLeft) {
+ selectPopup = m_selectPopup;
+ hideSelectPopup();
+ ASSERT(!m_selectPopup);
+ }
+
+ m_lastMouseDownPoint = WebPoint(event.x, event.y);
+
+ RefPtr<Node> clickedNode;
+ if (event.button == WebMouseEvent::ButtonLeft) {
+ IntPoint point(event.x, event.y);
+ point = m_page->mainFrame()->view()->windowToContents(point);
+ HitTestResult result(m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false));
+ Node* hitNode = result.innerNonSharedNode();
+
+ // Take capture on a mouse down on a plugin so we can send it mouse events.
+ if (hitNode && hitNode->renderer() && hitNode->renderer()->isEmbeddedObject())
+ m_mouseCaptureNode = hitNode;
+
+ // If a text field that has focus is clicked again, we should display the
+ // AutoFill popup.
+ RefPtr<Node> focusedNode = focusedWebCoreNode();
+ if (focusedNode.get() && toHTMLInputElement(focusedNode.get())) {
+ if (hitNode == focusedNode) {
+ // Already focused text field was clicked, let's remember this. If
+ // focus has not changed after the mouse event is processed, we'll
+ // trigger the autocomplete.
+ clickedNode = focusedNode;
+ }
+ }
+ }
+
+ mainFrameImpl()->frame()->loader()->resetMultipleFormSubmissionProtection();
+
+ mainFrameImpl()->frame()->eventHandler()->handleMousePressEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+
+ if (clickedNode.get() && clickedNode == focusedWebCoreNode()) {
+ // Focus has not changed, show the AutoFill popup.
+ static_cast<EditorClientImpl*>(m_page->editorClient())->
+ showFormAutofillForNode(clickedNode.get());
+ }
+ if (m_selectPopup && m_selectPopup == selectPopup) {
+ // That click triggered a select popup which is the same as the one that
+ // was showing before the click. It means the user clicked the select
+ // while the popup was showing, and as a result we first closed then
+ // immediately reopened the select popup. It needs to be closed.
+ hideSelectPopup();
+ }
+
+ // Dispatch the contextmenu event regardless of if the click was swallowed.
+ // On Windows, we handle it on mouse up, not down.
+#if OS(DARWIN)
+ if (event.button == WebMouseEvent::ButtonRight
+ || (event.button == WebMouseEvent::ButtonLeft
+ && event.modifiers & WebMouseEvent::ControlKey))
+ mouseContextMenu(event);
+#elif OS(LINUX) || OS(FREEBSD)
+ if (event.button == WebMouseEvent::ButtonRight)
+ mouseContextMenu(event);
+#endif
+}
+
+void WebViewImpl::mouseContextMenu(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_page->contextMenuController()->clearContextMenu();
+
+ PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event);
+
+ // Find the right target frame. See issue 1186900.
+ HitTestResult result = hitTestResultForWindowPos(pme.pos());
+ Frame* targetFrame;
+ if (result.innerNonSharedNode())
+ targetFrame = result.innerNonSharedNode()->document()->frame();
+ else
+ targetFrame = m_page->focusController()->focusedOrMainFrame();
+
+#if OS(WINDOWS)
+ targetFrame->view()->setCursor(pointerCursor());
+#endif
+
+ m_contextMenuAllowed = true;
+ targetFrame->eventHandler()->sendContextMenuEvent(pme);
+ m_contextMenuAllowed = false;
+ // Actually showing the context menu is handled by the ContextMenuClient
+ // implementation...
+}
+
+void WebViewImpl::mouseUp(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+#if OS(LINUX) || OS(FREEBSD)
+ // If the event was a middle click, attempt to copy text into the focused
+ // frame. We execute this before we let the page have a go at the event
+ // because the page may change what is focused during in its event handler.
+ //
+ // This code is in the mouse up handler. There is some debate about putting
+ // this here, as opposed to the mouse down handler.
+ // xterm: pastes on up.
+ // GTK: pastes on down.
+ // Firefox: pastes on up.
+ // Midori: couldn't paste at all with 0.1.2
+ //
+ // There is something of a webcompat angle to this well, as highlighted by
+ // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on
+ // down then the text is pasted just before the onclick handler runs and
+ // clears the text box. So it's important this happens after the
+ // handleMouseReleaseEvent() earlier in this function
+ if (event.button == WebMouseEvent::ButtonMiddle) {
+ Frame* focused = focusedWebCoreFrame();
+ FrameView* view = m_page->mainFrame()->view();
+ IntPoint clickPoint(m_lastMouseDownPoint.x, m_lastMouseDownPoint.y);
+ IntPoint contentPoint = view->windowToContents(clickPoint);
+ HitTestResult hitTestResult = focused->eventHandler()->hitTestResultAtPoint(contentPoint, false, false, ShouldHitTestScrollbars);
+ // We don't want to send a paste when middle clicking a scroll bar or a
+ // link (which will navigate later in the code). The main scrollbars
+ // have to be handled separately.
+ if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused && !view->scrollbarAtPoint(clickPoint)) {
+ Editor* editor = focused->editor();
+ Pasteboard* pasteboard = Pasteboard::generalPasteboard();
+ bool oldSelectionMode = pasteboard->isSelectionMode();
+ pasteboard->setSelectionMode(true);
+ editor->command(AtomicString("Paste")).execute();
+ pasteboard->setSelectionMode(oldSelectionMode);
+ }
+ }
+#endif
+
+ mainFrameImpl()->frame()->eventHandler()->handleMouseReleaseEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+
+#if OS(WINDOWS)
+ // Dispatch the contextmenu event regardless of if the click was swallowed.
+ // On Mac/Linux, we handle it on mouse down, not up.
+ if (event.button == WebMouseEvent::ButtonRight)
+ mouseContextMenu(event);
+#endif
+}
+
+bool WebViewImpl::mouseWheel(const WebMouseWheelEvent& event)
+{
+ PlatformWheelEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
+ return mainFrameImpl()->frame()->eventHandler()->handleWheelEvent(platformEvent);
+}
+
+bool WebViewImpl::keyEvent(const WebKeyboardEvent& event)
+{
+ ASSERT((event.type == WebInputEvent::RawKeyDown)
+ || (event.type == WebInputEvent::KeyDown)
+ || (event.type == WebInputEvent::KeyUp));
+
+ // Please refer to the comments explaining the m_suppressNextKeypressEvent
+ // member.
+ // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
+ // Webkit. A keyDown event is typically associated with a keyPress(char)
+ // event and a keyUp event. We reset this flag here as this is a new keyDown
+ // event.
+ m_suppressNextKeypressEvent = false;
+
+ // Give any select popup a chance at consuming the key event.
+ if (selectPopupHandleKeyEvent(event))
+ return true;
+
+ // Give Autocomplete a chance to consume the key events it is interested in.
+ if (autocompleteHandleKeyEvent(event))
+ return true;
+
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ EventHandler* handler = frame->eventHandler();
+ if (!handler)
+ return keyEventDefault(event);
+
+#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD)
+ const WebInputEvent::Type contextMenuTriggeringEventType =
+#if OS(WINDOWS)
+ WebInputEvent::KeyUp;
+#elif OS(LINUX) || OS(FREEBSD)
+ WebInputEvent::RawKeyDown;
+#endif
+
+ bool isUnmodifiedMenuKey = !(event.modifiers & WebInputEvent::InputModifiers) && event.windowsKeyCode == VKEY_APPS;
+ bool isShiftF10 = event.modifiers == WebInputEvent::ShiftKey && event.windowsKeyCode == VKEY_F10;
+ if ((isUnmodifiedMenuKey || isShiftF10) && event.type == contextMenuTriggeringEventType) {
+ sendContextMenuEvent(event);
+ return true;
+ }
+#endif // OS(WINDOWS) || OS(LINUX) || OS(FREEBSD)
+
+ // It's not clear if we should continue after detecting a capslock keypress.
+ // I'll err on the side of continuing, which is the pre-existing behaviour.
+ if (event.windowsKeyCode == VKEY_CAPITAL)
+ handler->capsLockStateMayHaveChanged();
+
+ PlatformKeyboardEventBuilder evt(event);
+
+ if (handler->keyEvent(evt)) {
+ if (WebInputEvent::RawKeyDown == event.type) {
+ // Suppress the next keypress event unless the focused node is a plug-in node.
+ // (Flash needs these keypress events to handle non-US keyboards.)
+ Node* node = frame->document()->focusedNode();
+ if (!node || !node->renderer() || !node->renderer()->isEmbeddedObject())
+ m_suppressNextKeypressEvent = true;
+ }
+ return true;
+ }
+
+ return keyEventDefault(event);
+}
+
+bool WebViewImpl::selectPopupHandleKeyEvent(const WebKeyboardEvent& event)
+{
+ if (!m_selectPopup)
+ return false;
+
+ return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+}
+
+bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
+{
+ if (!m_autoFillPopupShowing
+ // Home and End should be left to the text field to process.
+ || event.windowsKeyCode == VKEY_HOME
+ || event.windowsKeyCode == VKEY_END)
+ return false;
+
+ // Pressing delete triggers the removal of the selected suggestion from the DB.
+ if (event.windowsKeyCode == VKEY_DELETE
+ && m_autoFillPopup->selectedIndex() != -1) {
+ Node* node = focusedWebCoreNode();
+ if (!node || (node->nodeType() != Node::ELEMENT_NODE)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+ Element* element = static_cast<Element*>(node);
+ if (!element->hasLocalName(HTMLNames::inputTag)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ int selectedIndex = m_autoFillPopup->selectedIndex();
+
+ if (!m_autoFillPopupClient->canRemoveSuggestionAtIndex(selectedIndex))
+ return false;
+
+ WebString name = WebInputElement(static_cast<HTMLInputElement*>(element)).nameForAutofill();
+ WebString value = m_autoFillPopupClient->itemText(selectedIndex);
+ m_autoFillClient->removeAutocompleteSuggestion(name, value);
+ // Update the entries in the currently showing popup to reflect the
+ // deletion.
+ m_autoFillPopupClient->removeSuggestionAtIndex(selectedIndex);
+ refreshAutoFillPopup();
+ return false;
+ }
+
+ if (!m_autoFillPopup->isInterestedInEventForKey(event.windowsKeyCode))
+ return false;
+
+ if (m_autoFillPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) {
+ // We need to ignore the next Char event after this otherwise pressing
+ // enter when selecting an item in the menu will go to the page.
+ if (WebInputEvent::RawKeyDown == event.type)
+ m_suppressNextKeypressEvent = true;
+ return true;
+ }
+
+ return false;
+}
+
+bool WebViewImpl::charEvent(const WebKeyboardEvent& event)
+{
+ ASSERT(event.type == WebInputEvent::Char);
+
+ // Please refer to the comments explaining the m_suppressNextKeypressEvent
+ // member. The m_suppressNextKeypressEvent is set if the KeyDown is
+ // handled by Webkit. A keyDown event is typically associated with a
+ // keyPress(char) event and a keyUp event. We reset this flag here as it
+ // only applies to the current keyPress event.
+ bool suppress = m_suppressNextKeypressEvent;
+ m_suppressNextKeypressEvent = false;
+
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return suppress;
+
+ EventHandler* handler = frame->eventHandler();
+ if (!handler)
+ return suppress || keyEventDefault(event);
+
+ PlatformKeyboardEventBuilder evt(event);
+ if (!evt.isCharacterKey())
+ return true;
+
+ // Accesskeys are triggered by char events and can't be suppressed.
+ if (handler->handleAccessKey(evt))
+ return true;
+
+ // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to
+ // the eventHandler::keyEvent. We mimic this behavior on all platforms since
+ // for now we are converting other platform's key events to windows key
+ // events.
+ if (evt.isSystemKey())
+ return false;
+
+ if (!suppress && !handler->keyEvent(evt))
+ return keyEventDefault(event);
+
+ return true;
+}
+
+#if ENABLE(TOUCH_EVENTS)
+bool WebViewImpl::touchEvent(const WebTouchEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return false;
+
+ PlatformTouchEventBuilder touchEventBuilder(mainFrameImpl()->frameView(), event);
+ return mainFrameImpl()->frame()->eventHandler()->handleTouchEvent(touchEventBuilder);
+}
+#endif
+
+#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD)
+// Mac has no way to open a context menu based on a keyboard event.
+bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event)
+{
+ // The contextMenuController() holds onto the last context menu that was
+ // popped up on the page until a new one is created. We need to clear
+ // this menu before propagating the event through the DOM so that we can
+ // detect if we create a new menu for this event, since we won't create
+ // a new menu if the DOM swallows the event and the defaultEventHandler does
+ // not run.
+ page()->contextMenuController()->clearContextMenu();
+
+ m_contextMenuAllowed = true;
+ Frame* focusedFrame = page()->focusController()->focusedOrMainFrame();
+ bool handled = focusedFrame->eventHandler()->sendContextMenuEventForKey();
+ m_contextMenuAllowed = false;
+ return handled;
+}
+#endif
+
+bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event)
+{
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ switch (event.type) {
+ case WebInputEvent::Char:
+ if (event.windowsKeyCode == VKEY_SPACE) {
+ int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT);
+ return scrollViewWithKeyboard(keyCode, event.modifiers);
+ }
+ break;
+ case WebInputEvent::RawKeyDown:
+ if (event.modifiers == WebInputEvent::ControlKey) {
+ switch (event.windowsKeyCode) {
+#if !OS(DARWIN)
+ case 'A':
+ focusedFrame()->executeCommand(WebString::fromUTF8("SelectAll"));
+ return true;
+ case VKEY_INSERT:
+ case 'C':
+ focusedFrame()->executeCommand(WebString::fromUTF8("Copy"));
+ return true;
+#endif
+ // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl
+ // key combinations which affect scrolling. Safari is buggy in the
+ // sense that it scrolls the page for all Ctrl+scrolling key
+ // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc.
+ case VKEY_HOME:
+ case VKEY_END:
+ break;
+ default:
+ return false;
+ }
+ }
+ if (!event.isSystemKey && !(event.modifiers & WebInputEvent::ShiftKey))
+ return scrollViewWithKeyboard(event.windowsKeyCode, event.modifiers);
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool WebViewImpl::scrollViewWithKeyboard(int keyCode, int modifiers)
+{
+ ScrollDirection scrollDirection;
+ ScrollGranularity scrollGranularity;
+ if (!mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranularity))
+ return false;
+ return propagateScroll(scrollDirection, scrollGranularity);
+}
+
+bool WebViewImpl::mapKeyCodeForScroll(int keyCode,
+ WebCore::ScrollDirection* scrollDirection,
+ WebCore::ScrollGranularity* scrollGranularity)
+{
+ switch (keyCode) {
+ case VKEY_LEFT:
+ *scrollDirection = ScrollLeft;
+ *scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_RIGHT:
+ *scrollDirection = ScrollRight;
+ *scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_UP:
+ *scrollDirection = ScrollUp;
+ *scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_DOWN:
+ *scrollDirection = ScrollDown;
+ *scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_HOME:
+ *scrollDirection = ScrollUp;
+ *scrollGranularity = ScrollByDocument;
+ break;
+ case VKEY_END:
+ *scrollDirection = ScrollDown;
+ *scrollGranularity = ScrollByDocument;
+ break;
+ case VKEY_PRIOR: // page up
+ *scrollDirection = ScrollUp;
+ *scrollGranularity = ScrollByPage;
+ break;
+ case VKEY_NEXT: // page down
+ *scrollDirection = ScrollDown;
+ *scrollGranularity = ScrollByPage;
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+void WebViewImpl::hideSelectPopup()
+{
+ if (m_selectPopup.get())
+ m_selectPopup->hidePopup();
+}
+
+bool WebViewImpl::propagateScroll(ScrollDirection scrollDirection,
+ ScrollGranularity scrollGranularity)
+{
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ bool scrollHandled = frame->eventHandler()->scrollOverflow(scrollDirection, scrollGranularity);
+ Frame* currentFrame = frame;
+ while (!scrollHandled && currentFrame) {
+ scrollHandled = currentFrame->view()->scroll(scrollDirection, scrollGranularity);
+ currentFrame = currentFrame->tree()->parent();
+ }
+ return scrollHandled;
+}
+
+void WebViewImpl::popupOpened(WebCore::PopupContainer* popupContainer)
+{
+ if (popupContainer->popupType() == WebCore::PopupContainer::Select) {
+ ASSERT(!m_selectPopup);
+ m_selectPopup = popupContainer;
+ }
+}
+
+void WebViewImpl::popupClosed(WebCore::PopupContainer* popupContainer)
+{
+ if (popupContainer->popupType() == WebCore::PopupContainer::Select) {
+ ASSERT(m_selectPopup.get());
+ m_selectPopup = 0;
+ }
+}
+
+void WebViewImpl::hideAutoFillPopup()
+{
+ if (m_autoFillPopupShowing) {
+ m_autoFillPopup->hidePopup();
+ m_autoFillPopupShowing = false;
+ }
+}
+
+Frame* WebViewImpl::focusedWebCoreFrame()
+{
+ return m_page.get() ? m_page->focusController()->focusedOrMainFrame() : 0;
+}
+
+WebViewImpl* WebViewImpl::fromPage(Page* page)
+{
+ if (!page)
+ return 0;
+
+ return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView();
+}
+
+// WebWidget ------------------------------------------------------------------
+
+void WebViewImpl::close()
+{
+ RefPtr<WebFrameImpl> mainFrameImpl;
+
+ if (m_page.get()) {
+ // Initiate shutdown for the entire frameset. This will cause a lot of
+ // notifications to be sent.
+ if (m_page->mainFrame()) {
+ mainFrameImpl = WebFrameImpl::fromFrame(m_page->mainFrame());
+ m_page->mainFrame()->loader()->frameDetached();
+ }
+ m_page.clear();
+ }
+
+ // Should happen after m_page.clear().
+ if (m_devToolsAgent.get())
+ m_devToolsAgent.clear();
+
+ // Reset the delegate to prevent notifications being sent as we're being
+ // deleted.
+ m_client = 0;
+
+ deref(); // Balances ref() acquired in WebView::create
+}
+
+void WebViewImpl::resize(const WebSize& newSize)
+{
+ if (m_size == newSize)
+ return;
+ m_size = newSize;
+
+ if (mainFrameImpl()->frameView()) {
+ mainFrameImpl()->frameView()->resize(m_size.width, m_size.height);
+ mainFrameImpl()->frame()->eventHandler()->sendResizeEvent();
+ }
+
+ if (m_client) {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ if (isAcceleratedCompositingActive()) {
+#if USE(ACCELERATED_COMPOSITING)
+ invalidateRootLayerRect(damagedRect);
+#endif
+ } else
+ m_client->didInvalidateRect(damagedRect);
+ }
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_layerRenderer && isAcceleratedCompositingActive()) {
+ m_layerRenderer->resizeOnscreenContent(IntSize(std::max(1, m_size.width),
+ std::max(1, m_size.height)));
+ }
+#endif
+}
+
+void WebViewImpl::animate()
+{
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe) {
+ FrameView* view = webframe->frameView();
+ if (view)
+ view->serviceScriptedAnimations();
+ }
+#endif
+}
+
+void WebViewImpl::layout()
+{
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe) {
+ // In order for our child HWNDs (NativeWindowWidgets) to update properly,
+ // they need to be told that we are updating the screen. The problem is
+ // that the native widgets need to recalculate their clip region and not
+ // overlap any of our non-native widgets. To force the resizing, call
+ // setFrameRect(). This will be a quick operation for most frames, but
+ // the NativeWindowWidgets will update a proper clipping region.
+ FrameView* view = webframe->frameView();
+ if (view)
+ view->setFrameRect(view->frameRect());
+
+ // setFrameRect may have the side-effect of causing existing page
+ // layout to be invalidated, so layout needs to be called last.
+
+ webframe->layout();
+ }
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect)
+{
+ ASSERT(rect.right() <= m_layerRenderer->rootLayerTextureSize().width()
+ && rect.bottom() <= m_layerRenderer->rootLayerTextureSize().height());
+
+#if PLATFORM(SKIA)
+ PlatformContextSkia context(canvas);
+
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+ int bitmapHeight = canvas->getDevice()->accessBitmap(false).height();
+#elif PLATFORM(CG)
+ GraphicsContext gc(canvas);
+ int bitmapHeight = CGBitmapContextGetHeight(reinterpret_cast<CGContextRef>(canvas));
+#else
+ notImplemented();
+#endif
+ // Compute rect to sample from inverted GPU buffer.
+ IntRect invertRect(rect.x(), bitmapHeight - rect.bottom(), rect.width(), rect.height());
+
+ OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(rect.size()));
+ RefPtr<ByteArray> pixelArray(ByteArray::create(rect.width() * rect.height() * 4));
+ if (imageBuffer.get() && pixelArray.get()) {
+ m_layerRenderer->getFramebufferPixels(pixelArray->data(), invertRect);
+ imageBuffer->putPremultipliedImageData(pixelArray.get(), rect.size(), IntRect(IntPoint(), rect.size()), IntPoint());
+ gc.save();
+ gc.translate(FloatSize(0.0f, bitmapHeight));
+ gc.scale(FloatSize(1.0f, -1.0f));
+ // Use invertRect in next line, so that transform above inverts it back to
+ // desired destination rect.
+ gc.drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, invertRect.location());
+ gc.restore();
+ }
+}
+#endif
+
+void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ if (isAcceleratedCompositingActive()) {
+#if USE(ACCELERATED_COMPOSITING)
+ doComposite();
+
+ // If a canvas was passed in, we use it to grab a copy of the
+ // freshly-rendered pixels.
+ if (canvas) {
+ // Clip rect to the confines of the rootLayerTexture.
+ IntRect resizeRect(rect);
+ resizeRect.intersect(IntRect(IntPoint(), m_layerRenderer->rootLayerTextureSize()));
+ doPixelReadbackToCanvas(canvas, resizeRect);
+ }
+#endif
+ } else {
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe)
+ webframe->paint(canvas, rect);
+ }
+}
+
+void WebViewImpl::themeChanged()
+{
+ if (!page())
+ return;
+ FrameView* view = page()->mainFrame()->view();
+
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ view->invalidateRect(damagedRect);
+}
+
+void WebViewImpl::composite(bool finish)
+{
+#if USE(ACCELERATED_COMPOSITING)
+ doComposite();
+
+ // Finish if requested.
+ if (finish)
+ m_layerRenderer->finish();
+
+ // Put result onscreen.
+ m_layerRenderer->present();
+
+ GraphicsContext3D* context = m_layerRenderer->context();
+ if (context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR)
+ reallocateRenderer();
+#endif
+}
+
+const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
+
+bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
+
+ // If we've started a drag and drop operation, ignore input events until
+ // we're done.
+ if (m_doingDragAndDrop)
+ return true;
+
+ if (m_ignoreInputEvents)
+ return true;
+
+ m_currentInputEvent = &inputEvent;
+
+ if (m_mouseCaptureNode.get() && WebInputEvent::isMouseEventType(inputEvent.type)) {
+ // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
+ RefPtr<Node> node = m_mouseCaptureNode;
+
+ // Not all platforms call mouseCaptureLost() directly.
+ if (inputEvent.type == WebInputEvent::MouseUp)
+ mouseCaptureLost();
+
+ AtomicString eventType;
+ switch (inputEvent.type) {
+ case WebInputEvent::MouseMove:
+ eventType = eventNames().mousemoveEvent;
+ break;
+ case WebInputEvent::MouseLeave:
+ eventType = eventNames().mouseoutEvent;
+ break;
+ case WebInputEvent::MouseDown:
+ eventType = eventNames().mousedownEvent;
+ break;
+ case WebInputEvent::MouseUp:
+ eventType = eventNames().mouseupEvent;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ node->dispatchMouseEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), *static_cast<const WebMouseEvent*>(&inputEvent)),
+ eventType, static_cast<const WebMouseEvent*>(&inputEvent)->clickCount);
+ m_currentInputEvent = 0;
+ return true;
+ }
+
+ bool handled = true;
+
+ // FIXME: WebKit seems to always return false on mouse events processing
+ // methods. For now we'll assume it has processed them (as we are only
+ // interested in whether keyboard events are processed).
+ switch (inputEvent.type) {
+ case WebInputEvent::MouseMove:
+ mouseMove(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseLeave:
+ mouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseWheel:
+ handled = mouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseDown:
+ mouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseUp:
+ mouseUp(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::RawKeyDown:
+ case WebInputEvent::KeyDown:
+ case WebInputEvent::KeyUp:
+ handled = keyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::Char:
+ handled = charEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+ break;
+
+#if ENABLE(TOUCH_EVENTS)
+ case WebInputEvent::TouchStart:
+ case WebInputEvent::TouchMove:
+ case WebInputEvent::TouchEnd:
+ case WebInputEvent::TouchCancel:
+ handled = touchEvent(*static_cast<const WebTouchEvent*>(&inputEvent));
+ break;
+#endif
+
+ default:
+ handled = false;
+ }
+
+ m_currentInputEvent = 0;
+
+ return handled;
+}
+
+void WebViewImpl::mouseCaptureLost()
+{
+ m_mouseCaptureNode = 0;
+}
+
+void WebViewImpl::setFocus(bool enable)
+{
+ m_page->focusController()->setFocused(enable);
+ if (enable) {
+ // Note that we don't call setActive() when disabled as this cause extra
+ // focus/blur events to be dispatched.
+ m_page->focusController()->setActive(true);
+ RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame();
+ if (focusedFrame) {
+ Node* focusedNode = focusedFrame->document()->focusedNode();
+ if (focusedNode && focusedNode->isElementNode()
+ && focusedFrame->selection()->selection().isNone()) {
+ // If the selection was cleared while the WebView was not
+ // focused, then the focus element shows with a focus ring but
+ // no caret and does respond to keyboard inputs.
+ Element* element = static_cast<Element*>(focusedNode);
+ if (element->isTextFormControl())
+ element->updateFocusAppearance(true);
+ else if (focusedNode->isContentEditable()) {
+ // updateFocusAppearance() selects all the text of
+ // contentseditable DIVs. So we set the selection explicitly
+ // instead. Note that this has the side effect of moving the
+ // caret back to the beginning of the text.
+ Position position(focusedNode, 0,
+ Position::PositionIsOffsetInAnchor);
+ focusedFrame->selection()->setSelection(
+ VisibleSelection(position, SEL_DEFAULT_AFFINITY));
+ }
+ }
+ }
+ m_imeAcceptEvents = true;
+ } else {
+ hideAutoFillPopup();
+ hideSelectPopup();
+
+ // Clear focus on the currently focused frame if any.
+ if (!m_page.get())
+ return;
+
+ Frame* frame = m_page->mainFrame();
+ if (!frame)
+ return;
+
+ RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame();
+ if (focusedFrame.get()) {
+ // Finish an ongoing composition to delete the composition node.
+ Editor* editor = focusedFrame->editor();
+ if (editor && editor->hasComposition())
+ editor->confirmComposition();
+ m_imeAcceptEvents = false;
+ }
+ }
+}
+
+bool WebViewImpl::setComposition(
+ const WebString& text,
+ const WebVector<WebCompositionUnderline>& underlines,
+ int selectionStart,
+ int selectionEnd)
+{
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused || !m_imeAcceptEvents)
+ return false;
+ Editor* editor = focused->editor();
+ if (!editor)
+ return false;
+
+ // The input focus has been moved to another WebWidget object.
+ // We should use this |editor| object only to complete the ongoing
+ // composition.
+ if (!editor->canEdit() && !editor->hasComposition())
+ return false;
+
+ // We should verify the parent node of this IME composition node are
+ // editable because JavaScript may delete a parent node of the composition
+ // node. In this case, WebKit crashes while deleting texts from the parent
+ // node, which doesn't exist any longer.
+ PassRefPtr<Range> range = editor->compositionRange();
+ if (range) {
+ const Node* node = range->startPosition().node();
+ if (!node || !node->isContentEditable())
+ return false;
+ }
+
+ // If we're not going to fire a keypress event, then the keydown event was
+ // canceled. In that case, cancel any existing composition.
+ if (text.isEmpty() || m_suppressNextKeypressEvent) {
+ // A browser process sent an IPC message which does not contain a valid
+ // string, which means an ongoing composition has been canceled.
+ // If the ongoing composition has been canceled, replace the ongoing
+ // composition string with an empty string and complete it.
+ String emptyString;
+ Vector<CompositionUnderline> emptyUnderlines;
+ editor->setComposition(emptyString, emptyUnderlines, 0, 0);
+ return text.isEmpty();
+ }
+
+ // When the range of composition underlines overlap with the range between
+ // selectionStart and selectionEnd, WebKit somehow won't paint the selection
+ // at all (see InlineTextBox::paint() function in InlineTextBox.cpp).
+ // But the selection range actually takes effect.
+ editor->setComposition(String(text),
+ CompositionUnderlineVectorBuilder(underlines),
+ selectionStart, selectionEnd);
+
+ return editor->hasComposition();
+}
+
+bool WebViewImpl::confirmComposition()
+{
+ return confirmComposition(WebString());
+}
+
+bool WebViewImpl::confirmComposition(const WebString& text)
+{
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused || !m_imeAcceptEvents)
+ return false;
+ Editor* editor = focused->editor();
+ if (!editor || (!editor->hasComposition() && !text.length()))
+ return false;
+
+ // We should verify the parent node of this IME composition node are
+ // editable because JavaScript may delete a parent node of the composition
+ // node. In this case, WebKit crashes while deleting texts from the parent
+ // node, which doesn't exist any longer.
+ PassRefPtr<Range> range = editor->compositionRange();
+ if (range) {
+ const Node* node = range->startPosition().node();
+ if (!node || !node->isContentEditable())
+ return false;
+ }
+
+ if (editor->hasComposition()) {
+ if (text.length())
+ editor->confirmComposition(String(text));
+ else
+ editor->confirmComposition();
+ } else
+ editor->insertText(String(text), 0);
+
+ return true;
+}
+
+WebTextInputType WebViewImpl::textInputType()
+{
+ WebTextInputType type = WebTextInputTypeNone;
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return type;
+
+ const Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return type;
+
+ SelectionController* controller = focused->selection();
+ if (!controller)
+ return type;
+
+ const Node* node = controller->start().node();
+ if (!node)
+ return type;
+
+ // FIXME: Support more text input types when necessary, eg. Number,
+ // Date, Email, URL, etc.
+ if (controller->isInPasswordField())
+ type = WebTextInputTypePassword;
+ else if (node->shouldUseInputMethod())
+ type = WebTextInputTypeText;
+
+ return type;
+}
+
+WebRect WebViewImpl::caretOrSelectionBounds()
+{
+ WebRect rect;
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return rect;
+
+ SelectionController* controller = focused->selection();
+ if (!controller)
+ return rect;
+
+ const FrameView* view = focused->view();
+ if (!view)
+ return rect;
+
+ const Node* node = controller->start().node();
+ if (!node || !node->renderer())
+ return rect;
+
+ if (controller->isCaret())
+ rect = view->contentsToWindow(controller->absoluteCaretBounds());
+ else if (controller->isRange()) {
+ node = controller->end().node();
+ if (!node || !node->renderer())
+ return rect;
+ RefPtr<Range> range = controller->toNormalizedRange();
+ rect = view->contentsToWindow(focused->editor()->firstRectForRange(range.get()));
+ }
+ return rect;
+}
+
+void WebViewImpl::setTextDirection(WebTextDirection direction)
+{
+ // The Editor::setBaseWritingDirection() function checks if we can change
+ // the text direction of the selected node and updates its DOM "dir"
+ // attribute and its CSS "direction" property.
+ // So, we just call the function as Safari does.
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return;
+
+ switch (direction) {
+ case WebTextDirectionDefault:
+ editor->setBaseWritingDirection(NaturalWritingDirection);
+ break;
+
+ case WebTextDirectionLeftToRight:
+ editor->setBaseWritingDirection(LeftToRightWritingDirection);
+ break;
+
+ case WebTextDirectionRightToLeft:
+ editor->setBaseWritingDirection(RightToLeftWritingDirection);
+ break;
+
+ default:
+ notImplemented();
+ break;
+ }
+}
+
+bool WebViewImpl::isAcceleratedCompositingActive() const
+{
+#if USE(ACCELERATED_COMPOSITING)
+ return m_isAcceleratedCompositingActive;
+#else
+ return false;
+#endif
+}
+
+// WebView --------------------------------------------------------------------
+
+WebSettings* WebViewImpl::settings()
+{
+ if (!m_webSettings.get())
+ m_webSettings.set(new WebSettingsImpl(m_page->settings()));
+ ASSERT(m_webSettings.get());
+ return m_webSettings.get();
+}
+
+WebString WebViewImpl::pageEncoding() const
+{
+ if (!m_page.get())
+ return WebString();
+
+ return m_page->mainFrame()->loader()->writer()->encoding();
+}
+
+void WebViewImpl::setPageEncoding(const WebString& encodingName)
+{
+ if (!m_page.get())
+ return;
+
+ // Only change override encoding, don't change default encoding.
+ // Note that the new encoding must be 0 if it isn't supposed to be set.
+ String newEncodingName;
+ if (!encodingName.isEmpty())
+ newEncodingName = encodingName;
+ m_page->mainFrame()->loader()->reloadWithOverrideEncoding(newEncodingName);
+}
+
+bool WebViewImpl::dispatchBeforeUnloadEvent()
+{
+ // FIXME: This should really cause a recursive depth-first walk of all
+ // frames in the tree, calling each frame's onbeforeunload. At the moment,
+ // we're consistent with Safari 3.1, not IE/FF.
+ Frame* frame = m_page->mainFrame();
+ if (!frame)
+ return true;
+
+ return frame->loader()->shouldClose();
+}
+
+void WebViewImpl::dispatchUnloadEvent()
+{
+ // Run unload handlers.
+ m_page->mainFrame()->loader()->closeURL();
+}
+
+WebFrame* WebViewImpl::mainFrame()
+{
+ return mainFrameImpl();
+}
+
+WebFrame* WebViewImpl::findFrameByName(
+ const WebString& name, WebFrame* relativeToFrame)
+{
+ if (!relativeToFrame)
+ relativeToFrame = mainFrame();
+ Frame* frame = static_cast<WebFrameImpl*>(relativeToFrame)->frame();
+ frame = frame->tree()->find(name);
+ return WebFrameImpl::fromFrame(frame);
+}
+
+WebFrame* WebViewImpl::focusedFrame()
+{
+ return WebFrameImpl::fromFrame(focusedWebCoreFrame());
+}
+
+void WebViewImpl::setFocusedFrame(WebFrame* frame)
+{
+ if (!frame) {
+ // Clears the focused frame if any.
+ Frame* frame = focusedWebCoreFrame();
+ if (frame)
+ frame->selection()->setFocused(false);
+ return;
+ }
+ WebFrameImpl* frameImpl = static_cast<WebFrameImpl*>(frame);
+ Frame* webcoreFrame = frameImpl->frame();
+ webcoreFrame->page()->focusController()->setFocusedFrame(webcoreFrame);
+}
+
+void WebViewImpl::setInitialFocus(bool reverse)
+{
+ if (!m_page.get())
+ return;
+
+ // Since we don't have a keyboard event, we'll create one.
+ WebKeyboardEvent keyboardEvent;
+ keyboardEvent.type = WebInputEvent::RawKeyDown;
+ if (reverse)
+ keyboardEvent.modifiers = WebInputEvent::ShiftKey;
+
+ // VK_TAB which is only defined on Windows.
+ keyboardEvent.windowsKeyCode = 0x09;
+ PlatformKeyboardEventBuilder platformEvent(keyboardEvent);
+ RefPtr<KeyboardEvent> webkitEvent = KeyboardEvent::create(platformEvent, 0);
+
+ Frame* frame = page()->focusController()->focusedOrMainFrame();
+ if (Document* document = frame->document())
+ document->setFocusedNode(0);
+ page()->focusController()->setInitialFocus(
+ reverse ? FocusDirectionBackward : FocusDirectionForward,
+ webkitEvent.get());
+}
+
+void WebViewImpl::clearFocusedNode()
+{
+ if (!m_page.get())
+ return;
+
+ RefPtr<Frame> frame = m_page->mainFrame();
+ if (!frame.get())
+ return;
+
+ RefPtr<Document> document = frame->document();
+ if (!document.get())
+ return;
+
+ RefPtr<Node> oldFocusedNode = document->focusedNode();
+
+ // Clear the focused node.
+ document->setFocusedNode(0);
+
+ if (!oldFocusedNode.get())
+ return;
+
+ // If a text field has focus, we need to make sure the selection controller
+ // knows to remove selection from it. Otherwise, the text field is still
+ // processing keyboard events even though focus has been moved to the page and
+ // keystrokes get eaten as a result.
+ if (oldFocusedNode->hasTagName(HTMLNames::textareaTag)
+ || (oldFocusedNode->hasTagName(HTMLNames::inputTag)
+ && static_cast<HTMLInputElement*>(oldFocusedNode.get())->isTextField())) {
+ // Clear the selection.
+ SelectionController* selection = frame->selection();
+ selection->clear();
+ }
+}
+
+void WebViewImpl::scrollFocusedNodeIntoView()
+{
+ Node* focusedNode = focusedWebCoreNode();
+ if (focusedNode && focusedNode->isElementNode()) {
+ Element* elementNode = static_cast<Element*>(focusedNode);
+ elementNode->scrollIntoViewIfNeeded(true);
+ }
+}
+
+double WebViewImpl::zoomLevel()
+{
+ return m_zoomLevel;
+}
+
+double WebViewImpl::setZoomLevel(bool textOnly, double zoomLevel)
+{
+ if (zoomLevel < m_minimumZoomLevel)
+ m_zoomLevel = m_minimumZoomLevel;
+ else if (zoomLevel > m_maximumZoomLevel)
+ m_zoomLevel = m_maximumZoomLevel;
+ else
+ m_zoomLevel = zoomLevel;
+
+ Frame* frame = mainFrameImpl()->frame();
+ WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame);
+ if (pluginContainer)
+ pluginContainer->plugin()->setZoomLevel(m_zoomLevel, textOnly);
+ else {
+ double zoomFactor = zoomLevelToZoomFactor(m_zoomLevel);
+ if (textOnly)
+ frame->setPageAndTextZoomFactors(1, zoomFactor);
+ else
+ frame->setPageAndTextZoomFactors(zoomFactor, 1);
+ }
+ return m_zoomLevel;
+}
+
+void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel,
+ double maximumZoomLevel)
+{
+ m_minimumZoomLevel = minimumZoomLevel;
+ m_maximumZoomLevel = maximumZoomLevel;
+ m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel);
+}
+
+void WebViewImpl::fullFramePluginZoomLevelChanged(double zoomLevel)
+{
+ if (zoomLevel == m_zoomLevel)
+ return;
+
+ m_zoomLevel = std::max(std::min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel);
+ m_client->zoomLevelChanged();
+}
+
+double WebView::zoomLevelToZoomFactor(double zoomLevel)
+{
+ return std::pow(textSizeMultiplierRatio, zoomLevel);
+}
+
+double WebView::zoomFactorToZoomLevel(double factor)
+{
+ // Since factor = 1.2^level, level = log(factor) / log(1.2)
+ return log(factor) / log(textSizeMultiplierRatio);
+}
+
+void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
+ const WebPoint& location)
+{
+ HitTestResult result =
+ hitTestResultForWindowPos(location);
+ RefPtr<Node> node = result.innerNonSharedNode();
+ if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag))
+ return;
+
+ RefPtr<HTMLMediaElement> mediaElement =
+ static_pointer_cast<HTMLMediaElement>(node);
+ switch (action.type) {
+ case WebMediaPlayerAction::Play:
+ if (action.enable)
+ mediaElement->play(mediaElement->processingUserGesture());
+ else
+ mediaElement->pause(mediaElement->processingUserGesture());
+ break;
+ case WebMediaPlayerAction::Mute:
+ mediaElement->setMuted(action.enable);
+ break;
+ case WebMediaPlayerAction::Loop:
+ mediaElement->setLoop(action.enable);
+ break;
+ case WebMediaPlayerAction::Controls:
+ mediaElement->setControls(action.enable);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void WebViewImpl::copyImageAt(const WebPoint& point)
+{
+ if (!m_page.get())
+ return;
+
+ HitTestResult result = hitTestResultForWindowPos(point);
+
+ if (result.absoluteImageURL().isEmpty()) {
+ // There isn't actually an image at these coordinates. Might be because
+ // the window scrolled while the context menu was open or because the page
+ // changed itself between when we thought there was an image here and when
+ // we actually tried to retreive the image.
+ //
+ // FIXME: implement a cache of the most recent HitTestResult to avoid having
+ // to do two hit tests.
+ return;
+ }
+
+ m_page->mainFrame()->editor()->copyImage(result);
+}
+
+void WebViewImpl::dragSourceEndedAt(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation)
+{
+ PlatformMouseEvent pme(clientPoint,
+ screenPoint,
+ LeftButton, MouseEventMoved, 0, false, false, false,
+ false, 0);
+ m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme,
+ static_cast<DragOperation>(operation));
+ m_dragScrollTimer->stop();
+}
+
+void WebViewImpl::dragSourceMovedTo(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation)
+{
+ m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);
+}
+
+void WebViewImpl::dragSourceSystemDragEnded()
+{
+ // It's possible for us to get this callback while not doing a drag if
+ // it's from a previous page that got unloaded.
+ if (m_doingDragAndDrop) {
+ m_page->dragController()->dragEnded();
+ m_doingDragAndDrop = false;
+ }
+}
+
+WebDragOperation WebViewImpl::dragTargetDragEnter(
+ const WebDragData& webDragData, int identity,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed)
+{
+ ASSERT(!m_currentDragData.get());
+
+ m_currentDragData = webDragData;
+ m_dragIdentity = identity;
+ m_operationsAllowed = operationsAllowed;
+
+ return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter);
+}
+
+WebDragOperation WebViewImpl::dragTargetDragEnterNew(
+ int identity,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed)
+{
+ ASSERT(!m_currentDragData.get());
+
+ m_currentDragData = ChromiumDataObject::createReadable(Clipboard::DragAndDrop);
+ m_dragIdentity = identity;
+ m_operationsAllowed = operationsAllowed;
+
+ return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter);
+}
+
+WebDragOperation WebViewImpl::dragTargetDragOver(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed)
+{
+ m_operationsAllowed = operationsAllowed;
+
+ return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver);
+}
+
+void WebViewImpl::dragTargetDragLeave()
+{
+ ASSERT(m_currentDragData.get());
+
+ DragData dragData(
+ m_currentDragData.get(),
+ IntPoint(),
+ IntPoint(),
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_dragTargetDispatch = true;
+ m_page->dragController()->dragExited(&dragData);
+ m_dragTargetDispatch = false;
+
+ m_currentDragData = 0;
+ m_dropEffect = DropEffectDefault;
+ m_dragOperation = WebDragOperationNone;
+ m_dragIdentity = 0;
+}
+
+void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
+ const WebPoint& screenPoint)
+{
+ ASSERT(m_currentDragData.get());
+
+ // If this webview transitions from the "drop accepting" state to the "not
+ // accepting" state, then our IPC message reply indicating that may be in-
+ // flight, or else delayed by javascript processing in this webview. If a
+ // drop happens before our IPC reply has reached the browser process, then
+ // the browser forwards the drop to this webview. So only allow a drop to
+ // proceed if our webview m_dragOperation state is not DragOperationNone.
+
+ if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
+ dragTargetDragLeave();
+ return;
+ }
+
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_dragTargetDispatch = true;
+ m_page->dragController()->performDrag(&dragData);
+ m_dragTargetDispatch = false;
+
+ m_currentDragData = 0;
+ m_dropEffect = DropEffectDefault;
+ m_dragOperation = WebDragOperationNone;
+ m_dragIdentity = 0;
+ m_dragScrollTimer->stop();
+}
+
+int WebViewImpl::dragIdentity()
+{
+ if (m_dragTargetDispatch)
+ return m_dragIdentity;
+ return 0;
+}
+
+WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPoint, const WebPoint& screenPoint, DragAction dragAction)
+{
+ ASSERT(m_currentDragData.get());
+
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_dropEffect = DropEffectDefault;
+ m_dragTargetDispatch = true;
+ DragOperation effect = dragAction == DragEnter ? m_page->dragController()->dragEntered(&dragData)
+ : m_page->dragController()->dragUpdated(&dragData);
+ // Mask the operation against the drag source's allowed operations.
+ if (!(effect & dragData.draggingSourceOperationMask()))
+ effect = DragOperationNone;
+ m_dragTargetDispatch = false;
+
+ if (m_dropEffect != DropEffectDefault) {
+ m_dragOperation = (m_dropEffect != DropEffectNone) ? WebDragOperationCopy
+ : WebDragOperationNone;
+ } else
+ m_dragOperation = static_cast<WebDragOperation>(effect);
+
+ if (dragAction == DragOver)
+ m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);
+ else
+ m_dragScrollTimer->stop();
+
+
+ return m_dragOperation;
+}
+
+unsigned long WebViewImpl::createUniqueIdentifierForRequest()
+{
+ if (m_page)
+ return m_page->progress()->createUniqueIdentifier();
+ return 0;
+}
+
+void WebViewImpl::inspectElementAt(const WebPoint& point)
+{
+ if (!m_page.get())
+ return;
+
+ if (point.x == -1 || point.y == -1)
+ m_page->inspectorController()->inspect(0);
+ else {
+ HitTestResult result = hitTestResultForWindowPos(point);
+
+ if (!result.innerNonSharedNode())
+ return;
+
+ m_page->inspectorController()->inspect(result.innerNonSharedNode());
+ }
+}
+
+WebString WebViewImpl::inspectorSettings() const
+{
+ return m_inspectorSettings;
+}
+
+void WebViewImpl::setInspectorSettings(const WebString& settings)
+{
+ m_inspectorSettings = settings;
+}
+
+bool WebViewImpl::inspectorSetting(const WebString& key, WebString* value) const
+{
+ if (!m_inspectorSettingsMap->contains(key))
+ return false;
+ *value = m_inspectorSettingsMap->get(key);
+ return true;
+}
+
+void WebViewImpl::setInspectorSetting(const WebString& key,
+ const WebString& value)
+{
+ m_inspectorSettingsMap->set(key, value);
+ client()->didUpdateInspectorSetting(key, value);
+}
+
+WebDevToolsAgent* WebViewImpl::devToolsAgent()
+{
+ return m_devToolsAgent.get();
+}
+
+WebAccessibilityObject WebViewImpl::accessibilityObject()
+{
+ if (!mainFrameImpl())
+ return WebAccessibilityObject();
+
+ Document* document = mainFrameImpl()->frame()->document();
+ return WebAccessibilityObject(
+ document->axObjectCache()->getOrCreate(document->renderer()));
+}
+
+void WebViewImpl::applyAutoFillSuggestions(
+ const WebNode& node,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& uniqueIDs,
+ int separatorIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == uniqueIDs.size());
+ ASSERT(separatorIndex < static_cast<int>(names.size()));
+
+ if (names.isEmpty()) {
+ hideAutoFillPopup();
+ return;
+ }
+
+ RefPtr<Node> focusedNode = focusedWebCoreNode();
+ // If the node for which we queried the AutoFill suggestions is not the
+ // focused node, then we have nothing to do. FIXME: also check the
+ // caret is at the end and that the text has not changed.
+ if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) {
+ hideAutoFillPopup();
+ return;
+ }
+
+ HTMLInputElement* inputElem =
+ static_cast<HTMLInputElement*>(focusedNode.get());
+
+ // The first time the AutoFill popup is shown we'll create the client and
+ // the popup.
+ if (!m_autoFillPopupClient.get())
+ m_autoFillPopupClient.set(new AutoFillPopupMenuClient);
+
+ m_autoFillPopupClient->initialize(
+ inputElem, names, labels, icons, uniqueIDs, separatorIndex);
+
+ if (!m_autoFillPopup.get()) {
+ m_autoFillPopup = PopupContainer::create(m_autoFillPopupClient.get(),
+ PopupContainer::Suggestion,
+ autoFillPopupSettings);
+ }
+
+ if (m_autoFillPopupShowing) {
+ refreshAutoFillPopup();
+ } else {
+ m_autoFillPopup->show(focusedNode->getRect(), focusedNode->ownerDocument()->view(), 0);
+ m_autoFillPopupShowing = true;
+ }
+}
+
+void WebViewImpl::hidePopups()
+{
+ hideSelectPopup();
+ hideAutoFillPopup();
+}
+
+void WebViewImpl::performCustomContextMenuAction(unsigned action)
+{
+ if (!m_page)
+ return;
+ ContextMenu* menu = m_page->contextMenuController()->contextMenu();
+ if (!menu)
+ return;
+ ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + action));
+ if (item)
+ m_page->contextMenuController()->contextMenuItemSelected(item);
+ m_page->contextMenuController()->clearContextMenu();
+}
+
+// WebView --------------------------------------------------------------------
+
+bool WebViewImpl::setDropEffect(bool accept)
+{
+ if (m_dragTargetDispatch) {
+ m_dropEffect = accept ? DropEffectCopy : DropEffectNone;
+ return true;
+ }
+ return false;
+}
+
+void WebViewImpl::setIsTransparent(bool isTransparent)
+{
+ // Set any existing frames to be transparent.
+ Frame* frame = m_page->mainFrame();
+ while (frame) {
+ frame->view()->setTransparent(isTransparent);
+ frame = frame->tree()->traverseNext();
+ }
+
+ // Future frames check this to know whether to be transparent.
+ m_isTransparent = isTransparent;
+}
+
+bool WebViewImpl::isTransparent() const
+{
+ return m_isTransparent;
+}
+
+void WebViewImpl::setIsActive(bool active)
+{
+ if (page() && page()->focusController())
+ page()->focusController()->setActive(active);
+}
+
+bool WebViewImpl::isActive() const
+{
+ return (page() && page()->focusController()) ? page()->focusController()->isActive() : false;
+}
+
+void WebViewImpl::setDomainRelaxationForbidden(bool forbidden, const WebString& scheme)
+{
+ SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(forbidden, String(scheme));
+}
+
+void WebViewImpl::setScrollbarColors(unsigned inactiveColor,
+ unsigned activeColor,
+ unsigned trackColor) {
+#if OS(LINUX) || OS(FREEBSD)
+ PlatformThemeChromiumGtk::setScrollbarColors(inactiveColor,
+ activeColor,
+ trackColor);
+#endif
+}
+
+void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor,
+ unsigned activeForegroundColor,
+ unsigned inactiveBackgroundColor,
+ unsigned inactiveForegroundColor) {
+#if OS(LINUX) || OS(FREEBSD)
+ RenderThemeChromiumLinux::setSelectionColors(activeBackgroundColor,
+ activeForegroundColor,
+ inactiveBackgroundColor,
+ inactiveForegroundColor);
+ theme()->platformColorsDidChange();
+#endif
+}
+
+void WebView::addUserScript(const WebString& sourceCode,
+ const WebVector<WebString>& patternsIn,
+ WebView::UserScriptInjectAt injectAt,
+ WebView::UserContentInjectIn injectIn)
+{
+ OwnPtr<Vector<String> > patterns(new Vector<String>);
+ for (size_t i = 0; i < patternsIn.size(); ++i)
+ patterns->append(patternsIn[i]);
+
+ PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
+ RefPtr<DOMWrapperWorld> world(DOMWrapperWorld::create());
+ pageGroup->addUserScriptToWorld(world.get(), sourceCode, WebURL(), patterns.release(), 0,
+ static_cast<UserScriptInjectionTime>(injectAt),
+ static_cast<UserContentInjectedFrames>(injectIn));
+}
+
+void WebView::addUserStyleSheet(const WebString& sourceCode,
+ const WebVector<WebString>& patternsIn,
+ WebView::UserContentInjectIn injectIn,
+ WebView::UserStyleInjectionTime injectionTime)
+{
+ OwnPtr<Vector<String> > patterns(new Vector<String>);
+ for (size_t i = 0; i < patternsIn.size(); ++i)
+ patterns->append(patternsIn[i]);
+
+ PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
+ RefPtr<DOMWrapperWorld> world(DOMWrapperWorld::create());
+
+ // FIXME: Current callers always want the level to be "author". It probably makes sense to let
+ // callers specify this though, since in other cases the caller will probably want "user" level.
+ //
+ // FIXME: It would be nice to populate the URL correctly, instead of passing an empty URL.
+ pageGroup->addUserStyleSheetToWorld(world.get(), sourceCode, WebURL(), patterns.release(), 0,
+ static_cast<UserContentInjectedFrames>(injectIn),
+ UserStyleAuthorLevel,
+ static_cast<WebCore::UserStyleInjectionTime>(injectionTime));
+}
+
+void WebView::removeAllUserContent()
+{
+ PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
+ pageGroup->removeAllUserContent();
+}
+
+void WebViewImpl::didCommitLoad(bool* isNewNavigation)
+{
+ if (isNewNavigation)
+ *isNewNavigation = m_observedNewNavigation;
+
+#ifndef NDEBUG
+ ASSERT(!m_observedNewNavigation
+ || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoader);
+ m_newNavigationLoader = 0;
+#endif
+ m_observedNewNavigation = false;
+}
+
+bool WebViewImpl::useExternalPopupMenus()
+{
+ return shouldUseExternalPopupMenus;
+}
+
+bool WebViewImpl::navigationPolicyFromMouseEvent(unsigned short button,
+ bool ctrl, bool shift,
+ bool alt, bool meta,
+ WebNavigationPolicy* policy)
+{
+#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD) || OS(SOLARIS)
+ const bool newTabModifier = (button == 1) || ctrl;
+#elif OS(DARWIN)
+ const bool newTabModifier = (button == 1) || meta;
+#endif
+ if (!newTabModifier && !shift && !alt)
+ return false;
+
+ ASSERT(policy);
+ if (newTabModifier) {
+ if (shift)
+ *policy = WebNavigationPolicyNewForegroundTab;
+ else
+ *policy = WebNavigationPolicyNewBackgroundTab;
+ } else {
+ if (shift)
+ *policy = WebNavigationPolicyNewWindow;
+ else
+ *policy = WebNavigationPolicyDownload;
+ }
+ return true;
+}
+
+void WebViewImpl::startDragging(const WebDragData& dragData,
+ WebDragOperationsMask mask,
+ const WebImage& dragImage,
+ const WebPoint& dragImageOffset)
+{
+ if (!m_client)
+ return;
+ ASSERT(!m_doingDragAndDrop);
+ m_doingDragAndDrop = true;
+ m_client->startDragging(dragData, mask, dragImage, dragImageOffset);
+}
+
+void WebViewImpl::observeNewNavigation()
+{
+ m_observedNewNavigation = true;
+#ifndef NDEBUG
+ m_newNavigationLoader = m_page->mainFrame()->loader()->documentLoader();
+#endif
+}
+
+void WebViewImpl::setIgnoreInputEvents(bool newValue)
+{
+ ASSERT(m_ignoreInputEvents != newValue);
+ m_ignoreInputEvents = newValue;
+}
+
+#if ENABLE(NOTIFICATIONS)
+NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl()
+{
+ if (!m_notificationPresenter.isInitialized() && m_client)
+ m_notificationPresenter.initialize(m_client->notificationPresenter());
+ return &m_notificationPresenter;
+}
+#endif
+
+void WebViewImpl::refreshAutoFillPopup()
+{
+ ASSERT(m_autoFillPopupShowing);
+
+ // Hide the popup if it has become empty.
+ if (!m_autoFillPopupClient->listSize()) {
+ hideAutoFillPopup();
+ return;
+ }
+
+ IntRect oldBounds = m_autoFillPopup->frameRect();
+ m_autoFillPopup->refresh(focusedWebCoreNode()->getRect());
+ IntRect newBounds = m_autoFillPopup->frameRect();
+ // Let's resize the backing window if necessary.
+ if (oldBounds != newBounds) {
+ WebPopupMenuImpl* popupMenu =
+ static_cast<WebPopupMenuImpl*>(m_autoFillPopup->client());
+ if (popupMenu)
+ popupMenu->client()->setWindowRect(newBounds);
+ }
+}
+
+Node* WebViewImpl::focusedWebCoreNode()
+{
+ Frame* frame = m_page->focusController()->focusedFrame();
+ if (!frame)
+ return 0;
+
+ Document* document = frame->document();
+ if (!document)
+ return 0;
+
+ return document->focusedNode();
+}
+
+HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos)
+{
+ IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos));
+ return m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(docPoint, false);
+}
+
+void WebViewImpl::setTabsToLinks(bool enable)
+{
+ m_tabsToLinks = enable;
+}
+
+bool WebViewImpl::tabsToLinks() const
+{
+ return m_tabsToLinks;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+bool WebViewImpl::allowsAcceleratedCompositing()
+{
+ return !m_compositorCreationFailed;
+}
+
+void WebViewImpl::setRootGraphicsLayer(WebCore::PlatformLayer* layer)
+{
+ setIsAcceleratedCompositingActive(layer ? true : false);
+ if (m_layerRenderer)
+ m_layerRenderer->setRootLayer(layer);
+
+ IntRect damagedRect(0, 0, m_size.width, m_size.height);
+ if (m_isAcceleratedCompositingActive)
+ invalidateRootLayerRect(damagedRect);
+ else
+ m_client->didInvalidateRect(damagedRect);
+}
+
+void WebViewImpl::setRootLayerNeedsDisplay()
+{
+ m_client->scheduleComposite();
+}
+
+
+void WebViewImpl::scrollRootLayerRect(const IntSize& scrollDelta, const IntRect& clipRect)
+{
+ setRootLayerNeedsDisplay();
+}
+
+void WebViewImpl::invalidateRootLayerRect(const IntRect& rect)
+{
+ ASSERT(m_layerRenderer);
+
+ if (!page())
+ return;
+
+ FrameView* view = page()->mainFrame()->view();
+ IntRect contentRect = view->visibleContentRect(false);
+ IntRect visibleRect = view->visibleContentRect(true);
+
+ IntRect dirtyRect = view->windowToContents(rect);
+ m_layerRenderer->invalidateRootLayerRect(dirtyRect, visibleRect, contentRect);
+ setRootLayerNeedsDisplay();
+}
+
+
+void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
+{
+ PlatformBridge::histogramEnumeration("GPU.setIsAcceleratedCompositingActive", active * 2 + m_isAcceleratedCompositingActive, 4);
+
+ if (m_isAcceleratedCompositingActive == active)
+ return;
+
+ if (!active) {
+ m_isAcceleratedCompositingActive = false;
+ if (m_layerRenderer)
+ m_layerRenderer->finish(); // finish all GL rendering before we hide the window?
+ m_client->didActivateAcceleratedCompositing(false);
+ } else if (m_layerRenderer) {
+ m_isAcceleratedCompositingActive = true;
+ m_layerRenderer->resizeOnscreenContent(WebCore::IntSize(std::max(1, m_size.width),
+ std::max(1, m_size.height)));
+
+ m_client->didActivateAcceleratedCompositing(true);
+ } else {
+ RefPtr<GraphicsContext3D> context = m_temporaryOnscreenGraphicsContext3D.release();
+ if (!context) {
+ context = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow);
+ if (context)
+ context->reshape(std::max(1, m_size.width), std::max(1, m_size.height));
+ }
+ m_layerRenderer = LayerRendererChromium::create(context.release());
+ if (m_layerRenderer) {
+ m_client->didActivateAcceleratedCompositing(true);
+ m_isAcceleratedCompositingActive = true;
+ m_compositorCreationFailed = false;
+ } else {
+ m_isAcceleratedCompositingActive = false;
+ m_client->didActivateAcceleratedCompositing(false);
+ m_compositorCreationFailed = true;
+ }
+ }
+ if (page())
+ page()->mainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositingActive);
+}
+
+class WebViewImplTilePaintInterface : public TilePaintInterface {
+public:
+ explicit WebViewImplTilePaintInterface(WebViewImpl* webViewImpl)
+ : m_webViewImpl(webViewImpl)
+ {
+ }
+
+ virtual void paint(GraphicsContext& context, const IntRect& contentRect)
+ {
+ Page* page = m_webViewImpl->page();
+ if (!page)
+ return;
+ FrameView* view = page->mainFrame()->view();
+ view->paintContents(&context, contentRect);
+ }
+
+private:
+ WebViewImpl* m_webViewImpl;
+};
+
+
+class WebViewImplScrollbarPaintInterface : public TilePaintInterface {
+public:
+ explicit WebViewImplScrollbarPaintInterface(WebViewImpl* webViewImpl)
+ : m_webViewImpl(webViewImpl)
+ {
+ }
+
+ virtual void paint(GraphicsContext& context, const IntRect& contentRect)
+ {
+ Page* page = m_webViewImpl->page();
+ if (!page)
+ return;
+ FrameView* view = page->mainFrame()->view();
+
+ context.translate(view->scrollX(), view->scrollY());
+ IntRect windowRect = view->contentsToWindow(contentRect);
+ view->paintScrollbars(&context, windowRect);
+ }
+
+private:
+ WebViewImpl* m_webViewImpl;
+};
+
+void WebViewImpl::doComposite()
+{
+ ASSERT(isAcceleratedCompositingActive());
+ if (!page())
+ return;
+ FrameView* view = page()->mainFrame()->view();
+
+ // The visibleRect includes scrollbars whereas the contentRect doesn't.
+ IntRect visibleRect = view->visibleContentRect(true);
+ IntRect contentRect = view->visibleContentRect(false);
+ IntPoint scroll(view->scrollX(), view->scrollY());
+
+ WebViewImplTilePaintInterface tilePaint(this);
+
+ WebViewImplScrollbarPaintInterface scrollbarPaint(this);
+ m_layerRenderer->drawLayers(visibleRect, contentRect, scroll, tilePaint, scrollbarPaint);
+}
+
+void WebViewImpl::reallocateRenderer()
+{
+ GraphicsContext3D* context = m_layerRenderer->context();
+ RefPtr<GraphicsContext3D> newContext = GraphicsContext3D::create(context->getContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow);
+ // GraphicsContext3D::create might fail and return 0, in that case LayerRendererChromium::create will also return 0.
+ RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(newContext);
+
+ // Reattach the root layer. Child layers will get reattached as a side effect of updateLayersRecursive.
+ if (layerRenderer)
+ m_layerRenderer->transferRootLayer(layerRenderer.get());
+ m_layerRenderer = layerRenderer;
+
+ // Enable or disable accelerated compositing and request a refresh.
+ setRootGraphicsLayer(m_layerRenderer ? m_layerRenderer->rootLayer() : 0);
+}
+#endif
+
+
+WebGraphicsContext3D* WebViewImpl::graphicsContext3D()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_page->settings()->acceleratedCompositingEnabled() && allowsAcceleratedCompositing()) {
+ GraphicsContext3D* context = 0;
+ if (m_layerRenderer)
+ context = m_layerRenderer->context();
+ else if (m_temporaryOnscreenGraphicsContext3D)
+ context = m_temporaryOnscreenGraphicsContext3D.get();
+ else {
+ m_temporaryOnscreenGraphicsContext3D = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow);
+ if (m_temporaryOnscreenGraphicsContext3D)
+ m_temporaryOnscreenGraphicsContext3D->reshape(std::max(1, m_size.width), std::max(1, m_size.height));
+ context = m_temporaryOnscreenGraphicsContext3D.get();
+ }
+ return GraphicsContext3DInternal::extractWebGraphicsContext3D(context);
+ }
+#endif
+ return 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h
new file mode 100644
index 0000000..d164a48
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebViewImpl.h
@@ -0,0 +1,554 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebViewImpl_h
+#define WebViewImpl_h
+
+#include "WebNavigationPolicy.h"
+#include "WebPoint.h"
+#include "WebRect.h"
+#include "WebSize.h"
+#include "WebString.h"
+#include "WebView.h"
+
+#include "ChromeClientImpl.h"
+#include "ContextMenuClientImpl.h"
+#include "DragClientImpl.h"
+#include "EditorClientImpl.h"
+#include "GraphicsContext3D.h"
+#include "GraphicsLayer.h"
+#include "InspectorClientImpl.h"
+#include "IntRect.h"
+#include "LayerRendererChromium.h"
+#include "NotificationPresenterImpl.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class ChromiumDataObject;
+class Frame;
+class HistoryItem;
+class HitTestResult;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class PopupContainer;
+class PopupMenuClient;
+class Range;
+class RenderTheme;
+class Widget;
+}
+
+namespace WebKit {
+class AutocompletePopupMenuClient;
+class AutoFillPopupMenuClient;
+class ContextMenuClientImpl;
+class DeviceOrientationClientProxy;
+class DragScrollTimer;
+class GeolocationClientProxy;
+class SpeechInputClientImpl;
+class WebAccessibilityObject;
+class WebDevToolsAgentClient;
+class WebDevToolsAgentPrivate;
+class WebFrameImpl;
+class WebImage;
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebSettingsImpl;
+class WebTouchEvent;
+
+class WebViewImpl : public WebView, public RefCounted<WebViewImpl> {
+public:
+ // WebWidget methods:
+ virtual void close();
+ virtual WebSize size() { return m_size; }
+ virtual void resize(const WebSize&);
+ virtual void animate();
+ virtual void layout();
+ virtual void paint(WebCanvas*, const WebRect&);
+ virtual void themeChanged();
+ virtual void composite(bool finish);
+ virtual bool handleInputEvent(const WebInputEvent&);
+ virtual void mouseCaptureLost();
+ virtual void setFocus(bool enable);
+ virtual bool setComposition(
+ const WebString& text,
+ const WebVector<WebCompositionUnderline>& underlines,
+ int selectionStart,
+ int selectionEnd);
+ virtual bool confirmComposition();
+ virtual bool confirmComposition(const WebString& text);
+ virtual WebTextInputType textInputType();
+ virtual WebRect caretOrSelectionBounds();
+ virtual void setTextDirection(WebTextDirection direction);
+ virtual bool isAcceleratedCompositingActive() const;
+
+ // WebView methods:
+ virtual void initializeMainFrame(WebFrameClient*);
+ virtual WebSettings* settings();
+ virtual WebString pageEncoding() const;
+ virtual void setPageEncoding(const WebString& encoding);
+ virtual bool isTransparent() const;
+ virtual void setIsTransparent(bool value);
+ virtual bool tabsToLinks() const;
+ virtual void setTabsToLinks(bool value);
+ virtual bool tabKeyCyclesThroughElements() const;
+ virtual void setTabKeyCyclesThroughElements(bool value);
+ virtual bool isActive() const;
+ virtual void setIsActive(bool value);
+ virtual void setDomainRelaxationForbidden(bool, const WebString& scheme);
+ virtual bool dispatchBeforeUnloadEvent();
+ virtual void dispatchUnloadEvent();
+ virtual WebFrame* mainFrame();
+ virtual WebFrame* findFrameByName(
+ const WebString& name, WebFrame* relativeToFrame);
+ virtual WebFrame* focusedFrame();
+ virtual void setFocusedFrame(WebFrame* frame);
+ virtual void setInitialFocus(bool reverse);
+ virtual void clearFocusedNode();
+ virtual void scrollFocusedNodeIntoView();
+ virtual double zoomLevel();
+ virtual double setZoomLevel(bool textOnly, double zoomLevel);
+ virtual void zoomLimitsChanged(double minimumZoomLevel,
+ double maximumZoomLevel);
+ virtual void performMediaPlayerAction(
+ const WebMediaPlayerAction& action,
+ const WebPoint& location);
+ virtual void copyImageAt(const WebPoint& point);
+ virtual void dragSourceEndedAt(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation);
+ virtual void dragSourceMovedTo(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation);
+ virtual void dragSourceSystemDragEnded();
+ virtual WebDragOperation dragTargetDragEnter(
+ const WebDragData& dragData, int identity,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed);
+ virtual WebDragOperation dragTargetDragEnterNew(
+ int identity,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed);
+ virtual WebDragOperation dragTargetDragOver(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed);
+ virtual void dragTargetDragLeave();
+ virtual void dragTargetDrop(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint);
+ virtual int dragIdentity();
+ virtual bool setDropEffect(bool accept);
+ virtual unsigned long createUniqueIdentifierForRequest();
+ virtual void inspectElementAt(const WebPoint& point);
+ virtual WebString inspectorSettings() const;
+ virtual void setInspectorSettings(const WebString& settings);
+ virtual bool inspectorSetting(const WebString& key, WebString* value) const;
+ virtual void setInspectorSetting(const WebString& key,
+ const WebString& value);
+ virtual WebDevToolsAgent* devToolsAgent();
+ virtual WebAccessibilityObject accessibilityObject();
+ virtual void applyAutoFillSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& uniqueIDs,
+ int separatorIndex);
+ virtual void hidePopups();
+ virtual void setScrollbarColors(unsigned inactiveColor,
+ unsigned activeColor,
+ unsigned trackColor);
+ virtual void setSelectionColors(unsigned activeBackgroundColor,
+ unsigned activeForegroundColor,
+ unsigned inactiveBackgroundColor,
+ unsigned inactiveForegroundColor);
+ virtual void performCustomContextMenuAction(unsigned action);
+
+ // WebViewImpl
+
+ void setIgnoreInputEvents(bool newValue);
+ WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
+
+ const WebPoint& lastMouseDownPoint() const
+ {
+ return m_lastMouseDownPoint;
+ }
+
+ WebCore::Frame* focusedWebCoreFrame();
+
+ // Returns the currently focused Node or null if no node has focus.
+ WebCore::Node* focusedWebCoreNode();
+
+ static WebViewImpl* fromPage(WebCore::Page*);
+
+ WebViewClient* client()
+ {
+ return m_client;
+ }
+
+ WebAutoFillClient* autoFillClient()
+ {
+ return m_autoFillClient;
+ }
+
+ // Returns the page object associated with this view. This may be null when
+ // the page is shutting down, but will be valid at all other times.
+ WebCore::Page* page() const
+ {
+ return m_page.get();
+ }
+
+ WebCore::RenderTheme* theme() const;
+
+ // Returns the main frame associated with this view. This may be null when
+ // the page is shutting down, but will be valid at all other times.
+ WebFrameImpl* mainFrameImpl();
+
+ // History related methods:
+ void observeNewNavigation();
+
+ // Event related methods:
+ void mouseMove(const WebMouseEvent&);
+ void mouseLeave(const WebMouseEvent&);
+ void mouseDown(const WebMouseEvent&);
+ void mouseUp(const WebMouseEvent&);
+ void mouseContextMenu(const WebMouseEvent&);
+ void mouseDoubleClick(const WebMouseEvent&);
+ bool mouseWheel(const WebMouseWheelEvent&);
+ bool keyEvent(const WebKeyboardEvent&);
+ bool charEvent(const WebKeyboardEvent&);
+ bool touchEvent(const WebTouchEvent&);
+
+ // Handles context menu events orignated via the the keyboard. These
+ // include the VK_APPS virtual key and the Shift+F10 combine. Code is
+ // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
+ // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
+ // significant change in this function is the code to convert from a
+ // Keyboard event to the Right Mouse button down event.
+ bool sendContextMenuEvent(const WebKeyboardEvent&);
+
+ // Notifies the WebView that a load has been committed. isNewNavigation
+ // will be true if a new session history item should be created for that
+ // load.
+ void didCommitLoad(bool* isNewNavigation);
+
+ // Returns true if popup menus should be rendered by the browser, false if
+ // they should be rendered by WebKit (which is the default).
+ static bool useExternalPopupMenus();
+
+ bool contextMenuAllowed() const
+ {
+ return m_contextMenuAllowed;
+ }
+
+ // Set the disposition for how this webview is to be initially shown.
+ void setInitialNavigationPolicy(WebNavigationPolicy policy)
+ {
+ m_initialNavigationPolicy = policy;
+ }
+ WebNavigationPolicy initialNavigationPolicy() const
+ {
+ return m_initialNavigationPolicy;
+ }
+
+ // Determines whether a page should e.g. be opened in a background tab.
+ // Returns false if it has no opinion, in which case it doesn't set *policy.
+ static bool navigationPolicyFromMouseEvent(
+ unsigned short button,
+ bool ctrl,
+ bool shift,
+ bool alt,
+ bool meta,
+ WebNavigationPolicy*);
+
+ // Start a system drag and drop operation.
+ void startDragging(
+ const WebDragData& dragData,
+ WebDragOperationsMask mask,
+ const WebImage& dragImage,
+ const WebPoint& dragImageOffset);
+
+ void autoFillPopupDidHide()
+ {
+ m_autoFillPopupShowing = false;
+ }
+
+#if ENABLE(NOTIFICATIONS)
+ // Returns the provider of desktop notifications.
+ NotificationPresenterImpl* notificationPresenterImpl();
+#endif
+
+ // Tries to scroll a frame or any parent of a frame. Returns true if the view
+ // was scrolled.
+ bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+
+ // Notification that a popup was opened/closed.
+ void popupOpened(WebCore::PopupContainer* popupContainer);
+ void popupClosed(WebCore::PopupContainer* popupContainer);
+
+ void hideAutoFillPopup();
+
+ // Returns the input event we're currently processing. This is used in some
+ // cases where the WebCore DOM event doesn't have the information we need.
+ static const WebInputEvent* currentInputEvent()
+ {
+ return m_currentInputEvent;
+ }
+
+#if USE(ACCELERATED_COMPOSITING)
+ bool allowsAcceleratedCompositing();
+ void setRootGraphicsLayer(WebCore::PlatformLayer*);
+ void setRootLayerNeedsDisplay();
+ void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect);
+ void invalidateRootLayerRect(const WebCore::IntRect&);
+#endif
+
+ // Returns the onscreen 3D context used by the compositor. This is
+ // used by the renderer's code to set up resource sharing between
+ // the compositor's context and subordinate contexts for APIs like
+ // WebGL. Returns 0 if compositing support is not compiled in.
+ virtual WebGraphicsContext3D* graphicsContext3D();
+
+ WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); }
+
+ // Returns true if the event leads to scrolling.
+ static bool mapKeyCodeForScroll(int keyCode,
+ WebCore::ScrollDirection* scrollDirection,
+ WebCore::ScrollGranularity* scrollGranularity);
+
+ // Called by a full frame plugin inside this view to inform it that its
+ // zoom level has been updated. The plugin should only call this function
+ // if the zoom change was triggered by the browser, it's only needed in case
+ // a plugin can update its own zoom, say because of its own UI.
+ void fullFramePluginZoomLevelChanged(double zoomLevel);
+
+private:
+ friend class WebView; // So WebView::Create can call our constructor
+ friend class WTF::RefCounted<WebViewImpl>;
+
+ enum DragAction {
+ DragEnter,
+ DragOver
+ };
+
+ WebViewImpl(WebViewClient*, WebDevToolsAgentClient*, WebAutoFillClient*);
+ ~WebViewImpl();
+
+ // Returns true if the event was actually processed.
+ bool keyEventDefault(const WebKeyboardEvent&);
+
+ // Returns true if the select popup has consumed the event.
+ bool selectPopupHandleKeyEvent(const WebKeyboardEvent&);
+
+ // Returns true if the autocomple has consumed the event.
+ bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
+
+ // Repaints the AutoFill popup. Should be called when the suggestions
+ // have changed. Note that this should only be called when the AutoFill
+ // popup is showing.
+ void refreshAutoFillPopup();
+
+ // Returns true if the view was scrolled.
+ bool scrollViewWithKeyboard(int keyCode, int modifiers);
+
+ void hideSelectPopup();
+
+ // Converts |pos| from window coordinates to contents coordinates and gets
+ // the HitTestResult for it.
+ WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&);
+
+ // Consolidate some common code between starting a drag over a target and
+ // updating a drag over a target. If we're starting a drag, |isEntering|
+ // should be true.
+ WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ DragAction);
+
+#if USE(ACCELERATED_COMPOSITING)
+ void setIsAcceleratedCompositingActive(bool);
+ void doComposite();
+ void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&);
+ void reallocateRenderer();
+#endif
+
+ WebViewClient* m_client;
+ WebAutoFillClient* m_autoFillClient;
+
+ ChromeClientImpl m_chromeClientImpl;
+ ContextMenuClientImpl m_contextMenuClientImpl;
+ DragClientImpl m_dragClientImpl;
+ EditorClientImpl m_editorClientImpl;
+ InspectorClientImpl m_inspectorClientImpl;
+
+ WebSize m_size;
+
+ WebPoint m_lastMousePosition;
+ OwnPtr<WebCore::Page> m_page;
+
+ // This flag is set when a new navigation is detected. It is used to satisfy
+ // the corresponding argument to WebFrameClient::didCommitProvisionalLoad.
+ bool m_observedNewNavigation;
+#ifndef NDEBUG
+ // Used to assert that the new navigation we observed is the same navigation
+ // when we make use of m_observedNewNavigation.
+ const WebCore::DocumentLoader* m_newNavigationLoader;
+#endif
+
+ // An object that can be used to manipulate m_page->settings() without linking
+ // against WebCore. This is lazily allocated the first time GetWebSettings()
+ // is called.
+ OwnPtr<WebSettingsImpl> m_webSettings;
+
+ // A copy of the web drop data object we received from the browser.
+ RefPtr<WebCore::ChromiumDataObject> m_currentDragData;
+
+ // The point relative to the client area where the mouse was last pressed
+ // down. This is used by the drag client to determine what was under the
+ // mouse when the drag was initiated. We need to track this here in
+ // WebViewImpl since DragClient::startDrag does not pass the position the
+ // mouse was at when the drag was initiated, only the current point, which
+ // can be misleading as it is usually not over the element the user actually
+ // dragged by the time a drag is initiated.
+ WebPoint m_lastMouseDownPoint;
+
+ // Keeps track of the current zoom level. 0 means no zoom, positive numbers
+ // mean zoom in, negative numbers mean zoom out.
+ double m_zoomLevel;
+
+ double m_minimumZoomLevel;
+
+ double m_maximumZoomLevel;
+
+ bool m_contextMenuAllowed;
+
+ bool m_doingDragAndDrop;
+
+ bool m_ignoreInputEvents;
+
+ // Webkit expects keyPress events to be suppressed if the associated keyDown
+ // event was handled. Safari implements this behavior by peeking out the
+ // associated WM_CHAR event if the keydown was handled. We emulate
+ // this behavior by setting this flag if the keyDown was handled.
+ bool m_suppressNextKeypressEvent;
+
+ // The policy for how this webview is to be initially shown.
+ WebNavigationPolicy m_initialNavigationPolicy;
+
+ // Represents whether or not this object should process incoming IME events.
+ bool m_imeAcceptEvents;
+
+ // True while dispatching system drag and drop events to drag/drop targets
+ // within this WebView.
+ bool m_dragTargetDispatch;
+
+ // Valid when m_dragTargetDispatch is true; the identity of the drag data
+ // copied from the WebDropData object sent from the browser process.
+ int m_dragIdentity;
+
+ // Valid when m_dragTargetDispatch is true. Used to override the default
+ // browser drop effect with the effects "none" or "copy".
+ enum DragTargetDropEffect {
+ DropEffectDefault = -1,
+ DropEffectNone,
+ DropEffectCopy
+ } m_dropEffect;
+
+ // The available drag operations (copy, move link...) allowed by the source.
+ WebDragOperation m_operationsAllowed;
+
+ // The current drag operation as negotiated by the source and destination.
+ // When not equal to DragOperationNone, the drag data can be dropped onto the
+ // current drop target in this WebView (the drop target can accept the drop).
+ WebDragOperation m_dragOperation;
+
+ // Whether an AutoFill popup is currently showing.
+ bool m_autoFillPopupShowing;
+
+ // The AutoFill popup client.
+ OwnPtr<AutoFillPopupMenuClient> m_autoFillPopupClient;
+
+ // The AutoFill popup.
+ RefPtr<WebCore::PopupContainer> m_autoFillPopup;
+
+ // The popup associated with a select element.
+ RefPtr<WebCore::PopupContainer> m_selectPopup;
+
+ OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
+
+ // Whether the webview is rendering transparently.
+ bool m_isTransparent;
+
+ // Whether the user can press tab to focus links.
+ bool m_tabsToLinks;
+
+ // Inspector settings.
+ WebString m_inspectorSettings;
+
+ typedef HashMap<WTF::String, WTF::String> SettingsMap;
+ OwnPtr<SettingsMap> m_inspectorSettingsMap;
+ OwnPtr<DragScrollTimer> m_dragScrollTimer;
+
+#if ENABLE(NOTIFICATIONS)
+ // The provider of desktop notifications;
+ NotificationPresenterImpl m_notificationPresenter;
+#endif
+
+ // If set, the (plugin) node which has mouse capture.
+ RefPtr<WebCore::Node> m_mouseCaptureNode;
+
+#if USE(ACCELERATED_COMPOSITING)
+ WebCore::IntRect m_rootLayerScrollDamage;
+ RefPtr<WebCore::LayerRendererChromium> m_layerRenderer;
+ bool m_isAcceleratedCompositingActive;
+ bool m_compositorCreationFailed;
+#endif
+ static const WebInputEvent* m_currentInputEvent;
+
+#if ENABLE(INPUT_SPEECH)
+ OwnPtr<SpeechInputClientImpl> m_speechInputClient;
+#endif
+ // If we attempt to fetch the on-screen GraphicsContext3D before
+ // the compositor has been turned on, we need to instantiate it
+ // early. This member holds on to the GC3D in this case.
+ RefPtr<WebCore::GraphicsContext3D> m_temporaryOnscreenGraphicsContext3D;
+ OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
+ OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebWorkerBase.cpp b/Source/WebKit/chromium/src/WebWorkerBase.cpp
new file mode 100644
index 0000000..06eb7b1
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebWorkerBase.cpp
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebWorkerBase.h"
+
+#include "CrossThreadTask.h"
+#include "DatabaseTask.h"
+#include "MessagePortChannel.h"
+#include "PlatformMessagePortChannel.h"
+
+#include "WebDataSourceImpl.h"
+#include "WebFileError.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebMessagePortChannel.h"
+#include "WebRuntimeFeatures.h"
+#include "WebSettings.h"
+#include "WebView.h"
+#include "WebWorkerClient.h"
+
+#include "WorkerContext.h"
+#include "WorkerFileSystemCallbacksBridge.h"
+#include "WorkerScriptController.h"
+#include "WorkerThread.h"
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if ENABLE(WORKERS)
+
+static const char allowDatabaseMode[] = "allowDatabaseMode";
+static const char openFileSystemMode[] = "openFileSystemMode";
+
+namespace {
+
+// This class is used to route the result of the WebWorkerBase::allowDatabase
+// call back to the worker context.
+class AllowDatabaseMainThreadBridge : public ThreadSafeShared<AllowDatabaseMainThreadBridge> {
+public:
+ static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebWorkerBase* worker, const WTF::String& mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
+ {
+ return adoptRef(new AllowDatabaseMainThreadBridge(worker, mode, commonClient, frame, name, displayName, estimatedSize));
+ }
+
+ // These methods are invoked on the worker context.
+ void cancel()
+ {
+ MutexLocker locker(m_mutex);
+ m_worker = 0;
+ }
+
+ bool result()
+ {
+ return m_result;
+ }
+
+ // This method is invoked on the main thread.
+ void signalCompleted(bool result)
+ {
+ MutexLocker locker(m_mutex);
+ if (m_worker)
+ m_worker->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), m_mode);
+ }
+
+private:
+ AllowDatabaseMainThreadBridge(WebWorkerBase* worker, const WTF::String& mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
+ : m_worker(worker)
+ , m_mode(mode)
+ {
+ worker->dispatchTaskToMainThread(createCallbackTask(&allowDatabaseTask, commonClient, frame, String(name), String(displayName), estimatedSize, this));
+ }
+
+ static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String name, const WTF::String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
+ {
+ if (!commonClient)
+ bridge->signalCompleted(false);
+ else
+ bridge->signalCompleted(commonClient->allowDatabase(frame, name, displayName, estimatedSize));
+ }
+
+ static void didComplete(WebCore::ScriptExecutionContext* context, PassRefPtr<AllowDatabaseMainThreadBridge> bridge, bool result)
+ {
+ bridge->m_result = result;
+ }
+
+ bool m_result;
+ Mutex m_mutex;
+ WebWorkerBase* m_worker;
+ WTF::String m_mode;
+};
+
+}
+
+// This function is called on the main thread to force to initialize some static
+// values used in WebKit before any worker thread is started. This is because in
+// our worker processs, we do not run any WebKit code in main thread and thus
+// when multiple workers try to start at the same time, we might hit crash due
+// to contention for initializing static values.
+static void initializeWebKitStaticValues()
+{
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ // Note that we have to pass a URL with valid protocol in order to follow
+ // the path to do static value initializations.
+ RefPtr<SecurityOrigin> origin =
+ SecurityOrigin::create(KURL(ParsedURLString, "http://localhost"));
+ origin.release();
+ }
+}
+
+WebWorkerBase::WebWorkerBase()
+ : m_webView(0)
+ , m_askedToTerminate(false)
+{
+ initializeWebKitStaticValues();
+}
+
+WebWorkerBase::~WebWorkerBase()
+{
+ ASSERT(m_webView);
+ WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+ if (webFrame)
+ webFrame->setClient(0);
+ m_webView->close();
+}
+
+void WebWorkerBase::stopWorkerThread()
+{
+ if (m_askedToTerminate)
+ return;
+ m_askedToTerminate = true;
+ if (m_workerThread)
+ m_workerThread->stop();
+}
+
+void WebWorkerBase::initializeLoader(const WebURL& url)
+{
+ // Create 'shadow page'. This page is never displayed, it is used to proxy the
+ // loading requests from the worker context to the rest of WebKit and Chromium
+ // infrastructure.
+ ASSERT(!m_webView);
+ m_webView = WebView::create(0, 0, 0);
+ m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled());
+ m_webView->initializeMainFrame(this);
+
+ WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+
+ // Construct substitute data source for the 'shadow page'. We only need it
+ // to have same origin as the worker so the loading checks work correctly.
+ CString content("");
+ int len = static_cast<int>(content.length());
+ RefPtr<SharedBuffer> buf(SharedBuffer::create(content.data(), len));
+ SubstituteData substData(buf, String("text/html"), String("UTF-8"), KURL());
+ webFrame->frame()->loader()->load(ResourceRequest(url), substData, false);
+
+ // This document will be used as 'loading context' for the worker.
+ m_loadingDocument = webFrame->frame()->document();
+}
+
+void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+ callOnMainThread(invokeTaskMethod, task.leakPtr());
+}
+
+void WebWorkerBase::invokeTaskMethod(void* param)
+{
+ ScriptExecutionContext::Task* task =
+ static_cast<ScriptExecutionContext::Task*>(param);
+ task->performTask(0);
+ delete task;
+}
+
+void WebWorkerBase::didCreateDataSource(WebFrame*, WebDataSource* ds)
+{
+ // Tell the loader to load the data into the 'shadow page' synchronously,
+ // so we can grab the resulting Document right after load.
+ static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false);
+}
+
+WebApplicationCacheHost* WebWorkerBase::createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient* appcacheHostClient)
+{
+ if (commonClient())
+ return commonClient()->createApplicationCacheHost(appcacheHostClient);
+ return 0;
+}
+
+bool WebWorkerBase::allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
+{
+ WorkerRunLoop& runLoop = m_workerThread->runLoop();
+ WorkerScriptController* controller = WorkerScriptController::controllerForContext();
+ WorkerContext* workerContext = controller->workerContext();
+
+ // Create a unique mode just for this synchronous call.
+ String mode = allowDatabaseMode;
+ mode.append(String::number(runLoop.createUniqueId()));
+
+ RefPtr<AllowDatabaseMainThreadBridge> bridge = AllowDatabaseMainThreadBridge::create(this, mode, commonClient(), m_webView->mainFrame(), String(name), String(displayName), estimatedSize);
+
+ // Either the bridge returns, or the queue gets terminated.
+ if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated) {
+ bridge->cancel();
+ return false;
+ }
+
+ return bridge->result();
+}
+
+#if ENABLE(FILE_SYSTEM)
+void WebWorkerBase::openFileSystem(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks, bool synchronous)
+{
+ WorkerRunLoop& runLoop = m_workerThread->runLoop();
+ WorkerScriptController* controller = WorkerScriptController::controllerForContext();
+ WorkerContext* workerContext = controller->workerContext();
+
+ // Create a unique mode for this openFileSystem call.
+ String mode = openFileSystemMode;
+ mode.append(String::number(runLoop.createUniqueId()));
+
+ RefPtr<WorkerFileSystemCallbacksBridge> bridge = WorkerFileSystemCallbacksBridge::create(this, workerContext, callbacks);
+ bridge->postOpenFileSystemToMainThread(commonClient(), type, size, mode);
+
+ if (synchronous) {
+ if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated)
+ bridge->stop();
+ }
+}
+#endif
+
+// WorkerObjectProxy -----------------------------------------------------------
+
+void WebWorkerBase::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ dispatchTaskToMainThread(createCallbackTask(&postMessageTask, this,
+ message->toWireString(), channels));
+}
+
+void WebWorkerBase::postMessageTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ String message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ if (!thisPtr->client())
+ return;
+
+ WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0);
+ for (size_t i = 0; i < webChannels.size(); ++i) {
+ webChannels[i] = (*channels)[i]->channel()->webChannelRelease();
+ webChannels[i]->setClient(0);
+ }
+
+ thisPtr->client()->postMessageToWorkerObject(message, webChannels);
+}
+
+void WebWorkerBase::postExceptionToWorkerObject(const String& errorMessage,
+ int lineNumber,
+ const String& sourceURL)
+{
+ dispatchTaskToMainThread(createCallbackTask(&postExceptionTask, this,
+ errorMessage, lineNumber,
+ sourceURL));
+}
+
+void WebWorkerBase::postExceptionTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ const String& errorMessage,
+ int lineNumber, const String& sourceURL)
+{
+ if (!thisPtr->commonClient())
+ return;
+
+ thisPtr->commonClient()->postExceptionToWorkerObject(errorMessage,
+ lineNumber,
+ sourceURL);
+}
+
+void WebWorkerBase::postConsoleMessageToWorkerObject(MessageSource source,
+ MessageType type,
+ MessageLevel level,
+ const String& message,
+ int lineNumber,
+ const String& sourceURL)
+{
+ dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, this,
+ source, type, level,
+ message, lineNumber, sourceURL));
+}
+
+void WebWorkerBase::postConsoleMessageTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ int source,
+ int type, int level,
+ const String& message,
+ int lineNumber,
+ const String& sourceURL)
+{
+ if (!thisPtr->commonClient())
+ return;
+ thisPtr->commonClient()->postConsoleMessageToWorkerObject(source,
+ type, level, message,
+ lineNumber, sourceURL);
+}
+
+void WebWorkerBase::confirmMessageFromWorkerObject(bool hasPendingActivity)
+{
+ dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, this,
+ hasPendingActivity));
+}
+
+void WebWorkerBase::confirmMessageTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ bool hasPendingActivity)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->confirmMessageFromWorkerObject(hasPendingActivity);
+}
+
+void WebWorkerBase::reportPendingActivity(bool hasPendingActivity)
+{
+ dispatchTaskToMainThread(createCallbackTask(&reportPendingActivityTask,
+ this, hasPendingActivity));
+}
+
+void WebWorkerBase::reportPendingActivityTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ bool hasPendingActivity)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->reportPendingActivity(hasPendingActivity);
+}
+
+void WebWorkerBase::workerContextClosed()
+{
+ dispatchTaskToMainThread(createCallbackTask(&workerContextClosedTask,
+ this));
+}
+
+void WebWorkerBase::workerContextClosedTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr)
+{
+ if (thisPtr->commonClient())
+ thisPtr->commonClient()->workerContextClosed();
+
+ thisPtr->stopWorkerThread();
+}
+
+void WebWorkerBase::workerContextDestroyed()
+{
+ dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask,
+ this));
+}
+
+void WebWorkerBase::workerContextDestroyedTask(ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr)
+{
+ if (thisPtr->commonClient())
+ thisPtr->commonClient()->workerContextDestroyed();
+ // The lifetime of this proxy is controlled by the worker context.
+ delete thisPtr;
+}
+
+// WorkerLoaderProxy -----------------------------------------------------------
+
+void WebWorkerBase::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+ ASSERT(m_loadingDocument->isDocument());
+ m_loadingDocument->postTask(task);
+}
+
+void WebWorkerBase::postTaskForModeToWorkerContext(
+ PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
+{
+ m_workerThread->runLoop().postTaskForMode(task, mode);
+}
+
+#endif // ENABLE(WORKERS)
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebWorkerBase.h b/Source/WebKit/chromium/src/WebWorkerBase.h
new file mode 100644
index 0000000..fe84bf7
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebWorkerBase.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebWorkerBase_h
+#define WebWorkerBase_h
+
+#if ENABLE(WORKERS)
+
+#include "ScriptExecutionContext.h"
+#include "WebFrameClient.h"
+#include "WorkerLoaderProxy.h"
+#include "WorkerObjectProxy.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class WorkerThread;
+}
+
+namespace WebKit {
+class WebApplicationCacheHost;
+class WebApplicationCacheHostClient;
+class WebCommonWorkerClient;
+class WebSecurityOrigin;
+class WebString;
+class WebURL;
+class WebView;
+class WebWorker;
+class WebWorkerClient;
+
+// Base class for WebSharedWorkerImpl and WebWorkerImpl. It contains common
+// code used by both implementation classes, including implementations of the
+// WorkerObjectProxy and WorkerLoaderProxy interfaces.
+class WebWorkerBase : public WebCore::WorkerObjectProxy
+ , public WebCore::WorkerLoaderProxy
+ , public WebFrameClient {
+public:
+ WebWorkerBase();
+ virtual ~WebWorkerBase();
+
+ // WebCore::WorkerObjectProxy methods:
+ virtual void postMessageToWorkerObject(
+ PassRefPtr<WebCore::SerializedScriptValue>,
+ PassOwnPtr<WebCore::MessagePortChannelArray>);
+ virtual void postExceptionToWorkerObject(
+ const WTF::String&, int, const WTF::String&);
+ virtual void postConsoleMessageToWorkerObject(
+ WebCore::MessageSource, WebCore::MessageType,
+ WebCore::MessageLevel, const WTF::String&, int, const WTF::String&);
+ virtual void confirmMessageFromWorkerObject(bool);
+ virtual void reportPendingActivity(bool);
+ virtual void workerContextClosed();
+ virtual void workerContextDestroyed();
+
+ // WebCore::WorkerLoaderProxy methods:
+ virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+ virtual void postTaskForModeToWorkerContext(
+ PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode);
+
+ // WebFrameClient methods to support resource loading thru the 'shadow page'.
+ virtual void didCreateDataSource(WebFrame*, WebDataSource*);
+ virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient*);
+
+ // Controls whether access to Web Databases is allowed for this worker.
+ virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize);
+
+#if ENABLE(FILE_SYSTEM)
+ // Requests to open a file system for this worker. (Note that this is not the implementation for WebFrameClient::openFileSystem.)
+ void openFileSystem(WebFileSystem::Type, long long size, WebFileSystemCallbacks*, bool synchronous);
+#endif
+
+ // Executes the given task on the main thread.
+ static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+
+protected:
+ virtual WebWorkerClient* client() = 0;
+ virtual WebCommonWorkerClient* commonClient() = 0;
+
+ void setWorkerThread(PassRefPtr<WebCore::WorkerThread> thread) { m_workerThread = thread; }
+ WebCore::WorkerThread* workerThread() { return m_workerThread.get(); }
+
+ // Shuts down the worker thread.
+ void stopWorkerThread();
+
+ // Creates the shadow loader used for worker network requests.
+ void initializeLoader(const WebURL&);
+
+private:
+ // Function used to invoke tasks on the main thread.
+ static void invokeTaskMethod(void*);
+
+ // Tasks that are run on the main thread.
+ static void postMessageTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ WTF::String message,
+ PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+ static void postExceptionTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ const WTF::String& message,
+ int lineNumber,
+ const WTF::String& sourceURL);
+ static void postConsoleMessageTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ int source,
+ int type,
+ int level,
+ const WTF::String& message,
+ int lineNumber,
+ const WTF::String& sourceURL);
+ static void confirmMessageTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ bool hasPendingActivity);
+ static void reportPendingActivityTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr,
+ bool hasPendingActivity);
+ static void workerContextClosedTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr);
+ static void workerContextDestroyedTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerBase* thisPtr);
+
+ // 'shadow page' - created to proxy loading requests from the worker.
+ RefPtr<WebCore::ScriptExecutionContext> m_loadingDocument;
+ WebView* m_webView;
+ bool m_askedToTerminate;
+
+ RefPtr<WebCore::WorkerThread> m_workerThread;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WORKERS)
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp
new file mode 100644
index 0000000..f90e7e8
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp
@@ -0,0 +1,418 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebWorkerClientImpl.h"
+
+#if ENABLE(WORKERS)
+
+#include "CrossThreadTask.h"
+#include "DedicatedWorkerThread.h"
+#include "ErrorEvent.h"
+#include "Frame.h"
+#include "FrameLoaderClient.h"
+#include "MessageEvent.h"
+#include "MessagePort.h"
+#include "MessagePortChannel.h"
+#include "ScriptCallStack.h"
+#include "ScriptExecutionContext.h"
+#include "Worker.h"
+#include "WorkerContext.h"
+#include "WorkerContextExecutionProxy.h"
+#include "WorkerScriptController.h"
+#include "WorkerMessagingProxy.h"
+#include <wtf/Threading.h>
+
+#include "FrameLoaderClientImpl.h"
+#include "PlatformMessagePortChannel.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebMessagePortChannel.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebViewImpl.h"
+#include "WebWorker.h"
+#include "WebWorkerImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// When WebKit creates a WorkerContextProxy object, we check if we're in the
+// renderer or worker process. If the latter, then we just use
+// WorkerMessagingProxy.
+//
+// If we're in the renderer process, then we need use the glue provided
+// WebWorker object to talk to the worker process over IPC. The worker process
+// talks to Worker* using WorkerObjectProxy, which we implement on
+// WebWorkerClientImpl.
+//
+// Note that if we're running each worker in a separate process, then nested
+// workers end up using the same codepath as the renderer process.
+
+// static
+WorkerContextProxy* WebWorkerClientImpl::createWorkerContextProxy(Worker* worker)
+{
+ // Special behavior for multiple workers per process.
+ // FIXME: v8 doesn't support more than one workers per process.
+ // if (!worker->scriptExecutionContext()->isDocument())
+ // return new WorkerMessagingProxy(worker);
+
+ WebWorker* webWorker = 0;
+ WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker);
+
+ if (worker->scriptExecutionContext()->isDocument()) {
+ Document* document = static_cast<Document*>(
+ worker->scriptExecutionContext());
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ webWorker = webFrame->client()->createWorker(webFrame, proxy);
+ } else {
+ WorkerScriptController* controller = WorkerScriptController::controllerForContext();
+ if (!controller) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+
+ DedicatedWorkerThread* thread = static_cast<DedicatedWorkerThread*>(controller->workerContext()->thread());
+ WorkerObjectProxy* workerObjectProxy = &thread->workerObjectProxy();
+ WebWorkerImpl* impl = reinterpret_cast<WebWorkerImpl*>(workerObjectProxy);
+ webWorker = impl->client()->createWorker(proxy);
+ }
+
+ proxy->setWebWorker(webWorker);
+ return proxy;
+}
+
+WebWorkerClientImpl::WebWorkerClientImpl(Worker* worker)
+ : m_scriptExecutionContext(worker->scriptExecutionContext())
+ , m_worker(worker)
+ , m_askedToTerminate(false)
+ , m_unconfirmedMessageCount(0)
+ , m_workerContextHadPendingActivity(false)
+ , m_workerThreadId(currentThread())
+{
+}
+
+WebWorkerClientImpl::~WebWorkerClientImpl()
+{
+}
+
+void WebWorkerClientImpl::setWebWorker(WebWorker* webWorker)
+{
+ m_webWorker = webWorker;
+}
+
+void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL,
+ const String& userAgent,
+ const String& sourceCode)
+{
+ // Worker.terminate() could be called from JS before the context is started.
+ if (m_askedToTerminate)
+ return;
+ if (!isMainThread()) {
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(
+ &startWorkerContextTask,
+ this,
+ scriptURL.string(),
+ userAgent,
+ sourceCode));
+ return;
+ }
+ m_webWorker->startWorkerContext(scriptURL, userAgent, sourceCode);
+}
+
+void WebWorkerClientImpl::terminateWorkerContext()
+{
+ if (m_askedToTerminate)
+ return;
+ m_askedToTerminate = true;
+ if (!isMainThread()) {
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&terminateWorkerContextTask, this));
+ return;
+ }
+ m_webWorker->terminateWorkerContext();
+}
+
+void WebWorkerClientImpl::postMessageToWorkerContext(
+ PassRefPtr<SerializedScriptValue> message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ // Worker.terminate() could be called from JS before the context is started.
+ if (m_askedToTerminate)
+ return;
+ ++m_unconfirmedMessageCount;
+ if (!isMainThread()) {
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToWorkerContextTask,
+ this,
+ message->toWireString(),
+ channels));
+ return;
+ }
+ WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0);
+ for (size_t i = 0; i < webChannels.size(); ++i) {
+ WebMessagePortChannel* webchannel =
+ (*channels)[i]->channel()->webChannelRelease();
+ webchannel->setClient(0);
+ webChannels[i] = webchannel;
+ }
+ m_webWorker->postMessageToWorkerContext(message->toWireString(), webChannels);
+}
+
+bool WebWorkerClientImpl::hasPendingActivity() const
+{
+ return !m_askedToTerminate
+ && (m_unconfirmedMessageCount || m_workerContextHadPendingActivity);
+}
+
+void WebWorkerClientImpl::workerObjectDestroyed()
+{
+ if (isMainThread()) {
+ m_webWorker->workerObjectDestroyed();
+ m_worker = 0;
+ }
+ // Even if this is called on the main thread, there could be a queued task for
+ // this object, so don't delete it right away.
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerObjectDestroyedTask,
+ this));
+}
+
+void WebWorkerClientImpl::postMessageToWorkerObject(const WebString& message,
+ const WebMessagePortChannelArray& channels)
+{
+ OwnPtr<MessagePortChannelArray> channels2;
+ if (channels.size()) {
+ channels2 = new MessagePortChannelArray(channels.size());
+ for (size_t i = 0; i < channels.size(); ++i) {
+ RefPtr<PlatformMessagePortChannel> platform_channel =
+ PlatformMessagePortChannel::create(channels[i]);
+ channels[i]->setClient(platform_channel.get());
+ (*channels2)[i] = MessagePortChannel::create(platform_channel);
+ }
+ }
+
+ if (currentThread() != m_workerThreadId) {
+ m_scriptExecutionContext->postTask(createCallbackTask(&postMessageToWorkerObjectTask,
+ this,
+ String(message),
+ channels2.release()));
+ return;
+ }
+
+ postMessageToWorkerObjectTask(m_scriptExecutionContext.get(), this,
+ message, channels2.release());
+}
+
+void WebWorkerClientImpl::postExceptionToWorkerObject(const WebString& errorMessage,
+ int lineNumber,
+ const WebString& sourceURL)
+{
+ if (currentThread() != m_workerThreadId) {
+ m_scriptExecutionContext->postTask(createCallbackTask(&postExceptionToWorkerObjectTask,
+ this,
+ String(errorMessage),
+ lineNumber,
+ String(sourceURL)));
+ return;
+ }
+
+ bool unhandled = m_worker->dispatchEvent(ErrorEvent::create(errorMessage,
+ sourceURL,
+ lineNumber));
+ if (unhandled)
+ m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0);
+}
+
+void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destination,
+ int sourceId,
+ int messageType,
+ int messageLevel,
+ const WebString& message,
+ int lineNumber,
+ const WebString& sourceURL)
+{
+ if (currentThread() != m_workerThreadId) {
+ m_scriptExecutionContext->postTask(createCallbackTask(&postConsoleMessageToWorkerObjectTask,
+ this,
+ sourceId,
+ messageType,
+ messageLevel,
+ String(message),
+ lineNumber,
+ String(sourceURL)));
+ return;
+ }
+
+ m_scriptExecutionContext->addMessage(static_cast<MessageSource>(sourceId),
+ static_cast<MessageType>(messageType),
+ static_cast<MessageLevel>(messageLevel),
+ String(message), lineNumber,
+ String(sourceURL), 0);
+}
+
+void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int sourceId,
+ int messageType,
+ int messageLevel,
+ const WebString& message,
+ int lineNumber,
+ const WebString& sourceURL)
+{
+ postConsoleMessageToWorkerObject(0, sourceId, messageType, messageLevel, message, lineNumber, sourceURL);
+}
+
+void WebWorkerClientImpl::confirmMessageFromWorkerObject(bool hasPendingActivity)
+{
+ // unconfirmed_message_count_ can only be updated on the thread where it's
+ // accessed. Otherwise there are race conditions with v8's garbage
+ // collection.
+ m_scriptExecutionContext->postTask(createCallbackTask(&confirmMessageFromWorkerObjectTask,
+ this));
+}
+
+void WebWorkerClientImpl::reportPendingActivity(bool hasPendingActivity)
+{
+ // See above comment in confirmMessageFromWorkerObject.
+ m_scriptExecutionContext->postTask(createCallbackTask(&reportPendingActivityTask,
+ this,
+ hasPendingActivity));
+}
+
+void WebWorkerClientImpl::workerContextDestroyed()
+{
+}
+
+void WebWorkerClientImpl::workerContextClosed()
+{
+}
+
+void WebWorkerClientImpl::startWorkerContextTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const String& scriptURL,
+ const String& userAgent,
+ const String& sourceCode)
+{
+ thisPtr->m_webWorker->startWorkerContext(KURL(ParsedURLString, scriptURL),
+ userAgent, sourceCode);
+}
+
+void WebWorkerClientImpl::terminateWorkerContextTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr)
+{
+ thisPtr->m_webWorker->terminateWorkerContext();
+}
+
+void WebWorkerClientImpl::postMessageToWorkerContextTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const String& message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0);
+
+ for (size_t i = 0; i < webChannels.size(); ++i) {
+ webChannels[i] = (*channels)[i]->channel()->webChannelRelease();
+ webChannels[i]->setClient(0);
+ }
+
+ thisPtr->m_webWorker->postMessageToWorkerContext(message, webChannels);
+}
+
+void WebWorkerClientImpl::workerObjectDestroyedTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr)
+{
+ if (thisPtr->m_worker) // Check we haven't alread called this.
+ thisPtr->m_webWorker->workerObjectDestroyed();
+ delete thisPtr;
+}
+
+void WebWorkerClientImpl::postMessageToWorkerObjectTask(
+ ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const String& message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+
+ if (thisPtr->m_worker) {
+ OwnPtr<MessagePortArray> ports =
+ MessagePort::entanglePorts(*context, channels);
+ RefPtr<SerializedScriptValue> serializedMessage =
+ SerializedScriptValue::createFromWire(message);
+ thisPtr->m_worker->dispatchEvent(MessageEvent::create(ports.release(),
+ serializedMessage.release()));
+ }
+}
+
+void WebWorkerClientImpl::postExceptionToWorkerObjectTask(
+ ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const String& errorMessage,
+ int lineNumber,
+ const String& sourceURL)
+{
+ bool handled = false;
+ if (thisPtr->m_worker)
+ handled = thisPtr->m_worker->dispatchEvent(ErrorEvent::create(errorMessage,
+ sourceURL,
+ lineNumber));
+ if (!handled)
+ thisPtr->m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0);
+}
+
+void WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ int sourceId,
+ int messageType,
+ int messageLevel,
+ const String& message,
+ int lineNumber,
+ const String& sourceURL)
+{
+ thisPtr->m_scriptExecutionContext->addMessage(static_cast<MessageSource>(sourceId),
+ static_cast<MessageType>(messageType),
+ static_cast<MessageLevel>(messageLevel),
+ message, lineNumber, sourceURL, 0);
+}
+
+void WebWorkerClientImpl::confirmMessageFromWorkerObjectTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr)
+{
+ thisPtr->m_unconfirmedMessageCount--;
+}
+
+void WebWorkerClientImpl::reportPendingActivityTask(ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ bool hasPendingActivity)
+{
+ thisPtr->m_workerContextHadPendingActivity = hasPendingActivity;
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebWorkerClientImpl.h b/Source/WebKit/chromium/src/WebWorkerClientImpl.h
new file mode 100644
index 0000000..0604823
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebWorkerClientImpl.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebWorkerClientImpl_h
+#define WebWorkerClientImpl_h
+
+#if ENABLE(WORKERS)
+
+#include "WebFileSystem.h"
+#include "WebWorkerClient.h"
+#include "WorkerContextProxy.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class ScriptExecutionContext;
+}
+
+namespace WebKit {
+class WebWorker;
+
+// The purpose of this class is to provide a WorkerContextProxy
+// implementation that we can give to WebKit. Internally, it converts the
+// data types to Chrome compatible ones so that renderer code can use it over
+// IPC.
+class WebWorkerClientImpl : public WebCore::WorkerContextProxy
+ , public WebWorkerClient {
+public:
+ WebWorkerClientImpl(WebCore::Worker*);
+
+ // WebCore::WorkerContextProxy Factory.
+ static WebCore::WorkerContextProxy* createWorkerContextProxy(WebCore::Worker*);
+ void setWebWorker(WebWorker*);
+
+ // WebCore::WorkerContextProxy methods:
+ // These are called on the thread that created the worker. In the renderer
+ // process, this will be the main WebKit thread. In the worker process, this
+ // will be the thread of the executing worker (not the main WebKit thread).
+ virtual void startWorkerContext(const WebCore::KURL&,
+ const WTF::String&,
+ const WTF::String&);
+ virtual void terminateWorkerContext();
+ virtual void postMessageToWorkerContext(
+ PassRefPtr<WebCore::SerializedScriptValue> message,
+ PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+ virtual bool hasPendingActivity() const;
+ virtual void workerObjectDestroyed();
+
+ // WebWorkerClient methods:
+ // These are called on the main WebKit thread.
+ virtual void postMessageToWorkerObject(const WebString&, const WebMessagePortChannelArray&);
+ virtual void postExceptionToWorkerObject(const WebString&, int, const WebString&);
+
+ // FIXME: the below is for compatibility only and should be
+ // removed once Chromium is updated to remove message
+ // destination parameter <http://webkit.org/b/37155>.
+ virtual void postConsoleMessageToWorkerObject(int, int, int, int, const WebString&, int, const WebString&);
+ virtual void postConsoleMessageToWorkerObject(int, int, int, const WebString&, int, const WebString&);
+ virtual void confirmMessageFromWorkerObject(bool);
+ virtual void reportPendingActivity(bool);
+ virtual void workerContextClosed();
+ virtual void workerContextDestroyed();
+ virtual WebWorker* createWorker(WebWorkerClient*) { return 0; }
+ virtual WebNotificationPresenter* notificationPresenter()
+ {
+ // FIXME: Notifications not yet supported in workers.
+ return 0;
+ }
+ virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) { return 0; }
+ virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
+ {
+ ASSERT_NOT_REACHED();
+ return true;
+ }
+ virtual void openFileSystem(WebFrame*, WebFileSystem::Type, long long size, WebFileSystemCallbacks*)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+private:
+ virtual ~WebWorkerClientImpl();
+
+ // Methods used to support WebWorkerClientImpl being constructed on worker
+ // threads.
+ // These tasks are dispatched on the WebKit thread.
+ static void startWorkerContextTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const WTF::String& scriptURL,
+ const WTF::String& userAgent,
+ const WTF::String& sourceCode);
+ static void terminateWorkerContextTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr);
+ static void postMessageToWorkerContextTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const WTF::String& message,
+ PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+ static void workerObjectDestroyedTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr);
+
+ // These tasks are dispatched on the thread that created the worker (i.e.
+ // main WebKit thread in renderer process, and the worker thread in the
+ // worker process).
+ static void postMessageToWorkerObjectTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const WTF::String& message,
+ PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+ static void postExceptionToWorkerObjectTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ const WTF::String& message,
+ int lineNumber,
+ const WTF::String& sourceURL);
+ static void postConsoleMessageToWorkerObjectTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ int sourceId,
+ int messageType,
+ int messageLevel,
+ const WTF::String& message,
+ int lineNumber,
+ const WTF::String& sourceURL);
+ static void confirmMessageFromWorkerObjectTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr);
+ static void reportPendingActivityTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerClientImpl* thisPtr,
+ bool hasPendingActivity);
+
+ // Guard against context from being destroyed before a worker exits.
+ RefPtr<WebCore::ScriptExecutionContext> m_scriptExecutionContext;
+
+ WebCore::Worker* m_worker;
+ WebWorker* m_webWorker;
+ bool m_askedToTerminate;
+ unsigned m_unconfirmedMessageCount;
+ bool m_workerContextHadPendingActivity;
+ ThreadIdentifier m_workerThreadId;
+};
+
+} // namespace WebKit;
+
+#endif // ENABLE(WORKERS)
+
+#endif
diff --git a/Source/WebKit/chromium/src/WebWorkerImpl.cpp b/Source/WebKit/chromium/src/WebWorkerImpl.cpp
new file mode 100644
index 0000000..165af68
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebWorkerImpl.cpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebWorkerImpl.h"
+
+#include "CrossThreadTask.h"
+#include "DedicatedWorkerContext.h"
+#include "DedicatedWorkerThread.h"
+#include "KURL.h"
+#include "MessageEvent.h"
+#include "MessagePort.h"
+#include "MessagePortChannel.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+#include "SerializedScriptValue.h"
+#include "SubstituteData.h"
+#include <wtf/Threading.h>
+
+#include "PlatformMessagePortChannel.h"
+#include "WebMessagePortChannel.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebWorkerClient.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if ENABLE(WORKERS)
+
+WebWorker* WebWorker::create(WebWorkerClient* client)
+{
+ return new WebWorkerImpl(client);
+}
+
+
+WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client)
+ : m_client(client)
+{
+}
+
+WebWorkerImpl::~WebWorkerImpl()
+{
+}
+
+WebCommonWorkerClient* WebWorkerImpl::commonClient()
+{
+ return m_client;
+}
+
+void WebWorkerImpl::postMessageToWorkerContextTask(WebCore::ScriptExecutionContext* context,
+ WebWorkerImpl* thisPtr,
+ const String& message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ ASSERT(context->isWorkerContext());
+ DedicatedWorkerContext* workerContext =
+ static_cast<DedicatedWorkerContext*>(context);
+
+ OwnPtr<MessagePortArray> ports =
+ MessagePort::entanglePorts(*context, channels);
+ RefPtr<SerializedScriptValue> serializedMessage =
+ SerializedScriptValue::createFromWire(message);
+ workerContext->dispatchEvent(MessageEvent::create(
+ ports.release(), serializedMessage.release()));
+ thisPtr->confirmMessageFromWorkerObject(workerContext->hasPendingActivity());
+}
+
+// WebWorker -------------------------------------------------------------------
+
+void WebWorkerImpl::startWorkerContext(const WebURL& scriptUrl,
+ const WebString& userAgent,
+ const WebString& sourceCode)
+{
+ initializeLoader(scriptUrl);
+ setWorkerThread(DedicatedWorkerThread::create(scriptUrl, userAgent,
+ sourceCode, *this, *this));
+ // Worker initialization means a pending activity.
+ reportPendingActivity(true);
+ workerThread()->start();
+}
+
+void WebWorkerImpl::terminateWorkerContext()
+{
+ stopWorkerThread();
+}
+
+void WebWorkerImpl::postMessageToWorkerContext(const WebString& message,
+ const WebMessagePortChannelArray& webChannels)
+{
+ OwnPtr<MessagePortChannelArray> channels;
+ if (webChannels.size()) {
+ channels = new MessagePortChannelArray(webChannels.size());
+ for (size_t i = 0; i < webChannels.size(); ++i) {
+ RefPtr<PlatformMessagePortChannel> platform_channel =
+ PlatformMessagePortChannel::create(webChannels[i]);
+ webChannels[i]->setClient(platform_channel.get());
+ (*channels)[i] = MessagePortChannel::create(platform_channel);
+ }
+ }
+
+ workerThread()->runLoop().postTask(
+ createCallbackTask(&postMessageToWorkerContextTask,
+ this, String(message), channels.release()));
+}
+
+void WebWorkerImpl::workerObjectDestroyed()
+{
+ // Worker object in the renderer was destroyed, perhaps a result of GC.
+ // For us, it's a signal to start terminating the WorkerContext too.
+ // FIXME: when 'kill a worker' html5 spec algorithm is implemented, it
+ // should be used here instead of 'terminate a worker'.
+ terminateWorkerContext();
+}
+
+void WebWorkerImpl::clientDestroyed()
+{
+ m_client = 0;
+}
+
+#else
+
+WebWorker* WebWorker::create(WebWorkerClient* client)
+{
+ return 0;
+}
+
+#endif // ENABLE(WORKERS)
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebWorkerImpl.h b/Source/WebKit/chromium/src/WebWorkerImpl.h
new file mode 100644
index 0000000..d2fd016
--- /dev/null
+++ b/Source/WebKit/chromium/src/WebWorkerImpl.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebWorkerImpl_h
+#define WebWorkerImpl_h
+
+#include "WebWorker.h"
+
+#if ENABLE(WORKERS)
+
+#include "ScriptExecutionContext.h"
+
+#include "WebWorkerBase.h"
+
+namespace WebKit {
+class WebView;
+
+// This class is used by the worker process code to talk to the WebCore::Worker
+// implementation. It can't use it directly since it uses WebKit types, so this
+// class converts the data types. When the WebCore::Worker object wants to call
+// WebCore::WorkerObjectProxy, this class will conver to Chrome data types first
+// and then call the supplied WebWorkerClient.
+class WebWorkerImpl : public WebWorkerBase, public WebWorker {
+public:
+ explicit WebWorkerImpl(WebWorkerClient* client);
+
+ // WebWorker methods:
+ virtual void startWorkerContext(const WebURL&, const WebString&, const WebString&);
+ virtual void terminateWorkerContext();
+ virtual void postMessageToWorkerContext(const WebString&, const WebMessagePortChannelArray&);
+ virtual void workerObjectDestroyed();
+ virtual void clientDestroyed();
+
+ // WebWorkerBase methods:
+ virtual WebWorkerClient* client() { return m_client; }
+ virtual WebCommonWorkerClient* commonClient();
+
+private:
+ virtual ~WebWorkerImpl();
+
+ // Tasks that are run on the worker thread.
+ static void postMessageToWorkerContextTask(
+ WebCore::ScriptExecutionContext* context,
+ WebWorkerImpl* thisPtr,
+ const WTF::String& message,
+ PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+
+ WebWorkerClient* m_client;
+
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WORKERS)
+
+#endif
diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
new file mode 100644
index 0000000..058e947
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WorkerAsyncFileSystemChromium.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystemCallbacks.h"
+#include "FileMetadata.h"
+#include "FileSystem.h"
+#include "NotImplemented.h"
+#include "WebFileSystem.h"
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebFileWriter.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebWorkerBase.h"
+#include "WorkerAsyncFileWriterChromium.h"
+#include "WorkerContext.h"
+#include "WorkerFileSystemCallbacksBridge.h"
+#include "WorkerScriptController.h"
+#include "WorkerThread.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+namespace WebCore {
+
+static const char fileSystemOperationsMode[] = "fileSystemOperationsMode";
+
+WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, const String& rootPath, bool synchronous)
+ : AsyncFileSystem(rootPath)
+ , m_scriptExecutionContext(context)
+ , m_webFileSystem(WebKit::webKitClient()->fileSystem())
+ , m_workerContext(static_cast<WorkerContext*>(context))
+ , m_synchronous(synchronous)
+{
+ ASSERT(m_webFileSystem);
+ ASSERT(m_scriptExecutionContext->isWorkerContext());
+
+ WorkerLoaderProxy* workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy();
+ m_worker = static_cast<WebWorkerBase*>(workerLoaderProxy);
+}
+
+WorkerAsyncFileSystemChromium::~WorkerAsyncFileSystemChromium()
+{
+}
+
+bool WorkerAsyncFileSystemChromium::waitForOperationToComplete()
+{
+ if (!m_bridgeForCurrentOperation.get())
+ return false;
+
+ RefPtr<WorkerFileSystemCallbacksBridge> bridge = m_bridgeForCurrentOperation.release();
+ if (m_workerContext->thread()->runLoop().runInMode(m_workerContext, m_modeForCurrentOperation) == MessageQueueTerminated) {
+ bridge->stop();
+ return false;
+ }
+ return true;
+}
+
+void WorkerAsyncFileSystemChromium::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveRecursivelyToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+void WorkerAsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+class WorkerFileWriterHelperCallbacks : public AsyncFileSystemCallbacks {
+public:
+ static PassOwnPtr<WorkerFileWriterHelperCallbacks> create(AsyncFileWriterClient* client, const String& path, WebKit::WebFileSystem* webFileSystem, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks, WorkerContext* workerContext)
+ {
+ return adoptPtr(new WorkerFileWriterHelperCallbacks(client, path, webFileSystem, callbacks, workerContext));
+ }
+
+ virtual void didSucceed()
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ virtual void didReadMetadata(const FileMetadata& metadata)
+ {
+ ASSERT(m_callbacks);
+ if (metadata.type != FileMetadata::TypeFile || metadata.length < 0)
+ m_callbacks->didFail(WebKit::WebFileErrorInvalidState);
+ else {
+ OwnPtr<WorkerAsyncFileWriterChromium> asyncFileWriterChromium = WorkerAsyncFileWriterChromium::create(m_webFileSystem, m_path, m_workerContext, m_client, WorkerAsyncFileWriterChromium::Asynchronous);
+ m_callbacks->didCreateFileWriter(asyncFileWriterChromium.release(), metadata.length);
+ }
+ }
+
+ virtual void didReadDirectoryEntry(const String& name, bool isDirectory)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ virtual void didReadDirectoryEntries(bool hasMore)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ virtual void didOpenFileSystem(const String&, PassOwnPtr<AsyncFileSystem>)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ // Called when an AsyncFileWrter has been created successfully.
+ virtual void didCreateFileWriter(PassOwnPtr<AsyncFileWriter>, long long)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ virtual void didFail(int code)
+ {
+ ASSERT(m_callbacks);
+ m_callbacks->didFail(code);
+ }
+
+private:
+ WorkerFileWriterHelperCallbacks(AsyncFileWriterClient* client, const String& path, WebKit::WebFileSystem* webFileSystem, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks, WorkerContext* workerContext)
+ : m_client(client)
+ , m_path(path)
+ , m_webFileSystem(webFileSystem)
+ , m_callbacks(callbacks)
+ , m_workerContext(workerContext)
+ {
+ }
+
+ AsyncFileWriterClient* m_client;
+ String m_path;
+ WebKit::WebFileSystem* m_webFileSystem;
+ OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
+ WorkerContext* m_workerContext;
+};
+
+void WorkerAsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ createWorkerFileSystemCallbacksBridge(WorkerFileWriterHelperCallbacks::create(client, path, m_webFileSystem, callbacks, m_workerContext))->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
+}
+
+PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ ASSERT(!m_synchronous || !m_bridgeForCurrentOperation.get());
+
+ m_modeForCurrentOperation = fileSystemOperationsMode;
+ m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId()));
+
+ m_bridgeForCurrentOperation = WorkerFileSystemCallbacksBridge::create(m_worker, m_scriptExecutionContext, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+ return m_bridgeForCurrentOperation;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h
new file mode 100644
index 0000000..0b4b708
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WorkerAsyncFileSystemChromium_h
+#define WorkerAsyncFileSystemChromium_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystem.h"
+#include "PlatformString.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+class WebFileSystem;
+class WebWorkerBase;
+class WorkerFileSystemCallbacksBridge;
+}
+
+namespace WebCore {
+
+class AsyncFileSystemCallbacks;
+class ScriptExecutionContext;
+class WorkerContext;
+
+class WorkerAsyncFileSystemChromium : public AsyncFileSystem {
+public:
+ static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, const String& rootPath, bool synchronous)
+ {
+ return adoptPtr(new WorkerAsyncFileSystemChromium(context, rootPath, synchronous));
+ }
+
+ virtual ~WorkerAsyncFileSystemChromium();
+
+ // Runs one pending operation (to wait for completion in the sync-mode).
+ virtual bool waitForOperationToComplete();
+
+ virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+
+private:
+ WorkerAsyncFileSystemChromium(ScriptExecutionContext*, const String& rootPath, bool synchronous);
+
+ PassRefPtr<WebKit::WorkerFileSystemCallbacksBridge> createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks>);
+
+ ScriptExecutionContext* m_scriptExecutionContext;
+ WebKit::WebFileSystem* m_webFileSystem;
+ WebKit::WebWorkerBase* m_worker;
+ WorkerContext* m_workerContext;
+ RefPtr<WebKit::WorkerFileSystemCallbacksBridge> m_bridgeForCurrentOperation;
+ String m_modeForCurrentOperation;
+ bool m_synchronous;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
+
+#endif // WorkerAsyncFileSystemChromium_h
diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp
new file mode 100644
index 0000000..0d0ac8b
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WorkerAsyncFileWriterChromium.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystem.h"
+#include "Blob.h"
+#include "ScriptExecutionContext.h"
+#include "WebFileSystem.h"
+#include "WebFileWriter.h"
+#include "WebURL.h"
+#include "WebWorkerBase.h"
+#include "WorkerContext.h"
+#include "WorkerFileWriterCallbacksBridge.h"
+#include "WorkerLoaderProxy.h"
+#include "WorkerThread.h"
+#include <wtf/Assertions.h>
+
+using namespace WebKit;
+
+namespace WebCore {
+
+WorkerAsyncFileWriterChromium::WorkerAsyncFileWriterChromium(WebFileSystem* webFileSystem, const String& path, WorkerContext* workerContext, AsyncFileWriterClient* client, WriterType type)
+ : m_type(type)
+{
+ ASSERT(m_type == Asynchronous); // Synchronous is not implemented yet.
+
+ WorkerLoaderProxy* proxy = &workerContext->thread()->workerLoaderProxy();
+ m_bridge = WorkerFileWriterCallbacksBridge::create(path, proxy, workerContext, client);
+}
+
+WorkerAsyncFileWriterChromium::~WorkerAsyncFileWriterChromium()
+{
+ m_bridge->postShutdownToMainThread(m_bridge);
+}
+
+bool WorkerAsyncFileWriterChromium::waitForOperationToComplete()
+{
+ return m_bridge->waitForOperationToComplete();
+}
+
+void WorkerAsyncFileWriterChromium::write(long long position, Blob* data)
+{
+ m_bridge->postWriteToMainThread(position, data->url());
+}
+
+void WorkerAsyncFileWriterChromium::truncate(long long length)
+{
+ m_bridge->postTruncateToMainThread(length);
+}
+
+void WorkerAsyncFileWriterChromium::abort()
+{
+ m_bridge->postAbortToMainThread();
+}
+
+}
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h
new file mode 100644
index 0000000..01058c3
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerAsyncFileWriterChromium.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WorkerAsyncFileWriterChromium_h
+#define WorkerAsyncFileWriterChromium_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileWriter.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+ class WebFileSystem;
+ class WebFileWriter;
+ class WorkerFileWriterCallbacksBridge;
+}
+
+namespace WTF {
+ class String;
+}
+using WTF::String;
+
+namespace WebCore {
+
+class AsyncFileSystem;
+class AsyncFileWriterClient;
+class Blob;
+class WorkerContext;
+
+class WorkerAsyncFileWriterChromium : public AsyncFileWriter {
+public:
+ enum WriterType {
+ Asynchronous,
+ Synchronous,
+ };
+
+ static PassOwnPtr<WorkerAsyncFileWriterChromium> create(WebKit::WebFileSystem* webFileSystem, const String& path, WorkerContext* workerContext, AsyncFileWriterClient* client, WriterType type)
+ {
+ return adoptPtr(new WorkerAsyncFileWriterChromium(webFileSystem, path, workerContext, client, type));
+ }
+ ~WorkerAsyncFileWriterChromium();
+
+ bool waitForOperationToComplete();
+
+ // FileWriter
+ virtual void write(long long position, Blob* data);
+ virtual void truncate(long long length);
+ virtual void abort();
+
+private:
+
+ WorkerAsyncFileWriterChromium(WebKit::WebFileSystem*, const String& path, WorkerContext*, AsyncFileWriterClient*, WriterType);
+ RefPtr<WebKit::WorkerFileWriterCallbacksBridge> m_bridge;
+ WriterType m_type;
+};
+
+} // namespace
+
+#endif // ENABLE(FILE_SYSTEM)
+
+#endif // AsyncFileWriterChromium_h
diff --git a/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
new file mode 100644
index 0000000..6c31221
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
@@ -0,0 +1,392 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WorkerFileSystemCallbacksBridge.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "CrossThreadTask.h"
+#include "WebCommonWorkerClient.h"
+#include "WebFileInfo.h"
+#include "WebFileSystemCallbacks.h"
+#include "WebFileSystemEntry.h"
+#include "WebString.h"
+#include "WebWorkerBase.h"
+#include "WorkerContext.h"
+#include "WorkerScriptController.h"
+#include "WorkerThread.h"
+#include <wtf/MainThread.h>
+#include <wtf/Threading.h>
+
+namespace WebCore {
+
+template<> struct CrossThreadCopierBase<false, false, WebKit::WebFileInfo> {
+ typedef WebKit::WebFileInfo Type;
+ static Type copy(const WebKit::WebFileInfo& info)
+ {
+ // Perform per-field copy to make sure we don't do any (unexpected) non-thread safe copy here.
+ struct WebKit::WebFileInfo newInfo;
+ newInfo.modificationTime = info.modificationTime;
+ newInfo.length = info.length;
+ newInfo.type = info.type;
+ return newInfo;
+ }
+};
+
+template<> struct CrossThreadCopierBase<false, false, WebKit::WebVector<WebKit::WebFileSystemEntry> > {
+ typedef WebKit::WebVector<WebKit::WebFileSystemEntry> Type;
+ static Type copy(const WebKit::WebVector<WebKit::WebFileSystemEntry>& entries)
+ {
+ WebKit::WebVector<WebKit::WebFileSystemEntry> newEntries(entries.size());
+ for (size_t i = 0; i < entries.size(); ++i) {
+ String name = entries[i].name;
+ newEntries[i].isDirectory = entries[i].isDirectory;
+ newEntries[i].name = name.crossThreadString();
+ }
+ return newEntries;
+ }
+};
+
+}
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// FileSystemCallbacks that are to be dispatched on the main thread.
+class MainThreadFileSystemCallbacks : public WebFileSystemCallbacks {
+public:
+ // Callbacks are self-destructed and we always return leaked pointer here.
+ static MainThreadFileSystemCallbacks* createLeakedPtr(PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+ {
+ OwnPtr<MainThreadFileSystemCallbacks> callbacks = adoptPtr(new MainThreadFileSystemCallbacks(bridge, mode));
+ return callbacks.leakPtr();
+ }
+
+ virtual ~MainThreadFileSystemCallbacks()
+ {
+ }
+
+ virtual void didOpenFileSystem(const WebString& name, const WebString& path)
+ {
+ m_bridge->didOpenFileSystemOnMainThread(name, path, m_mode);
+ delete this;
+ }
+
+ virtual void didFail(WebFileError error)
+ {
+ m_bridge->didFailOnMainThread(error, m_mode);
+ delete this;
+ }
+
+ virtual void didSucceed()
+ {
+ m_bridge->didSucceedOnMainThread(m_mode);
+ delete this;
+ }
+
+ virtual void didReadMetadata(const WebFileInfo& info)
+ {
+ m_bridge->didReadMetadataOnMainThread(info, m_mode);
+ delete this;
+ }
+
+ virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
+ {
+ m_bridge->didReadDirectoryOnMainThread(entries, hasMore, m_mode);
+ delete this;
+ }
+
+private:
+ MainThreadFileSystemCallbacks(PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+ : m_bridge(bridge)
+ , m_mode(mode)
+ {
+ ASSERT(m_bridge.get());
+ }
+
+ friend class WorkerFileSystemCallbacksBridge;
+ RefPtr<WorkerFileSystemCallbacksBridge> m_bridge;
+ const String m_mode;
+};
+
+void WorkerFileSystemCallbacksBridge::stop()
+{
+ ASSERT(m_workerContext->isContextThread());
+ MutexLocker locker(m_mutex);
+ m_worker = 0;
+
+ if (m_callbacksOnWorkerThread) {
+ m_callbacksOnWorkerThread->didFail(WebFileErrorAbort);
+ m_callbacksOnWorkerThread = 0;
+ }
+}
+
+void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, const String& mode)
+{
+ dispatchTaskToMainThread(createCallbackTask(&openFileSystemOnMainThread, commonClient, type, size, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postMoveToMainThread(WebFileSystem* fileSystem, const String& sourcePath, const String& destinationPath, const String& mode)
+{
+ dispatchTaskToMainThread(createCallbackTask(&moveOnMainThread, fileSystem, sourcePath, destinationPath, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCopyToMainThread(WebFileSystem* fileSystem, const String& sourcePath, const String& destinationPath, const String& mode)
+{
+ dispatchTaskToMainThread(createCallbackTask(&copyOnMainThread, fileSystem, sourcePath, destinationPath, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postRemoveToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&removeOnMainThread, fileSystem, path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&removeRecursivelyOnMainThread, fileSystem, path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&readMetadataOnMainThread, fileSystem, path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCreateFileToMainThread(WebFileSystem* fileSystem, const String& path, bool exclusive, const String& mode)
+{
+ dispatchTaskToMainThread(createCallbackTask(&createFileOnMainThread, fileSystem, path, exclusive, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCreateDirectoryToMainThread(WebFileSystem* fileSystem, const String& path, bool exclusive, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&createDirectoryOnMainThread, fileSystem, path, exclusive, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postFileExistsToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&fileExistsOnMainThread, fileSystem, path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postDirectoryExistsToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&directoryExistsOnMainThread, fileSystem, path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(createCallbackTask(&readDirectoryOnMainThread, fileSystem, path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ if (!commonClient)
+ bridge->didFailOnMainThread(WebFileErrorAbort, mode);
+ else {
+ commonClient->openFileSystem(type, size, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+ }
+}
+
+void WorkerFileSystemCallbacksBridge::moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& sourcePath, const String& destinationPath, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->move(sourcePath, destinationPath, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& sourcePath, const String& destinationPath, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->copy(sourcePath, destinationPath, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->remove(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->removeRecursively(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->readMetadata(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->createFile(path, exclusive, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->createDirectory(path, exclusive, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->fileExists(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->directoryExists(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+ fileSystem->readDirectory(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::didFailOnMainThread(WebFileError error, const String& mode)
+{
+ mayPostTaskToWorker(createCallbackTask(&didFailOnWorkerThread, this, error), mode);
+}
+
+void WorkerFileSystemCallbacksBridge::didOpenFileSystemOnMainThread(const String& name, const String& rootPath, const String& mode)
+{
+ mayPostTaskToWorker(createCallbackTask(&didOpenFileSystemOnWorkerThread, this, name, rootPath), mode);
+}
+
+void WorkerFileSystemCallbacksBridge::didSucceedOnMainThread(const String& mode)
+{
+ mayPostTaskToWorker(createCallbackTask(&didSucceedOnWorkerThread, this), mode);
+}
+
+void WorkerFileSystemCallbacksBridge::didReadMetadataOnMainThread(const WebFileInfo& info, const String& mode)
+{
+ mayPostTaskToWorker(createCallbackTask(&didReadMetadataOnWorkerThread, this, info), mode);
+}
+
+void WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>& entries, bool hasMore, const String& mode)
+{
+ mayPostTaskToWorker(createCallbackTask(&didReadDirectoryOnWorkerThread, this, entries, hasMore), mode);
+}
+
+WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebWorkerBase* worker, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacks* callbacks)
+ : WorkerContext::Observer(static_cast<WorkerContext*>(scriptExecutionContext))
+ , m_worker(worker)
+ , m_workerContext(scriptExecutionContext)
+ , m_callbacksOnWorkerThread(callbacks)
+{
+ ASSERT(m_workerContext->isContextThread());
+}
+
+WorkerFileSystemCallbacksBridge::~WorkerFileSystemCallbacksBridge()
+{
+ ASSERT(!m_callbacksOnWorkerThread);
+}
+
+void WorkerFileSystemCallbacksBridge::didFailOnWorkerThread(ScriptExecutionContext*, WorkerFileSystemCallbacksBridge* bridge, WebFileError error)
+{
+ bridge->m_callbacksOnWorkerThread->didFail(error);
+}
+
+void WorkerFileSystemCallbacksBridge::didOpenFileSystemOnWorkerThread(ScriptExecutionContext*, WorkerFileSystemCallbacksBridge* bridge, const String& name, const String& rootPath)
+{
+ bridge->m_callbacksOnWorkerThread->didOpenFileSystem(name, rootPath);
+}
+
+void WorkerFileSystemCallbacksBridge::didSucceedOnWorkerThread(ScriptExecutionContext*, WorkerFileSystemCallbacksBridge* bridge)
+{
+ bridge->m_callbacksOnWorkerThread->didSucceed();
+}
+
+void WorkerFileSystemCallbacksBridge::didReadMetadataOnWorkerThread(ScriptExecutionContext*, WorkerFileSystemCallbacksBridge* bridge, const WebFileInfo& info)
+{
+ bridge->m_callbacksOnWorkerThread->didReadMetadata(info);
+}
+
+void WorkerFileSystemCallbacksBridge::didReadDirectoryOnWorkerThread(ScriptExecutionContext*, WorkerFileSystemCallbacksBridge* bridge, const WebVector<WebFileSystemEntry>& entries, bool hasMore)
+{
+ bridge->m_callbacksOnWorkerThread->didReadDirectory(entries, hasMore);
+}
+
+bool WorkerFileSystemCallbacksBridge::derefIfWorkerIsStopped()
+{
+ WebWorkerBase* worker = 0;
+ {
+ MutexLocker locker(m_mutex);
+ worker = m_worker;
+ }
+
+ if (!worker) {
+ m_selfRef.clear();
+ return true;
+ }
+ return false;
+}
+
+void WorkerFileSystemCallbacksBridge::runTaskOnMainThread(WebCore::ScriptExecutionContext* scriptExecutionContext, WorkerFileSystemCallbacksBridge* bridge, PassOwnPtr<WebCore::ScriptExecutionContext::Task> taskToRun)
+{
+ ASSERT(isMainThread());
+ if (bridge->derefIfWorkerIsStopped())
+ return;
+ taskToRun->performTask(scriptExecutionContext);
+}
+
+void WorkerFileSystemCallbacksBridge::runTaskOnWorkerThread(WebCore::ScriptExecutionContext* scriptExecutionContext, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, PassOwnPtr<WebCore::ScriptExecutionContext::Task> taskToRun)
+{
+ if (!bridge->m_callbacksOnWorkerThread)
+ return;
+ ASSERT(bridge->m_workerContext->isContextThread());
+ taskToRun->performTask(scriptExecutionContext);
+ bridge->m_callbacksOnWorkerThread = 0;
+}
+
+void WorkerFileSystemCallbacksBridge::dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task> task)
+{
+ ASSERT(!m_selfRef);
+ ASSERT(m_worker);
+ ASSERT(m_workerContext->isContextThread());
+ m_selfRef = this;
+ m_worker->dispatchTaskToMainThread(createCallbackTask(&runTaskOnMainThread, this, task));
+}
+
+void WorkerFileSystemCallbacksBridge::mayPostTaskToWorker(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
+{
+ ASSERT(isMainThread());
+ { // Let go of the mutex before possibly deleting this due to m_selfRef.clear().
+ MutexLocker locker(m_mutex);
+ if (m_worker)
+ m_worker->postTaskForModeToWorkerContext(createCallbackTask(&runTaskOnWorkerThread, m_selfRef, task), mode);
+ }
+ m_selfRef.clear();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
new file mode 100644
index 0000000..fa57f38
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WorkerFileSystemCallbacksBridge_h
+#define WorkerFileSystemCallbacksBridge_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "PlatformString.h"
+#include "ScriptExecutionContext.h"
+#include "WebFileError.h"
+#include "WebFileSystem.h"
+#include "WebVector.h"
+#include "WorkerContext.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
+
+namespace WebKit {
+
+class AsyncFileSystem;
+class MainThreadFileSystemCallbacks;
+class ThreadableCallbacksBridgeWrapper;
+class WebCommonWorkerClient;
+class WebFileSystemCallbacks;
+class WebWorkerBase;
+struct WebFileInfo;
+struct WebFileSystemEntry;
+
+// This class is used to post a openFileSystem request to the main thread and get called back for the request. This must be destructed on the worker thread.
+//
+// A typical flow for openFileSystem would look like this:
+// Bridge::postOpenFileSystemToMainThread() on WorkerThread
+// --> Bridge::openFileSystemOnMainThread() is called on MainThread
+// This makes an IPC with a MainThreadFileSystemCallbacks instance
+// [actual operation is down in the browser]
+// --> MainThreadFileSystemCallbacks::didXxx is called on MainThread
+// --> Bridge::didXxxOnMainThread is called on MainThread
+// --> Bridge::didXxxOnWorkerThread is called on WorkerThread
+// This calls the original callbacks (m_callbacksOnWorkerThread) and
+// releases a self-reference to the bridge.
+class WorkerFileSystemCallbacksBridge : public ThreadSafeShared<WorkerFileSystemCallbacksBridge>, public WebCore::WorkerContext::Observer {
+public:
+ ~WorkerFileSystemCallbacksBridge();
+
+ // WorkerContext::Observer method.
+ virtual void notifyStop()
+ {
+ stop();
+ }
+
+ void stop();
+
+ static PassRefPtr<WorkerFileSystemCallbacksBridge> create(WebWorkerBase* worker, WebCore::ScriptExecutionContext* workerContext, WebFileSystemCallbacks* callbacks)
+ {
+ return adoptRef(new WorkerFileSystemCallbacksBridge(worker, workerContext, callbacks));
+ }
+
+ // Methods that create an instance and post an initial request task to the main thread. They must be called on the worker thread.
+ void postOpenFileSystemToMainThread(WebCommonWorkerClient*, WebFileSystem::Type, long long size, const String& mode);
+ void postMoveToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode);
+ void postCopyToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode);
+ void postRemoveToMainThread(WebFileSystem*, const String& path, const String& mode);
+ void postRemoveRecursivelyToMainThread(WebFileSystem*, const String& path, const String& mode);
+ void postReadMetadataToMainThread(WebFileSystem*, const String& path, const String& mode);
+ void postCreateFileToMainThread(WebFileSystem*, const String& path, bool exclusive, const String& mode);
+ void postCreateDirectoryToMainThread(WebFileSystem*, const String& path, bool exclusive, const String& mode);
+ void postFileExistsToMainThread(WebFileSystem*, const String& path, const String& mode);
+ void postDirectoryExistsToMainThread(WebFileSystem*, const String& path, const String& mode);
+ void postReadDirectoryToMainThread(WebFileSystem*, const String& path, const String& mode);
+
+ // Callback methods that are called on the main thread.
+ void didFailOnMainThread(WebFileError, const String& mode);
+ void didOpenFileSystemOnMainThread(const String& name, const String& rootPath, const String& mode);
+ void didSucceedOnMainThread(const String& mode);
+ void didReadMetadataOnMainThread(const WebFileInfo&, const String& mode);
+ void didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>&, bool hasMore, const String& mode);
+
+private:
+ WorkerFileSystemCallbacksBridge(WebWorkerBase*, WebCore::ScriptExecutionContext*, WebFileSystemCallbacks*);
+
+ // Methods that are to be called on the main thread.
+ static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystem::Type, long long size, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+ static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+
+ friend class MainThreadFileSystemCallbacks;
+
+ // Methods that dispatch WebFileSystemCallbacks on the worker threads.
+ // They release a selfRef of the WorkerFileSystemCallbacksBridge.
+ static void didFailOnWorkerThread(WebCore::ScriptExecutionContext*, WorkerFileSystemCallbacksBridge*, WebFileError);
+ static void didOpenFileSystemOnWorkerThread(WebCore::ScriptExecutionContext*, WorkerFileSystemCallbacksBridge*, const String& name, const String& rootPath);
+ static void didSucceedOnWorkerThread(WebCore::ScriptExecutionContext*, WorkerFileSystemCallbacksBridge*);
+ static void didReadMetadataOnWorkerThread(WebCore::ScriptExecutionContext*, WorkerFileSystemCallbacksBridge*, const WebFileInfo&);
+ static void didReadDirectoryOnWorkerThread(WebCore::ScriptExecutionContext*, WorkerFileSystemCallbacksBridge*, const WebVector<WebFileSystemEntry>&, bool hasMore);
+
+ // For early-exist; this deref's selfRef and returns true if the worker is already null.
+ bool derefIfWorkerIsStopped();
+
+ static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, WorkerFileSystemCallbacksBridge*, PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+ static void runTaskOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+
+ void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+ void mayPostTaskToWorker(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode);
+
+ // m_selfRef keeps a reference to itself until a task is created for the worker thread (at which point the task holds the reference).
+ RefPtr<WorkerFileSystemCallbacksBridge> m_selfRef;
+
+ Mutex m_mutex;
+ WebWorkerBase* m_worker;
+ WebCore::ScriptExecutionContext* m_workerContext;
+
+ // This is self-destructed and must be fired on the worker thread.
+ WebFileSystemCallbacks* m_callbacksOnWorkerThread;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // WorkerFileSystemCallbacksBridge_h
diff --git a/Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.cpp b/Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.cpp
new file mode 100644
index 0000000..179aea5
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.cpp
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WorkerFileWriterCallbacksBridge.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileWriterClient.h"
+#include "CrossThreadTask.h"
+#include "WebCString.h"
+#include "WebFileSystem.h"
+#include "WebFileWriter.h"
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebWorkerBase.h"
+#include "WorkerContext.h"
+#include "WorkerLoaderProxy.h"
+#include "WorkerThread.h"
+#include <wtf/MainThread.h>
+#include <wtf/Threading.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WorkerFileWriterCallbacksBridge::notifyStop()
+{
+ ASSERT(m_workerContext->isContextThread());
+ m_clientOnWorkerThread = 0;
+}
+
+void WorkerFileWriterCallbacksBridge::postWriteToMainThread(long long position, const KURL& data)
+{
+ ASSERT(!m_operationInProgress);
+ m_operationInProgress = true;
+ dispatchTaskToMainThread(createCallbackTask(&writeOnMainThread, this, position, data));
+}
+
+void WorkerFileWriterCallbacksBridge::postTruncateToMainThread(long long length)
+{
+ ASSERT(!m_operationInProgress);
+ m_operationInProgress = true;
+ dispatchTaskToMainThread(createCallbackTask(&truncateOnMainThread, this, length));
+}
+
+void WorkerFileWriterCallbacksBridge::postAbortToMainThread()
+{
+ ASSERT(m_operationInProgress);
+ dispatchTaskToMainThread(createCallbackTask(&abortOnMainThread, this));
+}
+
+void WorkerFileWriterCallbacksBridge::postShutdownToMainThread(PassRefPtr<WorkerFileWriterCallbacksBridge> bridge)
+{
+ ASSERT(m_workerContext->isContextThread());
+ m_clientOnWorkerThread = 0;
+ dispatchTaskToMainThread(createCallbackTask(&shutdownOnMainThread, bridge));
+}
+
+void WorkerFileWriterCallbacksBridge::writeOnMainThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long position, const KURL& data)
+{
+ bridge->m_writer->write(position, WebURL(data));
+}
+
+void WorkerFileWriterCallbacksBridge::truncateOnMainThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long length)
+{
+ bridge->m_writer->truncate(length);
+}
+
+void WorkerFileWriterCallbacksBridge::abortOnMainThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge)
+{
+ bridge->m_writer->cancel();
+}
+
+void WorkerFileWriterCallbacksBridge::initOnMainThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, const String& path)
+{
+ ASSERT(!bridge->m_writer);
+ bridge->m_writer = webKitClient()->fileSystem()->createFileWriter(path, bridge.get());
+}
+
+void WorkerFileWriterCallbacksBridge::shutdownOnMainThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge)
+{
+ bridge->m_writerDeleted = true;
+ bridge->m_writer.clear();
+}
+
+void WorkerFileWriterCallbacksBridge::didWrite(long long bytes, bool complete)
+{
+ dispatchTaskToWorkerThread(createCallbackTask(&didWriteOnWorkerThread, this, bytes, complete));
+}
+
+void WorkerFileWriterCallbacksBridge::didFail(WebFileError error)
+{
+ dispatchTaskToWorkerThread(createCallbackTask(&didFailOnWorkerThread, this, error));
+}
+
+void WorkerFileWriterCallbacksBridge::didTruncate()
+{
+ dispatchTaskToWorkerThread(createCallbackTask(&didTruncateOnWorkerThread, this));
+}
+
+static const char fileWriterOperationsMode[] = "fileWriterOperationsMode";
+
+WorkerFileWriterCallbacksBridge::WorkerFileWriterCallbacksBridge(const String& path, WorkerLoaderProxy* proxy, ScriptExecutionContext* scriptExecutionContext, AsyncFileWriterClient* client)
+ : WorkerContext::Observer(static_cast<WorkerContext*>(scriptExecutionContext))
+ , m_proxy(proxy)
+ , m_workerContext(scriptExecutionContext)
+ , m_clientOnWorkerThread(client)
+ , m_writerDeleted(false)
+ , m_operationInProgress(false)
+{
+ ASSERT(m_workerContext->isContextThread());
+ m_mode = fileWriterOperationsMode;
+ m_mode.append(String::number(static_cast<WorkerContext*>(scriptExecutionContext)->thread()->runLoop().createUniqueId()));
+ postInitToMainThread(path);
+}
+
+void WorkerFileWriterCallbacksBridge::postInitToMainThread(const String& path)
+{
+ dispatchTaskToMainThread(createCallbackTask(&initOnMainThread, this, path));
+}
+
+WorkerFileWriterCallbacksBridge::~WorkerFileWriterCallbacksBridge()
+{
+ ASSERT(!m_clientOnWorkerThread);
+ ASSERT(!m_writer);
+}
+
+// We know m_clientOnWorkerThread is still valid because it is only cleared on the context thread, and because we check in runTaskOnWorkerThread before calling any of these methods.
+void WorkerFileWriterCallbacksBridge::didWriteOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, long long length, bool complete)
+{
+ ASSERT(bridge->m_workerContext->isContextThread());
+ ASSERT(bridge->m_operationInProgress);
+ if (complete)
+ bridge->m_operationInProgress = false;
+ bridge->m_clientOnWorkerThread->didWrite(length, complete);
+}
+
+void WorkerFileWriterCallbacksBridge::didFailOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, WebFileError error)
+{
+ ASSERT(bridge->m_workerContext->isContextThread());
+ ASSERT(bridge->m_operationInProgress);
+ bridge->m_operationInProgress = false;
+ bridge->m_clientOnWorkerThread->didFail(static_cast<FileError::ErrorCode>(error));
+}
+
+void WorkerFileWriterCallbacksBridge::didTruncateOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge)
+{
+ ASSERT(bridge->m_workerContext->isContextThread());
+ ASSERT(bridge->m_operationInProgress);
+ bridge->m_operationInProgress = false;
+ bridge->m_clientOnWorkerThread->didTruncate();
+}
+
+void WorkerFileWriterCallbacksBridge::runTaskOnMainThread(ScriptExecutionContext* scriptExecutionContext, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, PassOwnPtr<ScriptExecutionContext::Task> taskToRun)
+{
+ ASSERT(isMainThread());
+ if (!bridge->m_writerDeleted)
+ taskToRun->performTask(scriptExecutionContext);
+}
+
+void WorkerFileWriterCallbacksBridge::runTaskOnWorkerThread(ScriptExecutionContext* scriptExecutionContext, PassRefPtr<WorkerFileWriterCallbacksBridge> bridge, PassOwnPtr<ScriptExecutionContext::Task> taskToRun)
+{
+ ASSERT(bridge->m_workerContext->isContextThread());
+ if (bridge->m_clientOnWorkerThread)
+ taskToRun->performTask(scriptExecutionContext);
+}
+
+void WorkerFileWriterCallbacksBridge::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+ ASSERT(m_workerContext->isContextThread());
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&runTaskOnMainThread, this, task));
+}
+
+void WorkerFileWriterCallbacksBridge::dispatchTaskToWorkerThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+ ASSERT(isMainThread());
+ m_proxy->postTaskForModeToWorkerContext(createCallbackTask(&runTaskOnWorkerThread, this, task), m_mode);
+}
+
+bool WorkerFileWriterCallbacksBridge::waitForOperationToComplete()
+{
+ while (m_operationInProgress) {
+ WorkerContext* context = static_cast<WorkerContext*>(m_workerContext);
+ if (context->thread()->runLoop().runInMode(context, m_mode) == MessageQueueTerminated)
+ return false;
+ }
+ return true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.h b/Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.h
new file mode 100644
index 0000000..62e333c
--- /dev/null
+++ b/Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WorkerFileWriterCallbacksBridge_h
+#define WorkerFileWriterCallbacksBridge_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "WebFileError.h"
+#include "WebFileWriterClient.h"
+#include "WorkerContext.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/ThreadSafeShared.h>
+
+namespace WebCore {
+ class AsyncFileWriterClient;
+ class KURL;
+ class WorkerLoaderProxy;
+}
+
+namespace WTF {
+ class String;
+}
+using WTF::String;
+
+namespace WebKit {
+
+class WebFileSystem;
+class WebFileWriter;
+class WebFileWriterClient;
+class WebWorkerBase;
+
+// This class is used as a mechanism to bridge calls between threads.
+// Calls to a WebFileWriter must happen on the main thread, but they come from
+// the context thread. The responses through the WebFileWriterClient interface
+// start on the main thread, but must be sent via the worker context thread.
+//
+// A typical flow for write would look like this:
+// Bridge::postWriteToMainThread() on WorkerThread
+// --> Bridge::writeOnMainThread() is called on MainThread
+// --> WebFileWriter::write()
+// This makes an IPC; the actual operation is down in the browser.
+// --> Bridge::didWrite is called on MainThread
+// --> Bridge::didWriteOnWorkerThread is called on WorkerThread
+// This calls the original client (m_clientOnWorkerThread).
+//
+// The bridge object is refcounted, so that it doesn't get deleted while there
+// are cross-thread calls in flight. Each CrossThreadTask carries a reference
+// to the bridge, which guarantees that the bridge will still be valid when the
+// task is executed. In order to shut down the bridge, the WebFileWriterClient
+// should call postShutdownToMainThread before dropping its reference to the
+// bridge. This ensures that the WebFileWriter will be cleared on the main
+// thread and that no further calls to the WebFileWriterClient will be made.
+class WorkerFileWriterCallbacksBridge : public ThreadSafeShared<WorkerFileWriterCallbacksBridge>, public WebCore::WorkerContext::Observer, public WebFileWriterClient {
+public:
+ ~WorkerFileWriterCallbacksBridge();
+
+ // WorkerContext::Observer method.
+ virtual void notifyStop();
+
+ static PassRefPtr<WorkerFileWriterCallbacksBridge> create(const String& path, WebCore::WorkerLoaderProxy* proxy, WebCore::ScriptExecutionContext* workerContext, WebCore::AsyncFileWriterClient* client)
+ {
+ return adoptRef(new WorkerFileWriterCallbacksBridge(path, proxy, workerContext, client));
+ }
+
+ // Methods that create an instance and post an initial request task to the main thread. They must be called on the worker thread.
+ void postWriteToMainThread(long long position, const WebCore::KURL& data);
+ void postTruncateToMainThread(long long length);
+ void postAbortToMainThread();
+
+ // The owning WorkerAsyncFileWriterChromium should call this method before dropping its last reference to the bridge, on the context thread.
+ // The actual deletion of the WorkerFileWriterCallbacksBridge may happen on either the main or context thread, depending on where the last reference goes away; that's safe as long as this is called first.
+ void postShutdownToMainThread(PassRefPtr<WorkerFileWriterCallbacksBridge>);
+
+ // Callback methods that are called on the main thread.
+ // These are the implementation of WebKit::WebFileWriterClient.
+ void didWrite(long long bytes, bool complete);
+ void didFail(WebFileError);
+ void didTruncate();
+
+ // Call this on the context thread to wait for the current operation to complete.
+ bool waitForOperationToComplete();
+
+private:
+ WorkerFileWriterCallbacksBridge(const String& path, WebCore::WorkerLoaderProxy*, WebCore::ScriptExecutionContext*, WebCore::AsyncFileWriterClient*);
+
+ void postInitToMainThread(const String& path);
+
+ // Methods that are to be called on the main thread.
+ static void writeOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, long long position, const WebCore::KURL& data);
+ static void truncateOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, long long length);
+ static void abortOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>);
+ static void initOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, const String& path);
+ static void shutdownOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>);
+
+ // Methods that dispatch to AsyncFileWriterClient on the worker threads.
+ static void didWriteOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, long long length, bool complete);
+ static void didFailOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, WebFileError);
+ static void didTruncateOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>);
+
+ // Called on the main thread to run the supplied task.
+ static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+ // Called on the worker thread to run the supplied task.
+ static void runTaskOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileWriterCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+
+ // Called on the worker thread to dispatch to the main thread.
+ void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+ // Called on the main thread to dispatch to the worker thread.
+ void dispatchTaskToWorkerThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+
+ // Used from the main thread to post tasks to the context thread.
+ WebCore::WorkerLoaderProxy* m_proxy;
+
+ // Used on the context thread, only to check that we're running on the context thread.
+ WebCore::ScriptExecutionContext* m_workerContext;
+
+ // Created and destroyed from the main thread.
+ OwnPtr<WebKit::WebFileWriter> m_writer;
+
+ // Used on the context thread to call back into the client.
+ WebCore::AsyncFileWriterClient* m_clientOnWorkerThread;
+
+ // Used to indicate that shutdown has started on the main thread, and hence the writer has been deleted.
+ bool m_writerDeleted;
+
+ // Used by waitForOperationToComplete.
+ bool m_operationInProgress;
+
+ // Used by postTaskForModeToWorkerContext and runInMode.
+ String m_mode;
+};
+
+} // namespace WebCore
+
+#endif
+
+#endif // WorkerFileWriterCallbacksBridge_h
diff --git a/Source/WebKit/chromium/src/WrappedResourceRequest.h b/Source/WebKit/chromium/src/WrappedResourceRequest.h
new file mode 100644
index 0000000..3057387
--- /dev/null
+++ b/Source/WebKit/chromium/src/WrappedResourceRequest.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WrappedResourceRequest_h
+#define WrappedResourceRequest_h
+
+#include "WebURLRequest.h"
+#include "WebURLRequestPrivate.h"
+
+namespace WebKit {
+
+class WrappedResourceRequest : public WebURLRequest {
+public:
+ ~WrappedResourceRequest()
+ {
+ reset(); // Need to drop reference to m_handle
+ }
+
+ WrappedResourceRequest() { }
+
+ WrappedResourceRequest(WebCore::ResourceRequest& resourceRequest)
+ {
+ bind(resourceRequest);
+ }
+
+ WrappedResourceRequest(const WebCore::ResourceRequest& resourceRequest)
+ {
+ bind(resourceRequest);
+ }
+
+ void bind(WebCore::ResourceRequest& resourceRequest)
+ {
+ m_handle.m_resourceRequest = &resourceRequest;
+ assign(&m_handle);
+ }
+
+ void bind(const WebCore::ResourceRequest& resourceRequest)
+ {
+ bind(*const_cast<WebCore::ResourceRequest*>(&resourceRequest));
+ }
+
+private:
+ class Handle : public WebURLRequestPrivate {
+ public:
+ virtual void dispose() { m_resourceRequest = 0; }
+ };
+
+ Handle m_handle;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/WrappedResourceResponse.h b/Source/WebKit/chromium/src/WrappedResourceResponse.h
new file mode 100644
index 0000000..927582d
--- /dev/null
+++ b/Source/WebKit/chromium/src/WrappedResourceResponse.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WrappedResourceResponse_h
+#define WrappedResourceResponse_h
+
+#include "WebURLResponse.h"
+#include "WebURLResponsePrivate.h"
+
+namespace WebKit {
+
+class WrappedResourceResponse : public WebURLResponse {
+public:
+ ~WrappedResourceResponse()
+ {
+ reset(); // Need to drop reference to m_handle
+ }
+
+ WrappedResourceResponse() { }
+
+ WrappedResourceResponse(WebCore::ResourceResponse& resourceResponse)
+ {
+ bind(resourceResponse);
+ }
+
+ WrappedResourceResponse(const WebCore::ResourceResponse& resourceResponse)
+ {
+ bind(resourceResponse);
+ }
+
+ void bind(WebCore::ResourceResponse& resourceResponse)
+ {
+ m_handle.m_resourceResponse = &resourceResponse;
+ assign(&m_handle);
+ }
+
+ void bind(const WebCore::ResourceResponse& resourceResponse)
+ {
+ bind(*const_cast<WebCore::ResourceResponse*>(&resourceResponse));
+ }
+
+private:
+ class Handle : public WebURLResponsePrivate {
+ public:
+ virtual void dispose() { m_resourceResponse = 0; }
+ };
+
+ Handle m_handle;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp b/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp
new file mode 100644
index 0000000..dd25eb1
--- /dev/null
+++ b/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFontInfo.h"
+#include "WebFontRenderStyle.h"
+
+#include <fontconfig/fontconfig.h>
+#include <string.h>
+#include <unicode/utf16.h>
+
+namespace WebKit {
+
+WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters)
+{
+ FcCharSet* cset = FcCharSetCreate();
+ for (size_t i = 0; i < numCharacters; ++i) {
+ if (U16_IS_SURROGATE(characters[i])
+ && U16_IS_SURROGATE_LEAD(characters[i])
+ && i != numCharacters - 1
+ && U16_IS_TRAIL(characters[i + 1])) {
+ FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
+ i++;
+ } else
+ FcCharSetAddChar(cset, characters[i]);
+ }
+ FcPattern* pattern = FcPatternCreate();
+
+ FcValue fcvalue;
+ fcvalue.type = FcTypeCharSet;
+ fcvalue.u.c = cset;
+ FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeBool;
+ fcvalue.u.b = FcTrue;
+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcResult result;
+ FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
+ FcPatternDestroy(pattern);
+ FcCharSetDestroy(cset);
+
+ if (!fontSet)
+ return WebCString();
+
+ // Older versions of fontconfig have a bug where they cannot select
+ // only scalable fonts so we have to manually filter the results.
+ for (int i = 0; i < fontSet->nfont; ++i) {
+ FcPattern* current = fontSet->fonts[i];
+ FcBool isScalable;
+
+ if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
+ || !isScalable)
+ continue;
+
+ // fontconfig can also return fonts which are unreadable
+ FcChar8* cFilename;
+ if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
+ continue;
+
+ if (access(reinterpret_cast<char*>(cFilename), R_OK))
+ continue;
+
+ FcChar8* family;
+ WebCString result;
+ if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) {
+ const char* charFamily = reinterpret_cast<char*>(family);
+ result = WebCString(charFamily, strlen(charFamily));
+ }
+ FcFontSetDestroy(fontSet);
+ return result;
+ }
+
+ FcFontSetDestroy(fontSet);
+ return WebCString();
+}
+
+void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* out)
+{
+ bool isBold = sizeAndStyle & 1;
+ bool isItalic = sizeAndStyle & 2;
+ int pixelSize = sizeAndStyle >> 2;
+
+ FcPattern* pattern = FcPatternCreate();
+ FcValue fcvalue;
+
+ fcvalue.type = FcTypeString;
+ fcvalue.u.s = reinterpret_cast<const FcChar8 *>(family);
+ FcPatternAdd(pattern, FC_FAMILY, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = isBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
+ FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = isItalic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
+ FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeBool;
+ fcvalue.u.b = FcTrue;
+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeDouble;
+ fcvalue.u.d = pixelSize;
+ FcPatternAdd(pattern, FC_SIZE, fcvalue, FcFalse);
+
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcResult result;
+ // Some versions of fontconfig don't actually write a value into result.
+ // However, it's not clear from the documentation if result should be a
+ // non-0 pointer: future versions might expect to be able to write to
+ // it. So we pass in a valid pointer and ignore it.
+ FcPattern* match = FcFontMatch(0, pattern, &result);
+ FcPatternDestroy(pattern);
+
+ out->setDefaults();
+
+ if (!match) {
+ FcPatternDestroy(match);
+ return;
+ }
+
+ FcBool b;
+ int i;
+
+ if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &b) == FcResultMatch)
+ out->useAntiAlias = b;
+ if (FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &b) == FcResultMatch)
+ out->useBitmaps = b;
+ if (FcPatternGetBool(match, FC_AUTOHINT, 0, &b) == FcResultMatch)
+ out->useAutoHint = b;
+ if (FcPatternGetBool(match, FC_HINTING, 0, &b) == FcResultMatch)
+ out->useHinting = b;
+ if (FcPatternGetInteger(match, FC_HINT_STYLE, 0, &i) == FcResultMatch)
+ out->hintStyle = i;
+ if (FcPatternGetInteger(match, FC_RGBA, 0, &i) == FcResultMatch) {
+ switch (i) {
+ case FC_RGBA_NONE:
+ out->useSubpixel = 0;
+ break;
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ out->useSubpixel = 1;
+ break;
+ default:
+ // This includes FC_RGBA_UNKNOWN.
+ out->useSubpixel = 2;
+ break;
+ }
+ }
+
+ FcPatternDestroy(match);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/gtk/WebInputEventFactory.cpp b/Source/WebKit/chromium/src/gtk/WebInputEventFactory.cpp
new file mode 100644
index 0000000..71d1b39
--- /dev/null
+++ b/Source/WebKit/chromium/src/gtk/WebInputEventFactory.cpp
@@ -0,0 +1,563 @@
+/*
+ * Copyright (C) 2006-2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputEventFactory.h"
+
+#include "KeyboardCodes.h"
+#include "KeyCodeConversion.h"
+
+#include "WebInputEvent.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkversion.h>
+
+#include <wtf/Assertions.h>
+
+namespace {
+
+bool countsAsDoubleClick(gint timeDiff, gint xDiff, gint yDiff)
+{
+ static GtkSettings* settings = gtk_settings_get_default();
+ gint doubleClickTime = 250;
+ gint doubleClickDistance = 5;
+ g_object_get(G_OBJECT(settings),
+ "gtk-double-click-time", &doubleClickTime,
+ "gtk-double-click-distance", &doubleClickDistance, NULL);
+ return timeDiff <= doubleClickTime && abs(xDiff) <= doubleClickDistance && abs(yDiff) <= doubleClickDistance;
+}
+
+} // namespace
+
+namespace WebKit {
+
+static double gdkEventTimeToWebEventTime(guint32 time)
+{
+ // Convert from time in ms to time in sec.
+ return time / 1000.0;
+}
+
+static int gdkStateToWebEventModifiers(guint state)
+{
+ int modifiers = 0;
+ if (state & GDK_SHIFT_MASK)
+ modifiers |= WebInputEvent::ShiftKey;
+ if (state & GDK_CONTROL_MASK)
+ modifiers |= WebInputEvent::ControlKey;
+ if (state & GDK_MOD1_MASK)
+ modifiers |= WebInputEvent::AltKey;
+#if GTK_CHECK_VERSION(2, 10, 0)
+ if (state & GDK_META_MASK)
+ modifiers |= WebInputEvent::MetaKey;
+#endif
+ if (state & GDK_BUTTON1_MASK)
+ modifiers |= WebInputEvent::LeftButtonDown;
+ if (state & GDK_BUTTON2_MASK)
+ modifiers |= WebInputEvent::MiddleButtonDown;
+ if (state & GDK_BUTTON3_MASK)
+ modifiers |= WebInputEvent::RightButtonDown;
+ if (state & GDK_LOCK_MASK)
+ modifiers |= WebInputEvent::CapsLockOn;
+ if (state & GDK_MOD2_MASK)
+ modifiers |= WebInputEvent::NumLockOn;
+ return modifiers;
+}
+
+static int gdkEventToWindowsKeyCode(const GdkEventKey* event)
+{
+ static const unsigned int hardwareCodeToGDKKeyval[] = {
+ 0, // 0x00:
+ 0, // 0x01:
+ 0, // 0x02:
+ 0, // 0x03:
+ 0, // 0x04:
+ 0, // 0x05:
+ 0, // 0x06:
+ 0, // 0x07:
+ 0, // 0x08:
+ 0, // 0x09: GDK_Escape
+ GDK_1, // 0x0A: GDK_1
+ GDK_2, // 0x0B: GDK_2
+ GDK_3, // 0x0C: GDK_3
+ GDK_4, // 0x0D: GDK_4
+ GDK_5, // 0x0E: GDK_5
+ GDK_6, // 0x0F: GDK_6
+ GDK_7, // 0x10: GDK_7
+ GDK_8, // 0x11: GDK_8
+ GDK_9, // 0x12: GDK_9
+ GDK_0, // 0x13: GDK_0
+ GDK_minus, // 0x14: GDK_minus
+ GDK_equal, // 0x15: GDK_equal
+ 0, // 0x16: GDK_BackSpace
+ 0, // 0x17: GDK_Tab
+ GDK_q, // 0x18: GDK_q
+ GDK_w, // 0x19: GDK_w
+ GDK_e, // 0x1A: GDK_e
+ GDK_r, // 0x1B: GDK_r
+ GDK_t, // 0x1C: GDK_t
+ GDK_y, // 0x1D: GDK_y
+ GDK_u, // 0x1E: GDK_u
+ GDK_i, // 0x1F: GDK_i
+ GDK_o, // 0x20: GDK_o
+ GDK_p, // 0x21: GDK_p
+ GDK_bracketleft, // 0x22: GDK_bracketleft
+ GDK_bracketright, // 0x23: GDK_bracketright
+ 0, // 0x24: GDK_Return
+ 0, // 0x25: GDK_Control_L
+ GDK_a, // 0x26: GDK_a
+ GDK_s, // 0x27: GDK_s
+ GDK_d, // 0x28: GDK_d
+ GDK_f, // 0x29: GDK_f
+ GDK_g, // 0x2A: GDK_g
+ GDK_h, // 0x2B: GDK_h
+ GDK_j, // 0x2C: GDK_j
+ GDK_k, // 0x2D: GDK_k
+ GDK_l, // 0x2E: GDK_l
+ GDK_semicolon, // 0x2F: GDK_semicolon
+ GDK_apostrophe, // 0x30: GDK_apostrophe
+ GDK_grave, // 0x31: GDK_grave
+ 0, // 0x32: GDK_Shift_L
+ GDK_backslash, // 0x33: GDK_backslash
+ GDK_z, // 0x34: GDK_z
+ GDK_x, // 0x35: GDK_x
+ GDK_c, // 0x36: GDK_c
+ GDK_v, // 0x37: GDK_v
+ GDK_b, // 0x38: GDK_b
+ GDK_n, // 0x39: GDK_n
+ GDK_m, // 0x3A: GDK_m
+ GDK_comma, // 0x3B: GDK_comma
+ GDK_period, // 0x3C: GDK_period
+ GDK_slash, // 0x3D: GDK_slash
+ 0, // 0x3E: GDK_Shift_R
+ 0, // 0x3F:
+ 0, // 0x40:
+ 0, // 0x41:
+ 0, // 0x42:
+ 0, // 0x43:
+ 0, // 0x44:
+ 0, // 0x45:
+ 0, // 0x46:
+ 0, // 0x47:
+ 0, // 0x48:
+ 0, // 0x49:
+ 0, // 0x4A:
+ 0, // 0x4B:
+ 0, // 0x4C:
+ 0, // 0x4D:
+ 0, // 0x4E:
+ 0, // 0x4F:
+ 0, // 0x50:
+ 0, // 0x51:
+ 0, // 0x52:
+ 0, // 0x53:
+ 0, // 0x54:
+ 0, // 0x55:
+ 0, // 0x56:
+ 0, // 0x57:
+ 0, // 0x58:
+ 0, // 0x59:
+ 0, // 0x5A:
+ 0, // 0x5B:
+ 0, // 0x5C:
+ 0, // 0x5D:
+ 0, // 0x5E:
+ 0, // 0x5F:
+ 0, // 0x60:
+ 0, // 0x61:
+ 0, // 0x62:
+ 0, // 0x63:
+ 0, // 0x64:
+ 0, // 0x65:
+ 0, // 0x66:
+ 0, // 0x67:
+ 0, // 0x68:
+ 0, // 0x69:
+ 0, // 0x6A:
+ 0, // 0x6B:
+ 0, // 0x6C:
+ 0, // 0x6D:
+ 0, // 0x6E:
+ 0, // 0x6F:
+ 0, // 0x70:
+ 0, // 0x71:
+ 0, // 0x72:
+ GDK_Super_L, // 0x73: GDK_Super_L
+ GDK_Super_R, // 0x74: GDK_Super_R
+ };
+
+ // |windowsKeyCode| has to include a valid virtual-key code even when we
+ // use non-US layouts, e.g. even when we type an 'A' key of a US keyboard
+ // on the Hebrew layout, |windowsKeyCode| should be VK_A.
+ // On the other hand, |event->keyval| value depends on the current
+ // GdkKeymap object, i.e. when we type an 'A' key of a US keyboard on
+ // the Hebrew layout, |event->keyval| becomes GDK_hebrew_shin and this
+ // WebCore::windowsKeyCodeForKeyEvent() call returns 0.
+ // To improve compatibilty with Windows, we use |event->hardware_keycode|
+ // for retrieving its Windows key-code for the keys when the
+ // WebCore::windowsKeyCodeForEvent() call returns 0.
+ // We shouldn't use |event->hardware_keycode| for keys that GdkKeymap
+ // objects cannot change because |event->hardware_keycode| doesn't change
+ // even when we change the layout options, e.g. when we swap a control
+ // key and a caps-lock key, GTK doesn't swap their
+ // |event->hardware_keycode| values but swap their |event->keyval| values.
+ int windowsKeyCode = WebCore::windowsKeyCodeForKeyEvent(event->keyval);
+ if (windowsKeyCode)
+ return windowsKeyCode;
+
+ const int tableSize = sizeof(hardwareCodeToGDKKeyval) / sizeof(hardwareCodeToGDKKeyval[0]);
+ if (event->hardware_keycode < tableSize) {
+ int keyval = hardwareCodeToGDKKeyval[event->hardware_keycode];
+ if (keyval)
+ return WebCore::windowsKeyCodeForKeyEvent(keyval);
+ }
+
+ // This key is one that keyboard-layout drivers cannot change.
+ // Use |event->keyval| to retrieve its |windowsKeyCode| value.
+ return WebCore::windowsKeyCodeForKeyEvent(event->keyval);
+}
+
+// Gets the corresponding control character of a specified key code. See:
+// http://en.wikipedia.org/wiki/Control_characters
+// We emulate Windows behavior here.
+static WebUChar getControlCharacter(int windowsKeyCode, bool shift)
+{
+ if (windowsKeyCode >= WebCore::VKEY_A && windowsKeyCode <= WebCore::VKEY_Z) {
+ // ctrl-A ~ ctrl-Z map to \x01 ~ \x1A
+ return windowsKeyCode - WebCore::VKEY_A + 1;
+ }
+ if (shift) {
+ // following graphics chars require shift key to input.
+ switch (windowsKeyCode) {
+ // ctrl-@ maps to \x00 (Null byte)
+ case WebCore::VKEY_2:
+ return 0;
+ // ctrl-^ maps to \x1E (Record separator, Information separator two)
+ case WebCore::VKEY_6:
+ return 0x1E;
+ // ctrl-_ maps to \x1F (Unit separator, Information separator one)
+ case WebCore::VKEY_OEM_MINUS:
+ return 0x1F;
+ // Returns 0 for all other keys to avoid inputting unexpected chars.
+ default:
+ return 0;
+ }
+ } else {
+ switch (windowsKeyCode) {
+ // ctrl-[ maps to \x1B (Escape)
+ case WebCore::VKEY_OEM_4:
+ return 0x1B;
+ // ctrl-\ maps to \x1C (File separator, Information separator four)
+ case WebCore::VKEY_OEM_5:
+ return 0x1C;
+ // ctrl-] maps to \x1D (Group separator, Information separator three)
+ case WebCore::VKEY_OEM_6:
+ return 0x1D;
+ // ctrl-Enter maps to \x0A (Line feed)
+ case WebCore::VKEY_RETURN:
+ return 0x0A;
+ // Returns 0 for all other keys to avoid inputting unexpected chars.
+ default:
+ return 0;
+ }
+ }
+}
+
+// WebKeyboardEvent -----------------------------------------------------------
+
+WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event)
+{
+ WebKeyboardEvent result;
+
+ result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
+ result.modifiers = gdkStateToWebEventModifiers(event->state);
+
+ switch (event->type) {
+ case GDK_KEY_RELEASE:
+ result.type = WebInputEvent::KeyUp;
+ break;
+ case GDK_KEY_PRESS:
+ result.type = WebInputEvent::RawKeyDown;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ // According to MSDN:
+ // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx
+ // Key events with Alt modifier and F10 are system key events.
+ // We just emulate this behavior. It's necessary to prevent webkit from
+ // processing keypress event generated by alt-d, etc.
+ // F10 is not special on Linux, so don't treat it as system key.
+ if (result.modifiers & WebInputEvent::AltKey)
+ result.isSystemKey = true;
+
+ // The key code tells us which physical key was pressed (for example, the
+ // A key went down or up). It does not determine whether A should be lower
+ // or upper case. This is what text does, which should be the keyval.
+ result.windowsKeyCode = gdkEventToWindowsKeyCode(event);
+ result.nativeKeyCode = event->hardware_keycode;
+
+ if (result.windowsKeyCode == WebCore::VKEY_RETURN)
+ // We need to treat the enter key as a key press of character \r. This
+ // is apparently just how webkit handles it and what it expects.
+ result.unmodifiedText[0] = '\r';
+ else
+ // FIXME: fix for non BMP chars
+ result.unmodifiedText[0] =
+ static_cast<WebUChar>(gdk_keyval_to_unicode(event->keyval));
+
+ // If ctrl key is pressed down, then control character shall be input.
+ if (result.modifiers & WebInputEvent::ControlKey)
+ result.text[0] = getControlCharacter(
+ result.windowsKeyCode, result.modifiers & WebInputEvent::ShiftKey);
+ else
+ result.text[0] = result.unmodifiedText[0];
+
+ result.setKeyIdentifierFromWindowsKeyCode();
+
+ // FIXME: Do we need to set IsAutoRepeat or IsKeyPad?
+
+ return result;
+}
+
+WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, int state, double timeStampSeconds)
+{
+ // keyboardEvent(const GdkEventKey*) depends on the GdkEventKey object and
+ // it is hard to use/ it from signal handlers which don't use GdkEventKey
+ // objects (e.g. GtkIMContext signal handlers.) For such handlers, this
+ // function creates a WebInputEvent::Char event without using a
+ // GdkEventKey object.
+ WebKeyboardEvent result;
+ result.type = WebKit::WebInputEvent::Char;
+ result.timeStampSeconds = timeStampSeconds;
+ result.modifiers = gdkStateToWebEventModifiers(state);
+ result.windowsKeyCode = character;
+ result.nativeKeyCode = character;
+ result.text[0] = character;
+ result.unmodifiedText[0] = character;
+
+ // According to MSDN:
+ // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx
+ // Key events with Alt modifier and F10 are system key events.
+ // We just emulate this behavior. It's necessary to prevent webkit from
+ // processing keypress event generated by alt-d, etc.
+ // F10 is not special on Linux, so don't treat it as system key.
+ if (result.modifiers & WebInputEvent::AltKey)
+ result.isSystemKey = true;
+
+ return result;
+}
+
+// WebMouseEvent --------------------------------------------------------------
+
+WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
+{
+ WebMouseEvent result;
+
+ result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
+
+ result.modifiers = gdkStateToWebEventModifiers(event->state);
+ result.x = static_cast<int>(event->x);
+ result.y = static_cast<int>(event->y);
+ result.windowX = result.x;
+ result.windowY = result.y;
+ result.globalX = static_cast<int>(event->x_root);
+ result.globalY = static_cast<int>(event->y_root);
+ result.clickCount = 0;
+
+ switch (event->type) {
+ case GDK_BUTTON_PRESS:
+ result.type = WebInputEvent::MouseDown;
+ break;
+ case GDK_BUTTON_RELEASE:
+ result.type = WebInputEvent::MouseUp;
+ break;
+ case GDK_3BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ default:
+ ASSERT_NOT_REACHED();
+ };
+
+ if (GDK_BUTTON_PRESS == event->type) {
+ static int numClicks = 0;
+ static GdkWindow* eventWindow = 0;
+ static gint lastLeftClickTime = 0;
+ static gint lastLeftClickX = 0;
+ static gint lastLeftClickY = 0;
+
+ gint timeDiff = event->time - lastLeftClickTime;
+ gint xDiff = event->x - lastLeftClickX;
+ gint yDiff = event->y - lastLeftClickY;
+ if (eventWindow == event->window && countsAsDoubleClick(timeDiff, xDiff, yDiff))
+ numClicks++;
+ else
+ numClicks = 1;
+
+ result.clickCount = numClicks;
+ eventWindow = event->window;
+ lastLeftClickTime = event->time;
+ lastLeftClickX = event->x;
+ lastLeftClickY = event->y;
+ }
+
+ result.button = WebMouseEvent::ButtonNone;
+ if (event->button == 1)
+ result.button = WebMouseEvent::ButtonLeft;
+ else if (event->button == 2)
+ result.button = WebMouseEvent::ButtonMiddle;
+ else if (event->button == 3)
+ result.button = WebMouseEvent::ButtonRight;
+
+ return result;
+}
+
+WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventMotion* event)
+{
+ WebMouseEvent result;
+
+ result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
+ result.modifiers = gdkStateToWebEventModifiers(event->state);
+ result.x = static_cast<int>(event->x);
+ result.y = static_cast<int>(event->y);
+ result.windowX = result.x;
+ result.windowY = result.y;
+ result.globalX = static_cast<int>(event->x_root);
+ result.globalY = static_cast<int>(event->y_root);
+
+ switch (event->type) {
+ case GDK_MOTION_NOTIFY:
+ result.type = WebInputEvent::MouseMove;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ result.button = WebMouseEvent::ButtonNone;
+ if (event->state & GDK_BUTTON1_MASK)
+ result.button = WebMouseEvent::ButtonLeft;
+ else if (event->state & GDK_BUTTON2_MASK)
+ result.button = WebMouseEvent::ButtonMiddle;
+ else if (event->state & GDK_BUTTON3_MASK)
+ result.button = WebMouseEvent::ButtonRight;
+
+ return result;
+}
+
+WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventCrossing* event)
+{
+ WebMouseEvent result;
+
+ result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
+ result.modifiers = gdkStateToWebEventModifiers(event->state);
+ result.x = static_cast<int>(event->x);
+ result.y = static_cast<int>(event->y);
+ result.windowX = result.x;
+ result.windowY = result.y;
+ result.globalX = static_cast<int>(event->x_root);
+ result.globalY = static_cast<int>(event->y_root);
+
+ switch (event->type) {
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ // Note that if we sent MouseEnter or MouseLeave to WebKit, it
+ // wouldn't work - they don't result in the proper JavaScript events.
+ // MouseMove does the right thing.
+ result.type = WebInputEvent::MouseMove;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ result.button = WebMouseEvent::ButtonNone;
+ if (event->state & GDK_BUTTON1_MASK)
+ result.button = WebMouseEvent::ButtonLeft;
+ else if (event->state & GDK_BUTTON2_MASK)
+ result.button = WebMouseEvent::ButtonMiddle;
+ else if (event->state & GDK_BUTTON3_MASK)
+ result.button = WebMouseEvent::ButtonRight;
+
+ return result;
+}
+
+// WebMouseWheelEvent ---------------------------------------------------------
+
+WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(const GdkEventScroll* event)
+{
+ WebMouseWheelEvent result;
+
+ result.type = WebInputEvent::MouseWheel;
+ result.button = WebMouseEvent::ButtonNone;
+
+ result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
+ result.modifiers = gdkStateToWebEventModifiers(event->state);
+ result.x = static_cast<int>(event->x);
+ result.y = static_cast<int>(event->y);
+ result.windowX = result.x;
+ result.windowY = result.y;
+ result.globalX = static_cast<int>(event->x_root);
+ result.globalY = static_cast<int>(event->y_root);
+
+ // How much should we scroll per mouse wheel event?
+ // - Windows uses 3 lines by default and obeys a system setting.
+ // - Mozilla has a pref that lets you either use the "system" number of lines
+ // to scroll, or lets the user override it.
+ // For the "system" number of lines, it appears they've hardcoded 3.
+ // See case NS_MOUSE_SCROLL in content/events/src/nsEventStateManager.cpp
+ // and InitMouseScrollEvent in widget/src/gtk2/nsCommonWidget.cpp .
+ // - Gtk makes the scroll amount a function of the size of the scroll bar,
+ // which is not available to us here.
+ // Instead, we pick a number that empirically matches Firefox's behavior.
+ static const float scrollbarPixelsPerTick = 160.0f / 3.0f;
+
+ switch (event->direction) {
+ case GDK_SCROLL_UP:
+ result.deltaY = scrollbarPixelsPerTick;
+ result.wheelTicksY = 1;
+ break;
+ case GDK_SCROLL_DOWN:
+ result.deltaY = -scrollbarPixelsPerTick;
+ result.wheelTicksY = -1;
+ break;
+ case GDK_SCROLL_LEFT:
+ result.deltaX = scrollbarPixelsPerTick;
+ result.wheelTicksX = 1;
+ break;
+ case GDK_SCROLL_RIGHT:
+ result.deltaX = -scrollbarPixelsPerTick;
+ result.wheelTicksX = -1;
+ break;
+ }
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/js/DevTools.js b/Source/WebKit/chromium/src/js/DevTools.js
new file mode 100644
index 0000000..d6536bc
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/DevTools.js
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * FIXME: change field naming style to use trailing underscore.
+ * @fileoverview Tools is a main class that wires all components of the
+ * DevTools frontend together. It is also responsible for overriding existing
+ * WebInspector functionality while it is getting upstreamed into WebCore.
+ */
+
+var context = {}; // Used by WebCore's inspector routines.
+
+(function () {
+ Preferences.ignoreWhitespace = false;
+ Preferences.samplingCPUProfiler = true;
+ Preferences.heapProfilerPresent = true;
+ Preferences.debuggerAlwaysEnabled = true;
+ Preferences.profilerAlwaysEnabled = true;
+ Preferences.canEditScriptSource = true;
+ Preferences.onlineDetectionEnabled = false;
+ Preferences.nativeInstrumentationEnabled = true;
+ Preferences.fileSystemEnabled = false;
+ Preferences.resourceExportEnabled = true;
+ Preferences.showTimingTab = true;
+ Preferences.showCookiesTab = true;
+})();
+
+var devtools = devtools || {};
+
+devtools.domContentLoaded = function()
+{
+ WebInspector.setAttachedWindow(WebInspector.queryParamsObject.docked === "true");
+ if (WebInspector.queryParamsObject.toolbar_color && WebInspector.queryParamsObject.text_color)
+ WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbar_color, WebInspector.queryParamsObject.text_color);
+}
+document.addEventListener("DOMContentLoaded", devtools.domContentLoaded, false);
+
+
+// FIXME: This needs to be upstreamed.
+(function InterceptProfilesPanelEvents()
+{
+ var oldShow = WebInspector.ProfilesPanel.prototype.show;
+ WebInspector.ProfilesPanel.prototype.show = function()
+ {
+ this.enableToggleButton.visible = false;
+ oldShow.call(this);
+ // Show is called on every show event of a panel, so
+ // we only need to intercept it once.
+ WebInspector.ProfilesPanel.prototype.show = oldShow;
+ };
+})();
+
+
+/*
+ * @override
+ * TODO(mnaganov): Restore l10n when it will be agreed that it is needed.
+ */
+WebInspector.UIString = function(string)
+{
+ return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));
+};
+
+
+/** Pending WebKit upstream by apavlov). Fixes iframe vs drag problem. */
+(function()
+{
+ var originalDragStart = WebInspector.elementDragStart;
+ WebInspector.elementDragStart = function(element)
+ {
+ if (element) {
+ var glassPane = document.createElement("div");
+ glassPane.style.cssText = "position:absolute;width:100%;height:100%;opacity:0;z-index:1";
+ glassPane.id = "glass-pane-for-drag";
+ element.parentElement.appendChild(glassPane);
+ }
+
+ originalDragStart.apply(this, arguments);
+ };
+
+ var originalDragEnd = WebInspector.elementDragEnd;
+ WebInspector.elementDragEnd = function()
+ {
+ originalDragEnd.apply(this, arguments);
+
+ var glassPane = document.getElementById("glass-pane-for-drag");
+ if (glassPane)
+ glassPane.parentElement.removeChild(glassPane);
+ };
+})();
+
+
+
+///////////////////////////////////////////
+// Chromium layout test harness support. //
+///////////////////////////////////////////
+
+WebInspector.runAfterPendingDispatchesQueue = [];
+
+WebInspector.TestController.prototype.runAfterPendingDispatches = function(callback)
+{
+ WebInspector.runAfterPendingDispatchesQueue.push(callback);
+};
+
+WebInspector.queuesAreEmpty = function()
+{
+ var copy = this.runAfterPendingDispatchesQueue.slice();
+ this.runAfterPendingDispatchesQueue = [];
+ for (var i = 0; i < copy.length; ++i)
+ copy[i].call(this);
+};
+
+
+/////////////////////////////
+// Chromium theme support. //
+/////////////////////////////
+
+WebInspector.setToolbarColors = function(backgroundColor, color)
+{
+ if (!WebInspector._themeStyleElement) {
+ WebInspector._themeStyleElement = document.createElement("style");
+ document.head.appendChild(WebInspector._themeStyleElement);
+ }
+ WebInspector._themeStyleElement.textContent =
+ "#toolbar {\
+ background-image: none !important;\
+ background-color: " + backgroundColor + " !important;\
+ }\
+ \
+ .toolbar-label {\
+ color: " + color + " !important;\
+ text-shadow: none;\
+ }";
+}
+
+WebInspector.resetToolbarColors = function()
+{
+ if (WebInspector._themeStyleElement)
+ WebInspector._themeStyleElement.textContent = "";
+
+}
+
+////////////////////////////////////////////////////////
+// Platform-specific WebInspector extensions support. //
+////////////////////////////////////////////////////////
+
+WebInspector.platformExtensionAPI = function(tabId)
+{
+ function getTabId()
+ {
+ return tabId;
+ }
+ webInspector.inspectedWindow.__proto__.__defineGetter__("tabId", getTabId);
+}
+
+WebInspector.buildPlatformExtensionAPI = function()
+{
+ return "(" + WebInspector.platformExtensionAPI + ")(" + WebInspector._inspectedTabId + ");";
+}
+
+WebInspector.setInspectedTabId = function(tabId)
+{
+ WebInspector._inspectedTabId = tabId;
+}
diff --git a/Source/WebKit/chromium/src/js/Images/segmentChromium.png b/Source/WebKit/chromium/src/js/Images/segmentChromium.png
new file mode 100755
index 0000000..f4248e1
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/segmentChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/segmentHoverChromium.png b/Source/WebKit/chromium/src/js/Images/segmentHoverChromium.png
new file mode 100755
index 0000000..0a743d9
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/segmentHoverChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/segmentHoverEndChromium.png b/Source/WebKit/chromium/src/js/Images/segmentHoverEndChromium.png
new file mode 100755
index 0000000..cf62072
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/segmentHoverEndChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/segmentSelectedChromium.png b/Source/WebKit/chromium/src/js/Images/segmentSelectedChromium.png
new file mode 100755
index 0000000..a1f7251
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/segmentSelectedChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png b/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png
new file mode 100755
index 0000000..07641db
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/segmentSelectedEndChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/statusbarBackgroundChromium.png b/Source/WebKit/chromium/src/js/Images/statusbarBackgroundChromium.png
new file mode 100755
index 0000000..7a760c1
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/statusbarBackgroundChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/statusbarBottomBackgroundChromium.png b/Source/WebKit/chromium/src/js/Images/statusbarBottomBackgroundChromium.png
new file mode 100755
index 0000000..e3bc944
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/statusbarBottomBackgroundChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/statusbarButtonsChromium.png b/Source/WebKit/chromium/src/js/Images/statusbarButtonsChromium.png
new file mode 100755
index 0000000..136d5a8
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/statusbarButtonsChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/statusbarMenuButtonChromium.png b/Source/WebKit/chromium/src/js/Images/statusbarMenuButtonChromium.png
new file mode 100755
index 0000000..5ff61d9
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/statusbarMenuButtonChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Images/statusbarMenuButtonSelectedChromium.png b/Source/WebKit/chromium/src/js/Images/statusbarMenuButtonSelectedChromium.png
new file mode 100755
index 0000000..3c0aeec
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Images/statusbarMenuButtonSelectedChromium.png
Binary files differ
diff --git a/Source/WebKit/chromium/src/js/Tests.js b/Source/WebKit/chromium/src/js/Tests.js
new file mode 100644
index 0000000..900d79e
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/Tests.js
@@ -0,0 +1,813 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/**
+ * @fileoverview This file contains small testing framework along with the
+ * test suite for the frontend. These tests are a part of the continues build
+ * and are executed by the devtools_sanity_unittest.cc as a part of the
+ * Interactive UI Test suite.
+ * FIXME: change field naming style to use trailing underscore.
+ */
+
+if (window.domAutomationController) {
+
+var ___interactiveUiTestsMode = true;
+
+/**
+ * Test suite for interactive UI tests.
+ * @constructor
+ */
+TestSuite = function()
+{
+ this.controlTaken_ = false;
+ this.timerId_ = -1;
+};
+
+
+/**
+ * Reports test failure.
+ * @param {string} message Failure description.
+ */
+TestSuite.prototype.fail = function(message)
+{
+ if (this.controlTaken_)
+ this.reportFailure_(message);
+ else
+ throw message;
+};
+
+
+/**
+ * Equals assertion tests that expected === actual.
+ * @param {Object} expected Expected object.
+ * @param {Object} actual Actual object.
+ * @param {string} opt_message User message to print if the test fails.
+ */
+TestSuite.prototype.assertEquals = function(expected, actual, opt_message)
+{
+ if (expected !== actual) {
+ var message = "Expected: '" + expected + "', but was '" + actual + "'";
+ if (opt_message)
+ message = opt_message + "(" + message + ")";
+ this.fail(message);
+ }
+};
+
+
+/**
+ * True assertion tests that value == true.
+ * @param {Object} value Actual object.
+ * @param {string} opt_message User message to print if the test fails.
+ */
+TestSuite.prototype.assertTrue = function(value, opt_message)
+{
+ this.assertEquals(true, !!value, opt_message);
+};
+
+
+/**
+ * Contains assertion tests that string contains substring.
+ * @param {string} string Outer.
+ * @param {string} substring Inner.
+ */
+TestSuite.prototype.assertContains = function(string, substring)
+{
+ if (string.indexOf(substring) === -1)
+ this.fail("Expected to: '" + string + "' to contain '" + substring + "'");
+};
+
+
+/**
+ * Takes control over execution.
+ */
+TestSuite.prototype.takeControl = function()
+{
+ this.controlTaken_ = true;
+ // Set up guard timer.
+ var self = this;
+ this.timerId_ = setTimeout(function() {
+ self.reportFailure_("Timeout exceeded: 20 sec");
+ }, 20000);
+};
+
+
+/**
+ * Releases control over execution.
+ */
+TestSuite.prototype.releaseControl = function()
+{
+ if (this.timerId_ !== -1) {
+ clearTimeout(this.timerId_);
+ this.timerId_ = -1;
+ }
+ this.reportOk_();
+};
+
+
+/**
+ * Async tests use this one to report that they are completed.
+ */
+TestSuite.prototype.reportOk_ = function()
+{
+ window.domAutomationController.send("[OK]");
+};
+
+
+/**
+ * Async tests use this one to report failures.
+ */
+TestSuite.prototype.reportFailure_ = function(error)
+{
+ if (this.timerId_ !== -1) {
+ clearTimeout(this.timerId_);
+ this.timerId_ = -1;
+ }
+ window.domAutomationController.send("[FAILED] " + error);
+};
+
+
+/**
+ * Runs all global functions starting with "test" as unit tests.
+ */
+TestSuite.prototype.runTest = function(testName)
+{
+ try {
+ this[testName]();
+ if (!this.controlTaken_)
+ this.reportOk_();
+ } catch (e) {
+ this.reportFailure_(e);
+ }
+};
+
+
+/**
+ * @param {string} panelName Name of the panel to show.
+ */
+TestSuite.prototype.showPanel = function(panelName)
+{
+ // Open Scripts panel.
+ var toolbar = document.getElementById("toolbar");
+ var button = toolbar.getElementsByClassName(panelName)[0];
+ button.click();
+ this.assertEquals(WebInspector.panels[panelName], WebInspector.currentPanel);
+};
+
+
+/**
+ * Overrides the method with specified name until it's called first time.
+ * @param {Object} receiver An object whose method to override.
+ * @param {string} methodName Name of the method to override.
+ * @param {Function} override A function that should be called right after the
+ * overriden method returns.
+ * @param {boolean} opt_sticky Whether restore original method after first run
+ * or not.
+ */
+TestSuite.prototype.addSniffer = function(receiver, methodName, override, opt_sticky)
+{
+ var orig = receiver[methodName];
+ if (typeof orig !== "function")
+ this.fail("Cannot find method to override: " + methodName);
+ var test = this;
+ receiver[methodName] = function(var_args) {
+ try {
+ var result = orig.apply(this, arguments);
+ } finally {
+ if (!opt_sticky)
+ receiver[methodName] = orig;
+ }
+ // In case of exception the override won't be called.
+ try {
+ override.apply(this, arguments);
+ } catch (e) {
+ test.fail("Exception in overriden method '" + methodName + "': " + e);
+ }
+ return result;
+ };
+};
+
+
+TestSuite.prototype.testEnableResourcesTab = function()
+{
+ // FIXME once reference is removed downstream.
+}
+
+TestSuite.prototype.testCompletionOnPause = function()
+{
+ // FIXME once reference is removed downstream.
+}
+
+// UI Tests
+
+
+/**
+ * Tests that profiler works.
+ */
+TestSuite.prototype.testProfilerTab = function()
+{
+ this.showPanel("profiles");
+
+ var panel = WebInspector.panels.profiles;
+ var test = this;
+
+ function findDisplayedNode() {
+ var node = panel.visibleView.profileDataGridTree.children[0];
+ if (!node) {
+ // Profile hadn't been queried yet, re-schedule.
+ window.setTimeout(findDisplayedNode, 100);
+ return;
+ }
+
+ // Iterate over displayed functions and search for a function
+ // that is called "fib" or "eternal_fib". If found, this will mean
+ // that we actually have profiled page's code.
+ while (node) {
+ if (node.functionName.indexOf("fib") !== -1)
+ test.releaseControl();
+ node = node.traverseNextNode(true, null, true);
+ }
+
+ test.fail();
+ }
+
+ function findVisibleView() {
+ if (!panel.visibleView) {
+ setTimeout(findVisibleView, 0);
+ return;
+ }
+ setTimeout(findDisplayedNode, 0);
+ }
+
+ findVisibleView();
+ this.takeControl();
+};
+
+
+/**
+ * Tests that heap profiler works.
+ */
+TestSuite.prototype.testHeapProfiler = function()
+{
+ this.showPanel("profiles");
+
+ var panel = WebInspector.panels.profiles;
+ var test = this;
+
+ function findDisplayedNode() {
+ var node = panel.visibleView.dataGrid.children[0];
+ if (!node) {
+ // Profile hadn't been queried yet, re-schedule.
+ window.setTimeout(findDisplayedNode, 100);
+ return;
+ }
+
+ // Iterate over displayed functions and find node called "A"
+ // If found, this will mean that we actually have taken heap snapshot.
+ while (node) {
+ if (node.constructorName.indexOf("A") !== -1) {
+ test.releaseControl();
+ return;
+ }
+ node = node.traverseNextNode(false, null, true);
+ }
+
+ test.fail();
+ }
+
+ function findVisibleView() {
+ if (!panel.visibleView) {
+ setTimeout(findVisibleView, 0);
+ return;
+ }
+ setTimeout(findDisplayedNode, 0);
+ }
+
+ WebInspector.HeapSnapshotProfileType.prototype.buttonClicked();
+ findVisibleView();
+ this.takeControl();
+};
+
+
+/**
+ * Tests that scripts tab can be open and populated with inspected scripts.
+ */
+TestSuite.prototype.testShowScriptsTab = function()
+{
+ this.showPanel("scripts");
+ var test = this;
+ // There should be at least main page script.
+ this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
+ function() {
+ test.releaseControl();
+ });
+ // Wait until all scripts are added to the debugger.
+ this.takeControl();
+};
+
+
+/**
+ * Tests that scripts tab is populated with inspected scripts even if it
+ * hadn't been shown by the moment inspected paged refreshed.
+ * @see http://crbug.com/26312
+ */
+TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh = function()
+{
+ var test = this;
+ this.assertEquals(WebInspector.panels.elements, WebInspector.currentPanel, "Elements panel should be current one.");
+
+ this.addSniffer(WebInspector.panels.scripts, "reset", waitUntilScriptIsParsed);
+
+ // Reload inspected page. It will reset the debugger agent.
+ test.evaluateInConsole_(
+ "window.location.reload(true);",
+ function(resultText) {});
+
+ function waitUntilScriptIsParsed() {
+ test.showPanel("scripts");
+ test._waitUntilScriptsAreParsed(["debugger_test_page.html"],
+ function() {
+ test.releaseControl();
+ });
+ }
+
+ // Wait until all scripts are added to the debugger.
+ this.takeControl();
+};
+
+
+/**
+ * Tests that scripts list contains content scripts.
+ */
+TestSuite.prototype.testContentScriptIsPresent = function()
+{
+ this.showPanel("scripts");
+ var test = this;
+
+ test._waitUntilScriptsAreParsed(
+ ["page_with_content_script.html", "simple_content_script.js"],
+ function() {
+ test.releaseControl();
+ });
+
+ // Wait until all scripts are added to the debugger.
+ this.takeControl();
+};
+
+
+/**
+ * Tests that scripts are not duplicaed on Scripts tab switch.
+ */
+TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function()
+{
+ var test = this;
+
+ // There should be two scripts: one for the main page and another
+ // one which is source of console API(see
+ // InjectedScript._ensureCommandLineAPIInstalled).
+ var expectedScriptsCount = 2;
+ var parsedScripts = [];
+
+ this.showPanel("scripts");
+
+
+ function switchToElementsTab() {
+ test.showPanel("elements");
+ setTimeout(switchToScriptsTab, 0);
+ }
+
+ function switchToScriptsTab() {
+ test.showPanel("scripts");
+ setTimeout(checkScriptsPanel, 0);
+ }
+
+ function checkScriptsPanel() {
+ test.assertTrue(!!WebInspector.panels.scripts.visibleView, "No visible script view.");
+ test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html"]), "Some scripts are missing.");
+ checkNoDuplicates();
+ test.releaseControl();
+ }
+
+ function checkNoDuplicates() {
+ var scriptSelect = document.getElementById("scripts-files");
+ var options = scriptSelect.options;
+ for (var i = 0; i < options.length; i++) {
+ var scriptName = options[i].text;
+ for (var j = i + 1; j < options.length; j++)
+ test.assertTrue(scriptName !== options[j].text, "Found script duplicates: " + test.optionsToString_(options));
+ }
+ }
+
+ test._waitUntilScriptsAreParsed(
+ ["debugger_test_page.html"],
+ function() {
+ checkNoDuplicates();
+ setTimeout(switchToElementsTab, 0);
+ });
+
+
+ // Wait until all scripts are added to the debugger.
+ this.takeControl();
+};
+
+
+// Tests that debugger works correctly if pause event occurs when DevTools
+// frontend is being loaded.
+TestSuite.prototype.testPauseWhenLoadingDevTools = function()
+{
+ this.showPanel("scripts");
+ var test = this;
+
+ var expectations = {
+ functionsOnStack: ["callDebugger"],
+ lineNumber: 8,
+ lineText: " debugger;"
+ };
+
+
+ // Script execution can already be paused.
+ if (WebInspector.currentPanel.paused) {
+ var callFrame = WebInspector.currentPanel.sidebarPanes.callstack.selectedCallFrame;
+ this.assertEquals(expectations.functionsOnStack[0], callFrame.functionName);
+ var callbackInvoked = false;
+ this._checkSourceFrameWhenLoaded(expectations, function() {
+ callbackInvoked = true;
+ if (test.controlTaken_)
+ test.releaseControl();
+ });
+ if (!callbackInvoked) {
+ test.takeControl();
+ }
+ return;
+ }
+
+ this._waitForScriptPause(
+ {
+ functionsOnStack: ["callDebugger"],
+ lineNumber: 8,
+ lineText: " debugger;"
+ },
+ function() {
+ test.releaseControl();
+ });
+ this.takeControl();
+};
+
+
+// Tests that pressing "Pause" will pause script execution if the script
+// is already running.
+TestSuite.prototype.testPauseWhenScriptIsRunning = function()
+{
+ this.showPanel("scripts");
+ var test = this;
+
+ test.evaluateInConsole_(
+ 'setTimeout("handleClick()" , 0)',
+ function(resultText) {
+ test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText);
+ testScriptPauseAfterDelay();
+ });
+
+ // Wait for some time to make sure that inspected page is running the
+ // infinite loop.
+ function testScriptPauseAfterDelay() {
+ setTimeout(testScriptPause, 300);
+ }
+
+ function testScriptPause() {
+ // The script should be in infinite loop. Click "Pause" button to
+ // pause it and wait for the result.
+ WebInspector.panels.scripts.pauseButton.click();
+
+ test._waitForScriptPause(
+ {
+ functionsOnStack: ["handleClick", ""],
+ lineNumber: 5,
+ lineText: " while(true) {"
+ },
+ function() {
+ test.releaseControl();
+ });
+ }
+
+ this.takeControl();
+};
+
+
+/**
+ * Serializes options collection to string.
+ * @param {HTMLOptionsCollection} options
+ * @return {string}
+ */
+TestSuite.prototype.optionsToString_ = function(options)
+{
+ var names = [];
+ for (var i = 0; i < options.length; i++)
+ names.push('"' + options[i].text + '"');
+ return names.join(",");
+};
+
+
+/**
+ * Ensures that main HTML resource is selected in Scripts panel and that its
+ * source frame is setup. Invokes the callback when the condition is satisfied.
+ * @param {HTMLOptionsCollection} options
+ * @param {function(WebInspector.SourceView,string)} callback
+ */
+TestSuite.prototype.showMainPageScriptSource_ = function(scriptName, callback)
+{
+ var test = this;
+
+ var scriptSelect = document.getElementById("scripts-files");
+ var options = scriptSelect.options;
+
+ test.assertTrue(options.length, "Scripts list is empty");
+
+ // Select page's script if it's not current option.
+ var scriptResource;
+ if (options[scriptSelect.selectedIndex].text === scriptName)
+ scriptResource = options[scriptSelect.selectedIndex].representedObject;
+ else {
+ var pageScriptIndex = -1;
+ for (var i = 0; i < options.length; i++) {
+ if (options[i].text === scriptName) {
+ pageScriptIndex = i;
+ break;
+ }
+ }
+ test.assertTrue(-1 !== pageScriptIndex, "Script with url " + scriptName + " not found among " + test.optionsToString_(options));
+ scriptResource = options[pageScriptIndex].representedObject;
+
+ // Current panel is "Scripts".
+ WebInspector.currentPanel._showScriptOrResource(scriptResource);
+ test.assertEquals(pageScriptIndex, scriptSelect.selectedIndex, "Unexpected selected option index.");
+ }
+
+ test.assertTrue(scriptResource instanceof WebInspector.Resource,
+ "Unexpected resource class.");
+ test.assertTrue(!!scriptResource.url, "Resource URL is null.");
+ test.assertTrue(scriptResource.url.search(scriptName + "$") !== -1, "Main HTML resource should be selected.");
+
+ var scriptsPanel = WebInspector.panels.scripts;
+
+ var view = scriptsPanel.visibleView;
+ test.assertTrue(view instanceof WebInspector.SourceView);
+
+ if (!view.sourceFrame._loaded) {
+ test.addSniffer(view, "_sourceFrameSetupFinished", function(event) {
+ callback(view, scriptResource.url);
+ });
+ } else
+ callback(view, scriptResource.url);
+};
+
+
+/*
+ * Evaluates the code in the console as if user typed it manually and invokes
+ * the callback when the result message is received and added to the console.
+ * @param {string} code
+ * @param {function(string)} callback
+ */
+TestSuite.prototype.evaluateInConsole_ = function(code, callback)
+{
+ WebInspector.showConsole();
+ WebInspector.console.prompt.text = code;
+ WebInspector.console.promptElement.dispatchEvent( TestSuite.createKeyEvent("Enter"));
+
+ this.addSniffer(WebInspector.ConsoleView.prototype, "addMessage",
+ function(commandResult) {
+ callback(commandResult.toMessageElement().textContent);
+ });
+};
+
+
+/**
+ * Checks current execution line against expectations.
+ * @param {WebInspector.SourceFrame} sourceFrame
+ * @param {number} lineNumber Expected line number
+ * @param {string} lineContent Expected line text
+ */
+TestSuite.prototype._checkExecutionLine = function(sourceFrame, lineNumber, lineContent)
+{
+ this.assertEquals(lineNumber, sourceFrame._executionLine, "Unexpected execution line number.");
+ this.assertEquals(lineContent, sourceFrame._textModel.line(lineNumber - 1), "Unexpected execution line text.");
+}
+
+
+/**
+ * Checks that all expected scripts are present in the scripts list
+ * in the Scripts panel.
+ * @param {Array.<string>} expected Regular expressions describing
+ * expected script names.
+ * @return {boolean} Whether all the scripts are in "scripts-files" select
+ * box
+ */
+TestSuite.prototype._scriptsAreParsed = function(expected)
+{
+ var scriptSelect = document.getElementById("scripts-files");
+ var options = scriptSelect.options;
+
+ // Check that at least all the expected scripts are present.
+ var missing = expected.slice(0);
+ for (var i = 0 ; i < options.length; i++) {
+ for (var j = 0; j < missing.length; j++) {
+ if (options[i].text.search(missing[j]) !== -1) {
+ missing.splice(j, 1);
+ break;
+ }
+ }
+ }
+ return missing.length === 0;
+};
+
+
+/**
+ * Waits for script pause, checks expectations, and invokes the callback.
+ * @param {Object} expectations Dictionary of expectations
+ * @param {function():void} callback
+ */
+TestSuite.prototype._waitForScriptPause = function(expectations, callback)
+{
+ var test = this;
+ // Wait until script is paused.
+ test.addSniffer(
+ WebInspector.debuggerModel,
+ "_pausedScript",
+ function(details) {
+ var callFrames = details.callFrames;
+ var functionsOnStack = [];
+ for (var i = 0; i < callFrames.length; i++)
+ functionsOnStack.push(callFrames[i].functionName);
+
+ test.assertEquals(expectations.functionsOnStack.join(","), functionsOnStack.join(","), "Unexpected stack.");
+
+ // Check that execution line where the script is paused is
+ // expected one.
+ test._checkSourceFrameWhenLoaded(expectations, callback);
+ });
+};
+
+
+/**
+ * Waits for current source frame to load, checks expectations, and invokes
+ * the callback.
+ * @param {Object} expectations Dictionary of expectations
+ * @param {function():void} callback
+ */
+TestSuite.prototype._checkSourceFrameWhenLoaded = function(expectations, callback)
+{
+ var test = this;
+
+ var frame = WebInspector.currentPanel.visibleView.sourceFrame;
+
+ if (frame._textViewer)
+ checkExecLine();
+ else {
+ setTimeout(function() {
+ test._checkSourceFrameWhenLoaded(expectations, callback);
+ }, 100);
+ }
+ function checkExecLine() {
+ test._checkExecutionLine(frame, expectations.lineNumber, expectations.lineText);
+ callback();
+ }
+};
+
+
+/**
+ * Waits until all the scripts are parsed and asynchronously executes the code
+ * in the inspected page.
+ */
+TestSuite.prototype._executeCodeWhenScriptsAreParsed = function(code, expectedScripts)
+{
+ var test = this;
+
+ function executeFunctionInInspectedPage() {
+ // Since breakpoints are ignored in evals' calculate() function is
+ // execute after zero-timeout so that the breakpoint is hit.
+ test.evaluateInConsole_(
+ 'setTimeout("' + code + '" , 0)',
+ function(resultText) {
+ test.assertTrue(!isNaN(resultText), "Failed to get timer id: " + resultText + ". Code: " + code);
+ });
+ }
+
+ test._waitUntilScriptsAreParsed(expectedScripts, executeFunctionInInspectedPage);
+};
+
+
+/**
+ * Waits until all the scripts are parsed and invokes the callback.
+ */
+TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callback)
+{
+ var test = this;
+
+ function waitForAllScripts() {
+ if (test._scriptsAreParsed(expectedScripts))
+ callback();
+ else
+ test.addSniffer(WebInspector.debuggerModel, "_parsedScriptSource", waitForAllScripts);
+ }
+
+ waitForAllScripts();
+};
+
+
+/**
+ * Key event with given key identifier.
+ */
+TestSuite.createKeyEvent = function(keyIdentifier)
+{
+ var evt = document.createEvent("KeyboardEvent");
+ evt.initKeyboardEvent("keydown", true /* can bubble */, true /* can cancel */, null /* view */, keyIdentifier, "");
+ return evt;
+};
+
+
+/**
+ * Test runner for the test suite.
+ */
+var uiTests = {};
+
+
+/**
+ * Run each test from the test suit on a fresh instance of the suite.
+ */
+uiTests.runAllTests = function()
+{
+ // For debugging purposes.
+ for (var name in TestSuite.prototype) {
+ if (name.substring(0, 4) === "test" && typeof TestSuite.prototype[name] === "function")
+ uiTests.runTest(name);
+ }
+};
+
+
+/**
+ * Run specified test on a fresh instance of the test suite.
+ * @param {string} name Name of a test method from TestSuite class.
+ */
+uiTests.runTest = function(name)
+{
+ if (uiTests._populatedInterface)
+ new TestSuite().runTest(name);
+ else
+ uiTests._pendingTestName = name;
+};
+
+(function() {
+
+function runTests()
+{
+ uiTests._populatedInterface = true;
+ var name = uiTests._pendingTestName;
+ delete uiTests._pendingTestName;
+ if (name)
+ new TestSuite().runTest(name);
+}
+
+var oldShowElementsPanel = WebInspector.showElementsPanel;
+WebInspector.showElementsPanel = function()
+{
+ oldShowElementsPanel.call(this);
+ runTests();
+}
+
+var oldShowPanel = WebInspector.showPanel;
+WebInspector.showPanel = function(name)
+{
+ oldShowPanel.call(this, name);
+ runTests();
+}
+
+})();
+
+}
diff --git a/Source/WebKit/chromium/src/js/devTools.css b/Source/WebKit/chromium/src/js/devTools.css
new file mode 100644
index 0000000..64ea9d5
--- /dev/null
+++ b/Source/WebKit/chromium/src/js/devTools.css
@@ -0,0 +1,117 @@
+.data-grid table {
+ line-height: 120%;
+}
+
+body.attached #toolbar {
+ height: 34px;
+ border-top: 1px solid rgb(100, 100, 100);
+ cursor: default; /* overriden */
+ padding-left: 0;
+}
+
+/* Chrome theme overrides */
+
+body.platform-windows #toolbar, body.platform-windows.inactive #toolbar {
+ background-image: none;
+}
+
+body.detached.platform-mac-leopard #toolbar {
+ background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(175, 175, 175)), to(rgb(151, 151, 151))) !important;
+}
+
+body.detached.platform-mac-leopard.inactive #toolbar {
+ background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(221, 221, 221)), to(rgb(207, 207, 207))) !important;
+}
+
+body.detached.platform-mac-snowleopard #toolbar {
+ background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(189, 189, 189)), to(rgb(151, 151, 151))) !important;
+}
+
+body.detached.platform-mac-snowleopard.inactive #toolbar {
+ background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(215, 215, 215)), to(rgb(207, 207, 207))) !important;
+}
+
+body.platform-linux #scripts-files {
+ font-size: 11px;
+ font-weight: normal;
+ line-height: 12px;
+}
+
+.console-group-messages .section > .header {
+ padding: 0 8px 0 0;
+ background-image: none;
+ border: none;
+ min-height: 0;
+}
+
+#resources-filter {
+ background: -webkit-gradient(linear, left top, left bottom, from(rgb(233, 233, 233)), to(rgb(233, 233, 233)));
+}
+
+.crumbs .crumb {
+ -webkit-border-image: url(Images/segmentChromium.png) 0 12 0 2;
+ margin-right: -3px;
+ padding-left: 6px;
+}
+
+.crumbs .crumb.selected {
+ -webkit-border-image: url(Images/segmentSelectedChromium.png) 0 12 0 2;
+ color: white;
+ text-shadow: rgba(255, 255, 255, 0.5) 0 0px 0;
+}
+
+.crumbs .crumb.selected:hover {
+ -webkit-border-image: url(Images/segmentSelectedChromium.png) 0 12 0 2;
+}
+
+.crumbs .crumb.selected.end, .crumbs .crumb.selected.end:hover {
+ -webkit-border-image: url(Images/segmentSelectedEndChromium.png) 0 2 0 2;
+}
+
+.crumbs .crumb:hover {
+ -webkit-border-image: url(Images/segmentHoverChromium.png) 0 12 0 2;
+}
+
+.crumbs .crumb.dimmed:hover {
+ -webkit-border-image: url(Images/segmentHoverChromium.png) 0 12 0 2;
+}
+
+.crumbs .crumb.end:hover {
+ -webkit-border-image: url(Images/segmentHoverEndChromium.png) 0 2 0 2;
+}
+
+body.drawer-visible #main-status-bar {
+ background-image: url(Images/statusbarResizerVertical.png), url(Images/statusbarBackgroundChromium.png);
+}
+
+.status-bar {
+ background-image: url(Images/statusbarBackgroundChromium.png);
+}
+
+button.status-bar-item {
+ background-image: url(Images/statusbarButtonsChromium.png);
+}
+
+select.status-bar-item:active {
+ -webkit-border-image: url(Images/statusbarMenuButtonSelectedChromium.png) 0 17 0 2;
+}
+
+#drawer {
+ background-image: url(Images/statusbarBottomBackgroundChromium.png);
+}
+
+select.status-bar-item {
+ -webkit-border-image: url(Images/statusbarMenuButtonChromium.png) 0 17 0 2;
+}
+
+.scope-bar li.selected {
+ -webkit-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.0);
+}
+
+.scope-bar li:active {
+ -webkit-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.0);
+}
+
+.timeline-category-statusbar-item input {
+ vertical-align: middle;
+}
diff --git a/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp b/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp
new file mode 100644
index 0000000..0b864d1
--- /dev/null
+++ b/Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFontRenderStyle.h"
+
+#include "FontRenderStyle.h"
+
+using WebCore::FontRenderStyle;
+
+namespace WebKit {
+
+void WebFontRenderStyle::toFontRenderStyle(FontRenderStyle* out)
+{
+ out->useBitmaps = useBitmaps;
+ out->useAutoHint = useAutoHint;
+ out->useHinting = useHinting;
+ out->hintStyle = hintStyle;
+ out->useAntiAlias = useAntiAlias;
+ out->useSubpixel = useSubpixel;
+}
+
+void WebFontRenderStyle::setDefaults()
+{
+ useBitmaps = 2;
+ useAutoHint = 2;
+ useHinting = 2;
+ hintStyle = 0;
+ useAntiAlias = 2;
+ useSubpixel = 2;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/linux/WebFontRendering.cpp b/Source/WebKit/chromium/src/linux/WebFontRendering.cpp
new file mode 100644
index 0000000..b9862f5
--- /dev/null
+++ b/Source/WebKit/chromium/src/linux/WebFontRendering.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFontRendering.h"
+
+#include "FontPlatformData.h"
+
+using WebCore::FontPlatformData;
+
+namespace WebKit {
+
+// static
+void WebFontRendering::setHinting(SkPaint::Hinting hinting)
+{
+ FontPlatformData::setHinting(hinting);
+}
+
+// static
+void WebFontRendering::setAntiAlias(bool isAntiAlias)
+{
+ FontPlatformData::setAntiAlias(isAntiAlias);
+}
+
+// static
+void WebFontRendering::setSubpixelGlyphs(bool isSubpixelGlyphs)
+{
+ FontPlatformData::setSubpixelGlyphs(isSubpixelGlyphs);
+}
+
+// static
+void WebFontRendering::setLCDOrder(SkFontHost::LCDOrder order)
+{
+ SkFontHost::SetSubpixelOrder(order);
+}
+
+// static
+void WebFontRendering::setLCDOrientation(SkFontHost::LCDOrientation orientation)
+{
+ SkFontHost::SetSubpixelOrientation(orientation);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/linux/WebRenderTheme.cpp b/Source/WebKit/chromium/src/linux/WebRenderTheme.cpp
new file mode 100644
index 0000000..16ea22c
--- /dev/null
+++ b/Source/WebKit/chromium/src/linux/WebRenderTheme.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Joel Stanley. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebRenderTheme.h"
+
+#include "RenderThemeChromiumLinux.h"
+#include "WebView.h"
+
+using WebCore::RenderTheme;
+using WebCore::RenderThemeChromiumLinux;
+
+namespace WebKit {
+
+void setCaretBlinkInterval(double interval)
+{
+ RenderThemeChromiumLinux::setCaretBlinkInterval(interval);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/mac/WebInputEventFactory.mm b/Source/WebKit/chromium/src/mac/WebInputEventFactory.mm
new file mode 100644
index 0000000..55883c9
--- /dev/null
+++ b/Source/WebKit/chromium/src/mac/WebInputEventFactory.mm
@@ -0,0 +1,1206 @@
+/*
+ * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2009 Google Inc.
+ *
+ * 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 COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputEventFactory.h"
+
+#include <ApplicationServices/ApplicationServices.h>
+#import <Cocoa/Cocoa.h>
+
+#include "WebInputEvent.h"
+#include <wtf/ASCIICType.h>
+
+namespace WebKit {
+
+// WebKeyboardEvent -----------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// Begin Apple code, copied from KeyEventMac.mm
+//
+// We can share some of this code if we factored it out of KeyEventMac, but
+// the main problem is that it relies on the NSString ctor on String for
+// conversions, and since we're building without PLATFORM(MAC), we don't have
+// that. As a result we have to use NSString here exclusively and thus tweak
+// the code so it's not re-usable as-is. One possiblity would be to make the
+// upstream code only use NSString, but I'm not certain how far that change
+// would propagate.
+
+static inline bool isKeyUpEvent(NSEvent* event)
+{
+ if ([event type] != NSFlagsChanged)
+ return [event type] == NSKeyUp;
+ // FIXME: This logic fails if the user presses both Shift keys at once, for example:
+ // we treat releasing one of them as keyDown.
+ switch ([event keyCode]) {
+ case 54: // Right Command
+ case 55: // Left Command
+ return ([event modifierFlags] & NSCommandKeyMask) == 0;
+
+ case 57: // Capslock
+ return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0;
+
+ case 56: // Left Shift
+ case 60: // Right Shift
+ return ([event modifierFlags] & NSShiftKeyMask) == 0;
+
+ case 58: // Left Alt
+ case 61: // Right Alt
+ return ([event modifierFlags] & NSAlternateKeyMask) == 0;
+
+ case 59: // Left Ctrl
+ case 62: // Right Ctrl
+ return ([event modifierFlags] & NSControlKeyMask) == 0;
+
+ case 63: // Function
+ return ([event modifierFlags] & NSFunctionKeyMask) == 0;
+ }
+ return false;
+}
+
+static bool isKeypadEvent(NSEvent* event)
+{
+ // Check that this is the type of event that has a keyCode.
+ switch ([event type]) {
+ case NSKeyDown:
+ case NSKeyUp:
+ case NSFlagsChanged:
+ break;
+ default:
+ return false;
+ }
+
+ if ([event modifierFlags] & NSNumericPadKeyMask)
+ return true;
+
+ switch ([event keyCode]) {
+ case 71: // Clear
+ case 81: // =
+ case 75: // /
+ case 67: // *
+ case 78: // -
+ case 69: // +
+ case 76: // Enter
+ case 65: // .
+ case 82: // 0
+ case 83: // 1
+ case 84: // 2
+ case 85: // 3
+ case 86: // 4
+ case 87: // 5
+ case 88: // 6
+ case 89: // 7
+ case 91: // 8
+ case 92: // 9
+ return true;
+ }
+
+ return false;
+}
+
+static int windowsKeyCodeForKeyEvent(NSEvent* event)
+{
+ switch ([event keyCode]) {
+ // VK_TAB (09) TAB key
+ case 48:
+ return 0x09;
+
+ // VK_APPS (5D) Right windows/meta key
+ case 54: // Right Command
+ return 0x5D;
+
+ // VK_LWIN (5B) Left windows/meta key
+ case 55: // Left Command
+ return 0x5B;
+
+ // VK_CAPITAL (14) caps locks key
+ case 57: // Capslock
+ return 0x14;
+
+ // VK_SHIFT (10) either shift key
+ case 56: // Left Shift
+ case 60: // Right Shift
+ return 0x10;
+
+ // VK_MENU (12) either alt key
+ case 58: // Left Alt
+ case 61: // Right Alt
+ return 0x12;
+
+ // VK_CONTROL (11) either ctrl key
+ case 59: // Left Ctrl
+ case 62: // Right Ctrl
+ return 0x11;
+
+// Begin non-Apple addition ---------------------------------------------------
+ case 63: // Function (no Windows key code)
+ return 0;
+// End non-Apple addition -----------------------------------------------------
+
+ // VK_CLEAR (0C) CLEAR key
+ case 71: return 0x0C;
+
+ // VK_NUMPAD0 (60) Numeric keypad 0 key
+ case 82: return 0x60;
+ // VK_NUMPAD1 (61) Numeric keypad 1 key
+ case 83: return 0x61;
+ // VK_NUMPAD2 (62) Numeric keypad 2 key
+ case 84: return 0x62;
+ // VK_NUMPAD3 (63) Numeric keypad 3 key
+ case 85: return 0x63;
+ // VK_NUMPAD4 (64) Numeric keypad 4 key
+ case 86: return 0x64;
+ // VK_NUMPAD5 (65) Numeric keypad 5 key
+ case 87: return 0x65;
+ // VK_NUMPAD6 (66) Numeric keypad 6 key
+ case 88: return 0x66;
+ // VK_NUMPAD7 (67) Numeric keypad 7 key
+ case 89: return 0x67;
+ // VK_NUMPAD8 (68) Numeric keypad 8 key
+ case 91: return 0x68;
+ // VK_NUMPAD9 (69) Numeric keypad 9 key
+ case 92: return 0x69;
+ // VK_MULTIPLY (6A) Multiply key
+ case 67: return 0x6A;
+ // VK_ADD (6B) Add key
+ case 69: return 0x6B;
+
+ // VK_SUBTRACT (6D) Subtract key
+ case 78: return 0x6D;
+ // VK_DECIMAL (6E) Decimal key
+ case 65: return 0x6E;
+ // VK_DIVIDE (6F) Divide key
+ case 75: return 0x6F;
+ }
+
+// Begin non-Apple addition ---------------------------------------------------
+ // |-[NSEvent charactersIgnoringModifiers]| isn't allowed for
+ // NSFlagsChanged, and conceivably we may not have caught everything
+ // which causes an NSFlagsChanged above.
+ if ([event type] == NSFlagsChanged)
+ return 0;
+// End non-Apple addition -----------------------------------------------------
+
+ NSString* s = [event charactersIgnoringModifiers];
+ if ([s length] != 1)
+ return 0;
+
+ switch ([s characterAtIndex:0]) {
+ // VK_LBUTTON (01) Left mouse button
+ // VK_RBUTTON (02) Right mouse button
+ // VK_CANCEL (03) Control-break processing
+ // VK_MBUTTON (04) Middle mouse button (three-button mouse)
+ // VK_XBUTTON1 (05)
+ // VK_XBUTTON2 (06)
+
+ // VK_BACK (08) BACKSPACE key
+ case 8: case 0x7F: return 0x08;
+ // VK_TAB (09) TAB key
+ case 9: return 0x09;
+
+ // VK_CLEAR (0C) CLEAR key
+ // handled by key code above
+
+ // VK_RETURN (0D)
+ case 0xD: case 3: return 0x0D;
+
+ // VK_SHIFT (10) SHIFT key
+ // VK_CONTROL (11) CTRL key
+ // VK_MENU (12) ALT key
+
+ // VK_PAUSE (13) PAUSE key
+ case NSPauseFunctionKey: return 0x13;
+
+ // VK_CAPITAL (14) CAPS LOCK key
+ // VK_KANA (15) Input Method Editor (IME) Kana mode
+ // VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
+ // VK_HANGUL (15) IME Hangul mode
+ // VK_JUNJA (17) IME Junja mode
+ // VK_FINAL (18) IME final mode
+ // VK_HANJA (19) IME Hanja mode
+ // VK_KANJI (19) IME Kanji mode
+
+ // VK_ESCAPE (1B) ESC key
+ case 0x1B: return 0x1B;
+
+ // VK_CONVERT (1C) IME convert
+ // VK_NONCONVERT (1D) IME nonconvert
+ // VK_ACCEPT (1E) IME accept
+ // VK_MODECHANGE (1F) IME mode change request
+
+ // VK_SPACE (20) SPACEBAR
+ case ' ': return 0x20;
+ // VK_PRIOR (21) PAGE UP key
+ case NSPageUpFunctionKey: return 0x21;
+ // VK_NEXT (22) PAGE DOWN key
+ case NSPageDownFunctionKey: return 0x22;
+ // VK_END (23) END key
+ case NSEndFunctionKey: return 0x23;
+ // VK_HOME (24) HOME key
+ case NSHomeFunctionKey: return 0x24;
+ // VK_LEFT (25) LEFT ARROW key
+ case NSLeftArrowFunctionKey: return 0x25;
+ // VK_UP (26) UP ARROW key
+ case NSUpArrowFunctionKey: return 0x26;
+ // VK_RIGHT (27) RIGHT ARROW key
+ case NSRightArrowFunctionKey: return 0x27;
+ // VK_DOWN (28) DOWN ARROW key
+ case NSDownArrowFunctionKey: return 0x28;
+ // VK_SELECT (29) SELECT key
+ case NSSelectFunctionKey: return 0x29;
+ // VK_PRINT (2A) PRINT key
+ case NSPrintFunctionKey: return 0x2A;
+ // VK_EXECUTE (2B) EXECUTE key
+ case NSExecuteFunctionKey: return 0x2B;
+ // VK_SNAPSHOT (2C) PRINT SCREEN key
+ case NSPrintScreenFunctionKey: return 0x2C;
+ // VK_INSERT (2D) INS key
+ case NSInsertFunctionKey: case NSHelpFunctionKey: return 0x2D;
+ // VK_DELETE (2E) DEL key
+ case NSDeleteFunctionKey: return 0x2E;
+
+ // VK_HELP (2F) HELP key
+
+ // (30) 0 key
+ case '0': case ')': return 0x30;
+ // (31) 1 key
+ case '1': case '!': return 0x31;
+ // (32) 2 key
+ case '2': case '@': return 0x32;
+ // (33) 3 key
+ case '3': case '#': return 0x33;
+ // (34) 4 key
+ case '4': case '$': return 0x34;
+ // (35) 5 key
+ case '5': case '%': return 0x35;
+ // (36) 6 key
+ case '6': case '^': return 0x36;
+ // (37) 7 key
+ case '7': case '&': return 0x37;
+ // (38) 8 key
+ case '8': case '*': return 0x38;
+ // (39) 9 key
+ case '9': case '(': return 0x39;
+ // (41) A key
+ case 'a': case 'A': return 0x41;
+ // (42) B key
+ case 'b': case 'B': return 0x42;
+ // (43) C key
+ case 'c': case 'C': return 0x43;
+ // (44) D key
+ case 'd': case 'D': return 0x44;
+ // (45) E key
+ case 'e': case 'E': return 0x45;
+ // (46) F key
+ case 'f': case 'F': return 0x46;
+ // (47) G key
+ case 'g': case 'G': return 0x47;
+ // (48) H key
+ case 'h': case 'H': return 0x48;
+ // (49) I key
+ case 'i': case 'I': return 0x49;
+ // (4A) J key
+ case 'j': case 'J': return 0x4A;
+ // (4B) K key
+ case 'k': case 'K': return 0x4B;
+ // (4C) L key
+ case 'l': case 'L': return 0x4C;
+ // (4D) M key
+ case 'm': case 'M': return 0x4D;
+ // (4E) N key
+ case 'n': case 'N': return 0x4E;
+ // (4F) O key
+ case 'o': case 'O': return 0x4F;
+ // (50) P key
+ case 'p': case 'P': return 0x50;
+ // (51) Q key
+ case 'q': case 'Q': return 0x51;
+ // (52) R key
+ case 'r': case 'R': return 0x52;
+ // (53) S key
+ case 's': case 'S': return 0x53;
+ // (54) T key
+ case 't': case 'T': return 0x54;
+ // (55) U key
+ case 'u': case 'U': return 0x55;
+ // (56) V key
+ case 'v': case 'V': return 0x56;
+ // (57) W key
+ case 'w': case 'W': return 0x57;
+ // (58) X key
+ case 'x': case 'X': return 0x58;
+ // (59) Y key
+ case 'y': case 'Y': return 0x59;
+ // (5A) Z key
+ case 'z': case 'Z': return 0x5A;
+
+ // VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
+ // VK_RWIN (5C) Right Windows key (Natural keyboard)
+ // VK_APPS (5D) Applications key (Natural keyboard)
+ // VK_SLEEP (5F) Computer Sleep key
+
+ // VK_NUMPAD0 (60) Numeric keypad 0 key
+ // VK_NUMPAD1 (61) Numeric keypad 1 key
+ // VK_NUMPAD2 (62) Numeric keypad 2 key
+ // VK_NUMPAD3 (63) Numeric keypad 3 key
+ // VK_NUMPAD4 (64) Numeric keypad 4 key
+ // VK_NUMPAD5 (65) Numeric keypad 5 key
+ // VK_NUMPAD6 (66) Numeric keypad 6 key
+ // VK_NUMPAD7 (67) Numeric keypad 7 key
+ // VK_NUMPAD8 (68) Numeric keypad 8 key
+ // VK_NUMPAD9 (69) Numeric keypad 9 key
+ // VK_MULTIPLY (6A) Multiply key
+ // VK_ADD (6B) Add key
+ // handled by key code above
+
+ // VK_SEPARATOR (6C) Separator key
+
+ // VK_SUBTRACT (6D) Subtract key
+ // VK_DECIMAL (6E) Decimal key
+ // VK_DIVIDE (6F) Divide key
+ // handled by key code above
+
+ // VK_F1 (70) F1 key
+ case NSF1FunctionKey: return 0x70;
+ // VK_F2 (71) F2 key
+ case NSF2FunctionKey: return 0x71;
+ // VK_F3 (72) F3 key
+ case NSF3FunctionKey: return 0x72;
+ // VK_F4 (73) F4 key
+ case NSF4FunctionKey: return 0x73;
+ // VK_F5 (74) F5 key
+ case NSF5FunctionKey: return 0x74;
+ // VK_F6 (75) F6 key
+ case NSF6FunctionKey: return 0x75;
+ // VK_F7 (76) F7 key
+ case NSF7FunctionKey: return 0x76;
+ // VK_F8 (77) F8 key
+ case NSF8FunctionKey: return 0x77;
+ // VK_F9 (78) F9 key
+ case NSF9FunctionKey: return 0x78;
+ // VK_F10 (79) F10 key
+ case NSF10FunctionKey: return 0x79;
+ // VK_F11 (7A) F11 key
+ case NSF11FunctionKey: return 0x7A;
+ // VK_F12 (7B) F12 key
+ case NSF12FunctionKey: return 0x7B;
+ // VK_F13 (7C) F13 key
+ case NSF13FunctionKey: return 0x7C;
+ // VK_F14 (7D) F14 key
+ case NSF14FunctionKey: return 0x7D;
+ // VK_F15 (7E) F15 key
+ case NSF15FunctionKey: return 0x7E;
+ // VK_F16 (7F) F16 key
+ case NSF16FunctionKey: return 0x7F;
+ // VK_F17 (80H) F17 key
+ case NSF17FunctionKey: return 0x80;
+ // VK_F18 (81H) F18 key
+ case NSF18FunctionKey: return 0x81;
+ // VK_F19 (82H) F19 key
+ case NSF19FunctionKey: return 0x82;
+ // VK_F20 (83H) F20 key
+ case NSF20FunctionKey: return 0x83;
+ // VK_F21 (84H) F21 key
+ case NSF21FunctionKey: return 0x84;
+ // VK_F22 (85H) F22 key
+ case NSF22FunctionKey: return 0x85;
+ // VK_F23 (86H) F23 key
+ case NSF23FunctionKey: return 0x86;
+ // VK_F24 (87H) F24 key
+ case NSF24FunctionKey: return 0x87;
+
+ // VK_NUMLOCK (90) NUM LOCK key
+
+ // VK_SCROLL (91) SCROLL LOCK key
+ case NSScrollLockFunctionKey: return 0x91;
+
+ // VK_LSHIFT (A0) Left SHIFT key
+ // VK_RSHIFT (A1) Right SHIFT key
+ // VK_LCONTROL (A2) Left CONTROL key
+ // VK_RCONTROL (A3) Right CONTROL key
+ // VK_LMENU (A4) Left MENU key
+ // VK_RMENU (A5) Right MENU key
+ // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
+ // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
+ // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
+ // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
+ // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
+ // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
+ // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
+ // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
+ // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
+ // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
+ // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
+ // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
+ // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
+ // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
+ // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
+ // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
+ // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
+ // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
+
+ // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
+ case ';': case ':': return 0xBA;
+ // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
+ case '=': case '+': return 0xBB;
+ // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
+ case ',': case '<': return 0xBC;
+ // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
+ case '-': case '_': return 0xBD;
+ // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
+ case '.': case '>': return 0xBE;
+ // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
+ case '/': case '?': return 0xBF;
+ // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
+ case '`': case '~': return 0xC0;
+ // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
+ case '[': case '{': return 0xDB;
+ // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
+ case '\\': case '|': return 0xDC;
+ // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
+ case ']': case '}': return 0xDD;
+ // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
+ case '\'': case '"': return 0xDE;
+
+ // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
+ // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
+ // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
+ // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
+ // VK_ATTN (F6) Attn key
+ // VK_CRSEL (F7) CrSel key
+ // VK_EXSEL (F8) ExSel key
+ // VK_EREOF (F9) Erase EOF key
+ // VK_PLAY (FA) Play key
+ // VK_ZOOM (FB) Zoom key
+ // VK_NONAME (FC) Reserved for future use
+ // VK_PA1 (FD) PA1 key
+ // VK_OEM_CLEAR (FE) Clear key
+ }
+
+ return 0;
+}
+
+static inline NSString* textFromEvent(NSEvent* event)
+{
+ if ([event type] == NSFlagsChanged)
+ return @"";
+ return [event characters];
+}
+
+static inline NSString* unmodifiedTextFromEvent(NSEvent* event)
+{
+ if ([event type] == NSFlagsChanged)
+ return @"";
+ return [event charactersIgnoringModifiers];
+}
+
+static NSString* keyIdentifierForKeyEvent(NSEvent* event)
+{
+ if ([event type] == NSFlagsChanged) {
+ switch ([event keyCode]) {
+ case 54: // Right Command
+ case 55: // Left Command
+ return @"Meta";
+
+ case 57: // Capslock
+ return @"CapsLock";
+
+ case 56: // Left Shift
+ case 60: // Right Shift
+ return @"Shift";
+
+ case 58: // Left Alt
+ case 61: // Right Alt
+ return @"Alt";
+
+ case 59: // Left Ctrl
+ case 62: // Right Ctrl
+ return @"Control";
+
+// Begin non-Apple addition/modification --------------------------------------
+ case 63: // Function
+ return @"Function";
+
+ default: // Unknown, but this may be a strange/new keyboard.
+ return @"Unidentified";
+// End non-Apple addition/modification ----------------------------------------
+ }
+ }
+
+ NSString* s = [event charactersIgnoringModifiers];
+ if ([s length] != 1)
+ return @"Unidentified";
+
+ unichar c = [s characterAtIndex:0];
+ switch (c) {
+ // Each identifier listed in the DOM spec is listed here.
+ // Many are simply commented out since they do not appear on standard Macintosh keyboards
+ // or are on a key that doesn't have a corresponding character.
+
+ // "Accept"
+ // "AllCandidates"
+
+ // "Alt"
+ case NSMenuFunctionKey:
+ return @"Alt";
+
+ // "Apps"
+ // "BrowserBack"
+ // "BrowserForward"
+ // "BrowserHome"
+ // "BrowserRefresh"
+ // "BrowserSearch"
+ // "BrowserStop"
+ // "CapsLock"
+
+ // "Clear"
+ case NSClearLineFunctionKey:
+ return @"Clear";
+
+ // "CodeInput"
+ // "Compose"
+ // "Control"
+ // "Crsel"
+ // "Convert"
+ // "Copy"
+ // "Cut"
+
+ // "Down"
+ case NSDownArrowFunctionKey:
+ return @"Down";
+ // "End"
+ case NSEndFunctionKey:
+ return @"End";
+ // "Enter"
+ case 0x3: case 0xA: case 0xD: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM
+ return @"Enter";
+
+ // "EraseEof"
+
+ // "Execute"
+ case NSExecuteFunctionKey:
+ return @"Execute";
+
+ // "Exsel"
+
+ // "F1"
+ case NSF1FunctionKey:
+ return @"F1";
+ // "F2"
+ case NSF2FunctionKey:
+ return @"F2";
+ // "F3"
+ case NSF3FunctionKey:
+ return @"F3";
+ // "F4"
+ case NSF4FunctionKey:
+ return @"F4";
+ // "F5"
+ case NSF5FunctionKey:
+ return @"F5";
+ // "F6"
+ case NSF6FunctionKey:
+ return @"F6";
+ // "F7"
+ case NSF7FunctionKey:
+ return @"F7";
+ // "F8"
+ case NSF8FunctionKey:
+ return @"F8";
+ // "F9"
+ case NSF9FunctionKey:
+ return @"F9";
+ // "F10"
+ case NSF10FunctionKey:
+ return @"F10";
+ // "F11"
+ case NSF11FunctionKey:
+ return @"F11";
+ // "F12"
+ case NSF12FunctionKey:
+ return @"F12";
+ // "F13"
+ case NSF13FunctionKey:
+ return @"F13";
+ // "F14"
+ case NSF14FunctionKey:
+ return @"F14";
+ // "F15"
+ case NSF15FunctionKey:
+ return @"F15";
+ // "F16"
+ case NSF16FunctionKey:
+ return @"F16";
+ // "F17"
+ case NSF17FunctionKey:
+ return @"F17";
+ // "F18"
+ case NSF18FunctionKey:
+ return @"F18";
+ // "F19"
+ case NSF19FunctionKey:
+ return @"F19";
+ // "F20"
+ case NSF20FunctionKey:
+ return @"F20";
+ // "F21"
+ case NSF21FunctionKey:
+ return @"F21";
+ // "F22"
+ case NSF22FunctionKey:
+ return @"F22";
+ // "F23"
+ case NSF23FunctionKey:
+ return @"F23";
+ // "F24"
+ case NSF24FunctionKey:
+ return @"F24";
+
+ // "FinalMode"
+
+ // "Find"
+ case NSFindFunctionKey:
+ return @"Find";
+
+ // "FullWidth"
+ // "HalfWidth"
+ // "HangulMode"
+ // "HanjaMode"
+
+ // "Help"
+ case NSHelpFunctionKey:
+ return @"Help";
+
+ // "Hiragana"
+
+ // "Home"
+ case NSHomeFunctionKey:
+ return @"Home";
+ // "Insert"
+ case NSInsertFunctionKey:
+ return @"Insert";
+
+ // "JapaneseHiragana"
+ // "JapaneseKatakana"
+ // "JapaneseRomaji"
+ // "JunjaMode"
+ // "KanaMode"
+ // "KanjiMode"
+ // "Katakana"
+ // "LaunchApplication1"
+ // "LaunchApplication2"
+ // "LaunchMail"
+
+ // "Left"
+ case NSLeftArrowFunctionKey:
+ return @"Left";
+
+ // "Meta"
+ // "MediaNextTrack"
+ // "MediaPlayPause"
+ // "MediaPreviousTrack"
+ // "MediaStop"
+
+ // "ModeChange"
+ case NSModeSwitchFunctionKey:
+ return @"ModeChange";
+
+ // "Nonconvert"
+ // "NumLock"
+
+ // "PageDown"
+ case NSPageDownFunctionKey:
+ return @"PageDown";
+ // "PageUp"
+ case NSPageUpFunctionKey:
+ return @"PageUp";
+
+ // "Paste"
+
+ // "Pause"
+ case NSPauseFunctionKey:
+ return @"Pause";
+
+ // "Play"
+ // "PreviousCandidate"
+
+ // "PrintScreen"
+ case NSPrintScreenFunctionKey:
+ return @"PrintScreen";
+
+ // "Process"
+ // "Props"
+
+ // "Right"
+ case NSRightArrowFunctionKey:
+ return @"Right";
+
+ // "RomanCharacters"
+
+ // "Scroll"
+ case NSScrollLockFunctionKey:
+ return @"Scroll";
+ // "Select"
+ case NSSelectFunctionKey:
+ return @"Select";
+
+ // "SelectMedia"
+ // "Shift"
+
+ // "Stop"
+ case NSStopFunctionKey:
+ return @"Stop";
+ // "Up"
+ case NSUpArrowFunctionKey:
+ return @"Up";
+ // "Undo"
+ case NSUndoFunctionKey:
+ return @"Undo";
+
+ // "VolumeDown"
+ // "VolumeMute"
+ // "VolumeUp"
+ // "Win"
+ // "Zoom"
+
+ // More function keys, not in the key identifier specification.
+ case NSF25FunctionKey:
+ return @"F25";
+ case NSF26FunctionKey:
+ return @"F26";
+ case NSF27FunctionKey:
+ return @"F27";
+ case NSF28FunctionKey:
+ return @"F28";
+ case NSF29FunctionKey:
+ return @"F29";
+ case NSF30FunctionKey:
+ return @"F30";
+ case NSF31FunctionKey:
+ return @"F31";
+ case NSF32FunctionKey:
+ return @"F32";
+ case NSF33FunctionKey:
+ return @"F33";
+ case NSF34FunctionKey:
+ return @"F34";
+ case NSF35FunctionKey:
+ return @"F35";
+
+ // Turn 0x7F into 0x08, because backspace needs to always be 0x08.
+ case 0x7F:
+ return @"U+0008";
+ // Standard says that DEL becomes U+007F.
+ case NSDeleteFunctionKey:
+ return @"U+007F";
+
+ // Always use 0x09 for tab instead of AppKit's backtab character.
+ case NSBackTabCharacter:
+ return @"U+0009";
+
+ case NSBeginFunctionKey:
+ case NSBreakFunctionKey:
+ case NSClearDisplayFunctionKey:
+ case NSDeleteCharFunctionKey:
+ case NSDeleteLineFunctionKey:
+ case NSInsertCharFunctionKey:
+ case NSInsertLineFunctionKey:
+ case NSNextFunctionKey:
+ case NSPrevFunctionKey:
+ case NSPrintFunctionKey:
+ case NSRedoFunctionKey:
+ case NSResetFunctionKey:
+ case NSSysReqFunctionKey:
+ case NSSystemFunctionKey:
+ case NSUserFunctionKey:
+ // FIXME: We should use something other than the vendor-area Unicode values for the above keys.
+ // For now, just fall through to the default.
+ default:
+ return [NSString stringWithFormat:@"U+%04X", WTF::toASCIIUpper(c)];
+ }
+}
+
+// End Apple code.
+// ----------------------------------------------------------------------------
+
+static inline int modifiersFromEvent(NSEvent* event) {
+ int modifiers = 0;
+
+ if ([event modifierFlags] & NSControlKeyMask)
+ modifiers |= WebInputEvent::ControlKey;
+ if ([event modifierFlags] & NSShiftKeyMask)
+ modifiers |= WebInputEvent::ShiftKey;
+ if ([event modifierFlags] & NSAlternateKeyMask)
+ modifiers |= WebInputEvent::AltKey;
+ if ([event modifierFlags] & NSCommandKeyMask)
+ modifiers |= WebInputEvent::MetaKey;
+ if ([event modifierFlags] & NSAlphaShiftKeyMask)
+ modifiers |= WebInputEvent::CapsLockOn;
+ // TODO(port): Set mouse button states
+
+ return modifiers;
+}
+
+static inline void setWebEventLocationFromEventInView(WebMouseEvent* result,
+ NSEvent* event,
+ NSView* view) {
+ NSPoint windowLocal = [event locationInWindow];
+
+ NSPoint screenLocal = [[view window] convertBaseToScreen:windowLocal];
+ result->globalX = screenLocal.x;
+ // Flip y.
+ NSScreen* primaryScreen = ([[NSScreen screens] count] > 0) ?
+ [[NSScreen screens] objectAtIndex:0] : nil;
+ if (primaryScreen)
+ result->globalY = [primaryScreen frame].size.height - screenLocal.y;
+ else
+ result->globalY = screenLocal.y;
+
+ NSPoint contentLocal = [view convertPoint:windowLocal fromView:nil];
+ result->x = contentLocal.x;
+ result->y = [view frame].size.height - contentLocal.y; // Flip y.
+
+ result->windowX = result->x;
+ result->windowY = result->y;
+}
+
+WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event)
+{
+ WebKeyboardEvent result;
+
+ result.type =
+ isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::RawKeyDown;
+
+ result.modifiers = modifiersFromEvent(event);
+
+ if (isKeypadEvent(event))
+ result.modifiers |= WebInputEvent::IsKeyPad;
+
+ if (([event type] != NSFlagsChanged) && [event isARepeat])
+ result.modifiers |= WebInputEvent::IsAutoRepeat;
+
+ result.windowsKeyCode = windowsKeyCodeForKeyEvent(event);
+ result.nativeKeyCode = [event keyCode];
+
+ NSString* textStr = textFromEvent(event);
+ NSString* unmodifiedStr = unmodifiedTextFromEvent(event);
+ NSString* identifierStr = keyIdentifierForKeyEvent(event);
+
+ // Begin Apple code, copied from KeyEventMac.mm
+
+ // Always use 13 for Enter/Return -- we don't want to use AppKit's
+ // different character for Enter.
+ if (result.windowsKeyCode == '\r') {
+ textStr = @"\r";
+ unmodifiedStr = @"\r";
+ }
+
+ // The adjustments below are only needed in backward compatibility mode,
+ // but we cannot tell what mode we are in from here.
+
+ // Turn 0x7F into 8, because backspace needs to always be 8.
+ if ([textStr isEqualToString:@"\x7F"])
+ textStr = @"\x8";
+ if ([unmodifiedStr isEqualToString:@"\x7F"])
+ unmodifiedStr = @"\x8";
+ // Always use 9 for tab -- we don't want to use AppKit's different character
+ // for shift-tab.
+ if (result.windowsKeyCode == 9) {
+ textStr = @"\x9";
+ unmodifiedStr = @"\x9";
+ }
+
+ // End Apple code.
+
+ if ([textStr length] < WebKeyboardEvent::textLengthCap &&
+ [unmodifiedStr length] < WebKeyboardEvent::textLengthCap) {
+ [textStr getCharacters:&result.text[0]];
+ [unmodifiedStr getCharacters:&result.unmodifiedText[0]];
+ } else
+ ASSERT_NOT_REACHED();
+
+ [identifierStr getCString:&result.keyIdentifier[0]
+ maxLength:sizeof(result.keyIdentifier)
+ encoding:NSASCIIStringEncoding];
+
+ result.timeStampSeconds = [event timestamp];
+
+ // Windows and Linux set |isSystemKey| if alt is down. WebKit looks at this
+ // flag to decide if it should handle a key or not. E.g. alt-left/right
+ // shouldn't be used by WebKit to scroll the current page, because we want
+ // to get that key back for it to do history navigation. Hence, the
+ // corresponding situation on OS X is to set this for cmd key presses.
+ if (result.modifiers & WebInputEvent::MetaKey)
+ result.isSystemKey = true;
+
+ return result;
+}
+
+WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character,
+ int modifiers,
+ double timeStampSeconds)
+{
+ // keyboardEvent(NSEvent*) depends on the NSEvent object and
+ // it is hard to use it from methods of the NSTextInput protocol. For
+ // such methods, this function creates a WebInputEvent::Char event without
+ // using a NSEvent object.
+ WebKeyboardEvent result;
+ result.type = WebKit::WebInputEvent::Char;
+ result.timeStampSeconds = timeStampSeconds;
+ result.modifiers = modifiers;
+ result.windowsKeyCode = character;
+ result.nativeKeyCode = character;
+ result.text[0] = character;
+ result.unmodifiedText[0] = character;
+
+ // Windows and Linux set |isSystemKey| if alt is down. WebKit looks at this
+ // flag to decide if it should handle a key or not. E.g. alt-left/right
+ // shouldn't be used by WebKit to scroll the current page, because we want
+ // to get that key back for it to do history navigation. Hence, the
+ // corresponding situation on OS X is to set this for cmd key presses.
+ if (result.modifiers & WebInputEvent::MetaKey)
+ result.isSystemKey = true;
+
+ return result;
+}
+
+// WebMouseEvent --------------------------------------------------------------
+
+WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view)
+{
+ WebMouseEvent result;
+
+ result.clickCount = 0;
+
+ switch ([event type]) {
+ case NSMouseExited:
+ result.type = WebInputEvent::MouseLeave;
+ result.button = WebMouseEvent::ButtonNone;
+ break;
+ case NSLeftMouseDown:
+ result.type = WebInputEvent::MouseDown;
+ result.clickCount = [event clickCount];
+ result.button = WebMouseEvent::ButtonLeft;
+ break;
+ case NSOtherMouseDown:
+ result.type = WebInputEvent::MouseDown;
+ result.clickCount = [event clickCount];
+ result.button = WebMouseEvent::ButtonMiddle;
+ break;
+ case NSRightMouseDown:
+ result.type = WebInputEvent::MouseDown;
+ result.clickCount = [event clickCount];
+ result.button = WebMouseEvent::ButtonRight;
+ break;
+ case NSLeftMouseUp:
+ result.type = WebInputEvent::MouseUp;
+ result.clickCount = [event clickCount];
+ result.button = WebMouseEvent::ButtonLeft;
+ break;
+ case NSOtherMouseUp:
+ result.type = WebInputEvent::MouseUp;
+ result.clickCount = [event clickCount];
+ result.button = WebMouseEvent::ButtonMiddle;
+ break;
+ case NSRightMouseUp:
+ result.type = WebInputEvent::MouseUp;
+ result.clickCount = [event clickCount];
+ result.button = WebMouseEvent::ButtonRight;
+ break;
+ case NSMouseMoved:
+ case NSMouseEntered:
+ result.type = WebInputEvent::MouseMove;
+ break;
+ case NSLeftMouseDragged:
+ result.type = WebInputEvent::MouseMove;
+ result.button = WebMouseEvent::ButtonLeft;
+ break;
+ case NSOtherMouseDragged:
+ result.type = WebInputEvent::MouseMove;
+ result.button = WebMouseEvent::ButtonMiddle;
+ break;
+ case NSRightMouseDragged:
+ result.type = WebInputEvent::MouseMove;
+ result.button = WebMouseEvent::ButtonRight;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ setWebEventLocationFromEventInView(&result, event, view);
+
+ result.modifiers = modifiersFromEvent(event);
+
+ result.timeStampSeconds = [event timestamp];
+
+ return result;
+}
+
+// WebMouseWheelEvent ---------------------------------------------------------
+
+WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(NSEvent* event, NSView* view)
+{
+ WebMouseWheelEvent result;
+
+ result.type = WebInputEvent::MouseWheel;
+ result.button = WebMouseEvent::ButtonNone;
+
+ result.modifiers = modifiersFromEvent(event);
+
+ setWebEventLocationFromEventInView(&result, event, view);
+
+ // Of Mice and Men
+ // ---------------
+ //
+ // There are three types of scroll data available on a scroll wheel CGEvent.
+ // Apple's documentation ([1]) is rather vague in their differences, and not
+ // terribly helpful in deciding which to use. This is what's really going on.
+ //
+ // First, these events behave very differently depending on whether a standard
+ // wheel mouse is used (one that scrolls in discrete units) or a
+ // trackpad/Mighty Mouse is used (which both provide continuous scrolling).
+ // You must check to see which was used for the event by testing the
+ // kCGScrollWheelEventIsContinuous field.
+ //
+ // Second, these events refer to "axes". Axis 1 is the y-axis, and axis 2 is
+ // the x-axis.
+ //
+ // Third, there is a concept of mouse acceleration. Scrolling the same amount
+ // of physical distance will give you different results logically depending on
+ // whether you scrolled a little at a time or in one continuous motion. Some
+ // fields account for this while others do not.
+ //
+ // Fourth, for trackpads there is a concept of chunkiness. When scrolling
+ // continuously, events can be delivered in chunks. That is to say, lots of
+ // scroll events with delta 0 will be delivered, and every so often an event
+ // with a non-zero delta will be delivered, containing the accumulated deltas
+ // from all the intermediate moves. [2]
+ //
+ // For notchy wheel mice (kCGScrollWheelEventIsContinuous == 0)
+ // ------------------------------------------------------------
+ //
+ // kCGScrollWheelEventDeltaAxis*
+ // This is the rawest of raw events. For each mouse notch you get a value of
+ // +1/-1. This does not take acceleration into account and thus is less
+ // useful for building UIs.
+ //
+ // kCGScrollWheelEventPointDeltaAxis*
+ // This is smarter. In general, for each mouse notch you get a value of
+ // +1/-1, but this _does_ take acceleration into account, so you will get
+ // larger values on longer scrolls. This field would be ideal for building
+ // UIs except for one nasty bug: when the shift key is pressed, this set of
+ // fields fails to move the value into the axis2 field (the other two types
+ // of data do). This wouldn't be so bad except for the fact that while the
+ // number of axes is used in the creation of a CGScrollWheelEvent, there is
+ // no way to get that information out of the event once created.
+ //
+ // kCGScrollWheelEventFixedPtDeltaAxis*
+ // This is a fixed value, and for each mouse notch you get a value of
+ // +0.1/-0.1 (but, like above, scaled appropriately for acceleration). This
+ // value takes acceleration into account, and in fact is identical to the
+ // results you get from -[NSEvent delta*]. (That is, if you linked on Tiger
+ // or greater; see [2] for details.)
+ //
+ // A note about continuous devices
+ // -------------------------------
+ //
+ // There are two devices that provide continuous scrolling events (trackpads
+ // and Mighty Mouses) and they behave rather differently. The Mighty Mouse
+ // behaves a lot like a regular mouse. There is no chunking, and the
+ // FixedPtDelta values are the PointDelta values multiplied by 0.1. With the
+ // trackpad, though, there is chunking. While the FixedPtDelta values are
+ // reasonable (they occur about every fifth event but have values five times
+ // larger than usual) the Delta values are unreasonable. They don't appear to
+ // accumulate properly.
+ //
+ // For continuous devices (kCGScrollWheelEventIsContinuous != 0)
+ // -------------------------------------------------------------
+ //
+ // kCGScrollWheelEventDeltaAxis*
+ // This provides values with no acceleration. With a trackpad, these values
+ // are chunked but each non-zero value does not appear to be cumulative.
+ // This seems to be a bug.
+ //
+ // kCGScrollWheelEventPointDeltaAxis*
+ // This provides values with acceleration. With a trackpad, these values are
+ // not chunked and are highly accurate.
+ //
+ // kCGScrollWheelEventFixedPtDeltaAxis*
+ // This provides values with acceleration. With a trackpad, these values are
+ // chunked but unlike Delta events are properly cumulative.
+ //
+ // Summary
+ // -------
+ //
+ // In general the best approach to take is: determine if the event is
+ // continuous. If it is not, then use the FixedPtDelta events (or just stick
+ // with Cocoa events). They provide both acceleration and proper horizontal
+ // scrolling. If the event is continuous, then doing pixel scrolling with the
+ // PointDelta is the way to go. In general, avoid the Delta events. They're
+ // the oldest (dating back to 10.4, before CGEvents were public) but they lack
+ // acceleration and precision, making them useful only in specific edge cases.
+ //
+ // References
+ // ----------
+ //
+ // [1] <http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html>
+ // [2] <http://developer.apple.com/releasenotes/Cocoa/AppKitOlderNotes.html>
+ // Scroll to the section headed "NSScrollWheel events".
+ //
+ // P.S. The "smooth scrolling" option in the system preferences is utterly
+ // unrelated to any of this.
+
+ CGEventRef cgEvent = [event CGEvent];
+ ASSERT(cgEvent);
+
+ // Wheel ticks are supposed to be raw, unaccelerated values, one per physical
+ // mouse wheel notch. The delta event is perfect for this (being a good
+ // "specific edge case" as mentioned above). Trackpads, unfortunately, do
+ // event chunking, and sending mousewheel events with 0 ticks causes some
+ // websites to malfunction. Therefore, for all continuous input devices we use
+ // the point delta data instead, since we cannot distinguish trackpad data
+ // from data from any other continuous device.
+
+ // Conversion between wheel delta amounts and number of pixels to scroll.
+ static const double scrollbarPixelsPerCocoaTick = 40.0;
+
+ if (CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventIsContinuous)) {
+ result.deltaX = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2);
+ result.deltaY = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1);
+ result.wheelTicksX = result.deltaX / scrollbarPixelsPerCocoaTick;
+ result.wheelTicksY = result.deltaY / scrollbarPixelsPerCocoaTick;
+ } else {
+ result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick;
+ result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick;
+ result.wheelTicksY = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventDeltaAxis1);
+ result.wheelTicksX = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventDeltaAxis2);
+ }
+
+ result.timeStampSeconds = [event timestamp];
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm b/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm
new file mode 100644
index 0000000..2805f7a
--- /dev/null
+++ b/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebScreenInfoFactory.h"
+
+#import <AppKit/AppKit.h>
+
+#include "WebScreenInfo.h"
+
+namespace WebKit {
+
+static NSScreen* screenForWindow(NSWindow* window)
+{
+ NSScreen* screen = [window screen]; // nil if the window is off-screen
+ if (screen)
+ return screen;
+
+ NSArray* screens = [NSScreen screens];
+ if ([screens count] > 0)
+ return [screens objectAtIndex:0]; // screen containing the menubar
+
+ return nil;
+}
+
+static WebRect toUserSpace(const NSRect& rect, NSWindow* destination)
+{
+ CGRect userRect = NSRectToCGRect(rect);
+
+ userRect.origin.y =
+ NSMaxY([screenForWindow(destination) frame]) - (userRect.origin.y + userRect.size.height); // flip
+
+ if (destination) {
+ CGFloat scale = 1 / [destination userSpaceScaleFactor]; // scale down
+ userRect.origin.x *= scale;
+ userRect.origin.y *= scale;
+ userRect.size.width *= scale;
+ userRect.size.height *= scale;
+ }
+
+ return WebRect(userRect.origin.x,
+ userRect.origin.y,
+ userRect.size.width,
+ userRect.size.height);
+}
+
+WebScreenInfo WebScreenInfoFactory::screenInfo(NSView* view)
+{
+ NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]);
+
+ WebScreenInfo results;
+ results.depth =
+ NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]);
+ results.depthPerComponent =
+ NSBitsPerSampleFromDepth([[NSScreen deepestScreen] depth]);
+ results.isMonochrome = colorSpace == NSCalibratedWhiteColorSpace
+ || colorSpace == NSCalibratedBlackColorSpace
+ || colorSpace == NSDeviceWhiteColorSpace
+ || colorSpace == NSDeviceBlackColorSpace;
+ results.rect =
+ toUserSpace([screenForWindow([view window]) frame], [view window]);
+ results.availableRect =
+ toUserSpace([screenForWindow([view window]) visibleFrame], [view window]);
+ return results;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp b/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp
new file mode 100644
index 0000000..c71a3b6
--- /dev/null
+++ b/Source/WebKit/chromium/src/win/WebInputEventFactory.cpp
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2006-2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputEventFactory.h"
+
+#include "WebInputEvent.h"
+
+#include <wtf/Assertions.h>
+
+namespace WebKit {
+
+static const unsigned long defaultScrollLinesPerWheelDelta = 3;
+static const unsigned long defaultScrollCharsPerWheelDelta = 1;
+
+// WebKeyboardEvent -----------------------------------------------------------
+
+static bool isKeyPad(WPARAM wparam, LPARAM lparam)
+{
+ bool keypad = false;
+ switch (wparam) {
+ case VK_RETURN:
+ keypad = (lparam >> 16) & KF_EXTENDED;
+ break;
+ case VK_INSERT:
+ case VK_DELETE:
+ case VK_HOME:
+ case VK_END:
+ case VK_PRIOR:
+ case VK_NEXT:
+ case VK_UP:
+ case VK_DOWN:
+ case VK_LEFT:
+ case VK_RIGHT:
+ keypad = !((lparam >> 16) & KF_EXTENDED);
+ break;
+ case VK_NUMLOCK:
+ case VK_NUMPAD0:
+ case VK_NUMPAD1:
+ case VK_NUMPAD2:
+ case VK_NUMPAD3:
+ case VK_NUMPAD4:
+ case VK_NUMPAD5:
+ case VK_NUMPAD6:
+ case VK_NUMPAD7:
+ case VK_NUMPAD8:
+ case VK_NUMPAD9:
+ case VK_DIVIDE:
+ case VK_MULTIPLY:
+ case VK_SUBTRACT:
+ case VK_ADD:
+ case VK_DECIMAL:
+ case VK_CLEAR:
+ keypad = true;
+ break;
+ default:
+ keypad = false;
+ }
+ return keypad;
+}
+
+// Loads the state for toggle keys into the event.
+static void SetToggleKeyState(WebInputEvent* event)
+{
+ // Low bit set from GetKeyState indicates "toggled".
+ if (::GetKeyState(VK_NUMLOCK) & 1)
+ event->modifiers |= WebInputEvent::NumLockOn;
+ if (::GetKeyState(VK_CAPITAL) & 1)
+ event->modifiers |= WebInputEvent::CapsLockOn;
+}
+
+WebKeyboardEvent WebInputEventFactory::keyboardEvent(HWND hwnd, UINT message,
+ WPARAM wparam, LPARAM lparam)
+{
+ WebKeyboardEvent result;
+
+ // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that
+ // GetMessageTime() refers to is the same one that we're passed in? Perhaps
+ // one of the construction parameters should be the time passed by the
+ // caller, who would know for sure.
+ result.timeStampSeconds = GetMessageTime() / 1000.0;
+
+ result.windowsKeyCode = result.nativeKeyCode = static_cast<int>(wparam);
+
+ switch (message) {
+ case WM_SYSKEYDOWN:
+ result.isSystemKey = true;
+ case WM_KEYDOWN:
+ result.type = WebInputEvent::RawKeyDown;
+ break;
+ case WM_SYSKEYUP:
+ result.isSystemKey = true;
+ case WM_KEYUP:
+ result.type = WebInputEvent::KeyUp;
+ break;
+ case WM_IME_CHAR:
+ result.type = WebInputEvent::Char;
+ break;
+ case WM_SYSCHAR:
+ result.isSystemKey = true;
+ result.type = WebInputEvent::Char;
+ case WM_CHAR:
+ result.type = WebInputEvent::Char;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ if (result.type == WebInputEvent::Char || result.type == WebInputEvent::RawKeyDown) {
+ result.text[0] = result.windowsKeyCode;
+ result.unmodifiedText[0] = result.windowsKeyCode;
+ }
+ if (result.type != WebInputEvent::Char)
+ result.setKeyIdentifierFromWindowsKeyCode();
+
+ if (GetKeyState(VK_SHIFT) & 0x8000)
+ result.modifiers |= WebInputEvent::ShiftKey;
+ if (GetKeyState(VK_CONTROL) & 0x8000)
+ result.modifiers |= WebInputEvent::ControlKey;
+ if (GetKeyState(VK_MENU) & 0x8000)
+ result.modifiers |= WebInputEvent::AltKey;
+ // NOTE: There doesn't seem to be a way to query the mouse button state in
+ // this case.
+
+ if (LOWORD(lparam) > 1)
+ result.modifiers |= WebInputEvent::IsAutoRepeat;
+ if (isKeyPad(wparam, lparam))
+ result.modifiers |= WebInputEvent::IsKeyPad;
+
+ SetToggleKeyState(&result);
+ return result;
+}
+
+// WebMouseEvent --------------------------------------------------------------
+
+static int gLastClickCount;
+static double gLastClickTime;
+
+static LPARAM GetRelativeCursorPos(HWND hwnd)
+{
+ POINT pos = {-1, -1};
+ GetCursorPos(&pos);
+ ScreenToClient(hwnd, &pos);
+ return MAKELPARAM(pos.x, pos.y);
+}
+
+void WebInputEventFactory::resetLastClickState()
+{
+ gLastClickTime = gLastClickCount = 0;
+}
+
+WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message,
+ WPARAM wparam, LPARAM lparam)
+{
+ WebMouseEvent result; //(WebInputEvent::Uninitialized());
+
+ switch (message) {
+ case WM_MOUSEMOVE:
+ result.type = WebInputEvent::MouseMove;
+ if (wparam & MK_LBUTTON)
+ result.button = WebMouseEvent::ButtonLeft;
+ else if (wparam & MK_MBUTTON)
+ result.button = WebMouseEvent::ButtonMiddle;
+ else if (wparam & MK_RBUTTON)
+ result.button = WebMouseEvent::ButtonRight;
+ else
+ result.button = WebMouseEvent::ButtonNone;
+ break;
+ case WM_MOUSELEAVE:
+ result.type = WebInputEvent::MouseLeave;
+ result.button = WebMouseEvent::ButtonNone;
+ // set the current mouse position (relative to the client area of the
+ // current window) since none is specified for this event
+ lparam = GetRelativeCursorPos(hwnd);
+ break;
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ result.type = WebInputEvent::MouseDown;
+ result.button = WebMouseEvent::ButtonLeft;
+ break;
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONDBLCLK:
+ result.type = WebInputEvent::MouseDown;
+ result.button = WebMouseEvent::ButtonMiddle;
+ break;
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONDBLCLK:
+ result.type = WebInputEvent::MouseDown;
+ result.button = WebMouseEvent::ButtonRight;
+ break;
+ case WM_LBUTTONUP:
+ result.type = WebInputEvent::MouseUp;
+ result.button = WebMouseEvent::ButtonLeft;
+ break;
+ case WM_MBUTTONUP:
+ result.type = WebInputEvent::MouseUp;
+ result.button = WebMouseEvent::ButtonMiddle;
+ break;
+ case WM_RBUTTONUP:
+ result.type = WebInputEvent::MouseUp;
+ result.button = WebMouseEvent::ButtonRight;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that
+ // GetMessageTime() refers to is the same one that we're passed in? Perhaps
+ // one of the construction parameters should be the time passed by the
+ // caller, who would know for sure.
+ result.timeStampSeconds = GetMessageTime() / 1000.0;
+
+ // set position fields:
+
+ result.x = static_cast<short>(LOWORD(lparam));
+ result.y = static_cast<short>(HIWORD(lparam));
+ result.windowX = result.x;
+ result.windowY = result.y;
+
+ POINT globalPoint = { result.x, result.y };
+ ClientToScreen(hwnd, &globalPoint);
+
+ result.globalX = globalPoint.x;
+ result.globalY = globalPoint.y;
+
+ // calculate number of clicks:
+
+ // This differs slightly from the WebKit code in WebKit/win/WebView.cpp
+ // where their original code looks buggy.
+ static int lastClickPositionX;
+ static int lastClickPositionY;
+ static WebMouseEvent::Button lastClickButton = WebMouseEvent::ButtonLeft;
+
+ double currentTime = result.timeStampSeconds;
+ bool cancelPreviousClick =
+ (abs(lastClickPositionX - result.x) > (GetSystemMetrics(SM_CXDOUBLECLK) / 2))
+ || (abs(lastClickPositionY - result.y) > (GetSystemMetrics(SM_CYDOUBLECLK) / 2))
+ || ((currentTime - gLastClickTime) * 1000.0 > GetDoubleClickTime());
+
+ if (result.type == WebInputEvent::MouseDown) {
+ if (!cancelPreviousClick && (result.button == lastClickButton))
+ ++gLastClickCount;
+ else {
+ gLastClickCount = 1;
+ lastClickPositionX = result.x;
+ lastClickPositionY = result.y;
+ }
+ gLastClickTime = currentTime;
+ lastClickButton = result.button;
+ } else if (result.type == WebInputEvent::MouseMove
+ || result.type == WebInputEvent::MouseLeave) {
+ if (cancelPreviousClick) {
+ gLastClickCount = 0;
+ lastClickPositionX = 0;
+ lastClickPositionY = 0;
+ gLastClickTime = 0;
+ }
+ }
+ result.clickCount = gLastClickCount;
+
+ // set modifiers:
+
+ if (wparam & MK_CONTROL)
+ result.modifiers |= WebInputEvent::ControlKey;
+ if (wparam & MK_SHIFT)
+ result.modifiers |= WebInputEvent::ShiftKey;
+ if (GetKeyState(VK_MENU) & 0x8000)
+ result.modifiers |= WebInputEvent::AltKey;
+ if (wparam & MK_LBUTTON)
+ result.modifiers |= WebInputEvent::LeftButtonDown;
+ if (wparam & MK_MBUTTON)
+ result.modifiers |= WebInputEvent::MiddleButtonDown;
+ if (wparam & MK_RBUTTON)
+ result.modifiers |= WebInputEvent::RightButtonDown;
+
+ SetToggleKeyState(&result);
+ return result;
+}
+
+// WebMouseWheelEvent ---------------------------------------------------------
+
+WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(HWND hwnd, UINT message,
+ WPARAM wparam, LPARAM lparam)
+{
+ WebMouseWheelEvent result; //(WebInputEvent::Uninitialized());
+
+ result.type = WebInputEvent::MouseWheel;
+
+ // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that
+ // GetMessageTime() refers to is the same one that we're passed in? Perhaps
+ // one of the construction parameters should be the time passed by the
+ // caller, who would know for sure.
+ result.timeStampSeconds = GetMessageTime() / 1000.0;
+
+ result.button = WebMouseEvent::ButtonNone;
+
+ // Get key state, coordinates, and wheel delta from event.
+ typedef SHORT (WINAPI *GetKeyStateFunction)(int key);
+ GetKeyStateFunction getKeyState;
+ UINT keyState;
+ float wheelDelta;
+ bool horizontalScroll = false;
+ if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) {
+ // Synthesize mousewheel event from a scroll event. This is needed to
+ // simulate middle mouse scrolling in some laptops. Use GetAsyncKeyState
+ // for key state since we are synthesizing the input event.
+ getKeyState = GetAsyncKeyState;
+ keyState = 0;
+ if (getKeyState(VK_SHIFT))
+ keyState |= MK_SHIFT;
+ if (getKeyState(VK_CONTROL))
+ keyState |= MK_CONTROL;
+ // NOTE: There doesn't seem to be a way to query the mouse button state
+ // in this case.
+
+ POINT cursorPosition = {0};
+ GetCursorPos(&cursorPosition);
+ result.globalX = cursorPosition.x;
+ result.globalY = cursorPosition.y;
+
+ switch (LOWORD(wparam)) {
+ case SB_LINEUP: // == SB_LINELEFT
+ wheelDelta = WHEEL_DELTA;
+ break;
+ case SB_LINEDOWN: // == SB_LINERIGHT
+ wheelDelta = -WHEEL_DELTA;
+ break;
+ case SB_PAGEUP:
+ wheelDelta = 1;
+ result.scrollByPage = true;
+ break;
+ case SB_PAGEDOWN:
+ wheelDelta = -1;
+ result.scrollByPage = true;
+ break;
+ default: // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here.
+ wheelDelta = 0;
+ break;
+ }
+
+ if (message == WM_HSCROLL)
+ horizontalScroll = true;
+ } else {
+ // Non-synthesized event; we can just read data off the event.
+ getKeyState = GetKeyState;
+ keyState = GET_KEYSTATE_WPARAM(wparam);
+
+ result.globalX = static_cast<short>(LOWORD(lparam));
+ result.globalY = static_cast<short>(HIWORD(lparam));
+
+ wheelDelta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam));
+ if (message == WM_MOUSEHWHEEL) {
+ horizontalScroll = true;
+ wheelDelta = -wheelDelta; // Windows is <- -/+ ->, WebKit <- +/- ->.
+ }
+ }
+ if (keyState & MK_SHIFT)
+ horizontalScroll = true;
+
+ // Set modifiers based on key state.
+ if (keyState & MK_SHIFT)
+ result.modifiers |= WebInputEvent::ShiftKey;
+ if (keyState & MK_CONTROL)
+ result.modifiers |= WebInputEvent::ControlKey;
+ if (getKeyState(VK_MENU) & 0x8000)
+ result.modifiers |= WebInputEvent::AltKey;
+ if (keyState & MK_LBUTTON)
+ result.modifiers |= WebInputEvent::LeftButtonDown;
+ if (keyState & MK_MBUTTON)
+ result.modifiers |= WebInputEvent::MiddleButtonDown;
+ if (keyState & MK_RBUTTON)
+ result.modifiers |= WebInputEvent::RightButtonDown;
+
+ SetToggleKeyState(&result);
+
+ // Set coordinates by translating event coordinates from screen to client.
+ POINT clientPoint = { result.globalX, result.globalY };
+ MapWindowPoints(0, hwnd, &clientPoint, 1);
+ result.x = clientPoint.x;
+ result.y = clientPoint.y;
+ result.windowX = result.x;
+ result.windowY = result.y;
+
+ // Convert wheel delta amount to a number of pixels to scroll.
+ //
+ // How many pixels should we scroll per line? Gecko uses the height of the
+ // current line, which means scroll distance changes as you go through the
+ // page or go to different pages. IE 8 is ~60 px/line, although the value
+ // seems to vary slightly by page and zoom level. Also, IE defaults to
+ // smooth scrolling while Firefox doesn't, so it can get away with somewhat
+ // larger scroll values without feeling as jerky. Here we use 100 px per
+ // three lines (the default scroll amount is three lines per wheel tick).
+ // Even though we have smooth scrolling, we don't make this as large as IE
+ // because subjectively IE feels like it scrolls farther than you want while
+ // reading articles.
+ static const float scrollbarPixelsPerLine = 100.0f / 3.0f;
+ wheelDelta /= WHEEL_DELTA;
+ float scrollDelta = wheelDelta;
+ if (horizontalScroll) {
+ unsigned long scrollChars = defaultScrollCharsPerWheelDelta;
+ SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0);
+ // TODO(pkasting): Should probably have a different multiplier
+ // scrollbarPixelsPerChar here.
+ scrollDelta *= static_cast<float>(scrollChars) * scrollbarPixelsPerLine;
+ } else {
+ unsigned long scrollLines = defaultScrollLinesPerWheelDelta;
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
+ if (scrollLines == WHEEL_PAGESCROLL)
+ result.scrollByPage = true;
+ if (!result.scrollByPage)
+ scrollDelta *= static_cast<float>(scrollLines) * scrollbarPixelsPerLine;
+ }
+
+ // Set scroll amount based on above calculations. WebKit expects positive
+ // deltaY to mean "scroll up" and positive deltaX to mean "scroll left".
+ if (horizontalScroll) {
+ result.deltaX = scrollDelta;
+ result.wheelTicksX = wheelDelta;
+ } else {
+ result.deltaY = scrollDelta;
+ result.wheelTicksY = wheelDelta;
+ }
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp b/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp
new file mode 100644
index 0000000..8416acc
--- /dev/null
+++ b/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebScreenInfoFactory.h"
+
+#include "WebScreenInfo.h"
+
+#include <windows.h>
+
+namespace WebKit {
+
+static WebRect toWebRect(const RECT& input)
+{
+ WebRect output;
+ output.x = input.left;
+ output.y = input.top;
+ output.width = input.right - input.left;
+ output.height = input.bottom - input.top;
+ return output;
+}
+
+WebScreenInfo WebScreenInfoFactory::screenInfo(HWND window)
+{
+ HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
+
+ MONITORINFOEX monitorInfo;
+ monitorInfo.cbSize = sizeof(MONITORINFOEX);
+ GetMonitorInfo(monitor, &monitorInfo);
+
+ DEVMODE devMode;
+ devMode.dmSize = sizeof(devMode);
+ devMode.dmDriverExtra = 0;
+ EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
+
+ WebScreenInfo results;
+ results.depth = devMode.dmBitsPerPel;
+ results.depthPerComponent = devMode.dmBitsPerPel / 3; // Assumes RGB
+ results.isMonochrome = devMode.dmColor == DMCOLOR_MONOCHROME;
+ results.rect = toWebRect(monitorInfo.rcMonitor);
+ results.availableRect = toWebRect(monitorInfo.rcWork);
+ return results;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp b/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp
new file mode 100644
index 0000000..548880c
--- /dev/null
+++ b/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebScreenInfoFactory.h"
+
+#include "WebScreenInfo.h"
+
+#include <X11/Xlib.h>
+
+namespace WebKit {
+
+WebScreenInfo WebScreenInfoFactory::screenInfo(Display* display, int screenNumber)
+{
+ WebScreenInfo results;
+ // FIXME: not all screens with use 8bpp.
+ results.depthPerComponent = 8;
+
+ int displayWidth = XDisplayWidth(display, screenNumber);
+ int displayHeight = XDisplayHeight(display, screenNumber);
+ results.depth = XDisplayPlanes(display, screenNumber);
+ results.isMonochrome = results.depth == 1;
+
+ results.rect = WebRect(0, 0, displayWidth, displayHeight);
+
+ // I don't know of a way to query the "maximize" size of the window (e.g.
+ // screen size less sidebars etc) since this is something which only the
+ // window manager knows.
+ results.availableRect = results.rect;
+
+ return results;
+}
+
+} // namespace WebKit