summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/web
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
commit679147eead574d186ebf3069647b4c23e8ccace6 (patch)
treefc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/third_party/WebKit/Source/web
Initial import.
Diffstat (limited to 'chromium/third_party/WebKit/Source/web')
-rw-r--r--chromium/third_party/WebKit/Source/web/ApplicationCacheHost.cpp259
-rw-r--r--chromium/third_party/WebKit/Source/web/ApplicationCacheHostInternal.h80
-rw-r--r--chromium/third_party/WebKit/Source/web/AssertMatchingEnums.cpp669
-rw-r--r--chromium/third_party/WebKit/Source/web/AssociatedURLLoader.cpp373
-rw-r--r--chromium/third_party/WebKit/Source/web/AssociatedURLLoader.h72
-rw-r--r--chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.cpp128
-rw-r--r--chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.h74
-rw-r--r--chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.cpp94
-rw-r--r--chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.h74
-rw-r--r--chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.cpp358
-rw-r--r--chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.h145
-rw-r--r--chromium/third_party/WebKit/Source/web/BackForwardClientImpl.cpp73
-rw-r--r--chromium/third_party/WebKit/Source/web/BackForwardClientImpl.h56
-rw-r--r--chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp1018
-rw-r--r--chromium/third_party/WebKit/Source/web/ChromeClientImpl.h221
-rw-r--r--chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.cpp152
-rw-r--r--chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.h71
-rw-r--r--chromium/third_party/WebKit/Source/web/ColorChooserUIController.cpp86
-rw-r--r--chromium/third_party/WebKit/Source/web/ColorChooserUIController.h70
-rw-r--r--chromium/third_party/WebKit/Source/web/CompositionUnderlineBuilder.h53
-rw-r--r--chromium/third_party/WebKit/Source/web/CompositionUnderlineVectorBuilder.cpp49
-rw-r--r--chromium/third_party/WebKit/Source/web/CompositionUnderlineVectorBuilder.h53
-rw-r--r--chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.cpp153
-rw-r--r--chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.h58
-rw-r--r--chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp419
-rw-r--r--chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.h54
-rw-r--r--chromium/third_party/WebKit/Source/web/DEPS12
-rw-r--r--chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp64
-rw-r--r--chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.h54
-rw-r--r--chromium/third_party/WebKit/Source/web/DatabaseObserver.cpp205
-rw-r--r--chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.cpp196
-rw-r--r--chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.h77
-rw-r--r--chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp78
-rw-r--r--chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.h60
-rw-r--r--chromium/third_party/WebKit/Source/web/DragClientImpl.cpp91
-rw-r--r--chromium/third_party/WebKit/Source/web/DragClientImpl.h67
-rw-r--r--chromium/third_party/WebKit/Source/web/EditorClientImpl.cpp772
-rw-r--r--chromium/third_party/WebKit/Source/web/EditorClientImpl.h134
-rw-r--r--chromium/third_party/WebKit/Source/web/EventListenerWrapper.cpp74
-rw-r--r--chromium/third_party/WebKit/Source/web/EventListenerWrapper.h62
-rw-r--r--chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.cpp157
-rw-r--r--chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.h64
-rw-r--r--chromium/third_party/WebKit/Source/web/ExternalPopupMenu.cpp194
-rw-r--r--chromium/third_party/WebKit/Source/web/ExternalPopupMenu.h90
-rw-r--r--chromium/third_party/WebKit/Source/web/FindInPageCoordinates.cpp140
-rw-r--r--chromium/third_party/WebKit/Source/web/FindInPageCoordinates.h61
-rw-r--r--chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp791
-rw-r--r--chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.h168
-rw-r--r--chromium/third_party/WebKit/Source/web/FullscreenController.cpp185
-rw-r--r--chromium/third_party/WebKit/Source/web/FullscreenController.h79
-rw-r--r--chromium/third_party/WebKit/Source/web/GeolocationClientProxy.cpp98
-rw-r--r--chromium/third_party/WebKit/Source/web/GeolocationClientProxy.h61
-rw-r--r--chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.cpp52
-rw-r--r--chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.h49
-rw-r--r--chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.cpp68
-rw-r--r--chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.h55
-rw-r--r--chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.cpp154
-rw-r--r--chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.h71
-rw-r--r--chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.cpp176
-rw-r--r--chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.h63
-rw-r--r--chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.cpp100
-rw-r--r--chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.h77
-rw-r--r--chromium/third_party/WebKit/Source/web/InspectorClientImpl.cpp176
-rw-r--r--chromium/third_party/WebKit/Source/web/InspectorClientImpl.h89
-rw-r--r--chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.cpp170
-rw-r--r--chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.h90
-rw-r--r--chromium/third_party/WebKit/Source/web/LinkHighlight.cpp343
-rw-r--r--chromium/third_party/WebKit/Source/web/LinkHighlight.h101
-rw-r--r--chromium/third_party/WebKit/Source/web/LocalFileSystemClient.cpp88
-rw-r--r--chromium/third_party/WebKit/Source/web/LocalFileSystemClient.h55
-rw-r--r--chromium/third_party/WebKit/Source/web/MIDIClientImpl.cpp64
-rw-r--r--chromium/third_party/WebKit/Source/web/MIDIClientImpl.h60
-rw-r--r--chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.cpp92
-rw-r--r--chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.h60
-rw-r--r--chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.cpp147
-rw-r--r--chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.h76
-rw-r--r--chromium/third_party/WebKit/Source/web/OWNERS8
-rw-r--r--chromium/third_party/WebKit/Source/web/PageOverlay.cpp161
-rw-r--r--chromium/third_party/WebKit/Source/web/PageOverlay.h77
-rw-r--r--chromium/third_party/WebKit/Source/web/PageOverlayList.cpp139
-rw-r--r--chromium/third_party/WebKit/Source/web/PageOverlayList.h78
-rw-r--r--chromium/third_party/WebKit/Source/web/PageWidgetDelegate.cpp220
-rw-r--r--chromium/third_party/WebKit/Source/web/PageWidgetDelegate.h86
-rw-r--r--chromium/third_party/WebKit/Source/web/PinchViewports.cpp189
-rw-r--r--chromium/third_party/WebKit/Source/web/PinchViewports.h88
-rw-r--r--chromium/third_party/WebKit/Source/web/PopupContainer.cpp465
-rw-r--r--chromium/third_party/WebKit/Source/web/PopupContainer.h161
-rw-r--r--chromium/third_party/WebKit/Source/web/PopupListBox.cpp938
-rw-r--r--chromium/third_party/WebKit/Source/web/PopupListBox.h303
-rw-r--r--chromium/third_party/WebKit/Source/web/PopupMenuChromium.cpp98
-rw-r--r--chromium/third_party/WebKit/Source/web/PopupMenuChromium.h74
-rw-r--r--chromium/third_party/WebKit/Source/web/PrerendererClientImpl.cpp59
-rw-r--r--chromium/third_party/WebKit/Source/web/PrerendererClientImpl.h60
-rw-r--r--chromium/third_party/WebKit/Source/web/ScrollbarGroup.cpp290
-rw-r--r--chromium/third_party/WebKit/Source/web/ScrollbarGroup.h89
-rw-r--r--chromium/third_party/WebKit/Source/web/SharedWorkerRepository.cpp269
-rw-r--r--chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.cpp93
-rw-r--r--chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.h64
-rw-r--r--chromium/third_party/WebKit/Source/web/SpeechInputClientImpl.cpp108
-rw-r--r--chromium/third_party/WebKit/Source/web/SpeechInputClientImpl.h81
-rw-r--r--chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.cpp149
-rw-r--r--chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.h72
-rw-r--r--chromium/third_party/WebKit/Source/web/StorageAreaProxy.cpp201
-rw-r--r--chromium/third_party/WebKit/Source/web/StorageAreaProxy.h82
-rw-r--r--chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.cpp79
-rw-r--r--chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.h52
-rw-r--r--chromium/third_party/WebKit/Source/web/StorageQuotaChromium.cpp73
-rw-r--r--chromium/third_party/WebKit/Source/web/UserMediaClientImpl.cpp62
-rw-r--r--chromium/third_party/WebKit/Source/web/UserMediaClientImpl.h63
-rw-r--r--chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp146
-rw-r--r--chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.h70
-rw-r--r--chromium/third_party/WebKit/Source/web/ViewportAnchor.cpp127
-rw-r--r--chromium/third_party/WebKit/Source/web/ViewportAnchor.h78
-rw-r--r--chromium/third_party/WebKit/Source/web/WebAccessibilityObject.cpp1021
-rw-r--r--chromium/third_party/WebKit/Source/web/WebArrayBufferView.cpp88
-rw-r--r--chromium/third_party/WebKit/Source/web/WebBindings.cpp402
-rw-r--r--chromium/third_party/WebKit/Source/web/WebBlob.cpp103
-rw-r--r--chromium/third_party/WebKit/Source/web/WebBlobData.cpp136
-rw-r--r--chromium/third_party/WebKit/Source/web/WebCache.cpp97
-rw-r--r--chromium/third_party/WebKit/Source/web/WebCachedURLRequest.cpp77
-rw-r--r--chromium/third_party/WebKit/Source/web/WebColorName.cpp129
-rw-r--r--chromium/third_party/WebKit/Source/web/WebCommon.cpp44
-rw-r--r--chromium/third_party/WebKit/Source/web/WebCrossOriginPreflightResultCache.cpp43
-rw-r--r--chromium/third_party/WebKit/Source/web/WebCustomElement.cpp45
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMActivityLogger.cpp70
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMCustomEvent.cpp51
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMEvent.cpp209
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMEventListener.cpp66
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp89
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.h92
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMMessageEvent.cpp70
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMMouseEvent.cpp100
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMMutationEvent.cpp65
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMProgressEvent.cpp48
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDOMResourceProgressEvent.cpp47
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDataSourceImpl.cpp195
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDataSourceImpl.h98
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDatabase.cpp114
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp768
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h141
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDevToolsAgentPrivate.h66
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp173
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.h78
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDeviceOrientation.cpp67
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp76
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDeviceOrientationController.cpp47
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDocument.cpp295
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDocumentType.cpp63
-rw-r--r--chromium/third_party/WebKit/Source/web/WebDragData.cpp178
-rw-r--r--chromium/third_party/WebKit/Source/web/WebElement.cpp195
-rw-r--r--chromium/third_party/WebKit/Source/web/WebEntities.cpp87
-rw-r--r--chromium/third_party/WebKit/Source/web/WebEntities.h76
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.cpp65
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.h58
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.cpp138
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.h83
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFontCache.cpp64
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFontDescription.cpp71
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFontImpl.cpp130
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFontImpl.h66
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFormControlElement.cpp101
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFormElement.cpp131
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFrameImpl.cpp2495
-rw-r--r--chromium/third_party/WebKit/Source/web/WebFrameImpl.h504
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGeolocationClientMock.cpp138
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGeolocationController.cpp52
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGeolocationError.cpp67
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequest.cpp50
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequestManager.cpp95
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGeolocationPosition.cpp61
-rw-r--r--chromium/third_party/WebKit/Source/web/WebGlyphCache.cpp45
-rw-r--r--chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp252
-rw-r--r--chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.h87
-rw-r--r--chromium/third_party/WebKit/Source/web/WebHistoryItem.cpp346
-rw-r--r--chromium/third_party/WebKit/Source/web/WebHitTestResult.cpp105
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.cpp123
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.h67
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.cpp66
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.h54
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBDatabaseError.cpp66
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBKey.cpp232
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBKeyPath.cpp112
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBKeyRange.cpp95
-rw-r--r--chromium/third_party/WebKit/Source/web/WebIDBMetadata.cpp89
-rw-r--r--chromium/third_party/WebKit/Source/web/WebImageCache.cpp60
-rw-r--r--chromium/third_party/WebKit/Source/web/WebImageDecoder.cpp115
-rw-r--r--chromium/third_party/WebKit/Source/web/WebImageSkia.cpp168
-rw-r--r--chromium/third_party/WebKit/Source/web/WebInputElement.cpp287
-rw-r--r--chromium/third_party/WebKit/Source/web/WebInputEvent.cpp239
-rw-r--r--chromium/third_party/WebKit/Source/web/WebInputEventConversion.cpp748
-rw-r--r--chromium/third_party/WebKit/Source/web/WebInputEventConversion.h148
-rw-r--r--chromium/third_party/WebKit/Source/web/WebKit.cpp227
-rw-r--r--chromium/third_party/WebKit/Source/web/WebKitUnitTests.isolate43
-rw-r--r--chromium/third_party/WebKit/Source/web/WebLabelElement.cpp64
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMIDIPermissionRequest.cpp78
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.cpp739
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.h232
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.cpp57
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.h54
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMediaStreamRegistry.cpp51
-rw-r--r--chromium/third_party/WebKit/Source/web/WebMutationEvent.cpp65
-rw-r--r--chromium/third_party/WebKit/Source/web/WebNetworkStateNotifier.cpp45
-rw-r--r--chromium/third_party/WebKit/Source/web/WebNode.cpp276
-rw-r--r--chromium/third_party/WebKit/Source/web/WebNodeCollection.cpp89
-rw-r--r--chromium/third_party/WebKit/Source/web/WebNodeList.cpp80
-rw-r--r--chromium/third_party/WebKit/Source/web/WebNotification.cpp175
-rw-r--r--chromium/third_party/WebKit/Source/web/WebOptionElement.cpp101
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPagePopupImpl.cpp354
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPagePopupImpl.h99
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPageSerializer.cpp302
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp530
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.h192
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPasswordFormData.cpp182
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.cpp104
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.h63
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPerformance.cpp187
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp897
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.h202
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginDocument.cpp72
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginLoadObserver.cpp57
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginLoadObserver.h67
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.cpp369
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.h105
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp400
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.h139
-rw-r--r--chromium/third_party/WebKit/Source/web/WebRange.cpp170
-rw-r--r--chromium/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp395
-rw-r--r--chromium/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.cpp57
-rw-r--r--chromium/third_party/WebKit/Source/web/WebScopedUserGesture.cpp55
-rw-r--r--chromium/third_party/WebKit/Source/web/WebScriptBindings.cpp46
-rw-r--r--chromium/third_party/WebKit/Source/web/WebScriptController.cpp55
-rw-r--r--chromium/third_party/WebKit/Source/web/WebScrollbarThemePainter.cpp125
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSearchableFormData.cpp300
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSecurityOrigin.cpp165
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSecurityPolicy.cpp117
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSelectElement.cpp80
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSerializedScriptValue.cpp96
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSettingsImpl.cpp684
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSettingsImpl.h198
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp457
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.h186
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSocket.cpp49
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSocketImpl.cpp170
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSocketImpl.h85
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSpeechGrammar.cpp67
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSpeechInputResult.cpp63
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSpeechRecognitionHandle.cpp71
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp62
-rw-r--r--chromium/third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp67
-rw-r--r--chromium/third_party/WebKit/Source/web/WebSurroundingText.cpp76
-rw-r--r--chromium/third_party/WebKit/Source/web/WebTestingSupport.cpp47
-rw-r--r--chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp65
-rw-r--r--chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.h60
-rw-r--r--chromium/third_party/WebKit/Source/web/WebTextCheckingResult.cpp59
-rw-r--r--chromium/third_party/WebKit/Source/web/WebTextInputInfo.cpp46
-rw-r--r--chromium/third_party/WebKit/Source/web/WebTextRun.cpp45
-rw-r--r--chromium/third_party/WebKit/Source/web/WebURLLoadTiming.cpp192
-rw-r--r--chromium/third_party/WebKit/Source/web/WebUserGestureIndicator.cpp56
-rw-r--r--chromium/third_party/WebKit/Source/web/WebUserGestureToken.cpp73
-rw-r--r--chromium/third_party/WebKit/Source/web/WebUserMediaRequest.cpp140
-rw-r--r--chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.cpp104
-rw-r--r--chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.h66
-rw-r--r--chromium/third_party/WebKit/Source/web/WebViewImpl.cpp4086
-rw-r--r--chromium/third_party/WebKit/Source/web/WebViewImpl.h837
-rw-r--r--chromium/third_party/WebKit/Source/web/WebWorkerBase.cpp59
-rw-r--r--chromium/third_party/WebKit/Source/web/WebWorkerBase.h61
-rw-r--r--chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.cpp157
-rw-r--r--chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.h98
-rw-r--r--chromium/third_party/WebKit/Source/web/WebWorkerInfo.cpp43
-rw-r--r--chromium/third_party/WebKit/Source/web/WebWorkerRunLoop.cpp79
-rw-r--r--chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.cpp104
-rw-r--r--chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.h94
-rw-r--r--chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.cpp494
-rw-r--r--chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.h156
-rw-r--r--chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.cpp141
-rw-r--r--chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.h54
-rw-r--r--chromium/third_party/WebKit/Source/web/android/WebInputEventFactory.cpp179
-rw-r--r--chromium/third_party/WebKit/Source/web/default/WebRenderTheme.cpp47
-rw-r--r--chromium/third_party/WebKit/Source/web/gtk/WebInputEventFactory.cpp628
-rw-r--r--chromium/third_party/WebKit/Source/web/linux/WebFontInfo.cpp335
-rw-r--r--chromium/third_party/WebKit/Source/web/linux/WebFontRenderStyle.cpp62
-rw-r--r--chromium/third_party/WebKit/Source/web/linux/WebFontRendering.cpp95
-rw-r--r--chromium/third_party/WebKit/Source/web/mac/WebInputEventFactory.mm958
-rw-r--r--chromium/third_party/WebKit/Source/web/mac/WebSubstringUtil.mm115
-rw-r--r--chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.cpp60
-rw-r--r--chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.h51
-rw-r--r--chromium/third_party/WebKit/Source/web/painting/PaintAggregator.cpp371
-rw-r--r--chromium/third_party/WebKit/Source/web/painting/PaintAggregator.h92
-rw-r--r--chromium/third_party/WebKit/Source/web/web.gyp320
-rw-r--r--chromium/third_party/WebKit/Source/web/web.gypi378
-rw-r--r--chromium/third_party/WebKit/Source/web/web_tests.gyp164
-rw-r--r--chromium/third_party/WebKit/Source/web/win/WebInputEventFactory.cpp490
-rw-r--r--chromium/third_party/WebKit/Source/web/x11/WebScreenInfoFactory.cpp69
293 files changed, 52979 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/web/ApplicationCacheHost.cpp b/chromium/third_party/WebKit/Source/web/ApplicationCacheHost.cpp
new file mode 100644
index 00000000000..fb0d328d0bd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ApplicationCacheHost.cpp
@@ -0,0 +1,259 @@
+/*
+ * 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 "core/loader/appcache/ApplicationCacheHost.h"
+
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebURLResponse.h"
+#include "public/platform/WebVector.h"
+#include "ApplicationCacheHostInternal.h"
+#include "WebFrameImpl.h"
+#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "core/dom/ProgressEvent.h"
+#include "core/inspector/InspectorApplicationCacheAgent.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoader.h"
+#include "core/loader/appcache/DOMApplicationCache.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "core/platform/chromium/support/WrappedResourceResponse.h"
+#include "weborigin/SecurityOrigin.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::willStartLoadingMainResource(ResourceRequest& request)
+{
+ // 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 = adoptPtr(new ApplicationCacheHostInternal(this));
+ if (m_internal->m_outerHost) {
+ WrappedResourceRequest wrapped(request);
+ m_internal->m_outerHost->willStartMainResourceRequest(wrapped, WebFrameImpl::fromFrame(m_documentLoader->frame()));
+ } 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::didReceiveResponseForMainResource(const ResourceResponse& response)
+{
+ if (m_internal) {
+ WrappedResourceResponse wrapped(response);
+ m_internal->m_outerHost->didReceiveResponseForMainResource(wrapped);
+ }
+}
+
+void ApplicationCacheHost::mainResourceDataReceived(const char* data, int length)
+{
+ 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);
+}
+
+void ApplicationCacheHost::willStartLoadingResource(ResourceRequest& request)
+{
+ // FIXME: look into the purpose of the unused KURL& originalURL parameter
+ if (m_internal) {
+ WrappedResourceRequest wrapped(request);
+ m_internal->m_outerHost->willStartSubResourceRequest(wrapped);
+ }
+}
+
+void ApplicationCacheHost::willStartLoadingSynchronously(ResourceRequest& request)
+{
+ if (m_internal) {
+ WrappedResourceRequest wrapped(request);
+ m_internal->m_outerHost->willStartSubResourceRequest(wrapped);
+ }
+}
+
+void ApplicationCacheHost::setDOMApplicationCache(DOMApplicationCache* domApplicationCache)
+{
+ ASSERT(!m_domApplicationCache || !domApplicationCache);
+ m_domApplicationCache = domApplicationCache;
+}
+
+void ApplicationCacheHost::notifyDOMApplicationCache(EventID id, int total, int done)
+{
+ if (id != PROGRESS_EVENT)
+ InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader->frame());
+
+ if (m_defersEvents) {
+ // Event dispatching is deferred until document.onload has fired.
+ m_deferredEvents.append(DeferredEvent(id, total, done));
+ return;
+ }
+ dispatchDOMEvent(id, total, done);
+}
+
+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));
+ }
+}
+
+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::dispatchDOMEvent(EventID id, int total, int done)
+{
+ if (m_domApplicationCache) {
+ const AtomicString& eventType = DOMApplicationCache::toEventType(id);
+ 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, ASSERT_NO_EXCEPTION);
+ }
+}
+
+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()
+{
+ bool success = m_internal ? m_internal->m_outerHost->swapCache() : false;
+ if (success)
+ InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader->frame());
+ return success;
+}
+
+void ApplicationCacheHost::abort()
+{
+ if (m_internal)
+ m_internal->m_outerHost->abort();
+}
+
+bool ApplicationCacheHost::isApplicationCacheEnabled()
+{
+ ASSERT(m_documentLoader->frame());
+ return m_documentLoader->frame()->settings()
+ && m_documentLoader->frame()->settings()->offlineWebApplicationCacheEnabled();
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/ApplicationCacheHostInternal.h b/chromium/third_party/WebKit/Source/web/ApplicationCacheHostInternal.h
new file mode 100644
index 00000000000..81ce9819fbd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ApplicationCacheHostInternal.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.
+ */
+
+#include "config.h"
+#include "core/loader/appcache/ApplicationCacheHost.h"
+
+#include "WebApplicationCacheHostClient.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "core/loader/DocumentLoader.h"
+#include "public/platform/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 = adoptPtr(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)
+ return innerHost->m_internal->m_outerHost.get();
+ return 0;
+ }
+
+private:
+ friend class ApplicationCacheHost;
+ ApplicationCacheHost* m_innerHost;
+ OwnPtr<WebKit::WebApplicationCacheHost> m_outerHost;
+};
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/AssertMatchingEnums.cpp b/chromium/third_party/WebKit/Source/web/AssertMatchingEnums.cpp
new file mode 100644
index 00000000000..e4266ce952c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AssertMatchingEnums.cpp
@@ -0,0 +1,669 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "public/platform/WebClipboard.h"
+#include "public/platform/WebCompositingReasons.h"
+#include "public/platform/WebFileError.h"
+#include "public/platform/WebFileInfo.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebIDBCursor.h"
+#include "public/platform/WebIDBDatabase.h"
+#include "public/platform/WebIDBDatabaseException.h"
+#include "public/platform/WebIDBFactory.h"
+#include "public/platform/WebIDBKey.h"
+#include "public/platform/WebIDBKeyPath.h"
+#include "public/platform/WebIDBMetadata.h"
+#include "public/platform/WebMediaStreamSource.h"
+#include "public/platform/WebReferrerPolicy.h"
+#include "public/platform/WebRTCDataChannelHandlerClient.h"
+#include "public/platform/WebRTCPeerConnectionHandlerClient.h"
+#include "public/platform/WebScrollbar.h"
+#include "public/platform/WebURLRequest.h"
+#include "public/platform/WebURLResponse.h"
+#include "public/web/WebNavigationPolicy.h"
+#include "wtf/Assertions.h"
+#include "wtf/text/StringImpl.h"
+#include "WebAccessibilityNotification.h"
+#include "WebAccessibilityObject.h"
+#include "WebApplicationCacheHost.h"
+#include "WebConsoleMessage.h"
+#include "WebContentSecurityPolicy.h"
+#include "WebCursorInfo.h"
+#include "WebEditingAction.h"
+#include "WebFontDescription.h"
+#include "WebFormElement.h"
+#include "WebGeolocationError.h"
+#include "WebGeolocationPosition.h"
+#include "WebIconURL.h"
+#include "WebInbandTextTrack.h"
+#include "WebInputElement.h"
+#include "WebMediaPlayer.h"
+#include "WebMediaPlayerClient.h"
+#include "WebMediaSourceClient.h"
+#include "WebNotificationPresenter.h"
+#include "WebPageVisibilityState.h"
+#include "WebSettings.h"
+#include "WebSpeechRecognizerClient.h"
+#include "WebStorageQuotaError.h"
+#include "WebStorageQuotaType.h"
+#include "WebTextAffinity.h"
+#include "WebTextCheckingResult.h"
+#include "WebTextCheckingType.h"
+#include "WebView.h"
+#include "core/accessibility/AXObjectCache.h"
+#include "core/accessibility/AccessibilityObject.h"
+#include "core/dom/DocumentMarker.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/dom/IconURL.h"
+#include "core/editing/EditorInsertAction.h"
+#include "core/editing/TextAffinity.h"
+#include "core/fileapi/FileError.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/shadow/TextControlInnerElements.h"
+#include "core/loader/NavigationPolicy.h"
+#include "core/loader/appcache/ApplicationCacheHost.h"
+#include "core/page/ContentSecurityPolicy.h"
+#include "core/page/PageVisibilityState.h"
+#include "core/page/Settings.h"
+#include "core/page/UserContentTypes.h"
+#include "core/page/UserStyleSheetTypes.h"
+#include "core/platform/Cursor.h"
+#include "core/platform/FileMetadata.h"
+#include "core/platform/graphics/ContentDecryptionModuleSession.h"
+#include "core/platform/graphics/FontDescription.h"
+#include "core/platform/graphics/FontSmoothingMode.h"
+#include "core/platform/graphics/InbandTextTrackPrivate.h"
+#include "core/platform/graphics/MediaPlayer.h"
+#include "core/platform/graphics/MediaSourcePrivate.h"
+#include "core/platform/graphics/filters/FilterOperation.h"
+#include "core/platform/mediastream/MediaStreamSource.h"
+#include "core/platform/mediastream/RTCDataChannelHandlerClient.h"
+#include "core/platform/mediastream/RTCPeerConnectionHandlerClient.h"
+#include "core/platform/network/ResourceLoadPriority.h"
+#include "core/platform/network/ResourceResponse.h"
+#include "core/platform/text/TextChecking.h"
+#include "core/rendering/CompositingReasons.h"
+#include "modules/filesystem/FileSystemType.h"
+#include "modules/geolocation/GeolocationError.h"
+#include "modules/geolocation/GeolocationPosition.h"
+#include "modules/indexeddb/IDBCursor.h"
+#include "modules/indexeddb/IDBDatabaseBackendInterface.h"
+#include "modules/indexeddb/IDBKey.h"
+#include "modules/indexeddb/IDBKeyPath.h"
+#include "modules/indexeddb/IDBMetadata.h"
+#include "modules/indexeddb/chromium/IDBFactoryBackendInterfaceChromium.h"
+#include "modules/notifications/NotificationClient.h"
+#include "modules/quota/StorageQuota.h"
+#include "modules/speech/SpeechRecognitionError.h"
+#include "weborigin/ReferrerPolicy.h"
+
+#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \
+ COMPILE_ASSERT(int(WebKit::webkit_name) == int(WebCore::webcore_name), mismatching_enums)
+
+#define COMPILE_ASSERT_MATCHING_UINT64(webkit_name, webcore_name) \
+ COMPILE_ASSERT(WebKit::webkit_name == 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(WebAccessibilityNotificationActiveDescendantChanged, AXObjectCache::AXActiveDescendantChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationAutocorrectionOccured, AXObjectCache::AXAutocorrectionOccured);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationCheckedStateChanged, AXObjectCache::AXCheckedStateChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationChildrenChanged, AXObjectCache::AXChildrenChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationFocusedUIElementChanged, AXObjectCache::AXFocusedUIElementChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationLayoutComplete, AXObjectCache::AXLayoutComplete);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationLoadComplete, AXObjectCache::AXLoadComplete);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationSelectedChildrenChanged, AXObjectCache::AXSelectedChildrenChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationSelectedTextChanged, AXObjectCache::AXSelectedTextChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationValueChanged, AXObjectCache::AXValueChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationScrolledToAnchor, AXObjectCache::AXScrolledToAnchor);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationLiveRegionChanged, AXObjectCache::AXLiveRegionChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationMenuListItemSelected, AXObjectCache::AXMenuListItemSelected);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationMenuListValueChanged, AXObjectCache::AXMenuListValueChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationRowCountChanged, AXObjectCache::AXRowCountChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationRowCollapsed, AXObjectCache::AXRowCollapsed);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationRowExpanded, AXObjectCache::AXRowExpanded);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationInvalidStatusChanged, AXObjectCache::AXInvalidStatusChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationTextChanged, AXObjectCache::AXTextChanged);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityNotificationAriaAttributeChanged, AXObjectCache::AXAriaAttributeChanged);
+
+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(WebAccessibilityRoleMathElement, MathElementRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleWebArea, WebAreaRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSeamlessWebArea, SeamlessWebAreaRole);
+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(WebAccessibilityRoleDefinition, DefinitionRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDescriptionListTerm, DescriptionListTermRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDescriptionListDetail, DescriptionListDetailRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleAnnotation, AnnotationRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSliderThumb, SliderThumbRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSpinButton, SpinButtonRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSpinButtonPart, SpinButtonPartRole);
+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(WebAccessibilityRoleFooter, FooterRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleListItem, ListItemRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleParagraph, ParagraphRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLabel, LabelRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleDiv, DivRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleForm, FormRole);
+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);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleToggleButton, ToggleButtonRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleCanvas, CanvasRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleLegend, LegendRole);
+COMPILE_ASSERT_MATCHING_ENUM(WebAccessibilityRoleSVGRoot, SVGRootRole);
+
+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);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypePointer, Cursor::Pointer);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCross, Cursor::Cross);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeHand, Cursor::Hand);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeIBeam, Cursor::IBeam);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWait, Cursor::Wait);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeHelp, Cursor::Help);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastResize, Cursor::EastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthResize, Cursor::NorthResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastResize, Cursor::NorthEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestResize, Cursor::NorthWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthResize, Cursor::SouthResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthEastResize, Cursor::SouthEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthWestResize, Cursor::SouthWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWestResize, Cursor::WestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthSouthResize, Cursor::NorthSouthResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastWestResize, Cursor::EastWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastSouthWestResize, Cursor::NorthEastSouthWestResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestSouthEastResize, Cursor::NorthWestSouthEastResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeColumnResize, Cursor::ColumnResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeRowResize, Cursor::RowResize);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeMiddlePanning, Cursor::MiddlePanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeEastPanning, Cursor::EastPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthPanning, Cursor::NorthPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthEastPanning, Cursor::NorthEastPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNorthWestPanning, Cursor::NorthWestPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthPanning, Cursor::SouthPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthEastPanning, Cursor::SouthEastPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeSouthWestPanning, Cursor::SouthWestPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeWestPanning, Cursor::WestPanning);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeMove, Cursor::Move);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeVerticalText, Cursor::VerticalText);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCell, Cursor::Cell);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeContextMenu, Cursor::ContextMenu);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeAlias, Cursor::Alias);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeProgress, Cursor::Progress);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNoDrop, Cursor::NoDrop);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCopy, Cursor::Copy);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNone, Cursor::None);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeNotAllowed, Cursor::NotAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeZoomIn, Cursor::ZoomIn);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeZoomOut, Cursor::ZoomOut);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeGrab, Cursor::Grab);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeGrabbing, Cursor::Grabbing);
+COMPILE_ASSERT_MATCHING_ENUM(WebCursorInfo::TypeCustom, Cursor::Custom);
+
+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(WebIconURL::TypeInvalid, InvalidIcon);
+COMPILE_ASSERT_MATCHING_ENUM(WebIconURL::TypeFavicon, Favicon);
+COMPILE_ASSERT_MATCHING_ENUM(WebIconURL::TypeTouch, TouchIcon);
+COMPILE_ASSERT_MATCHING_ENUM(WebIconURL::TypeTouchPrecomposed, TouchPrecomposedIcon);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::KindSubtitles, InbandTextTrackPrivate::Subtitles);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::KindCaptions, InbandTextTrackPrivate::Captions);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::KindDescriptions, InbandTextTrackPrivate::Descriptions);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::KindChapters, InbandTextTrackPrivate::Chapters);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::KindMetadata, InbandTextTrackPrivate::Metadata);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::KindNone, InbandTextTrackPrivate::None);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::ModeDisabled, InbandTextTrackPrivate::Disabled);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::ModeHidden, InbandTextTrackPrivate::Hidden);
+COMPILE_ASSERT_MATCHING_ENUM(WebInbandTextTrack::ModeShowing, InbandTextTrackPrivate::Showing);
+
+#if ENABLE(INPUT_SPEECH)
+COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Idle, InputFieldSpeechButtonElement::Idle);
+COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Recording, InputFieldSpeechButtonElement::Recording);
+COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Recognizing, InputFieldSpeechButtonElement::Recognizing);
+#endif
+
+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::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);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateEmpty, MediaPlayer::Empty);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateIdle, MediaPlayer::Idle);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateLoading, MediaPlayer::Loading);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateLoaded, MediaPlayer::Loaded);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateFormatError, MediaPlayer::FormatError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateNetworkError, MediaPlayer::NetworkError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::NetworkStateDecodeError, MediaPlayer::DecodeError);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::ReadyStateHaveNothing, MediaPlayer::HaveNothing);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::ReadyStateHaveMetadata, MediaPlayer::HaveMetadata);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::ReadyStateHaveCurrentData, MediaPlayer::HaveCurrentData);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::ReadyStateHaveFutureData, MediaPlayer::HaveFutureData);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::ReadyStateHaveEnoughData, MediaPlayer::HaveEnoughData);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadNone, MediaPlayer::None);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadMetaData, MediaPlayer::MetaData);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadAuto, MediaPlayer::Auto);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::AddStatusOk, MediaSourcePrivate::Ok);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::AddStatusNotSupported, MediaSourcePrivate::NotSupported);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::AddStatusReachedIdLimit, MediaSourcePrivate::ReachedIdLimit);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::EndOfStreamStatusNoError, MediaSourcePrivate::EosNoError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::EndOfStreamStatusNetworkError, MediaSourcePrivate::EosNetworkError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::EndOfStreamStatusDecodeError, MediaSourcePrivate::EosDecodeError);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::MediaKeyExceptionNoError, MediaPlayer::NoError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::MediaKeyExceptionInvalidPlayerState, MediaPlayer::InvalidPlayerState);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported, MediaPlayer::KeySystemNotSupported);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::MediaKeyErrorCodeUnknown, MediaPlayerClient::UnknownError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::MediaKeyErrorCodeClient, MediaPlayerClient::ClientError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::MediaKeyErrorCodeService, MediaPlayerClient::ServiceError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::MediaKeyErrorCodeOutput, MediaPlayerClient::OutputError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::MediaKeyErrorCodeHardwareChange, MediaPlayerClient::HardwareChangeError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::MediaKeyErrorCodeDomain, MediaPlayerClient::DomainError);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebContentDecryptionModuleSession::Client::MediaKeyErrorCodeUnknown, ContentDecryptionModuleSessionClient::UnknownError);
+COMPILE_ASSERT_MATCHING_ENUM(WebContentDecryptionModuleSession::Client::MediaKeyErrorCodeClient, ContentDecryptionModuleSessionClient::ClientError);
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionAllowed, NotificationClient::PermissionAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionNotAllowed, NotificationClient::PermissionNotAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebNotificationPresenter::PermissionDenied, NotificationClient::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(WebScrollbar::RegularScrollbar, RegularScrollbar);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::SmallScrollbar, SmallScrollbar);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::NoPart, NoPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::BackButtonStartPart, BackButtonStartPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ForwardButtonStartPart, ForwardButtonStartPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::BackTrackPart, BackTrackPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ThumbPart, ThumbPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ForwardTrackPart, ForwardTrackPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::BackButtonEndPart, BackButtonEndPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ForwardButtonEndPart, ForwardButtonEndPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollbarBGPart, ScrollbarBGPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::TrackBGPart, TrackBGPart);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::AllParts, AllParts);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollbarOverlayStyleDefault, ScrollbarOverlayStyleDefault);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollbarOverlayStyleDark, ScrollbarOverlayStyleDark);
+COMPILE_ASSERT_MATCHING_ENUM(WebScrollbar::ScrollbarOverlayStyleLight, ScrollbarOverlayStyleLight);
+
+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(WebSettings::EditingBehaviorAndroid, EditingAndroidBehavior);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityUpstream, UPSTREAM);
+COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityDownstream, DOWNSTREAM);
+
+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(WebIDBDatabaseExceptionUnknownError, UnknownError);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionConstraintError, ConstraintError);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionDataError, DataError);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionVersionError, VersionError);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionAbortError, AbortError);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionQuotaError, QuotaExceededError);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyTypeInvalid, IDBKey::InvalidType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyTypeArray, IDBKey::ArrayType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyTypeString, IDBKey::StringType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyTypeDate, IDBKey::DateType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyTypeNumber, IDBKey::NumberType);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPathTypeNull, IDBKeyPath::NullType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPathTypeString, IDBKeyPath::StringType);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPathTypeArray, IDBKeyPath::ArrayType);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBMetadata::NoIntVersion, IDBDatabaseMetadata::NoIntVersion);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBCursor::Next, IndexedDB::CursorNext);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBCursor::NextNoDuplicate, IndexedDB::CursorNextNoDuplicate);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBCursor::Prev, IndexedDB::CursorPrev);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBCursor::PrevNoDuplicate, IndexedDB::CursorPrevNoDuplicate);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabase::PreemptiveTask, IDBDatabaseBackendInterface::PreemptiveTask);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabase::NormalTask, IDBDatabaseBackendInterface::NormalTask);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeTemporary, FileSystemTypeTemporary);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypePersistent, FileSystemTypePersistent);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeExternal, FileSystemTypeExternal);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeIsolated, FileSystemTypeIsolated);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeUnknown, FileMetadata::TypeUnknown);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeFile, FileMetadata::TypeFile);
+COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeDirectory, FileMetadata::TypeDirectory);
+
+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);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeSpelling, TextCheckingTypeSpelling);
+COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeGrammar, TextCheckingTypeGrammar);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorNotSupported, NotSupportedError);
+COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorInvalidModification, InvalidModificationError);
+COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorInvalidAccess, InvalidAccessError);
+COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaErrorAbort, AbortError);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaTypeTemporary, StorageQuota::Temporary);
+COMPILE_ASSERT_MATCHING_ENUM(WebStorageQuotaTypePersistent, StorageQuota::Persistent);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebPageVisibilityStateVisible, PageVisibilityStateVisible);
+COMPILE_ASSERT_MATCHING_ENUM(WebPageVisibilityStateHidden, PageVisibilityStateHidden);
+COMPILE_ASSERT_MATCHING_ENUM(WebPageVisibilityStatePrerender, PageVisibilityStatePrerender);
+COMPILE_ASSERT_MATCHING_ENUM(WebPageVisibilityStatePreview, PageVisibilityStatePreview);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::TypeAudio, MediaStreamSource::TypeAudio);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::TypeVideo, MediaStreamSource::TypeVideo);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::ReadyStateLive, MediaStreamSource::ReadyStateLive);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::ReadyStateMuted, MediaStreamSource::ReadyStateMuted);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::ReadyStateEnded, MediaStreamSource::ReadyStateEnded);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::SignalingStateStable, RTCPeerConnectionHandlerClient::SignalingStateStable);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer, RTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer, RTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer, RTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer, RTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::SignalingStateClosed, RTCPeerConnectionHandlerClient::SignalingStateClosed);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateStarting, RTCPeerConnectionHandlerClient::IceConnectionStateNew);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateNew, RTCPeerConnectionHandlerClient::IceConnectionStateNew);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateChecking, RTCPeerConnectionHandlerClient::IceConnectionStateChecking);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateConnected, RTCPeerConnectionHandlerClient::IceConnectionStateConnected);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateCompleted, RTCPeerConnectionHandlerClient::IceConnectionStateCompleted);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateFailed, RTCPeerConnectionHandlerClient::IceConnectionStateFailed);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateDisconnected, RTCPeerConnectionHandlerClient::IceConnectionStateDisconnected);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed, RTCPeerConnectionHandlerClient::IceConnectionStateClosed);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew, RTCPeerConnectionHandlerClient::IceGatheringStateNew);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEGatheringStateGathering, RTCPeerConnectionHandlerClient::IceGatheringStateGathering);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCPeerConnectionHandlerClient::ICEGatheringStateComplete, RTCPeerConnectionHandlerClient::IceGatheringStateComplete);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCDataChannelHandlerClient::ReadyStateConnecting, RTCDataChannelHandlerClient::ReadyStateConnecting);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCDataChannelHandlerClient::ReadyStateOpen, RTCDataChannelHandlerClient::ReadyStateOpen);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCDataChannelHandlerClient::ReadyStateClosing, RTCDataChannelHandlerClient::ReadyStateClosing);
+COMPILE_ASSERT_MATCHING_ENUM(WebRTCDataChannelHandlerClient::ReadyStateClosed, RTCDataChannelHandlerClient::ReadyStateClosed);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::OtherError, SpeechRecognitionError::ErrorCodeOther);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::NoSpeechError, SpeechRecognitionError::ErrorCodeNoSpeech);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::AbortedError, SpeechRecognitionError::ErrorCodeAborted);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::AudioCaptureError, SpeechRecognitionError::ErrorCodeAudioCapture);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::NetworkError, SpeechRecognitionError::ErrorCodeNetwork);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::NotAllowedError, SpeechRecognitionError::ErrorCodeNotAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::ServiceNotAllowedError, SpeechRecognitionError::ErrorCodeServiceNotAllowed);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::BadGrammarError, SpeechRecognitionError::ErrorCodeBadGrammar);
+COMPILE_ASSERT_MATCHING_ENUM(WebSpeechRecognizerClient::LanguageNotSupportedError, SpeechRecognitionError::ErrorCodeLanguageNotSupported);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebReferrerPolicyAlways, ReferrerPolicyAlways);
+COMPILE_ASSERT_MATCHING_ENUM(WebReferrerPolicyDefault, ReferrerPolicyDefault);
+COMPILE_ASSERT_MATCHING_ENUM(WebReferrerPolicyNever, ReferrerPolicyNever);
+COMPILE_ASSERT_MATCHING_ENUM(WebReferrerPolicyOrigin, ReferrerPolicyOrigin);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebContentSecurityPolicyTypeReport, ContentSecurityPolicy::Report);
+COMPILE_ASSERT_MATCHING_ENUM(WebContentSecurityPolicyTypeEnforce, ContentSecurityPolicy::Enforce);
+COMPILE_ASSERT_MATCHING_ENUM(WebContentSecurityPolicyTypePrefixedReport, ContentSecurityPolicy::PrefixedReport);
+COMPILE_ASSERT_MATCHING_ENUM(WebContentSecurityPolicyTypePrefixedEnforce, ContentSecurityPolicy::PrefixedEnforce);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::Unknown, ResourceResponse::Unknown);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_0_9, ResourceResponse::HTTP_0_9);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_0, ResourceResponse::HTTP_1_0);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_1, ResourceResponse::HTTP_1_1);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUnspecified, MediaPlayerClient::Unspecified);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeAnonymous, MediaPlayerClient::Anonymous);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUseCredentials, MediaPlayerClient::UseCredentials);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultSuccess, HTMLFormElement::AutocompleteResultSuccess);
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorDisabled, HTMLFormElement::AutocompleteResultErrorDisabled);
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorCancel, HTMLFormElement::AutocompleteResultErrorCancel);
+COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorInvalid, HTMLFormElement::AutocompleteResultErrorInvalid);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebURLRequest::PriorityUnresolved, ResourceLoadPriorityUnresolved);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLRequest::PriorityVeryLow, ResourceLoadPriorityVeryLow);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLRequest::PriorityLow, ResourceLoadPriorityLow);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLRequest::PriorityMedium, ResourceLoadPriorityMedium);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLRequest::PriorityHigh, ResourceLoadPriorityHigh);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLRequest::PriorityVeryHigh, ResourceLoadPriorityVeryHigh);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyIgnore, NavigationPolicyIgnore);
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyDownload, NavigationPolicyDownload);
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyCurrentTab, NavigationPolicyCurrentTab);
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyNewBackgroundTab, NavigationPolicyNewBackgroundTab);
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyNewForegroundTab, NavigationPolicyNewForegroundTab);
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyNewWindow, NavigationPolicyNewWindow);
+COMPILE_ASSERT_MATCHING_ENUM(WebNavigationPolicyNewPopup, NavigationPolicyNewPopup);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebConsoleMessage::LevelDebug, DebugMessageLevel);
+COMPILE_ASSERT_MATCHING_ENUM(WebConsoleMessage::LevelLog, LogMessageLevel);
+COMPILE_ASSERT_MATCHING_ENUM(WebConsoleMessage::LevelWarning, WarningMessageLevel);
+COMPILE_ASSERT_MATCHING_ENUM(WebConsoleMessage::LevelError, ErrorMessageLevel);
+
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonUnknown, CompositingReasonNone);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReason3DTransform, CompositingReason3DTransform);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonVideo, CompositingReasonVideo);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonCanvas, CompositingReasonCanvas);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonPlugin, CompositingReasonPlugin);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonIFrame, CompositingReasonIFrame);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonBackfaceVisibilityHidden, CompositingReasonBackfaceVisibilityHidden);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonAnimation, CompositingReasonAnimation);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonFilters, CompositingReasonFilters);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonPositionFixed, CompositingReasonPositionFixed);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonPositionSticky, CompositingReasonPositionSticky);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonOverflowScrollingTouch, CompositingReasonOverflowScrollingTouch);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonBlending, CompositingReasonBlending);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonAssumedOverlap, CompositingReasonAssumedOverlap);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonOverlap, CompositingReasonOverlap);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonNegativeZIndexChildren, CompositingReasonNegativeZIndexChildren);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonTransformWithCompositedDescendants, CompositingReasonTransformWithCompositedDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonOpacityWithCompositedDescendants, CompositingReasonOpacityWithCompositedDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonMaskWithCompositedDescendants, CompositingReasonMaskWithCompositedDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonReflectionWithCompositedDescendants, CompositingReasonReflectionWithCompositedDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonFilterWithCompositedDescendants, CompositingReasonFilterWithCompositedDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonBlendingWithCompositedDescendants, CompositingReasonBlendingWithCompositedDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonClipsCompositingDescendants, CompositingReasonClipsCompositingDescendants);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonPerspective, CompositingReasonPerspective);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonPreserve3D, CompositingReasonPreserve3D);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonReflectionOfCompositedParent, CompositingReasonReflectionOfCompositedParent);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonRoot, CompositingReasonRoot);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForClip, CompositingReasonLayerForClip);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForScrollbar, CompositingReasonLayerForScrollbar);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForScrollingContainer, CompositingReasonLayerForScrollingContainer);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForForeground, CompositingReasonLayerForForeground);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForBackground, CompositingReasonLayerForBackground);
+COMPILE_ASSERT_MATCHING_UINT64(CompositingReasonLayerForMask, CompositingReasonLayerForMask);
diff --git a/chromium/third_party/WebKit/Source/web/AssociatedURLLoader.cpp b/chromium/third_party/WebKit/Source/web/AssociatedURLLoader.cpp
new file mode 100644
index 00000000000..98f9cae4fe2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AssociatedURLLoader.cpp
@@ -0,0 +1,373 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Google Inc. 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 "core/loader/CrossOriginAccessControl.h"
+#include "core/loader/DocumentThreadableLoader.h"
+#include "core/loader/DocumentThreadableLoaderClient.h"
+#include "core/platform/Timer.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "core/platform/chromium/support/WrappedResourceResponse.h"
+#include "core/platform/network/HTTPParsers.h"
+#include "core/platform/network/ResourceError.h"
+#include "core/xml/XMLHttpRequest.h"
+#include "public/platform/WebHTTPHeaderVisitor.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebURLLoaderClient.h"
+#include "public/platform/WebURLRequest.h"
+#include "wtf/HashSet.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+using namespace WTF;
+
+namespace WebKit {
+
+namespace {
+
+class HTTPRequestHeaderValidator : public WebHTTPHeaderVisitor {
+ WTF_MAKE_NONCOPYABLE(HTTPRequestHeaderValidator);
+public:
+ HTTPRequestHeaderValidator() : m_isSafe(true) { }
+
+ void visitHeader(const WebString& name, const WebString& value);
+ bool isSafe() const { return m_isSafe; }
+
+private:
+ bool m_isSafe;
+};
+
+typedef HashSet<String, CaseFoldingHash> HTTPHeaderSet;
+
+void HTTPRequestHeaderValidator::visitHeader(const WebString& name, const WebString& value)
+{
+ m_isSafe = m_isSafe && isValidHTTPToken(name) && XMLHttpRequest::isAllowedHTTPHeader(name) && isValidHTTPHeaderValue(value);
+}
+
+// FIXME: Remove this and use WebCore code that does the same thing.
+class HTTPResponseHeaderValidator : public WebHTTPHeaderVisitor {
+ WTF_MAKE_NONCOPYABLE(HTTPResponseHeaderValidator);
+public:
+ HTTPResponseHeaderValidator(bool usingAccessControl) : m_usingAccessControl(usingAccessControl) { }
+
+ void visitHeader(const WebString& name, const WebString& value);
+ const HTTPHeaderSet& blockedHeaders();
+
+private:
+ HTTPHeaderSet m_exposedHeaders;
+ HTTPHeaderSet m_blockedHeaders;
+ bool m_usingAccessControl;
+};
+
+void HTTPResponseHeaderValidator::visitHeader(const WebString& name, const WebString& value)
+{
+ String headerName(name);
+ if (m_usingAccessControl) {
+ if (equalIgnoringCase(headerName, "access-control-expose-headers"))
+ parseAccessControlExposeHeadersAllowList(value, m_exposedHeaders);
+ else if (!isOnAccessControlResponseHeaderWhitelist(headerName))
+ m_blockedHeaders.add(name);
+ }
+}
+
+const HTTPHeaderSet& HTTPResponseHeaderValidator::blockedHeaders()
+{
+ // Remove exposed headers from the blocked set.
+ if (!m_exposedHeaders.isEmpty()) {
+ // Don't allow Set-Cookie headers to be exposed.
+ m_exposedHeaders.remove("set-cookie");
+ m_exposedHeaders.remove("set-cookie2");
+ // Block Access-Control-Expose-Header itself. It could be exposed later.
+ m_blockedHeaders.add("access-control-expose-headers");
+ HTTPHeaderSet::const_iterator end = m_exposedHeaders.end();
+ for (HTTPHeaderSet::const_iterator it = m_exposedHeaders.begin(); it != end; ++it)
+ m_blockedHeaders.remove(*it);
+ }
+
+ return m_blockedHeaders;
+}
+
+}
+
+// This class bridges the interface differences between WebCore and WebKit loader clients.
+// It forwards its ThreadableLoaderClient notifications to a WebURLLoaderClient.
+class AssociatedURLLoader::ClientAdapter : public DocumentThreadableLoaderClient {
+ WTF_MAKE_NONCOPYABLE(ClientAdapter);
+public:
+ static PassOwnPtr<ClientAdapter> create(AssociatedURLLoader*, WebURLLoaderClient*, const WebURLLoaderOptions&);
+
+ virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/);
+ virtual void willSendRequest(ResourceRequest& /*newRequest*/, const ResourceResponse& /*redirectResponse*/);
+
+ virtual void didReceiveResponse(unsigned long, const ResourceResponse&);
+ virtual void didDownloadData(int /*dataLength*/);
+ virtual void didReceiveData(const char*, int /*dataLength*/);
+ virtual void didReceiveCachedMetadata(const char*, int /*dataLength*/);
+ virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishTime*/);
+ virtual void didFail(const ResourceError&);
+ virtual void didFailRedirectCheck();
+
+ virtual bool isDocumentThreadableLoaderClient() { return true; }
+
+ // Sets an error to be reported back to the client, asychronously.
+ void setDelayedError(const ResourceError&);
+
+ // Enables forwarding of error notifications to the WebURLLoaderClient. These must be
+ // deferred until after the call to AssociatedURLLoader::loadAsynchronously() completes.
+ void enableErrorNotifications();
+
+ // Stops loading and releases the DocumentThreadableLoader as early as possible.
+ void clearClient() { m_client = 0; }
+
+private:
+ ClientAdapter(AssociatedURLLoader*, WebURLLoaderClient*, const WebURLLoaderOptions&);
+
+ void notifyError(Timer<ClientAdapter>*);
+
+ AssociatedURLLoader* m_loader;
+ WebURLLoaderClient* m_client;
+ WebURLLoaderOptions m_options;
+ WebURLError m_error;
+
+ Timer<ClientAdapter> m_errorTimer;
+ bool m_enableErrorNotifications;
+ bool m_didFail;
+};
+
+PassOwnPtr<AssociatedURLLoader::ClientAdapter> AssociatedURLLoader::ClientAdapter::create(AssociatedURLLoader* loader, WebURLLoaderClient* client, const WebURLLoaderOptions& options)
+{
+ return adoptPtr(new ClientAdapter(loader, client, options));
+}
+
+AssociatedURLLoader::ClientAdapter::ClientAdapter(AssociatedURLLoader* loader, WebURLLoaderClient* client, const WebURLLoaderOptions& options)
+ : m_loader(loader)
+ , m_client(client)
+ , m_options(options)
+ , m_errorTimer(this, &ClientAdapter::notifyError)
+ , m_enableErrorNotifications(false)
+ , m_didFail(false)
+{
+ ASSERT(m_loader);
+ ASSERT(m_client);
+}
+
+void AssociatedURLLoader::ClientAdapter::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
+{
+ if (!m_client)
+ return;
+
+ WrappedResourceRequest wrappedNewRequest(newRequest);
+ WrappedResourceResponse wrappedRedirectResponse(redirectResponse);
+ m_client->willSendRequest(m_loader, wrappedNewRequest, wrappedRedirectResponse);
+}
+
+void AssociatedURLLoader::ClientAdapter::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+{
+ if (!m_client)
+ return;
+
+ m_client->didSendData(m_loader, bytesSent, totalBytesToBeSent);
+}
+
+void AssociatedURLLoader::ClientAdapter::didReceiveResponse(unsigned long, const ResourceResponse& response)
+{
+ // Try to use the original ResourceResponse if possible.
+ WebURLResponse validatedResponse = WrappedResourceResponse(response);
+ HTTPResponseHeaderValidator validator(m_options.crossOriginRequestPolicy == WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl);
+ if (!m_options.exposeAllResponseHeaders)
+ validatedResponse.visitHTTPHeaderFields(&validator);
+
+ // If there are blocked headers, copy the response so we can remove them.
+ const HTTPHeaderSet& blockedHeaders = validator.blockedHeaders();
+ if (!blockedHeaders.isEmpty()) {
+ validatedResponse = WebURLResponse(validatedResponse);
+ HTTPHeaderSet::const_iterator end = blockedHeaders.end();
+ for (HTTPHeaderSet::const_iterator it = blockedHeaders.begin(); it != end; ++it)
+ validatedResponse.clearHTTPHeaderField(*it);
+ }
+ m_client->didReceiveResponse(m_loader, validatedResponse);
+}
+
+void AssociatedURLLoader::ClientAdapter::didDownloadData(int dataLength)
+{
+ if (!m_client)
+ return;
+
+ m_client->didDownloadData(m_loader, dataLength);
+}
+
+void AssociatedURLLoader::ClientAdapter::didReceiveData(const char* data, int dataLength)
+{
+ if (!m_client)
+ return;
+
+ m_client->didReceiveData(m_loader, data, dataLength, -1);
+}
+
+void AssociatedURLLoader::ClientAdapter::didReceiveCachedMetadata(const char* data, int dataLength)
+{
+ if (!m_client)
+ return;
+
+ m_client->didReceiveCachedMetadata(m_loader, data, dataLength);
+}
+
+void AssociatedURLLoader::ClientAdapter::didFinishLoading(unsigned long identifier, double finishTime)
+{
+ if (!m_client)
+ return;
+
+ m_client->didFinishLoading(m_loader, finishTime);
+}
+
+void AssociatedURLLoader::ClientAdapter::didFail(const ResourceError& error)
+{
+ if (!m_client)
+ return;
+
+ m_didFail = true;
+ m_error = WebURLError(error);
+ if (m_enableErrorNotifications)
+ notifyError(&m_errorTimer);
+}
+
+void AssociatedURLLoader::ClientAdapter::didFailRedirectCheck()
+{
+ m_loader->cancel();
+}
+
+void AssociatedURLLoader::ClientAdapter::setDelayedError(const ResourceError& error)
+{
+ didFail(error);
+}
+
+void AssociatedURLLoader::ClientAdapter::enableErrorNotifications()
+{
+ m_enableErrorNotifications = true;
+ // If an error has already been received, start a timer to report it to the client
+ // after AssociatedURLLoader::loadAsynchronously has returned to the caller.
+ if (m_didFail)
+ m_errorTimer.startOneShot(0);
+}
+
+void AssociatedURLLoader::ClientAdapter::notifyError(Timer<ClientAdapter>* timer)
+{
+ ASSERT_UNUSED(timer, timer == &m_errorTimer);
+
+ m_client->didFail(m_loader, m_error);
+}
+
+AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl, const WebURLLoaderOptions& options)
+ : m_frameImpl(frameImpl)
+ , m_options(options)
+ , m_client(0)
+{
+ ASSERT(m_frameImpl);
+}
+
+AssociatedURLLoader::~AssociatedURLLoader()
+{
+ cancel();
+}
+
+#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \
+ COMPILE_ASSERT(static_cast<int>(WebKit::webkit_name) == static_cast<int>(WebCore::webcore_name), mismatching_enums)
+
+COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyDeny, DenyCrossOriginRequests);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl, UseAccessControl);
+COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyAllow, AllowCrossOriginRequests);
+
+void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURLResponse& response, WebURLError& error, WebData& data)
+{
+ ASSERT(0); // Synchronous loading is not supported.
+}
+
+void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client)
+{
+ ASSERT(!m_client);
+
+ m_client = client;
+ ASSERT(m_client);
+
+ bool allowLoad = true;
+ WebURLRequest newRequest(request);
+ if (m_options.untrustedHTTP) {
+ WebString method = newRequest.httpMethod();
+ allowLoad = isValidHTTPToken(method) && XMLHttpRequest::isAllowedHTTPMethod(method);
+ if (allowLoad) {
+ newRequest.setHTTPMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(method));
+ HTTPRequestHeaderValidator validator;
+ newRequest.visitHTTPHeaderFields(&validator);
+ allowLoad = validator.isSafe();
+ }
+ }
+
+ m_clientAdapter = ClientAdapter::create(this, m_client, m_options);
+
+ if (allowLoad) {
+ ThreadableLoaderOptions options;
+ options.sendLoadCallbacks = SendCallbacks; // Always send callbacks.
+ options.sniffContent = m_options.sniffContent ? SniffContent : DoNotSniffContent;
+ options.allowCredentials = m_options.allowCredentials ? AllowStoredCredentials : DoNotAllowStoredCredentials;
+ options.preflightPolicy = m_options.forcePreflight ? ForcePreflight : ConsiderPreflight;
+ options.crossOriginRequestPolicy = static_cast<WebCore::CrossOriginRequestPolicy>(m_options.crossOriginRequestPolicy);
+ options.dataBufferingPolicy = DoNotBufferData;
+
+ const ResourceRequest& webcoreRequest = newRequest.toResourceRequest();
+ Document* webcoreDocument = m_frameImpl->frame()->document();
+ m_loader = DocumentThreadableLoader::create(webcoreDocument, m_clientAdapter.get(), webcoreRequest, options);
+ } else {
+ // FIXME: return meaningful error codes.
+ m_clientAdapter->setDelayedError(ResourceError());
+ }
+ m_clientAdapter->enableErrorNotifications();
+}
+
+void AssociatedURLLoader::cancel()
+{
+ if (m_clientAdapter)
+ m_clientAdapter->clearClient();
+ if (m_loader)
+ m_loader->cancel();
+}
+
+void AssociatedURLLoader::setDefersLoading(bool defersLoading)
+{
+ if (m_loader)
+ m_loader->setDefersLoading(defersLoading);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/AssociatedURLLoader.h b/chromium/third_party/WebKit/Source/web/AssociatedURLLoader.h
new file mode 100644
index 00000000000..7007a5d8dbf
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AssociatedURLLoader.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010, 2011 Google Inc. 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 "WebURLLoaderOptions.h"
+#include "public/platform/WebURLLoader.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore { class DocumentThreadableLoader; }
+
+namespace WebKit {
+
+class WebFrameImpl;
+
+// This class is used to implement WebFrame::createAssociatedURLLoader.
+class AssociatedURLLoader : public WebURLLoader {
+ WTF_MAKE_NONCOPYABLE(AssociatedURLLoader);
+public:
+ AssociatedURLLoader(PassRefPtr<WebFrameImpl>, const WebURLLoaderOptions&);
+ ~AssociatedURLLoader();
+
+ // WebURLLoader methods:
+ virtual void loadSynchronously(const WebURLRequest&, WebURLResponse&, WebURLError&, WebData&);
+ virtual void loadAsynchronously(const WebURLRequest&, WebURLLoaderClient*);
+ virtual void cancel();
+ virtual void setDefersLoading(bool);
+
+private:
+
+ class ClientAdapter;
+
+ RefPtr<WebFrameImpl> m_frameImpl;
+ WebURLLoaderOptions m_options;
+ WebURLLoaderClient* m_client;
+ OwnPtr<ClientAdapter> m_clientAdapter;
+ RefPtr<WebCore::DocumentThreadableLoader> m_loader;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.cpp b/chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.cpp
new file mode 100644
index 00000000000..66b37edee11
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.cpp
@@ -0,0 +1,128 @@
+/*
+ * 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"
+
+#include "AsyncFileWriterChromium.h"
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebFileWriter.h"
+#include "core/platform/AsyncFileSystemCallbacks.h"
+#include "core/platform/FileMetadata.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebFileInfo.h"
+#include "public/platform/WebFileSystem.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuilder.h"
+
+namespace WebCore {
+
+PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create()
+{
+ return AsyncFileSystemChromium::create();
+}
+
+AsyncFileSystemChromium::AsyncFileSystemChromium()
+{
+}
+
+AsyncFileSystemChromium::~AsyncFileSystemChromium()
+{
+}
+
+void AsyncFileSystemChromium::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->move(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->copy(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->remove(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->removeRecursively(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->readMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->createFile(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->createDirectory(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->fileExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->directoryExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ OwnPtr<AsyncFileWriterChromium> asyncFileWriter = AsyncFileWriterChromium::create(client);
+ WebKit::WebFileWriterClient* writerClient = asyncFileWriter.get();
+
+ webFileSystem()->createFileWriter(path, writerClient, new WebKit::WebFileSystemCallbacksImpl(callbacks, asyncFileWriter.release()));
+}
+
+void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ webFileSystem()->createSnapshotFileAndReadMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+}
+
+WebKit::WebFileSystem* AsyncFileSystemChromium::webFileSystem()
+{
+ return WebKit::Platform::current()->fileSystem();
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.h b/chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.h
new file mode 100644
index 00000000000..1eaa9c2d89e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AsyncFileSystemChromium.h
@@ -0,0 +1,74 @@
+/*
+ * 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
+
+#include "core/platform/AsyncFileSystem.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebKit {
+class WebFileSystem;
+}
+
+namespace WebCore {
+
+class AsyncFileSystemCallbacks;
+
+class AsyncFileSystemChromium : public AsyncFileSystem {
+public:
+ static PassOwnPtr<AsyncFileSystem> create()
+ {
+ return adoptPtr(new AsyncFileSystemChromium());
+ }
+
+ virtual ~AsyncFileSystemChromium();
+
+ virtual void move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+ virtual void createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+
+private:
+ AsyncFileSystemChromium();
+ WebKit::WebFileSystem* webFileSystem();
+};
+
+} // namespace WebCore
+
+#endif // AsyncFileSystemChromium_h
diff --git a/chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.cpp b/chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.cpp
new file mode 100644
index 00000000000..83460761563
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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"
+
+#include "WebFileWriter.h"
+#include "core/fileapi/Blob.h"
+#include "modules/filesystem/AsyncFileWriterClient.h"
+#include "public/platform/WebURL.h"
+
+namespace WebCore {
+
+PassOwnPtr<AsyncFileWriterChromium> AsyncFileWriterChromium::create(AsyncFileWriterClient* client)
+{
+ return adoptPtr(new AsyncFileWriterChromium(client));
+}
+
+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
diff --git a/chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.h b/chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.h
new file mode 100644
index 00000000000..358c82b769c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AsyncFileWriterChromium.h
@@ -0,0 +1,74 @@
+/*
+ * 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
+
+#include "WebFileWriterClient.h"
+#include "modules/filesystem/AsyncFileWriter.h"
+#include "public/platform/WebFileError.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebKit {
+class WebFileWriter;
+}
+
+namespace WebCore {
+
+class Blob;
+class AsyncFileWriterClient;
+
+class AsyncFileWriterChromium : public AsyncFileWriter, public WebKit::WebFileWriterClient {
+public:
+ static PassOwnPtr<AsyncFileWriterChromium> create(AsyncFileWriterClient*);
+ virtual ~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:
+ explicit AsyncFileWriterChromium(AsyncFileWriterClient*);
+
+ OwnPtr<WebKit::WebFileWriter> m_writer;
+ AsyncFileWriterClient* m_client;
+};
+
+} // namespace
+
+#endif // AsyncFileWriterChromium_h
diff --git a/chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.cpp b/chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.cpp
new file mode 100644
index 00000000000..2c4fc51aeca
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.cpp
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "CSSValueKeywords.h"
+#include "WebAutofillClient.h"
+#include "WebNode.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/css/CSSFontSelector.h"
+#include "core/css/resolver/StyleResolver.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/page/Chrome.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/rendering/RenderTheme.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+AutofillPopupMenuClient::AutofillPopupMenuClient()
+ : m_selectedIndex(-1)
+ , m_textField(0)
+ , m_useLegacyBehavior(false)
+{
+}
+
+AutofillPopupMenuClient::~AutofillPopupMenuClient()
+{
+}
+
+unsigned AutofillPopupMenuClient::getSuggestionsCount() const
+{
+ return m_names.size();
+}
+
+WebString AutofillPopupMenuClient::getSuggestion(unsigned listIndex) const
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_names.size());
+ return m_names[listIndex];
+}
+
+WebString AutofillPopupMenuClient::getLabel(unsigned listIndex) const
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_labels.size());
+ return m_labels[listIndex];
+}
+
+WebString AutofillPopupMenuClient::getIcon(unsigned listIndex) const
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_icons.size());
+ return m_icons[listIndex];
+}
+
+void AutofillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex)
+{
+ if (!canRemoveSuggestionAtIndex(listIndex))
+ return;
+
+ ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_names.size());
+
+ m_names.remove(listIndex);
+ m_labels.remove(listIndex);
+ m_icons.remove(listIndex);
+ m_itemIDs.remove(listIndex);
+}
+
+bool AutofillPopupMenuClient::canRemoveSuggestionAtIndex(unsigned listIndex)
+{
+ return m_itemIDs[listIndex] == WebAutofillClient::MenuItemIDAutocompleteEntry || m_itemIDs[listIndex] == WebAutofillClient::MenuItemIDPasswordEntry;
+}
+
+void AutofillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
+{
+ WebViewImpl* webView = getWebView();
+ if (!webView)
+ return;
+
+ ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_names.size());
+
+ if (m_useLegacyBehavior) {
+ for (size_t i = 0; i < m_itemIDs.size(); ++i) {
+ if (m_itemIDs[i] == WebAutofillClient::MenuItemIDSeparator) {
+ if (listIndex > i)
+ listIndex--;
+ break;
+ }
+ }
+ }
+
+ webView->autofillClient()->didAcceptAutofillSuggestion(WebNode(getTextField()),
+ m_names[listIndex],
+ m_labels[listIndex],
+ m_itemIDs[listIndex],
+ listIndex);
+}
+
+void AutofillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
+{
+ WebViewImpl* webView = getWebView();
+ if (!webView)
+ return;
+
+ ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_names.size());
+
+ webView->autofillClient()->didSelectAutofillSuggestion(WebNode(getTextField()),
+ m_names[listIndex],
+ m_labels[listIndex],
+ m_itemIDs[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;
+}
+
+WebCore::LayoutUnit 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);
+}
+
+WebCore::LayoutUnit 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_itemIDs[listIndex] == WebAutofillClient::MenuItemIDSeparator;
+}
+
+bool AutofillPopupMenuClient::itemIsWarning(unsigned listIndex) const
+{
+ return m_itemIDs[listIndex] == WebAutofillClient::MenuItemIDWarningMessage;
+}
+
+void AutofillPopupMenuClient::setTextFromItem(unsigned listIndex)
+{
+ m_textField->setValue(getSuggestion(listIndex));
+}
+
+FontSelector* AutofillPopupMenuClient::fontSelector() const
+{
+ return m_textField->document()->styleResolver()->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>& itemIDs,
+ int separatorIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == icons.size());
+ ASSERT(names.size() == itemIDs.size());
+
+ m_selectedIndex = -1;
+ m_textField = textField;
+
+ if (separatorIndex == -1) {
+ // The suggestions must be set before initializing the
+ // AutofillPopupMenuClient.
+ setSuggestions(names, labels, icons, itemIDs);
+ } else {
+ m_useLegacyBehavior = true;
+ WebVector<WebString> namesWithSeparator(names.size() + 1);
+ WebVector<WebString> labelsWithSeparator(labels.size() + 1);
+ WebVector<WebString> iconsWithSeparator(icons.size() + 1);
+ WebVector<int> itemIDsWithSeparator(itemIDs.size() + 1);
+ for (size_t i = 0; i < names.size(); ++i) {
+ size_t j = i < static_cast<size_t>(separatorIndex) ? i : i + 1;
+ namesWithSeparator[j] = names[i];
+ labelsWithSeparator[j] = labels[i];
+ iconsWithSeparator[j] = icons[i];
+ itemIDsWithSeparator[j] = itemIDs[i];
+ }
+ itemIDsWithSeparator[separatorIndex] = WebAutofillClient::MenuItemIDSeparator;
+ setSuggestions(namesWithSeparator, labelsWithSeparator, iconsWithSeparator, itemIDsWithSeparator);
+ }
+
+ 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()->styleResolver()->fontSelector());
+ // The direction of text in popup menu is set the same as the direction of
+ // the input element: textField.
+ m_regularStyle = adoptPtr(new PopupMenuStyle(Color::black, Color::white, regularFont, true, false,
+ Length(WebCore::Fixed), textField->renderer()->style()->direction(),
+ textField->renderer()->style()->unicodeBidi() == Override,
+ PopupMenuStyle::CustomBackgroundColor, PopupMenuStyle::AutofillPopup));
+
+ FontDescription warningFontDescription = regularFont.fontDescription();
+ warningFontDescription.setItalic(true);
+ Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing());
+ warningFont.update(regularFont.fontSelector());
+ m_warningStyle = adoptPtr(new PopupMenuStyle(Color::darkGray, m_regularStyle->backgroundColor(), warningFont,
+ m_regularStyle->isVisible(), m_regularStyle->isDisplayNone(),
+ m_regularStyle->textIndent(), m_regularStyle->textDirection(),
+ m_regularStyle->hasTextDirectionOverride(),
+ PopupMenuStyle::CustomBackgroundColor, PopupMenuStyle::AutofillPopup));
+}
+
+void AutofillPopupMenuClient::setSuggestions(const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& itemIDs)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == icons.size());
+ ASSERT(names.size() == itemIDs.size());
+
+ m_names.clear();
+ m_labels.clear();
+ m_icons.clear();
+ m_itemIDs.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_itemIDs.append(itemIDs[i]);
+ }
+
+ // Try to preserve selection if possible.
+ if (getSelectedIndex() >= static_cast<int>(names.size()))
+ setSelectedIndex(-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<WebViewImpl*>(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/chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.h b/chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.h
new file mode 100644
index 00000000000..62863196945
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/AutofillPopupMenuClient.h
@@ -0,0 +1,145 @@
+/*
+ * 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 "core/platform/PopupMenuClient.h"
+
+namespace WebCore {
+class FontSelector;
+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 WebCore::LayoutUnit clientPaddingLeft() const;
+ virtual WebCore::LayoutUnit 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 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>& itemIDs,
+ int separatorIndex);
+
+ void setSuggestions(const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
+ const WebVector<int>& itemIDs);
+
+private:
+ 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_itemIDs;
+
+ // 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;
+
+ // Use legacy behavior while the chromium side hasn't been updated.
+ bool m_useLegacyBehavior;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/BackForwardClientImpl.cpp b/chromium/third_party/WebKit/Source/web/BackForwardClientImpl.cpp
new file mode 100644
index 00000000000..6e2c17f4bca
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/BackForwardClientImpl.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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 "BackForwardClientImpl.h"
+
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+BackForwardClientImpl::BackForwardClientImpl(WebViewImpl* webView)
+ : m_webView(webView)
+{
+}
+
+BackForwardClientImpl::~BackForwardClientImpl()
+{
+}
+
+void BackForwardClientImpl::didAddItem()
+{
+ // If WebCore adds a new HistoryItem, it means this is a new navigation (ie,
+ // not a reload or back/forward).
+ m_webView->observeNewNavigation();
+}
+
+int BackForwardClientImpl::backListCount()
+{
+ if (!m_webView->client())
+ return 0;
+
+ return m_webView->client()->historyBackListCount();
+}
+
+int BackForwardClientImpl::forwardListCount()
+{
+ if (!m_webView->client())
+ return 0;
+
+ return m_webView->client()->historyForwardListCount();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/BackForwardClientImpl.h b/chromium/third_party/WebKit/Source/web/BackForwardClientImpl.h
new file mode 100644
index 00000000000..6550a4075ef
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/BackForwardClientImpl.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 BackForwardClientImpl_h
+#define BackForwardClientImpl_h
+
+#include "core/history/BackForwardClient.h"
+#include "core/history/HistoryItem.h"
+
+namespace WebKit {
+class WebViewImpl;
+
+class BackForwardClientImpl : public WebCore::BackForwardClient {
+public:
+ explicit BackForwardClientImpl(WebViewImpl*);
+ virtual ~BackForwardClientImpl();
+
+private:
+ // WebCore::BackForwardList methods:
+ virtual void didAddItem();
+ virtual int backListCount();
+ virtual int forwardListCount();
+
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp b/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp
new file mode 100644
index 00000000000..a567df5fb45
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp
@@ -0,0 +1,1018 @@
+/*
+ * 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 "ColorChooserPopupUIController.h"
+#include "ColorChooserUIController.h"
+#include "DateTimeChooserImpl.h"
+#include "ExternalDateTimeChooser.h"
+#include "ExternalPopupMenu.h"
+#include "HTMLNames.h"
+#include "PopupContainer.h"
+#include "PopupMenuChromium.h"
+#include "RuntimeEnabledFeatures.h"
+#include "WebAccessibilityObject.h"
+#include "WebAutofillClient.h"
+#include "WebColorChooser.h"
+#include "WebConsoleMessage.h"
+#include "WebCursorInfo.h"
+#include "WebFileChooserCompletionImpl.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebInputElement.h"
+#include "WebInputEvent.h"
+#include "WebKit.h"
+#include "WebNode.h"
+#include "WebPasswordGeneratorClient.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPopupMenuImpl.h"
+#include "WebPopupMenuInfo.h"
+#include "WebPopupType.h"
+#include "WebSettings.h"
+#include "WebSettingsImpl.h"
+#include "WebTextDirection.h"
+#include "WebUserGestureIndicator.h"
+#include "WebUserGestureToken.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "WebWindowFeatures.h"
+#include "bindings/v8/ScriptController.h"
+#include "core/accessibility/AXObjectCache.h"
+#include "core/accessibility/AccessibilityObject.h"
+#include "core/dom/Document.h"
+#include "core/dom/Node.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoadRequest.h"
+#include "core/loader/NavigationAction.h"
+#include "core/page/Console.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/PagePopupDriver.h"
+#include "core/page/Settings.h"
+#include "core/page/WindowFeatures.h"
+#include "core/platform/ColorChooser.h"
+#include "core/platform/ColorChooserClient.h"
+#include "core/platform/Cursor.h"
+#include "core/platform/DateTimeChooser.h"
+#include "core/platform/FileChooser.h"
+#include "core/platform/PlatformScreen.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "core/platform/graphics/FloatRect.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/platform/graphics/IntRect.h"
+#include "core/rendering/HitTestResult.h"
+#include "core/rendering/RenderWidget.h"
+#include "modules/geolocation/Geolocation.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebURLRequest.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/StringConcatenate.h"
+#include "wtf/unicode/CharacterNames.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)
+{
+ // These enums have the same values; enforced in AssertMatchingEnums.cpp.
+ return static_cast<WebAccessibilityNotification>(notification);
+}
+
+ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
+ : m_webView(webView)
+ , m_toolbarsVisible(true)
+ , m_statusbarVisible(true)
+ , m_scrollbarsVisible(true)
+ , m_menubarVisible(true)
+ , m_resizable(true)
+ , m_pagePopupDriver(webView)
+{
+}
+
+ChromeClientImpl::~ChromeClientImpl()
+{
+}
+
+void* ChromeClientImpl::webView() const
+{
+ return static_cast<void*>(m_webView);
+}
+
+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();
+}
+
+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(toElement(node));
+ if (hitTest.isLiveLink())
+ focusURL = hitTest.absoluteLinkURL();
+ }
+ m_webView->client()->setKeyboardFocusURL(focusURL);
+}
+
+Page* ChromeClientImpl::createWindow(
+ Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features, const NavigationAction& action, NavigationPolicy navigationPolicy)
+{
+ if (!m_webView->client())
+ return 0;
+
+ WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPolicy);
+ if (policy == WebNavigationPolicyIgnore)
+ policy = getNavigationPolicy();
+
+ WrappedResourceRequest request;
+ if (!r.resourceRequest().isEmpty())
+ request.bind(r.resourceRequest());
+ else if (!action.resourceRequest().isEmpty())
+ request.bind(action.resourceRequest());
+ WebViewImpl* newView = static_cast<WebViewImpl*>(
+ m_webView->client()->createView(WebFrameImpl::fromFrame(frame), request, features, r.frameName(), policy));
+ if (!newView)
+ return 0;
+ return newView->page();
+}
+
+static inline void updatePolicyForEvent(const WebInputEvent* inputEvent, NavigationPolicy* policy)
+{
+ if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp)
+ return;
+
+ const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent);
+
+ 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;
+ }
+ bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey;
+ bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey;
+ bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey;
+ bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey;
+
+ NavigationPolicy userPolicy = *policy;
+ navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPolicy);
+ // User and app agree that we want a new window; let the app override the decorations.
+ if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNewPopup)
+ return;
+ *policy = userPolicy;
+}
+
+WebNavigationPolicy ChromeClientImpl::getNavigationPolicy()
+{
+ // 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;
+
+ NavigationPolicy policy = NavigationPolicyNewForegroundTab;
+ if (asPopup)
+ policy = NavigationPolicyNewPopup;
+ updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy);
+
+ return static_cast<WebNavigationPolicy>(policy);
+}
+
+void ChromeClientImpl::show(NavigationPolicy navigationPolicy)
+{
+ if (!m_webView->client())
+ return;
+
+ WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPolicy);
+ if (policy == WebNavigationPolicyIgnore)
+ policy = getNavigationPolicy();
+ 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,
+ 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()->clearPageGroup();
+
+ // 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()) {
+ if (WebUserGestureIndicator::isProcessingUserGesture())
+ WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt();
+ m_webView->client()->runModalAlertDialog(
+ WebFrameImpl::fromFrame(frame), message);
+ }
+}
+
+// See comments for runJavaScriptAlert().
+bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message)
+{
+ if (m_webView->client()) {
+ if (WebUserGestureIndicator::isProcessingUserGesture())
+ WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt();
+ 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()) {
+ if (WebUserGestureIndicator::isProcessingUserGesture())
+ WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt();
+ 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::tabsToLinks()
+{
+ return m_webView->tabsToLinks();
+}
+
+IntRect ChromeClientImpl::windowResizerRect() const
+{
+ IntRect result;
+ if (m_webView->client())
+ result = m_webView->client()->windowResizerRect();
+ return result;
+}
+
+void ChromeClientImpl::invalidateContentsAndRootView(const IntRect& updateRect)
+{
+ if (updateRect.isEmpty())
+ return;
+ m_webView->invalidateRect(updateRect);
+}
+
+void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect)
+{
+ invalidateContentsAndRootView(updateRect);
+}
+
+void ChromeClientImpl::scheduleAnimation()
+{
+ m_webView->scheduleAnimation();
+}
+
+void ChromeClientImpl::scroll(
+ const IntSize& scrollDelta, const IntRect& scrollRect,
+ const IntRect& clipRect)
+{
+ if (!m_webView->isAcceleratedCompositingActive()) {
+ if (m_webView->client()) {
+ int dx = scrollDelta.width();
+ int dy = scrollDelta.height();
+ m_webView->client()->didScrollRect(dx, dy, intersection(scrollRect, clipRect));
+ }
+ } else
+ m_webView->scrollRootLayerRect(scrollDelta, clipRect);
+}
+
+IntPoint ChromeClientImpl::screenToRootView(const IntPoint& point) const
+{
+ IntPoint windowPoint(point);
+
+ if (m_webView->client()) {
+ WebRect windowRect = m_webView->client()->windowRect();
+ windowPoint.move(-windowRect.x, -windowRect.y);
+ }
+
+ return windowPoint;
+}
+
+IntRect ChromeClientImpl::rootViewToScreen(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;
+}
+
+WebScreenInfo ChromeClientImpl::screenInfo() const
+{
+ return m_webView->client() ? m_webView->client()->screenInfo() : WebScreenInfo();
+}
+
+void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const
+{
+ m_webView->didChangeContentsSize();
+
+ WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
+ webframe->didChangeContentsSize(size);
+ if (webframe->client())
+ webframe->client()->didChangeContentsSize(webframe, size);
+}
+
+void ChromeClientImpl::deviceOrPageScaleFactorChanged() const
+{
+ m_webView->deviceOrPageScaleFactorChanged();
+}
+
+void ChromeClientImpl::didProgrammaticallyScroll(Frame* frame, const IntPoint& scrollPoint) const
+{
+ ASSERT(frame->view()->inProgrammaticScroll());
+ if (frame->page()->mainFrame() == frame)
+ m_webView->didProgrammaticallyScroll(scrollPoint);
+}
+
+void ChromeClientImpl::layoutUpdated(Frame* frame) const
+{
+ m_webView->layoutUpdated(WebFrameImpl::fromFrame(frame));
+}
+
+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.roundedPointInInnerNodeFrame());
+ }
+ }
+ }
+
+ 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::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const
+{
+ m_webView->updatePageDefinedPageScaleConstraints(arguments);
+}
+
+void ChromeClientImpl::print(Frame* frame)
+{
+ if (m_webView->client())
+ m_webView->client()->printPage(WebFrameImpl::fromFrame(frame));
+}
+
+PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(ColorChooserClient* chooserClient, const Color&)
+{
+ OwnPtr<ColorChooserUIController> controller;
+ if (RuntimeEnabledFeatures::pagePopupEnabled())
+ controller = adoptPtr(new ColorChooserPopupUIController(this, chooserClient));
+ else
+ controller = adoptPtr(new ColorChooserUIController(this, chooserClient));
+ controller->openUI();
+ return controller.release();
+}
+PassOwnPtr<WebColorChooser> ChromeClientImpl::createWebColorChooser(WebColorChooserClient* chooserClient, const WebColor& initialColor)
+{
+ WebViewClient* client = m_webView->client();
+ if (!client)
+ return nullptr;
+ return adoptPtr(client->createColorChooser(chooserClient, initialColor));
+}
+
+PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChooserClient* pickerClient, const DateTimeChooserParameters& parameters)
+{
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+ return DateTimeChooserImpl::create(this, pickerClient, parameters);
+#else
+ return ExternalDateTimeChooser::create(this, m_webView->client(), pickerClient, parameters);
+#endif
+}
+
+void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
+{
+ WebViewClient* client = m_webView->client();
+ if (!client)
+ return;
+
+ WebFileChooserParams params;
+ params.multiSelect = fileChooser->settings().allowsMultipleFiles;
+ params.directory = fileChooser->settings().allowsDirectoryUpload;
+ params.acceptTypes = fileChooser->settings().acceptTypes();
+ params.selectedFiles = fileChooser->settings().selectedFiles;
+ if (params.selectedFiles.size() > 0)
+ params.initialValue = params.selectedFiles[0];
+#if ENABLE(MEDIA_CAPTURE)
+ params.useMediaCapture = fileChooser->settings().useMediaCapture;
+#endif
+ 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::enumerateChosenDirectory(FileChooser* fileChooser)
+{
+ WebViewClient* client = m_webView->client();
+ if (!client)
+ return;
+
+ WebFileChooserCompletionImpl* chooserCompletion =
+ new WebFileChooserCompletionImpl(fileChooser);
+
+ ASSERT(fileChooser && fileChooser->settings().selectedFiles.size());
+
+ // If the enumeration can't happen, call the callback with an empty list.
+ if (!client->enumerateChosenDirectory(fileChooser->settings().selectedFiles[0], chooserCompletion))
+ chooserCompletion->didChooseFile(WebVector<WebString>());
+}
+
+void ChromeClientImpl::popupOpened(PopupContainer* popupContainer,
+ const IntRect& bounds,
+ bool handleExternally)
+{
+ // For Autofill popups, if the popup will not be fully visible, we shouldn't
+ // show it at all. Among other things, this prevents users from being able
+ // to interact via the keyboard with an invisible popup.
+ if (popupContainer->popupType() == PopupContainer::Suggestion) {
+ FrameView* view = m_webView->page()->mainFrame()->view();
+ IntRect visibleRect = view->visibleContentRect(ScrollableArea::IncludeScrollbars);
+ // |bounds| is in screen coordinates, so make sure to convert it to
+ // content coordinates prior to comparing to |visibleRect|.
+ IntRect screenRect = bounds;
+ screenRect.setLocation(view->screenToContents(bounds.location()));
+ if (!visibleRect.contains(screenRect)) {
+ m_webView->hideAutofillPopup();
+ return;
+ }
+ }
+
+ 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)->initialize(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 OS(DARWIN)
+ // On Mac the mousemove event propagates to both the popup and main window.
+ // If a popup is open we don't want the main window to change the cursor.
+ if (m_webView->hasOpenedPopup())
+ return;
+#endif
+ if (m_webView->client())
+ m_webView->client()->didChangeCursor(cursor);
+}
+
+void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor)
+{
+ setCursor(cursor);
+}
+
+void ChromeClientImpl::formStateDidChange(const Node* node)
+{
+ if (m_webView->client())
+ m_webView->client()->didChangeFormState(WebNode(const_cast<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<WebMenuItemInfo> outputItems(inputItems.size());
+
+ for (size_t i = 0; i < inputItems.size(); ++i) {
+ const PopupItem& inputItem = *inputItems[i];
+ WebMenuItemInfo& outputItem = outputItems[i];
+
+ outputItem.label = inputItem.label;
+ outputItem.enabled = inputItem.enabled;
+ if (inputItem.textDirection == WebCore::RTL)
+ outputItem.textDirection = WebTextDirectionRightToLeft;
+ else
+ outputItem.textDirection = WebTextDirectionLeftToRight;
+ outputItem.hasTextDirectionOverride = inputItem.hasTextDirectionOverride;
+
+ switch (inputItem.type) {
+ case PopupItem::TypeOption:
+ outputItem.type = WebMenuItemInfo::Option;
+ break;
+ case PopupItem::TypeGroup:
+ outputItem.type = WebMenuItemInfo::Group;
+ break;
+ case PopupItem::TypeSeparator:
+ outputItem.type = WebMenuItemInfo::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));
+}
+
+String ChromeClientImpl::acceptLanguages()
+{
+ return m_webView->client()->acceptLanguages();
+}
+
+bool ChromeClientImpl::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
+{
+ Frame* frame = m_webView->mainFrameImpl()->frame();
+ WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame);
+ if (pluginContainer)
+ return pluginContainer->paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
+ return false;
+}
+
+GraphicsLayerFactory* ChromeClientImpl::graphicsLayerFactory() const
+{
+ return m_webView->graphicsLayerFactory();
+}
+
+void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
+{
+ m_webView->setRootGraphicsLayer(graphicsLayer);
+}
+
+void ChromeClientImpl::scheduleCompositingLayerFlush()
+{
+ m_webView->scheduleCompositingLayerSync();
+}
+
+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;
+ if (settings->acceleratedCompositingForScrollableFramesEnabled())
+ flags |= ScrollableInnerFrameTrigger;
+ if (settings->acceleratedCompositingForFiltersEnabled())
+ flags |= FilterTrigger;
+
+ return flags;
+}
+
+void ChromeClientImpl::enterFullScreenForElement(Element* element)
+{
+ m_webView->enterFullScreenForElement(element);
+}
+
+void ChromeClientImpl::exitFullScreenForElement(Element* element)
+{
+ m_webView->exitFullScreenForElement(element);
+}
+
+bool ChromeClientImpl::hasOpenedPopup() const
+{
+ return m_webView->hasOpenedPopup();
+}
+
+PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(Frame& frame, PopupMenuClient* client) const
+{
+ if (WebViewImpl::useExternalPopupMenus())
+ return adoptRef(new ExternalPopupMenu(frame, client, m_webView->client()));
+
+ return adoptRef(new PopupMenuChromium(frame, client));
+}
+
+PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView)
+{
+ ASSERT(m_pagePopupDriver);
+ return m_pagePopupDriver->openPagePopup(client, originBoundsInRootView);
+}
+
+void ChromeClientImpl::closePagePopup(PagePopup* popup)
+{
+ ASSERT(m_pagePopupDriver);
+ m_pagePopupDriver->closePagePopup(popup);
+}
+
+void ChromeClientImpl::setPagePopupDriver(PagePopupDriver* driver)
+{
+ ASSERT(driver);
+ m_pagePopupDriver = driver;
+}
+
+void ChromeClientImpl::resetPagePopupDriver()
+{
+ m_pagePopupDriver = m_webView;
+}
+
+bool ChromeClientImpl::isPasswordGenerationEnabled() const
+{
+ return m_webView->passwordGeneratorClient();
+}
+
+void ChromeClientImpl::openPasswordGenerator(HTMLInputElement* input)
+{
+ ASSERT(isPasswordGenerationEnabled());
+ WebInputElement webInput(input);
+ m_webView->passwordGeneratorClient()->openPasswordGenerator(webInput);
+}
+
+bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType& dialogType, const String& dialogMessage, Document::PageDismissalType dismissalType) const
+{
+ const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"};
+ int dialog = static_cast<int>(dialogType);
+ ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog && dialog < static_cast<int>(arraysize(kDialogs)));
+
+ const char* kDismissals[] = {"beforeunload", "pagehide", "unload"};
+ int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal.
+ ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal && dismissal < static_cast<int>(arraysize(kDismissals)));
+
+ WebKit::Platform::current()->histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arraysize(kDismissals));
+
+ String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessage + "') during " + kDismissals[dismissal] + ".";
+ m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMessage::LevelError, message));
+
+ return false;
+}
+
+bool ChromeClientImpl::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
+{
+ ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown);
+
+ if (!m_webView->client())
+ return false;
+
+ if (direction == WebCore::ScrollLeft)
+ return !m_webView->client()->historyBackListCount();
+ if (direction == WebCore::ScrollRight)
+ return !m_webView->client()->historyForwardListCount();
+
+ ASSERT_NOT_REACHED();
+ return true;
+}
+
+void ChromeClientImpl::numWheelEventHandlersChanged(unsigned numberOfWheelHandlers)
+{
+ m_webView->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
+}
+
+void ChromeClientImpl::needTouchEvents(bool needsTouchEvents)
+{
+ m_webView->hasTouchEventHandlers(needsTouchEvents);
+}
+
+bool ChromeClientImpl::requestPointerLock()
+{
+ return m_webView->requestPointerLock();
+}
+
+void ChromeClientImpl::requestPointerUnlock()
+{
+ return m_webView->requestPointerUnlock();
+}
+
+bool ChromeClientImpl::isPointerLocked()
+{
+ return m_webView->isPointerLocked();
+}
+
+void ChromeClientImpl::annotatedRegionsChanged()
+{
+ WebViewClient* client = m_webView->client();
+ if (client)
+ client->draggableRegionsChanged();
+}
+
+void ChromeClientImpl::didAssociateFormControls(const Vector<RefPtr<Element> >& elements)
+{
+ if (!m_webView->autofillClient())
+ return;
+ WebVector<WebNode> elementVector(static_cast<size_t>(elements.size()));
+ size_t elementsCount = elements.size();
+ for (size_t i = 0; i < elementsCount; ++i)
+ elementVector[i] = elements[i];
+ m_webView->autofillClient()->didAssociateFormControls(elementVector);
+}
+
+#if ENABLE(NAVIGATOR_CONTENT_UTILS)
+PassOwnPtr<NavigatorContentUtilsClientImpl> NavigatorContentUtilsClientImpl::create(WebViewImpl* webView)
+{
+ return adoptPtr(new NavigatorContentUtilsClientImpl(webView));
+}
+
+NavigatorContentUtilsClientImpl::NavigatorContentUtilsClientImpl(WebViewImpl* webView)
+ : m_webView(webView)
+{
+}
+
+void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
+{
+ m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title);
+}
+#endif
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/ChromeClientImpl.h b/chromium/third_party/WebKit/Source/web/ChromeClientImpl.h
new file mode 100644
index 00000000000..639e9d9550b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ChromeClientImpl.h
@@ -0,0 +1,221 @@
+/*
+ * 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 "WebNavigationPolicy.h"
+#include "core/page/ChromeClient.h"
+#include "core/platform/PopupMenu.h"
+#include "modules/navigatorcontentutils/NavigatorContentUtilsClient.h"
+#include "public/platform/WebColor.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebCore {
+class AccessibilityObject;
+class ColorChooser;
+class ColorChooserClient;
+class Element;
+class FileChooser;
+class GraphicsLayerFactory;
+class PopupContainer;
+class PopupMenuClient;
+class RenderBox;
+class SecurityOrigin;
+class DateTimeChooser;
+class DateTimeChooserClient;
+struct WindowFeatures;
+}
+
+namespace WebKit {
+class WebColorChooser;
+class WebColorChooserClient;
+class WebViewImpl;
+struct WebCursorInfo;
+struct WebPopupMenuInfo;
+
+// Handles window-level notifications from WebCore on behalf of a WebView.
+class ChromeClientImpl : public WebCore::ChromeClient {
+public:
+ explicit ChromeClientImpl(WebViewImpl* webView);
+ virtual ~ChromeClientImpl();
+
+ virtual void* webView() const;
+
+ // ChromeClient methods:
+ virtual void chromeDestroyed();
+ virtual void setWindowRect(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect windowRect();
+ virtual WebCore::FloatRect pageRect();
+ virtual void focus();
+ virtual void unfocus();
+ virtual bool canTakeFocus(WebCore::FocusDirection);
+ virtual void takeFocus(WebCore::FocusDirection);
+ virtual void focusedNodeChanged(WebCore::Node*);
+ virtual WebCore::Page* createWindow(
+ WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&, WebCore::NavigationPolicy);
+ virtual void show(WebCore::NavigationPolicy);
+ 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::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 tabsToLinks();
+ virtual WebCore::IntRect windowResizerRect() const;
+ virtual void invalidateContentsAndRootView(const WebCore::IntRect&);
+ virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&);
+ virtual void scheduleAnimation();
+ virtual void scroll(
+ const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
+ const WebCore::IntRect& clipRect);
+ virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const;
+ virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const;
+ virtual WebScreenInfo screenInfo() const;
+ virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
+ virtual void deviceOrPageScaleFactorChanged() const;
+ virtual void didProgrammaticallyScroll(WebCore::Frame*, const WebCore::IntPoint&) const;
+ virtual void layoutUpdated(WebCore::Frame*) const;
+ virtual void mouseDidMoveOverElement(
+ const WebCore::HitTestResult& result, unsigned modifierFlags);
+ virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection);
+ virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const;
+ virtual void print(WebCore::Frame*);
+ virtual void annotatedRegionsChanged();
+ virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
+ virtual PassOwnPtr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) OVERRIDE;
+ PassOwnPtr<WebColorChooser> createWebColorChooser(WebColorChooserClient*, const WebColor&);
+ virtual PassRefPtr<WebCore::DateTimeChooser> openDateTimeChooser(WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&) OVERRIDE;
+ virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
+ virtual void enumerateChosenDirectory(WebCore::FileChooser*);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void formStateDidChange(const WebCore::Node*);
+ virtual void needTouchEvents(bool needTouchEvents) OVERRIDE;
+
+ virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE;
+
+ // Pass 0 as the GraphicsLayer to detatch the root layer.
+ virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
+
+ // 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 scheduleCompositingLayerFlush();
+
+ virtual CompositingTriggerFlags allowedCompositingTriggers() const;
+
+ virtual void enterFullScreenForElement(WebCore::Element*);
+ virtual void exitFullScreenForElement(WebCore::Element*);
+
+ // ChromeClient 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);
+ virtual String acceptLanguages() OVERRIDE;
+
+ // ChromeClientImpl:
+ void setCursorForPlugin(const WebCursorInfo&);
+ void setNewWindowNavigationPolicy(WebNavigationPolicy);
+
+ virtual bool hasOpenedPopup() const OVERRIDE;
+ virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::Frame&, WebCore::PopupMenuClient*) const;
+ virtual WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect&) OVERRIDE;
+ virtual void closePagePopup(WebCore::PagePopup*) OVERRIDE;
+ virtual void setPagePopupDriver(WebCore::PagePopupDriver*) OVERRIDE;
+ virtual void resetPagePopupDriver() OVERRIDE;
+
+ virtual bool isPasswordGenerationEnabled() const OVERRIDE;
+ virtual void openPasswordGenerator(WebCore::HTMLInputElement*) OVERRIDE;
+
+ virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::Document::PageDismissalType) const;
+
+ virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const;
+ virtual void numWheelEventHandlersChanged(unsigned);
+
+ virtual bool requestPointerLock();
+ virtual void requestPointerUnlock();
+ virtual bool isPointerLocked();
+
+ virtual void didAssociateFormControls(const Vector<RefPtr<WebCore::Element> >&) OVERRIDE;
+
+private:
+ WebNavigationPolicy getNavigationPolicy();
+ 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;
+
+ WebCore::PagePopupDriver* m_pagePopupDriver;
+};
+
+#if ENABLE(NAVIGATOR_CONTENT_UTILS)
+class NavigatorContentUtilsClientImpl : public WebCore::NavigatorContentUtilsClient {
+public:
+ static PassOwnPtr<NavigatorContentUtilsClientImpl> create(WebViewImpl*);
+ ~NavigatorContentUtilsClientImpl() { }
+
+ virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) OVERRIDE;
+
+private:
+ explicit NavigatorContentUtilsClientImpl(WebViewImpl*);
+
+ WebViewImpl* m_webView;
+};
+#endif
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.cpp b/chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.cpp
new file mode 100644
index 00000000000..ed2ad855a02
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "ColorChooserPopupUIController.h"
+
+#include "ChromeClientImpl.h"
+#include "ColorSuggestionPicker.h"
+#include "PickerCommon.h"
+#include "WebColorChooser.h"
+#include "WebViewImpl.h"
+#include "core/page/FrameView.h"
+#include "core/platform/ColorChooserClient.h"
+#include "core/platform/LocalizedStrings.h"
+#include "core/platform/graphics/IntRect.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebLocalizedString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Keep in sync with Actions in colorSuggestionPicker.js.
+enum ColorPickerPopupAction {
+ ColorPickerPopupActionChooseOtherColor = -2,
+ ColorPickerPopupActionCancel = -1,
+ ColorPickerPopupActionSetValue = 0
+};
+
+ColorChooserPopupUIController::ColorChooserPopupUIController(ChromeClientImpl* chromeClient, ColorChooserClient* client)
+ : ColorChooserUIController(chromeClient, client)
+ , m_chromeClient(chromeClient)
+ , m_client(client)
+ , m_popup(0)
+ , m_locale(Locale::createDefault())
+{
+}
+
+ColorChooserPopupUIController::~ColorChooserPopupUIController()
+{
+}
+
+void ColorChooserPopupUIController::openUI()
+{
+ if (m_client->shouldShowSuggestions())
+ openPopup();
+ else
+ openColorChooser();
+}
+
+void ColorChooserPopupUIController::endChooser()
+{
+ if (m_chooser)
+ m_chooser->endChooser();
+ if (m_popup)
+ closePopup();
+}
+
+IntSize ColorChooserPopupUIController::contentSize()
+{
+ return IntSize(0, 0);
+}
+
+void ColorChooserPopupUIController::writeDocument(DocumentWriter& writer)
+{
+ Vector<Color> suggestions = m_client->suggestions();
+ Vector<String> suggestionValues;
+ for (unsigned i = 0; i < suggestions.size(); i++)
+ suggestionValues.append(suggestions[i].serialized());
+ IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_client->elementRectRelativeToRootView());
+
+ PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer);
+ writer.addData(pickerCommonCss, sizeof(pickerCommonCss));
+ writer.addData(colorSuggestionPickerCss, sizeof(colorSuggestionPickerCss));
+ PagePopupClient::addString("</style></head><body><div id=main>Loading...</div><script>\n"
+ "window.dialogArguments = {\n", writer);
+ PagePopupClient::addProperty("values", suggestionValues, writer);
+ PagePopupClient::addProperty("otherColorLabel", Platform::current()->queryLocalizedString(WebLocalizedString::OtherColorLabel), writer);
+ addProperty("anchorRectInScreen", anchorRectInScreen, writer);
+ PagePopupClient::addString("};\n", writer);
+ writer.addData(pickerCommonJs, sizeof(pickerCommonJs));
+ writer.addData(colorSuggestionPickerJs, sizeof(colorSuggestionPickerJs));
+ PagePopupClient::addString("</script></body>\n", writer);
+}
+
+Locale& ColorChooserPopupUIController::locale()
+{
+ return *m_locale;
+}
+
+void ColorChooserPopupUIController::setValueAndClosePopup(int numValue, const String& stringValue)
+{
+ ASSERT(m_popup);
+ ASSERT(m_client);
+ if (numValue == ColorPickerPopupActionSetValue)
+ m_client->didChooseColor(StyleColor(stringValue).color());
+ if (numValue == ColorPickerPopupActionChooseOtherColor)
+ openColorChooser();
+ closePopup();
+}
+
+void ColorChooserPopupUIController::setValue(const String& value)
+{
+ ASSERT(m_client);
+ m_client->didChooseColor(StyleColor(value).color());
+}
+
+void ColorChooserPopupUIController::didClosePopup()
+{
+ m_popup = 0;
+
+ if (!m_chooser)
+ didEndChooser();
+}
+
+
+void ColorChooserPopupUIController::openPopup()
+{
+ ASSERT(!m_popup);
+ m_popup = m_chromeClient->openPagePopup(this, m_client->elementRectRelativeToRootView());
+}
+
+void ColorChooserPopupUIController::closePopup()
+{
+ if (!m_popup)
+ return;
+ m_chromeClient->closePagePopup(m_popup);
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.h b/chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.h
new file mode 100644
index 00000000000..18a8fca7599
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ColorChooserPopupUIController.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 ColorChooserPopupUIController_h
+#define ColorChooserPopupUIController_h
+
+#include "ColorChooserUIController.h"
+#include "core/page/PagePopupClient.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebCore {
+class ColorChooserClient;
+class PagePopup;
+}
+
+namespace WebKit {
+
+class ColorChooserPopupUIController : public ColorChooserUIController, public WebCore::PagePopupClient {
+
+public:
+ ColorChooserPopupUIController(ChromeClientImpl*, WebCore::ColorChooserClient*);
+ virtual ~ColorChooserPopupUIController();
+
+ // ColorChooserUIController functions:
+ virtual void openUI() OVERRIDE;
+
+ // ColorChooser functions
+ void endChooser() OVERRIDE;
+
+ // PagePopupClient functions:
+ virtual WebCore::IntSize contentSize() OVERRIDE;
+ virtual void writeDocument(WebCore::DocumentWriter&) OVERRIDE;
+ virtual WebCore::Locale& locale() OVERRIDE;
+ virtual void setValueAndClosePopup(int, const String&) OVERRIDE;
+ virtual void setValue(const String&) OVERRIDE;
+ virtual void closePopup() OVERRIDE;
+ virtual void didClosePopup() OVERRIDE;
+
+private:
+ void openPopup();
+
+ ChromeClientImpl* m_chromeClient;
+ WebCore::ColorChooserClient* m_client;
+ WebCore::PagePopup* m_popup;
+ OwnPtr<WebCore::Locale> m_locale;
+};
+}
+
+#endif // ColorChooserPopupUIController_h
diff --git a/chromium/third_party/WebKit/Source/web/ColorChooserUIController.cpp b/chromium/third_party/WebKit/Source/web/ColorChooserUIController.cpp
new file mode 100644
index 00000000000..125d2e6808d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ColorChooserUIController.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "ColorChooserUIController.h"
+
+#include "ChromeClientImpl.h"
+#include "WebColorChooser.h"
+#include "core/platform/ColorChooserClient.h"
+#include "core/platform/graphics/Color.h"
+#include "public/platform/WebColor.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+
+ColorChooserUIController::ColorChooserUIController(ChromeClientImpl* chromeClient, ColorChooserClient* client)
+ : m_chromeClient(chromeClient)
+ , m_client(client)
+{
+}
+
+ColorChooserUIController::~ColorChooserUIController()
+{
+}
+
+void ColorChooserUIController::openUI()
+{
+ openColorChooser();
+}
+
+void ColorChooserUIController::setSelectedColor(const Color& color)
+{
+ ASSERT(m_chooser);
+ m_chooser->setSelectedColor(static_cast<WebColor>(color.rgb()));
+}
+
+void ColorChooserUIController::endChooser()
+{
+ if (m_chooser)
+ m_chooser->endChooser();
+}
+
+void ColorChooserUIController::didChooseColor(const WebColor& color)
+{
+ ASSERT(m_client);
+ m_client->didChooseColor(Color(static_cast<RGBA32>(color)));
+}
+
+void ColorChooserUIController::didEndChooser()
+{
+ ASSERT(m_client);
+ m_chooser = nullptr;
+ m_client->didEndChooser();
+}
+
+void ColorChooserUIController::openColorChooser()
+{
+ ASSERT(!m_chooser);
+ m_chooser = m_chromeClient->createWebColorChooser(this, static_cast<WebColor>(m_client->currentColor().rgb()));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/ColorChooserUIController.h b/chromium/third_party/WebKit/Source/web/ColorChooserUIController.h
new file mode 100644
index 00000000000..7b4761cfd0c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ColorChooserUIController.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 ColorChooserUIController_h
+#define ColorChooserUIController_h
+
+#include "WebColorChooserClient.h"
+#include "core/platform/ColorChooser.h"
+#include "core/platform/text/PlatformLocale.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebCore {
+class ColorChooserClient;
+}
+
+namespace WebKit {
+
+class ChromeClientImpl;
+class WebColorChooser;
+
+class ColorChooserUIController : public WebColorChooserClient, public WebCore::ColorChooser {
+public:
+ ColorChooserUIController(ChromeClientImpl*, WebCore::ColorChooserClient*);
+ virtual ~ColorChooserUIController();
+
+ virtual void openUI();
+
+ // ColorChooser functions:
+ virtual void setSelectedColor(const WebCore::Color&) OVERRIDE;
+ virtual void endChooser() OVERRIDE;
+
+ // WebColorChooserClient functions:
+ virtual void didChooseColor(const WebColor&) OVERRIDE;
+ virtual void didEndChooser() OVERRIDE;
+
+protected:
+ void openColorChooser();
+ OwnPtr<WebColorChooser> m_chooser;
+
+private:
+
+ ChromeClientImpl* m_chromeClient;
+ WebCore::ColorChooserClient* m_client;
+};
+
+}
+
+#endif // ColorChooserUIController_h
diff --git a/chromium/third_party/WebKit/Source/web/CompositionUnderlineBuilder.h b/chromium/third_party/WebKit/Source/web/CompositionUnderlineBuilder.h
new file mode 100644
index 00000000000..6ed745547bb
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebCompositionUnderline.h"
+#include "core/editing/CompositionUnderline.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Vector.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/chromium/third_party/WebKit/Source/web/CompositionUnderlineVectorBuilder.cpp b/chromium/third_party/WebKit/Source/web/CompositionUnderlineVectorBuilder.cpp
new file mode 100644
index 00000000000..55dca85afc3
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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/chromium/third_party/WebKit/Source/web/CompositionUnderlineVectorBuilder.h b/chromium/third_party/WebKit/Source/web/CompositionUnderlineVectorBuilder.h
new file mode 100644
index 00000000000..7a6c8ae1fcc
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebCompositionUnderline.h"
+#include "core/editing/CompositionUnderline.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Vector.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/chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.cpp b/chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.cpp
new file mode 100644
index 00000000000..4fc801b7a7b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "ContextFeaturesClientImpl.h"
+
+#include "WebDocument.h"
+#include "WebPermissionClient.h"
+#include "core/dom/Document.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class ContextFeaturesCache : public Supplement<ScriptExecutionContext> {
+public:
+ class Entry {
+ public:
+ enum Value {
+ IsEnabled,
+ IsDisabled,
+ NeedsRefresh
+ };
+
+ Entry()
+ : m_value(NeedsRefresh)
+ , m_defaultValue(false)
+ { }
+
+ bool isEnabled() const
+ {
+ ASSERT(m_value != NeedsRefresh);
+ return m_value == IsEnabled;
+ }
+
+ void set(bool value, bool defaultValue)
+ {
+ m_value = value ? IsEnabled : IsDisabled;
+ m_defaultValue = defaultValue;
+ }
+
+ bool needsRefresh(bool defaultValue) const
+ {
+ return m_value == NeedsRefresh || m_defaultValue != defaultValue;
+ }
+
+ private:
+ Value m_value;
+ bool m_defaultValue; // Needs to be traked as a part of the signature since it can be changed dynamically.
+ };
+
+ static const char* supplementName();
+ static ContextFeaturesCache* from(Document*);
+
+ Entry& entryFor(ContextFeatures::FeatureType type)
+ {
+ size_t index = static_cast<size_t>(type);
+ ASSERT_WITH_SECURITY_IMPLICATION(index < ContextFeatures::FeatureTypeSize);
+ return m_entries[index];
+ }
+
+ void validateAgainst(Document*);
+
+private:
+ String m_domain;
+ Entry m_entries[ContextFeatures::FeatureTypeSize];
+};
+
+const char* ContextFeaturesCache::supplementName()
+{
+ return "ContextFeaturesCache";
+}
+
+ContextFeaturesCache* ContextFeaturesCache::from(Document* document)
+{
+ ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(Supplement<ScriptExecutionContext>::from(document, supplementName()));
+ if (!cache) {
+ cache = new ContextFeaturesCache();
+ Supplement<ScriptExecutionContext>::provideTo(document, supplementName(), adoptPtr(cache));
+ }
+
+ return cache;
+}
+
+void ContextFeaturesCache::validateAgainst(Document* document)
+{
+ String currentDomain = document->securityOrigin()->domain();
+ if (currentDomain == m_domain)
+ return;
+ m_domain = currentDomain;
+ for (size_t i = 0; i < ContextFeatures::FeatureTypeSize; ++i)
+ m_entries[i] = Entry();
+}
+
+bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue)
+{
+ ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(document)->entryFor(type);
+ if (cache.needsRefresh(defaultValue))
+ cache.set(askIfIsEnabled(document, type, defaultValue), defaultValue);
+ return cache.isEnabled();
+}
+
+void ContextFeaturesClientImpl::urlDidChange(Document* document)
+{
+ ContextFeaturesCache::from(document)->validateAgainst(document);
+}
+
+bool ContextFeaturesClientImpl::askIfIsEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue)
+{
+ if (!m_client)
+ return defaultValue;
+
+ switch (type) {
+ case ContextFeatures::StyleScoped:
+ return m_client->allowWebComponents(WebDocument(document), defaultValue);
+ case ContextFeatures::MutationEvents:
+ return m_client->allowMutationEvents(WebDocument(document), defaultValue);
+ case ContextFeatures::PushState:
+ return m_client->allowPushState(WebDocument(document));
+ default:
+ return defaultValue;
+ }
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.h b/chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.h
new file mode 100644
index 00000000000..626984e87bf
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ContextFeaturesClientImpl.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 ContextFeaturesClientImpl_h
+#define ContextFeaturesClientImpl_h
+
+#include "core/dom/ContextFeatures.h"
+
+namespace WebKit {
+
+class WebPermissionClient;
+
+class ContextFeaturesClientImpl : public WebCore::ContextFeaturesClient {
+public:
+ ContextFeaturesClientImpl()
+ : m_client(0)
+ { }
+
+ virtual bool isEnabled(WebCore::Document*, WebCore::ContextFeatures::FeatureType, bool defaultValue) OVERRIDE;
+ virtual void urlDidChange(WebCore::Document*) OVERRIDE;
+ void setPermissionClient(WebPermissionClient* client) { m_client = client; }
+
+private:
+ bool askIfIsEnabled(WebCore::Document*, WebCore::ContextFeatures::FeatureType, bool defaultValue);
+
+ WebPermissionClient* m_client;
+};
+
+} // namespace WebKit
+
+#endif // ContextFeaturesClientImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp b/chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
new file mode 100644
index 00000000000..c8f36925cf7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
@@ -0,0 +1,419 @@
+/*
+ * Copyright (C) 2009, 2012 Google Inc. 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 "HTMLNames.h"
+#include "WebContextMenuData.h"
+#include "WebDataSourceImpl.h"
+#include "WebFormElement.h"
+#include "WebFrameImpl.h"
+#include "WebMenuItemInfo.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebSearchableFormData.h"
+#include "WebSpellCheckClient.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "core/css/CSSStyleDeclaration.h"
+#include "core/dom/Document.h"
+#include "core/dom/DocumentMarkerController.h"
+#include "core/editing/Editor.h"
+#include "core/history/HistoryItem.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLMediaElement.h"
+#include "core/html/HTMLPlugInImageElement.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/html/MediaError.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoader.h"
+#include "core/page/ContextMenuController.h"
+#include "core/page/EventHandler.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/ContextMenu.h"
+#include "core/platform/Widget.h"
+#include "core/platform/text/TextBreakIterator.h"
+#include "core/rendering/HitTestResult.h"
+#include "core/rendering/RenderWidget.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLResponse.h"
+#include "public/platform/WebVector.h"
+#include "weborigin/KURL.h"
+#include "wtf/text/WTFString.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, 0, text.length());
+ return it && textBreakNext(it) == static_cast<int>(text.length());
+}
+
+// Helper function to get misspelled word on which context menu
+// is to be invoked. This function also sets the word on which context menu
+// has been invoked 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(Frame* selectedFrame)
+{
+ // First select from selectedText to check for multiple word selection.
+ String misspelledWord = selectedFrame->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().pointInInnerNodeFrame());
+ 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->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;
+}
+
+static bool IsWhiteSpaceOrPunctuation(UChar c)
+{
+ return isSpaceOrNewline(c) || WTF::Unicode::isPunct(c);
+}
+
+static String selectMisspellingAsync(Frame* selectedFrame, DocumentMarker& marker)
+{
+ VisibleSelection selection = selectedFrame->selection()->selection();
+ if (!selection.isCaretOrRange())
+ return String();
+
+ // Caret and range selections always return valid normalized ranges.
+ RefPtr<Range> selectionRange = selection.toNormalizedRange();
+ Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(selectionRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
+ if (markers.size() != 1)
+ return String();
+ marker = *markers[0];
+
+ // Cloning a range fails only for invalid ranges.
+ RefPtr<Range> markerRange = selectionRange->cloneRange(ASSERT_NO_EXCEPTION);
+ markerRange->setStart(markerRange->startContainer(), marker.startOffset());
+ markerRange->setEnd(markerRange->endContainer(), marker.endOffset());
+
+ if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selectionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation))
+ return String();
+
+ return markerRange->text();
+}
+
+void ContextMenuClientImpl::showContextMenu(const WebCore::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;
+
+ HitTestResult r = m_webView->page()->contextMenuController().hitTestResult();
+ Frame* selectedFrame = r.innerNodeFrame();
+
+ WebContextMenuData data;
+ data.mousePosition = selectedFrame->view()->contentsToWindow(r.roundedPointInInnerNodeFrame());
+
+ // 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;
+ data.mediaFlags |= WebContextMenuData::MediaCanPrint;
+ } 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 =
+ toMediaElement(r.innerNonSharedNode());
+ if (isHTMLVideoElement(mediaElement))
+ 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 = toHTMLPlugInImageElement(r.innerNonSharedNode());
+ data.srcURL = pluginElement->document()->completeURL(pluginElement->url());
+ data.mediaFlags |= WebContextMenuData::MediaCanSave;
+
+ // Add context menu commands that are supported by the plugin.
+ if (plugin->plugin()->canRotateView())
+ data.mediaFlags |= WebContextMenuData::MediaCanRotate;
+ }
+ }
+ }
+
+ 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.
+ if (selectedFrame->document()->loader())
+ data.frameEncoding = selectedFrame->document()->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);
+ RefPtr<HistoryItem> historyItem = selectedFrame->loader()->history()->currentItem();
+ if (historyItem)
+ data.frameHistoryItem = WebHistoryItem(historyItem);
+ }
+
+ if (r.isSelected()) {
+ if (!r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag) || !toHTMLInputElement(r.innerNonSharedNode())->isPasswordField())
+ data.selectedText = selectedFrame->selectedText().stripWhiteSpace();
+ }
+
+ if (r.isContentEditable()) {
+ data.isEditable = true;
+#if ENABLE(INPUT_SPEECH)
+ if (r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag))
+ data.isSpeechInputEnabled = toHTMLInputElement(r.innerNonSharedNode())->isSpeechEnabled();
+#endif
+ // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled
+ // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks
+ // a mouse on a word, Chrome just needs to find a spelling marker on the word instead of spellchecking it.
+ if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
+ DocumentMarker marker;
+ data.misspelledWord = selectMisspellingAsync(selectedFrame, marker);
+ data.misspellingHash = marker.hash();
+ if (marker.description().length()) {
+ Vector<String> suggestions;
+ marker.description().split('\n', suggestions);
+ data.dictionarySuggestions = suggestions;
+ } else if (m_webView->spellCheckClient()) {
+ int misspelledOffset, misspelledLength;
+ m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
+ }
+ } else {
+ data.isSpellCheckingEnabled =
+ m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled();
+ // Spellchecking might be enabled for the field, but could be disabled on the node.
+ if (m_webView->focusedWebCoreFrame()->editor()->isSpellCheckingEnabledInFocusedNode()) {
+ data.misspelledWord = selectMisspelledWord(selectedFrame);
+ if (m_webView->spellCheckClient()) {
+ int misspelledOffset, misspelledLength;
+ m_webView->spellCheckClient()->spellCheck(
+ data.misspelledWord, misspelledOffset, misspelledLength,
+ &data.dictionarySuggestions);
+ if (!misspelledLength)
+ data.misspelledWord.reset();
+ }
+ }
+ }
+ HTMLFormElement* form = selectedFrame->selection()->currentForm();
+ if (form && r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) {
+ HTMLInputElement* selectedElement = toHTMLInputElement(r.innerNonSharedNode());
+ if (selectedElement) {
+ WebSearchableFormData ws = WebSearchableFormData(WebFormElement(form), WebInputElement(selectedElement));
+ if (ws.url().isValid())
+ data.keywordURL = ws.url();
+ }
+ }
+ }
+
+#if OS(DARWIN)
+ if (selectedFrame->editor()->selectionHasStyle(CSSPropertyDirection, "ltr") != FalseTriState)
+ data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuItemChecked;
+ if (selectedFrame->editor()->selectionHasStyle(CSSPropertyDirection, "rtl") != 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();
+
+ data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document()->referrerPolicy());
+
+ // 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);
+}
+
+void ContextMenuClientImpl::clearContextMenu()
+{
+ if (m_webView->client())
+ m_webView->client()->clearContextMenu();
+}
+
+static void populateSubMenuItems(const Vector<ContextMenuItem>& inputMenu, WebVector<WebMenuItemInfo>& subMenuItems)
+{
+ Vector<WebMenuItemInfo> subItems;
+ for (size_t i = 0; i < inputMenu.size(); ++i) {
+ const ContextMenuItem* inputItem = &inputMenu.at(i);
+ 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::SubMenu;
+ populateSubMenuItems(inputItem->subMenuItems(), outputItem.subMenuItems);
+ break;
+ }
+ subItems.append(outputItem);
+ }
+
+ WebVector<WebMenuItemInfo> outputItems(subItems.size());
+ for (size_t i = 0; i < subItems.size(); ++i)
+ outputItems[i] = subItems[i];
+ subMenuItems.swap(outputItems);
+}
+
+void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
+{
+ populateSubMenuItems(defaultMenu->items(), data->customItems);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.h b/chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.h
new file mode 100644
index 00000000000..5b0875c064a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ContextMenuClientImpl.h
@@ -0,0 +1,54 @@
+/*
+ * 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 "core/page/ContextMenuClient.h"
+
+namespace WebKit {
+
+class WebViewImpl;
+struct WebContextMenuData;
+
+class ContextMenuClientImpl : public WebCore::ContextMenuClient {
+public:
+ ContextMenuClientImpl(WebViewImpl* webView) : m_webView(webView) {}
+ virtual ~ContextMenuClientImpl() {}
+ virtual void showContextMenu(const WebCore::ContextMenu*);
+ virtual void clearContextMenu();
+private:
+ void populateCustomMenuItems(const WebCore::ContextMenu*, WebContextMenuData*);
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif // ContextMenuClientImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/DEPS b/chromium/third_party/WebKit/Source/web/DEPS
new file mode 100644
index 00000000000..b1ad93e2275
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DEPS
@@ -0,0 +1,12 @@
+include_rules = [
+ "+..",
+ "+bindings",
+ "+core",
+ "+modules",
+ "+painting",
+ "+public",
+ "+public/platform",
+ "+skia",
+ "+third_party/skia",
+ "+weborigin",
+]
diff --git a/chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp b/chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp
new file mode 100644
index 00000000000..3c8c112417d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "DOMUtilitiesPrivate.h"
+
+#include "HTMLNames.h"
+#include "core/dom/Element.h"
+#include "core/html/HTMLAreaElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLTableElement.h"
+
+using namespace WebCore;
+using namespace WebCore::HTMLNames;
+
+namespace WebKit {
+
+bool elementHasLegalLinkAttribute(const Element* element, const QualifiedName& attrName)
+{
+ if (attrName == srcAttr)
+ return element->hasTagName(imgTag) || element->hasTagName(scriptTag) || element->hasTagName(iframeTag) || element->hasTagName(frameTag) || (element->hasTagName(inputTag) && toHTMLInputElement(element)->isImageButton());
+ if (attrName == hrefAttr)
+ return element->hasTagName(linkTag) || isHTMLAnchorElement(element) || isHTMLAreaElement(element);
+ if (attrName == actionAttr)
+ return element->hasTagName(formTag);
+ if (attrName == backgroundAttr)
+ return element->hasTagName(bodyTag) || isHTMLTableElement(element) || element->hasTagName(trTag) || element->hasTagName(tdTag);
+ if (attrName == citeAttr)
+ return element->hasTagName(blockquoteTag) || element->hasTagName(qTag) || element->hasTagName(delTag) || element->hasTagName(insTag);
+ if (attrName == classidAttr || attrName == dataAttr)
+ return element->hasTagName(objectTag);
+ if (attrName == codebaseAttr)
+ return element->hasTagName(objectTag) || element->hasTagName(appletTag);
+ return false;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.h b/chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.h
new file mode 100644
index 00000000000..86f4a110d65
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DOMUtilitiesPrivate.h
@@ -0,0 +1,54 @@
+/*
+ * 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 QualifiedName;
+}
+
+// This file is an aggregate of useful WebCore operations.
+namespace WebKit {
+
+// 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/chromium/third_party/WebKit/Source/web/DatabaseObserver.cpp b/chromium/third_party/WebKit/Source/web/DatabaseObserver.cpp
new file mode 100644
index 00000000000..d1d4aa5aa0a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DatabaseObserver.cpp
@@ -0,0 +1,205 @@
+/*
+ * 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 "modules/webdatabase/DatabaseObserver.h"
+
+#include "WebCommonWorkerClient.h"
+#include "WebDatabase.h"
+#include "WebDatabaseObserver.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebPermissionClient.h"
+#include "WebSecurityOrigin.h"
+#include "WebViewImpl.h"
+#include "WebWorkerBase.h"
+#include "WorkerAllowMainThreadBridgeBase.h"
+#include "bindings/v8/WorkerScriptController.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/dom/Document.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/platform/CrossThreadCopier.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "modules/webdatabase/DatabaseBackendBase.h"
+#include "modules/webdatabase/DatabaseBackendContext.h"
+
+using namespace WebKit;
+
+namespace {
+
+static const char allowDatabaseMode[] = "allowDatabaseMode";
+
+// This class is used to route the result of the WebWorkerBase::allowDatabase
+// call back to the worker context.
+class AllowDatabaseMainThreadBridge : public WorkerAllowMainThreadBridgeBase {
+public:
+ static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
+ {
+ return adoptRef(new AllowDatabaseMainThreadBridge(workerGlobalScope, webWorkerBase, mode, frame, name, displayName, estimatedSize));
+ }
+
+private:
+ class AllowDatabaseParams : public AllowParams
+ {
+ public:
+ AllowDatabaseParams(const String& mode, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
+ : AllowParams(mode)
+ , m_frame(WebCore::AllowCrossThreadAccess(frame))
+ , m_name(name.isolatedCopy())
+ , m_displayName(displayName.isolatedCopy())
+ , m_estimatedSize(estimatedSize)
+ {
+ }
+ WebCore::AllowCrossThreadAccessWrapper<WebFrame> m_frame;
+ String m_name;
+ String m_displayName;
+ unsigned long m_estimatedSize;
+ };
+
+ AllowDatabaseMainThreadBridge(WebCore::WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
+ : WorkerAllowMainThreadBridgeBase(workerGlobalScope, webWorkerBase)
+ {
+ postTaskToMainThread(
+ adoptPtr(new AllowDatabaseParams(mode, frame, name, displayName, estimatedSize)));
+ }
+
+ virtual bool allowOnMainThread(WebCommonWorkerClient* commonClient, AllowParams* params)
+ {
+ ASSERT(isMainThread());
+ AllowDatabaseParams* allowDBParams = static_cast<AllowDatabaseParams*>(params);
+ return commonClient->allowDatabase(
+ allowDBParams->m_frame.value(), allowDBParams->m_name, allowDBParams->m_displayName, allowDBParams->m_estimatedSize);
+ }
+};
+
+bool allowDatabaseForWorker(WebFrame* frame, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
+{
+ WebCore::WorkerScriptController* controller = WebCore::WorkerScriptController::controllerForContext();
+ WebCore::WorkerGlobalScope* workerGlobalScope = controller->workerGlobalScope();
+ WebCore::WorkerThread* workerThread = workerGlobalScope->thread();
+ WebCore::WorkerRunLoop& runLoop = workerThread->runLoop();
+ WebCore::WorkerLoaderProxy* workerLoaderProxy = &workerThread->workerLoaderProxy();
+
+ // Create a unique mode just for this synchronous call.
+ String mode = allowDatabaseMode;
+ mode.append(String::number(runLoop.createUniqueId()));
+
+ RefPtr<AllowDatabaseMainThreadBridge> bridge = AllowDatabaseMainThreadBridge::create(workerGlobalScope, workerLoaderProxy->toWebWorkerBase(), mode, frame, name, displayName, estimatedSize);
+
+ // Either the bridge returns, or the queue gets terminated.
+ if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated) {
+ bridge->cancel();
+ return false;
+ }
+
+ return bridge->result();
+}
+
+}
+
+namespace WebCore {
+
+bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize)
+{
+ ASSERT(scriptExecutionContext->isContextThread());
+ ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerGlobalScope());
+ if (scriptExecutionContext->isDocument()) {
+ Document* document = toDocument(scriptExecutionContext);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ if (!webFrame)
+ return false;
+ WebViewImpl* webView = webFrame->viewImpl();
+ if (!webView)
+ return false;
+ if (webView->permissionClient())
+ return webView->permissionClient()->allowDatabase(webFrame, name, displayName, estimatedSize);
+ } else {
+ WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(scriptExecutionContext);
+ WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase());
+ WebView* view = webWorker->view();
+ if (!view)
+ return false;
+ return allowDatabaseForWorker(view->mainFrame(), name, displayName, estimatedSize);
+ }
+
+ return true;
+}
+
+void DatabaseObserver::databaseOpened(DatabaseBackendBase* database)
+{
+ ASSERT(database->databaseContext()->scriptExecutionContext()->isContextThread());
+ WebDatabase::observer()->databaseOpened(WebDatabase(database));
+}
+
+void DatabaseObserver::databaseModified(DatabaseBackendBase* database)
+{
+ ASSERT(database->databaseContext()->scriptExecutionContext()->isContextThread());
+ WebDatabase::observer()->databaseModified(WebDatabase(database));
+}
+
+void DatabaseObserver::databaseClosed(DatabaseBackendBase* database)
+{
+ ASSERT(database->databaseContext()->scriptExecutionContext()->isContextThread());
+ WebDatabase::observer()->databaseClosed(WebDatabase(database));
+}
+
+void DatabaseObserver::reportOpenDatabaseResult(DatabaseBackendBase* database, int errorSite, int webSqlErrorCode, int sqliteErrorCode)
+{
+ WebDatabase::observer()->reportOpenDatabaseResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode);
+}
+
+void DatabaseObserver::reportChangeVersionResult(DatabaseBackendBase* database, int errorSite, int webSqlErrorCode, int sqliteErrorCode)
+{
+ WebDatabase::observer()->reportChangeVersionResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode);
+}
+
+void DatabaseObserver::reportStartTransactionResult(DatabaseBackendBase* database, int errorSite, int webSqlErrorCode, int sqliteErrorCode)
+{
+ WebDatabase::observer()->reportStartTransactionResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode);
+}
+
+void DatabaseObserver::reportCommitTransactionResult(DatabaseBackendBase* database, int errorSite, int webSqlErrorCode, int sqliteErrorCode)
+{
+ WebDatabase::observer()->reportCommitTransactionResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode);
+}
+
+void DatabaseObserver::reportExecuteStatementResult(DatabaseBackendBase* database, int errorSite, int webSqlErrorCode, int sqliteErrorCode)
+{
+ WebDatabase::observer()->reportExecuteStatementResult(WebDatabase(database), errorSite, webSqlErrorCode, sqliteErrorCode);
+}
+
+void DatabaseObserver::reportVacuumDatabaseResult(DatabaseBackendBase* database, int sqliteErrorCode)
+{
+ WebDatabase::observer()->reportVacuumDatabaseResult(WebDatabase(database), sqliteErrorCode);
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.cpp b/chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.cpp
new file mode 100644
index 00000000000..095580701cd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.cpp
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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(INPUT_MULTIPLE_FIELDS_UI)
+#include "DateTimeChooserImpl.h"
+
+#include "CalendarPicker.h"
+#include "ChromeClientImpl.h"
+#include "PickerCommon.h"
+#include "WebViewImpl.h"
+#include "core/html/InputTypeNames.h"
+#include "core/page/FrameView.h"
+#include "core/platform/DateComponents.h"
+#include "core/platform/DateTimeChooserClient.h"
+#include "core/platform/Language.h"
+#include "core/platform/NotImplemented.h"
+#include "core/platform/text/PlatformLocale.h"
+#include "core/rendering/RenderTheme.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebLocalizedString.h"
+
+#if !ENABLE(CALENDAR_PICKER)
+#error "ENABLE_INPUT_MULTIPLE_FIELDS_UI requires ENABLE_CALENDAR_PICKER in Chromium."
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DateTimeChooserImpl::DateTimeChooserImpl(ChromeClientImpl* chromeClient, WebCore::DateTimeChooserClient* client, const WebCore::DateTimeChooserParameters& parameters)
+ : m_chromeClient(chromeClient)
+ , m_client(client)
+ , m_popup(0)
+ , m_parameters(parameters)
+ , m_locale(WebCore::Locale::create(parameters.locale))
+{
+ ASSERT(m_chromeClient);
+ ASSERT(m_client);
+ m_popup = m_chromeClient->openPagePopup(this, m_parameters.anchorRectInRootView);
+}
+
+PassRefPtr<DateTimeChooserImpl> DateTimeChooserImpl::create(ChromeClientImpl* chromeClient, WebCore::DateTimeChooserClient* client, const WebCore::DateTimeChooserParameters& parameters)
+{
+ return adoptRef(new DateTimeChooserImpl(chromeClient, client, parameters));
+}
+
+DateTimeChooserImpl::~DateTimeChooserImpl()
+{
+}
+
+void DateTimeChooserImpl::endChooser()
+{
+ if (!m_popup)
+ return;
+ m_chromeClient->closePagePopup(m_popup);
+}
+
+WebCore::IntSize DateTimeChooserImpl::contentSize()
+{
+ return WebCore::IntSize(0, 0);
+}
+
+void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer)
+{
+ WebCore::DateComponents minDate;
+ WebCore::DateComponents maxDate;
+ if (m_parameters.type == WebCore::InputTypeNames::month()) {
+ minDate.setMonthsSinceEpoch(m_parameters.minimum);
+ maxDate.setMonthsSinceEpoch(m_parameters.maximum);
+ } else if (m_parameters.type == WebCore::InputTypeNames::week()) {
+ minDate.setMillisecondsSinceEpochForWeek(m_parameters.minimum);
+ maxDate.setMillisecondsSinceEpochForWeek(m_parameters.maximum);
+ } else {
+ minDate.setMillisecondsSinceEpochForDate(m_parameters.minimum);
+ maxDate.setMillisecondsSinceEpochForDate(m_parameters.maximum);
+ }
+ String stepString = String::number(m_parameters.step);
+ String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::TruncateTrailingZeros);
+ IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.anchorRectInRootView);
+ String todayLabelString;
+ String otherDateLabelString;
+ if (m_parameters.type == WebCore::InputTypeNames::month()) {
+ todayLabelString = Platform::current()->queryLocalizedString(WebLocalizedString::ThisMonthButtonLabel);
+ otherDateLabelString = Platform::current()->queryLocalizedString(WebLocalizedString::OtherMonthLabel);
+ } else if (m_parameters.type == WebCore::InputTypeNames::week()) {
+ todayLabelString = Platform::current()->queryLocalizedString(WebLocalizedString::ThisWeekButtonLabel);
+ otherDateLabelString = Platform::current()->queryLocalizedString(WebLocalizedString::OtherWeekLabel);
+ } else {
+ todayLabelString = Platform::current()->queryLocalizedString(WebLocalizedString::CalendarToday);
+ otherDateLabelString = Platform::current()->queryLocalizedString(WebLocalizedString::OtherDateLabel);
+ }
+
+ addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer);
+ writer.addData(WebCore::pickerCommonCss, sizeof(WebCore::pickerCommonCss));
+ writer.addData(WebCore::pickerCommonChromiumCss, sizeof(WebCore::pickerCommonChromiumCss));
+ writer.addData(WebCore::suggestionPickerCss, sizeof(WebCore::suggestionPickerCss));
+ writer.addData(WebCore::calendarPickerCss, sizeof(WebCore::calendarPickerCss));
+ writer.addData(WebCore::calendarPickerChromiumCss, sizeof(WebCore::calendarPickerChromiumCss));
+ addString("</style></head><body><div id=main>Loading...</div><script>\n"
+ "window.dialogArguments = {\n", writer);
+ addProperty("anchorRectInScreen", anchorRectInScreen, writer);
+ addProperty("min", minDate.toString(), writer);
+ addProperty("max", maxDate.toString(), writer);
+ addProperty("step", stepString, writer);
+ addProperty("stepBase", stepBaseString, writer);
+ addProperty("required", m_parameters.required, writer);
+ addProperty("currentValue", m_parameters.currentValue, writer);
+ addProperty("locale", m_parameters.locale.string(), writer);
+ addProperty("todayLabel", todayLabelString, writer);
+ addProperty("clearLabel", Platform::current()->queryLocalizedString(WebLocalizedString::CalendarClear), writer);
+ addProperty("weekLabel", Platform::current()->queryLocalizedString(WebLocalizedString::WeekNumberLabel), writer);
+ addProperty("weekStartDay", m_locale->firstDayOfWeek(), writer);
+ addProperty("shortMonthLabels", m_locale->shortMonthLabels(), writer);
+ addProperty("dayLabels", m_locale->weekDayShortLabels(), writer);
+ addProperty("isLocaleRTL", m_locale->isRTL(), writer);
+ addProperty("isRTL", m_parameters.isAnchorElementRTL, writer);
+ addProperty("mode", m_parameters.type.string(), writer);
+ if (m_parameters.suggestionValues.size()) {
+ addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectInRootView.width()), writer);
+ addProperty("suggestionValues", m_parameters.suggestionValues, writer);
+ addProperty("localizedSuggestionValues", m_parameters.localizedSuggestionValues, writer);
+ addProperty("suggestionLabels", m_parameters.suggestionLabels, writer);
+ addProperty("showOtherDateEntry", WebCore::RenderTheme::defaultTheme()->supportsCalendarPicker(m_parameters.type), writer);
+ addProperty("otherDateLabel", otherDateLabelString, writer);
+ addProperty("suggestionHighlightColor", WebCore::RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor().serialized(), writer);
+ addProperty("suggestionHighlightTextColor", WebCore::RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor().serialized(), writer);
+ }
+ addString("}\n", writer);
+
+ writer.addData(WebCore::pickerCommonJs, sizeof(WebCore::pickerCommonJs));
+ writer.addData(WebCore::suggestionPickerJs, sizeof(WebCore::suggestionPickerJs));
+ writer.addData(WebCore::calendarPickerJs, sizeof(WebCore::calendarPickerJs));
+ addString("</script></body>\n", writer);
+}
+
+WebCore::Locale& DateTimeChooserImpl::locale()
+{
+ return *m_locale;
+}
+
+void DateTimeChooserImpl::setValueAndClosePopup(int numValue, const String& stringValue)
+{
+ RefPtr<DateTimeChooserImpl> protector(this);
+ if (numValue >= 0)
+ setValue(stringValue);
+ endChooser();
+}
+
+void DateTimeChooserImpl::setValue(const String& value)
+{
+ m_client->didChooseValue(value);
+}
+
+void DateTimeChooserImpl::closePopup()
+{
+ endChooser();
+}
+
+void DateTimeChooserImpl::didClosePopup()
+{
+ ASSERT(m_client);
+ m_popup = 0;
+ m_client->didEndChooser();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI)
diff --git a/chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.h b/chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.h
new file mode 100644
index 00000000000..ed32a18cec5
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DateTimeChooserImpl.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 DateTimeChooserImpl_h
+#define DateTimeChooserImpl_h
+
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "core/page/PagePopupClient.h"
+#include "core/platform/DateTimeChooser.h"
+
+namespace WebCore {
+class PagePopup;
+class DateTimeChooserClient;
+}
+
+namespace WebKit {
+
+class ChromeClientImpl;
+
+class DateTimeChooserImpl : public WebCore::DateTimeChooser, public WebCore::PagePopupClient {
+public:
+ static PassRefPtr<DateTimeChooserImpl> create(ChromeClientImpl*, WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&);
+ virtual ~DateTimeChooserImpl();
+
+ // DateTimeChooser functions:
+ virtual void endChooser() OVERRIDE;
+
+private:
+ DateTimeChooserImpl(ChromeClientImpl*, WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&);
+ // PagePopupClient functions:
+ virtual WebCore::IntSize contentSize() OVERRIDE;
+ virtual void writeDocument(WebCore::DocumentWriter&) OVERRIDE;
+ virtual WebCore::Locale& locale() OVERRIDE;
+ virtual void setValueAndClosePopup(int, const String&) OVERRIDE;
+ virtual void setValue(const String&) OVERRIDE;
+ virtual void closePopup() OVERRIDE;
+ virtual void didClosePopup() OVERRIDE;
+
+ ChromeClientImpl* m_chromeClient;
+ WebCore::DateTimeChooserClient* m_client;
+ WebCore::PagePopup* m_popup;
+ WebCore::DateTimeChooserParameters m_parameters;
+ OwnPtr<WebCore::Locale> m_locale;
+};
+
+}
+
+#endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+
+#endif // DateTimeChooserImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp b/chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp
new file mode 100644
index 00000000000..8afee341615
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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 "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::DeviceOrientationData* DeviceOrientationClientProxy::lastOrientation() const
+{
+ if (!m_client)
+ return 0;
+
+ // Cache the DeviceOrientationData 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/chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.h b/chromium/third_party/WebKit/Source/web/DeviceOrientationClientProxy.h
new file mode 100644
index 00000000000..f54caae1565
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebDeviceOrientationClient.h"
+#include "core/dom/DeviceOrientationClient.h"
+#include "modules/device_orientation/DeviceOrientationData.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+class DeviceOrientationController;
+}
+
+namespace WebKit {
+
+class DeviceOrientationClientProxy : public WebCore::DeviceOrientationClient {
+public:
+ DeviceOrientationClientProxy(WebDeviceOrientationClient* client)
+ : m_client(client)
+ {
+ }
+
+ virtual void setController(WebCore::DeviceOrientationController*) OVERRIDE;
+ virtual void startUpdating() OVERRIDE;
+ virtual void stopUpdating() OVERRIDE;
+ virtual WebCore::DeviceOrientationData* lastOrientation() const OVERRIDE;
+ virtual void deviceOrientationControllerDestroyed() OVERRIDE;
+
+private:
+ WebDeviceOrientationClient* m_client;
+ mutable RefPtr<WebCore::DeviceOrientationData> m_lastOrientation;
+};
+
+} // namespace WebKit
+
+#endif // DeviceOrientationClientProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/DragClientImpl.cpp b/chromium/third_party/WebKit/Source/web/DragClientImpl.cpp
new file mode 100644
index 00000000000..9cf856b97a2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DragClientImpl.cpp
@@ -0,0 +1,91 @@
+/*
+ * 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 "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/page/Frame.h"
+#include "core/platform/DragImage.h"
+#include "core/platform/chromium/ChromiumDataObject.h"
+#include "core/platform/chromium/ClipboardChromium.h"
+#include "core/platform/graphics/IntSize.h"
+#include "core/platform/graphics/skia/NativeImageSkia.h"
+#include "public/platform/WebCommon.h"
+#include "public/platform/WebDragData.h"
+#include "public/platform/WebImage.h"
+#include "public/platform/WebPoint.h"
+#include "public/web/WebDragOperation.h"
+#include "wtf/Assertions.h"
+#include "wtf/RefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DragDestinationAction DragClientImpl::actionMaskForDrag(DragData*)
+{
+ if (m_webView->client() && m_webView->client()->acceptsLoadDrops())
+ return DragDestinationActionAny;
+
+ return static_cast<DragDestinationAction>(
+ DragDestinationActionDHTML | DragDestinationActionEdit);
+}
+
+void DragClientImpl::startDrag(DragImage* 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();
+ WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation());
+ WebImage image;
+ IntSize offsetSize(eventPos - dragImageOrigin);
+ WebPoint offsetPoint(offsetSize.width(), offsetSize.height());
+
+ if (dragImage) {
+ float resolutionScale = dragImage->resolutionScale();
+ if (m_webView->deviceScaleFactor() != resolutionScale) {
+ ASSERT(resolutionScale > 0);
+ float scale = m_webView->deviceScaleFactor() / resolutionScale;
+ dragImage->scale(scale, scale);
+ }
+ image = dragImage->bitmap();
+ }
+
+ m_webView->startDragging(frame, dragData, dragOperationMask, image, offsetPoint);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/DragClientImpl.h b/chromium/third_party/WebKit/Source/web/DragClientImpl.h
new file mode 100644
index 00000000000..241258c30c2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/DragClientImpl.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 DragClientImpl_h
+#define DragClientImpl_h
+
+#include "core/page/DragActions.h"
+#include "core/page/DragClient.h"
+
+namespace WebCore {
+class ClipBoard;
+class DragData;
+class DragImage;
+class IntPoint;
+class KURL;
+}
+
+namespace WebKit {
+class WebViewImpl;
+
+class DragClientImpl : public WebCore::DragClient {
+public:
+ DragClientImpl(WebViewImpl* webView) : m_webView(webView) { }
+
+ virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
+ virtual void startDrag(
+ WebCore::DragImage*,
+ const WebCore::IntPoint& dragImageOrigin,
+ const WebCore::IntPoint& eventPos,
+ WebCore::Clipboard* clipboard,
+ WebCore::Frame* frame,
+ bool isLinkDrag = false);
+
+private:
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/EditorClientImpl.cpp b/chromium/third_party/WebKit/Source/web/EditorClientImpl.cpp
new file mode 100644
index 00000000000..7b1741f745c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/EditorClientImpl.cpp
@@ -0,0 +1,772 @@
+/*
+ * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved.
+ * Copyright (C) 2012 Google, Inc. 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 "HTMLNames.h"
+#include "WebAutofillClient.h"
+#include "WebEditingAction.h"
+#include "WebElement.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebInputElement.h"
+#include "WebInputEventConversion.h"
+#include "WebKit.h"
+#include "WebNode.h"
+#include "WebPermissionClient.h"
+#include "WebRange.h"
+#include "WebSpellCheckClient.h"
+#include "WebTextAffinity.h"
+#include "WebTextCheckingCompletionImpl.h"
+#include "WebTextCheckingResult.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/dom/Document.h"
+#include "core/dom/EventNames.h"
+#include "core/dom/KeyboardEvent.h"
+#include "core/editing/Editor.h"
+#include "core/editing/SpellChecker.h"
+#include "core/editing/UndoStep.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/page/EventHandler.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/NotImplemented.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "core/rendering/RenderObject.h"
+#include "wtf/text/WTFString.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;
+
+EditorClientImpl::EditorClientImpl(WebViewImpl* webview)
+ : m_webView(webview)
+ , m_inRedo(false)
+ , m_spellCheckThisFieldStatus(SpellCheckAutomatic)
+{
+}
+
+EditorClientImpl::~EditorClientImpl()
+{
+}
+
+bool EditorClientImpl::smartInsertDeleteEnabled()
+{
+ if (m_webView->page())
+ return m_webView->page()->settings()->smartInsertDeleteEnabled();
+ return false;
+}
+
+bool EditorClientImpl::isSelectTrailingWhitespaceEnabled()
+{
+ if (m_webView->page())
+ return m_webView->page()->settings()->selectTrailingWhitespaceEnabled();
+ return false;
+}
+
+bool EditorClientImpl::shouldSpellcheckByDefault()
+{
+ // Spellcheck should be enabled for all editable areas (such as textareas,
+ // contentEditable regions, designMode docs and 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 Element* element = document->focusedElement();
+ // If |element| 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 |element| 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 (!element)
+ return true;
+ const RenderObject* renderer = element->renderer();
+ if (!renderer)
+ return false;
+
+ return true;
+}
+
+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;
+}
+
+bool EditorClientImpl::isGrammarCheckingEnabled()
+{
+ const Frame* frame = m_webView->focusedWebCoreFrame();
+ return frame && frame->settings() && (frame->settings()->asynchronousSpellCheckingEnabled() || frame->settings()->unifiedTextCheckerEnabled());
+}
+
+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(StylePropertySet* 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;
+}
+
+void EditorClientImpl::didBeginEditing()
+{
+ if (m_webView->client())
+ m_webView->client()->didBeginEditing();
+}
+
+void EditorClientImpl::respondToChangedSelection(Frame* frame)
+{
+ if (m_webView->client() && 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::didCancelCompositionOnSelectionChange()
+{
+ if (m_webView->client())
+ m_webView->client()->didCancelCompositionOnSelectionChange();
+}
+
+void EditorClientImpl::registerUndoStep(PassRefPtr<UndoStep> step)
+{
+ if (m_undoStack.size() == maximumUndoStackDepth)
+ m_undoStack.removeFirst(); // drop oldest item off the far end
+ if (!m_inRedo)
+ m_redoStack.clear();
+ m_undoStack.append(step);
+}
+
+void EditorClientImpl::registerRedoStep(PassRefPtr<UndoStep> step)
+{
+ m_redoStack.append(step);
+}
+
+void EditorClientImpl::clearUndoRedoOperations()
+{
+ m_undoStack.clear();
+ m_redoStack.clear();
+}
+
+bool EditorClientImpl::canCopyCut(Frame* frame, bool defaultValue) const
+{
+ if (!m_webView->permissionClient())
+ return defaultValue;
+ return m_webView->permissionClient()->allowWriteToClipboard(WebFrameImpl::fromFrame(frame), defaultValue);
+}
+
+bool EditorClientImpl::canPaste(Frame* frame, bool defaultValue) const
+{
+ if (!m_webView->permissionClient())
+ return defaultValue;
+ return m_webView->permissionClient()->allowReadFromClipboard(WebFrameImpl::fromFrame(frame), defaultValue);
+}
+
+bool EditorClientImpl::canUndo() const
+{
+ return !m_undoStack.isEmpty();
+}
+
+bool EditorClientImpl::canRedo() const
+{
+ return !m_redoStack.isEmpty();
+}
+
+void EditorClientImpl::undo()
+{
+ if (canUndo()) {
+ UndoManagerStack::iterator back = --m_undoStack.end();
+ RefPtr<UndoStep> step(*back);
+ m_undoStack.remove(back);
+ step->unapply();
+ // unapply will call us back to push this command onto the redo stack.
+ }
+}
+
+void EditorClientImpl::redo()
+{
+ if (canRedo()) {
+ UndoManagerStack::iterator back = --m_redoStack.end();
+ RefPtr<UndoStep> step(*back);
+ m_redoStack.remove(back);
+
+ ASSERT(!m_inRedo);
+ m_inRedo = true;
+ step->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_UP, CtrlKey, "MoveParagraphBackward" },
+ { VKEY_UP, CtrlKey | ShiftKey, "MoveParagraphBackwardAndModifySelection" },
+ { VKEY_DOWN, CtrlKey, "MoveParagraphForward" },
+ { VKEY_DOWN, CtrlKey | ShiftKey, "MoveParagraphForwardAndModifySelection" },
+ { 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
+ { VKEY_INSERT, 0, "OverWrite" },
+};
+
+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() == PlatformEvent::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() == PlatformEvent::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)
+{
+ // Give the embedder a chance to handle the keyboard event.
+ if ((m_webView->client()
+ && m_webView->client()->handleCurrentKeyboardEvent())
+ || handleEditingKeyboardEvent(evt))
+ evt->setDefaultHandled();
+}
+
+void EditorClientImpl::textFieldDidEndEditing(Element* element)
+{
+ if (m_webView->autofillClient() && element->hasTagName(HTMLNames::inputTag))
+ m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(toHTMLInputElement(element)));
+
+ // Notification that focus was lost. Be careful with this, it's also sent
+ // when the page is being closed.
+
+ // Hide any showing popup.
+ m_webView->hideAutofillPopup();
+}
+
+void EditorClientImpl::textDidChangeInTextField(Element* element)
+{
+ HTMLInputElement* inputElement = toHTMLInputElement(element);
+ if (m_webView->autofillClient())
+ m_webView->autofillClient()->textFieldDidChange(WebInputElement(inputElement));
+}
+
+bool EditorClientImpl::doTextFieldCommandFromEvent(Element* element,
+ KeyboardEvent* event)
+{
+ if (m_webView->autofillClient() && element->hasTagName(HTMLNames::inputTag)) {
+ m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(toHTMLInputElement(element)),
+ WebKeyboardEventBuilder(*event));
+ }
+
+ // 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;
+}
+
+bool EditorClientImpl::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const
+{
+ const Frame* frame = m_webView->focusedWebCoreFrame();
+ return !frame || !frame->settings() || (!frame->settings()->asynchronousSpellCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled());
+}
+
+void EditorClientImpl::checkSpellingOfString(const String& text,
+ 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 (m_webView->spellCheckClient())
+ m_webView->spellCheckClient()->spellCheck(text, spellLocation, spellLength, 0);
+ 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;
+}
+
+void EditorClientImpl::requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest> request)
+{
+ if (m_webView->spellCheckClient()) {
+ const String& text = request->data().text();
+ const Vector<uint32_t>& markers = request->data().markers();
+ const Vector<unsigned>& markerOffsets = request->data().offsets();
+ m_webView->spellCheckClient()->requestCheckingOfText(text, markers, markerOffsets, new WebTextCheckingCompletionImpl(request));
+ }
+}
+
+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();
+ }
+
+ if (m_webView->spellCheckClient())
+ return m_webView->spellCheckClient()->autoCorrectWord(WebString(misspelledWord));
+ return String();
+}
+
+void EditorClientImpl::checkGrammarOfString(const String& text, WTF::Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
+{
+ if (badGrammarLocation)
+ *badGrammarLocation = -1;
+ if (badGrammarLength)
+ *badGrammarLength = 0;
+
+ if (!m_webView->spellCheckClient())
+ return;
+ WebVector<WebTextCheckingResult> webResults;
+ m_webView->spellCheckClient()->checkTextOfParagraph(text, WebTextCheckingTypeGrammar, &webResults);
+ if (!webResults.size())
+ return;
+
+ // Convert a list of WebTextCheckingResults to a list of GrammarDetails. If
+ // the converted vector of GrammarDetails has grammar errors, we set
+ // badGrammarLocation and badGrammarLength to tell WebKit that the input
+ // text has grammar errors.
+ for (size_t i = 0; i < webResults.size(); ++i) {
+ if (webResults[i].type == WebTextCheckingTypeGrammar) {
+ GrammarDetail detail;
+ detail.location = webResults[i].location;
+ detail.length = webResults[i].length;
+ detail.userDescription = webResults[i].replacement;
+ details.append(detail);
+ }
+ }
+ if (!details.size())
+ return;
+ if (badGrammarLocation)
+ *badGrammarLocation = 0;
+ if (badGrammarLength)
+ *badGrammarLength = text.length();
+}
+
+void EditorClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ if (m_webView->spellCheckClient())
+ m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebString(misspelledWord));
+}
+
+void EditorClientImpl::showSpellingUI(bool show)
+{
+ if (m_webView->spellCheckClient())
+ m_webView->spellCheckClient()->showSpellingUI(show);
+}
+
+bool EditorClientImpl::spellingUIIsShowing()
+{
+ if (m_webView->spellCheckClient())
+ return m_webView->spellCheckClient()->isShowingSpellingUI();
+ return false;
+}
+
+bool EditorClientImpl::supportsGlobalSelection()
+{
+#if OS(UNIX) && !OS(DARWIN)
+ return true;
+#else
+ return false;
+#endif
+}
+
+void EditorClientImpl::willSetInputMethodState()
+{
+ if (m_webView->client())
+ m_webView->client()->resetInputMethod();
+}
+
+} // namesace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/EditorClientImpl.h b/chromium/third_party/WebKit/Source/web/EditorClientImpl.h
new file mode 100644
index 00000000000..1d6c7afcad2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/EditorClientImpl.h
@@ -0,0 +1,134 @@
+/*
+ * 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 "core/page/EditorClient.h"
+#include "core/platform/Timer.h"
+#include "core/platform/text/TextCheckerClient.h"
+#include "wtf/Deque.h"
+#include "wtf/HashSet.h"
+
+namespace WebCore {
+class Frame;
+class HTMLInputElement;
+}
+
+namespace WebKit {
+class WebViewImpl;
+class WebTextCheckingCompletionImpl;
+
+class EditorClientImpl : public WebCore::EditorClient, public WebCore::TextCheckerClient {
+public:
+ EditorClientImpl(WebViewImpl* webView);
+
+ virtual ~EditorClientImpl();
+
+ virtual bool smartInsertDeleteEnabled() OVERRIDE;
+ virtual bool isSelectTrailingWhitespaceEnabled() OVERRIDE;
+ virtual bool isContinuousSpellCheckingEnabled() OVERRIDE;
+ virtual void toggleContinuousSpellChecking() OVERRIDE;
+ virtual bool isGrammarCheckingEnabled() OVERRIDE;
+ virtual bool shouldBeginEditing(WebCore::Range*) OVERRIDE;
+ virtual bool shouldEndEditing(WebCore::Range*) OVERRIDE;
+ virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) OVERRIDE;
+ virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction) OVERRIDE;
+ virtual bool shouldDeleteRange(WebCore::Range*) OVERRIDE;
+ virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange,
+ WebCore::EAffinity, bool stillSelecting) OVERRIDE;
+ virtual bool shouldApplyStyle(WebCore::StylePropertySet*, WebCore::Range*) OVERRIDE;
+ virtual void didBeginEditing() OVERRIDE;
+ virtual void respondToChangedContents() OVERRIDE;
+ virtual void respondToChangedSelection(WebCore::Frame*) OVERRIDE;
+ virtual void didEndEditing() OVERRIDE;
+ virtual void didCancelCompositionOnSelectionChange() OVERRIDE;
+ virtual void registerUndoStep(PassRefPtr<WebCore::UndoStep>) OVERRIDE;
+ virtual void registerRedoStep(PassRefPtr<WebCore::UndoStep>) OVERRIDE;
+ virtual void clearUndoRedoOperations() OVERRIDE;
+ virtual bool canCopyCut(WebCore::Frame*, bool defaultValue) const OVERRIDE;
+ virtual bool canPaste(WebCore::Frame*, bool defaultValue) const OVERRIDE;
+ virtual bool canUndo() const OVERRIDE;
+ virtual bool canRedo() const OVERRIDE;
+ virtual void undo() OVERRIDE;
+ virtual void redo() OVERRIDE;
+ virtual void handleKeyboardEvent(WebCore::KeyboardEvent*) OVERRIDE;
+ virtual void textFieldDidEndEditing(WebCore::Element*) OVERRIDE;
+ virtual void textDidChangeInTextField(WebCore::Element*) OVERRIDE;
+ virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) OVERRIDE;
+ virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const OVERRIDE;
+ virtual void checkSpellingOfString(const String&, int* misspellingLocation, int* misspellingLength) OVERRIDE;
+ virtual void checkGrammarOfString(const String&, WTF::Vector<WebCore::GrammarDetail>&,
+ int* badGrammarLocation, int* badGrammarLength) OVERRIDE;
+ virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) OVERRIDE;
+ virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) OVERRIDE;
+ virtual void showSpellingUI(bool show) OVERRIDE;
+ virtual bool spellingUIIsShowing() OVERRIDE;
+ virtual void willSetInputMethodState() OVERRIDE;
+ virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) OVERRIDE;
+ virtual bool supportsGlobalSelection() OVERRIDE;
+
+ virtual WebCore::TextCheckerClient* textChecker() { return this; }
+
+ const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
+
+private:
+ bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
+ void modifySelection(WebCore::Frame*, WebCore::KeyboardEvent*);
+
+ // 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::UndoStep> > UndoManagerStack;
+ UndoManagerStack m_undoStack;
+ UndoManagerStack m_redoStack;
+
+ // 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;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/EventListenerWrapper.cpp b/chromium/third_party/WebKit/Source/web/EventListenerWrapper.cpp
new file mode 100644
index 00000000000..b880f0fd61b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/EventListenerWrapper.cpp
@@ -0,0 +1,74 @@
+/*
+ * 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 "core/dom/Event.h"
+#include "core/dom/EventListener.h"
+
+#include "WebDOMEvent.h"
+#include "WebDOMEventListener.h"
+
+using namespace WebCore;
+
+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/chromium/third_party/WebKit/Source/web/EventListenerWrapper.h b/chromium/third_party/WebKit/Source/web/EventListenerWrapper.h
new file mode 100644
index 00000000000..de0e2d483cd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/EventListenerWrapper.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:
+ *
+ * * 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 "core/dom/EventListener.h"
+
+namespace WebCore {
+class ScriptExecutionContext;
+}
+
+namespace WebKit {
+
+class WebDOMEventListener;
+
+// FIXME: Remove the DeprecatedEventListenerWrapper class below once Chromium
+// switched to using WebDOMEvent.
+class EventListenerWrapper : public WebCore::EventListener {
+public:
+ EventListenerWrapper(WebDOMEventListener*);
+ ~EventListenerWrapper();
+
+ virtual bool operator==(const WebCore::EventListener&);
+ virtual void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*);
+
+ void webDOMEventListenerDeleted();
+
+private:
+ WebDOMEventListener* m_webDOMEventListener;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.cpp b/chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.cpp
new file mode 100644
index 00000000000..cdf91aedff7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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"
+#if !ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "ExternalDateTimeChooser.h"
+
+#include "ChromeClientImpl.h"
+#include "WebDateTimeChooserCompletion.h"
+#include "WebDateTimeChooserParams.h"
+#include "WebViewClient.h"
+#include "core/html/InputTypeNames.h"
+#include "core/platform/DateTimeChooserClient.h"
+#include "wtf/text/AtomicString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebDateTimeChooserCompletionImpl : public WebDateTimeChooserCompletion {
+public:
+ WebDateTimeChooserCompletionImpl(ExternalDateTimeChooser* chooser)
+ : m_chooser(chooser)
+ {
+ }
+
+private:
+ virtual void didChooseValue(const WebString& value) OVERRIDE
+ {
+ m_chooser->didChooseValue(value);
+ delete this;
+ }
+
+ virtual void didCancelChooser() OVERRIDE
+ {
+ m_chooser->didCancelChooser();
+ delete this;
+ }
+
+ RefPtr<ExternalDateTimeChooser> m_chooser;
+};
+
+ExternalDateTimeChooser::~ExternalDateTimeChooser()
+{
+}
+
+ExternalDateTimeChooser::ExternalDateTimeChooser(WebCore::DateTimeChooserClient* client)
+ : m_client(client)
+{
+ ASSERT(client);
+}
+
+PassRefPtr<ExternalDateTimeChooser> ExternalDateTimeChooser::create(ChromeClientImpl* chromeClient, WebViewClient* webViewClient, WebCore::DateTimeChooserClient* client, const WebCore::DateTimeChooserParameters& parameters)
+{
+ ASSERT(chromeClient);
+ RefPtr<ExternalDateTimeChooser> chooser = adoptRef(new ExternalDateTimeChooser(client));
+ if (!chooser->openDateTimeChooser(chromeClient, webViewClient, parameters))
+ chooser.clear();
+ return chooser.release();
+}
+
+
+static WebDateTimeInputType toWebDateTimeInputType(const AtomicString& source)
+{
+ if (source == InputTypeNames::date())
+ return WebDateTimeInputTypeDate;
+ if (source == InputTypeNames::datetime())
+ return WebDateTimeInputTypeDateTime;
+ if (source == InputTypeNames::datetimelocal())
+ return WebDateTimeInputTypeDateTimeLocal;
+ if (source == InputTypeNames::month())
+ return WebDateTimeInputTypeMonth;
+ if (source == InputTypeNames::time())
+ return WebDateTimeInputTypeTime;
+ if (source == InputTypeNames::week())
+ return WebDateTimeInputTypeWeek;
+ return WebDateTimeInputTypeNone;
+}
+
+bool ExternalDateTimeChooser::openDateTimeChooser(ChromeClientImpl* chromeClient, WebViewClient* webViewClient, const DateTimeChooserParameters& parameters)
+{
+ if (!webViewClient)
+ return false;
+
+ WebDateTimeChooserParams webParams;
+ webParams.type = toWebDateTimeInputType(parameters.type);
+ webParams.anchorRectInScreen = chromeClient->rootViewToScreen(parameters.anchorRectInRootView);
+ webParams.currentValue = parameters.currentValue;
+ webParams.suggestionValues = parameters.suggestionValues;
+ webParams.localizedSuggestionValues = parameters.localizedSuggestionValues;
+ webParams.suggestionLabels = parameters.suggestionLabels;
+ webParams.minimum = parameters.minimum;
+ webParams.maximum = parameters.maximum;
+ webParams.step = parameters.step;
+ webParams.stepBase = parameters.stepBase;
+ webParams.isRequired = parameters.required;
+ webParams.isAnchorElementRTL = parameters.isAnchorElementRTL;
+
+ WebDateTimeChooserCompletion* completion = new WebDateTimeChooserCompletionImpl(this);
+ if (webViewClient->openDateTimeChooser(webParams, completion))
+ return true;
+ // We can't open a chooser. Calling
+ // WebDateTimeChooserCompletionImpl::didCancelChooser to delete the
+ // WebDateTimeChooserCompletionImpl object and deref this.
+ completion->didCancelChooser();
+ return false;
+}
+
+void ExternalDateTimeChooser::didChooseValue(const WebString& value)
+{
+ if (m_client)
+ m_client->didChooseValue(value);
+ // didChooseValue might run JavaScript code, and endChooser() might be
+ // called. However DateTimeChooserCompletionImpl still has one reference to
+ // this object.
+ if (m_client)
+ m_client->didEndChooser();
+}
+
+void ExternalDateTimeChooser::didCancelChooser()
+{
+ if (m_client)
+ m_client->didEndChooser();
+}
+
+void ExternalDateTimeChooser::endChooser()
+{
+ DateTimeChooserClient* client = m_client;
+ m_client = 0;
+ client->didEndChooser();
+}
+
+}
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.h b/chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.h
new file mode 100644
index 00000000000..bf127e39b5a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ExternalDateTimeChooser.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ExternalDateTimeChooser_h
+#define ExternalDateTimeChooser_h
+
+#if !ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "core/platform/DateTimeChooser.h"
+
+namespace WebCore {
+class DateTimeChooserClient;
+}
+
+namespace WebKit {
+
+class ChromeClientImpl;
+class WebString;
+class WebViewClient;
+
+class ExternalDateTimeChooser : public WebCore::DateTimeChooser {
+public:
+ static PassRefPtr<ExternalDateTimeChooser> create(ChromeClientImpl*, WebViewClient*, WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&);
+ virtual ~ExternalDateTimeChooser();
+
+ // The following functions are for DateTimeChooserCompletion.
+ void didChooseValue(const WebString&);
+ void didCancelChooser();
+
+private:
+ ExternalDateTimeChooser(WebCore::DateTimeChooserClient*);
+ bool openDateTimeChooser(ChromeClientImpl*, WebViewClient*, const WebCore::DateTimeChooserParameters&);
+
+ // DateTimeChooser function:
+ virtual void endChooser() OVERRIDE;
+
+ WebCore::DateTimeChooserClient* m_client;
+};
+
+}
+#endif
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/ExternalPopupMenu.cpp b/chromium/third_party/WebKit/Source/web/ExternalPopupMenu.cpp
new file mode 100644
index 00000000000..8b22f3b5122
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ExternalPopupMenu.cpp
@@ -0,0 +1,194 @@
+/*
+ * 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 "WebExternalPopupMenu.h"
+#include "WebMenuItemInfo.h"
+#include "WebPopupMenuInfo.h"
+#include "WebViewClient.h"
+#include "core/page/FrameView.h"
+#include "core/platform/PopupMenuClient.h"
+#include "core/platform/graphics/FloatQuad.h"
+#include "core/platform/graphics/IntPoint.h"
+#include "core/platform/text/TextDirection.h"
+#include "public/platform/WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ExternalPopupMenu::ExternalPopupMenu(Frame& frame, PopupMenuClient* popupMenuClient, WebViewClient* webViewClient)
+ : m_popupMenuClient(popupMenuClient)
+ , m_frameView(frame.view())
+ , m_webViewClient(webViewClient)
+ , m_webExternalPopupMenu(0)
+{
+}
+
+ExternalPopupMenu::~ExternalPopupMenu()
+{
+}
+
+void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, int index)
+{
+ IntRect rect(controlPosition.enclosingBoundingBox());
+ // 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);
+ if (m_webExternalPopupMenu)
+ m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect));
+ else {
+ // The client might refuse to create a popup (when there is already one pending to be shown for example).
+ didCancel();
+ }
+}
+
+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::didAcceptIndices(const WebVector<int>& indices)
+{
+ if (!m_popupMenuClient) {
+ m_webExternalPopupMenu = 0;
+ return;
+ }
+
+ // 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> protect(this);
+
+ if (!indices.size())
+ m_popupMenuClient->valueChanged(-1, true);
+ else {
+ for (size_t i = 0; i < indices.size(); ++i)
+ m_popupMenuClient->listBoxSelectItem(indices[i], (i > 0), false, (i == indices.size() - 1));
+ }
+
+ // 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<WebMenuItemInfo> items(static_cast<size_t>(itemCount));
+ for (int i = 0; i < itemCount; ++i) {
+ WebMenuItemInfo& popupItem = items[i];
+ popupItem.label = m_popupMenuClient->itemText(i);
+ popupItem.toolTip = m_popupMenuClient->itemToolTip(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);
+ popupItem.checked = m_popupMenuClient->itemIsSelected(i);
+ PopupMenuStyle style = m_popupMenuClient->itemStyle(i);
+ if (style.textDirection() == WebCore::RTL)
+ popupItem.textDirection = WebTextDirectionRightToLeft;
+ else
+ popupItem.textDirection = WebTextDirectionLeftToRight;
+ popupItem.hasTextDirectionOverride = style.hasTextDirectionOverride();
+ }
+
+ info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().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->allowMultipleSelection = m_popupMenuClient->multiple();
+ info->items.swap(items);
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/ExternalPopupMenu.h b/chromium/third_party/WebKit/Source/web/ExternalPopupMenu.h
new file mode 100644
index 00000000000..a87a3697acd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ExternalPopupMenu.h
@@ -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.
+ */
+
+#ifndef ExternalPopupMenu_h
+#define ExternalPopupMenu_h
+
+#include "WebExternalPopupMenuClient.h"
+#include "core/platform/PopupMenu.h"
+#include "public/platform/WebCanvas.h"
+#include "public/platform/WebScrollbar.h"
+
+namespace WebCore {
+class FloatQuad;
+class Frame;
+class FrameView;
+class IntRect;
+class IntSize;
+class PopupMenuClient;
+}
+
+namespace WebKit {
+
+class WebExternalPopupMenu;
+class WebViewClient;
+struct WebPopupMenuInfo;
+class WebInputEvent;
+
+// 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::Frame&, WebCore::PopupMenuClient*, WebViewClient*);
+ virtual ~ExternalPopupMenu();
+
+private:
+ // WebCore::PopupMenu methods:
+ virtual void show(const WebCore::FloatQuad& controlPosition, const WebCore::IntSize&, int index) OVERRIDE;
+ virtual void hide() OVERRIDE;
+ virtual void updateFromElement() OVERRIDE;
+ virtual void disconnectClient() OVERRIDE;
+
+ // WebExternalPopupClient methods:
+ virtual void didChangeSelection(int index);
+ virtual void didAcceptIndex(int index);
+ virtual void didAcceptIndices(const WebVector<int>& indices);
+ 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;
+ RefPtr<WebCore::FrameView> m_frameView;
+ WebViewClient* m_webViewClient;
+
+ // The actual implementor of the show menu.
+ WebExternalPopupMenu* m_webExternalPopupMenu;
+};
+
+} // namespace WebKit
+
+#endif // ExternalPopupMenu_h
diff --git a/chromium/third_party/WebKit/Source/web/FindInPageCoordinates.cpp b/chromium/third_party/WebKit/Source/web/FindInPageCoordinates.cpp
new file mode 100644
index 00000000000..125e83efe1e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/FindInPageCoordinates.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "FindInPageCoordinates.h"
+
+#include "core/dom/Node.h"
+#include "core/dom/Range.h"
+#include "core/page/Frame.h"
+#include "core/platform/graphics/FloatPoint.h"
+#include "core/platform/graphics/FloatQuad.h"
+#include "core/platform/graphics/FloatRect.h"
+#include "core/platform/graphics/IntPoint.h"
+#include "core/rendering/RenderBlock.h"
+#include "core/rendering/RenderBox.h"
+#include "core/rendering/RenderObject.h"
+#include "core/rendering/RenderPart.h"
+#include "core/rendering/RenderView.h"
+#include "core/rendering/style/RenderStyle.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const RenderBlock* enclosingScrollableAncestor(const RenderObject* renderer)
+{
+ ASSERT(!renderer->isRenderView());
+
+ // Trace up the containingBlocks until we reach either the render view or a scrollable object.
+ const RenderBlock* container = renderer->containingBlock();
+ while (!container->hasOverflowClip() && !container->isRenderView())
+ container = container->containingBlock();
+ return container;
+}
+
+static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const RenderObject* renderer, const RenderBlock* container)
+{
+ ASSERT(renderer);
+
+ ASSERT(container || renderer->isRenderView());
+ if (!container)
+ return FloatRect();
+
+ // We want to normalize by the max layout overflow size instead of only the visible bounding box.
+ // Quads and their enclosing bounding boxes need to be used in order to keep results transform-friendly.
+ FloatPoint scrolledOrigin;
+
+ // For overflow:scroll we need to get where the actual origin is independently of the scroll.
+ if (container->hasOverflowClip())
+ scrolledOrigin = -IntPoint(container->scrolledContentOffset());
+
+ FloatRect overflowRect(scrolledOrigin, container->maxLayoutOverflow());
+ FloatRect containerRect = container->localToAbsoluteQuad(FloatQuad(overflowRect)).enclosingBoundingBox();
+
+ if (containerRect.isEmpty())
+ return FloatRect();
+
+ // Make the coordinates relative to the container enclosing bounding box.
+ // Since we work with rects enclosing quad unions this is still transform-friendly.
+ FloatRect normalizedRect = absoluteRect;
+ normalizedRect.moveBy(-containerRect.location());
+
+ // Fixed positions do not make sense in this coordinate system, but need to leave consistent tickmarks.
+ // So, use their position when the view is not scrolled, like an absolute position.
+ if (renderer->style()->position() == FixedPosition && container->isRenderView())
+ normalizedRect.move(-toRenderView(container)->frameView()->scrollOffsetForFixedPosition());
+
+ normalizedRect.scale(1 / containerRect.width(), 1 / containerRect.height());
+ return normalizedRect;
+}
+
+FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const RenderObject* baseRenderer)
+{
+ if (!baseRenderer || inputRect.isEmpty())
+ return FloatRect();
+
+ // Normalize the input rect to its container block.
+ const RenderBlock* baseContainer = enclosingScrollableAncestor(baseRenderer);
+ FloatRect normalizedRect = toNormalizedRect(inputRect, baseRenderer, baseContainer);
+
+ // Go up across frames.
+ for (const RenderBox* renderer = baseContainer; renderer; ) {
+
+ // Go up the render tree until we reach the root of the current frame (the RenderView).
+ while (!renderer->isRenderView()) {
+ const RenderBlock* container = enclosingScrollableAncestor(renderer);
+
+ // Compose the normalized rects.
+ FloatRect normalizedBoxRect = toNormalizedRect(renderer->absoluteBoundingBoxRect(), renderer, container);
+ normalizedRect.scale(normalizedBoxRect.width(), normalizedBoxRect.height());
+ normalizedRect.moveBy(normalizedBoxRect.location());
+
+ renderer = container;
+ }
+
+ ASSERT(renderer->isRenderView());
+
+ // Jump to the renderer owning the frame, if any.
+ renderer = renderer->frame() ? renderer->frame()->ownerRenderer() : 0;
+ }
+
+ return normalizedRect;
+}
+
+FloatRect findInPageRectFromRange(Range* range)
+{
+ if (!range || !range->firstNode())
+ return FloatRect();
+
+ return findInPageRectFromAbsoluteRect(RenderObject::absoluteBoundingBoxRectForRange(range), range->firstNode()->renderer());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/FindInPageCoordinates.h b/chromium/third_party/WebKit/Source/web/FindInPageCoordinates.h
new file mode 100644
index 00000000000..7c12e8cb148
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/FindInPageCoordinates.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 FindInPageCoordinates_h
+#define FindInPageCoordinates_h
+
+#include "core/platform/graphics/FloatRect.h"
+
+namespace WebCore {
+class Range;
+class RenderObject;
+}
+
+namespace WebKit {
+
+// Find-in-page coordinate conversion methods.
+//
+// This coordinate system is designed to give consistent tickmarks in cases where find matches
+// are in scrollable areas but might not be visible (e.g. child frames, scroll:overflow).
+// In these cases, using absolute positions might lead to tickmarks pointing outside the visible
+// area of its container, which is counter-intuitive for users.
+//
+// Find-in-page coordinates are represented as normalized fractions of the main frame document with
+// the property that they are built by composing the relative position of each renderer to the maximum
+// effective layout size of its container all the way up the render tree. The resulting coordinates
+// are scroll-independent, representing any contents scaled to the visible area of their container.
+// The provided methods support scroll:overflow and are CSS position and transform-friendly.
+
+WebCore::FloatRect findInPageRectFromAbsoluteRect(const WebCore::FloatRect&, const WebCore::RenderObject*);
+WebCore::FloatRect findInPageRectFromRange(WebCore::Range*);
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp b/chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp
new file mode 100644
index 00000000000..640bfb2563c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp
@@ -0,0 +1,791 @@
+/*
+ * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * 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 "HTMLNames.h"
+#include "core/dom/Document.h"
+#include "core/dom/MessageEvent.h"
+#include "core/dom/MouseEvent.h"
+#include "core/history/HistoryItem.h"
+#include "core/html/HTMLAppletElement.h"
+#include "core/html/HTMLFormElement.h" // needed by core/loader/FormState.h
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FormState.h"
+#include "core/loader/FrameLoadRequest.h"
+#include "core/loader/FrameLoader.h"
+#include "core/loader/ProgressTracker.h"
+#include "core/page/Chrome.h"
+#include "core/page/EventHandler.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/platform/MIMETypeRegistry.h"
+#include "core/platform/mediastream/RTCPeerConnectionHandler.h"
+#include "core/platform/network/HTTPParsers.h"
+#include "core/plugins/PluginData.h"
+#include "core/rendering/HitTestResult.h"
+#include <v8.h>
+#include "WebAutofillClient.h"
+#include "WebCachedURLRequest.h"
+#include "WebDOMEvent.h"
+#include "WebDataSourceImpl.h"
+#include "WebDevToolsAgentPrivate.h"
+#include "WebDocument.h"
+#include "WebFormElement.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebNode.h"
+#include "WebPermissionClient.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPluginLoadObserver.h"
+#include "WebPluginParams.h"
+#include "WebSecurityOrigin.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "bindings/v8/ScriptController.h"
+#include "core/dom/UserGestureIndicator.h"
+#include "core/page/Settings.h"
+#include "core/page/WindowFeatures.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "core/platform/chromium/support/WrappedResourceResponse.h"
+#include "core/platform/network/SocketStreamHandleInternal.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebMimeRegistry.h"
+#include "public/platform/WebSocketStreamHandle.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebVector.h"
+#include "wtf/StringExtras.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.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)
+{
+}
+
+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.
+ ASSERT(!m_webFrame->frame());
+ m_webFrame->deref();
+}
+
+void FrameLoaderClientImpl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didClearWindowObject(m_webFrame);
+}
+
+void FrameLoaderClientImpl::documentElementAvailable()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didCreateDocumentElement(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didExhaustMemoryAvailableForScript()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didExhaustMemoryAvailableForScript(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didCreateScriptContext(v8::Handle<v8::Context> context, int extensionGroup, int worldId)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview->devToolsAgentPrivate())
+ webview->devToolsAgentPrivate()->didCreateScriptContext(m_webFrame, worldId);
+ if (m_webFrame->client())
+ m_webFrame->client()->didCreateScriptContext(m_webFrame, context, extensionGroup, worldId);
+}
+
+void FrameLoaderClientImpl::willReleaseScriptContext(v8::Handle<v8::Context> context, int worldId)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willReleaseScriptContext(m_webFrame, context, worldId);
+}
+
+bool FrameLoaderClientImpl::allowScriptExtension(const String& extensionName,
+ int extensionGroup,
+ int worldId)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowScriptExtension(m_webFrame, extensionName, extensionGroup, worldId);
+
+ return true;
+}
+
+void FrameLoaderClientImpl::didChangeScrollOffset()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didChangeScrollOffset(m_webFrame);
+}
+
+bool FrameLoaderClientImpl::allowScript(bool enabledPerSettings)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowScript(m_webFrame, enabledPerSettings);
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowScriptFromSource(bool enabledPerSettings, const KURL& scriptURL)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowScriptFromSource(m_webFrame, enabledPerSettings, scriptURL);
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowPlugins(bool enabledPerSettings)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowPlugins(m_webFrame, enabledPerSettings);
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowImage(bool enabledPerSettings, const KURL& imageURL)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowImage(m_webFrame, enabledPerSettings, imageURL);
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowDisplayingInsecureContent(bool enabledPerSettings, SecurityOrigin* context, const KURL& url)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowDisplayingInsecureContent(m_webFrame, enabledPerSettings, WebSecurityOrigin(context), WebURL(url));
+
+ return enabledPerSettings;
+}
+
+bool FrameLoaderClientImpl::allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin* context, const KURL& url)
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ return webview->permissionClient()->allowRunningInsecureContent(m_webFrame, enabledPerSettings, WebSecurityOrigin(context), WebURL(url));
+
+ return enabledPerSettings;
+}
+
+void FrameLoaderClientImpl::didNotAllowScript()
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ webview->permissionClient()->didNotAllowScript(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didNotAllowPlugins()
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview && webview->permissionClient())
+ webview->permissionClient()->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::detachedFromParent()
+{
+ // 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()->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);
+}
+
+void FrameLoaderClientImpl::dispatchWillRequestAfterPreconnect(ResourceRequest& request)
+{
+ if (m_webFrame->client()) {
+ WrappedResourceRequest webreq(request);
+ m_webFrame->client()->willRequestAfterPreconnect(m_webFrame, webreq);
+ }
+}
+
+void FrameLoaderClientImpl::dispatchWillSendRequest(
+ DocumentLoader* loader, unsigned long identifier, ResourceRequest& request,
+ const ResourceResponse& redirectResponse)
+{
+ // 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);
+ }
+}
+
+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::dispatchDidChangeResourcePriority(unsigned long identifier,
+ ResourceLoadPriority priority)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didChangeResourcePriority(m_webFrame, identifier, static_cast<WebKit::WebURLRequest::Priority>(priority));
+}
+
+// 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::dispatchDidFinishDocumentLoad()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didFinishDocumentLoad(m_webFrame);
+}
+
+void 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);
+ }
+}
+
+void FrameLoaderClientImpl::dispatchDidHandleOnloadEvents()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didHandleOnloadEvents(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveServerRedirectForProvisionalLoad()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidNavigateWithinPage()
+{
+ bool isNewNavigation;
+ m_webFrame->viewImpl()->didCommitLoad(&isNewNavigation, true);
+ if (m_webFrame->client())
+ m_webFrame->client()->didNavigateWithinPage(m_webFrame, isNewNavigation);
+}
+
+void FrameLoaderClientImpl::dispatchWillClose()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willClose(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidStartProvisionalLoad()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didStartProvisionalLoad(m_webFrame);
+}
+
+void FrameLoaderClientImpl::dispatchDidReceiveTitle(const StringWithDirection& title)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didReceiveTitle(m_webFrame, title.string(), title.direction() == LTR ? WebTextDirectionLeftToRight : WebTextDirectionRightToLeft);
+}
+
+void FrameLoaderClientImpl::dispatchDidChangeIcons(WebCore::IconType type)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didChangeIcon(m_webFrame, static_cast<WebIconURL::Type>(type));
+}
+
+void FrameLoaderClientImpl::dispatchDidCommitLoad()
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ bool isNewNavigation;
+ webview->didCommitLoad(&isNewNavigation, false);
+
+ 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(ResourceError::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::dispatchDidLayout(LayoutMilestones milestones)
+{
+ if (!m_webFrame->client())
+ return;
+
+ if (milestones & DidFirstLayout)
+ m_webFrame->client()->didFirstLayout(m_webFrame);
+ if (milestones & DidFirstVisuallyNonEmptyLayout)
+ m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame);
+}
+
+NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(const ResourceRequest& request, NavigationType type, NavigationPolicy policy, bool /*isRedirect*/)
+{
+
+ if (!m_webFrame->client())
+ return NavigationPolicyIgnore;
+
+ // FIXME: We need to pull isRedirect off of provisionalDataSourceImpl() for compat reasons,
+ // but it seems wrong, since the request that triggered this policy check might not be the
+ // provisional data source.
+ WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
+ if (!ds)
+ return policy;
+
+ WrappedResourceRequest webRequest(request);
+ WebNavigationPolicy webPolicy = m_webFrame->client()->decidePolicyForNavigation(
+ m_webFrame, webRequest, WebDataSourceImpl::toWebNavigationType(type), static_cast<WebNavigationPolicy>(policy), ds->isRedirect());
+ return static_cast<NavigationPolicy>(webPolicy);
+}
+
+void FrameLoaderClientImpl::dispatchWillRequestResource(FetchRequest* request)
+{
+ if (m_webFrame->client()) {
+ WebCachedURLRequest urlRequest(request);
+ m_webFrame->client()->willRequestResource(m_webFrame, urlRequest);
+ }
+}
+
+void FrameLoaderClientImpl::dispatchWillSendSubmitEvent(PassRefPtr<FormState> prpFormState)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willSendSubmitEvent(m_webFrame, WebFormElement(prpFormState->form()));
+}
+
+void FrameLoaderClientImpl::dispatchWillSubmitForm(PassRefPtr<FormState> formState)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willSubmitForm(m_webFrame, WebFormElement(formState->form()));
+}
+
+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::loadURLExternally(const ResourceRequest& request, NavigationPolicy policy, const String& suggestedName)
+{
+ if (m_webFrame->client()) {
+ WrappedResourceRequest webreq(request);
+ m_webFrame->client()->loadURLExternally(
+ m_webFrame, webreq, static_cast<WebNavigationPolicy>(policy), suggestedName);
+ }
+}
+
+void FrameLoaderClientImpl::navigateBackForward(int offset) const
+{
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview->client())
+ webview->client()->navigateBackForwardSoon(offset);
+}
+
+void FrameLoaderClientImpl::didAccessInitialDocument()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didAccessInitialDocument(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didDisownOpener()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didDisownOpener(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didDisplayInsecureContent()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didDisplayInsecureContent(m_webFrame);
+}
+
+void FrameLoaderClientImpl::didRunInsecureContent(SecurityOrigin* origin, const KURL& insecureURL)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didRunInsecureContent(m_webFrame, WebSecurityOrigin(origin), insecureURL);
+}
+
+void FrameLoaderClientImpl::didDetectXSS(const KURL& insecureURL, bool didBlockEntirePage)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didDetectXSS(m_webFrame, insecureURL, didBlockEntirePage);
+}
+
+void FrameLoaderClientImpl::didDispatchPingLoader(const KURL& url)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didDispatchPingLoader(m_webFrame, url);
+}
+
+ResourceError FrameLoaderClientImpl::interruptedForPolicyChangeError(
+ const ResourceRequest& request)
+{
+ return ResourceError(internalErrorDomain, PolicyChangeError,
+ request.url().string(), String());
+}
+
+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();
+}
+
+String FrameLoaderClientImpl::userAgent(const KURL& url)
+{
+ WebString override = m_webFrame->client()->userAgentOverride(m_webFrame, WebURL(url));
+ if (!override.isEmpty())
+ return override;
+
+ return WebKit::Platform::current()->userAgent(url);
+}
+
+String FrameLoaderClientImpl::doNotTrackValue()
+{
+ WebString doNotTrack = m_webFrame->client()->doNotTrackValue(m_webFrame);
+ if (!doNotTrack.isEmpty())
+ return doNotTrack;
+ return String();
+}
+
+// Called when the FrameLoader goes into a state in which a new page load
+// will occur.
+void FrameLoaderClientImpl::transitionToCommittedForNewPage()
+{
+ m_webFrame->createFrameView();
+}
+
+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);
+}
+
+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;
+}
+
+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,
+ bool shouldPreferPlugInsForImages)
+{
+ // 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 Chrome is started with the --disable-plugins switch, pluginData is 0.
+ PluginData* pluginData = m_webFrame->frame()->page()->pluginData();
+ bool plugInSupportsMIMEType = pluginData && pluginData->supportsMimeType(mimeType);
+
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
+ return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? ObjectContentNetscapePlugin : ObjectContentImage;
+
+ if (plugInSupportsMIMEType)
+ return ObjectContentNetscapePlugin;
+
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
+ return ObjectContentFrame;
+
+ return ObjectContentNone;
+}
+
+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 nullptr;
+ }
+ return ds->releasePluginLoadObserver();
+}
+
+WebCookieJar* FrameLoaderClientImpl::cookieJar() const
+{
+ if (!m_webFrame->client())
+ return 0;
+ return m_webFrame->client()->cookieJar(m_webFrame);
+}
+
+bool FrameLoaderClientImpl::willCheckAndDispatchMessageEvent(
+ SecurityOrigin* target, MessageEvent* event) const
+{
+ if (!m_webFrame->client())
+ return false;
+
+ WebFrame* source = 0;
+ if (event && event->source() && event->source()->document())
+ source = WebFrameImpl::fromFrame(event->source()->document()->frame());
+ return m_webFrame->client()->willCheckAndDispatchMessageEvent(
+ source, m_webFrame, WebSecurityOrigin(target), WebDOMMessageEvent(event));
+}
+
+void FrameLoaderClientImpl::didChangeName(const String& name)
+{
+ if (!m_webFrame->client())
+ return;
+ m_webFrame->client()->didChangeName(m_webFrame, name);
+}
+
+void FrameLoaderClientImpl::dispatchWillOpenSocketStream(SocketStreamHandle* handle)
+{
+ m_webFrame->client()->willOpenSocketStream(SocketStreamHandleInternal::toWebSocketStreamHandle(handle));
+}
+
+void FrameLoaderClientImpl::dispatchWillStartUsingPeerConnectionHandler(RTCPeerConnectionHandler* handler)
+{
+ m_webFrame->client()->willStartUsingPeerConnectionHandler(webFrame(), RTCPeerConnectionHandler::toWebRTCPeerConnectionHandler(handler));
+}
+
+void FrameLoaderClientImpl::didRequestAutocomplete(PassRefPtr<FormState> formState)
+{
+ if (m_webFrame->viewImpl() && m_webFrame->viewImpl()->autofillClient())
+ m_webFrame->viewImpl()->autofillClient()->didRequestAutocomplete(m_webFrame, WebFormElement(formState->form()));
+}
+
+bool FrameLoaderClientImpl::allowWebGL(bool enabledPerSettings)
+{
+ if (m_webFrame->client())
+ return m_webFrame->client()->allowWebGL(m_webFrame, enabledPerSettings);
+
+ return enabledPerSettings;
+}
+
+void FrameLoaderClientImpl::didLoseWebGLContext(int arbRobustnessContextLostReason)
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->didLoseWebGLContext(m_webFrame, arbRobustnessContextLostReason);
+}
+
+void FrameLoaderClientImpl::dispatchWillInsertBody()
+{
+ if (m_webFrame->client())
+ m_webFrame->client()->willInsertBody(m_webFrame);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.h b/chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.h
new file mode 100644
index 00000000000..103567a883c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/FrameLoaderClientImpl.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * 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 "core/loader/FrameLoaderClient.h"
+#include "weborigin/KURL.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();
+
+ // Script in the page tried to allocate too much memory.
+ virtual void didExhaustMemoryAvailableForScript();
+
+ virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId);
+ virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId);
+
+ // 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, int worldId);
+
+ virtual bool hasWebView() const;
+ virtual bool hasFrameView() const;
+ virtual void detachedFromParent();
+ virtual void dispatchWillRequestAfterPreconnect(WebCore::ResourceRequest&);
+ virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
+ virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&);
+ virtual void dispatchDidChangeResourcePriority(unsigned long identifier, WebCore::ResourceLoadPriority);
+ virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier);
+ virtual void dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
+ virtual void dispatchDidHandleOnloadEvents();
+ virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
+ virtual void dispatchDidNavigateWithinPage();
+ virtual void dispatchWillClose();
+ virtual void dispatchDidStartProvisionalLoad();
+ virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
+ virtual void dispatchDidChangeIcons(WebCore::IconType);
+ virtual void dispatchDidCommitLoad();
+ virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
+ virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
+ virtual void dispatchDidFinishDocumentLoad();
+ virtual void dispatchDidFinishLoad();
+ virtual void dispatchDidLayout(WebCore::LayoutMilestones);
+ virtual WebCore::NavigationPolicy decidePolicyForNavigation(const WebCore::ResourceRequest&, WebCore::NavigationType, WebCore::NavigationPolicy, bool isRedirect);
+ virtual void dispatchWillRequestResource(WebCore::FetchRequest*);
+ virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>);
+ virtual void dispatchWillSubmitForm(PassRefPtr<WebCore::FormState>);
+ virtual void postProgressStartedNotification();
+ virtual void postProgressEstimateChangedNotification();
+ virtual void postProgressFinishedNotification();
+ virtual void loadURLExternally(const WebCore::ResourceRequest&, WebCore::NavigationPolicy, const String& suggestedName = String());
+ virtual void navigateBackForward(int offset) const;
+ virtual void didAccessInitialDocument();
+ virtual void didDisownOpener();
+ virtual void didDisplayInsecureContent();
+ virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL& insecureURL);
+ virtual void didDetectXSS(const WebCore::KURL&, bool didBlockEntirePage);
+ virtual void didDispatchPingLoader(const WebCore::KURL&);
+ virtual WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&);
+ virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(
+ const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
+ virtual WTF::String userAgent(const WebCore::KURL&);
+ virtual WTF::String doNotTrackValue();
+ virtual void transitionToCommittedForNewPage();
+ 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 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 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&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages);
+ virtual void didChangeScrollOffset();
+ virtual bool allowScript(bool enabledPerSettings);
+ virtual bool allowScriptFromSource(bool enabledPerSettings, const WebCore::KURL& scriptURL);
+ virtual bool allowPlugins(bool enabledPerSettings);
+ virtual bool allowImage(bool enabledPerSettings, const WebCore::KURL& imageURL);
+ virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&);
+ virtual bool allowRunningInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&);
+ virtual void didNotAllowScript();
+ virtual void didNotAllowPlugins();
+
+ virtual WebCookieJar* cookieJar() const;
+ virtual bool willCheckAndDispatchMessageEvent(WebCore::SecurityOrigin* target, WebCore::MessageEvent*) const;
+ virtual void didChangeName(const String&);
+
+ virtual void dispatchWillOpenSocketStream(WebCore::SocketStreamHandle*) OVERRIDE;
+
+ virtual void dispatchWillStartUsingPeerConnectionHandler(WebCore::RTCPeerConnectionHandler*) OVERRIDE;
+
+ virtual void didRequestAutocomplete(PassRefPtr<WebCore::FormState>) OVERRIDE;
+
+ virtual bool allowWebGL(bool enabledPerSettings) OVERRIDE;
+ virtual void didLoseWebGLContext(int arbRobustnessContextLostReason) OVERRIDE;
+
+ virtual void dispatchWillInsertBody() OVERRIDE;
+
+private:
+ 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;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/FullscreenController.cpp b/chromium/third_party/WebKit/Source/web/FullscreenController.cpp
new file mode 100644
index 00000000000..6268f88b85c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/FullscreenController.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "FullscreenController.h"
+
+#include "WebFrame.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/dom/Document.h"
+#include "core/dom/FullscreenElementStack.h"
+#include "core/html/HTMLMediaElement.h"
+#include "core/page/Frame.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<FullscreenController> FullscreenController::create(WebViewImpl* webViewImpl)
+{
+ return adoptPtr(new FullscreenController(webViewImpl));
+}
+
+FullscreenController::FullscreenController(WebViewImpl* webViewImpl)
+ : m_webViewImpl(webViewImpl)
+ , m_exitFullscreenPageScaleFactor(0)
+ , m_isCancelingFullScreen(false)
+{
+}
+
+void FullscreenController::willEnterFullScreen()
+{
+ if (!m_provisionalFullScreenElement)
+ return;
+
+ // Ensure that this element's document is still attached.
+ Document* doc = m_provisionalFullScreenElement->document();
+ if (doc->frame()) {
+ FullscreenElementStack::from(doc)->webkitWillEnterFullScreenForElement(m_provisionalFullScreenElement.get());
+ m_fullScreenFrame = doc->frame();
+ }
+ m_provisionalFullScreenElement.clear();
+}
+
+void FullscreenController::didEnterFullScreen()
+{
+ if (!m_fullScreenFrame)
+ return;
+
+ if (Document* doc = m_fullScreenFrame->document()) {
+ if (FullscreenElementStack::isFullScreen(doc)) {
+ if (!m_exitFullscreenPageScaleFactor) {
+ m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor();
+ m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->scrollOffset();
+ m_webViewImpl->setPageScaleFactorPreservingScrollOffset(1.0f);
+ }
+
+ FullscreenElementStack::from(doc)->webkitDidEnterFullScreenForElement(0);
+ }
+ }
+}
+
+void FullscreenController::willExitFullScreen()
+{
+ if (!m_fullScreenFrame)
+ return;
+
+ if (Document* doc = m_fullScreenFrame->document()) {
+ FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(doc);
+ if (!fullscreen)
+ return;
+ if (fullscreen->isFullScreen(doc)) {
+ // When the client exits from full screen we have to call webkitCancelFullScreen to
+ // notify the document. While doing that, suppress notifications back to the client.
+ m_isCancelingFullScreen = true;
+ fullscreen->webkitCancelFullScreen();
+ m_isCancelingFullScreen = false;
+ fullscreen->webkitWillExitFullScreenForElement(0);
+ }
+ }
+}
+
+void FullscreenController::didExitFullScreen()
+{
+ if (!m_fullScreenFrame)
+ return;
+
+ if (Document* doc = m_fullScreenFrame->document()) {
+ if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(doc)) {
+ if (fullscreen->webkitIsFullScreen()) {
+ if (m_exitFullscreenPageScaleFactor) {
+ m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleFactor,
+ WebPoint(m_exitFullscreenScrollOffset.width(), m_exitFullscreenScrollOffset.height()));
+ m_exitFullscreenPageScaleFactor = 0;
+ m_exitFullscreenScrollOffset = IntSize();
+ }
+
+ fullscreen->webkitDidExitFullScreenForElement(0);
+ }
+ }
+ }
+
+ m_fullScreenFrame.clear();
+}
+
+void FullscreenController::enterFullScreenForElement(WebCore::Element* element)
+{
+ // We are already transitioning to fullscreen for a different element.
+ if (m_provisionalFullScreenElement) {
+ m_provisionalFullScreenElement = element;
+ return;
+ }
+
+ // We are already in fullscreen mode.
+ if (m_fullScreenFrame) {
+ m_provisionalFullScreenElement = element;
+ willEnterFullScreen();
+ didEnterFullScreen();
+ return;
+ }
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ if (element && element->isMediaElement()) {
+ HTMLMediaElement* mediaElement = toMediaElement(element);
+ if (mediaElement->player() && mediaElement->player()->canEnterFullscreen()) {
+ mediaElement->player()->enterFullscreen();
+ m_provisionalFullScreenElement = element;
+ }
+ return;
+ }
+#endif
+
+ // We need to transition to fullscreen mode.
+ if (WebViewClient* client = m_webViewImpl->client()) {
+ if (client->enterFullScreen())
+ m_provisionalFullScreenElement = element;
+ }
+}
+
+void FullscreenController::exitFullScreenForElement(WebCore::Element* element)
+{
+ // The client is exiting full screen, so don't send a notification.
+ if (m_isCancelingFullScreen)
+ return;
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ if (element && element->isMediaElement()) {
+ HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(element);
+ if (mediaElement->player())
+ mediaElement->player()->exitFullscreen();
+ return;
+ }
+#endif
+ if (WebViewClient* client = m_webViewImpl->client())
+ client->exitFullScreen();
+}
+
+}
+
diff --git a/chromium/third_party/WebKit/Source/web/FullscreenController.h b/chromium/third_party/WebKit/Source/web/FullscreenController.h
new file mode 100644
index 00000000000..c0d3edc5966
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/FullscreenController.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 FullscreenController_h
+#define FullscreenController_h
+
+#include "core/platform/graphics/IntSize.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+class Element;
+class Frame;
+}
+
+namespace WebKit {
+class WebViewImpl;
+
+class FullscreenController {
+public:
+ static PassOwnPtr<FullscreenController> create(WebViewImpl*);
+
+ void willEnterFullScreen();
+ void didEnterFullScreen();
+ void willExitFullScreen();
+ void didExitFullScreen();
+
+ void enterFullScreenForElement(WebCore::Element*);
+ void exitFullScreenForElement(WebCore::Element*);
+
+protected:
+ explicit FullscreenController(WebViewImpl*);
+
+private:
+ WebViewImpl* m_webViewImpl;
+
+ float m_exitFullscreenPageScaleFactor;
+ WebCore::IntSize m_exitFullscreenScrollOffset;
+
+ // If set, the WebView is transitioning to fullscreen for this element.
+ RefPtr<WebCore::Element> m_provisionalFullScreenElement;
+
+ // If set, the WebView is in fullscreen mode for an element in this frame.
+ RefPtr<WebCore::Frame> m_fullScreenFrame;
+
+ bool m_isCancelingFullScreen;
+};
+
+}
+
+#endif
+
diff --git a/chromium/third_party/WebKit/Source/web/GeolocationClientProxy.cpp b/chromium/third_party/WebKit/Source/web/GeolocationClientProxy.cpp
new file mode 100644
index 00000000000..94ee7cfa7a5
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebGeolocationClient.h"
+#include "WebGeolocationController.h"
+#include "WebGeolocationPermissionRequest.h"
+#include "WebGeolocationPosition.h"
+#include "modules/geolocation/Geolocation.h"
+#include "modules/geolocation/GeolocationPosition.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/chromium/third_party/WebKit/Source/web/GeolocationClientProxy.h b/chromium/third_party/WebKit/Source/web/GeolocationClientProxy.h
new file mode 100644
index 00000000000..4fa9711d99a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebGeolocationController.h"
+#include "modules/geolocation/GeolocationClient.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/chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.cpp b/chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.cpp
new file mode 100644
index 00000000000..60643670b77
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "GraphicsLayerFactoryChromium.h"
+
+#include "WebViewImpl.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+GraphicsLayerFactoryChromium::GraphicsLayerFactoryChromium(WebViewImpl* webView)
+ : m_webView(webView)
+{
+}
+
+GraphicsLayerFactoryChromium::~GraphicsLayerFactoryChromium()
+{
+}
+
+PassOwnPtr<GraphicsLayer> GraphicsLayerFactoryChromium::createGraphicsLayer(GraphicsLayerClient* client)
+{
+ OwnPtr<GraphicsLayer> layer = adoptPtr(new GraphicsLayer(client));
+ m_webView->registerForAnimations(layer->platformLayer());
+ return layer.release();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.h b/chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.h
new file mode 100644
index 00000000000..920a7187892
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/GraphicsLayerFactoryChromium.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 GraphicsLayerFactoryChromium_h
+#define GraphicsLayerFactoryChromium_h
+
+#include "core/platform/graphics/GraphicsLayerFactory.h"
+
+namespace WebKit {
+class WebViewImpl;
+
+class GraphicsLayerFactoryChromium : public WebCore::GraphicsLayerFactory {
+public:
+ explicit GraphicsLayerFactoryChromium(WebViewImpl*);
+
+ virtual ~GraphicsLayerFactoryChromium();
+
+ virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;
+
+private:
+ // The owner of this GraphicsLayerFactoryChromium.
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.cpp b/chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.cpp
new file mode 100644
index 00000000000..79fafb272e2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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"
+
+#include "public/platform/WebIDBKey.h"
+#include "WebIDBCallbacksImpl.h"
+#include "modules/indexeddb/IDBAny.h"
+#include "modules/indexeddb/IDBCallbacks.h"
+#include "modules/indexeddb/IDBKey.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<IDBCursorBackendInterface> IDBCursorBackendProxy::create(PassOwnPtr<WebIDBCursor> idbCursor)
+{
+ return adoptRef(new IDBCursorBackendProxy(idbCursor));
+}
+
+IDBCursorBackendProxy::IDBCursorBackendProxy(PassOwnPtr<WebIDBCursor> idbCursor)
+ : m_idbCursor(idbCursor)
+{
+}
+
+IDBCursorBackendProxy::~IDBCursorBackendProxy()
+{
+}
+
+void IDBCursorBackendProxy::advance(unsigned long count, PassRefPtr<IDBCallbacks> callbacks)
+{
+ m_idbCursor->advance(count, new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBCursorBackendProxy::continueFunction(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks)
+{
+ m_idbCursor->continueFunction(key, new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBCursorBackendProxy::postSuccessHandlerCallback()
+{
+ m_idbCursor->postSuccessHandlerCallback();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.h b/chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.h
new file mode 100644
index 00000000000..08f2ebb226b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/IDBCursorBackendProxy.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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
+
+#include "public/platform/WebIDBCursor.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "modules/indexeddb/IDBCursorBackendInterface.h"
+
+namespace WebKit {
+
+class IDBCursorBackendProxy : public WebCore::IDBCursorBackendInterface {
+public:
+ static PassRefPtr<WebCore::IDBCursorBackendInterface> create(PassOwnPtr<WebIDBCursor>);
+ virtual ~IDBCursorBackendProxy();
+
+ virtual void advance(unsigned long, PassRefPtr<WebCore::IDBCallbacks>);
+ virtual void continueFunction(PassRefPtr<WebCore::IDBKey>, PassRefPtr<WebCore::IDBCallbacks>);
+ virtual void postSuccessHandlerCallback();
+
+private:
+ IDBCursorBackendProxy(PassOwnPtr<WebIDBCursor>);
+
+ OwnPtr<WebIDBCursor> m_idbCursor;
+};
+
+} // namespace WebKit
+
+#endif // IDBCursorBackendProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.cpp b/chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.cpp
new file mode 100644
index 00000000000..0680198a98a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "IDBDatabaseBackendProxy.h"
+
+#include "WebFrameImpl.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBDatabaseCallbacksImpl.h"
+#include "core/dom/DOMError.h"
+#include "modules/indexeddb/IDBCallbacks.h"
+#include "modules/indexeddb/IDBDatabaseCallbacks.h"
+#include "modules/indexeddb/IDBKeyRange.h"
+#include "modules/indexeddb/IDBMetadata.h"
+#include "public/platform/WebData.h"
+#include "public/platform/WebIDBCursor.h"
+#include "public/platform/WebIDBDatabase.h"
+#include "public/platform/WebIDBDatabaseError.h"
+#include "public/platform/WebIDBKeyRange.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<IDBDatabaseBackendInterface> IDBDatabaseBackendProxy::create(PassOwnPtr<WebIDBDatabase> database)
+{
+ return adoptRef(new IDBDatabaseBackendProxy(database));
+}
+
+IDBDatabaseBackendProxy::IDBDatabaseBackendProxy(PassOwnPtr<WebIDBDatabase> database)
+ : m_webIDBDatabase(database)
+{
+}
+
+IDBDatabaseBackendProxy::~IDBDatabaseBackendProxy()
+{
+}
+
+void IDBDatabaseBackendProxy::createObjectStore(int64_t transactionId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->createObjectStore(transactionId, objectStoreId, name, keyPath, autoIncrement);
+}
+
+void IDBDatabaseBackendProxy::deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->deleteObjectStore(transactionId, objectStoreId);
+}
+
+void IDBDatabaseBackendProxy::createTransaction(int64_t id, PassRefPtr<IDBDatabaseCallbacks>, const Vector<int64_t>& objectStoreIds, unsigned short mode)
+{
+ // WebIDBDatabaseImpl holds on to the specific callbacks object for this connection.
+ m_webIDBDatabase->createTransaction(id, 0, objectStoreIds, mode);
+}
+
+void IDBDatabaseBackendProxy::commit(int64_t transactionId)
+{
+ m_webIDBDatabase->commit(transactionId);
+}
+
+void IDBDatabaseBackendProxy::abort(int64_t transactionId)
+{
+ m_webIDBDatabase->abort(transactionId);
+}
+
+void IDBDatabaseBackendProxy::openCursor(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange> keyRange, IndexedDB::CursorDirection direction, bool keyOnly, TaskType taskType, PassRefPtr<IDBCallbacks> callbacks)
+{
+ m_webIDBDatabase->openCursor(transactionId, objectStoreId, indexId, keyRange, static_cast<WebIDBCursor::Direction>(direction), keyOnly, static_cast<WebIDBDatabase::TaskType>(taskType), new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBDatabaseBackendProxy::count(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->count(transactionId, objectStoreId, indexId, keyRange, new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBDatabaseBackendProxy::get(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange> keyRange, bool keyOnly, PassRefPtr<IDBCallbacks> callbacks)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->get(transactionId, objectStoreId, indexId, keyRange, keyOnly, new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBDatabaseBackendProxy::put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<SharedBuffer> value, PassRefPtr<IDBKey> key, PutMode putMode, PassRefPtr<IDBCallbacks> callbacks, const Vector<int64_t>& indexIds, const Vector<IndexKeys>& indexKeys)
+{
+ if (m_webIDBDatabase) {
+ m_webIDBDatabase->put(transactionId, objectStoreId, WebData(value), key, static_cast<WebIDBDatabase::PutMode>(putMode), new WebIDBCallbacksImpl(callbacks), indexIds, indexKeys);
+ }
+}
+
+void IDBDatabaseBackendProxy::setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBKey> primaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>& indexKeys)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->setIndexKeys(transactionId, objectStoreId, primaryKey, indexIds, indexKeys);
+}
+
+void IDBDatabaseBackendProxy::setIndexesReady(int64_t transactionId, int64_t objectStoreId, const Vector<int64_t>& indexIds)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->setIndexesReady(transactionId, objectStoreId, indexIds);
+}
+
+void IDBDatabaseBackendProxy::deleteRange(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->deleteRange(transactionId, objectStoreId, keyRange, new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBDatabaseBackendProxy::clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBCallbacks> callbacks)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->clear(transactionId, objectStoreId, new WebIDBCallbacksImpl(callbacks));
+}
+
+void IDBDatabaseBackendProxy::createIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId, const String& name, const WebCore::IDBKeyPath& keyPath, bool unique, bool multiEntry)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->createIndex(transactionId, objectStoreId, indexId, name, keyPath, unique, multiEntry);
+}
+
+void IDBDatabaseBackendProxy::deleteIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId)
+{
+ if (m_webIDBDatabase)
+ m_webIDBDatabase->deleteIndex(transactionId, objectStoreId, indexId);
+}
+
+void IDBDatabaseBackendProxy::close(PassRefPtr<IDBDatabaseCallbacks>)
+{
+ m_webIDBDatabase->close();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.h b/chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.h
new file mode 100644
index 00000000000..745da6af5bf
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/IDBDatabaseBackendProxy.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 IDBDatabaseBackendProxy_h
+#define IDBDatabaseBackendProxy_h
+
+#include "modules/indexeddb/IDBDatabaseBackendInterface.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebKit {
+
+class WebIDBDatabase;
+
+class IDBDatabaseBackendProxy : public WebCore::IDBDatabaseBackendInterface {
+public:
+ static PassRefPtr<WebCore::IDBDatabaseBackendInterface> create(PassOwnPtr<WebIDBDatabase>);
+ virtual ~IDBDatabaseBackendProxy();
+
+ virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId, const String& name, const WebCore::IDBKeyPath&, bool autoIncrement);
+ virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId);
+ virtual void createTransaction(int64_t, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const Vector<int64_t>&, unsigned short mode);
+ virtual void close(PassRefPtr<WebCore::IDBDatabaseCallbacks>);
+
+ virtual void commit(int64_t);
+ virtual void abort(int64_t);
+
+ virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<WebCore::IDBKeyRange>, bool keyOnly, PassRefPtr<WebCore::IDBCallbacks>) OVERRIDE;
+ virtual void put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<WebCore::SharedBuffer> value, PassRefPtr<WebCore::IDBKey>, PutMode, PassRefPtr<WebCore::IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
+ virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<WebCore::IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
+ virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, const Vector<int64_t>& indexIds) OVERRIDE;
+ virtual void openCursor(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<WebCore::IDBKeyRange>, WebCore::IndexedDB::CursorDirection, bool keyOnly, TaskType, PassRefPtr<WebCore::IDBCallbacks>) OVERRIDE;
+ virtual void count(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<WebCore::IDBKeyRange>, PassRefPtr<WebCore::IDBCallbacks>) OVERRIDE;
+ virtual void deleteRange(int64_t transactionId, int64_t objectStoreId, PassRefPtr<WebCore::IDBKeyRange>, PassRefPtr<WebCore::IDBCallbacks>) OVERRIDE;
+ virtual void clear(int64_t transactionId, int64_t objectStoreId, PassRefPtr<WebCore::IDBCallbacks>) OVERRIDE;
+
+ virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId, const String& name, const WebCore::IDBKeyPath&, bool unique, bool multiEntry) OVERRIDE;
+ virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId) OVERRIDE;
+
+private:
+ IDBDatabaseBackendProxy(PassOwnPtr<WebIDBDatabase>);
+
+ OwnPtr<WebIDBDatabase> m_webIDBDatabase;
+};
+
+} // namespace WebKit
+
+#endif // IDBDatabaseBackendProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.cpp b/chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.cpp
new file mode 100644
index 00000000000..f665616b98c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebIDBDatabase.h"
+#include "public/platform/WebIDBDatabaseError.h"
+#include "public/platform/WebIDBFactory.h"
+#include "public/platform/WebVector.h"
+#include "IDBDatabaseBackendProxy.h"
+#include "WebFrameImpl.h"
+#include "WebIDBCallbacksImpl.h"
+#include "WebIDBDatabaseCallbacksImpl.h"
+#include "WebKit.h"
+#include "WebPermissionClient.h"
+#include "WebSecurityOrigin.h"
+#include "WebViewImpl.h"
+#include "WebWorkerBase.h"
+#include "WebWorkerClientImpl.h"
+#include "WorkerAllowMainThreadBridgeBase.h"
+#include "bindings/v8/WorkerScriptController.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/dom/DOMError.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "modules/indexeddb/IDBDatabaseCallbacks.h"
+#include "weborigin/SecurityOrigin.h"
+
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendProxy::create()
+{
+ return adoptRef(new IDBFactoryBackendProxy());
+}
+
+IDBFactoryBackendProxy::IDBFactoryBackendProxy()
+{
+ m_webIDBFactory = WebKit::Platform::current()->idbFactory();
+}
+
+IDBFactoryBackendProxy::~IDBFactoryBackendProxy()
+{
+}
+
+static const char allowIndexedDBMode[] = "allowIndexedDBMode";
+
+class AllowIndexedDBMainThreadBridge : public WorkerAllowMainThreadBridgeBase {
+public:
+ static PassRefPtr<AllowIndexedDBMainThreadBridge> create(WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, const String& name)
+ {
+ return adoptRef(new AllowIndexedDBMainThreadBridge(workerGlobalScope, webWorkerBase, mode, name));
+ }
+
+private:
+ class AllowIDBParams : public AllowParams
+ {
+ public:
+ AllowIDBParams(const String& mode, const String& name)
+ : AllowParams(mode)
+ , m_name(name.isolatedCopy())
+ {
+ }
+ String m_name;
+ };
+
+ AllowIndexedDBMainThreadBridge(WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode, const String& name)
+ : WorkerAllowMainThreadBridgeBase(workerGlobalScope, webWorkerBase)
+ {
+ postTaskToMainThread(adoptPtr(new AllowIDBParams(mode, name)));
+ }
+
+ virtual bool allowOnMainThread(WebCommonWorkerClient* commonClient, AllowParams* params)
+ {
+ ASSERT(isMainThread());
+ AllowIDBParams* allowIDBParams = static_cast<AllowIDBParams*>(params);
+ return commonClient->allowIndexedDB(allowIDBParams->m_name);
+ }
+};
+
+bool IDBFactoryBackendProxy::allowIndexedDB(ScriptExecutionContext* context, const String& name, const WebSecurityOrigin& origin, PassRefPtr<IDBCallbacks> callbacks)
+{
+ bool allowed;
+ ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument() || context->isWorkerGlobalScope());
+ if (context->isDocument()) {
+ Document* document = toDocument(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ WebViewImpl* webView = webFrame->viewImpl();
+ // FIXME: webView->permissionClient() returns 0 in test_shell and content_shell http://crbug.com/137269
+ allowed = !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(webFrame, name, origin);
+ } else {
+ WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
+ WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase());
+ WorkerRunLoop& runLoop = workerGlobalScope->thread()->runLoop();
+
+ String mode = allowIndexedDBMode;
+ mode.append(String::number(runLoop.createUniqueId()));
+ RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThreadBridge::create(workerGlobalScope, webWorkerBase, mode, name);
+
+ // Either the bridge returns, or the queue gets terminated.
+ if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated) {
+ bridge->cancel();
+ return false;
+ }
+ allowed = bridge->result();
+ }
+
+ if (!allowed)
+ callbacks->onError(WebIDBDatabaseError(UnknownError, "The user denied permission to access the database."));
+
+ return allowed;
+}
+
+void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBCallbacks> prpCallbacks, const String& databaseIdentifier, ScriptExecutionContext* context)
+{
+ RefPtr<IDBCallbacks> callbacks(prpCallbacks);
+ WebSecurityOrigin origin(context->securityOrigin());
+ if (!allowIndexedDB(context, "Database Listing", origin, callbacks))
+ return;
+
+ m_webIDBFactory->getDatabaseNames(new WebIDBCallbacksImpl(callbacks), databaseIdentifier);
+}
+
+void IDBFactoryBackendProxy::open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, const String& databaseIdentifier, ScriptExecutionContext* context)
+{
+ RefPtr<IDBCallbacks> callbacks(prpCallbacks);
+ RefPtr<IDBDatabaseCallbacks> databaseCallbacks(prpDatabaseCallbacks);
+ WebSecurityOrigin origin(context->securityOrigin());
+ if (!allowIndexedDB(context, name, origin, callbacks))
+ return;
+
+ m_webIDBFactory->open(name, version, transactionId, new WebIDBCallbacksImpl(callbacks), new WebIDBDatabaseCallbacksImpl(databaseCallbacks), databaseIdentifier);
+}
+
+void IDBFactoryBackendProxy::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, const String& databaseIdentifier, ScriptExecutionContext* context)
+{
+ RefPtr<IDBCallbacks> callbacks(prpCallbacks);
+ WebSecurityOrigin origin(context->securityOrigin());
+ if (!allowIndexedDB(context, name, origin, callbacks))
+ return;
+
+ m_webIDBFactory->deleteDatabase(name, new WebIDBCallbacksImpl(callbacks), databaseIdentifier);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.h b/chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.h
new file mode 100644
index 00000000000..2c9eb602e55
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/IDBFactoryBackendProxy.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "modules/indexeddb/chromium/IDBFactoryBackendInterfaceChromium.h"
+#include "modules/indexeddb/IDBCallbacks.h"
+
+namespace WebCore {
+class ScriptExecutionContext;
+}
+
+namespace WebKit {
+
+class WebIDBFactory;
+class WebSecurityOrigin;
+
+class IDBFactoryBackendProxy : public WebCore::IDBFactoryBackendInterface {
+public:
+ static PassRefPtr<WebCore::IDBFactoryBackendInterface> create();
+ virtual ~IDBFactoryBackendProxy();
+
+ virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, const String& databaseIdentifier, WebCore::ScriptExecutionContext*) OVERRIDE;
+ virtual void open(const String& name, int64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const String& databaseIdentifier, WebCore::ScriptExecutionContext*) OVERRIDE;
+ virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, const String& databaseIdentifier, WebCore::ScriptExecutionContext*) OVERRIDE;
+
+private:
+ IDBFactoryBackendProxy();
+ bool allowIndexedDB(WebCore::ScriptExecutionContext*, const String& name, const WebSecurityOrigin&, PassRefPtr<WebCore::IDBCallbacks>);
+
+ // We don't own this pointer (unlike all the other proxy classes which do).
+ WebIDBFactory* m_webIDBFactory;
+};
+
+} // namespace WebKit
+
+#endif // IDBFactoryBackendProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.cpp b/chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.cpp
new file mode 100644
index 00000000000..29db76e7e1e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "InbandTextTrackPrivateImpl.h"
+#include "WebInbandTextTrack.h"
+#include "core/platform/graphics/InbandTextTrackPrivateClient.h"
+#include "public/platform/WebString.h"
+
+namespace WebKit {
+
+InbandTextTrackPrivateImpl::InbandTextTrackPrivateImpl(WebInbandTextTrack* track)
+ : m_track(track)
+{
+ ASSERT(track);
+ track->setClient(this);
+}
+
+InbandTextTrackPrivateImpl::~InbandTextTrackPrivateImpl()
+{
+ m_track->setClient(0);
+}
+
+void InbandTextTrackPrivateImpl::setMode(Mode mode)
+{
+ m_track->setMode(static_cast<WebInbandTextTrack::Mode>(mode));
+}
+
+WebCore::InbandTextTrackPrivate::Mode InbandTextTrackPrivateImpl::mode() const
+{
+ return static_cast<WebCore::InbandTextTrackPrivate::Mode>(m_track->mode());
+}
+
+WebCore::InbandTextTrackPrivate::Kind InbandTextTrackPrivateImpl::kind() const
+{
+ return static_cast<WebCore::InbandTextTrackPrivate::Kind>(m_track->kind());
+}
+
+bool InbandTextTrackPrivateImpl::isClosedCaptions() const
+{
+ return m_track->isClosedCaptions();
+}
+
+AtomicString InbandTextTrackPrivateImpl::label() const
+{
+ return m_track->label();
+}
+
+AtomicString InbandTextTrackPrivateImpl::language() const
+{
+ return m_track->language();
+}
+
+bool InbandTextTrackPrivateImpl::isDefault() const
+{
+ return m_track->isDefault();
+}
+
+int InbandTextTrackPrivateImpl::textTrackIndex() const
+{
+ return m_track->textTrackIndex();
+}
+
+void InbandTextTrackPrivateImpl::addWebVTTCue(
+ double start,
+ double end,
+ const WebString& id,
+ const WebString& content,
+ const WebString& settings)
+{
+ client()->addWebVTTCue(this, start, end, id, content, settings);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.h b/chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.h
new file mode 100644
index 00000000000..eb3cd725563
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/InbandTextTrackPrivateImpl.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 InbandTextTrackPrivateImpl_h
+#define InbandTextTrackPrivateImpl_h
+
+#include "core/platform/graphics/InbandTextTrackPrivate.h"
+#include "WebInbandTextTrackClient.h"
+
+namespace WebCore {
+class InbandTextTrackPrivateClient;
+}
+
+namespace WebKit {
+
+class WebInbandTextTrack;
+
+class InbandTextTrackPrivateImpl : public WebCore::InbandTextTrackPrivate,
+ public WebInbandTextTrackClient {
+public:
+ explicit InbandTextTrackPrivateImpl(WebInbandTextTrack*);
+ virtual ~InbandTextTrackPrivateImpl();
+
+ // InbandTextTrackPrivate methods.
+ virtual void setMode(Mode);
+ virtual InbandTextTrackPrivate::Mode mode() const;
+
+ virtual Kind kind() const;
+ virtual bool isClosedCaptions() const;
+
+ virtual AtomicString label() const;
+ virtual AtomicString language() const;
+ virtual bool isDefault() const;
+
+ virtual int textTrackIndex() const;
+
+ // WebInbandTextTrackClient methods.
+ virtual void addWebVTTCue(double start,
+ double end,
+ const WebString& id,
+ const WebString& content,
+ const WebString& settings);
+
+private:
+ WebInbandTextTrack* m_track;
+};
+
+}
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/InspectorClientImpl.cpp b/chromium/third_party/WebKit/Source/web/InspectorClientImpl.cpp
new file mode 100644
index 00000000000..dc24218743f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/InspectorClientImpl.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 "InspectorClientImpl.h"
+
+#include "WebDevToolsAgentImpl.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/page/DOMWindow.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/NotImplemented.h"
+#include "core/platform/graphics/FloatRect.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLRequest.h"
+#include "wtf/Vector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
+ : m_inspectedWebView(webView)
+{
+ ASSERT(m_inspectedWebView);
+}
+
+InspectorClientImpl::~InspectorClientImpl()
+{
+}
+
+void InspectorClientImpl::highlight()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->highlight();
+}
+
+void InspectorClientImpl::hideHighlight()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->hideHighlight();
+}
+
+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);
+}
+
+void InspectorClientImpl::clearBrowserCache()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->clearBrowserCache();
+}
+
+void InspectorClientImpl::clearBrowserCookies()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->clearBrowserCookies();
+}
+
+void InspectorClientImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->overrideDeviceMetrics(width, height, fontScaleFactor, fitWindow);
+}
+
+void InspectorClientImpl::autoZoomPageToFitWidth()
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->autoZoomPageToFitWidth();
+}
+
+bool InspectorClientImpl::overridesShowPaintRects()
+{
+ return m_inspectedWebView->isAcceleratedCompositingActive();
+}
+
+void InspectorClientImpl::setShowPaintRects(bool show)
+{
+ m_inspectedWebView->setShowPaintRects(show);
+}
+
+void InspectorClientImpl::setShowDebugBorders(bool show)
+{
+ m_inspectedWebView->setShowDebugBorders(show);
+}
+
+void InspectorClientImpl::setShowFPSCounter(bool show)
+{
+ m_inspectedWebView->setShowFPSCounter(show);
+}
+
+void InspectorClientImpl::setContinuousPaintingEnabled(bool enabled)
+{
+ m_inspectedWebView->setContinuousPaintingEnabled(enabled);
+}
+
+void InspectorClientImpl::setShowScrollBottleneckRects(bool show)
+{
+ m_inspectedWebView->setShowScrollBottleneckRects(show);
+}
+
+void InspectorClientImpl::getAllocatedObjects(HashSet<const void*>& set)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->getAllocatedObjects(set);
+}
+
+void InspectorClientImpl::dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>& map)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->dumpUncountedAllocatedObjects(map);
+}
+
+void InspectorClientImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->dispatchKeyEvent(event);
+}
+
+void InspectorClientImpl::dispatchMouseEvent(const PlatformMouseEvent& event)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->dispatchMouseEvent(event);
+}
+
+void InspectorClientImpl::setTraceEventCallback(TraceEventCallback callback)
+{
+ if (WebDevToolsAgentImpl* agent = devToolsAgent())
+ agent->setTraceEventCallback(callback);
+}
+
+WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
+{
+ return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/InspectorClientImpl.h b/chromium/third_party/WebKit/Source/web/InspectorClientImpl.h
new file mode 100644
index 00000000000..692d6423750
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/InspectorClientImpl.h
@@ -0,0 +1,89 @@
+/*
+ * 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 "core/inspector/InspectorClient.h"
+#include "core/inspector/InspectorController.h"
+#include "core/inspector/InspectorFrontendChannel.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebKit {
+
+class WebDevToolsAgentClient;
+class WebDevToolsAgentImpl;
+class WebViewImpl;
+
+class InspectorClientImpl : public WebCore::InspectorClient,
+ public WebCore::InspectorFrontendChannel {
+public:
+ explicit InspectorClientImpl(WebViewImpl*);
+ ~InspectorClientImpl();
+
+ // InspectorClient methods:
+ virtual void highlight();
+ virtual void hideHighlight();
+
+ virtual bool sendMessageToFrontend(const WTF::String&);
+
+ virtual void updateInspectorStateCookie(const WTF::String&);
+
+ virtual void clearBrowserCache();
+ virtual void clearBrowserCookies();
+
+ virtual void overrideDeviceMetrics(int, int, float, bool);
+ virtual void autoZoomPageToFitWidth();
+
+ virtual bool overridesShowPaintRects();
+ virtual void setShowPaintRects(bool);
+ virtual void setShowDebugBorders(bool);
+ virtual void setShowFPSCounter(bool);
+ virtual void setContinuousPaintingEnabled(bool);
+ virtual void setShowScrollBottleneckRects(bool);
+
+ virtual void getAllocatedObjects(HashSet<const void*>&);
+ virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&);
+
+ virtual void dispatchKeyEvent(const WebCore::PlatformKeyboardEvent&);
+ virtual void dispatchMouseEvent(const WebCore::PlatformMouseEvent&);
+
+ virtual void setTraceEventCallback(TraceEventCallback);
+
+private:
+ WebDevToolsAgentImpl* devToolsAgent();
+
+ // The WebViewImpl of the page being inspected; gets passed to the constructor
+ WebViewImpl* m_inspectedWebView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.cpp b/chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.cpp
new file mode 100644
index 00000000000..c5ebdab8cd9
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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 "V8InspectorFrontendHost.h"
+#include "WebDevToolsFrontendClient.h"
+#include "WebDevToolsFrontendImpl.h"
+#include "bindings/v8/ScriptController.h"
+#include "core/dom/Document.h"
+#include "core/inspector/InspectorFrontendHost.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/platform/NotImplemented.h"
+#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebString.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+InspectorFrontendClientImpl::InspectorFrontendClientImpl(Page* frontendPage, WebDevToolsFrontendClient* client, WebDevToolsFrontendImpl* frontend)
+ : m_frontendPage(frontendPage)
+ , m_client(client)
+{
+}
+
+InspectorFrontendClientImpl::~InspectorFrontendClientImpl()
+{
+ if (m_frontendHost)
+ m_frontendHost->disconnectClient();
+ m_client = 0;
+}
+
+void InspectorFrontendClientImpl::windowObjectCleared()
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> frameContext = m_frontendPage->mainFrame() ? m_frontendPage->mainFrame()->script()->currentWorldContext() : v8::Local<v8::Context>();
+ v8::Context::Scope contextScope(frameContext);
+
+ if (m_frontendHost)
+ m_frontendHost->disconnectClient();
+ m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage);
+ v8::Handle<v8::Value> frontendHostObj = toV8(m_frontendHost.get(), v8::Handle<v8::Object>(), frameContext->GetIsolate());
+ v8::Handle<v8::Object> global = frameContext->Global();
+
+ global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj);
+}
+
+void InspectorFrontendClientImpl::moveWindowBy(float x, float y)
+{
+ m_client->moveWindowBy(WebFloatPoint(x, y));
+}
+
+void InspectorFrontendClientImpl::bringToFront()
+{
+ m_client->activateWindow();
+}
+
+void InspectorFrontendClientImpl::closeWindow()
+{
+ m_client->closeWindow();
+}
+
+void InspectorFrontendClientImpl::requestSetDockSide(DockSide side)
+{
+ String sideString = "undocked";
+ switch (side) {
+ case DockedToRight: sideString = "right"; break;
+ case DockedToBottom: sideString = "bottom"; break;
+ case Undocked: sideString = "undocked"; break;
+ }
+ m_client->requestSetDockSide(sideString);
+}
+
+void InspectorFrontendClientImpl::changeAttachedWindowHeight(unsigned height)
+{
+ m_client->changeAttachedWindowHeight(height);
+}
+
+void InspectorFrontendClientImpl::openInNewTab(const String& url)
+{
+ m_client->openInNewTab(url);
+}
+
+void InspectorFrontendClientImpl::save(const String& url, const String& content, bool forceSaveAs)
+{
+ m_client->save(url, content, forceSaveAs);
+}
+
+void InspectorFrontendClientImpl::append(const String& url, const String& content)
+{
+ m_client->append(url, content);
+}
+
+void InspectorFrontendClientImpl::inspectedURLChanged(const String& url)
+{
+ m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url);
+}
+
+void InspectorFrontendClientImpl::sendMessageToBackend(const String& message)
+{
+ m_client->sendMessageToBackend(message);
+}
+
+void InspectorFrontendClientImpl::requestFileSystems()
+{
+ m_client->requestFileSystems();
+}
+
+void InspectorFrontendClientImpl::indexPath(int requestId, const String& fileSystemPath)
+{
+ m_client->indexPath(requestId, fileSystemPath);
+}
+
+void InspectorFrontendClientImpl::stopIndexing(int requestId)
+{
+ m_client->stopIndexing(requestId);
+}
+
+void InspectorFrontendClientImpl::searchInPath(int requestId, const String& fileSystemPath, const String& query)
+{
+ m_client->searchInPath(requestId, fileSystemPath, query);
+}
+
+void InspectorFrontendClientImpl::addFileSystem()
+{
+ m_client->addFileSystem();
+}
+
+void InspectorFrontendClientImpl::removeFileSystem(const String& fileSystemPath)
+{
+ m_client->removeFileSystem(fileSystemPath);
+}
+
+bool InspectorFrontendClientImpl::isUnderTest()
+{
+ return m_client->isUnderTest();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.h b/chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.h
new file mode 100644
index 00000000000..2f9c0c48e57
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/InspectorFrontendClientImpl.h
@@ -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.
+ */
+
+#ifndef InspectorFrontendClientImpl_h
+#define InspectorFrontendClientImpl_h
+
+#include "core/inspector/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 moveWindowBy(float x, float y);
+
+ virtual void bringToFront();
+ virtual void closeWindow();
+
+ virtual void requestSetDockSide(DockSide);
+ virtual void changeAttachedWindowHeight(unsigned);
+
+ virtual void openInNewTab(const String& url);
+
+ virtual void save(const WTF::String& urk, const WTF::String& content, bool forceSaveAs);
+ virtual void append(const WTF::String& urk, const WTF::String& content);
+
+ virtual void inspectedURLChanged(const WTF::String&);
+
+ virtual void sendMessageToBackend(const WTF::String&);
+
+ virtual void requestFileSystems();
+ virtual void addFileSystem();
+ virtual void removeFileSystem(const String& fileSystemPath);
+ virtual void indexPath(int requestId, const String& fileSystemPath);
+ virtual void stopIndexing(int requestId);
+ virtual void searchInPath(int requestId, const String& fileSystemPath, const String& query);
+
+ virtual bool isUnderTest();
+
+private:
+ WebCore::Page* m_frontendPage;
+ WebDevToolsFrontendClient* m_client;
+ RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/LinkHighlight.cpp b/chromium/third_party/WebKit/Source/web/LinkHighlight.cpp
new file mode 100644
index 00000000000..213d3d94943
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/LinkHighlight.cpp
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "LinkHighlight.h"
+
+#include "SkMatrix44.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebViewImpl.h"
+#include "core/dom/Node.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/platform/graphics/Color.h"
+#include "core/rendering/RenderLayer.h"
+#include "core/rendering/RenderLayerBacking.h"
+#include "core/rendering/RenderLayerModelObject.h"
+#include "core/rendering/RenderObject.h"
+#include "core/rendering/RenderView.h"
+#include "core/rendering/style/ShadowData.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebAnimationCurve.h"
+#include "public/platform/WebCompositorSupport.h"
+#include "public/platform/WebFloatAnimationCurve.h"
+#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebSize.h"
+#include "wtf/CurrentTime.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebViewImpl;
+
+PassOwnPtr<LinkHighlight> LinkHighlight::create(Node* node, WebViewImpl* owningWebViewImpl)
+{
+ return adoptPtr(new LinkHighlight(node, owningWebViewImpl));
+}
+
+LinkHighlight::LinkHighlight(Node* node, WebViewImpl* owningWebViewImpl)
+ : m_node(node)
+ , m_owningWebViewImpl(owningWebViewImpl)
+ , m_currentGraphicsLayer(0)
+ , m_geometryNeedsUpdate(false)
+ , m_isAnimating(false)
+ , m_startTime(monotonicallyIncreasingTime())
+{
+ ASSERT(m_node);
+ ASSERT(owningWebViewImpl);
+ WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport();
+ m_contentLayer = adoptPtr(compositorSupport->createContentLayer(this));
+ m_clipLayer = adoptPtr(compositorSupport->createLayer());
+ m_clipLayer->setAnchorPoint(WebFloatPoint());
+ m_clipLayer->addChild(m_contentLayer->layer());
+ m_contentLayer->layer()->setAnimationDelegate(this);
+ m_contentLayer->layer()->setDrawsContent(true);
+ m_contentLayer->layer()->setOpacity(1);
+ m_geometryNeedsUpdate = true;
+ updateGeometry();
+}
+
+LinkHighlight::~LinkHighlight()
+{
+ clearGraphicsLayerLinkHighlightPointer();
+ releaseResources();
+}
+
+WebContentLayer* LinkHighlight::contentLayer()
+{
+ return m_contentLayer.get();
+}
+
+WebLayer* LinkHighlight::clipLayer()
+{
+ return m_clipLayer.get();
+}
+
+void LinkHighlight::releaseResources()
+{
+ m_node.clear();
+}
+
+RenderLayer* LinkHighlight::computeEnclosingCompositingLayer()
+{
+ if (!m_node || !m_node->renderer())
+ return 0;
+
+ // Find the nearest enclosing composited layer and attach to it. We may need to cross frame boundaries
+ // to find a suitable layer.
+ RenderLayerModelObject* renderer = toRenderLayerModelObject(m_node->renderer());
+ RenderLayerModelObject* repaintContainer;
+ do {
+ repaintContainer = renderer->containerForRepaint();
+ if (!repaintContainer) {
+ renderer = renderer->frame()->ownerRenderer();
+ if (!renderer)
+ return 0;
+ }
+ } while (!repaintContainer);
+ RenderLayer* renderLayer = repaintContainer->layer();
+
+ if (!renderLayer || !renderLayer->isComposited())
+ return 0;
+
+ GraphicsLayer* newGraphicsLayer = renderLayer->backing()->graphicsLayer();
+ m_clipLayer->setSublayerTransform(SkMatrix44());
+
+ if (!newGraphicsLayer->drawsContent()) {
+ if (renderLayer->usesCompositedScrolling()) {
+ ASSERT(renderLayer->backing() && renderLayer->backing()->scrollingContentsLayer());
+ newGraphicsLayer = renderLayer->backing()->scrollingContentsLayer();
+ } else
+ ASSERT_NOT_REACHED();
+ }
+
+ if (m_currentGraphicsLayer != newGraphicsLayer) {
+ if (m_currentGraphicsLayer)
+ clearGraphicsLayerLinkHighlightPointer();
+
+ m_currentGraphicsLayer = newGraphicsLayer;
+ m_currentGraphicsLayer->setLinkHighlight(this);
+ }
+
+ return renderLayer;
+}
+
+static void convertTargetSpaceQuadToCompositedLayer(const FloatQuad& targetSpaceQuad, RenderObject* targetRenderer, RenderObject* compositedRenderer, FloatQuad& compositedSpaceQuad)
+{
+ ASSERT(targetRenderer);
+ ASSERT(compositedRenderer);
+
+ for (unsigned i = 0; i < 4; ++i) {
+ IntPoint point;
+ switch (i) {
+ case 0: point = roundedIntPoint(targetSpaceQuad.p1()); break;
+ case 1: point = roundedIntPoint(targetSpaceQuad.p2()); break;
+ case 2: point = roundedIntPoint(targetSpaceQuad.p3()); break;
+ case 3: point = roundedIntPoint(targetSpaceQuad.p4()); break;
+ }
+
+ point = targetRenderer->frame()->view()->contentsToWindow(point);
+ point = compositedRenderer->frame()->view()->windowToContents(point);
+ FloatPoint floatPoint = compositedRenderer->absoluteToLocal(point, UseTransforms);
+
+ switch (i) {
+ case 0: compositedSpaceQuad.setP1(floatPoint); break;
+ case 1: compositedSpaceQuad.setP2(floatPoint); break;
+ case 2: compositedSpaceQuad.setP3(floatPoint); break;
+ case 3: compositedSpaceQuad.setP4(floatPoint); break;
+ }
+ }
+}
+
+static void addQuadToPath(const FloatQuad& quad, Path& path)
+{
+ // FIXME: Make this create rounded quad-paths, just like the axis-aligned case.
+ path.moveTo(quad.p1());
+ path.addLineTo(quad.p2());
+ path.addLineTo(quad.p3());
+ path.addLineTo(quad.p4());
+ path.closeSubpath();
+}
+
+bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositingLayer)
+{
+ if (!m_node || !m_node->renderer())
+ return false;
+
+ ASSERT(compositingLayer);
+
+ // Get quads for node in absolute coordinates.
+ Vector<FloatQuad> quads;
+ m_node->renderer()->absoluteQuads(quads);
+ ASSERT(quads.size());
+
+ // Adjust for offset between target graphics layer and the node's renderer.
+ FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRenderer());
+
+ Path newPath;
+ for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
+ FloatQuad absoluteQuad = quads[quadIndex];
+ absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y());
+
+ // Transform node quads in target absolute coords to local coordinates in the compositor layer.
+ FloatQuad transformedQuad;
+ convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->renderer(), compositingLayer->renderer(), transformedQuad);
+
+ // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that
+ // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage
+ // links: these should ideally be merged into a single rect before creating the path, but that's
+ // another CL.
+ if (quads.size() == 1 && transformedQuad.isRectilinear()) {
+ FloatSize rectRoundingRadii(3, 3);
+ newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRadii);
+ } else
+ addQuadToPath(transformedQuad, newPath);
+ }
+
+ FloatRect boundingRect = newPath.boundingRect();
+ newPath.translate(-toFloatSize(boundingRect.location()));
+
+ bool pathHasChanged = !(newPath == m_path);
+ if (pathHasChanged) {
+ m_path = newPath;
+ m_contentLayer->layer()->setBounds(enclosingIntRect(boundingRect).size());
+ }
+
+ m_contentLayer->layer()->setPosition(boundingRect.location());
+
+ return pathHasChanged;
+}
+
+void LinkHighlight::paintContents(WebCanvas* canvas, const WebRect& webClipRect, bool, WebFloatRect&)
+{
+ if (!m_node || !m_node->renderer())
+ return;
+
+ GraphicsContext gc(canvas);
+ IntRect clipRect(IntPoint(webClipRect.x, webClipRect.y), IntSize(webClipRect.width, webClipRect.height));
+ gc.clip(clipRect);
+ gc.setFillColor(m_node->renderer()->resolveColor(CSSPropertyWebkitTapHighlightColor));
+ gc.fillPath(m_path);
+}
+
+void LinkHighlight::startHighlightAnimationIfNeeded()
+{
+ if (m_isAnimating)
+ return;
+
+ m_isAnimating = true;
+ const float startOpacity = 1;
+ // FIXME: Should duration be configurable?
+ const float fadeDuration = 0.1f;
+ const float minPreFadeDuration = 0.1f;
+
+ m_contentLayer->layer()->setOpacity(startOpacity);
+
+ WebCompositorSupport* compositorSupport = Platform::current()->compositorSupport();
+
+ OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(compositorSupport->createFloatAnimationCurve());
+
+ curve->add(WebFloatKeyframe(0, startOpacity));
+ // Make sure we have displayed for at least minPreFadeDuration before starting to fade out.
+ float extraDurationRequired = std::max(0.f, minPreFadeDuration - static_cast<float>(monotonicallyIncreasingTime() - m_startTime));
+ if (extraDurationRequired)
+ curve->add(WebFloatKeyframe(extraDurationRequired, startOpacity));
+ // For layout tests we don't fade out.
+ curve->add(WebFloatKeyframe(fadeDuration + extraDurationRequired, WebKit::layoutTestMode() ? startOpacity : 0));
+
+ m_animation = adoptPtr(compositorSupport->createAnimation(*curve, WebAnimation::TargetPropertyOpacity));
+
+ m_contentLayer->layer()->setDrawsContent(true);
+ m_contentLayer->layer()->addAnimation(m_animation.get());
+
+ invalidate();
+ m_owningWebViewImpl->scheduleAnimation();
+}
+
+void LinkHighlight::clearGraphicsLayerLinkHighlightPointer()
+{
+ if (m_currentGraphicsLayer) {
+ m_currentGraphicsLayer->setLinkHighlight(0);
+ m_currentGraphicsLayer = 0;
+ }
+}
+
+void LinkHighlight::notifyAnimationStarted(double)
+{
+}
+
+void LinkHighlight::notifyAnimationFinished(double)
+{
+ // Since WebViewImpl may hang on to us for a while, make sure we
+ // release resources as soon as possible.
+ clearGraphicsLayerLinkHighlightPointer();
+ releaseResources();
+}
+
+void LinkHighlight::updateGeometry()
+{
+ // To avoid unnecessary updates (e.g. other entities have requested animations from our WebViewImpl),
+ // only proceed if we actually requested an update.
+ if (!m_geometryNeedsUpdate)
+ return;
+
+ m_geometryNeedsUpdate = false;
+
+ RenderLayer* compositingLayer = computeEnclosingCompositingLayer();
+ if (compositingLayer && computeHighlightLayerPathAndPosition(compositingLayer)) {
+ // We only need to invalidate the layer if the highlight size has changed, otherwise
+ // we can just re-position the layer without needing to repaint.
+ m_contentLayer->layer()->invalidate();
+
+ if (m_currentGraphicsLayer)
+ m_currentGraphicsLayer->addRepaintRect(FloatRect(layer()->position().x, layer()->position().y, layer()->bounds().width, layer()->bounds().height));
+ } else if (!m_node || !m_node->renderer()) {
+ clearGraphicsLayerLinkHighlightPointer();
+ releaseResources();
+ }
+}
+
+void LinkHighlight::clearCurrentGraphicsLayer()
+{
+ m_currentGraphicsLayer = 0;
+ m_geometryNeedsUpdate = true;
+}
+
+void LinkHighlight::invalidate()
+{
+ // Make sure we update geometry on the next callback from WebViewImpl::layout().
+ m_geometryNeedsUpdate = true;
+}
+
+WebLayer* LinkHighlight::layer()
+{
+ return clipLayer();
+}
+
+} // namespace WeKit
diff --git a/chromium/third_party/WebKit/Source/web/LinkHighlight.h b/chromium/third_party/WebKit/Source/web/LinkHighlight.h
new file mode 100644
index 00000000000..0bd1668e7c1
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/LinkHighlight.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 LinkHighlight_h
+#define LinkHighlight_h
+
+#include "core/platform/graphics/FloatPoint.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/platform/graphics/IntPoint.h"
+#include "core/platform/graphics/Path.h"
+#include "public/platform/WebAnimationDelegate.h"
+#include "public/platform/WebContentLayer.h"
+#include "public/platform/WebContentLayerClient.h"
+#include "public/platform/WebLayer.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebCore {
+class RenderLayer;
+class Node;
+}
+
+namespace WebKit {
+
+struct WebFloatRect;
+struct WebRect;
+class WebViewImpl;
+
+class LinkHighlight : public WebContentLayerClient, public WebAnimationDelegate, WebCore::LinkHighlightClient {
+public:
+ static PassOwnPtr<LinkHighlight> create(WebCore::Node*, WebViewImpl*);
+ virtual ~LinkHighlight();
+
+ WebContentLayer* contentLayer();
+ WebLayer* clipLayer();
+ void startHighlightAnimationIfNeeded();
+ void updateGeometry();
+
+ // WebContentLayerClient implementation.
+ virtual void paintContents(WebCanvas*, const WebRect& clipRect, bool canPaintLCDText, WebFloatRect& opaque) OVERRIDE;
+
+ // WebAnimationDelegate implementation.
+ virtual void notifyAnimationStarted(double time) OVERRIDE;
+ virtual void notifyAnimationFinished(double time) OVERRIDE;
+
+ // LinkHighlightClient inplementation.
+ virtual void invalidate() OVERRIDE;
+ virtual WebLayer* layer() OVERRIDE;
+ virtual void clearCurrentGraphicsLayer() OVERRIDE;
+
+ WebCore::GraphicsLayer* currentGraphicsLayerForTesting() const { return m_currentGraphicsLayer; }
+
+private:
+ LinkHighlight(WebCore::Node*, WebViewImpl*);
+
+ void releaseResources();
+
+ WebCore::RenderLayer* computeEnclosingCompositingLayer();
+ void clearGraphicsLayerLinkHighlightPointer();
+ // This function computes the highlight path, and returns true if it has changed
+ // size since the last call to this function.
+ bool computeHighlightLayerPathAndPosition(WebCore::RenderLayer*);
+
+ OwnPtr<WebContentLayer> m_contentLayer;
+ OwnPtr<WebLayer> m_clipLayer;
+ WebCore::Path m_path;
+
+ RefPtr<WebCore::Node> m_node;
+ OwnPtr<WebAnimation> m_animation;
+ WebViewImpl* m_owningWebViewImpl;
+ WebCore::GraphicsLayer* m_currentGraphicsLayer;
+
+ bool m_geometryNeedsUpdate;
+ bool m_isAnimating;
+ double m_startTime;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/LocalFileSystemClient.cpp b/chromium/third_party/WebKit/Source/web/LocalFileSystemClient.cpp
new file mode 100644
index 00000000000..47e65efaea7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/LocalFileSystemClient.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "LocalFileSystemClient.h"
+
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebFrameImpl.h"
+#include "WebViewImpl.h"
+#include "core/dom/Document.h"
+#include "core/platform/AsyncFileSystemCallbacks.h"
+#include "public/platform/WebFileError.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemType.h"
+#include "public/web/WebFrameClient.h"
+#include "public/web/WebPermissionClient.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<FileSystemClient> LocalFileSystemClient::create()
+{
+ return adoptPtr(static_cast<FileSystemClient*>(new LocalFileSystemClient()));
+}
+
+LocalFileSystemClient::~LocalFileSystemClient()
+{
+}
+
+bool LocalFileSystemClient::allowFileSystem(ScriptExecutionContext* context)
+{
+ Document* document = toDocument(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ WebKit::WebViewImpl* webView = webFrame->viewImpl();
+
+ return !webView->permissionClient() || webView->permissionClient()->allowFileSystem(webFrame);
+}
+
+void LocalFileSystemClient::openFileSystem(ScriptExecutionContext* context, WebCore::FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType, long long size, OpenFileSystemMode openMode)
+{
+ Document* document = toDocument(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+
+ webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystemType>(type), size, openMode == CreateFileSystemIfNotPresent, new WebFileSystemCallbacksImpl(callbacks));
+}
+
+void LocalFileSystemClient::deleteFileSystem(ScriptExecutionContext* context, WebCore::FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ Document* document = toDocument(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+
+ webFrame->client()->deleteFileSystem(webFrame, static_cast<WebFileSystemType>(type), new WebFileSystemCallbacksImpl(callbacks));
+}
+
+LocalFileSystemClient::LocalFileSystemClient()
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/LocalFileSystemClient.h b/chromium/third_party/WebKit/Source/web/LocalFileSystemClient.h
new file mode 100644
index 00000000000..48014ce5d60
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/LocalFileSystemClient.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 LocalFileSystemClient_h
+#define LocalFileSystemClient_h
+
+#include "modules/filesystem/FileSystemClient.h"
+#include "wtf/Forward.h"
+
+namespace WebKit {
+
+class LocalFileSystemClient : public WebCore::FileSystemClient {
+public:
+ static PassOwnPtr<FileSystemClient> create();
+
+ virtual ~LocalFileSystemClient();
+
+ virtual bool allowFileSystem(WebCore::ScriptExecutionContext*) OVERRIDE;
+ virtual void openFileSystem(WebCore::ScriptExecutionContext*, WebCore::FileSystemType, PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::FileSystemSynchronousType, long long size, WebCore::OpenFileSystemMode) OVERRIDE;
+ virtual void deleteFileSystem(WebCore::ScriptExecutionContext*, WebCore::FileSystemType, PassOwnPtr<WebCore::AsyncFileSystemCallbacks>) OVERRIDE;
+
+private:
+ LocalFileSystemClient();
+};
+
+} // namespace WebKit
+
+#endif // LocalFileSystemClient_h
diff --git a/chromium/third_party/WebKit/Source/web/MIDIClientImpl.cpp b/chromium/third_party/WebKit/Source/web/MIDIClientImpl.cpp
new file mode 100644
index 00000000000..70369bf4418
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/MIDIClientImpl.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "MIDIClientImpl.h"
+
+#include "WebMIDIClient.h"
+#include "WebMIDIPermissionRequest.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "modules/webmidi/MIDIAccess.h"
+#include "wtf/RefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+MIDIClientImpl::MIDIClientImpl(WebViewImpl* webView)
+ : m_client(webView->client() ? webView->client()->webMIDIClient() : 0)
+{
+}
+
+void MIDIClientImpl::requestSysExPermission(PassRefPtr<MIDIAccess> access)
+{
+ if (m_client)
+ m_client->requestSysExPermission(WebMIDIPermissionRequest(access));
+ else
+ access->setSysExEnabled(false);
+}
+
+void MIDIClientImpl::cancelSysExPermissionRequest(MIDIAccess* access)
+{
+ if (m_client)
+ m_client->cancelSysExPermissionRequest(WebMIDIPermissionRequest(access));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/MIDIClientImpl.h b/chromium/third_party/WebKit/Source/web/MIDIClientImpl.h
new file mode 100644
index 00000000000..47433f7b46a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/MIDIClientImpl.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 MIDIClientImpl_h
+#define MIDIClientImpl_h
+
+#include "modules/webmidi/MIDIClient.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebCore {
+class MIDIAccess;
+}
+
+namespace WebKit {
+
+class WebMIDIClient;
+class WebViewImpl;
+
+class MIDIClientImpl : public WebCore::MIDIClient {
+public:
+ explicit MIDIClientImpl(WebViewImpl*);
+
+ // WebCore::MIDIClient ---------------------------------------------------
+ virtual void requestSysExPermission(PassRefPtr<WebCore::MIDIAccess>);
+ virtual void cancelSysExPermissionRequest(WebCore::MIDIAccess*);
+
+private:
+ WebMIDIClient* m_client;
+};
+
+} // namespace WebKit
+
+#endif // MIDIClientImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.cpp b/chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.cpp
new file mode 100644
index 00000000000..6365f015d51
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "MediaSourcePrivateImpl.h"
+
+#include "SourceBufferPrivateImpl.h"
+#include "WebMediaSourceClient.h"
+#include "WebSourceBuffer.h"
+#include <algorithm>
+#include <limits>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebKit {
+
+MediaSourcePrivateImpl::MediaSourcePrivateImpl(PassOwnPtr<WebKit::WebMediaSourceClient> client)
+ : m_client(client)
+{
+}
+
+WebCore::MediaSourcePrivate::AddStatus MediaSourcePrivateImpl::addSourceBuffer(const String& type, const CodecsArray& codecs,
+ OwnPtr<WebCore::SourceBufferPrivate>* sourceBuffer)
+{
+ if (!m_client)
+ return WebCore::MediaSourcePrivate::NotSupported;
+
+ WebSourceBuffer* webSourceBuffer = 0;
+ WebCore::MediaSourcePrivate::AddStatus result =
+ static_cast<WebCore::MediaSourcePrivate::AddStatus>(m_client->addSourceBuffer(type, codecs, &webSourceBuffer));
+
+ if (result == WebCore::MediaSourcePrivate::Ok) {
+ ASSERT(webSourceBuffer);
+ *sourceBuffer = adoptPtr(new SourceBufferPrivateImpl(adoptPtr(webSourceBuffer)));
+ }
+ return result;
+}
+
+double MediaSourcePrivateImpl::duration()
+{
+ if (!m_client)
+ return std::numeric_limits<float>::quiet_NaN();
+
+ return m_client->duration();
+}
+
+void MediaSourcePrivateImpl::setDuration(double duration)
+{
+ if (m_client)
+ m_client->setDuration(duration);
+}
+
+void MediaSourcePrivateImpl::markEndOfStream(WebCore::MediaSourcePrivate::EndOfStreamStatus status)
+{
+ if (m_client)
+ m_client->markEndOfStream(static_cast<WebMediaSourceClient::EndOfStreamStatus>(status));
+}
+
+void MediaSourcePrivateImpl::unmarkEndOfStream()
+{
+ if (m_client)
+ m_client->unmarkEndOfStream();
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.h b/chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.h
new file mode 100644
index 00000000000..3f5c6ae4717
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/MediaSourcePrivateImpl.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 MediaSourcePrivateImpl_h
+#define MediaSourcePrivateImpl_h
+
+#include "core/platform/graphics/MediaSourcePrivate.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebKit {
+
+class WebMediaSourceClient;
+
+class MediaSourcePrivateImpl : public WebCore::MediaSourcePrivate {
+public:
+ explicit MediaSourcePrivateImpl(PassOwnPtr<WebMediaSourceClient>);
+ virtual ~MediaSourcePrivateImpl() { }
+
+ // MediaSourcePrivate methods.
+ virtual WebCore::MediaSourcePrivate::AddStatus addSourceBuffer(const String& type, const CodecsArray&,
+ OwnPtr<WebCore::SourceBufferPrivate>*) OVERRIDE;
+ virtual double duration() OVERRIDE;
+ virtual void setDuration(double) OVERRIDE;
+ virtual void markEndOfStream(WebCore::MediaSourcePrivate::EndOfStreamStatus) OVERRIDE;
+ virtual void unmarkEndOfStream() OVERRIDE;
+
+private:
+ OwnPtr<WebKit::WebMediaSourceClient> m_client;
+};
+
+}
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.cpp b/chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.cpp
new file mode 100644
index 00000000000..01d8bc5f22b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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) || ENABLE(LEGACY_NOTIFICATIONS)
+
+#include "WebNotification.h"
+#include "WebNotificationPermissionCallback.h"
+#include "WebNotificationPresenter.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "modules/notifications/Notification.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if ENABLE(LEGACY_NOTIFICATIONS)
+class VoidCallbackClient : public WebNotificationPermissionCallback {
+public:
+ explicit VoidCallbackClient(PassRefPtr<VoidCallback> callback)
+ : m_callback(callback)
+ {
+ }
+
+ virtual void permissionRequestComplete()
+ {
+ if (m_callback)
+ m_callback->handleEvent();
+ delete this;
+ }
+
+private:
+ virtual ~VoidCallbackClient() { }
+
+ RefPtr<VoidCallback> m_callback;
+};
+#endif // ENABLE(LEGACY_NOTIFICATIONS)
+
+#if ENABLE(NOTIFICATIONS)
+class NotificationPermissionCallbackClient : public WebNotificationPermissionCallback {
+public:
+ NotificationPermissionCallbackClient(WebNotificationPresenter* presenter, PassRefPtr<SecurityOrigin> securityOrigin, PassRefPtr<NotificationPermissionCallback> callback)
+ : m_presenter(presenter)
+ , m_securityOrigin(securityOrigin)
+ , m_callback(callback)
+ {
+ }
+
+ virtual void permissionRequestComplete()
+ {
+ if (m_callback)
+ m_callback->handleEvent(Notification::permissionString(static_cast<NotificationClient::Permission>(m_presenter->checkPermission(WebSecurityOrigin(m_securityOrigin)))));
+ delete this;
+ }
+
+private:
+ virtual ~NotificationPermissionCallbackClient() { }
+
+ WebNotificationPresenter* m_presenter;
+ RefPtr<SecurityOrigin> m_securityOrigin;
+ RefPtr<NotificationPermissionCallback> m_callback;
+};
+#endif // ENABLE(NOTIFICATIONS)
+
+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));
+}
+
+void NotificationPresenterImpl::notificationControllerDestroyed()
+{
+}
+
+NotificationClient::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context)
+{
+ int result = m_presenter->checkPermission(WebSecurityOrigin(context->securityOrigin()));
+ return static_cast<NotificationClient::Permission>(result);
+}
+
+#if ENABLE(LEGACY_NOTIFICATIONS)
+void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
+{
+ m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new VoidCallbackClient(callback));
+}
+#endif // ENABLE(LEGACY_NOTIFICATIONS)
+
+#if ENABLE(NOTIFICATIONS)
+void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, WTF::PassRefPtr<NotificationPermissionCallback> callback)
+{
+ m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new NotificationPermissionCallbackClient(m_presenter, context->securityOrigin(), callback));
+}
+#endif // ENABLE(NOTIFICATIONS)
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
diff --git a/chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.h b/chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.h
new file mode 100644
index 00000000000..209a37d8351
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/NotificationPresenterImpl.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 NotificationPresenterImpl_h
+#define NotificationPresenterImpl_h
+
+#include "core/html/VoidCallback.h"
+#include "modules/notifications/NotificationClient.h"
+
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+
+namespace WebKit {
+
+class WebNotificationPresenter;
+
+class NotificationPresenterImpl : public WebCore::NotificationClient {
+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 void notificationControllerDestroyed();
+ virtual WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*);
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ virtual void requestPermission(WebCore::ScriptExecutionContext*, WTF::PassRefPtr<WebCore::VoidCallback> callback);
+#endif
+#if ENABLE(NOTIFICATIONS)
+ virtual void requestPermission(WebCore::ScriptExecutionContext*, WTF::PassRefPtr<WebCore::NotificationPermissionCallback>);
+#endif
+ virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) {}
+
+private:
+ // WebNotificationPresenter that this object delegates to.
+ WebNotificationPresenter* m_presenter;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/OWNERS b/chromium/third_party/WebKit/Source/web/OWNERS
new file mode 100644
index 00000000000..3afe268951f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/OWNERS
@@ -0,0 +1,8 @@
+abarth@chromium.org
+darin@chromium.org
+dglazkov@chromium.org
+jamesr@chromium.org
+jochen@chromium.org
+tkent@chromium.org
+tony@chromium.org
+pfeldman@chromium.org
diff --git a/chromium/third_party/WebKit/Source/web/PageOverlay.cpp b/chromium/third_party/WebKit/Source/web/PageOverlay.cpp
new file mode 100644
index 00000000000..9166835f2ca
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PageOverlay.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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. 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 GOOGLE 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 "PageOverlay.h"
+
+#include "WebPageOverlay.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/platform/graphics/GraphicsLayerClient.h"
+#include "public/platform/WebLayer.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+namespace {
+
+WebCanvas* ToWebCanvas(GraphicsContext* gc)
+{
+ return gc->canvas();
+}
+
+} // namespace
+
+PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverlay* overlay)
+{
+ return adoptPtr(new PageOverlay(viewImpl, overlay));
+}
+
+PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay)
+ : m_viewImpl(viewImpl)
+ , m_overlay(overlay)
+ , m_zOrder(0)
+{
+}
+
+class OverlayGraphicsLayerClientImpl : public WebCore::GraphicsLayerClient {
+public:
+ static PassOwnPtr<OverlayGraphicsLayerClientImpl*> create(WebPageOverlay* overlay)
+ {
+ return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay));
+ }
+
+ virtual ~OverlayGraphicsLayerClientImpl() { }
+
+ virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
+
+ virtual void paintContents(const GraphicsLayer*, GraphicsContext& gc, GraphicsLayerPaintingPhase, const IntRect& inClip)
+ {
+ gc.save();
+ m_overlay->paintPageOverlay(ToWebCanvas(&gc));
+ gc.restore();
+ }
+
+private:
+ explicit OverlayGraphicsLayerClientImpl(WebPageOverlay* overlay)
+ : m_overlay(overlay)
+ {
+ }
+
+ WebPageOverlay* m_overlay;
+};
+
+void PageOverlay::clear()
+{
+ invalidateWebFrame();
+
+ if (m_layer) {
+ m_layer->removeFromParent();
+ m_layer = nullptr;
+ m_layerClient = nullptr;
+ }
+}
+
+void PageOverlay::update()
+{
+ invalidateWebFrame();
+
+ if (!m_layer) {
+ m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay);
+ m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_layerClient.get());
+ m_layer->setName("WebViewImpl page overlay content");
+ m_layer->setDrawsContent(true);
+
+ // Compositor hit-testing does not know how to deal with layers that may be
+ // transparent to events (see http://crbug.com/269598). So require
+ // scrolling and touches on this layer to go to the main thread.
+ WebLayer* platformLayer = m_layer->platformLayer();
+ platformLayer->setShouldScrollOnMainThread(true);
+ WebVector<WebRect> webRects(static_cast<size_t>(1));
+ webRects[0] = WebRect(0, 0, INT_MAX, INT_MAX);
+ platformLayer->setTouchEventHandlerRegion(webRects);
+ }
+
+ FloatSize size(m_viewImpl->size());
+ if (size != m_layer->size()) {
+ // Triggers re-adding to root layer to ensure that we are on top of
+ // scrollbars.
+ m_layer->removeFromParent();
+ m_layer->setSize(size);
+ }
+
+ m_viewImpl->setOverlayLayer(m_layer.get());
+ m_layer->setNeedsDisplay();
+}
+
+void PageOverlay::paintWebFrame(GraphicsContext& gc)
+{
+ if (!m_viewImpl->isAcceleratedCompositingActive()) {
+ gc.save();
+ m_overlay->paintPageOverlay(ToWebCanvas(&gc));
+ gc.restore();
+ }
+}
+
+void PageOverlay::invalidateWebFrame()
+{
+ // WebPageOverlay does the actual painting of the overlay.
+ // Here we just make sure to invalidate.
+ if (!m_viewImpl->isAcceleratedCompositingActive()) {
+ // FIXME: able to invalidate a smaller rect.
+ // FIXME: Is it important to just invalidate a smaller rect 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_viewImpl->size();
+ WebRect damagedRect(0, 0, size.width, size.height);
+ if (m_viewImpl->client())
+ m_viewImpl->client()->didInvalidateRect(damagedRect);
+ }
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/PageOverlay.h b/chromium/third_party/WebKit/Source/web/PageOverlay.h
new file mode 100644
index 00000000000..21e2516b8fa
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PageOverlay.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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. 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 GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PageOverlay_h
+#define PageOverlay_h
+
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebCore {
+class GraphicsContext;
+class GraphicsLayer;
+class GraphicsLayerClient;
+}
+
+namespace WebKit {
+class WebPageOverlay;
+class WebViewImpl;
+struct WebRect;
+
+class PageOverlay {
+public:
+ static PassOwnPtr<PageOverlay> create(WebViewImpl*, WebPageOverlay*);
+
+ ~PageOverlay() { }
+
+ WebPageOverlay* overlay() const { return m_overlay; }
+ void setOverlay(WebPageOverlay* overlay) { m_overlay = overlay; }
+
+ int zOrder() const { return m_zOrder; }
+ void setZOrder(int zOrder) { m_zOrder = zOrder; }
+
+ void clear();
+ void update();
+ void paintWebFrame(WebCore::GraphicsContext&);
+
+ WebCore::GraphicsLayer* graphicsLayer() const { return m_layer.get(); }
+
+private:
+ PageOverlay(WebViewImpl*, WebPageOverlay*);
+ void invalidateWebFrame();
+
+ WebViewImpl* m_viewImpl;
+ WebPageOverlay* m_overlay;
+ OwnPtr<WebCore::GraphicsLayerClient> m_layerClient;
+ OwnPtr<WebCore::GraphicsLayer> m_layer;
+ int m_zOrder;
+};
+
+} // namespace WebKit
+
+#endif // PageOverlay_h
diff --git a/chromium/third_party/WebKit/Source/web/PageOverlayList.cpp b/chromium/third_party/WebKit/Source/web/PageOverlayList.cpp
new file mode 100644
index 00000000000..058b1043568
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PageOverlayList.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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. 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 GOOGLE 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 "PageOverlayList.h"
+
+#include "PageOverlay.h"
+#include "WebPageOverlay.h"
+#include "WebViewImpl.h"
+
+namespace WebKit {
+
+PassOwnPtr<PageOverlayList> PageOverlayList::create(WebViewImpl* viewImpl)
+{
+ return adoptPtr(new PageOverlayList(viewImpl));
+}
+
+PageOverlayList::PageOverlayList(WebViewImpl* viewImpl)
+ : m_viewImpl(viewImpl)
+{
+}
+
+PageOverlayList::~PageOverlayList()
+{
+}
+
+bool PageOverlayList::add(WebPageOverlay* overlay, int zOrder)
+{
+ bool added = false;
+ size_t index = find(overlay);
+ if (index == WTF::notFound) {
+ OwnPtr<PageOverlay> pageOverlay = PageOverlay::create(m_viewImpl, overlay);
+ m_pageOverlays.append(pageOverlay.release());
+ index = m_pageOverlays.size() - 1;
+ added = true;
+ }
+
+ PageOverlay* pageOverlay = m_pageOverlays[index].get();
+ pageOverlay->setZOrder(zOrder);
+
+ // Adjust page overlay list order based on their z-order numbers. We first
+ // check if we need to move the overlay up and do so if needed. Otherwise,
+ // check if we need to move it down.
+ bool zOrderChanged = false;
+ for (size_t i = index; i + 1 < m_pageOverlays.size(); ++i) {
+ if (m_pageOverlays[i]->zOrder() >= m_pageOverlays[i + 1]->zOrder()) {
+ m_pageOverlays[i].swap(m_pageOverlays[i + 1]);
+ zOrderChanged = true;
+ }
+ }
+
+ if (!zOrderChanged) {
+ for (size_t i = index; i >= 1; --i) {
+ if (m_pageOverlays[i]->zOrder() < m_pageOverlays[i - 1]->zOrder()) {
+ m_pageOverlays[i].swap(m_pageOverlays[i - 1]);
+ zOrderChanged = true;
+ }
+ }
+ }
+
+ // If we did move the overlay, that means z-order is changed and we need to
+ // update overlay layers' z-order. Otherwise, just update current overlay.
+ if (zOrderChanged) {
+ for (size_t i = 0; i < m_pageOverlays.size(); ++i)
+ m_pageOverlays[i]->clear();
+ update();
+ } else
+ pageOverlay->update();
+
+ return added;
+}
+
+bool PageOverlayList::remove(WebPageOverlay* overlay)
+{
+ size_t index = find(overlay);
+ if (index == WTF::notFound)
+ return false;
+
+ m_pageOverlays[index]->clear();
+ m_pageOverlays.remove(index);
+ return true;
+}
+
+void PageOverlayList::update()
+{
+ for (size_t i = 0; i < m_pageOverlays.size(); ++i)
+ m_pageOverlays[i]->update();
+}
+
+void PageOverlayList::paintWebFrame(WebCore::GraphicsContext& gc)
+{
+ for (size_t i = 0; i < m_pageOverlays.size(); ++i)
+ m_pageOverlays[i]->paintWebFrame(gc);
+}
+
+size_t PageOverlayList::find(WebPageOverlay* overlay)
+{
+ for (size_t i = 0; i < m_pageOverlays.size(); ++i) {
+ if (m_pageOverlays[i]->overlay() == overlay)
+ return i;
+ }
+ return WTF::notFound;
+}
+
+size_t PageOverlayList::findGraphicsLayer(WebCore::GraphicsLayer* layer)
+{
+ for (size_t i = 0; i < m_pageOverlays.size(); ++i) {
+ if (m_pageOverlays[i]->graphicsLayer() == layer)
+ return i;
+ }
+ return WTF::notFound;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/PageOverlayList.h b/chromium/third_party/WebKit/Source/web/PageOverlayList.h
new file mode 100644
index 00000000000..5f151b4e7fe
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PageOverlayList.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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. 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 GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PageOverlayList_h
+#define PageOverlayList_h
+
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+
+namespace WebCore {
+class GraphicsContext;
+class GraphicsLayer;
+}
+
+namespace WebKit {
+class PageOverlay;
+class WebPageOverlay;
+class WebViewImpl;
+
+class PageOverlayList {
+public:
+ static PassOwnPtr<PageOverlayList> create(WebViewImpl*);
+
+ ~PageOverlayList();
+
+ bool empty() const { return !m_pageOverlays.size(); }
+
+ // Adds/removes a PageOverlay for given client.
+ // Returns true if a PageOverlay is added/removed.
+ bool add(WebPageOverlay*, int /* zOrder */);
+ bool remove(WebPageOverlay*);
+
+ void update();
+ void paintWebFrame(WebCore::GraphicsContext&);
+
+ size_t findGraphicsLayer(WebCore::GraphicsLayer*);
+
+private:
+ typedef Vector<OwnPtr<PageOverlay>, 2> PageOverlays;
+
+ explicit PageOverlayList(WebViewImpl*);
+
+ // Returns the index of the client found. Otherwise, returns WTF::notFound.
+ size_t find(WebPageOverlay*);
+
+ WebViewImpl* m_viewImpl;
+ PageOverlays m_pageOverlays;
+};
+
+} // namespace WebKit
+
+#endif // PageOverlayList_h
diff --git a/chromium/third_party/WebKit/Source/web/PageWidgetDelegate.cpp b/chromium/third_party/WebKit/Source/web/PageWidgetDelegate.cpp
new file mode 100644
index 00000000000..5dfa077d2c9
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PageWidgetDelegate.cpp
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "PageWidgetDelegate.h"
+
+#include "PageOverlayList.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "core/page/EventHandler.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "wtf/CurrentTime.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static inline FrameView* mainFrameView(Page* page)
+{
+ if (!page)
+ return 0;
+ // FIXME: Can we remove this check?
+ if (!page->mainFrame())
+ return 0;
+ return page->mainFrame()->view();
+}
+
+void PageWidgetDelegate::animate(Page* page, double monotonicFrameBeginTime)
+{
+ FrameView* view = mainFrameView(page);
+ if (!view)
+ return;
+ view->serviceScriptedAnimations(monotonicFrameBeginTime);
+}
+
+void PageWidgetDelegate::layout(Page* page)
+{
+ FrameView* view = mainFrameView(page);
+ if (!view)
+ return;
+ // 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.
+ 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.
+ view->updateLayoutAndStyleIfNeededRecursive();
+}
+
+void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, CanvasBackground background)
+{
+ if (rect.isEmpty())
+ return;
+ GraphicsContext gc(canvas);
+ gc.setCertainlyOpaque(background == Opaque);
+ gc.applyDeviceScaleFactor(page->deviceScaleFactor());
+ gc.setUseHighResMarkers(page->deviceScaleFactor() > 1.5f);
+ IntRect dirtyRect(rect);
+ gc.save();
+ FrameView* view = mainFrameView(page);
+ // FIXME: Can we remove the mainFrame()->document() check?
+ if (view && page->mainFrame()->document()) {
+ gc.clip(dirtyRect);
+ view->paint(&gc, dirtyRect);
+ if (overlays)
+ overlays->paintWebFrame(gc);
+ } else {
+ gc.fillRect(dirtyRect, Color::white);
+ }
+ gc.restore();
+}
+
+bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& handler, const WebInputEvent& event)
+{
+ Frame* frame = page ? page->mainFrame() : 0;
+ switch (event.type) {
+
+ // 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).
+ case WebInputEvent::MouseMove:
+ if (!frame || !frame->view())
+ return true;
+ handler.handleMouseMove(*frame, *static_cast<const WebMouseEvent*>(&event));
+ return true;
+ case WebInputEvent::MouseLeave:
+ if (!frame || !frame->view())
+ return true;
+ handler.handleMouseLeave(*frame, *static_cast<const WebMouseEvent*>(&event));
+ return true;
+ case WebInputEvent::MouseDown:
+ if (!frame || !frame->view())
+ return true;
+ handler.handleMouseDown(*frame, *static_cast<const WebMouseEvent*>(&event));
+ return true;
+ case WebInputEvent::MouseUp:
+ if (!frame || !frame->view())
+ return true;
+ handler.handleMouseUp(*frame, *static_cast<const WebMouseEvent*>(&event));
+ return true;
+
+ case WebInputEvent::MouseWheel:
+ if (!frame || !frame->view())
+ return false;
+ return handler.handleMouseWheel(*frame, *static_cast<const WebMouseWheelEvent*>(&event));
+
+ case WebInputEvent::RawKeyDown:
+ case WebInputEvent::KeyDown:
+ case WebInputEvent::KeyUp:
+ return handler.handleKeyEvent(*static_cast<const WebKeyboardEvent*>(&event));
+
+ case WebInputEvent::Char:
+ return handler.handleCharEvent(*static_cast<const WebKeyboardEvent*>(&event));
+ case WebInputEvent::GestureScrollBegin:
+ case WebInputEvent::GestureScrollEnd:
+ case WebInputEvent::GestureScrollUpdate:
+ case WebInputEvent::GestureScrollUpdateWithoutPropagation:
+ case WebInputEvent::GestureFlingStart:
+ case WebInputEvent::GestureFlingCancel:
+ case WebInputEvent::GestureTap:
+ case WebInputEvent::GestureTapUnconfirmed:
+ case WebInputEvent::GestureTapDown:
+ case WebInputEvent::GestureTapCancel:
+ case WebInputEvent::GestureDoubleTap:
+ case WebInputEvent::GestureTwoFingerTap:
+ case WebInputEvent::GestureLongPress:
+ case WebInputEvent::GestureLongTap:
+ return handler.handleGestureEvent(*static_cast<const WebGestureEvent*>(&event));
+
+ case WebInputEvent::TouchStart:
+ case WebInputEvent::TouchMove:
+ case WebInputEvent::TouchEnd:
+ case WebInputEvent::TouchCancel:
+ if (!frame || !frame->view())
+ return false;
+ return handler.handleTouchEvent(*frame, *static_cast<const WebTouchEvent*>(&event));
+
+ case WebInputEvent::GesturePinchBegin:
+ case WebInputEvent::GesturePinchEnd:
+ case WebInputEvent::GesturePinchUpdate:
+ // FIXME: Once PlatformGestureEvent is updated to support pinch, this
+ // should call handleGestureEvent, just like it currently does for
+ // gesture scroll.
+ return false;
+
+ default:
+ return false;
+ }
+}
+
+// ----------------------------------------------------------------
+// Default handlers for PageWidgetEventHandler
+
+void PageWidgetEventHandler::handleMouseMove(Frame& mainFrame, const WebMouseEvent& event)
+{
+ // 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.
+ mainFrame.eventHandler()->mouseMoved(PlatformMouseEventBuilder(mainFrame.view(), event));
+}
+
+void PageWidgetEventHandler::handleMouseLeave(Frame& mainFrame, const WebMouseEvent& event)
+{
+ mainFrame.eventHandler()->mouseMoved(PlatformMouseEventBuilder(mainFrame.view(), event));
+}
+
+void PageWidgetEventHandler::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event)
+{
+ mainFrame.eventHandler()->handleMousePressEvent(PlatformMouseEventBuilder(mainFrame.view(), event));
+}
+
+void PageWidgetEventHandler::handleMouseUp(Frame& mainFrame, const WebMouseEvent& event)
+{
+ mainFrame.eventHandler()->handleMouseReleaseEvent(PlatformMouseEventBuilder(mainFrame.view(), event));
+}
+
+bool PageWidgetEventHandler::handleMouseWheel(Frame& mainFrame, const WebMouseWheelEvent& event)
+{
+ return mainFrame.eventHandler()->handleWheelEvent(PlatformWheelEventBuilder(mainFrame.view(), event));
+}
+
+bool PageWidgetEventHandler::handleTouchEvent(Frame& mainFrame, const WebTouchEvent& event)
+{
+ return mainFrame.eventHandler()->handleTouchEvent(PlatformTouchEventBuilder(mainFrame.view(), event));
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/PageWidgetDelegate.h b/chromium/third_party/WebKit/Source/web/PageWidgetDelegate.h
new file mode 100644
index 00000000000..7943de88212
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PageWidgetDelegate.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 PageWidgetDelegate_h
+#define PageWidgetDelegate_h
+
+#include "WebWidget.h"
+#include "core/page/Page.h"
+#include "public/platform/WebCanvas.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebCore {
+class Frame;
+class Page;
+}
+
+namespace WebKit {
+
+class PageOverlayList;
+class WebGestureEvent;
+class WebInputEvent;
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebTouchEvent;
+
+class PageWidgetEventHandler {
+public:
+ virtual void handleMouseMove(WebCore::Frame& mainFrame, const WebMouseEvent&);
+ virtual void handleMouseLeave(WebCore::Frame& mainFrame, const WebMouseEvent&);
+ virtual void handleMouseDown(WebCore::Frame& mainFrame, const WebMouseEvent&);
+ virtual void handleMouseUp(WebCore::Frame& mainFrame, const WebMouseEvent&);
+ virtual bool handleMouseWheel(WebCore::Frame& mainFrame, const WebMouseWheelEvent&);
+ virtual bool handleKeyEvent(const WebKeyboardEvent&) = 0;
+ virtual bool handleCharEvent(const WebKeyboardEvent&) = 0;
+ virtual bool handleGestureEvent(const WebGestureEvent&) = 0;
+ virtual bool handleTouchEvent(WebCore::Frame& mainFrame, const WebTouchEvent&);
+ virtual ~PageWidgetEventHandler() { }
+};
+
+
+// Common implementation of WebViewImpl and WebPagePopupImpl.
+class PageWidgetDelegate {
+public:
+ enum CanvasBackground {
+ Opaque,
+ Translucent,
+ };
+ static void animate(WebCore::Page*, double monotonicFrameBeginTime);
+ static void layout(WebCore::Page*);
+ static void paint(WebCore::Page*, PageOverlayList*, WebCanvas*, const WebRect&, CanvasBackground);
+ static bool handleInputEvent(WebCore::Page*, PageWidgetEventHandler&, const WebInputEvent&);
+
+private:
+ PageWidgetDelegate() { }
+};
+
+}
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/PinchViewports.cpp b/chromium/third_party/WebKit/Source/web/PinchViewports.cpp
new file mode 100644
index 00000000000..4e612b0de91
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PinchViewports.cpp
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "PinchViewports.h"
+
+#include "WebSettingsImpl.h"
+#include "WebViewImpl.h"
+#include "core/page/FrameView.h"
+#include "core/platform/graphics/FloatSize.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/rendering/RenderLayerCompositor.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebCompositorSupport.h"
+#include "public/platform/WebLayerTreeView.h"
+#include "public/platform/WebScrollbarLayer.h"
+
+using WebCore::GraphicsLayer;
+
+namespace WebKit {
+
+PassOwnPtr<PinchViewports> PinchViewports::create(WebViewImpl* owner)
+{
+ return adoptPtr(new PinchViewports(owner));
+}
+
+PinchViewports::PinchViewports(WebViewImpl* owner)
+ : m_owner(owner)
+ , m_innerViewportContainerLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), this))
+ , m_pageScaleLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), this))
+ , m_innerViewportScrollLayer(GraphicsLayer::create(m_owner->graphicsLayerFactory(), this))
+ , m_overlayScrollbarHorizontal(GraphicsLayer::create(m_owner->graphicsLayerFactory(), this))
+ , m_overlayScrollbarVertical(GraphicsLayer::create(m_owner->graphicsLayerFactory(), this))
+{
+ m_innerViewportContainerLayer->platformLayer()->setIsContainerForFixedPositionLayers(true);
+ // No need for the inner viewport to clip, since the compositing
+ // surface takes care of it -- and clipping here would interfere with
+ // dynamically-sized viewports on Android.
+ m_innerViewportContainerLayer->setMasksToBounds(false);
+
+ m_innerViewportScrollLayer->platformLayer()->setScrollable(true);
+
+#ifndef NDEBUG
+ m_innerViewportContainerLayer->setName("inner viewport container layer");
+ m_pageScaleLayer->setName("page scale layer");
+ m_innerViewportScrollLayer->setName("inner viewport scroll layer");
+ m_overlayScrollbarHorizontal->setName("overlay scrollbar horizontal");
+ m_overlayScrollbarVertical->setName("overlay scrollbar vertical");
+#endif
+
+ m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get());
+ m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get());
+ m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get());
+ m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get());
+
+ // Setup the inner viewport overlay scrollbars.
+ setupScrollbar(WebScrollbar::Horizontal);
+ setupScrollbar(WebScrollbar::Vertical);
+}
+
+PinchViewports::~PinchViewports() { }
+
+void PinchViewports::setViewportSize(const WebCore::IntSize& newSize)
+{
+ m_innerViewportContainerLayer->setSize(newSize);
+
+ // Need to re-compute sizes for the overlay scrollbars.
+ setupScrollbar(WebScrollbar::Horizontal);
+ setupScrollbar(WebScrollbar::Vertical);
+}
+
+// Modifies the top of the graphics layer tree to add layers needed to support
+// the inner/outer viewport fixed-position model for pinch zoom. When finished,
+// the tree will look like this (with * denoting added layers):
+//
+// *innerViewportContainerLayer (fixed pos container)
+// +- *pageScaleLayer
+// | +- *innerViewportScrollLayer
+// | +-- overflowControlsHostLayer (root layer)
+// | +-- outerViewportContainerLayer (fixed pos container) [frame container layer in RenderLayerCompositor]
+// | | +-- outerViewportScrollLayer [frame scroll layer in RenderLayerCompositor]
+// | | +-- content layers ...
+// | +-- horizontal ScrollbarLayer (non-overlay)
+// | +-- verticalScrollbarLayer (non-overlay)
+// | +-- scroll corner (non-overlay)
+// +- *horizontalScrollbarLayer (overlay)
+// +- *verticalScrollbarLayer (overlay)
+//
+void PinchViewports::setOverflowControlsHostLayer(GraphicsLayer* layer)
+{
+ if (layer) {
+ ASSERT(!m_innerViewportScrollLayer->children().size());
+ m_innerViewportScrollLayer->addChild(layer);
+ } else {
+ m_innerViewportScrollLayer->removeAllChildren();
+ return;
+ }
+
+ WebCore::Page* page = m_owner->page();
+ if (!page)
+ return;
+
+ // We only need to disable the existing (outer viewport) scrollbars
+ // if the existing ones are already overlay.
+ // FIXME: If we knew in advance before the overflowControlsHostLayer goes
+ // away, we would re-enable the drawing of these scrollbars.
+ if (GraphicsLayer* scrollbar = m_owner->compositor()->layerForHorizontalScrollbar())
+ scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollbars());
+ if (GraphicsLayer* scrollbar = m_owner->compositor()->layerForVerticalScrollbar())
+ scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollbars());
+}
+
+void PinchViewports::setupScrollbar(WebScrollbar::Orientation orientation)
+{
+ bool isHorizontal = orientation == WebScrollbar::Horizontal;
+ GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ?
+ m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get();
+
+ const int overlayScrollbarThickness = m_owner->settingsImpl()->pinchOverlayScrollbarThickness();
+
+ int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().width() - overlayScrollbarThickness;
+ int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height() - overlayScrollbarThickness : 0;
+ int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - overlayScrollbarThickness : overlayScrollbarThickness;
+ int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportContainerLayer->size().height() - overlayScrollbarThickness;
+
+ scrollbarGraphicsLayer->setPosition(WebCore::IntPoint(xPosition, yPosition));
+ scrollbarGraphicsLayer->setSize(WebCore::IntSize(width, height));
+}
+
+void PinchViewports::registerViewportLayersWithTreeView(WebLayerTreeView* layerTreeView) const
+{
+ if (!layerTreeView)
+ return;
+
+ WebCore::RenderLayerCompositor* compositor = m_owner->compositor();
+ ASSERT(compositor);
+ layerTreeView->registerPinchViewportLayers(
+ m_innerViewportContainerLayer->platformLayer(),
+ m_pageScaleLayer->platformLayer(),
+ m_innerViewportScrollLayer->platformLayer(),
+ compositor->scrollLayer()->platformLayer(),
+ m_overlayScrollbarHorizontal->platformLayer(),
+ m_overlayScrollbarVertical->platformLayer());
+}
+
+void PinchViewports::clearViewportLayersForTreeView(WebLayerTreeView* layerTreeView) const
+{
+ if (!layerTreeView)
+ return;
+
+ layerTreeView->clearPinchViewportLayers();
+}
+
+void PinchViewports::notifyAnimationStarted(const GraphicsLayer*, double time)
+{
+}
+
+void PinchViewports::paintContents(const GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip)
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/PinchViewports.h b/chromium/third_party/WebKit/Source/web/PinchViewports.h
new file mode 100644
index 00000000000..35a41c43a78
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PinchViewports.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 PinchViewports_h
+#define PinchViewports_h
+
+#include "core/platform/graphics/GraphicsLayerClient.h"
+#include "core/platform/graphics/IntSize.h"
+#include "public/platform/WebScrollbar.h"
+#include "public/platform/WebSize.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebCore {
+class GraphicsContext;
+class GraphicsLayer;
+class IntRect;
+class IntSize;
+}
+
+namespace WebKit {
+
+class WebLayerTreeView;
+class WebScrollbarLayer;
+class WebViewImpl;
+
+class PinchViewports : WebCore::GraphicsLayerClient {
+public:
+ static PassOwnPtr<PinchViewports> create(WebViewImpl* owner);
+ ~PinchViewports();
+
+ void setOverflowControlsHostLayer(WebCore::GraphicsLayer*);
+ WebCore::GraphicsLayer* rootGraphicsLayer()
+ {
+ return m_innerViewportContainerLayer.get();
+ }
+ void setViewportSize(const WebCore::IntSize&);
+
+ void registerViewportLayersWithTreeView(WebLayerTreeView*) const;
+ void clearViewportLayersForTreeView(WebLayerTreeView*) const;
+
+ // GraphicsLayerClient implementation.
+ virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) OVERRIDE;
+ virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip) OVERRIDE;
+
+private:
+ explicit PinchViewports(WebViewImpl* owner);
+
+ void setupScrollbar(WebKit::WebScrollbar::Orientation);
+
+ WebViewImpl* m_owner;
+ OwnPtr<WebCore::GraphicsLayer> m_innerViewportContainerLayer;
+ OwnPtr<WebCore::GraphicsLayer> m_pageScaleLayer;
+ OwnPtr<WebCore::GraphicsLayer> m_innerViewportScrollLayer;
+ OwnPtr<WebCore::GraphicsLayer> m_overlayScrollbarHorizontal;
+ OwnPtr<WebCore::GraphicsLayer> m_overlayScrollbarVertical;
+};
+
+} // namespace WebKit
+
+#endif // PinchViewports_h
diff --git a/chromium/third_party/WebKit/Source/web/PopupContainer.cpp b/chromium/third_party/WebKit/Source/web/PopupContainer.cpp
new file mode 100644
index 00000000000..bbd62a188d7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PopupContainer.cpp
@@ -0,0 +1,465 @@
+/*
+ * Copyright (c) 2011, Google Inc. 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 "PopupContainer.h"
+
+#include "PopupListBox.h"
+#include "core/dom/Document.h"
+#include "core/dom/UserGestureIndicator.h"
+#include "core/page/Chrome.h"
+#include "core/page/ChromeClient.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/platform/PlatformGestureEvent.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/PlatformMouseEvent.h"
+#include "core/platform/PlatformScreen.h"
+#include "core/platform/PlatformTouchEvent.h"
+#include "core/platform/PlatformWheelEvent.h"
+#include "core/platform/PopupMenuClient.h"
+#include "core/platform/chromium/FramelessScrollView.h"
+#include "core/platform/chromium/FramelessScrollViewClient.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/IntRect.h"
+#include <limits>
+
+namespace WebCore {
+
+static const int borderSize = 1;
+
+static PlatformMouseEvent constructRelativeMouseEvent(const PlatformMouseEvent& e, FramelessScrollView* parent, FramelessScrollView* child)
+{
+ IntPoint pos = parent->convertSelfToChild(child, e.position());
+
+ // FIXME: This is a horrible hack since PlatformMouseEvent has no setters for x/y.
+ PlatformMouseEvent relativeEvent = e;
+ IntPoint& relativePos = const_cast<IntPoint&>(relativeEvent.position());
+ relativePos.setX(pos.x());
+ relativePos.setY(pos.y());
+ return relativeEvent;
+}
+
+static PlatformWheelEvent constructRelativeWheelEvent(const PlatformWheelEvent& e, FramelessScrollView* parent, FramelessScrollView* child)
+{
+ IntPoint pos = parent->convertSelfToChild(child, e.position());
+
+ // FIXME: This is a horrible hack since PlatformWheelEvent has no setters for x/y.
+ PlatformWheelEvent relativeEvent = e;
+ IntPoint& relativePos = const_cast<IntPoint&>(relativeEvent.position());
+ relativePos.setX(pos.x());
+ relativePos.setY(pos.y());
+ return relativeEvent;
+}
+
+// static
+PassRefPtr<PopupContainer> PopupContainer::create(PopupMenuClient* client, PopupType popupType, const PopupContainerSettings& settings)
+{
+ return adoptRef(new PopupContainer(client, popupType, settings));
+}
+
+PopupContainer::PopupContainer(PopupMenuClient* client, PopupType popupType, const PopupContainerSettings& settings)
+ : m_listBox(PopupListBox::create(client, settings))
+ , m_settings(settings)
+ , m_popupType(popupType)
+ , m_popupOpen(false)
+{
+ setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
+}
+
+PopupContainer::~PopupContainer()
+{
+ if (m_listBox && m_listBox->parent())
+ removeChild(m_listBox.get());
+}
+
+IntRect PopupContainer::layoutAndCalculateWidgetRectInternal(IntRect widgetRectInScreen, int targetControlHeight, const FloatRect& windowRect, const FloatRect& screen, bool isRTL, const int rtlOffset, const int verticalOffset, const IntSize& transformOffset, PopupContent* listBox, bool& needToResizeView)
+{
+ ASSERT(listBox);
+ if (windowRect.x() >= screen.x() && windowRect.maxX() <= screen.maxX() && (widgetRectInScreen.x() < screen.x() || widgetRectInScreen.maxX() > screen.maxX())) {
+ // First, inverse the popup alignment if it does not fit the screen -
+ // this might fix things (or make them better).
+ IntRect inverseWidgetRectInScreen = widgetRectInScreen;
+ inverseWidgetRectInScreen.setX(inverseWidgetRectInScreen.x() + (isRTL ? -rtlOffset : rtlOffset));
+ inverseWidgetRectInScreen.setY(inverseWidgetRectInScreen.y() + (isRTL ? -verticalOffset : verticalOffset));
+ IntRect enclosingScreen = enclosingIntRect(screen);
+ unsigned originalCutoff = std::max(enclosingScreen.x() - widgetRectInScreen.x(), 0) + std::max(widgetRectInScreen.maxX() - enclosingScreen.maxX(), 0);
+ unsigned inverseCutoff = std::max(enclosingScreen.x() - inverseWidgetRectInScreen.x(), 0) + std::max(inverseWidgetRectInScreen.maxX() - enclosingScreen.maxX(), 0);
+
+ // Accept the inverse popup alignment if the trimmed content gets
+ // shorter than that in the original alignment case.
+ if (inverseCutoff < originalCutoff)
+ widgetRectInScreen = inverseWidgetRectInScreen;
+
+ if (widgetRectInScreen.x() < screen.x()) {
+ widgetRectInScreen.setWidth(widgetRectInScreen.maxX() - screen.x());
+ widgetRectInScreen.setX(screen.x());
+ listBox->setMaxWidthAndLayout(std::max(widgetRectInScreen.width() - borderSize * 2, 0));
+ } else if (widgetRectInScreen.maxX() > screen.maxX()) {
+ widgetRectInScreen.setWidth(screen.maxX() - widgetRectInScreen.x());
+ listBox->setMaxWidthAndLayout(std::max(widgetRectInScreen.width() - borderSize * 2, 0));
+ }
+ }
+
+ // Calculate Y axis size.
+ if (widgetRectInScreen.maxY() > static_cast<int>(screen.maxY())) {
+ if (widgetRectInScreen.y() - widgetRectInScreen.height() - targetControlHeight - transformOffset.height() > 0) {
+ // There is enough room to open upwards.
+ widgetRectInScreen.move(-transformOffset.width(), -(widgetRectInScreen.height() + targetControlHeight + transformOffset.height()));
+ } else {
+ // Figure whether upwards or downwards has more room and set the
+ // maximum number of items.
+ int spaceAbove = widgetRectInScreen.y() - targetControlHeight + transformOffset.height();
+ int spaceBelow = screen.maxY() - widgetRectInScreen.y();
+ if (spaceAbove > spaceBelow)
+ listBox->setMaxHeight(spaceAbove);
+ else
+ listBox->setMaxHeight(spaceBelow);
+ listBox->layout();
+ needToResizeView = true;
+ widgetRectInScreen.setHeight(listBox->popupContentHeight() + borderSize * 2);
+ // Move WebWidget upwards if necessary.
+ if (spaceAbove > spaceBelow)
+ widgetRectInScreen.move(-transformOffset.width(), -(widgetRectInScreen.height() + targetControlHeight + transformOffset.height()));
+ }
+ }
+ return widgetRectInScreen;
+}
+
+IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, const IntSize& transformOffset, const IntPoint& popupInitialCoordinate)
+{
+ // Reset the max width and height to their default values, they will be
+ // recomputed below if necessary.
+ m_listBox->setMaxHeight(PopupListBox::defaultMaxHeight);
+ m_listBox->setMaxWidth(std::numeric_limits<int>::max());
+
+ // Lay everything out to figure out our preferred size, then tell the view's
+ // WidgetClient about it. It should assign us a client.
+ m_listBox->layout();
+ fitToListBox();
+ bool isRTL = this->isRTL();
+
+ // Compute the starting x-axis for a normal RTL or right-aligned LTR
+ // dropdown. For those, the right edge of dropdown box should be aligned
+ // with the right edge of <select>/<input> element box, and the dropdown box
+ // should be expanded to the left if more space is needed.
+ // m_originalFrameRect.width() is the width of the target <select>/<input>
+ // element.
+ int rtlOffset = m_controlPosition.p2().x() - m_controlPosition.p1().x() - (m_listBox->width() + borderSize * 2);
+ int rightOffset = isRTL ? rtlOffset : 0;
+
+ // Compute the y-axis offset between the bottom left and bottom right
+ // points. If the <select>/<input> is transformed, they are not the same.
+ int verticalOffset = - m_controlPosition.p4().y() + m_controlPosition.p3().y();
+ int verticalForRTLOffset = isRTL ? verticalOffset : 0;
+
+ // Assume m_listBox size is already calculated.
+ IntSize targetSize(m_listBox->width() + borderSize * 2, m_listBox->height() + borderSize * 2);
+
+ IntRect widgetRectInScreen;
+ if (ChromeClient* client = chromeClient()) {
+ // If the popup would extend past the bottom of the screen, open upwards
+ // instead.
+ FloatRect screen = screenAvailableRect(m_frameView.get());
+ // Use popupInitialCoordinate.x() + rightOffset because RTL position
+ // needs to be considered.
+ widgetRectInScreen = client->rootViewToScreen(IntRect(popupInitialCoordinate.x() + rightOffset, popupInitialCoordinate.y() + verticalForRTLOffset, targetSize.width(), targetSize.height()));
+
+ // If we have multiple screens and the browser rect is in one screen, we
+ // have to clip the window width to the screen width.
+ // When clipping, we also need to set a maximum width for the list box.
+ FloatRect windowRect = client->windowRect();
+
+ bool needToResizeView = false;
+ widgetRectInScreen = layoutAndCalculateWidgetRectInternal(widgetRectInScreen, targetControlHeight, windowRect, screen, isRTL, rtlOffset, verticalOffset, transformOffset, m_listBox.get(), needToResizeView);
+ if (needToResizeView)
+ fitToListBox();
+ }
+
+ return widgetRectInScreen;
+}
+
+void PopupContainer::showPopup(FrameView* view)
+{
+ m_frameView = view;
+ listBox()->m_focusedElement = m_frameView->frame()->document()->focusedElement();
+
+ if (ChromeClient* client = chromeClient()) {
+ IntSize transformOffset(m_controlPosition.p4().x() - m_controlPosition.p1().x(), m_controlPosition.p4().y() - m_controlPosition.p1().y() - m_controlSize.height());
+ client->popupOpened(this, layoutAndCalculateWidgetRect(m_controlSize.height(), transformOffset, roundedIntPoint(m_controlPosition.p4())), false);
+ m_popupOpen = true;
+ }
+
+ if (!m_listBox->parent())
+ addChild(m_listBox.get());
+
+ // Enable scrollbars after the listbox is inserted into the hierarchy,
+ // so it has a proper WidgetClient.
+ m_listBox->setVerticalScrollbarMode(ScrollbarAuto);
+
+ m_listBox->scrollToRevealSelection();
+
+ invalidate();
+}
+
+void PopupContainer::hidePopup()
+{
+ listBox()->hidePopup();
+}
+
+void PopupContainer::notifyPopupHidden()
+{
+ if (!m_popupOpen)
+ return;
+ m_popupOpen = false;
+ chromeClient()->popupClosed(this);
+}
+
+void PopupContainer::fitToListBox()
+{
+ // Place the listbox within our border.
+ m_listBox->move(borderSize, borderSize);
+
+ // Size ourselves to contain listbox + border.
+ resize(m_listBox->width() + borderSize * 2, m_listBox->height() + borderSize * 2);
+ invalidate();
+}
+
+bool PopupContainer::handleMouseDownEvent(const PlatformMouseEvent& event)
+{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ return m_listBox->handleMouseDownEvent(
+ constructRelativeMouseEvent(event, this, m_listBox.get()));
+}
+
+bool PopupContainer::handleMouseMoveEvent(const PlatformMouseEvent& event)
+{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ return m_listBox->handleMouseMoveEvent(
+ constructRelativeMouseEvent(event, this, m_listBox.get()));
+}
+
+bool PopupContainer::handleMouseReleaseEvent(const PlatformMouseEvent& event)
+{
+ RefPtr<PopupContainer> protect(this);
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ return m_listBox->handleMouseReleaseEvent(
+ constructRelativeMouseEvent(event, this, m_listBox.get()));
+}
+
+bool PopupContainer::handleWheelEvent(const PlatformWheelEvent& event)
+{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ return m_listBox->handleWheelEvent(
+ constructRelativeWheelEvent(event, this, m_listBox.get()));
+}
+
+bool PopupContainer::handleTouchEvent(const PlatformTouchEvent&)
+{
+ return false;
+}
+
+// FIXME: Refactor this code to share functionality with
+// EventHandler::handleGestureEvent.
+bool PopupContainer::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
+{
+ switch (gestureEvent.type()) {
+ case PlatformEvent::GestureTap: {
+ PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, PlatformEvent::MouseMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
+ PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
+ PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, PlatformEvent::MouseReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
+ // handleMouseMoveEvent(fakeMouseMove);
+ handleMouseDownEvent(fakeMouseDown);
+ handleMouseReleaseEvent(fakeMouseUp);
+ return true;
+ }
+ case PlatformEvent::GestureScrollUpdate:
+ case PlatformEvent::GestureScrollUpdateWithoutPropagation: {
+ PlatformWheelEvent syntheticWheelEvent(gestureEvent.position(), gestureEvent.globalPosition(), gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / 120.0f, gestureEvent.deltaY() / 120.0f, ScrollByPixelWheelEvent, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
+ handleWheelEvent(syntheticWheelEvent);
+ return true;
+ }
+ case PlatformEvent::GestureScrollBegin:
+ case PlatformEvent::GestureScrollEnd:
+ case PlatformEvent::GestureTapDown:
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return false;
+}
+
+bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event)
+{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ return m_listBox->handleKeyEvent(event);
+}
+
+void PopupContainer::hide()
+{
+ m_listBox->abandon();
+}
+
+void PopupContainer::paint(GraphicsContext* gc, const IntRect& rect)
+{
+ // Adjust coords for scrolled frame.
+ IntRect r = intersection(rect, frameRect());
+ int tx = x();
+ int ty = y();
+
+ r.move(-tx, -ty);
+
+ gc->translate(static_cast<float>(tx), static_cast<float>(ty));
+ m_listBox->paint(gc, r);
+ gc->translate(-static_cast<float>(tx), -static_cast<float>(ty));
+
+ paintBorder(gc, rect);
+}
+
+void PopupContainer::paintBorder(GraphicsContext* gc, const IntRect& rect)
+{
+ // FIXME: Where do we get the border color from?
+ Color borderColor(127, 157, 185);
+
+ gc->setStrokeStyle(NoStroke);
+ gc->setFillColor(borderColor);
+
+ int tx = x();
+ int ty = y();
+
+ // top, left, bottom, right
+ gc->drawRect(IntRect(tx, ty, width(), borderSize));
+ gc->drawRect(IntRect(tx, ty, borderSize, height()));
+ gc->drawRect(IntRect(tx, ty + height() - borderSize, width(), borderSize));
+ gc->drawRect(IntRect(tx + width() - borderSize, ty, borderSize, height()));
+}
+
+bool PopupContainer::isInterestedInEventForKey(int keyCode)
+{
+ return m_listBox->isInterestedInEventForKey(keyCode);
+}
+
+ChromeClient* PopupContainer::chromeClient()
+{
+ return m_frameView->frame()->page()->chrome().client();
+}
+
+void PopupContainer::showInRect(const FloatQuad& controlPosition, const IntSize& controlSize, FrameView* v, int index)
+{
+ // The controlSize is the size of the select box. It's usually larger than
+ // we need. Subtract border size so that usually the container will be
+ // displayed exactly the same width as the select box.
+ listBox()->setBaseWidth(max(controlSize.width() - borderSize * 2, 0));
+
+ listBox()->updateFromElement();
+
+ // We set the selected item in updateFromElement(), and disregard the
+ // index passed into this function (same as Webkit's PopupMenuWin.cpp)
+ // FIXME: make sure this is correct, and add an assertion.
+ // ASSERT(popupWindow(popup)->listBox()->selectedIndex() == index);
+
+ // Save and convert the controlPosition to main window coords. Each point is converted separately
+ // to window coordinates because the control could be in a transformed webview and then each point
+ // would be transformed by a different delta.
+ m_controlPosition.setP1(v->contentsToWindow(IntPoint(controlPosition.p1().x(), controlPosition.p1().y())));
+ m_controlPosition.setP2(v->contentsToWindow(IntPoint(controlPosition.p2().x(), controlPosition.p2().y())));
+ m_controlPosition.setP3(v->contentsToWindow(IntPoint(controlPosition.p3().x(), controlPosition.p3().y())));
+ m_controlPosition.setP4(v->contentsToWindow(IntPoint(controlPosition.p4().x(), controlPosition.p4().y())));
+
+ m_controlSize = controlSize;
+
+ // Position at (0, 0) since the frameRect().location() is relative to the
+ // parent WebWidget.
+ setFrameRect(IntRect(IntPoint(), controlSize));
+ showPopup(v);
+}
+
+IntRect PopupContainer::refresh(const IntRect& targetControlRect)
+{
+ listBox()->setBaseWidth(max(m_controlSize.width() - borderSize * 2, 0));
+ listBox()->updateFromElement();
+
+ IntPoint locationInWindow = m_frameView->contentsToWindow(targetControlRect.location());
+
+ // Move it below the select widget.
+ locationInWindow.move(0, targetControlRect.height());
+
+ IntRect widgetRectInScreen = layoutAndCalculateWidgetRect(targetControlRect.height(), IntSize(), locationInWindow);
+
+ // Reset the size (which can be set to the PopupListBox size in
+ // layoutAndGetRTLOffset(), exceeding the available widget rectangle.)
+ if (size() != widgetRectInScreen.size())
+ resize(widgetRectInScreen.size());
+
+ invalidate();
+
+ return widgetRectInScreen;
+}
+
+inline bool PopupContainer::isRTL() const
+{
+ return m_listBox->m_popupClient->menuStyle().textDirection() == RTL;
+}
+
+int PopupContainer::selectedIndex() const
+{
+ return m_listBox->selectedIndex();
+}
+
+int PopupContainer::menuItemHeight() const
+{
+ return m_listBox->getRowHeight(0);
+}
+
+int PopupContainer::menuItemFontSize() const
+{
+ return m_listBox->getRowFont(0).size();
+}
+
+PopupMenuStyle PopupContainer::menuStyle() const
+{
+ return m_listBox->m_popupClient->menuStyle();
+}
+
+const WTF::Vector<PopupItem*>& PopupContainer:: popupData() const
+{
+ return m_listBox->items();
+}
+
+String PopupContainer::getSelectedItemToolTip()
+{
+ // We cannot use m_popupClient->selectedIndex() to choose tooltip message,
+ // because the selectedIndex() might return final selected index, not
+ // hovering selection.
+ return listBox()->m_popupClient->itemToolTip(listBox()->m_selectedIndex);
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/PopupContainer.h b/chromium/third_party/WebKit/Source/web/PopupContainer.h
new file mode 100644
index 00000000000..d9c8710df64
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PopupContainer.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2011, Google Inc. 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 PopupContainer_h
+#define PopupContainer_h
+
+#include "PopupListBox.h"
+#include "core/platform/PopupMenuStyle.h"
+#include "core/platform/chromium/FramelessScrollView.h"
+#include "core/platform/graphics/FloatQuad.h"
+
+namespace WebCore {
+
+class ChromeClient;
+class FrameView;
+class PopupMenuClient;
+
+class PopupContainer : public FramelessScrollView {
+public:
+ enum PopupType {
+ Select, // HTML select popup.
+ Suggestion, // Autocomplete/autofill popup.
+ };
+
+ static PassRefPtr<PopupContainer> create(PopupMenuClient*, PopupType, const PopupContainerSettings&);
+
+ // Whether a key event should be sent to this popup.
+ bool isInterestedInEventForKey(int keyCode);
+
+ // FramelessScrollView
+ virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
+ virtual void hide() OVERRIDE;
+ virtual bool handleMouseDownEvent(const PlatformMouseEvent&) OVERRIDE;
+ virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) OVERRIDE;
+ virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) OVERRIDE;
+ virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
+ virtual bool handleKeyEvent(const PlatformKeyboardEvent&) OVERRIDE;
+ virtual bool handleTouchEvent(const PlatformTouchEvent&) OVERRIDE;
+ virtual bool handleGestureEvent(const PlatformGestureEvent&) OVERRIDE;
+
+ // PopupContainer methods
+
+ // Show the popup
+ void showPopup(FrameView*);
+
+ // Show the popup in the specified rect for the specified frame.
+ // Note: this code was somehow arbitrarily factored-out of the Popup class
+ // so WebViewImpl can create a PopupContainer. This method is used for
+ // displaying auto complete popup menus on Mac Chromium, and for all
+ // popups on other platforms.
+ void showInRect(const FloatQuad& controlPosition, const IntSize& controlSize, FrameView*, int index);
+
+ // Hides the popup.
+ void hidePopup();
+
+ // The popup was hidden.
+ void notifyPopupHidden();
+
+ PopupListBox* listBox() const { return m_listBox.get(); }
+
+ bool isRTL() const;
+
+ // Gets the index of the item that the user is currently moused-over or
+ // has selected with the keyboard up/down arrows.
+ int selectedIndex() const;
+
+ // Refresh the popup values from the PopupMenuClient.
+ IntRect refresh(const IntRect& targetControlRect);
+
+ // The menu per-item data.
+ const WTF::Vector<PopupItem*>& popupData() const;
+
+ // The height of a row in the menu.
+ int menuItemHeight() const;
+
+ // The size of the font being used.
+ int menuItemFontSize() const;
+
+ // The style of the menu being used.
+ PopupMenuStyle menuStyle() const;
+
+ PopupType popupType() const { return m_popupType; }
+
+ // While hovering popup menu window, we want to show tool tip message.
+ String getSelectedItemToolTip();
+
+ // This is public for testing.
+ static IntRect layoutAndCalculateWidgetRectInternal(IntRect widgetRectInScreen, int targetControlHeight, const FloatRect& windowRect, const FloatRect& screen, bool isRTL, const int rtlOffset, const int verticalOffset, const IntSize& transformOffset, PopupContent*, bool& needToResizeView);
+
+private:
+ friend class WTF::RefCounted<PopupContainer>;
+
+ PopupContainer(PopupMenuClient*, PopupType, const PopupContainerSettings&);
+ ~PopupContainer();
+
+ // Paint the border.
+ void paintBorder(GraphicsContext*, const IntRect&);
+
+ // Layout and calculate popup widget size and location and returns it as IntRect.
+ IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const IntSize& transformOffset, const IntPoint& popupInitialCoordinate);
+
+ void fitToListBox();
+
+ // Returns the ChromeClient of the page this popup is associated with.
+ ChromeClient* chromeClient();
+
+ RefPtr<PopupListBox> m_listBox;
+ RefPtr<FrameView> m_frameView;
+
+ PopupContainerSettings m_settings;
+ PopupType m_popupType;
+
+ // m_controlPosition contains the transformed position of the
+ // <select>/<input> associated with this popup. m_controlSize is the size
+ // of the <select>/<input> without transform.
+ // The popup menu will be positioned as follows:
+ // LTR : If the popup is positioned down it will align with the bottom left
+ // of m_controlPosition (p4)
+ // If the popup is positioned up it will align with the top left of
+ // m_controlPosition (p1)
+ // RTL : If the popup is positioned down it will align with the bottom right
+ // of m_controlPosition (p3)
+ // If the popup is positioned up it will align with the top right of
+ // m_controlPosition (p2)
+ FloatQuad m_controlPosition;
+ IntSize m_controlSize;
+
+ // Whether the popup is currently open.
+ bool m_popupOpen;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/PopupListBox.cpp b/chromium/third_party/WebKit/Source/web/PopupListBox.cpp
new file mode 100644
index 00000000000..7c8732bdf53
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PopupListBox.cpp
@@ -0,0 +1,938 @@
+/*
+ * Copyright (c) 2011, Google Inc. 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 "PopupListBox.h"
+
+#include "CSSValueKeywords.h"
+#include "PopupContainer.h"
+#include "PopupMenuChromium.h"
+#include "RuntimeEnabledFeatures.h"
+#include "core/platform/PlatformGestureEvent.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/PlatformMouseEvent.h"
+#include "core/platform/PlatformScreen.h"
+#include "core/platform/PlatformTouchEvent.h"
+#include "core/platform/PlatformWheelEvent.h"
+#include "core/platform/PopupMenuClient.h"
+#include "core/platform/ScrollbarTheme.h"
+#include "core/platform/chromium/FramelessScrollViewClient.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "core/platform/graphics/Font.h"
+#include "core/platform/graphics/FontCache.h"
+#include "core/platform/graphics/FontSelector.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/IntRect.h"
+#include "core/platform/graphics/StringTruncator.h"
+#include "core/platform/graphics/TextRun.h"
+#include "core/rendering/RenderTheme.h"
+#include "wtf/ASCIICType.h"
+#include "wtf/CurrentTime.h"
+#include <limits>
+
+namespace WebCore {
+
+using namespace WTF::Unicode;
+
+static const int labelToIconPadding = 5;
+// Padding height put at the top and bottom of each line.
+static const int autofillLinePaddingHeight = 3;
+const int PopupListBox::defaultMaxHeight = 500;
+static const int maxVisibleRows = 20;
+static const int minEndOfLinePadding = 2;
+static const int textToLabelPadding = 10;
+static const TimeStamp typeAheadTimeoutMs = 1000;
+
+PopupListBox::PopupListBox(PopupMenuClient* client, const PopupContainerSettings& settings)
+ : m_settings(settings)
+ , m_originalIndex(0)
+ , m_selectedIndex(0)
+ , m_acceptedIndexOnAbandon(-1)
+ , m_visibleRows(0)
+ , m_baseWidth(0)
+ , m_maxHeight(defaultMaxHeight)
+ , m_popupClient(client)
+ , m_repeatingChar(0)
+ , m_lastCharTime(0)
+ , m_maxWindowWidth(std::numeric_limits<int>::max())
+{
+ setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
+}
+
+bool PopupListBox::handleMouseDownEvent(const PlatformMouseEvent& event)
+{
+ Scrollbar* scrollbar = scrollbarAtPoint(event.position());
+ if (scrollbar) {
+ m_capturingScrollbar = scrollbar;
+ m_capturingScrollbar->mouseDown(event);
+ return true;
+ }
+
+ if (!isPointInBounds(event.position()))
+ abandon();
+
+ return true;
+}
+
+bool PopupListBox::handleMouseMoveEvent(const PlatformMouseEvent& event)
+{
+ if (m_capturingScrollbar) {
+ m_capturingScrollbar->mouseMoved(event);
+ return true;
+ }
+
+ Scrollbar* scrollbar = scrollbarAtPoint(event.position());
+ if (m_lastScrollbarUnderMouse != scrollbar) {
+ // Send mouse exited to the old scrollbar.
+ if (m_lastScrollbarUnderMouse)
+ m_lastScrollbarUnderMouse->mouseExited();
+ m_lastScrollbarUnderMouse = scrollbar;
+ }
+
+ if (scrollbar) {
+ scrollbar->mouseMoved(event);
+ return true;
+ }
+
+ if (!isPointInBounds(event.position()))
+ return false;
+
+ selectIndex(pointToRowIndex(event.position()));
+ return true;
+}
+
+bool PopupListBox::handleMouseReleaseEvent(const PlatformMouseEvent& event)
+{
+ if (m_capturingScrollbar) {
+ m_capturingScrollbar->mouseUp(event);
+ m_capturingScrollbar = 0;
+ return true;
+ }
+
+ if (!isPointInBounds(event.position()))
+ return true;
+
+ // Need to check before calling acceptIndex(), because m_popupClient might
+ // be removed in acceptIndex() calling because of event handler.
+ bool isSelectPopup = m_popupClient->menuStyle().menuType() == PopupMenuStyle::SelectPopup;
+ if (acceptIndex(pointToRowIndex(event.position())) && m_focusedElement && isSelectPopup) {
+ m_focusedElement->dispatchMouseEvent(event, eventNames().mouseupEvent);
+ m_focusedElement->dispatchMouseEvent(event, eventNames().clickEvent);
+
+ // Clear m_focusedElement here, because we cannot clear in hidePopup()
+ // which is called before dispatchMouseEvent() is called.
+ m_focusedElement = 0;
+ }
+
+ return true;
+}
+
+bool PopupListBox::handleWheelEvent(const PlatformWheelEvent& event)
+{
+ if (!isPointInBounds(event.position())) {
+ abandon();
+ return true;
+ }
+
+ ScrollableArea::handleWheelEvent(event);
+ return true;
+}
+
+// Should be kept in sync with handleKeyEvent().
+bool PopupListBox::isInterestedInEventForKey(int keyCode)
+{
+ switch (keyCode) {
+ case VKEY_ESCAPE:
+ case VKEY_RETURN:
+ case VKEY_UP:
+ case VKEY_DOWN:
+ case VKEY_PRIOR:
+ case VKEY_NEXT:
+ case VKEY_HOME:
+ case VKEY_END:
+ case VKEY_TAB:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool PopupListBox::handleTouchEvent(const PlatformTouchEvent&)
+{
+ return false;
+}
+
+bool PopupListBox::handleGestureEvent(const PlatformGestureEvent&)
+{
+ return false;
+}
+
+static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event)
+{
+ // Check whether the event is a character-typed event or not.
+ // We use RawKeyDown/Char/KeyUp event scheme on all platforms,
+ // so PlatformKeyboardEvent::Char (not RawKeyDown) type event
+ // is considered as character type event.
+ return event.type() == PlatformEvent::Char;
+}
+
+bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event)
+{
+ if (event.type() == PlatformEvent::KeyUp)
+ return true;
+
+ if (!numItems() && event.windowsVirtualKeyCode() != VKEY_ESCAPE)
+ return true;
+
+ switch (event.windowsVirtualKeyCode()) {
+ case VKEY_ESCAPE:
+ abandon(); // may delete this
+ return true;
+ case VKEY_RETURN:
+ if (m_selectedIndex == -1) {
+ hidePopup();
+ // Don't eat the enter if nothing is selected.
+ return false;
+ }
+ acceptIndex(m_selectedIndex); // may delete this
+ return true;
+ case VKEY_UP:
+ case VKEY_DOWN:
+ // We have to forward only shift + up combination to focused node when
+ // autofill popup. Because all characters from the cursor to the start
+ // of the text area should selected when you press shift + up arrow.
+ // shift + down should be the similar way to shift + up.
+ if (event.modifiers() && m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup)
+ m_focusedElement->dispatchKeyEvent(event);
+ else if (event.windowsVirtualKeyCode() == VKEY_UP)
+ selectPreviousRow();
+ else
+ selectNextRow();
+ break;
+ case VKEY_PRIOR:
+ adjustSelectedIndex(-m_visibleRows);
+ break;
+ case VKEY_NEXT:
+ adjustSelectedIndex(m_visibleRows);
+ break;
+ case VKEY_HOME:
+ adjustSelectedIndex(-m_selectedIndex);
+ break;
+ case VKEY_END:
+ adjustSelectedIndex(m_items.size());
+ break;
+ default:
+ if (!event.ctrlKey() && !event.altKey() && !event.metaKey()
+ && isPrintableChar(event.windowsVirtualKeyCode())
+ && isCharacterTypeEvent(event))
+ typeAheadFind(event);
+ break;
+ }
+
+ if (m_originalIndex != m_selectedIndex) {
+ // Keyboard events should update the selection immediately (but we don't
+ // want to fire the onchange event until the popup is closed, to match
+ // IE). We change the original index so we revert to that when the
+ // popup is closed.
+ if (m_settings.acceptOnAbandon)
+ m_acceptedIndexOnAbandon = m_selectedIndex;
+
+ setOriginalIndex(m_selectedIndex);
+ if (m_settings.setTextOnIndexChange)
+ m_popupClient->setTextFromItem(m_selectedIndex);
+ }
+ if (event.windowsVirtualKeyCode() == VKEY_TAB) {
+ // TAB is a special case as it should select the current item if any and
+ // advance focus.
+ if (m_selectedIndex >= 0) {
+ acceptIndex(m_selectedIndex); // May delete us.
+ // Return false so the TAB key event is propagated to the page.
+ return false;
+ }
+ // Call abandon() so we honor m_acceptedIndexOnAbandon if set.
+ abandon();
+ // Return false so the TAB key event is propagated to the page.
+ return false;
+ }
+
+ return true;
+}
+
+HostWindow* PopupListBox::hostWindow() const
+{
+ // Our parent is the root ScrollView, so it is the one that has a
+ // HostWindow. FrameView::hostWindow() works similarly.
+ return parent() ? parent()->hostWindow() : 0;
+}
+
+// From HTMLSelectElement.cpp
+static String stripLeadingWhiteSpace(const String& string)
+{
+ int length = string.length();
+ int i;
+ for (i = 0; i < length; ++i)
+ if (string[i] != noBreakSpace
+ && (string[i] <= 0x7F ? !isASCIISpace(string[i]) : (direction(string[i]) != WhiteSpaceNeutral)))
+ break;
+
+ return string.substring(i, length - i);
+}
+
+// From HTMLSelectElement.cpp, with modifications
+void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event)
+{
+ TimeStamp now = static_cast<TimeStamp>(currentTime() * 1000.0f);
+ TimeStamp delta = now - m_lastCharTime;
+
+ // Reset the time when user types in a character. The time gap between
+ // last character and the current character is used to indicate whether
+ // user typed in a string or just a character as the search prefix.
+ m_lastCharTime = now;
+
+ UChar c = event.windowsVirtualKeyCode();
+
+ String prefix;
+ int searchStartOffset = 1;
+ if (delta > typeAheadTimeoutMs) {
+ m_typedString = prefix = String(&c, 1);
+ m_repeatingChar = c;
+ } else {
+ m_typedString.append(c);
+
+ if (c == m_repeatingChar) {
+ // The user is likely trying to cycle through all the items starting
+ // with this character, so just search on the character.
+ prefix = String(&c, 1);
+ } else {
+ m_repeatingChar = 0;
+ prefix = m_typedString;
+ searchStartOffset = 0;
+ }
+ }
+
+ // Compute a case-folded copy of the prefix string before beginning the
+ // search for a matching element. This code uses foldCase to work around the
+ // fact that String::startWith does not fold non-ASCII characters. This code
+ // can be changed to use startWith once that is fixed.
+ String prefixWithCaseFolded(prefix.foldCase());
+ int itemCount = numItems();
+ int index = (max(0, m_selectedIndex) + searchStartOffset) % itemCount;
+ for (int i = 0; i < itemCount; i++, index = (index + 1) % itemCount) {
+ if (!isSelectableItem(index))
+ continue;
+
+ if (stripLeadingWhiteSpace(m_items[index]->label).foldCase().startsWith(prefixWithCaseFolded)) {
+ selectIndex(index);
+ return;
+ }
+ }
+}
+
+void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
+{
+ // Adjust coords for scrolled frame.
+ IntRect r = intersection(rect, frameRect());
+ int tx = x() - scrollX();
+ int ty = y() - scrollY();
+
+ r.move(-tx, -ty);
+
+ // Set clip rect to match revised damage rect.
+ gc->save();
+ gc->translate(static_cast<float>(tx), static_cast<float>(ty));
+ gc->clip(r);
+
+ // FIXME: Can we optimize scrolling to not require repainting the entire
+ // window? Should we?
+ for (int i = 0; i < numItems(); ++i)
+ paintRow(gc, r, i);
+
+ // Special case for an empty popup.
+ if (!numItems())
+ gc->fillRect(r, Color::white);
+
+ gc->restore();
+
+ ScrollView::paint(gc, rect);
+}
+
+static const int separatorPadding = 4;
+static const int separatorHeight = 1;
+
+void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowIndex)
+{
+ // This code is based largely on RenderListBox::paint* methods.
+
+ IntRect rowRect = getRowBounds(rowIndex);
+ if (!rowRect.intersects(rect))
+ return;
+
+ PopupMenuStyle style = m_popupClient->itemStyle(rowIndex);
+
+ // Paint background
+ Color backColor, textColor, labelColor;
+ if (rowIndex == m_selectedIndex) {
+ backColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor();
+ textColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor();
+ labelColor = textColor;
+ } else {
+ backColor = style.backgroundColor();
+ textColor = style.foregroundColor();
+
+#if OS(LINUX)
+ // On other platforms, the <option> background color is the same as the
+ // <select> background color. On Linux, that makes the <option>
+ // background color very dark, so by default, try to use a lighter
+ // background color for <option>s.
+ if (style.backgroundColorType() == PopupMenuStyle::DefaultBackgroundColor && RenderTheme::defaultTheme()->systemColor(CSSValueButtonface) == backColor)
+ backColor = RenderTheme::defaultTheme()->systemColor(CSSValueMenu);
+#endif
+
+ // FIXME: for now the label color is hard-coded. It should be added to
+ // the PopupMenuStyle.
+ labelColor = Color(115, 115, 115);
+ }
+
+ // If we have a transparent background, make sure it has a color to blend
+ // against.
+ if (backColor.hasAlpha())
+ gc->fillRect(rowRect, Color::white);
+
+ gc->fillRect(rowRect, backColor);
+
+ // It doesn't look good but Autofill requires special style for separator.
+ // Autofill doesn't have padding and #dcdcdc color.
+ if (m_popupClient->itemIsSeparator(rowIndex)) {
+ int padding = style.menuType() == PopupMenuStyle::AutofillPopup ? 0 : separatorPadding;
+ IntRect separatorRect(
+ rowRect.x() + padding,
+ rowRect.y() + (rowRect.height() - separatorHeight) / 2,
+ rowRect.width() - 2 * padding, separatorHeight);
+ gc->fillRect(separatorRect, style.menuType() == PopupMenuStyle::AutofillPopup ? Color(0xdc, 0xdc, 0xdc) : textColor);
+ return;
+ }
+
+ if (!style.isVisible())
+ return;
+
+ gc->setFillColor(textColor);
+
+ FontCachePurgePreventer fontCachePurgePreventer;
+
+ Font itemFont = getRowFont(rowIndex);
+ // FIXME: http://crbug.com/19872 We should get the padding of individual option
+ // elements. This probably implies changes to PopupMenuClient.
+ bool rightAligned = m_popupClient->menuStyle().textDirection() == RTL;
+ int textX = 0;
+ int maxWidth = 0;
+ if (rightAligned)
+ maxWidth = rowRect.width() - max<int>(0, m_popupClient->clientPaddingRight() - m_popupClient->clientInsetRight());
+ else {
+ textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
+ maxWidth = rowRect.width() - textX;
+ }
+ // Prepare text to be drawn.
+ String itemText = m_popupClient->itemText(rowIndex);
+ String itemLabel = m_popupClient->itemLabel(rowIndex);
+ String itemIcon = m_popupClient->itemIcon(rowIndex);
+ if (m_settings.restrictWidthOfListBox) { // Truncate strings to fit in.
+ // FIXME: We should leftTruncate for the rtl case.
+ // StringTruncator::leftTruncate would have to be implemented.
+ String str = StringTruncator::rightTruncate(itemText, maxWidth, itemFont);
+ if (str != itemText) {
+ itemText = str;
+ // Don't display the label or icon, we already don't have enough
+ // room for the item text.
+ itemLabel = "";
+ itemIcon = "";
+ } else if (!itemLabel.isEmpty()) {
+ int availableWidth = maxWidth - textToLabelPadding - StringTruncator::width(itemText, itemFont);
+ itemLabel = StringTruncator::rightTruncate(itemLabel, availableWidth, itemFont);
+ }
+ }
+
+ // Prepare the directionality to draw text.
+ TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride());
+ // If the text is right-to-left, make it right-aligned by adjusting its
+ // beginning position.
+ if (rightAligned)
+ textX += maxWidth - itemFont.width(textRun);
+
+ // Draw the item text.
+ int textY = rowRect.y() + itemFont.fontMetrics().ascent() + (rowRect.height() - itemFont.fontMetrics().height()) / 2;
+ TextRunPaintInfo textRunPaintInfo(textRun);
+ textRunPaintInfo.bounds = rowRect;
+ gc->drawBidiText(itemFont, textRunPaintInfo, IntPoint(textX, textY));
+
+ // We are using the left padding as the right padding includes room for the scroll-bar which
+ // does not show in this case.
+ int rightPadding = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
+ int remainingWidth = rowRect.width() - rightPadding;
+
+ // Draw the icon if applicable.
+ RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data()));
+ if (image && !image->isNull()) {
+ IntRect imageRect = image->rect();
+ remainingWidth -= (imageRect.width() + labelToIconPadding);
+ imageRect.setX(rowRect.width() - rightPadding - imageRect.width());
+ imageRect.setY(rowRect.y() + (rowRect.height() - imageRect.height()) / 2);
+ gc->drawImage(image.get(), imageRect);
+ }
+
+ // Draw the the label if applicable.
+ if (itemLabel.isEmpty())
+ return;
+
+ // Autofill label is 0.9 smaller than regular font size.
+ if (style.menuType() == PopupMenuStyle::AutofillPopup) {
+ itemFont = m_popupClient->itemStyle(rowIndex).font();
+ FontDescription d = itemFont.fontDescription();
+ d.setComputedSize(d.computedSize() * 0.9);
+ itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
+ itemFont.update(0);
+ }
+
+ TextRun labelTextRun(itemLabel, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride());
+ if (rightAligned)
+ textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
+ else
+ textX = remainingWidth - itemFont.width(labelTextRun);
+ TextRunPaintInfo labelTextRunPaintInfo(labelTextRun);
+ labelTextRunPaintInfo.bounds = rowRect;
+
+ gc->setFillColor(labelColor);
+ gc->drawBidiText(itemFont, labelTextRunPaintInfo, IntPoint(textX, textY));
+}
+
+Font PopupListBox::getRowFont(int rowIndex)
+{
+ Font itemFont = m_popupClient->itemStyle(rowIndex).font();
+ if (m_popupClient->itemIsLabel(rowIndex)) {
+ // Bold-ify labels (ie, an <optgroup> heading).
+ FontDescription d = itemFont.fontDescription();
+ d.setWeight(FontWeightBold);
+ Font font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
+ font.update(0);
+ return font;
+ }
+
+ return itemFont;
+}
+
+void PopupListBox::abandon()
+{
+ RefPtr<PopupListBox> keepAlive(this);
+
+ m_selectedIndex = m_originalIndex;
+
+ hidePopup();
+
+ if (m_acceptedIndexOnAbandon >= 0) {
+ if (m_popupClient)
+ m_popupClient->valueChanged(m_acceptedIndexOnAbandon);
+ m_acceptedIndexOnAbandon = -1;
+ }
+}
+
+int PopupListBox::pointToRowIndex(const IntPoint& point)
+{
+ int y = scrollY() + point.y();
+
+ // FIXME: binary search if perf matters.
+ for (int i = 0; i < numItems(); ++i) {
+ if (y < m_items[i]->yOffset)
+ return i-1;
+ }
+
+ // Last item?
+ if (y < contentsHeight())
+ return m_items.size()-1;
+
+ return -1;
+}
+
+bool PopupListBox::acceptIndex(int index)
+{
+ // Clear m_acceptedIndexOnAbandon once user accepts the selected index.
+ if (m_acceptedIndexOnAbandon >= 0)
+ m_acceptedIndexOnAbandon = -1;
+
+ if (index >= numItems())
+ return false;
+
+ if (index < 0) {
+ if (m_popupClient) {
+ // Enter pressed with no selection, just close the popup.
+ hidePopup();
+ }
+ return false;
+ }
+
+ if (isSelectableItem(index)) {
+ RefPtr<PopupListBox> keepAlive(this);
+
+ // Hide ourselves first since valueChanged may have numerous side-effects.
+ hidePopup();
+
+ // Tell the <select> PopupMenuClient what index was selected.
+ m_popupClient->valueChanged(index);
+
+ return true;
+ }
+
+ return false;
+}
+
+void PopupListBox::selectIndex(int index)
+{
+ if (index < 0 || index >= numItems())
+ return;
+
+ bool isSelectable = isSelectableItem(index);
+ if (index != m_selectedIndex && isSelectable) {
+ invalidateRow(m_selectedIndex);
+ m_selectedIndex = index;
+ invalidateRow(m_selectedIndex);
+
+ scrollToRevealSelection();
+ m_popupClient->selectionChanged(m_selectedIndex);
+ } else if (!isSelectable)
+ clearSelection();
+}
+
+void PopupListBox::setOriginalIndex(int index)
+{
+ m_originalIndex = m_selectedIndex = index;
+}
+
+int PopupListBox::getRowHeight(int index)
+{
+ int minimumHeight = PopupMenuChromium::minimumRowHeight();
+ if (m_settings.deviceSupportsTouch)
+ minimumHeight = max(minimumHeight, PopupMenuChromium::optionRowHeightForTouch());
+
+ if (index < 0 || m_popupClient->itemStyle(index).isDisplayNone())
+ return minimumHeight;
+
+ // Separator row height is the same size as itself.
+ if (m_popupClient->itemIsSeparator(index))
+ return max(separatorHeight, minimumHeight);
+
+ String icon = m_popupClient->itemIcon(index);
+ RefPtr<Image> image(Image::loadPlatformResource(icon.utf8().data()));
+
+ int fontHeight = getRowFont(index).fontMetrics().height();
+ int iconHeight = (image && !image->isNull()) ? image->rect().height() : 0;
+
+ int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? autofillLinePaddingHeight : 0;
+ int calculatedRowHeight = max(fontHeight, iconHeight) + linePaddingHeight * 2;
+ return max(calculatedRowHeight, minimumHeight);
+}
+
+IntRect PopupListBox::getRowBounds(int index)
+{
+ if (index < 0)
+ return IntRect(0, 0, visibleWidth(), getRowHeight(index));
+
+ return IntRect(0, m_items[index]->yOffset, visibleWidth(), getRowHeight(index));
+}
+
+void PopupListBox::invalidateRow(int index)
+{
+ if (index < 0)
+ return;
+
+ // Invalidate in the window contents, as FramelessScrollView::invalidateRect
+ // paints in the window coordinates.
+ invalidateRect(contentsToWindow(getRowBounds(index)));
+}
+
+void PopupListBox::scrollToRevealRow(int index)
+{
+ if (index < 0)
+ return;
+
+ IntRect rowRect = getRowBounds(index);
+
+ if (rowRect.y() < scrollY()) {
+ // Row is above current scroll position, scroll up.
+ ScrollView::setScrollPosition(IntPoint(0, rowRect.y()));
+ } else if (rowRect.maxY() > scrollY() + visibleHeight()) {
+ // Row is below current scroll position, scroll down.
+ ScrollView::setScrollPosition(IntPoint(0, rowRect.maxY() - visibleHeight()));
+ }
+}
+
+bool PopupListBox::isSelectableItem(int index)
+{
+ ASSERT(index >= 0 && index < numItems());
+ return m_items[index]->type == PopupItem::TypeOption && m_popupClient->itemIsEnabled(index);
+}
+
+void PopupListBox::clearSelection()
+{
+ if (m_selectedIndex != -1) {
+ invalidateRow(m_selectedIndex);
+ m_selectedIndex = -1;
+ m_popupClient->selectionCleared();
+ }
+}
+
+void PopupListBox::selectNextRow()
+{
+ if (!m_settings.loopSelectionNavigation || m_selectedIndex != numItems() - 1) {
+ adjustSelectedIndex(1);
+ return;
+ }
+
+ // We are moving past the last item, no row should be selected.
+ clearSelection();
+}
+
+void PopupListBox::selectPreviousRow()
+{
+ if (!m_settings.loopSelectionNavigation || m_selectedIndex > 0) {
+ adjustSelectedIndex(-1);
+ return;
+ }
+
+ if (!m_selectedIndex) {
+ // We are moving past the first item, clear the selection.
+ clearSelection();
+ return;
+ }
+
+ // No row is selected, jump to the last item.
+ selectIndex(numItems() - 1);
+ scrollToRevealSelection();
+}
+
+void PopupListBox::adjustSelectedIndex(int delta)
+{
+ int targetIndex = m_selectedIndex + delta;
+ targetIndex = std::min(std::max(targetIndex, 0), numItems() - 1);
+ if (!isSelectableItem(targetIndex)) {
+ // We didn't land on an option. Try to find one.
+ // We try to select the closest index to target, prioritizing any in
+ // the range [current, target].
+
+ int dir = delta > 0 ? 1 : -1;
+ int testIndex = m_selectedIndex;
+ int bestIndex = m_selectedIndex;
+ bool passedTarget = false;
+ while (testIndex >= 0 && testIndex < numItems()) {
+ if (isSelectableItem(testIndex))
+ bestIndex = testIndex;
+ if (testIndex == targetIndex)
+ passedTarget = true;
+ if (passedTarget && bestIndex != m_selectedIndex)
+ break;
+
+ testIndex += dir;
+ }
+
+ // Pick the best index, which may mean we don't change.
+ targetIndex = bestIndex;
+ }
+
+ // Select the new index, and ensure its visible. We do this regardless of
+ // whether the selection changed to ensure keyboard events always bring the
+ // selection into view.
+ selectIndex(targetIndex);
+ scrollToRevealSelection();
+}
+
+void PopupListBox::hidePopup()
+{
+ if (parent()) {
+ PopupContainer* container = static_cast<PopupContainer*>(parent());
+ if (container->client())
+ container->client()->popupClosed(container);
+ container->notifyPopupHidden();
+ }
+
+ if (m_popupClient)
+ m_popupClient->popupDidHide();
+}
+
+void PopupListBox::updateFromElement()
+{
+ clear();
+
+ int size = m_popupClient->listSize();
+ for (int i = 0; i < size; ++i) {
+ PopupItem::Type type;
+ if (m_popupClient->itemIsSeparator(i))
+ type = PopupItem::TypeSeparator;
+ else if (m_popupClient->itemIsLabel(i))
+ type = PopupItem::TypeGroup;
+ else
+ type = PopupItem::TypeOption;
+ m_items.append(new PopupItem(m_popupClient->itemText(i), type));
+ m_items[i]->enabled = isSelectableItem(i);
+ PopupMenuStyle style = m_popupClient->itemStyle(i);
+ m_items[i]->textDirection = style.textDirection();
+ m_items[i]->hasTextDirectionOverride = style.hasTextDirectionOverride();
+ }
+
+ m_selectedIndex = m_popupClient->selectedIndex();
+ setOriginalIndex(m_selectedIndex);
+
+ layout();
+}
+
+void PopupListBox::setMaxWidthAndLayout(int maxWidth)
+{
+ m_maxWindowWidth = maxWidth;
+ layout();
+}
+
+void PopupListBox::layout()
+{
+ bool isRightAligned = m_popupClient->menuStyle().textDirection() == RTL;
+
+ // Size our child items.
+ int baseWidth = 0;
+ int paddingWidth = 0;
+ int lineEndPaddingWidth = 0;
+ int y = 0;
+ for (int i = 0; i < numItems(); ++i) {
+ // Place the item vertically.
+ m_items[i]->yOffset = y;
+ if (m_popupClient->itemStyle(i).isDisplayNone())
+ continue;
+ y += getRowHeight(i);
+
+ // Ensure the popup is wide enough to fit this item.
+ Font itemFont = getRowFont(i);
+ String text = m_popupClient->itemText(i);
+ String label = m_popupClient->itemLabel(i);
+ String icon = m_popupClient->itemIcon(i);
+ RefPtr<Image> iconImage(Image::loadPlatformResource(icon.utf8().data()));
+ int width = 0;
+ if (!text.isEmpty())
+ width = itemFont.width(TextRun(text));
+ if (!label.isEmpty()) {
+ if (width > 0)
+ width += textToLabelPadding;
+ width += itemFont.width(TextRun(label));
+ }
+ if (iconImage && !iconImage->isNull()) {
+ if (width > 0)
+ width += labelToIconPadding;
+ width += iconImage->rect().width();
+ }
+
+ baseWidth = max(baseWidth, width);
+ // FIXME: http://b/1210481 We should get the padding of individual
+ // option elements.
+ paddingWidth = max<int>(paddingWidth,
+ m_popupClient->clientPaddingLeft() + m_popupClient->clientPaddingRight());
+ lineEndPaddingWidth = max<int>(lineEndPaddingWidth,
+ isRightAligned ? m_popupClient->clientPaddingLeft() : m_popupClient->clientPaddingRight());
+ }
+
+ // Calculate scroll bar width.
+ int windowHeight = 0;
+ m_visibleRows = std::min(numItems(), maxVisibleRows);
+
+ for (int i = 0; i < m_visibleRows; ++i) {
+ int rowHeight = getRowHeight(i);
+
+ // Only clip the window height for non-Mac platforms.
+ if (windowHeight + rowHeight > m_maxHeight) {
+ m_visibleRows = i;
+ break;
+ }
+
+ windowHeight += rowHeight;
+ }
+
+ // Set our widget and scrollable contents sizes.
+ int scrollbarWidth = 0;
+ if (m_visibleRows < numItems()) {
+ scrollbarWidth = ScrollbarTheme::theme()->scrollbarThickness();
+
+ // Use minEndOfLinePadding when there is a scrollbar so that we use
+ // as much as (lineEndPaddingWidth - minEndOfLinePadding) padding
+ // space for scrollbar and allow user to use CSS padding to make the
+ // popup listbox align with the select element.
+ paddingWidth = paddingWidth - lineEndPaddingWidth + minEndOfLinePadding;
+ }
+
+ int windowWidth;
+ int contentWidth;
+ if (m_settings.restrictWidthOfListBox) {
+ windowWidth = m_baseWidth;
+ contentWidth = m_baseWidth - scrollbarWidth;
+ } else {
+ windowWidth = baseWidth + scrollbarWidth + paddingWidth;
+ if (windowWidth > m_maxWindowWidth) {
+ // windowWidth exceeds m_maxWindowWidth, so we have to clip.
+ windowWidth = m_maxWindowWidth;
+ baseWidth = windowWidth - scrollbarWidth - paddingWidth;
+ m_baseWidth = baseWidth;
+ }
+ contentWidth = windowWidth - scrollbarWidth;
+
+ if (windowWidth < m_baseWidth) {
+ windowWidth = m_baseWidth;
+ contentWidth = m_baseWidth - scrollbarWidth;
+ } else
+ m_baseWidth = baseWidth;
+ }
+
+ resize(windowWidth, windowHeight);
+ setContentsSize(IntSize(contentWidth, getRowBounds(numItems() - 1).maxY()));
+
+ if (hostWindow())
+ scrollToRevealSelection();
+
+ invalidate();
+}
+
+void PopupListBox::clear()
+{
+ for (Vector<PopupItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it)
+ delete *it;
+ m_items.clear();
+}
+
+bool PopupListBox::isPointInBounds(const IntPoint& point)
+{
+ return numItems() && IntRect(0, 0, width(), height()).contains(point);
+}
+
+int PopupListBox::popupContentHeight() const
+{
+ return height();
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/PopupListBox.h b/chromium/third_party/WebKit/Source/web/PopupListBox.h
new file mode 100644
index 00000000000..3a12389b5f7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PopupListBox.h
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 2011, Google Inc. 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 PopupListBox_h
+#define PopupListBox_h
+
+#include "core/dom/Element.h"
+#include "core/platform/chromium/FramelessScrollView.h"
+#include "core/platform/text/TextDirection.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+typedef unsigned long long TimeStamp;
+
+class Font;
+class GraphicsContext;
+class IntRect;
+class PlatformKeyboardEvent;
+class PlatformMouseEvent;
+class PlatformGestureEvent;
+class PlatformTouchEvent;
+class PlatformWheelEvent;
+class PopupMenuClient;
+
+struct PopupContainerSettings {
+ // Whether the PopupMenuClient should be told to change its text when a
+ // new item is selected by using the arrow keys.
+ bool setTextOnIndexChange;
+
+ // Whether the selection should be accepted when the popup menu is
+ // closed (through ESC being pressed or the focus going away).
+ // Note that when TAB is pressed, the selection is always accepted
+ // regardless of this setting.
+ bool acceptOnAbandon;
+
+ // Whether we should move the selection to the first/last item when
+ // the user presses down/up arrow keys and the last/first item is
+ // selected.
+ bool loopSelectionNavigation;
+
+ // Whether we should restrict the width of the PopupListBox or not.
+ // Autocomplete popups are restricted, combo-boxes (select tags) aren't.
+ bool restrictWidthOfListBox;
+
+ // If the device is a touch screen we increase the height of menu items
+ // to make it easier to unambiguously touch them.
+ bool deviceSupportsTouch;
+};
+
+class PopupContent {
+public:
+ virtual void layout() = 0;
+ virtual void setMaxHeight(int) = 0;
+ virtual void setMaxWidthAndLayout(int) = 0;
+ virtual int popupContentHeight() const = 0;
+ virtual ~PopupContent() { };
+};
+
+// A container for the data for each menu item (e.g. represented by <option>
+// or <optgroup> in a <select> widget) and is used by PopupListBox.
+struct PopupItem {
+ enum Type {
+ TypeOption,
+ TypeGroup,
+ TypeSeparator
+ };
+
+ PopupItem(const String& label, Type type)
+ : label(label)
+ , type(type)
+ , yOffset(0)
+ {
+ }
+ String label;
+ Type type;
+ int yOffset; // y offset of this item, relative to the top of the popup.
+ TextDirection textDirection;
+ bool hasTextDirectionOverride;
+ bool enabled;
+};
+
+// This class uses WebCore code to paint and handle events for a drop-down list
+// box ("combobox" on Windows).
+class PopupListBox : public FramelessScrollView, public PopupContent {
+public:
+ static PassRefPtr<PopupListBox> create(PopupMenuClient* client, const PopupContainerSettings& settings)
+ {
+ return adoptRef(new PopupListBox(client, settings));
+ }
+
+ // FramelessScrollView
+ virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
+ virtual bool handleMouseDownEvent(const PlatformMouseEvent&) OVERRIDE;
+ virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) OVERRIDE;
+ virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) OVERRIDE;
+ virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
+ virtual bool handleKeyEvent(const PlatformKeyboardEvent&) OVERRIDE;
+ virtual bool handleTouchEvent(const PlatformTouchEvent&) OVERRIDE;
+ virtual bool handleGestureEvent(const PlatformGestureEvent&) OVERRIDE;
+
+ // ScrollView
+ virtual HostWindow* hostWindow() const OVERRIDE;
+
+ // PopupListBox methods
+
+ // Hides the popup.
+ void hidePopup();
+
+ // Updates our internal list to match the client.
+ void updateFromElement();
+
+ // Frees any allocated resources used in a particular popup session.
+ void clear();
+
+ // Sets the index of the option that is displayed in the <select> widget in the page
+ void setOriginalIndex(int);
+
+ // Gets the index of the item that the user is currently moused over or has
+ // selected with the keyboard. This is not the same as the original index,
+ // since the user has not yet accepted this input.
+ int selectedIndex() const { return m_selectedIndex; }
+
+ // Moves selection down/up the given number of items, scrolling if necessary.
+ // Positive is down. The resulting index will be clamped to the range
+ // [0, numItems), and non-option items will be skipped.
+ void adjustSelectedIndex(int delta);
+
+ // Returns the number of items in the list.
+ int numItems() const { return static_cast<int>(m_items.size()); }
+
+ void setBaseWidth(int width) { m_baseWidth = std::min(m_maxWindowWidth, width); }
+
+ // Computes the size of widget and children.
+ virtual void layout() OVERRIDE;
+
+ // Returns whether the popup wants to process events for the passed key.
+ bool isInterestedInEventForKey(int keyCode);
+
+ // Gets the height of a row.
+ int getRowHeight(int index);
+
+ virtual void setMaxHeight(int maxHeight) OVERRIDE { m_maxHeight = maxHeight; }
+
+ void setMaxWidth(int maxWidth) { m_maxWindowWidth = maxWidth; }
+
+ virtual void setMaxWidthAndLayout(int) OVERRIDE;
+
+ void disconnectClient() { m_popupClient = 0; }
+
+ const Vector<PopupItem*>& items() const { return m_items; }
+
+ virtual int popupContentHeight() const OVERRIDE;
+
+ static const int defaultMaxHeight;
+
+private:
+ friend class PopupContainer;
+ friend class RefCounted<PopupListBox>;
+
+ PopupListBox(PopupMenuClient*, const PopupContainerSettings&);
+
+ virtual ~PopupListBox()
+ {
+ clear();
+ }
+
+ // Closes the popup
+ void abandon();
+
+ // Returns true if the selection can be changed to index.
+ // Disabled items, or labels cannot be selected.
+ bool isSelectableItem(int index);
+
+ // Select an index in the list, scrolling if necessary.
+ void selectIndex(int index);
+
+ // Accepts the selected index as the value to be displayed in the <select>
+ // widget on the web page, and closes the popup. Returns true if index is
+ // accepted.
+ bool acceptIndex(int index);
+
+ // Clears the selection (so no row appears selected).
+ void clearSelection();
+
+ // Scrolls to reveal the given index.
+ void scrollToRevealRow(int index);
+ void scrollToRevealSelection() { scrollToRevealRow(m_selectedIndex); }
+
+ // Invalidates the row at the given index.
+ void invalidateRow(int index);
+
+ // Get the bounds of a row.
+ IntRect getRowBounds(int index);
+
+ // Converts a point to an index of the row the point is over
+ int pointToRowIndex(const IntPoint&);
+
+ // Paint an individual row
+ void paintRow(GraphicsContext*, const IntRect&, int rowIndex);
+
+ // Test if the given point is within the bounds of the popup window.
+ bool isPointInBounds(const IntPoint&);
+
+ // Called when the user presses a text key. Does a prefix-search of the items.
+ void typeAheadFind(const PlatformKeyboardEvent&);
+
+ // Returns the font to use for the given row
+ Font getRowFont(int index);
+
+ // Moves the selection down/up one item, taking care of looping back to the
+ // first/last element if m_loopSelectionNavigation is true.
+ void selectPreviousRow();
+ void selectNextRow();
+
+ // The settings that specify the behavior for this Popup window.
+ PopupContainerSettings m_settings;
+
+ // This is the index of the item marked as "selected" - i.e. displayed in
+ // the widget on the page.
+ int m_originalIndex;
+
+ // This is the index of the item that the user is hovered over or has
+ // selected using the keyboard in the list. They have not confirmed this
+ // selection by clicking or pressing enter yet however.
+ int m_selectedIndex;
+
+ // If >= 0, this is the index we should accept if the popup is "abandoned".
+ // This is used for keyboard navigation, where we want the
+ // selection to change immediately, and is only used if the settings
+ // acceptOnAbandon field is true.
+ int m_acceptedIndexOnAbandon;
+
+ // This is the number of rows visible in the popup. The maximum number
+ // visible at a time is defined as being kMaxVisibleRows. For a scrolled
+ // popup, this can be thought of as the page size in data units.
+ int m_visibleRows;
+
+ // Our suggested width, not including scrollbar.
+ int m_baseWidth;
+
+ // The maximum height we can be without being off-screen.
+ int m_maxHeight;
+
+ // A list of the options contained within the <select>
+ Vector<PopupItem*> m_items;
+
+ // The <select> PopupMenuClient that opened us.
+ PopupMenuClient* m_popupClient;
+
+ // The scrollbar which has mouse capture. Mouse events go straight to this
+ // if not null.
+ RefPtr<Scrollbar> m_capturingScrollbar;
+
+ // The last scrollbar that the mouse was over. Used for mouseover highlights.
+ RefPtr<Scrollbar> m_lastScrollbarUnderMouse;
+
+ // The string the user has typed so far into the popup. Used for typeAheadFind.
+ String m_typedString;
+
+ // The char the user has hit repeatedly. Used for typeAheadFind.
+ UChar m_repeatingChar;
+
+ // The last time the user hit a key. Used for typeAheadFind.
+ TimeStamp m_lastCharTime;
+
+ // If width exeeds screen width, we have to clip it.
+ int m_maxWindowWidth;
+
+ // To forward last mouse release event.
+ RefPtr<Element> m_focusedElement;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/PopupMenuChromium.cpp b/chromium/third_party/WebKit/Source/web/PopupMenuChromium.cpp
new file mode 100644
index 00000000000..6e4e7fb3d74
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PopupMenuChromium.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2008, 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 "PopupMenuChromium.h"
+
+#include "PopupContainer.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+
+namespace WebCore {
+
+int PopupMenuChromium::s_minimumRowHeight = 0;
+int PopupMenuChromium::s_optionRowHeightForTouch = 28;
+
+// The settings used for the drop down menu.
+// This is the delegate used if none is provided.
+static const PopupContainerSettings dropDownSettings = {
+ true, // setTextOnIndexChange
+ true, // acceptOnAbandon
+ false, // loopSelectionNavigation
+ false // restrictWidthOfListBox
+};
+
+PopupMenuChromium::PopupMenuChromium(Frame& frame, PopupMenuClient* client)
+ : m_popupClient(client)
+ , m_frameView(frame.view())
+{
+}
+
+PopupMenuChromium::~PopupMenuChromium()
+{
+ // When the PopupMenuChromium is destroyed, the client could already have been
+ // deleted.
+ if (m_popup)
+ m_popup->listBox()->disconnectClient();
+ hide();
+}
+
+void PopupMenuChromium::show(const FloatQuad& controlPosition, const IntSize& controlSize, int index)
+{
+ if (!m_popup) {
+ Settings* settings = m_frameView->frame()->page()->settings();
+ PopupContainerSettings popupSettings = dropDownSettings;
+ popupSettings.deviceSupportsTouch = settings->deviceSupportsTouch();
+ m_popup = PopupContainer::create(client(), PopupContainer::Select, popupSettings);
+ }
+ m_popup->showInRect(controlPosition, controlSize, m_frameView.get(), index);
+}
+
+void PopupMenuChromium::hide()
+{
+ if (m_popup)
+ m_popup->hide();
+}
+
+void PopupMenuChromium::updateFromElement()
+{
+ m_popup->listBox()->updateFromElement();
+}
+
+
+void PopupMenuChromium::disconnectClient()
+{
+ m_popupClient = 0;
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/PopupMenuChromium.h b/chromium/third_party/WebKit/Source/web/PopupMenuChromium.h
new file mode 100644
index 00000000000..6db66fd89fe
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PopupMenuChromium.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2008, 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 PopupMenuChromium_h
+#define PopupMenuChromium_h
+
+#include "core/platform/PopupMenu.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+
+class Frame;
+class FrameView;
+class IntRect;
+class PopupContainer;
+struct PopupItem;
+class PopupMenuClient;
+
+class PopupMenuChromium : public PopupMenu {
+public:
+ PopupMenuChromium(Frame&, PopupMenuClient*);
+ ~PopupMenuChromium();
+
+ virtual void show(const FloatQuad& controlPosition, const IntSize& controlSize, int index) OVERRIDE;
+ virtual void hide() OVERRIDE;
+ virtual void updateFromElement() OVERRIDE;
+ virtual void disconnectClient() OVERRIDE;
+
+ static int minimumRowHeight() { return s_minimumRowHeight; }
+ static void setMinimumRowHeight(int minimumRowHeight) { s_minimumRowHeight = minimumRowHeight; }
+ static int optionRowHeightForTouch() { return s_optionRowHeightForTouch; }
+ static void setOptionRowHeightForTouch(int optionRowHeightForTouch) { s_optionRowHeightForTouch = optionRowHeightForTouch; }
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ RefPtr<FrameView> m_frameView;
+ RefPtr<PopupContainer> m_popup;
+
+ static int s_minimumRowHeight;
+ static int s_optionRowHeightForTouch;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/PrerendererClientImpl.cpp b/chromium/third_party/WebKit/Source/web/PrerendererClientImpl.cpp
new file mode 100644
index 00000000000..cd9107bf2b7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PrerendererClientImpl.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "PrerendererClientImpl.h"
+
+#include "WebPrerendererClient.h"
+#include "WebViewImpl.h"
+#include "core/dom/Document.h"
+#include "core/page/Frame.h"
+#include "core/platform/PrerenderHandle.h"
+#include "core/platform/chromium/Prerender.h"
+#include "public/platform/WebPrerender.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebKit {
+
+PrerendererClientImpl::PrerendererClientImpl(WebPrerendererClient* client)
+ : m_client(client)
+{
+}
+
+void PrerendererClientImpl::willAddPrerender(WebCore::PrerenderHandle* prerenderHandle)
+{
+ if (!m_client)
+ return;
+ WebPrerender webPrerender(prerenderHandle->prerender());
+ m_client->willAddPrerender(&webPrerender);
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/PrerendererClientImpl.h b/chromium/third_party/WebKit/Source/web/PrerendererClientImpl.h
new file mode 100644
index 00000000000..9568619b547
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/PrerendererClientImpl.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 PrerendererClientImpl_h
+#define PrerendererClientImpl_h
+
+#include "core/loader/PrerendererClient.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebCore {
+class PrerenderHandle;
+}
+
+namespace WebKit {
+
+class WebPrerendererClient;
+
+class PrerendererClientImpl : public WebCore::PrerendererClient {
+ WTF_MAKE_NONCOPYABLE(PrerendererClientImpl);
+public:
+ explicit PrerendererClientImpl(WebPrerendererClient*);
+
+ void willAddPrerender(WebCore::PrerenderHandle*) OVERRIDE;
+
+private:
+ WebPrerendererClient* m_client;
+};
+
+}
+
+#endif // PrerendererClientImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/ScrollbarGroup.cpp b/chromium/third_party/WebKit/Source/web/ScrollbarGroup.cpp
new file mode 100644
index 00000000000..f44ec53d67a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ScrollbarGroup.cpp
@@ -0,0 +1,290 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "ScrollbarGroup.h"
+
+#include "WebPluginScrollbarImpl.h"
+#include "core/page/FrameView.h"
+#include "core/platform/Scrollbar.h"
+#include "core/platform/ScrollbarTheme.h"
+#include "public/platform/WebRect.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ScrollbarGroup::ScrollbarGroup(FrameView* frameView, const IntRect& frameRect)
+ : m_frameView(frameView)
+ , m_frameRect(frameRect)
+ , m_horizontalScrollbar(0)
+ , m_verticalScrollbar(0)
+{
+}
+
+ScrollbarGroup::~ScrollbarGroup()
+{
+ ASSERT(!m_horizontalScrollbar);
+ ASSERT(!m_verticalScrollbar);
+}
+
+void ScrollbarGroup::scrollbarCreated(WebPluginScrollbarImpl* scrollbar)
+{
+ bool hadScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
+ if (scrollbar->scrollbar()->orientation() == HorizontalScrollbar) {
+ ASSERT(!m_horizontalScrollbar);
+ m_horizontalScrollbar = scrollbar;
+ didAddHorizontalScrollbar(scrollbar->scrollbar());
+ } else {
+ ASSERT(!m_verticalScrollbar);
+ m_verticalScrollbar = scrollbar;
+ didAddVerticalScrollbar(scrollbar->scrollbar());
+ }
+
+ if (!hadScrollbars) {
+ m_frameView->addScrollableArea(this);
+ m_frameView->setNeedsLayout();
+ }
+}
+
+void ScrollbarGroup::scrollbarDestroyed(WebPluginScrollbarImpl* scrollbar)
+{
+ if (scrollbar == m_horizontalScrollbar) {
+ willRemoveHorizontalScrollbar(scrollbar->scrollbar());
+ m_horizontalScrollbar = 0;
+ } else {
+ ASSERT(scrollbar == m_verticalScrollbar);
+ willRemoveVerticalScrollbar(scrollbar->scrollbar());
+ m_verticalScrollbar = 0;
+ }
+
+ if (!m_horizontalScrollbar && !m_verticalScrollbar) {
+ m_frameView->removeScrollableArea(this);
+ m_frameView->setNeedsLayout();
+ }
+}
+
+void ScrollbarGroup::setLastMousePosition(const IntPoint& point)
+{
+ m_lastMousePosition = point;
+}
+
+int ScrollbarGroup::scrollSize(WebCore::ScrollbarOrientation orientation) const
+{
+ WebPluginScrollbarImpl* webScrollbar = orientation == HorizontalScrollbar ? m_horizontalScrollbar : m_verticalScrollbar;
+ if (!webScrollbar)
+ return 0;
+ Scrollbar* scrollbar = webScrollbar->scrollbar();
+ return scrollbar->totalSize() - scrollbar->visibleSize();
+}
+
+void ScrollbarGroup::setScrollOffset(const IntPoint& offset)
+{
+ if (m_horizontalScrollbar && m_horizontalScrollbar->scrollOffset() != offset.x())
+ m_horizontalScrollbar->setScrollOffset(offset.x());
+ else if (m_verticalScrollbar && m_verticalScrollbar->scrollOffset() != offset.y())
+ m_verticalScrollbar->setScrollOffset(offset.y());
+}
+
+void ScrollbarGroup::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
+{
+ if (m_horizontalScrollbar && scrollbar == m_horizontalScrollbar->scrollbar())
+ m_horizontalScrollbar->invalidateScrollbarRect(rect);
+ else if (m_verticalScrollbar && scrollbar == m_verticalScrollbar->scrollbar())
+ m_verticalScrollbar->invalidateScrollbarRect(rect);
+}
+
+void ScrollbarGroup::invalidateScrollCornerRect(const IntRect&)
+{
+}
+
+bool ScrollbarGroup::isActive() const
+{
+ return true;
+}
+
+ScrollableArea* ScrollbarGroup::enclosingScrollableArea() const
+{
+ // FIXME: Return a parent scrollable area that can be scrolled.
+ return 0;
+}
+
+void ScrollbarGroup::setFrameRect(const IntRect& frameRect)
+{
+ m_frameRect = frameRect;
+}
+
+IntRect ScrollbarGroup::scrollableAreaBoundingBox() const
+{
+ return m_frameRect;
+}
+
+bool ScrollbarGroup::isScrollCornerVisible() const
+{
+ return false;
+}
+
+void ScrollbarGroup::getTickmarks(Vector<IntRect>& tickmarks) const
+{
+ if (m_verticalScrollbar)
+ m_verticalScrollbar->getTickmarks(tickmarks);
+}
+
+IntPoint ScrollbarGroup::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const
+{
+ if (m_horizontalScrollbar && scrollbar == m_horizontalScrollbar->scrollbar())
+ return m_horizontalScrollbar->convertFromContainingViewToScrollbar(parentPoint);
+ if (m_verticalScrollbar && scrollbar == m_verticalScrollbar->scrollbar())
+ return m_verticalScrollbar->convertFromContainingViewToScrollbar(parentPoint);
+ WEBKIT_ASSERT_NOT_REACHED();
+ return IntPoint();
+}
+
+Scrollbar* ScrollbarGroup::horizontalScrollbar() const
+{
+ return m_horizontalScrollbar ? m_horizontalScrollbar->scrollbar() : 0;
+}
+
+Scrollbar* ScrollbarGroup::verticalScrollbar() const
+{
+ return m_verticalScrollbar ? m_verticalScrollbar->scrollbar() : 0;
+}
+
+IntPoint ScrollbarGroup::scrollPosition() const
+{
+ int x = m_horizontalScrollbar ? m_horizontalScrollbar->scrollOffset() : 0;
+ int y = m_verticalScrollbar ? m_verticalScrollbar->scrollOffset() : 0;
+ return IntPoint(x, y);
+}
+
+IntPoint ScrollbarGroup::minimumScrollPosition() const
+{
+ return IntPoint();
+}
+
+IntPoint ScrollbarGroup::maximumScrollPosition() const
+{
+ return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().height() - visibleHeight());
+}
+
+int ScrollbarGroup::visibleHeight() const
+{
+ if (m_verticalScrollbar)
+ return m_verticalScrollbar->scrollbar()->height();
+ if (m_horizontalScrollbar)
+ return m_horizontalScrollbar->scrollbar()->height();
+ WEBKIT_ASSERT_NOT_REACHED();
+ return 0;
+}
+
+int ScrollbarGroup::visibleWidth() const
+{
+ if (m_horizontalScrollbar)
+ return m_horizontalScrollbar->scrollbar()->width();
+ if (m_verticalScrollbar)
+ return m_verticalScrollbar->scrollbar()->width();
+ WEBKIT_ASSERT_NOT_REACHED();
+ return 0;
+}
+
+IntSize ScrollbarGroup::contentsSize() const
+{
+ IntSize size;
+ if (m_horizontalScrollbar)
+ size.setWidth(m_horizontalScrollbar->scrollbar()->totalSize());
+ else if (m_verticalScrollbar) {
+ size.setWidth(m_verticalScrollbar->scrollbar()->x());
+ if (m_verticalScrollbar->scrollbar()->isOverlayScrollbar())
+ size.expand(WebPluginScrollbar::defaultThickness(), 0);
+ }
+ if (m_verticalScrollbar)
+ size.setHeight(m_verticalScrollbar->scrollbar()->totalSize());
+ else if (m_horizontalScrollbar) {
+ size.setHeight(m_horizontalScrollbar->scrollbar()->y());
+ if (m_horizontalScrollbar->scrollbar()->isOverlayScrollbar())
+ size.expand(0, WebPluginScrollbar::defaultThickness());
+ }
+ return size;
+}
+
+IntSize ScrollbarGroup::overhangAmount() const
+{
+ return IntSize();
+}
+
+IntPoint ScrollbarGroup::lastKnownMousePosition() const
+{
+ return m_lastMousePosition;
+}
+
+bool ScrollbarGroup::shouldSuspendScrollAnimations() const
+{
+ return false;
+}
+
+void ScrollbarGroup::scrollbarStyleChanged(int, bool forceUpdate)
+{
+ if (!forceUpdate)
+ return;
+
+ if (m_horizontalScrollbar)
+ m_horizontalScrollbar->scrollbarStyleChanged();
+ if (m_verticalScrollbar)
+ m_verticalScrollbar->scrollbarStyleChanged();
+}
+
+bool ScrollbarGroup::scrollbarsCanBeActive() const
+{
+ return true;
+}
+
+bool ScrollbarGroup::userInputScrollable(ScrollbarOrientation orientation) const
+{
+ return orientation == HorizontalScrollbar ? horizontalScrollbar() : verticalScrollbar();
+}
+
+int ScrollbarGroup::pageStep(ScrollbarOrientation orientation) const
+{
+ int length;
+ if (orientation == VerticalScrollbar) {
+ if (!m_verticalScrollbar)
+ return 0;
+
+ length = m_verticalScrollbar->scrollbar()->height();
+ } else {
+ if (!m_horizontalScrollbar)
+ return 0;
+
+ length = m_horizontalScrollbar->scrollbar()->width();
+ }
+
+ int pageStep = std::max(
+ static_cast<int>(static_cast<float>(length) * ScrollableArea::minFractionToStepWhenPaging()),
+ length - ScrollableArea::maxOverlapBetweenPages());
+
+ return std::max(pageStep, 1);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/ScrollbarGroup.h b/chromium/third_party/WebKit/Source/web/ScrollbarGroup.h
new file mode 100644
index 00000000000..838338044b6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ScrollbarGroup.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 ScrollbarGroup_h
+#define ScrollbarGroup_h
+
+#include "core/platform/ScrollableArea.h"
+
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+class FrameView;
+}
+
+namespace WebKit {
+
+class WebPluginScrollbarImpl;
+
+class ScrollbarGroup : public WebCore::ScrollableArea {
+public:
+ ScrollbarGroup(WebCore::FrameView*, const WebCore::IntRect& frameRect);
+ ~ScrollbarGroup();
+
+ void scrollbarCreated(WebPluginScrollbarImpl*);
+ void scrollbarDestroyed(WebPluginScrollbarImpl*);
+ void setLastMousePosition(const WebCore::IntPoint&);
+ void setFrameRect(const WebCore::IntRect&);
+
+ // WebCore::ScrollableArea methods
+ virtual int scrollSize(WebCore::ScrollbarOrientation) const OVERRIDE;
+ virtual void setScrollOffset(const WebCore::IntPoint&) OVERRIDE;
+ virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&) OVERRIDE;
+ virtual void invalidateScrollCornerRect(const WebCore::IntRect&) OVERRIDE;
+ virtual bool isActive() const OVERRIDE;
+ virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE;
+ virtual WebCore::IntRect scrollCornerRect() const OVERRIDE { return WebCore::IntRect(); }
+ virtual bool isScrollCornerVisible() const OVERRIDE;
+ virtual void getTickmarks(Vector<WebCore::IntRect>&) const OVERRIDE;
+ virtual WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntPoint& parentPoint) const OVERRIDE;
+ virtual WebCore::Scrollbar* horizontalScrollbar() const OVERRIDE;
+ virtual WebCore::Scrollbar* verticalScrollbar() const OVERRIDE;
+ virtual WebCore::IntPoint scrollPosition() const OVERRIDE;
+ virtual WebCore::IntPoint minimumScrollPosition() const OVERRIDE;
+ virtual WebCore::IntPoint maximumScrollPosition() const OVERRIDE;
+ virtual int visibleHeight() const OVERRIDE;
+ virtual int visibleWidth() const OVERRIDE;
+ virtual WebCore::IntSize contentsSize() const OVERRIDE;
+ virtual WebCore::IntSize overhangAmount() const OVERRIDE;
+ virtual WebCore::IntPoint lastKnownMousePosition() const OVERRIDE;
+ virtual bool shouldSuspendScrollAnimations() const OVERRIDE;
+ virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) OVERRIDE;
+ virtual bool scrollbarsCanBeActive() const OVERRIDE;
+ virtual WebCore::IntRect scrollableAreaBoundingBox() const OVERRIDE;
+ virtual bool userInputScrollable(WebCore::ScrollbarOrientation) const OVERRIDE;
+ virtual int pageStep(WebCore::ScrollbarOrientation) const OVERRIDE;
+
+private:
+ WebCore::FrameView* m_frameView;
+ WebCore::IntPoint m_lastMousePosition;
+ WebCore::IntRect m_frameRect;
+ WebPluginScrollbarImpl* m_horizontalScrollbar;
+ WebPluginScrollbarImpl* m_verticalScrollbar;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/SharedWorkerRepository.cpp b/chromium/third_party/WebKit/Source/web/SharedWorkerRepository.cpp
new file mode 100644
index 00000000000..979fca10a60
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/SharedWorkerRepository.cpp
@@ -0,0 +1,269 @@
+/*
+ * 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 "core/workers/SharedWorkerRepository.h"
+
+#include "WebContentSecurityPolicy.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebKit.h"
+#include "WebSharedWorker.h"
+#include "WebSharedWorkerRepository.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/dom/Event.h"
+#include "core/dom/EventNames.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/dom/MessagePortChannel.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/page/ContentSecurityPolicy.h"
+#include "core/platform/network/ResourceResponse.h"
+#include "core/workers/SharedWorker.h"
+#include "core/workers/WorkerScriptLoader.h"
+#include "core/workers/WorkerScriptLoaderClient.h"
+
+#include "public/platform/Platform.h"
+#include "public/platform/WebMessagePortChannel.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+
+namespace WebKit {
+
+WebSharedWorkerRepository* s_sharedWorkerRepository = 0;
+
+void setSharedWorkerRepository(WebSharedWorkerRepository* repository)
+{
+ s_sharedWorkerRepository = repository;
+}
+
+static WebSharedWorkerRepository* sharedWorkerRepository()
+{
+ // Will only be non-zero if the embedder has set the shared worker repository upon initialization. Nothing in WebKit sets this.
+ return s_sharedWorkerRepository;
+}
+
+}
+
+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(WorkerScriptLoader::create())
+ , m_loading(false)
+ , m_responseAppCacheID(0)
+ {
+ m_scriptLoader->setTargetType(ResourceRequest::TargetIsSharedWorker);
+ }
+
+ ~SharedWorkerScriptLoader();
+ void load();
+ static void stopAllLoadersForContext(ScriptExecutionContext*);
+
+private:
+ // WorkerScriptLoaderClient callbacks
+ virtual void didReceiveResponse(unsigned long identifier, 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;
+ RefPtr<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 {
+ // 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;
+
+ m_scriptLoader->loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this);
+ }
+}
+
+// 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(unsigned long identifier, const ResourceResponse& response)
+{
+ m_responseAppCacheID = response.appCacheID();
+ InspectorInstrumentation::didReceiveScriptResponse(m_worker->scriptExecutionContext(), identifier);
+}
+
+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_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeader(),
+ static_cast<WebKit::WebContentSecurityPolicyType>(m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeaderType()),
+ 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()
+{
+ return WebKit::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, ExceptionState& es)
+{
+ WebKit::WebSharedWorkerRepository* repository = WebKit::sharedWorkerRepository();
+
+ // This should not be callable unless there's a SharedWorkerRepository for
+ // this context (since isAvailable() should have returned null).
+ ASSERT(repository);
+
+ // No nested workers (for now) - connect() should only be called from document context.
+ ASSERT(worker->scriptExecutionContext()->isDocument());
+ Document* document = toDocument(worker->scriptExecutionContext());
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ OwnPtr<WebSharedWorker> webWorker;
+ webWorker = adoptPtr(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.
+ es.throwDOMException(URLMismatchError);
+ return;
+ }
+
+ repository->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)
+{
+ WebKit::WebSharedWorkerRepository* repository = WebKit::sharedWorkerRepository();
+
+ if (repository)
+ repository->documentDetached(getId(document));
+
+ // Stop the creation of any pending SharedWorkers for this context.
+ // FIXME: Need a way to invoke this for WorkerGlobalScopes as well when we support for nested workers.
+ SharedWorkerScriptLoader::stopAllLoadersForContext(document);
+}
+
+bool SharedWorkerRepository::hasSharedWorkers(Document* document)
+{
+ WebKit::WebSharedWorkerRepository* repository = WebKit::sharedWorkerRepository();
+
+ return repository && repository->hasSharedWorkers(getId(document));
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.cpp b/chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.cpp
new file mode 100644
index 00000000000..a756a1ee1cc
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "SourceBufferPrivateImpl.h"
+
+#include "WebSourceBuffer.h"
+
+namespace WebKit {
+
+SourceBufferPrivateImpl::SourceBufferPrivateImpl(PassOwnPtr<WebSourceBuffer> sourceBuffer)
+ : m_sourceBuffer(sourceBuffer)
+{
+ ASSERT(m_sourceBuffer);
+}
+
+PassRefPtr<WebCore::TimeRanges> SourceBufferPrivateImpl::buffered()
+{
+ WebTimeRanges webRanges = m_sourceBuffer->buffered();
+ RefPtr<WebCore::TimeRanges> ranges = WebCore::TimeRanges::create();
+ for (size_t i = 0; i < webRanges.size(); ++i)
+ ranges->add(webRanges[i].start, webRanges[i].end);
+ return ranges.release();
+}
+
+void SourceBufferPrivateImpl::append(const unsigned char* data, unsigned length)
+{
+ m_sourceBuffer->append(data, length);
+}
+
+void SourceBufferPrivateImpl::abort()
+{
+ m_sourceBuffer->abort();
+}
+
+void SourceBufferPrivateImpl::remove(double start, double end)
+{
+ m_sourceBuffer->remove(start, end);
+}
+
+bool SourceBufferPrivateImpl::setTimestampOffset(double offset)
+{
+ return m_sourceBuffer->setTimestampOffset(offset);
+}
+
+void SourceBufferPrivateImpl::setAppendWindowStart(double start)
+{
+ if (!m_sourceBuffer)
+ return;
+ m_sourceBuffer->setAppendWindowStart(start);
+}
+
+void SourceBufferPrivateImpl::setAppendWindowEnd(double end)
+{
+ if (!m_sourceBuffer)
+ return;
+ m_sourceBuffer->setAppendWindowEnd(end);
+}
+
+void SourceBufferPrivateImpl::removedFromMediaSource()
+{
+ m_sourceBuffer->removedFromMediaSource();
+ m_sourceBuffer.clear();
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.h b/chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.h
new file mode 100644
index 00000000000..b7caf614104
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/SourceBufferPrivateImpl.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 SourceBufferPrivateImpl_h
+#define SourceBufferPrivateImpl_h
+
+#include "core/platform/graphics/SourceBufferPrivate.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebKit {
+
+class WebSourceBuffer;
+
+class SourceBufferPrivateImpl : public WebCore::SourceBufferPrivate {
+public:
+ explicit SourceBufferPrivateImpl(PassOwnPtr<WebSourceBuffer>);
+ virtual ~SourceBufferPrivateImpl() { }
+
+ // SourceBufferPrivate methods.
+ virtual PassRefPtr<WebCore::TimeRanges> buffered() OVERRIDE;
+ virtual void append(const unsigned char* data, unsigned length) OVERRIDE;
+ virtual void abort() OVERRIDE;
+ virtual void remove(double start, double end) OVERRIDE;
+ virtual bool setTimestampOffset(double) OVERRIDE;
+ virtual void setAppendWindowStart(double) OVERRIDE;
+ virtual void setAppendWindowEnd(double) OVERRIDE;
+ virtual void removedFromMediaSource() OVERRIDE;
+
+private:
+ OwnPtr<WebSourceBuffer> m_sourceBuffer;
+};
+
+
+}
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/SpeechInputClientImpl.cpp b/chromium/third_party/WebKit/Source/web/SpeechInputClientImpl.cpp
new file mode 100644
index 00000000000..227de32b2e1
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "public/platform/WebString.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
+#include "WebSecurityOrigin.h"
+#include "WebSpeechInputController.h"
+#include "WebViewClient.h"
+#include "core/page/SpeechInputListener.h"
+#include "weborigin/SecurityOrigin.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/chromium/third_party/WebKit/Source/web/SpeechInputClientImpl.h b/chromium/third_party/WebKit/Source/web/SpeechInputClientImpl.h
new file mode 100644
index 00000000000..542293c2c41
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebSpeechInputListener.h"
+#include "core/page/SpeechInputClient.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/chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.cpp b/chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.cpp
new file mode 100644
index 00000000000..a5b617253d4
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 ``AS IS'' AND ANY
+ * EXPRESS OR 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 "SpeechRecognitionClientProxy.h"
+
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "WebSecurityOrigin.h"
+#include "WebSpeechGrammar.h"
+#include "WebSpeechRecognitionHandle.h"
+#include "WebSpeechRecognitionParams.h"
+#include "WebSpeechRecognitionResult.h"
+#include "WebSpeechRecognizer.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "modules/speech/SpeechGrammarList.h"
+#include "modules/speech/SpeechRecognition.h"
+#include "modules/speech/SpeechRecognitionError.h"
+#include "modules/speech/SpeechRecognitionResult.h"
+#include "modules/speech/SpeechRecognitionResultList.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy()
+{
+}
+
+PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(WebSpeechRecognizer* recognizer)
+{
+ return adoptPtr(new SpeechRecognitionClientProxy(recognizer));
+}
+
+void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const SpeechGrammarList* grammarList, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives)
+{
+ WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarList->length()));
+ for (unsigned long i = 0; i < grammarList->length(); ++i)
+ webSpeechGrammars[i] = grammarList->item(i);
+
+ WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, interimResults, maxAlternatives, WebSecurityOrigin(recognition->scriptExecutionContext()->securityOrigin()));
+ m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, this);
+}
+
+void SpeechRecognitionClientProxy::stop(SpeechRecognition* recognition)
+{
+ m_recognizer->stop(WebSpeechRecognitionHandle(recognition), this);
+}
+
+void SpeechRecognitionClientProxy::abort(SpeechRecognition* recognition)
+{
+ m_recognizer->abort(WebSpeechRecognitionHandle(recognition), this);
+}
+
+void SpeechRecognitionClientProxy::didStartAudio(const WebSpeechRecognitionHandle& handle)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didStartAudio();
+}
+
+void SpeechRecognitionClientProxy::didStartSound(const WebSpeechRecognitionHandle& handle)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didStartSound();
+ recognition->didStartSpeech();
+}
+
+void SpeechRecognitionClientProxy::didEndSound(const WebSpeechRecognitionHandle& handle)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didEndSpeech();
+ recognition->didEndSound();
+}
+
+void SpeechRecognitionClientProxy::didEndAudio(const WebSpeechRecognitionHandle& handle)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didEndAudio();
+}
+
+void SpeechRecognitionClientProxy::didReceiveResults(const WebSpeechRecognitionHandle& handle, const WebVector<WebSpeechRecognitionResult>& newFinalResults, const WebVector<WebSpeechRecognitionResult>& currentInterimResults)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+
+ Vector<RefPtr<SpeechRecognitionResult> > finalResultsVector(newFinalResults.size());
+ for (size_t i = 0; i < newFinalResults.size(); ++i)
+ finalResultsVector[i] = static_cast<PassRefPtr<SpeechRecognitionResult> >(newFinalResults[i]);
+
+ Vector<RefPtr<SpeechRecognitionResult> > interimResultsVector(currentInterimResults.size());
+ for (size_t i = 0; i < currentInterimResults.size(); ++i)
+ interimResultsVector[i] = static_cast<PassRefPtr<SpeechRecognitionResult> >(currentInterimResults[i]);
+
+ recognition->didReceiveResults(finalResultsVector, interimResultsVector);
+}
+
+void SpeechRecognitionClientProxy::didReceiveNoMatch(const WebSpeechRecognitionHandle& handle, const WebSpeechRecognitionResult& result)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didReceiveNoMatch(result);
+}
+
+void SpeechRecognitionClientProxy::didReceiveError(const WebSpeechRecognitionHandle& handle, const WebString& message, WebSpeechRecognizerClient::ErrorCode code)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ SpeechRecognitionError::ErrorCode errorCode = static_cast<SpeechRecognitionError::ErrorCode>(code);
+ recognition->didReceiveError(SpeechRecognitionError::create(errorCode, message));
+}
+
+void SpeechRecognitionClientProxy::didStart(const WebSpeechRecognitionHandle& handle)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didStart();
+}
+
+void SpeechRecognitionClientProxy::didEnd(const WebSpeechRecognitionHandle& handle)
+{
+ RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
+ recognition->didEnd();
+}
+
+SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer* recognizer)
+ : m_recognizer(recognizer)
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.h b/chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.h
new file mode 100644
index 00000000000..67c90f9ebf2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/SpeechRecognitionClientProxy.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 ``AS IS'' AND ANY
+ * EXPRESS OR 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 SpeechRecognitionClientProxy_h
+#define SpeechRecognitionClientProxy_h
+
+#include "WebSpeechRecognizerClient.h"
+#include "modules/speech/SpeechRecognitionClient.h"
+#include "wtf/Compiler.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebKit {
+
+class WebSpeechRecognizer;
+class WebString;
+
+class SpeechRecognitionClientProxy : public WebCore::SpeechRecognitionClient, public WebSpeechRecognizerClient {
+public:
+ ~SpeechRecognitionClientProxy();
+
+ // Constructing a proxy object with a 0 WebSpeechRecognizer is safe in
+ // itself, but attempting to call start/stop/abort on it will crash.
+ static PassOwnPtr<SpeechRecognitionClientProxy> create(WebSpeechRecognizer*);
+
+ // WebCore::SpeechRecognitionClient:
+ virtual void start(WebCore::SpeechRecognition*, const WebCore::SpeechGrammarList*, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives) OVERRIDE;
+ virtual void stop(WebCore::SpeechRecognition*) OVERRIDE;
+ virtual void abort(WebCore::SpeechRecognition*) OVERRIDE;
+
+ // WebSpeechRecognizerClient:
+ virtual void didStartAudio(const WebSpeechRecognitionHandle&) OVERRIDE;
+ virtual void didStartSound(const WebSpeechRecognitionHandle&) OVERRIDE;
+ virtual void didEndSound(const WebSpeechRecognitionHandle&) OVERRIDE;
+ virtual void didEndAudio(const WebSpeechRecognitionHandle&) OVERRIDE;
+ virtual void didReceiveResults(const WebSpeechRecognitionHandle&, const WebVector<WebSpeechRecognitionResult>& newFinalResults, const WebVector<WebSpeechRecognitionResult>& currentInterimResults) OVERRIDE;
+ virtual void didReceiveNoMatch(const WebSpeechRecognitionHandle&, const WebSpeechRecognitionResult&) OVERRIDE;
+ virtual void didReceiveError(const WebSpeechRecognitionHandle&, const WebString& message, WebSpeechRecognizerClient::ErrorCode) OVERRIDE;
+ virtual void didStart(const WebSpeechRecognitionHandle&) OVERRIDE;
+ virtual void didEnd(const WebSpeechRecognitionHandle&) OVERRIDE;
+
+private:
+ SpeechRecognitionClientProxy(WebSpeechRecognizer*);
+
+ WebSpeechRecognizer* m_recognizer;
+};
+
+}; // namespace WebKit
+
+#endif // SpeechRecognitionClientProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/StorageAreaProxy.cpp b/chromium/third_party/WebKit/Source/web/StorageAreaProxy.cpp
new file mode 100644
index 00000000000..97f1aa4fbb9
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/StorageAreaProxy.cpp
@@ -0,0 +1,201 @@
+/*
+ * 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"
+
+#include "StorageNamespaceProxy.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/dom/Document.h"
+#include "core/dom/EventNames.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/page/DOMWindow.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/page/PageGroup.h"
+#include "core/storage/Storage.h"
+#include "core/storage/StorageEvent.h"
+#include "weborigin/SecurityOrigin.h"
+
+#include "public/platform/WebStorageArea.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "WebFrameImpl.h"
+#include "WebPermissionClient.h"
+#include "WebViewImpl.h"
+
+namespace WebCore {
+
+StorageAreaProxy::StorageAreaProxy(PassOwnPtr<WebKit::WebStorageArea> storageArea, StorageType storageType)
+ : m_storageArea(storageArea)
+ , m_storageType(storageType)
+ , m_canAccessStorageCachedResult(false)
+ , m_canAccessStorageCachedFrame(0)
+{
+}
+
+StorageAreaProxy::~StorageAreaProxy()
+{
+}
+
+unsigned StorageAreaProxy::length(ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return 0;
+ }
+ return m_storageArea->length();
+}
+
+String StorageAreaProxy::key(unsigned index, ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return String();
+ }
+ return m_storageArea->key(index);
+}
+
+String StorageAreaProxy::getItem(const String& key, ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return String();
+ }
+ return m_storageArea->getItem(key);
+}
+
+void StorageAreaProxy::setItem(const String& key, const String& value, ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return;
+ }
+ WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK;
+ m_storageArea->setItem(key, value, frame->document()->url(), result);
+ if (result != WebKit::WebStorageArea::ResultOK)
+ es.throwDOMException(QuotaExceededError);
+}
+
+void StorageAreaProxy::removeItem(const String& key, ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return;
+ }
+ m_storageArea->removeItem(key, frame->document()->url());
+}
+
+void StorageAreaProxy::clear(ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return;
+ }
+ m_storageArea->clear(frame->document()->url());
+}
+
+bool StorageAreaProxy::contains(const String& key, ExceptionState& es, Frame* frame)
+{
+ if (!canAccessStorage(frame)) {
+ es.throwDOMException(SecurityError);
+ return false;
+ }
+ return !getItem(key, es, frame).isNull();
+}
+
+bool StorageAreaProxy::canAccessStorage(Frame* frame)
+{
+ if (!frame || !frame->page())
+ return false;
+ if (m_canAccessStorageCachedFrame == frame)
+ return m_canAccessStorageCachedResult;
+ WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame);
+ WebKit::WebViewImpl* webView = webFrame->viewImpl();
+ bool result = !webView->permissionClient() || webView->permissionClient()->allowStorage(webFrame, m_storageType == LocalStorage);
+ m_canAccessStorageCachedFrame = frame;
+ m_canAccessStorageCachedResult = result;
+ return result;
+}
+
+size_t StorageAreaProxy::memoryBytesUsedByCache()
+{
+ return m_storageArea->memoryBytesUsedByCache();
+}
+
+void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String& oldValue, const String& newValue,
+ SecurityOrigin* securityOrigin, const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originatedInProcess)
+{
+ // FIXME: This looks suspicious. Why doesn't this use allPages instead?
+ const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages();
+ for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); ++it) {
+ for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ Storage* storage = frame->domWindow()->optionalLocalStorage();
+ if (storage && frame->document()->securityOrigin()->equal(securityOrigin) && !isEventSource(storage, sourceAreaInstance))
+ frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, pageURL, storage));
+ }
+ InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue, newValue, LocalStorage, securityOrigin);
+ }
+}
+
+static Page* findPageWithSessionStorageNamespace(const WebKit::WebStorageNamespace& sessionNamespace)
+{
+ // FIXME: This looks suspicious. Why doesn't this use allPages instead?
+ const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages();
+ for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); ++it) {
+ const bool dontCreateIfMissing = false;
+ StorageNamespaceProxy* proxy = static_cast<StorageNamespaceProxy*>((*it)->sessionStorage(dontCreateIfMissing));
+ if (proxy && proxy->isSameNamespace(sessionNamespace))
+ return *it;
+ }
+ return 0;
+}
+
+void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const String& oldValue, const String& newValue,
+ SecurityOrigin* securityOrigin, const KURL& pageURL, const WebKit::WebStorageNamespace& sessionNamespace,
+ WebKit::WebStorageArea* sourceAreaInstance, bool originatedInProcess)
+{
+ Page* page = findPageWithSessionStorageNamespace(sessionNamespace);
+ if (!page)
+ return;
+
+ for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ Storage* storage = frame->domWindow()->optionalSessionStorage();
+ if (storage && frame->document()->securityOrigin()->equal(securityOrigin) && !isEventSource(storage, sourceAreaInstance))
+ frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, pageURL, storage));
+ }
+ InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, SessionStorage, securityOrigin);
+}
+
+bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* sourceAreaInstance)
+{
+ ASSERT(storage);
+ StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area());
+ return areaProxy->m_storageArea == sourceAreaInstance;
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/StorageAreaProxy.h b/chromium/third_party/WebKit/Source/web/StorageAreaProxy.h
new file mode 100644
index 00000000000..464682535a6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/StorageAreaProxy.h
@@ -0,0 +1,82 @@
+/*
+ * 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
+
+#include "core/storage/StorageArea.h"
+
+namespace WebKit {
+class WebStorageArea;
+class WebStorageNamespace;
+}
+
+namespace WebCore {
+
+class ExceptionState;
+class Frame;
+class KURL;
+class Page;
+class SecurityOrigin;
+class Storage;
+
+class StorageAreaProxy : public StorageArea {
+public:
+ StorageAreaProxy(PassOwnPtr<WebKit::WebStorageArea>, StorageType);
+ virtual ~StorageAreaProxy();
+
+ // The HTML5 DOM Storage API
+ virtual unsigned length(ExceptionState&, Frame* sourceFrame);
+ virtual String key(unsigned index, ExceptionState&, Frame* sourceFrame);
+ virtual String getItem(const String& key, ExceptionState&, Frame* sourceFrame);
+ virtual void setItem(const String& key, const String& value, ExceptionState&, Frame* sourceFrame);
+ virtual void removeItem(const String& key, ExceptionState&, Frame* sourceFrame);
+ virtual void clear(ExceptionState&, Frame* sourceFrame);
+ virtual bool contains(const String& key, ExceptionState&, Frame* sourceFrame);
+
+ virtual bool canAccessStorage(Frame*);
+
+ virtual size_t memoryBytesUsedByCache();
+
+ static void dispatchLocalStorageEvent(
+ const String& key, const String& oldValue, const String& newValue,
+ SecurityOrigin*, const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originatedInProcess);
+ static void dispatchSessionStorageEvent(
+ const String& key, const String& oldValue, const String& newValue,
+ SecurityOrigin*, const KURL& pageURL, const WebKit::WebStorageNamespace&,
+ WebKit::WebStorageArea* sourceAreaInstance, bool originatedInProcess);
+
+private:
+ static bool isEventSource(Storage*, WebKit::WebStorageArea* sourceAreaInstance);
+
+ OwnPtr<WebKit::WebStorageArea> m_storageArea;
+ StorageType m_storageType;
+ mutable bool m_canAccessStorageCachedResult;
+ mutable Frame* m_canAccessStorageCachedFrame;
+};
+
+} // namespace WebCore
+
+#endif // StorageAreaProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.cpp b/chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.cpp
new file mode 100644
index 00000000000..5f79dd3c460
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.cpp
@@ -0,0 +1,79 @@
+/*
+ * 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"
+
+#include "public/platform/Platform.h"
+#include "public/platform/WebStorageArea.h"
+#include "public/platform/WebStorageNamespace.h"
+#include "public/platform/WebString.h"
+#include "ChromeClientImpl.h"
+#include "StorageAreaProxy.h"
+#include "WebKit.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/page/Chrome.h"
+#include "core/page/Page.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/MainThread.h"
+
+namespace WebCore {
+
+PassOwnPtr<StorageArea> StorageNamespace::localStorageArea(SecurityOrigin* origin)
+{
+ ASSERT(isMainThread());
+ static WebKit::WebStorageNamespace* localStorageNamespace = 0;
+ if (!localStorageNamespace)
+ localStorageNamespace = WebKit::Platform::current()->createLocalStorageNamespace();
+ return adoptPtr(new StorageAreaProxy(adoptPtr(localStorageNamespace->createStorageArea(origin->toString())), LocalStorage));
+}
+
+PassOwnPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace(Page* page)
+{
+ WebKit::WebViewClient* webViewClient = static_cast<WebKit::WebViewImpl*>(page->chrome().client()->webView())->client();
+ return adoptPtr(new StorageNamespaceProxy(adoptPtr(webViewClient->createSessionStorageNamespace())));
+}
+
+StorageNamespaceProxy::StorageNamespaceProxy(PassOwnPtr<WebKit::WebStorageNamespace> storageNamespace)
+ : m_storageNamespace(storageNamespace)
+{
+}
+
+StorageNamespaceProxy::~StorageNamespaceProxy()
+{
+}
+
+PassOwnPtr<StorageArea> StorageNamespaceProxy::storageArea(SecurityOrigin* origin)
+{
+ return adoptPtr(new StorageAreaProxy(adoptPtr(m_storageNamespace->createStorageArea(origin->toString())), SessionStorage));
+}
+
+bool StorageNamespaceProxy::isSameNamespace(const WebKit::WebStorageNamespace& sessionNamespace)
+{
+ return m_storageNamespace && m_storageNamespace->isSameNamespace(sessionNamespace);
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.h b/chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.h
new file mode 100644
index 00000000000..b76f9c57851
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/StorageNamespaceProxy.h
@@ -0,0 +1,52 @@
+/*
+ * 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
+
+#include "core/storage/StorageArea.h"
+#include "core/storage/StorageNamespace.h"
+
+namespace WebKit { class WebStorageNamespace; }
+
+namespace WebCore {
+
+// Instances of StorageNamespaceProxy are only used to interact with
+// SessionStorage, never LocalStorage.
+class StorageNamespaceProxy : public StorageNamespace {
+public:
+ explicit StorageNamespaceProxy(PassOwnPtr<WebKit::WebStorageNamespace>);
+ virtual ~StorageNamespaceProxy();
+ virtual PassOwnPtr<StorageArea> storageArea(SecurityOrigin*);
+
+ bool isSameNamespace(const WebKit::WebStorageNamespace&);
+
+private:
+ OwnPtr<WebKit::WebStorageNamespace> m_storageNamespace;
+};
+
+} // namespace WebCore
+
+#endif // StorageNamespaceProxy_h
diff --git a/chromium/third_party/WebKit/Source/web/StorageQuotaChromium.cpp b/chromium/third_party/WebKit/Source/web/StorageQuotaChromium.cpp
new file mode 100644
index 00000000000..f0b66e7ea23
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/StorageQuotaChromium.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "modules/quota/StorageQuota.h"
+
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebStorageQuotaType.h"
+#include "WebWorkerBase.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerThread.h"
+#include "modules/quota/StorageErrorCallback.h"
+#include "modules/quota/StorageQuotaCallback.h"
+#include "modules/quota/StorageUsageCallback.h"
+#include "modules/quota/WebStorageQuotaCallbacksImpl.h"
+#include "wtf/Threading.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+// FIXME: Implement this as StorageQuotaClient.
+void StorageQuota::requestQuota(ScriptExecutionContext* scriptExecutionContext, unsigned long long newQuotaInBytes, PassRefPtr<StorageQuotaCallback> successCallback, PassRefPtr<StorageErrorCallback> errorCallback)
+{
+ ASSERT(scriptExecutionContext);
+ WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
+ if (storageType != WebStorageQuotaTypeTemporary && storageType != WebStorageQuotaTypePersistent) {
+ // Unknown storage type is requested.
+ scriptExecutionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
+ return;
+ }
+ if (scriptExecutionContext->isDocument()) {
+ Document* document = toDocument(scriptExecutionContext);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ webFrame->client()->requestStorageQuota(webFrame, storageType, newQuotaInBytes, WebStorageQuotaCallbacksImpl::createLeakedPtr(successCallback, errorCallback));
+ } else {
+ // Requesting quota in Worker is not supported.
+ scriptExecutionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
+ }
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/UserMediaClientImpl.cpp b/chromium/third_party/WebKit/Source/web/UserMediaClientImpl.cpp
new file mode 100644
index 00000000000..bba5c19e42b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/UserMediaClientImpl.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "UserMediaClientImpl.h"
+
+#include "WebUserMediaClient.h"
+#include "WebUserMediaRequest.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "public/platform/WebMediaStreamSource.h"
+#include "wtf/RefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+UserMediaClientImpl::UserMediaClientImpl(WebViewImpl* webView)
+ : m_client(webView->client() ? webView->client()->userMediaClient() : 0)
+{
+}
+
+void UserMediaClientImpl::requestUserMedia(PassRefPtr<UserMediaRequest> request)
+{
+ if (m_client)
+ m_client->requestUserMedia(request);
+}
+
+void UserMediaClientImpl::cancelUserMediaRequest(UserMediaRequest* request)
+{
+ if (m_client)
+ m_client->cancelUserMediaRequest(WebUserMediaRequest(request));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/UserMediaClientImpl.h b/chromium/third_party/WebKit/Source/web/UserMediaClientImpl.h
new file mode 100644
index 00000000000..47878c95a8b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/UserMediaClientImpl.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 UserMediaClientImpl_h
+#define UserMediaClientImpl_h
+
+#include "core/platform/mediastream/MediaStreamSource.h"
+#include "modules/mediastream/UserMediaClient.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebCore {
+class UserMediaRequest;
+}
+
+namespace WebKit {
+
+class WebUserMediaClient;
+class WebViewImpl;
+
+class UserMediaClientImpl : public WebCore::UserMediaClient {
+public:
+ UserMediaClientImpl(WebViewImpl*);
+
+ // WebCore::UserMediaClient ----------------------------------------------
+ virtual void requestUserMedia(PassRefPtr<WebCore::UserMediaRequest>);
+ virtual void cancelUserMediaRequest(WebCore::UserMediaRequest*);
+
+private:
+ UserMediaClientImpl();
+
+ WebUserMediaClient* m_client;
+};
+
+} // namespace WebKit
+
+#endif // UserMediaClientImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp b/chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp
new file mode 100644
index 00000000000..6c7c1557363
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "ValidationMessageClientImpl.h"
+
+#include "WebTextDirection.h"
+#include "WebValidationMessageClient.h"
+#include "WebViewImpl.h"
+#include "core/dom/Element.h"
+#include "core/page/FrameView.h"
+#include "core/platform/HostWindow.h"
+#include "core/rendering/RenderObject.h"
+#include "wtf/CurrentTime.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ValidationMessageClientImpl::ValidationMessageClientImpl(WebViewImpl& webView, WebValidationMessageClient& client)
+ : m_webView(webView)
+ , m_client(client)
+ , m_currentAnchor(0)
+ , m_lastPageScaleFactor(1)
+ , m_finishTime(0)
+ , m_timer(this, &ValidationMessageClientImpl::checkAnchorStatus)
+{
+}
+
+PassOwnPtr<ValidationMessageClientImpl> ValidationMessageClientImpl::create(WebViewImpl& webView, WebValidationMessageClient& client)
+{
+ return adoptPtr(new ValidationMessageClientImpl(webView, client));
+}
+
+ValidationMessageClientImpl::~ValidationMessageClientImpl()
+{
+ if (m_currentAnchor)
+ hideValidationMessage(*m_currentAnchor);
+}
+
+FrameView* ValidationMessageClientImpl::currentView()
+{
+ return m_currentAnchor->document()->view();
+}
+
+void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, const String& message)
+{
+ if (message.isEmpty()) {
+ hideValidationMessage(anchor);
+ return;
+ }
+ if (!anchor.renderBox())
+ return;
+ if (m_currentAnchor)
+ hideValidationMessage(*m_currentAnchor);
+ m_currentAnchor = &anchor;
+ IntRect anchorInRootView = currentView()->contentsToRootView(anchor.pixelSnappedBoundingBox());
+ m_lastAnchorRectInScreen = currentView()->hostWindow()->rootViewToScreen(anchorInRootView);
+ m_lastPageScaleFactor = m_webView.pageScaleFactor();
+ m_message = message;
+
+ WebTextDirection dir = m_currentAnchor->renderer()->style()->direction() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight;
+ AtomicString title = m_currentAnchor->fastGetAttribute(HTMLNames::titleAttr);
+ m_client.showValidationMessage(anchorInRootView, m_message, title, dir);
+
+ const double minimumSecondToShowValidationMessage = 5.0;
+ const double secondPerCharacter = 0.05;
+ const double statusCheckInterval = 0.1;
+ m_finishTime = monotonicallyIncreasingTime() + std::max(minimumSecondToShowValidationMessage, (message.length() + title.length()) * secondPerCharacter);
+ // FIXME: We should invoke checkAnchorStatus actively when layout, scroll,
+ // or page scale change happen.
+ m_timer.startRepeating(statusCheckInterval);
+}
+
+void ValidationMessageClientImpl::hideValidationMessage(const Element& anchor)
+{
+ if (!m_currentAnchor || !isValidationMessageVisible(anchor))
+ return;
+ m_timer.stop();
+ m_currentAnchor = 0;
+ m_message = String();
+ m_finishTime = 0;
+ m_client.hideValidationMessage();
+}
+
+bool ValidationMessageClientImpl::isValidationMessageVisible(const Element& anchor)
+{
+ return m_currentAnchor == &anchor;
+}
+
+void ValidationMessageClientImpl::documentDetached(const Document& document)
+{
+ if (m_currentAnchor && m_currentAnchor->document() == &document)
+ hideValidationMessage(*m_currentAnchor);
+}
+
+void ValidationMessageClientImpl::checkAnchorStatus(Timer<ValidationMessageClientImpl>*)
+{
+ ASSERT(m_currentAnchor);
+ if (monotonicallyIncreasingTime() >= m_finishTime || !currentView()) {
+ hideValidationMessage(*m_currentAnchor);
+ return;
+ }
+
+ // Check the visibility of the element.
+ // FIXME: Can we check invisibility by scrollable non-frame elements?
+ IntRect newAnchorRect = currentView()->contentsToRootView(m_currentAnchor->pixelSnappedBoundingBox());
+ newAnchorRect = intersection(currentView()->convertToRootView(currentView()->boundsRect()), newAnchorRect);
+ if (newAnchorRect.isEmpty()) {
+ hideValidationMessage(*m_currentAnchor);
+ return;
+ }
+
+ IntRect newAnchorRectInScreen = currentView()->hostWindow()->rootViewToScreen(newAnchorRect);
+ if (newAnchorRectInScreen == m_lastAnchorRectInScreen && m_webView.pageScaleFactor() == m_lastPageScaleFactor)
+ return;
+ m_lastAnchorRectInScreen = newAnchorRectInScreen;
+ m_lastPageScaleFactor = m_webView.pageScaleFactor();
+ m_client.moveValidationMessage(newAnchorRect);
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.h b/chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.h
new file mode 100644
index 00000000000..ac93cf5aa82
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ValidationMessageClientImpl.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ValidationMessageClientImpl_h
+#define ValidationMessageClientImpl_h
+
+#include "core/page/ValidationMessageClient.h"
+#include "core/platform/Timer.h"
+#include "core/platform/graphics/IntRect.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+class FrameView;
+}
+
+namespace WebKit {
+
+class WebValidationMessageClient;
+class WebViewImpl;
+
+class ValidationMessageClientImpl : public WebCore::ValidationMessageClient {
+public:
+ static PassOwnPtr<ValidationMessageClientImpl> create(WebViewImpl&, WebValidationMessageClient&);
+ virtual ~ValidationMessageClientImpl();
+
+private:
+ ValidationMessageClientImpl(WebViewImpl&, WebValidationMessageClient&);
+ void checkAnchorStatus(WebCore::Timer<ValidationMessageClientImpl>*);
+ WebCore::FrameView* currentView();
+
+ virtual void showValidationMessage(const WebCore::Element& anchor, const String& message) OVERRIDE;
+ virtual void hideValidationMessage(const WebCore::Element& anchor) OVERRIDE;
+ virtual bool isValidationMessageVisible(const WebCore::Element& anchor) OVERRIDE;
+ virtual void documentDetached(const WebCore::Document&) OVERRIDE;
+
+ WebViewImpl& m_webView;
+ WebValidationMessageClient& m_client;
+ const WebCore::Element* m_currentAnchor;
+ String m_message;
+ WebCore::IntRect m_lastAnchorRectInScreen;
+ float m_lastPageScaleFactor;
+ double m_finishTime;
+ WebCore::Timer<ValidationMessageClientImpl> m_timer;
+};
+
+}
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/ViewportAnchor.cpp b/chromium/third_party/WebKit/Source/web/ViewportAnchor.cpp
new file mode 100644
index 00000000000..71d233a6165
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ViewportAnchor.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "ViewportAnchor.h"
+
+#include "core/dom/ContainerNode.h"
+#include "core/dom/Node.h"
+#include "core/page/EventHandler.h"
+#include "core/rendering/HitTestResult.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+namespace {
+
+static const float viewportAnchorRelativeEpsilon = 0.1f;
+static const int viewportToNodeMaxRelativeArea = 2;
+
+template <typename RectType>
+int area(const RectType& rect) {
+ return rect.width() * rect.height();
+}
+
+Node* findNonEmptyAnchorNode(const IntPoint& point, const IntRect& viewRect, EventHandler* eventHandler)
+{
+ Node* node = eventHandler->hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent).innerNode();
+
+ // If the node bounding box is sufficiently large, make a single attempt to
+ // find a smaller node; the larger the node bounds, the greater the
+ // variability under resize.
+ const int maxNodeArea = area(viewRect) * viewportToNodeMaxRelativeArea;
+ if (node && area(node->boundingBox()) > maxNodeArea) {
+ IntSize pointOffset = viewRect.size();
+ pointOffset.scale(viewportAnchorRelativeEpsilon);
+ node = eventHandler->hitTestResultAtPoint(point + pointOffset, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent).innerNode();
+ }
+
+ while (node && node->boundingBox().isEmpty())
+ node = node->parentNode();
+
+ return node;
+}
+
+} // namespace
+
+ViewportAnchor::ViewportAnchor(EventHandler* eventHandler)
+ : m_eventHandler(eventHandler) { }
+
+void ViewportAnchor::setAnchor(const IntRect& viewRect, const FloatSize& anchorInViewCoords)
+{
+ m_viewRect = viewRect;
+ m_anchorNode.clear();
+ m_anchorNodeBounds = LayoutRect();
+ m_anchorInNodeCoords = FloatSize();
+ m_anchorInViewCoords = anchorInViewCoords;
+
+ if (viewRect.isEmpty())
+ return;
+
+ // Preserve origins at the absolute screen origin
+ if (viewRect.location() == IntPoint::zero())
+ return;
+
+ FloatSize anchorOffset = viewRect.size();
+ anchorOffset.scale(anchorInViewCoords.width(), anchorInViewCoords.height());
+ const FloatPoint anchorPoint = FloatPoint(viewRect.location()) + anchorOffset;
+
+ Node* node = findNonEmptyAnchorNode(flooredIntPoint(anchorPoint), viewRect, m_eventHandler);
+ if (!node)
+ return;
+
+ m_anchorNode = node;
+ m_anchorNodeBounds = node->boundingBox();
+ m_anchorInNodeCoords = anchorPoint - m_anchorNodeBounds.location();
+ m_anchorInNodeCoords.scale(1.f / m_anchorNodeBounds.width(), 1.f / m_anchorNodeBounds.height());
+}
+
+IntPoint ViewportAnchor::computeOrigin(const IntSize& currentViewSize) const
+{
+ if (!m_anchorNode || !m_anchorNode->inDocument())
+ return m_viewRect.location();
+
+ const LayoutRect currentNodeBounds = m_anchorNode->boundingBox();
+ if (m_anchorNodeBounds == currentNodeBounds)
+ return m_viewRect.location();
+
+ // Compute the new anchor point relative to the node position
+ FloatSize anchorOffsetFromNode = currentNodeBounds.size();
+ anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoords.height());
+ FloatPoint anchorPoint = currentNodeBounds.location() + anchorOffsetFromNode;
+
+ // Compute the new origin point relative to the new anchor point
+ FloatSize anchorOffsetFromOrigin = currentViewSize;
+ anchorOffsetFromOrigin.scale(m_anchorInViewCoords.width(), m_anchorInViewCoords.height());
+ return flooredIntPoint(anchorPoint - anchorOffsetFromOrigin);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/ViewportAnchor.h b/chromium/third_party/WebKit/Source/web/ViewportAnchor.h
new file mode 100644
index 00000000000..ab68609228f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/ViewportAnchor.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 ViewportAnchor_h
+#define ViewportAnchor_h
+
+#include "core/platform/graphics/FloatSize.h"
+#include "core/platform/graphics/IntPoint.h"
+#include "core/platform/graphics/IntRect.h"
+#include "core/platform/graphics/LayoutRect.h"
+#include "wtf/RefCounted.h"
+
+namespace WebCore {
+class EventHandler;
+class IntSize;
+class Node;
+}
+
+namespace WebKit {
+
+// ViewportAnchor provides a way to anchor a viewport origin to a DOM node.
+// In particular, the user supplies the current viewport (in CSS coordinates)
+// and an anchor point (in view coordinates, e.g., (0, 0) == viewport origin,
+// (0.5, 0) == viewport top center). The anchor point tracks the underlying DOM
+// node; as the node moves or the view is resized, the viewport anchor maintains
+// its orientation relative to the node, and the viewport origin maintains its
+// orientation relative to the anchor.
+class ViewportAnchor {
+ WTF_MAKE_NONCOPYABLE(ViewportAnchor);
+public:
+ explicit ViewportAnchor(WebCore::EventHandler* eventHandler);
+
+ void setAnchor(const WebCore::IntRect& viewRect, const WebCore::FloatSize& anchorInViewCoords);
+
+ WebCore::IntPoint computeOrigin(const WebCore::IntSize& currentViewSize) const;
+
+private:
+ WebCore::EventHandler* m_eventHandler;
+
+ WebCore::IntRect m_viewRect;
+
+ RefPtr<WebCore::Node> m_anchorNode;
+ WebCore::LayoutRect m_anchorNodeBounds;
+
+ WebCore::FloatSize m_anchorInViewCoords;
+ WebCore::FloatSize m_anchorInNodeCoords;
+};
+
+} // namespace WebKit
+
+ #endif
diff --git a/chromium/third_party/WebKit/Source/web/WebAccessibilityObject.cpp b/chromium/third_party/WebKit/Source/web/WebAccessibilityObject.cpp
new file mode 100644
index 00000000000..02d71810b2d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebAccessibilityObject.cpp
@@ -0,0 +1,1021 @@
+/*
+ * 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 "HTMLNames.h"
+#include "WebDocument.h"
+#include "WebNode.h"
+#include "core/accessibility/AXObjectCache.h"
+#include "core/accessibility/AccessibilityObject.h"
+#include "core/accessibility/AccessibilityTable.h"
+#include "core/accessibility/AccessibilityTableCell.h"
+#include "core/accessibility/AccessibilityTableColumn.h"
+#include "core/accessibility/AccessibilityTableRow.h"
+#include "core/css/CSSPrimitiveValueMappings.h"
+#include "core/dom/Document.h"
+#include "core/dom/Node.h"
+#include "core/page/EventHandler.h"
+#include "core/page/FrameView.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/rendering/style/RenderStyle.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "wtf/text/StringBuilder.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebAccessibilityObject::reset()
+{
+ m_private.reset();
+}
+
+void WebAccessibilityObject::assign(const WebKit::WebAccessibilityObject& other)
+{
+ m_private = other.m_private;
+}
+
+bool WebAccessibilityObject::equals(const WebAccessibilityObject& n) const
+{
+ return m_private.get() == n.m_private.get();
+}
+
+// static
+void WebAccessibilityObject::enableAccessibility()
+{
+ AXObjectCache::enableAccessibility();
+}
+
+// static
+bool WebAccessibilityObject::accessibilityEnabled()
+{
+ return AXObjectCache::accessibilityEnabled();
+}
+
+void WebAccessibilityObject::startCachingComputedObjectAttributesUntilTreeMutates()
+{
+ m_private->axObjectCache()->startCachingComputedObjectAttributesUntilTreeMutates();
+}
+
+void WebAccessibilityObject::stopCachingComputedObjectAttributes()
+{
+ m_private->axObjectCache()->stopCachingComputedObjectAttributes();
+}
+
+bool WebAccessibilityObject::isDetached() const
+{
+ if (m_private.isNull())
+ return true;
+
+ return m_private->isDetached();
+}
+
+int WebAccessibilityObject::axID() const
+{
+ if (isDetached())
+ return -1;
+
+ return m_private->axObjectID();
+}
+
+bool WebAccessibilityObject::updateBackingStoreAndCheckValidity()
+{
+ if (!isDetached())
+ m_private->updateBackingStore();
+ return !isDetached();
+}
+
+WebString WebAccessibilityObject::accessibilityDescription() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->accessibilityDescription();
+}
+
+WebString WebAccessibilityObject::actionVerb() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->actionVerb();
+}
+
+bool WebAccessibilityObject::canDecrement() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->isSlider();
+}
+
+bool WebAccessibilityObject::canIncrement() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->isSlider();
+}
+
+bool WebAccessibilityObject::canPress() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->actionElement() || m_private->isButton() || m_private->isMenuRelated();
+}
+
+bool WebAccessibilityObject::canSetFocusAttribute() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->canSetFocusAttribute();
+}
+
+bool WebAccessibilityObject::canSetValueAttribute() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->canSetValueAttribute();
+}
+
+unsigned WebAccessibilityObject::childCount() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->children().size();
+}
+
+WebAccessibilityObject WebAccessibilityObject::childAt(unsigned index) const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (m_private->children().size() <= index)
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(m_private->children()[index]);
+}
+
+WebAccessibilityObject WebAccessibilityObject::parentObject() const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(m_private->parentObject());
+}
+
+bool WebAccessibilityObject::canSetSelectedAttribute() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->canSetSelectedAttribute();
+}
+
+bool WebAccessibilityObject::isAnchor() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isAnchor();
+}
+
+bool WebAccessibilityObject::isAriaReadOnly() const
+{
+ if (isDetached())
+ return 0;
+
+ return equalIgnoringCase(m_private->getAttribute(HTMLNames::aria_readonlyAttr), "true");
+}
+
+bool WebAccessibilityObject::isButtonStateMixed() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->checkboxOrRadioValue() == ButtonStateMixed;
+}
+
+bool WebAccessibilityObject::isChecked() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isChecked();
+}
+
+bool WebAccessibilityObject::isCollapsed() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isCollapsed();
+}
+
+bool WebAccessibilityObject::isControl() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isControl();
+}
+
+bool WebAccessibilityObject::isEnabled() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isEnabled();
+}
+
+bool WebAccessibilityObject::isFocused() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isFocused();
+}
+
+bool WebAccessibilityObject::isHovered() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isHovered();
+}
+
+bool WebAccessibilityObject::isIndeterminate() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isIndeterminate();
+}
+
+bool WebAccessibilityObject::isLinked() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isLinked();
+}
+
+bool WebAccessibilityObject::isLoaded() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isLoaded();
+}
+
+bool WebAccessibilityObject::isMultiSelectable() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isMultiSelectable();
+}
+
+bool WebAccessibilityObject::isOffScreen() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isOffScreen();
+}
+
+bool WebAccessibilityObject::isPasswordField() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isPasswordField();
+}
+
+bool WebAccessibilityObject::isPressed() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isPressed();
+}
+
+bool WebAccessibilityObject::isReadOnly() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isReadOnly();
+}
+
+bool WebAccessibilityObject::isRequired() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isRequired();
+}
+
+bool WebAccessibilityObject::isSelected() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isSelected();
+}
+
+bool WebAccessibilityObject::isSelectedOptionActive() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->isSelectedOptionActive();
+}
+
+bool WebAccessibilityObject::isVertical() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->orientation() == AccessibilityOrientationVertical;
+}
+
+bool WebAccessibilityObject::isVisible() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isVisible();
+}
+
+bool WebAccessibilityObject::isVisited() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->isVisited();
+}
+
+WebString WebAccessibilityObject::accessKey() const
+{
+ if (isDetached())
+ return WebString();
+
+ return WebString(m_private->accessKey());
+}
+
+bool WebAccessibilityObject::ariaHasPopup() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->ariaHasPopup();
+}
+
+bool WebAccessibilityObject::ariaLiveRegionAtomic() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->ariaLiveRegionAtomic();
+}
+
+bool WebAccessibilityObject::ariaLiveRegionBusy() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->ariaLiveRegionBusy();
+}
+
+WebString WebAccessibilityObject::ariaLiveRegionRelevant() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->ariaLiveRegionRelevant();
+}
+
+WebString WebAccessibilityObject::ariaLiveRegionStatus() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->ariaLiveRegionStatus();
+}
+
+WebRect WebAccessibilityObject::boundingBoxRect() const
+{
+ if (isDetached())
+ return WebRect();
+
+ return pixelSnappedIntRect(m_private->elementRect());
+}
+
+bool WebAccessibilityObject::canvasHasFallbackContent() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->canvasHasFallbackContent();
+}
+
+WebPoint WebAccessibilityObject::clickPoint() const
+{
+ if (isDetached())
+ return WebPoint();
+
+ return WebPoint(m_private->clickPoint());
+}
+
+void WebAccessibilityObject::colorValue(int& r, int& g, int& b) const
+{
+ if (isDetached())
+ return;
+
+ m_private->colorValue(r, g, b);
+}
+
+double WebAccessibilityObject::estimatedLoadingProgress() const
+{
+ if (isDetached())
+ return 0.0;
+
+ return m_private->estimatedLoadingProgress();
+}
+
+WebString WebAccessibilityObject::helpText() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->helpText();
+}
+
+int WebAccessibilityObject::headingLevel() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->headingLevel();
+}
+
+int WebAccessibilityObject::hierarchicalLevel() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->hierarchicalLevel();
+}
+
+WebAccessibilityObject WebAccessibilityObject::hitTest(const WebPoint& point) const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ IntPoint contentsPoint = m_private->documentFrameView()->windowToContents(point);
+ RefPtr<AccessibilityObject> hit = m_private->accessibilityHitTest(contentsPoint);
+
+ if (hit)
+ return WebAccessibilityObject(hit);
+
+ if (m_private->elementRect().contains(contentsPoint))
+ return *this;
+
+ return WebAccessibilityObject();
+}
+
+WebString WebAccessibilityObject::keyboardShortcut() const
+{
+ if (isDetached())
+ return WebString();
+
+ String accessKey = m_private->accessKey();
+ if (accessKey.isNull())
+ return WebString();
+
+ DEFINE_STATIC_LOCAL(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 "+".
+ StringBuilder modifierStringBuilder;
+ if (modifiers & PlatformEvent::CtrlKey)
+ modifierStringBuilder.appendLiteral("Ctrl+");
+ if (modifiers & PlatformEvent::AltKey)
+ modifierStringBuilder.appendLiteral("Alt+");
+ if (modifiers & PlatformEvent::ShiftKey)
+ modifierStringBuilder.appendLiteral("Shift+");
+ if (modifiers & PlatformEvent::MetaKey)
+ modifierStringBuilder.appendLiteral("Win+");
+ modifierString = modifierStringBuilder.toString();
+ }
+
+ return String(modifierString + accessKey);
+}
+
+bool WebAccessibilityObject::performDefaultAction() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->performDefaultAction();
+}
+
+bool WebAccessibilityObject::increment() const
+{
+ if (isDetached())
+ return false;
+
+ if (canIncrement()) {
+ m_private->increment();
+ return true;
+ }
+ return false;
+}
+
+bool WebAccessibilityObject::decrement() const
+{
+ if (isDetached())
+ return false;
+
+ if (canDecrement()) {
+ m_private->decrement();
+ return true;
+ }
+ return false;
+}
+
+bool WebAccessibilityObject::press() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->press();
+}
+
+WebAccessibilityRole WebAccessibilityObject::roleValue() const
+{
+ if (isDetached())
+ return WebKit::WebAccessibilityRoleUnknown;
+
+ return static_cast<WebAccessibilityRole>(m_private->roleValue());
+}
+
+unsigned WebAccessibilityObject::selectionEnd() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->selectedTextRange().start + m_private->selectedTextRange().length;
+}
+
+unsigned WebAccessibilityObject::selectionStart() const
+{
+ if (isDetached())
+ return 0;
+
+ return m_private->selectedTextRange().start;
+}
+
+unsigned WebAccessibilityObject::selectionEndLineNumber() const
+{
+ if (isDetached())
+ return 0;
+
+ VisiblePosition position = m_private->visiblePositionForIndex(selectionEnd());
+ int lineNumber = m_private->lineForPosition(position);
+ if (lineNumber < 0)
+ return 0;
+ return lineNumber;
+}
+
+unsigned WebAccessibilityObject::selectionStartLineNumber() const
+{
+ if (isDetached())
+ return 0;
+
+ VisiblePosition position = m_private->visiblePositionForIndex(selectionStart());
+ int lineNumber = m_private->lineForPosition(position);
+ if (lineNumber < 0)
+ return 0;
+ return lineNumber;
+}
+
+void WebAccessibilityObject::setFocused(bool on) const
+{
+ if (!isDetached())
+ m_private->setFocused(on);
+}
+
+void WebAccessibilityObject::setSelectedTextRange(int selectionStart, int selectionEnd) const
+{
+ if (isDetached())
+ return;
+
+ m_private->setSelectedTextRange(PlainTextRange(selectionStart, selectionEnd - selectionStart));
+}
+
+WebString WebAccessibilityObject::stringValue() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->stringValue();
+}
+
+WebString WebAccessibilityObject::title() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->title();
+}
+
+WebAccessibilityObject WebAccessibilityObject::titleUIElement() const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (!m_private->exposesTitleUIElement())
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(m_private->titleUIElement());
+}
+
+WebURL WebAccessibilityObject::url() const
+{
+ if (isDetached())
+ return WebURL();
+
+ return m_private->url();
+}
+
+bool WebAccessibilityObject::supportsRangeValue() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->supportsRangeValue();
+}
+
+WebString WebAccessibilityObject::valueDescription() const
+{
+ if (isDetached())
+ return WebString();
+
+ return m_private->valueDescription();
+}
+
+float WebAccessibilityObject::valueForRange() const
+{
+ if (isDetached())
+ return 0.0;
+
+ return m_private->valueForRange();
+}
+
+float WebAccessibilityObject::maxValueForRange() const
+{
+ if (isDetached())
+ return 0.0;
+
+ return m_private->maxValueForRange();
+}
+
+float WebAccessibilityObject::minValueForRange() const
+{
+ if (isDetached())
+ return 0.0;
+
+ return m_private->minValueForRange();
+}
+
+WebNode WebAccessibilityObject::node() const
+{
+ if (isDetached())
+ return WebNode();
+
+ Node* node = m_private->node();
+ if (!node)
+ return WebNode();
+
+ return WebNode(node);
+}
+
+WebDocument WebAccessibilityObject::document() const
+{
+ if (isDetached())
+ return WebDocument();
+
+ Document* document = m_private->document();
+ if (!document)
+ return WebDocument();
+
+ return WebDocument(document);
+}
+
+bool WebAccessibilityObject::hasComputedStyle() const
+{
+ if (isDetached())
+ return false;
+
+ 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
+{
+ if (isDetached())
+ return WebString();
+
+ 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());
+}
+
+bool WebAccessibilityObject::accessibilityIsIgnored() const
+{
+ if (isDetached())
+ return false;
+
+ return m_private->accessibilityIsIgnored();
+}
+
+bool WebAccessibilityObject::lineBreaks(WebVector<int>& result) const
+{
+ if (isDetached())
+ return false;
+
+ Vector<int> lineBreaksVector;
+ m_private->lineBreaks(lineBreaksVector);
+
+ size_t vectorSize = lineBreaksVector.size();
+ WebVector<int> lineBreaksWebVector(vectorSize);
+ for (size_t i = 0; i< vectorSize; i++)
+ lineBreaksWebVector[i] = lineBreaksVector[i];
+ result.swap(lineBreaksWebVector);
+
+ return true;
+}
+
+unsigned WebAccessibilityObject::columnCount() const
+{
+ if (isDetached())
+ return false;
+
+ if (!m_private->isAccessibilityTable())
+ return 0;
+
+ return static_cast<WebCore::AccessibilityTable*>(m_private.get())->columnCount();
+}
+
+unsigned WebAccessibilityObject::rowCount() const
+{
+ if (isDetached())
+ return false;
+
+ if (!m_private->isAccessibilityTable())
+ return 0;
+
+ return static_cast<WebCore::AccessibilityTable*>(m_private.get())->rowCount();
+}
+
+WebAccessibilityObject WebAccessibilityObject::cellForColumnAndRow(unsigned column, unsigned row) const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (!m_private->isAccessibilityTable())
+ return WebAccessibilityObject();
+
+ WebCore::AccessibilityTableCell* cell = static_cast<WebCore::AccessibilityTable*>(m_private.get())->cellForColumnAndRow(column, row);
+ return WebAccessibilityObject(static_cast<WebCore::AccessibilityObject*>(cell));
+}
+
+WebAccessibilityObject WebAccessibilityObject::headerContainerObject() const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (!m_private->isAccessibilityTable())
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(static_cast<WebCore::AccessibilityTable*>(m_private.get())->headerContainer());
+}
+
+WebAccessibilityObject WebAccessibilityObject::rowAtIndex(unsigned int rowIndex) const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (!m_private->isAccessibilityTable())
+ return WebAccessibilityObject();
+
+ const AccessibilityObject::AccessibilityChildrenVector& rows = static_cast<WebCore::AccessibilityTable*>(m_private.get())->rows();
+ if (rowIndex < rows.size())
+ return WebAccessibilityObject(rows[rowIndex]);
+
+ return WebAccessibilityObject();
+}
+
+WebAccessibilityObject WebAccessibilityObject::columnAtIndex(unsigned int columnIndex) const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (!m_private->isAccessibilityTable())
+ return WebAccessibilityObject();
+
+ const AccessibilityObject::AccessibilityChildrenVector& columns = static_cast<WebCore::AccessibilityTable*>(m_private.get())->columns();
+ if (columnIndex < columns.size())
+ return WebAccessibilityObject(columns[columnIndex]);
+
+ return WebAccessibilityObject();
+}
+
+unsigned WebAccessibilityObject::rowIndex() const
+{
+ if (isDetached())
+ return 0;
+
+ if (!m_private->isTableRow())
+ return 0;
+
+ return static_cast<WebCore::AccessibilityTableRow*>(m_private.get())->rowIndex();
+}
+
+WebAccessibilityObject WebAccessibilityObject::rowHeader() const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (!m_private->isTableRow())
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(static_cast<WebCore::AccessibilityTableRow*>(m_private.get())->headerObject());
+}
+
+unsigned WebAccessibilityObject::columnIndex() const
+{
+ if (isDetached())
+ return 0;
+
+ if (m_private->roleValue() != ColumnRole)
+ return 0;
+
+ return static_cast<WebCore::AccessibilityTableColumn*>(m_private.get())->columnIndex();
+}
+
+WebAccessibilityObject WebAccessibilityObject::columnHeader() const
+{
+ if (isDetached())
+ return WebAccessibilityObject();
+
+ if (m_private->roleValue() != ColumnRole)
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(static_cast<WebCore::AccessibilityTableColumn*>(m_private.get())->headerObject());
+}
+
+unsigned WebAccessibilityObject::cellColumnIndex() const
+{
+ if (isDetached())
+ return 0;
+
+ if (!m_private->isTableCell())
+ return 0;
+
+ pair<unsigned, unsigned> columnRange;
+ static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->columnIndexRange(columnRange);
+ return columnRange.first;
+}
+
+unsigned WebAccessibilityObject::cellColumnSpan() const
+{
+ if (isDetached())
+ return 0;
+
+ if (!m_private->isTableCell())
+ return 0;
+
+ pair<unsigned, unsigned> columnRange;
+ static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->columnIndexRange(columnRange);
+ return columnRange.second;
+}
+
+unsigned WebAccessibilityObject::cellRowIndex() const
+{
+ if (isDetached())
+ return 0;
+
+ if (!m_private->isTableCell())
+ return 0;
+
+ pair<unsigned, unsigned> rowRange;
+ static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->rowIndexRange(rowRange);
+ return rowRange.first;
+}
+
+unsigned WebAccessibilityObject::cellRowSpan() const
+{
+ if (isDetached())
+ return 0;
+
+ if (!m_private->isTableCell())
+ return 0;
+
+ pair<unsigned, unsigned> rowRange;
+ static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->rowIndexRange(rowRange);
+ return rowRange.second;
+}
+
+void WebAccessibilityObject::scrollToMakeVisible() const
+{
+ if (!isDetached())
+ m_private->scrollToMakeVisible();
+}
+
+void WebAccessibilityObject::scrollToMakeVisibleWithSubFocus(const WebRect& subfocus) const
+{
+ if (!isDetached())
+ m_private->scrollToMakeVisibleWithSubFocus(subfocus);
+}
+
+void WebAccessibilityObject::scrollToGlobalPoint(const WebPoint& point) const
+{
+ if (!isDetached())
+ m_private->scrollToGlobalPoint(point);
+}
+
+WebAccessibilityObject::WebAccessibilityObject(const WTF::PassRefPtr<WebCore::AccessibilityObject>& object)
+ : m_private(object)
+{
+}
+
+WebAccessibilityObject& WebAccessibilityObject::operator=(const WTF::PassRefPtr<WebCore::AccessibilityObject>& object)
+{
+ m_private = object;
+ return *this;
+}
+
+WebAccessibilityObject::operator WTF::PassRefPtr<WebCore::AccessibilityObject>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebArrayBufferView.cpp b/chromium/third_party/WebKit/Source/web/WebArrayBufferView.cpp
new file mode 100644
index 00000000000..044ace41646
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebArrayBufferView.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebArrayBufferView.h"
+
+#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
+#include "wtf/ArrayBufferView.h"
+
+using namespace WTF;
+
+namespace WebKit {
+
+void WebArrayBufferView::assign(const WebArrayBufferView& other)
+{
+ m_private = other.m_private;
+}
+
+void WebArrayBufferView::reset()
+{
+ m_private.reset();
+}
+
+void* WebArrayBufferView::baseAddress() const
+{
+ return m_private->baseAddress();
+}
+
+unsigned WebArrayBufferView::byteOffset() const
+{
+ return m_private->byteOffset();
+}
+
+unsigned WebArrayBufferView::byteLength() const
+{
+ return m_private->byteLength();
+}
+
+WebArrayBufferView* WebArrayBufferView::createFromV8Value(v8::Handle<v8::Value> value)
+{
+ if (!value->IsArrayBufferView())
+ return 0;
+ ArrayBufferView* view = WebCore::V8ArrayBufferView::toNative(value->ToObject());
+ return new WebArrayBufferView(view);
+}
+
+WebArrayBufferView::WebArrayBufferView(const PassRefPtr<ArrayBufferView>& value)
+ : m_private(value)
+{
+}
+
+WebArrayBufferView& WebArrayBufferView::operator=(const PassRefPtr<ArrayBufferView>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebArrayBufferView::operator PassRefPtr<ArrayBufferView>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebBindings.cpp b/chromium/third_party/WebKit/Source/web/WebBindings.cpp
new file mode 100644
index 00000000000..664b8d720f5
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebBindings.cpp
@@ -0,0 +1,402 @@
+/*
+ * 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 "V8Element.h"
+#include "V8Range.h"
+#include "WebArrayBufferView.h"
+#include "WebElement.h"
+#include "WebRange.h"
+#include "bindings/v8/NPV8Object.h" // for PrivateIdentifier
+#include "bindings/v8/ScriptController.h"
+#include "bindings/v8/V8DOMWrapper.h"
+#include "bindings/v8/V8NPUtils.h"
+#include "bindings/v8/custom/V8ArrayBufferCustom.h"
+#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
+#include "bindings/v8/npruntime_impl.h"
+#include "bindings/v8/npruntime_priv.h"
+#include "core/dom/Range.h"
+#include "core/page/DOMWindow.h"
+#include "core/page/Frame.h"
+#include "public/platform/WebArrayBuffer.h"
+#include "wtf/ArrayBufferView.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebBindings::construct(NPP npp, NPObject* object, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ return _NPN_Construct(npp, object, args, argCount, result);
+}
+
+NPObject* WebBindings::createObject(NPP npp, NPClass* npClass)
+{
+ return _NPN_CreateObject(npp, npClass);
+}
+
+bool WebBindings::enumerate(NPP npp, NPObject* object, NPIdentifier** identifier, uint32_t* identifierCount)
+{
+ return _NPN_Enumerate(npp, object, identifier, identifierCount);
+}
+
+bool WebBindings::evaluate(NPP npp, NPObject* object, NPString* script, NPVariant* result)
+{
+ return _NPN_Evaluate(npp, object, script, result);
+}
+
+bool WebBindings::evaluateHelper(NPP npp, bool popupsAllowed, NPObject* object, NPString* script, NPVariant* result)
+{
+ return _NPN_EvaluateHelper(npp, popupsAllowed, object, script, result);
+}
+
+NPIdentifier WebBindings::getIntIdentifier(int32_t number)
+{
+ return _NPN_GetIntIdentifier(number);
+}
+
+bool WebBindings::getProperty(NPP npp, NPObject* object, NPIdentifier property, NPVariant* result)
+{
+ return _NPN_GetProperty(npp, object, property, 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* object, NPIdentifier method)
+{
+ return _NPN_HasMethod(npp, object, method);
+}
+
+bool WebBindings::hasProperty(NPP npp, NPObject* object, NPIdentifier property)
+{
+ return _NPN_HasProperty(npp, object, property);
+}
+
+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)
+{
+ _NPN_InitializeVariantWithStringCopy(variant, value);
+}
+
+bool WebBindings::invoke(NPP npp, NPObject* object, NPIdentifier method, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ return _NPN_Invoke(npp, object, method, args, argCount, result);
+}
+
+bool WebBindings::invokeDefault(NPP npp, NPObject* object, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ return _NPN_InvokeDefault(npp, object, args, argCount, result);
+}
+
+void WebBindings::releaseObject(NPObject* object)
+{
+ return _NPN_ReleaseObject(object);
+}
+
+void WebBindings::releaseVariantValue(NPVariant* variant)
+{
+ _NPN_ReleaseVariantValue(variant);
+}
+
+bool WebBindings::removeProperty(NPP npp, NPObject* object, NPIdentifier identifier)
+{
+ return _NPN_RemoveProperty(npp, object, identifier);
+}
+
+NPObject* WebBindings::retainObject(NPObject* object)
+{
+ return _NPN_RetainObject(object);
+}
+
+void WebBindings::setException(NPObject* object, const NPUTF8* message)
+{
+ _NPN_SetException(object, message);
+}
+
+bool WebBindings::setProperty(NPP npp, NPObject* object, NPIdentifier identifier, const NPVariant* value)
+{
+ return _NPN_SetProperty(npp, object, identifier, value);
+}
+
+void WebBindings::registerObjectOwner(NPP)
+{
+}
+
+void WebBindings::unregisterObjectOwner(NPP)
+{
+}
+
+NPP WebBindings::getObjectOwner(NPObject*)
+{
+ return 0;
+}
+
+void WebBindings::unregisterObject(NPObject* object)
+{
+ _NPN_UnregisterObject(object);
+}
+
+NPUTF8* WebBindings::utf8FromIdentifier(NPIdentifier identifier)
+{
+ return _NPN_UTF8FromIdentifier(identifier);
+}
+
+void WebBindings::extractIdentifierData(const NPIdentifier& identifier, const NPUTF8*& string, int32_t& number, bool& isString)
+{
+ PrivateIdentifier* data = static_cast<PrivateIdentifier*>(identifier);
+ if (!data) {
+ isString = false;
+ number = 0;
+ return;
+ }
+
+ isString = data->isString;
+ if (isString)
+ string = data->value.string;
+ else
+ number = data->value.number;
+}
+
+static bool getRangeImpl(NPObject* object, WebRange* webRange, v8::Isolate* isolate)
+{
+ if (!object)
+ return false;
+
+ V8NPObject* v8NPObject = npObjectToV8NPObject(object);
+ if (!v8NPObject)
+ return false;
+
+ v8::HandleScope handleScope(isolate);
+ v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object);
+ if (v8Object.IsEmpty())
+ return false;
+ if (!V8Range::info.equals(toWrapperTypeInfo(v8Object)))
+ return false;
+
+ Range* native = V8Range::HasInstanceInAnyWorld(v8Object, isolate) ? V8Range::toNative(v8Object) : 0;
+ if (!native)
+ return false;
+
+ *webRange = WebRange(native);
+ return true;
+}
+
+static bool getNodeImpl(NPObject* object, WebNode* webNode, v8::Isolate* isolate)
+{
+ if (!object)
+ return false;
+
+ V8NPObject* v8NPObject = npObjectToV8NPObject(object);
+ if (!v8NPObject)
+ return false;
+
+ v8::HandleScope handleScope(isolate);
+ v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object);
+ if (v8Object.IsEmpty())
+ return false;
+ Node* native = V8Node::HasInstanceInAnyWorld(v8Object, isolate) ? V8Node::toNative(v8Object) : 0;
+ if (!native)
+ return false;
+
+ *webNode = WebNode(native);
+ return true;
+}
+
+static bool getElementImpl(NPObject* object, WebElement* webElement, v8::Isolate* isolate)
+{
+ if (!object)
+ return false;
+
+ V8NPObject* v8NPObject = npObjectToV8NPObject(object);
+ if (!v8NPObject)
+ return false;
+
+ v8::HandleScope handleScope(isolate);
+ v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object);
+ if (v8Object.IsEmpty())
+ return false;
+ Element* native = V8Element::HasInstanceInAnyWorld(v8Object, isolate) ? V8Element::toNative(v8Object) : 0;
+ if (!native)
+ return false;
+
+ *webElement = WebElement(native);
+ return true;
+}
+
+static bool getArrayBufferImpl(NPObject* object, WebArrayBuffer* arrayBuffer, v8::Isolate* isolate)
+{
+ if (!object)
+ return false;
+
+ V8NPObject* v8NPObject = npObjectToV8NPObject(object);
+ if (!v8NPObject)
+ return false;
+
+ v8::HandleScope handleScope(isolate);
+ v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object);
+ if (v8Object.IsEmpty())
+ return false;
+ ArrayBuffer* native = V8ArrayBuffer::HasInstanceInAnyWorld(v8Object, isolate) ? V8ArrayBuffer::toNative(v8Object) : 0;
+ if (!native)
+ return false;
+
+ *arrayBuffer = WebArrayBuffer(native);
+ return true;
+}
+
+static bool getArrayBufferViewImpl(NPObject* object, WebArrayBufferView* arrayBufferView, v8::Isolate* isolate)
+{
+ if (!object)
+ return false;
+
+ V8NPObject* v8NPObject = npObjectToV8NPObject(object);
+ if (!v8NPObject)
+ return false;
+
+ v8::HandleScope handleScope(isolate);
+ v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object);
+ if (v8Object.IsEmpty())
+ return false;
+ ArrayBufferView* native = V8ArrayBufferView::HasInstanceInAnyWorld(v8Object, isolate) ? V8ArrayBufferView::toNative(v8Object) : 0;
+ if (!native)
+ return false;
+
+ *arrayBufferView = WebArrayBufferView(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]));
+
+ DOMWindow* window = toDOMWindow(v8::Context::GetCurrent());
+ return npCreateV8ScriptObject(0, result, window);
+}
+
+static NPObject* makeStringArrayImpl(const WebVector<WebString>& data)
+{
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ 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, v8String(data[i], isolate));
+
+ DOMWindow* window = toDOMWindow(v8::Context::GetCurrent());
+ return npCreateV8ScriptObject(0, result, window);
+}
+
+bool WebBindings::getRange(NPObject* range, WebRange* webRange)
+{
+ return getRangeImpl(range, webRange, v8::Isolate::GetCurrent());
+}
+
+bool WebBindings::getArrayBuffer(NPObject* arrayBuffer, WebArrayBuffer* webArrayBuffer)
+{
+ return getArrayBufferImpl(arrayBuffer, webArrayBuffer, v8::Isolate::GetCurrent());
+}
+
+bool WebBindings::getArrayBufferView(NPObject* arrayBufferView, WebArrayBufferView* webArrayBufferView)
+{
+ return getArrayBufferViewImpl(arrayBufferView, webArrayBufferView, v8::Isolate::GetCurrent());
+}
+
+bool WebBindings::getNode(NPObject* node, WebNode* webNode)
+{
+ return getNodeImpl(node, webNode, v8::Isolate::GetCurrent());
+}
+
+bool WebBindings::getElement(NPObject* element, WebElement* webElement)
+{
+ return getElementImpl(element, webElement, v8::Isolate::GetCurrent());
+}
+
+NPObject* WebBindings::makeIntArray(const WebVector<int>& data)
+{
+ return makeIntArrayImpl(data);
+}
+
+NPObject* WebBindings::makeStringArray(const WebVector<WebString>& data)
+{
+ return makeStringArrayImpl(data);
+}
+
+void WebBindings::pushExceptionHandler(ExceptionHandler handler, void* data)
+{
+ WebCore::pushExceptionHandler(handler, data);
+}
+
+void WebBindings::popExceptionHandler()
+{
+ WebCore::popExceptionHandler();
+}
+
+void WebBindings::toNPVariant(v8::Local<v8::Value> object, NPObject* root, NPVariant* result)
+{
+ WebCore::convertV8ObjectToNPVariant(object, root, result);
+}
+
+v8::Handle<v8::Value> WebBindings::toV8Value(const NPVariant* variant)
+{
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ if (variant->type == NPVariantType_Object) {
+ NPObject* object = NPVARIANT_TO_OBJECT(*variant);
+ V8NPObject* v8Object = npObjectToV8NPObject(object);
+ if (!v8Object)
+ return v8::Undefined();
+ return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()->script()->windowScriptNPObject(), isolate);
+ }
+ // Safe to pass 0 since we have checked the script object class to make sure the
+ // argument is a primitive v8 type.
+ return convertNPVariantToV8Object(variant, 0, isolate);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebBlob.cpp b/chromium/third_party/WebKit/Source/web/WebBlob.cpp
new file mode 100644
index 00000000000..3fb90d128b3
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebBlob.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebBlob.h"
+
+#include "V8Blob.h"
+#include "bindings/v8/V8Binding.h"
+#include "core/fileapi/Blob.h"
+#include "core/platform/network/BlobData.h"
+#include "wtf/PassOwnPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebBlob WebBlob::createFromFile(const WebString& path, long long size)
+{
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->appendFile(path);
+ RefPtr<Blob> blob = Blob::create(blobData.release(), size);
+ return WebBlob(blob);
+}
+
+WebBlob WebBlob::fromV8Value(v8::Handle<v8::Value> value)
+{
+ if (V8Blob::HasInstanceInAnyWorld(value, v8::Isolate::GetCurrent())) {
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
+ Blob* blob = V8Blob::toNative(object);
+ ASSERT(blob);
+ return WebBlob(blob);
+ }
+ return WebBlob();
+}
+
+void WebBlob::reset()
+{
+ m_private.reset();
+}
+
+void WebBlob::assign(const WebBlob& other)
+{
+ m_private = other.m_private;
+}
+
+WebURL WebBlob::url()
+{
+ if (!m_private.get())
+ return WebURL();
+ return m_private->url();
+}
+
+v8::Handle<v8::Value> WebBlob::toV8Value()
+{
+ if (!m_private.get())
+ return v8::Handle<v8::Value>();
+ return toV8(m_private.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
+}
+
+WebBlob::WebBlob(const WTF::PassRefPtr<WebCore::Blob>& blob)
+ : m_private(blob)
+{
+}
+
+WebBlob& WebBlob::operator=(const WTF::PassRefPtr<WebCore::Blob>& blob)
+{
+ m_private = blob;
+ return *this;
+}
+
+WebBlob::operator WTF::PassRefPtr<WebCore::Blob>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebBlobData.cpp b/chromium/third_party/WebKit/Source/web/WebBlobData.cpp
new file mode 100644
index 00000000000..bbb5798ba9e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebBlobData.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:
+ *
+ * * 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 "core/platform/network/BlobData.h"
+#include "public/platform/WebBlobData.h"
+#include "wtf/PassOwnPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebBlobDataPrivate : public BlobData {
+};
+
+void WebBlobData::initialize()
+{
+ assign(BlobData::create());
+}
+
+void WebBlobData::reset()
+{
+ assign(nullptr);
+}
+
+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; // FIXME: deprecate this.
+ result.url = item.url;
+ return true;
+ case BlobDataItem::URL:
+ result.type = Item::TypeURL;
+ result.url = 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/chromium/third_party/WebKit/Source/web/WebCache.cpp b/chromium/third_party/WebKit/Source/web/WebCache.cpp
new file mode 100644
index 00000000000..c68013d8f7e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebCache.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 "WebCache.h"
+
+#include "core/fetch/MemoryCache.h"
+
+using WebCore::MemoryCache;
+
+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->evictResources();
+}
+
+void WebCache::getUsageStats(UsageStats* result)
+{
+ ASSERT(result);
+
+ MemoryCache* cache = WebCore::memoryCache();
+ if (cache) {
+ result->minDeadCapacity = cache->minDeadCapacity();
+ result->maxDeadCapacity = cache->maxDeadCapacity();
+ result->capacity = cache->capacity();
+ result->liveSize = cache->liveSize();
+ result->deadSize = cache->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);
+ ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets);
+ ToResourceTypeStat(stats.fonts, result->fonts);
+ } else
+ memset(result, 0, sizeof(WebCache::ResourceTypeStats));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebCachedURLRequest.cpp b/chromium/third_party/WebKit/Source/web/WebCachedURLRequest.cpp
new file mode 100644
index 00000000000..a1d9eecf30e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebCachedURLRequest.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebCachedURLRequest.h"
+
+#include "core/fetch/FetchRequest.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "public/platform/WebURLRequest.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebCachedURLRequest::reset()
+{
+ m_resourceRequestWrapper.reset(0);
+ m_private = 0;
+}
+
+const WebURLRequest& WebCachedURLRequest::urlRequest() const
+{
+ if (!m_resourceRequestWrapper.get())
+ m_resourceRequestWrapper.reset(new WrappedResourceRequest(m_private->resourceRequest()));
+ else
+ m_resourceRequestWrapper->bind(m_private->resourceRequest());
+ return *m_resourceRequestWrapper.get();
+}
+
+WebString WebCachedURLRequest::charset() const
+{
+ return WebString(m_private->charset());
+}
+
+bool WebCachedURLRequest::forPreload() const
+{
+ return m_private->forPreload();
+}
+
+WebString WebCachedURLRequest::initiatorName() const
+{
+ return WebString(m_private->options().initiatorInfo.name);
+}
+
+WebCachedURLRequest::WebCachedURLRequest(FetchRequest* request)
+ : m_private(request)
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebColorName.cpp b/chromium/third_party/WebKit/Source/web/WebColorName.cpp
new file mode 100644
index 00000000000..54a1366162b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebColorName.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 "WebColorName.h"
+
+#include "CSSValueKeywords.h"
+#include "core/platform/graphics/Color.h"
+#include "core/rendering/RenderTheme.h"
+#include "public/platform/WebColor.h"
+#include "wtf/UnusedParam.h"
+
+using namespace::WebCore;
+
+namespace WebKit {
+
+static int toCSSValueKeyword(WebColorName name)
+{
+ switch (name) {
+ 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/chromium/third_party/WebKit/Source/web/WebCommon.cpp b/chromium/third_party/WebKit/Source/web/WebCommon.cpp
new file mode 100644
index 00000000000..227d11b1447
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "public/platform/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/chromium/third_party/WebKit/Source/web/WebCrossOriginPreflightResultCache.cpp b/chromium/third_party/WebKit/Source/web/WebCrossOriginPreflightResultCache.cpp
new file mode 100644
index 00000000000..62d43de2006
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/loader/CrossOriginPreflightResultCache.h"
+
+namespace WebKit {
+
+void WebCrossOriginPreflightResultCache::clear()
+{
+ WebCore::CrossOriginPreflightResultCache::shared().empty();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebCustomElement.cpp b/chromium/third_party/WebKit/Source/web/WebCustomElement.cpp
new file mode 100644
index 00000000000..575fb14ce99
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebCustomElement.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebCustomElement.h"
+
+#include "core/dom/CustomElement.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebCustomElement::allowTagName(const WebString& localName)
+{
+ CustomElement::allowTagName(localName);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMActivityLogger.cpp b/chromium/third_party/WebKit/Source/web/WebDOMActivityLogger.cpp
new file mode 100644
index 00000000000..d69d7a0e646
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMActivityLogger.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebDOMActivityLogger.h"
+
+#include "bindings/v8/DOMWrapperWorld.h"
+#include "bindings/v8/V8DOMActivityLogger.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class DOMActivityLoggerContainer : public V8DOMActivityLogger {
+public:
+ explicit DOMActivityLoggerContainer(PassOwnPtr<WebDOMActivityLogger> logger)
+ : m_domActivityLogger(logger)
+ {
+ }
+
+ virtual void log(const String& apiName, int argc, const v8::Handle<v8::Value>* argv, const String& extraInfo)
+ {
+ m_domActivityLogger->log(WebString(apiName), argc, argv, WebString(extraInfo));
+ }
+
+private:
+ OwnPtr<WebDOMActivityLogger> m_domActivityLogger;
+};
+
+bool hasDOMActivityLogger(int worldId)
+{
+ return DOMWrapperWorld::activityLogger(worldId);
+}
+
+void setDOMActivityLogger(int worldId, WebDOMActivityLogger* logger)
+{
+ ASSERT(logger);
+ DOMWrapperWorld::setActivityLogger(worldId, adoptPtr(new DOMActivityLoggerContainer(adoptPtr(logger))));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMCustomEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMCustomEvent.cpp
new file mode 100644
index 00000000000..bc5ebd07807
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMCustomEvent.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebDOMCustomEvent.h"
+
+#include "WebSerializedScriptValue.h"
+#include "bindings/v8/SerializedScriptValue.h"
+#include "core/dom/CustomEvent.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebDOMCustomEvent::initCustomEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& webSerializedScriptValue)
+{
+ ASSERT(m_private.get());
+ RefPtr<SerializedScriptValue> serializedScriptValue;
+ serializedScriptValue = webSerializedScriptValue;
+ unwrap<CustomEvent>()->initCustomEvent(type, canBubble, cancelable, serializedScriptValue.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMEvent.cpp
new file mode 100644
index 00000000000..11354c7c45e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMEvent.cpp
@@ -0,0 +1,209 @@
+/*
+ * 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 "core/dom/Event.h"
+#include "core/dom/EventNames.h"
+#include "core/dom/Node.h"
+#include "wtf/PassRefPtr.h"
+
+using WebCore::eventNames;
+
+namespace WebKit {
+
+class WebDOMEventPrivate : public WebCore::Event {
+};
+
+void WebDOMEvent::reset()
+{
+ assign(0);
+}
+
+void WebDOMEvent::assign(const WebDOMEvent& other)
+{
+ m_private = other.m_private;
+}
+
+void WebDOMEvent::assign(const WTF::PassRefPtr<WebDOMEventPrivate>& event)
+{
+ m_private = event;
+}
+
+WebDOMEvent::WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>& event)
+ : m_private(event)
+{
+}
+
+WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>() const
+{
+ return m_private.get();
+}
+
+WebString WebDOMEvent::type() const
+{
+ ASSERT(m_private.get());
+ return m_private->type();
+}
+
+WebNode WebDOMEvent::target() const
+{
+ ASSERT(m_private.get());
+ return WebNode(m_private->target()->toNode());
+}
+
+WebNode WebDOMEvent::currentTarget() const
+{
+ ASSERT(m_private.get());
+ return WebNode(m_private->currentTarget()->toNode());
+}
+
+WebDOMEvent::PhaseType WebDOMEvent::eventPhase() const
+{
+ ASSERT(m_private.get());
+ return static_cast<WebDOMEvent::PhaseType>(m_private->eventPhase());
+}
+
+bool WebDOMEvent::bubbles() const
+{
+ ASSERT(m_private.get());
+ return m_private->bubbles();
+}
+
+bool WebDOMEvent::cancelable() const
+{
+ ASSERT(m_private.get());
+ return m_private->cancelable();
+}
+
+bool WebDOMEvent::isUIEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->isUIEvent();
+}
+
+bool WebDOMEvent::isMouseEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->isMouseEvent();
+}
+
+bool WebDOMEvent::isKeyboardEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->isKeyboardEvent();
+}
+
+bool WebDOMEvent::isMutationEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(WebCore::eventNames().interfaceForMutationEvent);
+}
+
+bool WebDOMEvent::isTextEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForTextEvent);
+}
+
+bool WebDOMEvent::isCompositionEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForCompositionEvent);
+}
+
+bool WebDOMEvent::isDragEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->isDragEvent();
+}
+
+bool WebDOMEvent::isClipboardEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->isClipboardEvent();
+}
+
+bool WebDOMEvent::isMessageEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForMessageEvent);
+}
+
+bool WebDOMEvent::isWheelEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForWheelEvent);
+}
+
+bool WebDOMEvent::isBeforeTextInsertedEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->isBeforeTextInsertedEvent();
+}
+
+bool WebDOMEvent::isOverflowEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForOverflowEvent);
+}
+
+bool WebDOMEvent::isPageTransitionEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForPageTransitionEvent);
+}
+
+bool WebDOMEvent::isPopStateEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForPopStateEvent);
+}
+
+bool WebDOMEvent::isProgressEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForProgressEvent);
+}
+
+bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgressEvent);
+}
+
+bool WebDOMEvent::isBeforeLoadEvent() const
+{
+ ASSERT(m_private.get());
+ return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMEventListener.cpp b/chromium/third_party/WebKit/Source/web/WebDOMEventListener.cpp
new file mode 100644
index 00000000000..27e64686acb
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMEventListener.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebDOMEventListener.h"
+
+#include "WebDOMEventListenerPrivate.h"
+
+using namespace WebCore;
+
+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, EventTarget* target)
+{
+ return m_private->createEventListenerWrapper(eventType, useCapture, target);
+}
+
+EventListenerWrapper* WebDOMEventListener::getEventListenerWrapper(const WebString& eventType, bool useCapture, EventTarget* target)
+{
+ return m_private->getEventListenerWrapper(eventType, useCapture, target);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp b/chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.cpp
new file mode 100644
index 00000000000..2d83ea22249
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.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 "WebDOMEventListenerPrivate.h"
+
+#include "EventListenerWrapper.h"
+#include "WebDOMEventListener.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebDOMEventListenerPrivate::WebDOMEventListenerPrivate(WebDOMEventListener* webDOMEventListener)
+ : m_webDOMEventListener(webDOMEventListener)
+{
+}
+
+WebDOMEventListenerPrivate::~WebDOMEventListenerPrivate()
+{
+}
+
+EventListenerWrapper* WebDOMEventListenerPrivate::createEventListenerWrapper(const WebString& eventType, bool useCapture, EventTarget* target)
+{
+ EventListenerWrapper* listenerWrapper = new EventListenerWrapper(m_webDOMEventListener);
+ WebDOMEventListenerPrivate::ListenerInfo listenerInfo(eventType, useCapture, listenerWrapper, target);
+ m_listenerWrappers.append(listenerInfo);
+ return listenerWrapper;
+}
+
+EventListenerWrapper* WebDOMEventListenerPrivate::getEventListenerWrapper(const WebString& eventType, bool useCapture, EventTarget* target)
+{
+ Vector<WebDOMEventListenerPrivate::ListenerInfo>::const_iterator iter;
+ for (iter = m_listenerWrappers.begin(); iter != m_listenerWrappers.end(); ++iter) {
+ if (iter->target == target)
+ 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/chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.h b/chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.h
new file mode 100644
index 00000000000..94640d355ae
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMEventListenerPrivate.h
@@ -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:
+ *
+ * * 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 "public/platform/WebString.h"
+#include "wtf/Vector.h"
+
+namespace WebCore {
+class EventTarget;
+}
+
+namespace WebKit {
+
+class EventListenerWrapper;
+class WebDOMEventListener;
+
+class WebDOMEventListenerPrivate {
+public:
+ WebDOMEventListenerPrivate(WebDOMEventListener* webDOMEventListener);
+ ~WebDOMEventListenerPrivate();
+
+ EventListenerWrapper* createEventListenerWrapper(
+ const WebString& eventType, bool useCapture, WebCore::EventTarget*);
+
+ // Gets the ListenerEventWrapper for a specific node.
+ // Used by WebNode::removeDOMEventListener().
+ EventListenerWrapper* getEventListenerWrapper(
+ const WebString& eventType, bool useCapture, WebCore::EventTarget*);
+
+ // 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,
+ WebCore::EventTarget* target)
+ : eventType(eventType)
+ , useCapture(useCapture)
+ , eventListenerWrapper(eventListenerWrapper)
+ , target(target)
+ {
+ }
+
+ WebString eventType;
+ bool useCapture;
+ EventListenerWrapper* eventListenerWrapper;
+ WebCore::EventTarget* target;
+ };
+
+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/chromium/third_party/WebKit/Source/web/WebDOMMessageEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMMessageEvent.cpp
new file mode 100644
index 00000000000..4d6fc026106
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMMessageEvent.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebDOMMessageEvent.h"
+
+#include "WebFrame.h"
+#include "WebFrameImpl.h"
+#include "WebSerializedScriptValue.h"
+#include "bindings/v8/SerializedScriptValue.h"
+#include "core/dom/Document.h"
+#include "core/dom/MessageEvent.h"
+#include "core/dom/MessagePort.h"
+#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h"
+#include "core/page/DOMWindow.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId)
+{
+ ASSERT(m_private.get());
+ ASSERT(isMessageEvent());
+ DOMWindow* window = 0;
+ if (sourceFrame)
+ window = static_cast<const WebFrameImpl*>(sourceFrame)->frame()->domWindow();
+ OwnPtr<MessagePortArray> ports;
+ unwrap<MessageEvent>()->initMessageEvent(type, canBubble, cancelable, messageData, origin, lastEventId, window, ports.release());
+}
+
+WebSerializedScriptValue WebDOMMessageEvent::data() const
+{
+ return WebSerializedScriptValue(constUnwrap<MessageEvent>()->dataAsSerializedScriptValue());
+}
+
+WebString WebDOMMessageEvent::origin() const
+{
+ return WebString(constUnwrap<MessageEvent>()->origin());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMMouseEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMMouseEvent.cpp
new file mode 100644
index 00000000000..09ca6bae0d7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMMouseEvent.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 "WebDOMMouseEvent.h"
+
+#include "core/dom/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::offsetX()
+{
+ return unwrap<MouseEvent>()->offsetX();
+}
+
+int WebDOMMouseEvent::offsetY()
+{
+ return unwrap<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/chromium/third_party/WebKit/Source/web/WebDOMMutationEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMMutationEvent.cpp
new file mode 100644
index 00000000000..618b9561e56
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/dom/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/chromium/third_party/WebKit/Source/web/WebDOMProgressEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMProgressEvent.cpp
new file mode 100644
index 00000000000..7ee9a898811
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMProgressEvent.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebDOMProgressEvent.h"
+
+#include "core/dom/ProgressEvent.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebDOMProgressEvent::WebDOMProgressEvent(const WebString& type, bool lengthIsComputable, unsigned long long loaded, unsigned long long total)
+ : WebDOMEvent(ProgressEvent::create(type, lengthIsComputable, loaded, total))
+{
+ ASSERT(m_private.get());
+ ASSERT(isProgressEvent());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDOMResourceProgressEvent.cpp b/chromium/third_party/WebKit/Source/web/WebDOMResourceProgressEvent.cpp
new file mode 100644
index 00000000000..0e320939645
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDOMResourceProgressEvent.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebDOMResourceProgressEvent.h"
+
+#include "core/dom/ResourceProgressEvent.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebDOMResourceProgressEvent::WebDOMResourceProgressEvent(const WebString& type, bool lengthIsComputable, unsigned long long loaded, unsigned long long total, const WebString& url)
+ : WebDOMProgressEvent()
+{
+ assign(ResourceProgressEvent::create(type, lengthIsComputable, loaded, total, url));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDataSourceImpl.cpp b/chromium/third_party/WebKit/Source/web/WebDataSourceImpl.cpp
new file mode 100644
index 00000000000..0ed7727edb9
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDataSourceImpl.cpp
@@ -0,0 +1,195 @@
+/*
+ * 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 "core/dom/Document.h"
+#include "core/loader/FrameLoader.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static OwnPtr<WebPluginLoadObserver>& nextPluginLoadObserver()
+{
+ DEFINE_STATIC_LOCAL(OwnPtr<WebPluginLoadObserver>, nextPluginLoadObserver, ());
+ return nextPluginLoadObserver;
+}
+
+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);
+}
+
+bool WebDataSourceImpl::isClientRedirect() const
+{
+ return DocumentLoader::isClientRedirect();
+}
+
+bool WebDataSourceImpl::replacesCurrentHistoryItem() const
+{
+ return DocumentLoader::replacesCurrentHistoryItem();
+}
+
+WebString WebDataSourceImpl::pageTitle() const
+{
+ ASSERT(frame()->loader()->documentLoader() == this);
+ return frame()->document()->title();
+}
+
+WebTextDirection WebDataSourceImpl::pageTitleDirection() const
+{
+ ASSERT(frame()->loader()->documentLoader() == this);
+ return frame()->document()->titleWithDirection().direction() == LTR ? WebTextDirectionLeftToRight : WebTextDirectionRightToLeft;
+}
+
+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)
+{
+ // extraData can't be a PassOwnPtr because setExtraData is a WebKit API function.
+ m_extraData = adoptPtr(extraData);
+}
+
+WebApplicationCacheHost* WebDataSourceImpl::applicationCacheHost()
+{
+ return ApplicationCacheHostInternal::toWebApplicationCacheHost(DocumentLoader::applicationCacheHost());
+}
+
+void WebDataSourceImpl::setDeferMainResourceDataLoad(bool defer)
+{
+ DocumentLoader::setDeferMainResourceDataLoad(defer);
+}
+
+void WebDataSourceImpl::setNavigationStartTime(double navigationStart)
+{
+ timing()->setNavigationStart(navigationStart);
+}
+
+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;
+ }
+}
+
+void WebDataSourceImpl::setNextPluginLoadObserver(PassOwnPtr<WebPluginLoadObserver> observer)
+{
+ nextPluginLoadObserver() = observer;
+}
+
+WebDataSourceImpl::WebDataSourceImpl(const ResourceRequest& request, const SubstituteData& data)
+ : DocumentLoader(request, data)
+{
+ if (!nextPluginLoadObserver())
+ return;
+ // 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())
+ return;
+
+ ASSERT(nextPluginLoadObserver()->url() == WebURL(request.url()));
+ m_pluginLoadObserver = nextPluginLoadObserver().release();
+}
+
+WebDataSourceImpl::~WebDataSourceImpl()
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDataSourceImpl.h b/chromium/third_party/WebKit/Source/web/WebDataSourceImpl.h
new file mode 100644
index 00000000000..59ec26fb7db
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDataSourceImpl.h
@@ -0,0 +1,98 @@
+/*
+ * 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 "WebDataSource.h"
+#include "WebPluginLoadObserver.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/platform/chromium/support/WrappedResourceRequest.h"
+#include "core/platform/chromium/support/WrappedResourceResponse.h"
+#include "weborigin/KURL.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 bool isClientRedirect() const;
+ virtual bool replacesCurrentHistoryItem() const;
+ virtual WebString pageTitle() const;
+ virtual WebTextDirection pageTitleDirection() const;
+ virtual WebNavigationType navigationType() const;
+ virtual double triggeringEventTime() const;
+ virtual ExtraData* extraData() const;
+ virtual void setExtraData(ExtraData*);
+ virtual WebApplicationCacheHost* applicationCacheHost();
+ virtual void setDeferMainResourceDataLoad(bool);
+ virtual void setNavigationStartTime(double);
+
+ static WebNavigationType toWebNavigationType(WebCore::NavigationType type);
+
+ 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;
+
+ OwnPtr<ExtraData> m_extraData;
+ OwnPtr<WebPluginLoadObserver> m_pluginLoadObserver;
+};
+
+} // namespace WebKit
+
+#endif // WebDataSourceImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebDatabase.cpp b/chromium/third_party/WebKit/Source/web/WebDatabase.cpp
new file mode 100644
index 00000000000..dea6ea57f05
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDatabase.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 "WebDatabase.h"
+
+#include "public/platform/WebString.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "WebDatabaseObserver.h"
+#include "modules/webdatabase/DatabaseBackendBase.h"
+#include "modules/webdatabase/DatabaseManager.h"
+#include "modules/webdatabase/QuotaTracker.h"
+#include "weborigin/SecurityOrigin.h"
+
+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());
+}
+
+bool WebDatabase::isSyncDatabase() const
+{
+ ASSERT(m_database);
+ return m_database->isSyncDatabase();
+}
+
+void WebDatabase::setObserver(WebDatabaseObserver* observer)
+{
+ databaseObserver = observer;
+}
+
+WebDatabaseObserver* WebDatabase::observer()
+{
+ return databaseObserver;
+}
+
+void WebDatabase::updateDatabaseSize(const WebString& originIdentifier, const WebString& name, long long size)
+{
+ QuotaTracker::instance().updateDatabaseSize(originIdentifier, name, size);
+}
+
+void WebDatabase::updateSpaceAvailable(const WebString& originIdentifier, long long spaceAvailable)
+{
+ QuotaTracker::instance().updateSpaceAvailableToOrigin(originIdentifier, spaceAvailable);
+}
+
+void WebDatabase::resetSpaceAvailable(const WebString& originIdentifier)
+{
+ QuotaTracker::instance().resetSpaceAvailableToOrigin(originIdentifier);
+}
+
+void WebDatabase::closeDatabaseImmediately(const WebString& originIdentifier, const WebString& databaseName)
+{
+ DatabaseManager::manager().closeDatabasesImmediately(originIdentifier, databaseName);
+}
+
+WebDatabase::WebDatabase(const DatabaseBackendBase* database)
+ : m_database(database)
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp b/chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp
new file mode 100644
index 00000000000..3ea57461e1f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp
@@ -0,0 +1,768 @@
+/*
+ * Copyright (C) 2010-2011 Google Inc. 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 "InspectorBackendDispatcher.h"
+#include "InspectorFrontend.h"
+#include "InspectorProtocolVersion.h"
+#include "WebDataSource.h"
+#include "WebDevToolsAgentClient.h"
+#include "WebFrameImpl.h"
+#include "WebInputEventConversion.h"
+#include "WebMemoryUsageInfo.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "bindings/v8/PageScriptDebugServer.h"
+#include "bindings/v8/ScriptController.h"
+#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8Utilities.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/fetch/MemoryCache.h"
+#include "core/inspector/InjectedScriptHost.h"
+#include "core/inspector/InspectorController.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/PageGroup.h"
+#include "core/platform/JSONValues.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/network/ResourceError.h"
+#include "core/platform/network/ResourceRequest.h"
+#include "core/platform/network/ResourceResponse.h"
+#include "core/rendering/RenderView.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebURLRequest.h"
+#include "public/platform/WebURLResponse.h"
+#include "wtf/CurrentTime.h"
+#include "wtf/MathExtras.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+using namespace std;
+
+namespace OverlayZOrders {
+// Use 99 as a big z-order number so that highlight is above other overlays.
+static const int highlight = 99;
+}
+
+namespace WebKit {
+
+class ClientMessageLoopAdapter : public PageScriptDebugServer::ClientMessageLoop {
+public:
+ static void ensureClientMessageLoopCreated(WebDevToolsAgentClient* client)
+ {
+ if (s_instance)
+ return;
+ OwnPtr<ClientMessageLoopAdapter> instance = adoptPtr(new ClientMessageLoopAdapter(adoptPtr(client->createClientMessageLoop())));
+ s_instance = instance.get();
+ PageScriptDebugServer::shared().setClientMessageLoop(instance.release());
+ }
+
+ 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)
+ PageScriptDebugServer::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);
+ if (!view)
+ continue;
+ 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;
+ // FIXME: The ownership model for s_instance is somewhat complicated. Can we make this simpler?
+ static ClientMessageLoopAdapter* s_instance;
+};
+
+ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = 0;
+
+class DebuggerTask : public PageScriptDebugServer::Task {
+public:
+ DebuggerTask(PassOwnPtr<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;
+};
+
+class DeviceMetricsSupport {
+public:
+ DeviceMetricsSupport(WebViewImpl* webView)
+ : m_webView(webView)
+ , m_fitWindow(false)
+ , m_originalZoomFactor(0)
+ {
+ }
+
+ ~DeviceMetricsSupport()
+ {
+ restore();
+ }
+
+ void setDeviceMetrics(int width, int height, float textZoomFactor, bool fitWindow)
+ {
+ WebCore::FrameView* view = frameView();
+ if (!view)
+ return;
+
+ m_emulatedFrameSize = WebSize(width, height);
+ m_fitWindow = fitWindow;
+ m_originalZoomFactor = 0;
+ m_webView->setEmulatedTextZoomFactor(textZoomFactor);
+ applySizeOverrideInternal(view, FitWindowAllowed);
+ autoZoomPageToFitWidth(view->frame());
+
+ m_webView->sendResizeEventAndRepaint();
+ }
+
+ void autoZoomPageToFitWidthOnNavigation(Frame* frame)
+ {
+ FrameView* frameView = frame->view();
+ applySizeOverrideInternal(frameView, FitWindowNotAllowed);
+ m_originalZoomFactor = 0;
+ applySizeOverrideInternal(frameView, FitWindowAllowed);
+ autoZoomPageToFitWidth(frame);
+ }
+
+ void autoZoomPageToFitWidth(Frame* frame)
+ {
+ if (!frame)
+ return;
+
+ frame->setTextZoomFactor(m_webView->emulatedTextZoomFactor());
+ ensureOriginalZoomFactor(frame->view());
+ Document* document = frame->document();
+ float numerator = document->renderView() ? document->renderView()->viewWidth() : frame->view()->contentsWidth();
+ float factor = m_originalZoomFactor * (numerator / m_emulatedFrameSize.width);
+ frame->setPageAndTextZoomFactors(factor, m_webView->emulatedTextZoomFactor());
+ document->styleResolverChanged(RecalcStyleImmediately);
+ document->updateLayout();
+ }
+
+ void webViewResized()
+ {
+ if (!m_fitWindow)
+ return;
+
+ applySizeOverrideIfNecessary();
+ autoZoomPageToFitWidth(m_webView->mainFrameImpl()->frame());
+ }
+
+ void applySizeOverrideIfNecessary()
+ {
+ FrameView* view = frameView();
+ if (!view)
+ return;
+
+ applySizeOverrideInternal(view, FitWindowAllowed);
+ }
+
+private:
+ enum FitWindowFlag { FitWindowAllowed, FitWindowNotAllowed };
+
+ void ensureOriginalZoomFactor(FrameView* frameView)
+ {
+ if (m_originalZoomFactor)
+ return;
+
+ m_webView->setPageScaleFactor(1, WebPoint());
+ m_webView->setZoomLevel(false, 0);
+ WebSize scaledEmulatedSize = scaledEmulatedFrameSize(frameView);
+ double denominator = frameView->contentsWidth();
+ if (!denominator)
+ denominator = 1;
+ m_originalZoomFactor = static_cast<double>(scaledEmulatedSize.width) / denominator;
+ }
+
+ void restore()
+ {
+ WebCore::FrameView* view = frameView();
+ if (!view)
+ return;
+
+ m_webView->setZoomLevel(false, 0);
+ m_webView->setEmulatedTextZoomFactor(1);
+ view->setHorizontalScrollbarLock(false);
+ view->setVerticalScrollbarLock(false);
+ view->setScrollbarModes(ScrollbarAuto, ScrollbarAuto, false, false);
+ view->setFrameRect(IntRect(IntPoint(), IntSize(m_webView->size())));
+ m_webView->sendResizeEventAndRepaint();
+ }
+
+ WebSize scaledEmulatedFrameSize(FrameView* frameView)
+ {
+ if (!m_fitWindow)
+ return m_emulatedFrameSize;
+
+ WebSize scrollbarDimensions = forcedScrollbarDimensions(frameView);
+
+ int overrideWidth = m_emulatedFrameSize.width;
+ int overrideHeight = m_emulatedFrameSize.height;
+
+ WebSize webViewSize = m_webView->size();
+ int availableViewWidth = max(webViewSize.width - scrollbarDimensions.width, 1);
+ int availableViewHeight = max(webViewSize.height - scrollbarDimensions.height, 1);
+
+ double widthRatio = static_cast<double>(overrideWidth) / availableViewWidth;
+ double heightRatio = static_cast<double>(overrideHeight) / availableViewHeight;
+ double dimensionRatio = max(widthRatio, heightRatio);
+ overrideWidth = static_cast<int>(ceil(static_cast<double>(overrideWidth) / dimensionRatio));
+ overrideHeight = static_cast<int>(ceil(static_cast<double>(overrideHeight) / dimensionRatio));
+
+ return WebSize(overrideWidth, overrideHeight);
+ }
+
+ WebSize forcedScrollbarDimensions(FrameView* frameView)
+ {
+ frameView->setScrollbarModes(ScrollbarAlwaysOn, ScrollbarAlwaysOn, true, true);
+
+ int verticalScrollbarWidth = 0;
+ int horizontalScrollbarHeight = 0;
+ if (Scrollbar* verticalBar = frameView->verticalScrollbar())
+ verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0;
+ if (Scrollbar* horizontalBar = frameView->horizontalScrollbar())
+ horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0;
+ return WebSize(verticalScrollbarWidth, horizontalScrollbarHeight);
+ }
+
+ void applySizeOverrideInternal(FrameView* frameView, FitWindowFlag fitWindowFlag)
+ {
+ WebSize scrollbarDimensions = forcedScrollbarDimensions(frameView);
+
+ WebSize effectiveEmulatedSize = (fitWindowFlag == FitWindowAllowed) ? scaledEmulatedFrameSize(frameView) : m_emulatedFrameSize;
+ int overrideWidth = effectiveEmulatedSize.width + scrollbarDimensions.width;
+ int overrideHeight = effectiveEmulatedSize.height + scrollbarDimensions.height;
+
+ if (IntSize(overrideWidth, overrideHeight) != frameView->size())
+ frameView->resize(overrideWidth, overrideHeight);
+
+ Document* doc = frameView->frame()->document();
+ doc->styleResolverChanged(RecalcStyleImmediately);
+ doc->updateLayout();
+ }
+
+ WebCore::FrameView* frameView()
+ {
+ return m_webView->mainFrameImpl() ? m_webView->mainFrameImpl()->frameView() : 0;
+ }
+
+ WebViewImpl* m_webView;
+ WebSize m_emulatedFrameSize;
+ bool m_fitWindow;
+ double m_originalZoomFactor;
+};
+
+WebDevToolsAgentImpl::WebDevToolsAgentImpl(
+ WebViewImpl* webViewImpl,
+ WebDevToolsAgentClient* client)
+ : m_hostId(client->hostIdentifier())
+ , m_client(client)
+ , m_webViewImpl(webViewImpl)
+ , m_attached(false)
+{
+ ASSERT(m_hostId > 0);
+ ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client);
+}
+
+WebDevToolsAgentImpl::~WebDevToolsAgentImpl()
+{
+ ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl);
+ if (m_attached)
+ WebKit::Platform::current()->currentThread()->removeTaskObserver(this);
+}
+
+void WebDevToolsAgentImpl::attach()
+{
+ if (m_attached)
+ return;
+
+ inspectorController()->connectFrontend(this);
+ inspectorController()->webViewResized(m_webViewImpl->size());
+ WebKit::Platform::current()->currentThread()->addTaskObserver(this);
+ m_attached = true;
+}
+
+void WebDevToolsAgentImpl::reattach(const WebString& savedState)
+{
+ if (m_attached)
+ return;
+
+ inspectorController()->reuseFrontend(this, savedState);
+ WebKit::Platform::current()->currentThread()->addTaskObserver(this);
+ m_attached = true;
+}
+
+void WebDevToolsAgentImpl::detach()
+{
+ WebKit::Platform::current()->currentThread()->removeTaskObserver(this);
+
+ // Prevent controller from sending messages to the frontend.
+ InspectorController* ic = inspectorController();
+ ic->disconnectFrontend();
+ ic->hideHighlight();
+ m_attached = false;
+}
+
+void WebDevToolsAgentImpl::didNavigate()
+{
+ ClientMessageLoopAdapter::didNavigate();
+}
+
+void WebDevToolsAgentImpl::didBeginFrame()
+{
+ if (InspectorController* ic = inspectorController())
+ ic->didBeginFrame();
+}
+
+void WebDevToolsAgentImpl::didCancelFrame()
+{
+ if (InspectorController* ic = inspectorController())
+ ic->didCancelFrame();
+}
+
+void WebDevToolsAgentImpl::willComposite()
+{
+ if (InspectorController* ic = inspectorController())
+ ic->willComposite();
+}
+
+void WebDevToolsAgentImpl::didComposite()
+{
+ if (InspectorController* ic = inspectorController())
+ ic->didComposite();
+}
+
+void WebDevToolsAgentImpl::didCreateScriptContext(WebFrameImpl* webframe, int worldId)
+{
+ // Skip non main world contexts.
+ if (worldId)
+ return;
+ if (WebCore::Frame* frame = webframe->frame())
+ frame->script()->setContextDebugId(m_hostId);
+}
+
+void WebDevToolsAgentImpl::mainFrameViewCreated(WebFrameImpl* webFrame)
+{
+ if (m_metricsSupport)
+ m_metricsSupport->applySizeOverrideIfNecessary();
+}
+
+bool WebDevToolsAgentImpl::metricsOverridden()
+{
+ return !!m_metricsSupport;
+}
+
+void WebDevToolsAgentImpl::webViewResized(const WebSize& size)
+{
+ if (m_metricsSupport)
+ m_metricsSupport->webViewResized();
+ if (InspectorController* ic = inspectorController())
+ ic->webViewResized(m_metricsSupport ? IntSize(size.width, size.height) : IntSize());
+}
+
+bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputEvent& inputEvent)
+{
+ if (!m_attached)
+ return false;
+
+ InspectorController* ic = inspectorController();
+ if (!ic)
+ return false;
+
+ if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) {
+ // Only let GestureTab in (we only need it and we know PlatformGestureEventBuilder supports it).
+ PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(page->mainFrame()->view(), *static_cast<const WebGestureEvent*>(&inputEvent));
+ return ic->handleGestureEvent(page->mainFrame(), gestureEvent);
+ }
+ if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != WebInputEvent::MouseEnter) {
+ // PlatformMouseEventBuilder does not work with MouseEnter type, so we filter it out manually.
+ PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(page->mainFrame()->view(), *static_cast<const WebMouseEvent*>(&inputEvent));
+ return ic->handleMouseEvent(page->mainFrame(), mouseEvent);
+ }
+ if (WebInputEvent::isTouchEventType(inputEvent.type)) {
+ PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(page->mainFrame()->view(), *static_cast<const WebTouchEvent*>(&inputEvent));
+ return ic->handleTouchEvent(page->mainFrame(), touchEvent);
+ }
+ return false;
+}
+
+void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow)
+{
+ if (!width && !height) {
+ if (m_metricsSupport)
+ m_metricsSupport.clear();
+ if (InspectorController* ic = inspectorController())
+ ic->webViewResized(IntSize());
+ return;
+ }
+
+ if (!m_metricsSupport)
+ m_metricsSupport = adoptPtr(new DeviceMetricsSupport(m_webViewImpl));
+
+ m_metricsSupport->setDeviceMetrics(width, height, fontScaleFactor, fitWindow);
+ if (InspectorController* ic = inspectorController()) {
+ WebSize size = m_webViewImpl->size();
+ ic->webViewResized(IntSize(size.width, size.height));
+ }
+}
+
+void WebDevToolsAgentImpl::autoZoomPageToFitWidth()
+{
+ if (m_metricsSupport)
+ m_metricsSupport->autoZoomPageToFitWidthOnNavigation(m_webViewImpl->mainFrameImpl()->frame());
+}
+
+void WebDevToolsAgentImpl::getAllocatedObjects(HashSet<const void*>& set)
+{
+ class CountingVisitor : public WebDevToolsAgentClient::AllocatedObjectVisitor {
+ public:
+ CountingVisitor() : m_totalObjectsCount(0)
+ {
+ }
+
+ virtual bool visitObject(const void* ptr)
+ {
+ ++m_totalObjectsCount;
+ return true;
+ }
+ size_t totalObjectsCount() const
+ {
+ return m_totalObjectsCount;
+ }
+
+ private:
+ size_t m_totalObjectsCount;
+ };
+
+ CountingVisitor counter;
+ m_client->visitAllocatedObjects(&counter);
+
+ class PointerCollector : public WebDevToolsAgentClient::AllocatedObjectVisitor {
+ public:
+ explicit PointerCollector(size_t maxObjectsCount)
+ : m_maxObjectsCount(maxObjectsCount)
+ , m_index(0)
+ , m_success(true)
+ , m_pointers(new const void*[maxObjectsCount])
+ {
+ }
+ virtual ~PointerCollector()
+ {
+ delete[] m_pointers;
+ }
+ virtual bool visitObject(const void* ptr)
+ {
+ if (m_index == m_maxObjectsCount) {
+ m_success = false;
+ return false;
+ }
+ m_pointers[m_index++] = ptr;
+ return true;
+ }
+
+ bool success() const { return m_success; }
+
+ void copyTo(HashSet<const void*>& set)
+ {
+ for (size_t i = 0; i < m_index; i++)
+ set.add(m_pointers[i]);
+ }
+
+ private:
+ const size_t m_maxObjectsCount;
+ size_t m_index;
+ bool m_success;
+ const void** m_pointers;
+ };
+
+ // Double size to allow room for all objects that may have been allocated
+ // since we counted them.
+ size_t estimatedMaxObjectsCount = counter.totalObjectsCount() * 2;
+ while (true) {
+ PointerCollector collector(estimatedMaxObjectsCount);
+ m_client->visitAllocatedObjects(&collector);
+ if (collector.success()) {
+ collector.copyTo(set);
+ break;
+ }
+ estimatedMaxObjectsCount *= 2;
+ }
+}
+
+void WebDevToolsAgentImpl::dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>& map)
+{
+ class InstrumentedObjectSizeProvider : public WebDevToolsAgentClient::InstrumentedObjectSizeProvider {
+ public:
+ InstrumentedObjectSizeProvider(const HashMap<const void*, size_t>& map) : m_map(map) { }
+ virtual size_t objectSize(const void* ptr) const
+ {
+ HashMap<const void*, size_t>::const_iterator i = m_map.find(ptr);
+ return i == m_map.end() ? 0 : i->value;
+ }
+
+ private:
+ const HashMap<const void*, size_t>& m_map;
+ };
+
+ InstrumentedObjectSizeProvider provider(map);
+ m_client->dumpUncountedAllocatedObjects(&provider);
+}
+
+void WebDevToolsAgentImpl::setTraceEventCallback(TraceEventCallback callback)
+{
+ m_client->setTraceEventCallback(callback);
+}
+
+void WebDevToolsAgentImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event)
+{
+ WebKeyboardEvent webEvent = WebKeyboardEventBuilder(event);
+ if (!webEvent.keyIdentifier[0] && webEvent.type != WebInputEvent::Char)
+ webEvent.setKeyIdentifierFromWindowsKeyCode();
+ m_webViewImpl->handleInputEvent(webEvent);
+}
+
+void WebDevToolsAgentImpl::dispatchMouseEvent(const PlatformMouseEvent& event)
+{
+ WebMouseEvent webEvent = WebMouseEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), event);
+ m_webViewImpl->handleInputEvent(webEvent);
+}
+
+void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message)
+{
+ inspectorController()->dispatchMessageFromFrontend(message);
+}
+
+void WebDevToolsAgentImpl::inspectElementAt(const WebPoint& point)
+{
+ m_webViewImpl->inspectElementAt(point);
+}
+
+InspectorController* WebDevToolsAgentImpl::inspectorController()
+{
+ if (Page* page = m_webViewImpl->page())
+ return page->inspectorController();
+ return 0;
+}
+
+Frame* WebDevToolsAgentImpl::mainFrame()
+{
+ if (Page* page = m_webViewImpl->page())
+ return page->mainFrame();
+ return 0;
+}
+
+// WebPageOverlay
+void WebDevToolsAgentImpl::paintPageOverlay(WebCanvas* canvas)
+{
+ InspectorController* ic = inspectorController();
+ if (ic) {
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ ic->drawHighlight(context);
+ }
+}
+
+void WebDevToolsAgentImpl::highlight()
+{
+ m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight);
+}
+
+void WebDevToolsAgentImpl::hideHighlight()
+{
+ m_webViewImpl->removePageOverlay(this);
+}
+
+bool WebDevToolsAgentImpl::sendMessageToFrontend(const String& message)
+{
+ WebDevToolsAgentImpl* devToolsAgent = static_cast<WebDevToolsAgentImpl*>(m_webViewImpl->devToolsAgent());
+ if (!devToolsAgent)
+ return false;
+ m_client->sendMessageToInspectorFrontend(message);
+ return true;
+}
+
+void WebDevToolsAgentImpl::updateInspectorStateCookie(const String& state)
+{
+ m_client->saveAgentRuntimeState(state);
+}
+
+void WebDevToolsAgentImpl::clearBrowserCache()
+{
+ m_client->clearBrowserCache();
+}
+
+void WebDevToolsAgentImpl::clearBrowserCookies()
+{
+ m_client->clearBrowserCookies();
+}
+
+void WebDevToolsAgentImpl::setProcessId(long processId)
+{
+ inspectorController()->setProcessId(processId);
+}
+
+void WebDevToolsAgentImpl::setLayerTreeId(int layerTreeId)
+{
+ inspectorController()->setLayerTreeId(layerTreeId);
+}
+
+void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString& script)
+{
+ InspectorController* ic = inspectorController();
+ ic->evaluateForTestInFrontend(callId, script);
+}
+
+void WebDevToolsAgentImpl::willProcessTask()
+{
+ if (InspectorController* ic = inspectorController())
+ ic->willProcessTask();
+}
+
+void WebDevToolsAgentImpl::didProcessTask()
+{
+ if (InspectorController* ic = inspectorController())
+ ic->didProcessTask();
+}
+
+WebString WebDevToolsAgent::inspectorProtocolVersion()
+{
+ return WebCore::inspectorProtocolVersion();
+}
+
+bool WebDevToolsAgent::supportsInspectorProtocolVersion(const WebString& version)
+{
+ return WebCore::supportsInspectorProtocolVersion(version);
+}
+
+void WebDevToolsAgent::interruptAndDispatch(MessageDescriptor* rawDescriptor)
+{
+ // rawDescriptor can't be a PassOwnPtr because interruptAndDispatch is a WebKit API function.
+ OwnPtr<MessageDescriptor> descriptor = adoptPtr(rawDescriptor);
+ OwnPtr<DebuggerTask> task = adoptPtr(new DebuggerTask(descriptor.release()));
+ PageScriptDebugServer::interruptAndRun(task.release(), v8::Isolate::GetCurrent());
+}
+
+bool WebDevToolsAgent::shouldInterruptForMessage(const WebString& message)
+{
+ String commandName;
+ if (!InspectorBackendDispatcher::getCommandName(message, &commandName))
+ return false;
+ return commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kDebugger_pauseCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kDebugger_setBreakpointCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kDebugger_setBreakpointByUrlCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kDebugger_removeBreakpointCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kDebugger_setBreakpointsActiveCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kProfiler_startCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kProfiler_stopCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kProfiler_getCPUProfileCmd]
+ || commandName == InspectorBackendDispatcher::commandNames[InspectorBackendDispatcher::kHeapProfiler_getHeapSnapshotCmd];
+}
+
+void WebDevToolsAgent::processPendingMessages()
+{
+ PageScriptDebugServer::shared().runPendingTasks();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h b/chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h
new file mode 100644
index 00000000000..afa0b9f3412
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h
@@ -0,0 +1,141 @@
+/*
+ * 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 "core/inspector/InspectorClient.h"
+#include "core/inspector/InspectorFrontendChannel.h"
+
+#include "WebDevToolsAgentPrivate.h"
+#include "WebPageOverlay.h"
+#include "public/platform/WebSize.h"
+#include "public/platform/WebThread.h"
+#include "wtf/Forward.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebCore {
+class Document;
+class Frame;
+class FrameView;
+class GraphicsContext;
+class InspectorClient;
+class InspectorController;
+class Node;
+class PlatformKeyboardEvent;
+}
+
+namespace WebKit {
+
+class DeviceMetricsSupport;
+class WebDevToolsAgentClient;
+class WebFrame;
+class WebFrameImpl;
+class WebString;
+class WebURLRequest;
+class WebURLResponse;
+class WebViewImpl;
+struct WebMemoryUsageInfo;
+struct WebURLError;
+struct WebDevToolsMessageData;
+
+class WebDevToolsAgentImpl : public WebDevToolsAgentPrivate,
+ public WebCore::InspectorClient,
+ public WebCore::InspectorFrontendChannel,
+ public WebPageOverlay,
+ private WebThread::TaskObserver {
+public:
+ WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client);
+ virtual ~WebDevToolsAgentImpl();
+
+ // WebDevToolsAgentPrivate implementation.
+ virtual void didCreateScriptContext(WebFrameImpl*, int worldId);
+ virtual void mainFrameViewCreated(WebFrameImpl*);
+ virtual bool metricsOverridden();
+ virtual void webViewResized(const WebSize&);
+ virtual bool handleInputEvent(WebCore::Page*, const WebInputEvent&);
+
+ // WebDevToolsAgent implementation.
+ virtual void attach();
+ virtual void reattach(const WebString& savedState);
+ virtual void detach();
+ virtual void didNavigate();
+ virtual void didBeginFrame();
+ virtual void didCancelFrame();
+ virtual void willComposite();
+ virtual void didComposite();
+ virtual void dispatchOnInspectorBackend(const WebString& message);
+ virtual void inspectElementAt(const WebPoint& point);
+ virtual void evaluateInWebInspector(long callId, const WebString& script);
+ virtual void setProcessId(long);
+ virtual void setLayerTreeId(int);
+
+ // InspectorClient implementation.
+ virtual void highlight();
+ virtual void hideHighlight();
+ virtual void updateInspectorStateCookie(const WTF::String&);
+ virtual bool sendMessageToFrontend(const WTF::String&);
+
+ virtual void clearBrowserCache();
+ virtual void clearBrowserCookies();
+
+ virtual void overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow);
+ virtual void autoZoomPageToFitWidth();
+
+ virtual void getAllocatedObjects(HashSet<const void*>&);
+ virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&);
+ virtual void setTraceEventCallback(TraceEventCallback);
+
+ virtual void dispatchKeyEvent(const WebCore::PlatformKeyboardEvent&);
+ virtual void dispatchMouseEvent(const WebCore::PlatformMouseEvent&);
+
+ int hostId() { return m_hostId; }
+
+ // WebPageOverlay
+ virtual void paintPageOverlay(WebCanvas*);
+
+private:
+ // WebThread::TaskObserver
+ virtual void willProcessTask();
+ virtual void didProcessTask();
+
+ WebCore::InspectorController* inspectorController();
+ WebCore::Frame* mainFrame();
+
+ int m_hostId;
+ WebDevToolsAgentClient* m_client;
+ WebViewImpl* m_webViewImpl;
+ bool m_attached;
+ OwnPtr<DeviceMetricsSupport> m_metricsSupport;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebDevToolsAgentPrivate.h b/chromium/third_party/WebKit/Source/web/WebDevToolsAgentPrivate.h
new file mode 100644
index 00000000000..2c57e0f6d63
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDevToolsAgentPrivate.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 WebDevToolsAgentPrivate_h
+#define WebDevToolsAgentPrivate_h
+
+#include "WebDevToolsAgent.h"
+
+namespace WebKit {
+class WebFrameImpl;
+class WebInputEvent;
+struct WebSize;
+
+class WebDevToolsAgentPrivate : public WebDevToolsAgent {
+public:
+
+ // Notification from FrameLoaderClientImpl:
+ // New context has been created for a given world in given frame. Any
+ // processing hat needs to happen before the first script is evaluated
+ // in this context should be done here.
+ virtual void didCreateScriptContext(WebFrameImpl*, int worldId) = 0;
+
+ // A new FrameView has been created for the specified WebFrame using
+ // the Frame::createView() call.
+ virtual void mainFrameViewCreated(WebFrameImpl*) = 0;
+
+ // Returns true if the device metrics override mode is enabled.
+ virtual bool metricsOverridden() = 0;
+
+ // WebViewImpl has been resized.
+ virtual void webViewResized(const WebSize&) = 0;
+
+ // DevTools may handle input event from WebViewImpl.
+ virtual bool handleInputEvent(WebCore::Page*, const WebInputEvent&) = 0;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp b/chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp
new file mode 100644
index 00000000000..787626c856b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.cpp
@@ -0,0 +1,173 @@
+/*
+ * 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 "InspectorFrontendClientImpl.h"
+#include "V8InspectorFrontendHost.h"
+#include "V8MouseEvent.h"
+#include "V8Node.h"
+#include "WebDevToolsFrontendClient.h"
+#include "WebFrameImpl.h"
+#include "WebScriptSource.h"
+#include "WebViewImpl.h"
+#include "bindings/v8/ScriptController.h"
+#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8DOMWrapper.h"
+#include "bindings/v8/V8Utilities.h"
+#include "core/dom/Document.h"
+#include "core/dom/Event.h"
+#include "core/dom/Node.h"
+#include "core/inspector/InspectorController.h"
+#include "core/inspector/InspectorFrontendHost.h"
+#include "core/page/ContextMenuController.h"
+#include "core/page/DOMWindow.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/ContextMenuItem.h"
+#include "core/platform/Pasteboard.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebDevToolsFrontendImpl::InspectorFrontendResumeObserver : public ActiveDOMObject {
+ WTF_MAKE_NONCOPYABLE(InspectorFrontendResumeObserver);
+public:
+ InspectorFrontendResumeObserver(WebDevToolsFrontendImpl* webDevToolsFrontendImpl, Document* document)
+ : ActiveDOMObject(document)
+ , m_webDevToolsFrontendImpl(webDevToolsFrontendImpl)
+ {
+ suspendIfNeeded();
+ }
+
+private:
+ virtual bool canSuspend() const OVERRIDE
+ {
+ return true;
+ }
+
+ virtual void resume() OVERRIDE
+ {
+ m_webDevToolsFrontendImpl->resume();
+ }
+
+ WebDevToolsFrontendImpl* m_webDevToolsFrontendImpl;
+};
+
+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)
+ , m_inspectorFrontendDispatchTimer(this, &WebDevToolsFrontendImpl::maybeDispatch)
+{
+ InspectorController* ic = m_webViewImpl->page()->inspectorController();
+ ic->setInspectorFrontendClient(adoptPtr(new InspectorFrontendClientImpl(m_webViewImpl->page(), m_client, this)));
+
+ // Put each DevTools frontend Page into a private group so that it's not
+ // deferred along with the inspected page.
+ m_webViewImpl->page()->setGroupType(Page::InspectorPageGroup);
+}
+
+WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl()
+{
+}
+
+void WebDevToolsFrontendImpl::dispatchOnInspectorFrontend(const WebString& message)
+{
+ m_messages.append(message);
+ maybeDispatch(0);
+}
+
+void WebDevToolsFrontendImpl::resume()
+{
+ // We should call maybeDispatch asynchronously here because we are not allowed to update activeDOMObjects list in
+ // resume (See ScriptExecutionContext::resumeActiveDOMObjects).
+ if (!m_inspectorFrontendDispatchTimer.isActive())
+ m_inspectorFrontendDispatchTimer.startOneShot(0);
+}
+
+void WebDevToolsFrontendImpl::maybeDispatch(WebCore::Timer<WebDevToolsFrontendImpl>*)
+{
+ while (!m_messages.isEmpty()) {
+ Document* document = m_webViewImpl->page()->mainFrame()->document();
+ if (document->activeDOMObjectsAreSuspended()) {
+ m_inspectorFrontendResumeObserver = adoptPtr(new InspectorFrontendResumeObserver(this, document));
+ return;
+ }
+ m_inspectorFrontendResumeObserver.clear();
+ doDispatchOnInspectorFrontend(m_messages.takeFirst());
+ }
+}
+
+void WebDevToolsFrontendImpl::doDispatchOnInspectorFrontend(const WebString& message)
+{
+ WebFrameImpl* frame = m_webViewImpl->mainFrameImpl();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope;
+ v8::Handle<v8::Context> frameContext = frame->frame() ? frame->frame()->script()->currentWorldContext() : v8::Local<v8::Context>();
+ v8::Context::Scope contextScope(frameContext);
+ v8::Handle<v8::Value> inspectorFrontendApiValue = frameContext->Global()->Get(v8::String::New("InspectorFrontendAPI"));
+ if (!inspectorFrontendApiValue->IsObject())
+ return;
+ v8::Handle<v8::Object> inspectorFrontendApi = v8::Handle<v8::Object>::Cast(inspectorFrontendApiValue);
+ v8::Handle<v8::Value> dispatchFunction = inspectorFrontendApi->Get(v8::String::New("dispatchMessage"));
+ // 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(v8String(message, isolate));
+ v8::TryCatch tryCatch;
+ tryCatch.SetVerbose(true);
+ ScriptController::callFunctionWithInstrumentation(frame->frame() ? frame->frame()->document() : 0, function, inspectorFrontendApi, args.size(), args.data());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.h b/chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.h
new file mode 100644
index 00000000000..31a8742c49e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDevToolsFrontendImpl.h
@@ -0,0 +1,78 @@
+/*
+ * 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 "WebDevToolsFrontend.h"
+#include "core/platform/Timer.h"
+#include "wtf/Deque.h"
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
+
+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);
+
+private:
+ class InspectorFrontendResumeObserver;
+ void resume();
+ void maybeDispatch(WebCore::Timer<WebDevToolsFrontendImpl>*);
+ void doDispatchOnInspectorFrontend(const WebString& message);
+
+ WebKit::WebViewImpl* m_webViewImpl;
+ WebKit::WebDevToolsFrontendClient* m_client;
+ String m_applicationLocale;
+ OwnPtr<InspectorFrontendResumeObserver> m_inspectorFrontendResumeObserver;
+ Deque<WebString> m_messages;
+ WebCore::Timer<WebDevToolsFrontendImpl> m_inspectorFrontendDispatchTimer;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebDeviceOrientation.cpp b/chromium/third_party/WebKit/Source/web/WebDeviceOrientation.cpp
new file mode 100644
index 00000000000..2b850e2ca70
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDeviceOrientation.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 "WebDeviceOrientation.h"
+
+#include "modules/device_orientation/DeviceOrientationData.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebKit {
+
+WebDeviceOrientation::WebDeviceOrientation(const WebCore::DeviceOrientationData* orientation)
+{
+ if (!orientation) {
+ m_isNull = true;
+ m_canProvideAlpha = false;
+ m_alpha = 0;
+ m_canProvideBeta = false;
+ m_beta = 0;
+ m_canProvideGamma = false;
+ m_gamma = 0;
+ m_canProvideAbsolute = false;
+ m_absolute = false;
+ 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();
+ m_canProvideAbsolute = orientation->canProvideAbsolute();
+ m_absolute = orientation->absolute();
+}
+
+WebDeviceOrientation::operator PassRefPtr<WebCore::DeviceOrientationData>() const
+{
+ if (m_isNull)
+ return 0;
+ return WebCore::DeviceOrientationData::create(m_canProvideAlpha, m_alpha, m_canProvideBeta, m_beta, m_canProvideGamma, m_gamma, m_canProvideAbsolute, m_absolute);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp b/chromium/third_party/WebKit/Source/web/WebDeviceOrientationClientMock.cpp
new file mode 100644
index 00000000000..c64f16e6c6c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebDeviceOrientation.h"
+#include "WebDeviceOrientationController.h"
+#include "core/platform/mock/DeviceOrientationClientMock.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/chromium/third_party/WebKit/Source/web/WebDeviceOrientationController.cpp b/chromium/third_party/WebKit/Source/web/WebDeviceOrientationController.cpp
new file mode 100644
index 00000000000..007b0c2886e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebDeviceOrientation.h"
+#include "core/dom/DeviceOrientationController.h"
+#include "modules/device_orientation/DeviceOrientationData.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebKit {
+
+void WebDeviceOrientationController::didChangeDeviceOrientation(const WebDeviceOrientation& orientation)
+{
+ RefPtr<WebCore::DeviceOrientationData> deviceOrientation = PassRefPtr<WebCore::DeviceOrientationData>(orientation);
+ m_controller->didChangeDeviceOrientation(deviceOrientation.get());
+}
+
+WebCore::DeviceOrientationController* WebDeviceOrientationController::controller() const
+{
+ return m_controller;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDocument.cpp b/chromium/third_party/WebKit/Source/web/WebDocument.cpp
new file mode 100644
index 00000000000..41e9224b692
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDocument.cpp
@@ -0,0 +1,295 @@
+/*
+ * 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 "public/platform/WebURL.h"
+#include "wtf/PassRefPtr.h"
+#include "WebAccessibilityObject.h"
+#include "WebDOMEvent.h"
+#include "WebDocumentType.h"
+#include "WebElement.h"
+#include "WebFormElement.h"
+#include "WebFrameImpl.h"
+#include "WebNodeCollection.h"
+#include "WebNodeList.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/accessibility/AXObjectCache.h"
+#include "core/css/CSSParserMode.h"
+#include "core/css/StyleSheetContents.h"
+#include "core/dom/Document.h"
+#include "core/dom/DocumentStyleSheetCollection.h"
+#include "core/dom/DocumentType.h"
+#include "core/dom/Element.h"
+#include "core/dom/FullscreenElementStack.h"
+#include "core/dom/NodeList.h"
+#include "core/html/HTMLAllCollection.h"
+#include "core/html/HTMLBodyElement.h"
+#include "core/html/HTMLCollection.h"
+#include "core/html/HTMLElement.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLHeadElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/rendering/RenderObject.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebURL WebDocument::url() const
+{
+ return constUnwrap<Document>()->url();
+}
+
+WebSecurityOrigin WebDocument::securityOrigin() const
+{
+ if (!constUnwrap<Document>())
+ return WebSecurityOrigin();
+ return WebSecurityOrigin(constUnwrap<Document>()->securityOrigin());
+}
+
+WebString WebDocument::encoding() const
+{
+ return constUnwrap<Document>()->encoding();
+}
+
+WebString WebDocument::contentLanguage() const
+{
+ return constUnwrap<Document>()->contentLanguage();
+}
+
+WebURL WebDocument::openSearchDescriptionURL() const
+{
+ return const_cast<Document*>(constUnwrap<Document>())->openSearchDescriptionURL();
+}
+
+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());
+}
+
+void WebDocument::images(WebVector<WebElement>& results)
+{
+ RefPtr<HTMLCollection> images = unwrap<Document>()->images();
+ size_t sourceLength = images->length();
+ Vector<WebElement> temp;
+ temp.reserveCapacity(sourceLength);
+ for (size_t i = 0; i < sourceLength; ++i) {
+ Node* node = images->item(i);
+ if (node && node->isHTMLElement())
+ temp.append(WebElement(toElement(node)));
+ }
+ results.assign(temp);
+}
+
+void WebDocument::forms(WebVector<WebFormElement>& results) const
+{
+ RefPtr<HTMLCollection> forms = const_cast<Document*>(constUnwrap<Document>())->forms();
+ size_t sourceLength = forms->length();
+ Vector<WebFormElement> temp;
+ temp.reserveCapacity(sourceLength);
+ for (size_t i = 0; i < sourceLength; ++i) {
+ Node* node = forms->item(i);
+ // Strange but true, sometimes node can be 0.
+ if (node && node->isHTMLElement())
+ temp.append(WebFormElement(toHTMLFormElement(node)));
+ }
+ results.assign(temp);
+}
+
+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>()->focusedElement());
+}
+
+WebDocumentType WebDocument::doctype() const
+{
+ return WebDocumentType(constUnwrap<Document>()->doctype());
+}
+
+void WebDocument::insertUserStyleSheet(const WebString& sourceCode, UserStyleLevel styleLevel)
+{
+ RefPtr<Document> document = unwrap<Document>();
+
+ RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(document.get());
+ parsedSheet->setIsUserStyleSheet(styleLevel == UserStyleUserLevel);
+ parsedSheet->parseString(sourceCode);
+ if (parsedSheet->isUserStyleSheet())
+ document->styleSheetCollection()->addUserSheet(parsedSheet);
+ else
+ document->styleSheetCollection()->addAuthorSheet(parsedSheet);
+}
+
+void WebDocument::cancelFullScreen()
+{
+ if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(unwrap<Document>()))
+ fullscreen->webkitCancelFullScreen();
+}
+
+WebElement WebDocument::fullScreenElement() const
+{
+ Element* fullScreenElement = 0;
+ if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(const_cast<WebDocument*>(this)->unwrap<Document>()))
+ fullScreenElement = fullscreen->webkitCurrentFullScreenElement();
+ return WebElement(fullScreenElement);
+}
+
+WebDOMEvent WebDocument::createEvent(const WebString& eventType)
+{
+ TrackExceptionState es;
+ WebDOMEvent event(unwrap<Document>()->createEvent(eventType, es));
+ if (es.hadException())
+ return WebDOMEvent();
+ return event;
+}
+
+WebReferrerPolicy WebDocument::referrerPolicy() const
+{
+ return static_cast<WebReferrerPolicy>(constUnwrap<Document>()->referrerPolicy());
+}
+
+WebElement WebDocument::createElement(const WebString& tagName)
+{
+ TrackExceptionState es;
+ WebElement element(unwrap<Document>()->createElement(tagName, es));
+ if (es.hadException())
+ return WebElement();
+ return element;
+}
+
+WebAccessibilityObject WebDocument::accessibilityObject() const
+{
+ const Document* document = constUnwrap<Document>();
+ return WebAccessibilityObject(
+ document->axObjectCache()->getOrCreate(document->renderer()));
+}
+
+WebAccessibilityObject WebDocument::accessibilityObjectFromID(int axID) const
+{
+ const Document* document = constUnwrap<Document>();
+ return WebAccessibilityObject(
+ document->axObjectCache()->objectFromAXID(axID));
+}
+
+WebVector<WebDraggableRegion> WebDocument::draggableRegions() const
+{
+ WebVector<WebDraggableRegion> draggableRegions;
+ const Document* document = constUnwrap<Document>();
+ if (document->hasAnnotatedRegions()) {
+ const Vector<AnnotatedRegionValue>& regions = document->annotatedRegions();
+ draggableRegions = WebVector<WebDraggableRegion>(regions.size());
+ for (size_t i = 0; i < regions.size(); i++) {
+ const AnnotatedRegionValue& value = regions[i];
+ draggableRegions[i].draggable = value.draggable;
+ draggableRegions[i].bounds = WebCore::IntRect(value.bounds);
+ }
+ }
+ return draggableRegions;
+}
+
+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 toDocument(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebDocumentType.cpp b/chromium/third_party/WebKit/Source/web/WebDocumentType.cpp
new file mode 100644
index 00000000000..42d2c6acb4a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDocumentType.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebDocumentType.h"
+
+#include "core/dom/DocumentType.h"
+#include "public/platform/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/chromium/third_party/WebKit/Source/web/WebDragData.cpp b/chromium/third_party/WebKit/Source/web/WebDragData.cpp
new file mode 100644
index 00000000000..4b3f77051bd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebDragData.cpp
@@ -0,0 +1,178 @@
+/*
+ * 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 "core/dom/DataTransferItem.h"
+#include "core/platform/chromium/ChromiumDataObject.h"
+#include "core/platform/chromium/ClipboardMimeTypes.h"
+#include "modules/filesystem/DraggedIsolatedFileSystem.h"
+#include "public/platform/WebData.h"
+#include "public/platform/WebDragData.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebVector.h"
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebDragDataPrivate : public ChromiumDataObject {
+};
+
+void WebDragData::initialize()
+{
+ assign(static_cast<WebDragDataPrivate*>(ChromiumDataObject::create().leakRef()));
+}
+
+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);
+}
+
+WebVector<WebDragData::Item> WebDragData::items() const
+{
+ Vector<Item> itemList;
+ for (size_t i = 0; i < m_private->length(); ++i) {
+ ChromiumDataObjectItem* originalItem = m_private->item(i).get();
+ WebDragData::Item item;
+ if (originalItem->kind() == DataTransferItem::kindString) {
+ item.storageType = Item::StorageTypeString;
+ item.stringType = originalItem->type();
+ item.stringData = originalItem->internalGetAsString();
+ } else if (originalItem->kind() == DataTransferItem::kindFile) {
+ if (originalItem->sharedBuffer()) {
+ item.storageType = Item::StorageTypeBinaryData;
+ item.binaryData = originalItem->sharedBuffer();
+ } else if (originalItem->isFilename()) {
+ item.storageType = Item::StorageTypeFilename;
+ RefPtr<WebCore::Blob> blob = originalItem->getAsFile();
+ if (blob->isFile()) {
+ File* file = toFile(blob.get());
+ item.filenameData = file->path();
+ item.displayNameData = file->name();
+ } else
+ ASSERT_NOT_REACHED();
+ } else
+ ASSERT_NOT_REACHED();
+ } else
+ ASSERT_NOT_REACHED();
+ item.title = originalItem->title();
+ item.baseURL = originalItem->baseURL();
+ itemList.append(item);
+ }
+ return itemList;
+}
+
+void WebDragData::setItems(const WebVector<Item>& itemList)
+{
+ m_private->clearAll();
+ for (size_t i = 0; i < itemList.size(); ++i)
+ addItem(itemList[i]);
+}
+
+void WebDragData::addItem(const Item& item)
+{
+ ensureMutable();
+ switch (item.storageType) {
+ case Item::StorageTypeString:
+ if (String(item.stringType) == mimeTypeTextURIList)
+ m_private->setURLAndTitle(item.stringData, item.title);
+ else if (String(item.stringType) == mimeTypeTextHTML)
+ m_private->setHTMLAndBaseURL(item.stringData, item.baseURL);
+ else
+ m_private->setData(item.stringType, item.stringData);
+ return;
+ case Item::StorageTypeFilename:
+ m_private->addFilename(item.filenameData, item.displayNameData);
+ return;
+ case Item::StorageTypeBinaryData:
+ // This should never happen when dragging in.
+ ASSERT_NOT_REACHED();
+ }
+}
+
+WebString WebDragData::filesystemId() const
+{
+ ASSERT(!isNull());
+ DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_private);
+ if (filesystem)
+ return filesystem->filesystemId();
+ return WebString();
+}
+
+void WebDragData::setFilesystemId(const WebString& filesystemId)
+{
+ // The ID is an opaque string, given by and validated by chromium port.
+ ensureMutable();
+ DraggedIsolatedFileSystem::provideTo(m_private, DraggedIsolatedFileSystem::supplementName(), DraggedIsolatedFileSystem::create(filesystemId));
+}
+
+WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data)
+ : m_private(static_cast<WebDragDataPrivate*>(data.leakRef()))
+{
+}
+
+WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data)
+{
+ assign(static_cast<WebDragDataPrivate*>(data.leakRef()));
+ 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/chromium/third_party/WebKit/Source/web/WebElement.cpp b/chromium/third_party/WebKit/Source/web/WebElement.cpp
new file mode 100644
index 00000000000..7045bcc2156
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebElement.cpp
@@ -0,0 +1,195 @@
+/*
+ * 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 "WebElement.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/dom/CustomElementCallbackDispatcher.h"
+#include "core/dom/Element.h"
+#include "core/dom/NamedNodeMap.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/rendering/RenderBoxModelObject.h"
+#include "core/rendering/RenderObject.h"
+#include "public/platform/WebRect.h"
+#include "wtf/PassRefPtr.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::hasHTMLTagName(const WebString& tagName) const
+{
+ // How to create class nodeName localName
+ // createElement('input') HTMLInputElement INPUT input
+ // createElement('INPUT') HTMLInputElement INPUT input
+ // createElementNS(xhtmlNS, 'input') HTMLInputElement INPUT input
+ // createElementNS(xhtmlNS, 'INPUT') HTMLUnknownElement INPUT INPUT
+ const Element* element = constUnwrap<Element>();
+ return HTMLNames::xhtmlNamespaceURI == element->namespaceURI() && element->localName() == String(tagName).lower();
+}
+
+bool WebElement::hasAttribute(const WebString& attrName) const
+{
+ return constUnwrap<Element>()->hasAttribute(attrName);
+}
+
+void WebElement::removeAttribute(const WebString& attrName)
+{
+ // TODO: Custom element callbacks need to be called on WebKit API methods that
+ // mutate the DOM in any way.
+ CustomElementCallbackDispatcher::CallbackDeliveryScope deliverCustomElementCallbacks;
+ unwrap<Element>()->removeAttribute(attrName);
+}
+
+WebString WebElement::getAttribute(const WebString& attrName) const
+{
+ return constUnwrap<Element>()->getAttribute(attrName);
+}
+
+bool WebElement::setAttribute(const WebString& attrName, const WebString& attrValue)
+{
+ // TODO: Custom element callbacks need to be called on WebKit API methods that
+ // mutate the DOM in any way.
+ CustomElementCallbackDispatcher::CallbackDeliveryScope deliverCustomElementCallbacks;
+ TrackExceptionState es;
+ unwrap<Element>()->setAttribute(attrName, attrValue, es);
+ return !es.hadException();
+}
+
+unsigned WebElement::attributeCount() const
+{
+ if (!constUnwrap<Element>()->hasAttributes())
+ return 0;
+ return constUnwrap<Element>()->attributeCount();
+}
+
+WebNode WebElement::shadowRoot() const
+{
+ ShadowRoot* shadowRoot = constUnwrap<Element>()->shadowRoot();
+ if (!shadowRoot)
+ return WebNode();
+ return WebNode(shadowRoot->toNode());
+}
+
+WebString WebElement::attributeLocalName(unsigned index) const
+{
+ if (index >= attributeCount())
+ return WebString();
+ return constUnwrap<Element>()->attributeItem(index)->localName();
+}
+
+WebString WebElement::attributeValue(unsigned index) const
+{
+ if (index >= attributeCount())
+ return WebString();
+ return constUnwrap<Element>()->attributeItem(index)->value();
+}
+
+WebString WebElement::innerText()
+{
+ return unwrap<Element>()->innerText();
+}
+
+WebString WebElement::computeInheritedLanguage() const
+{
+ return WebString(constUnwrap<Element>()->computeInheritedLanguage());
+}
+
+void WebElement::requestFullScreen()
+{
+ unwrap<Element>()->webkitRequestFullScreen(Element::ALLOW_KEYBOARD_INPUT);
+}
+
+WebDocument WebElement::document() const
+{
+ return WebDocument(constUnwrap<Element>()->document());
+}
+
+WebRect WebElement::boundsInViewportSpace()
+{
+ return unwrap<Element>()->boundsInRootViewSpace();
+}
+
+WebImage WebElement::imageContents()
+{
+ if (isNull())
+ return WebImage();
+
+ WebCore::Image* image = unwrap<Element>()->imageContents();
+ if (!image)
+ return WebImage();
+
+ RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
+ if (!bitmap)
+ return WebImage();
+
+ return bitmap->bitmap();
+}
+
+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 toElement(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebEntities.cpp b/chromium/third_party/WebKit/Source/web/WebEntities.cpp
new file mode 100644
index 00000000000..e3d1186e9a0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebEntities.cpp
@@ -0,0 +1,87 @@
+/*
+ * 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 "public/platform/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
+{
+ // FIXME: We should use find so we only do one hash lookup.
+ if (m_entitiesMap.contains(code))
+ return m_entitiesMap.get(code);
+ return "";
+}
+
+String WebEntities::convertEntitiesInString(const String& value) const
+{
+ StringBuilder result;
+ bool didConvertEntity = false;
+ unsigned length = value.length();
+ for (unsigned i = 0; i < length; ++i) {
+ UChar c = value[i];
+ // FIXME: We should use find so we only do one hash lookup.
+ if (m_entitiesMap.contains(c)) {
+ didConvertEntity = true;
+ result.append('&');
+ result.append(m_entitiesMap.get(c));
+ result.append(';');
+ } else {
+ result.append(c);
+ }
+ }
+
+ if (!didConvertEntity)
+ return value;
+
+ return result.toString();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebEntities.h b/chromium/third_party/WebKit/Source/web/WebEntities.h
new file mode 100644
index 00000000000..1194b78769a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "wtf/HashMap.h"
+#include "wtf/text/WTFString.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/chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.cpp b/chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.cpp
new file mode 100644
index 00000000000..73452d0d048
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.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 "WebFileChooserCompletionImpl.h"
+
+namespace WebKit {
+
+WebFileChooserCompletionImpl::WebFileChooserCompletionImpl(PassRefPtr<WebCore::FileChooser> chooser)
+ : m_fileChooser(chooser)
+{
+}
+
+WebFileChooserCompletionImpl::~WebFileChooserCompletionImpl()
+{
+}
+
+void WebFileChooserCompletionImpl::didChooseFile(const WebVector<WebString>& fileNames)
+{
+ Vector<WebCore::FileChooserFileInfo> fileInfo;
+ for (size_t i = 0; i < fileNames.size(); ++i)
+ fileInfo.append(WebCore::FileChooserFileInfo(fileNames[i]));
+ m_fileChooser->chooseFiles(fileInfo);
+ // This object is no longer needed.
+ delete this;
+}
+
+void WebFileChooserCompletionImpl::didChooseFile(const WebVector<SelectedFileInfo>& files)
+{
+ Vector<WebCore::FileChooserFileInfo> fileInfo;
+ for (size_t i = 0; i < files.size(); ++i)
+ fileInfo.append(WebCore::FileChooserFileInfo(files[i].path, files[i].displayName));
+ m_fileChooser->chooseFiles(fileInfo);
+ // This object is no longer needed.
+ delete this;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.h b/chromium/third_party/WebKit/Source/web/WebFileChooserCompletionImpl.h
new file mode 100644
index 00000000000..a464f0b3a75
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/platform/FileChooser.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.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);
+ virtual void didChooseFile(const WebVector<SelectedFileInfo>& files);
+private:
+ RefPtr<WebCore::FileChooser> m_fileChooser;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.cpp b/chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.cpp
new file mode 100644
index 00000000000..a882f926a9a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.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 "WebFileSystemCallbacksImpl.h"
+
+#include "AsyncFileSystemChromium.h"
+#include "AsyncFileWriterChromium.h"
+#include "core/platform/AsyncFileSystemCallbacks.h"
+#include "core/platform/FileMetadata.h"
+#include "public/platform/WebFileInfo.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemEntry.h"
+#include "public/platform/WebString.h"
+#include "public/web/WebFileWriter.h"
+#include "wtf/Vector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+ ASSERT(m_callbacks);
+}
+
+WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, PassOwnPtr<AsyncFileWriterChromium> writer)
+ : m_callbacks(callbacks)
+ , m_writer(writer)
+{
+ 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);
+ fileMetadata.platformPath = webFileInfo.platformPath;
+ m_callbacks->didReadMetadata(fileMetadata);
+ delete this;
+}
+
+void WebFileSystemCallbacksImpl::didCreateSnapshotFile(const WebFileInfo& webFileInfo)
+{
+ // It's important to create a BlobDataHandle that refers to the platform file path prior
+ // to return from this method so the underlying file will not be deleted.
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->appendFile(webFileInfo.platformPath);
+ RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(blobData.release(), webFileInfo.length);
+ didCreateSnapshotFile(webFileInfo, snapshotBlob);
+}
+
+void WebFileSystemCallbacksImpl::didCreateSnapshotFile(const WebFileInfo& webFileInfo, PassRefPtr<WebCore::BlobDataHandle> snapshot)
+{
+ FileMetadata fileMetadata;
+ fileMetadata.modificationTime = webFileInfo.modificationTime;
+ fileMetadata.length = webFileInfo.length;
+ fileMetadata.type = static_cast<FileMetadata::Type>(webFileInfo.type);
+ fileMetadata.platformPath = webFileInfo.platformPath;
+ m_callbacks->didCreateSnapshotFile(fileMetadata, snapshot);
+ 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 WebURL& rootURL)
+{
+ // This object is intended to delete itself on exit.
+ OwnPtr<WebFileSystemCallbacksImpl> callbacks = adoptPtr(this);
+ m_callbacks->didOpenFileSystem(name, rootURL, AsyncFileSystemChromium::create());
+}
+
+void WebFileSystemCallbacksImpl::didCreateFileWriter(WebFileWriter* webFileWriter, long long length)
+{
+ // This object is intended to delete itself on exit.
+ OwnPtr<WebFileSystemCallbacksImpl> callbacks = adoptPtr(this);
+
+ m_writer->setWebFileWriter(adoptPtr(webFileWriter));
+ m_callbacks->didCreateFileWriter(m_writer.release(), length);
+}
+
+void WebFileSystemCallbacksImpl::didFail(WebFileError error)
+{
+ m_callbacks->didFail(error);
+ delete this;
+}
+
+bool WebFileSystemCallbacksImpl::shouldBlockUntilCompletion() const
+{
+ return m_callbacks->shouldBlockUntilCompletion();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.h b/chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.h
new file mode 100644
index 00000000000..1522f94af85
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFileSystemCallbacksImpl.h
@@ -0,0 +1,83 @@
+/*
+ * 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 "modules/filesystem/FileSystemType.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemCallbacks.h"
+#include "public/platform/WebVector.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebCore {
+class AsyncFileSystemCallbacks;
+class AsyncFileWriterChromium;
+class BlobDataHandle;
+}
+
+namespace WebKit {
+
+struct WebFileInfo;
+struct WebFileSystemEntry;
+class WebString;
+class WebURL;
+
+class WebFileSystemCallbacksImpl : public WebFileSystemCallbacks {
+public:
+ WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>);
+ WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, PassOwnPtr<WebCore::AsyncFileWriterChromium>);
+ virtual ~WebFileSystemCallbacksImpl();
+
+ virtual void didSucceed();
+ virtual void didReadMetadata(const WebFileInfo&);
+ virtual void didCreateSnapshotFile(const WebFileInfo&);
+ virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore);
+ virtual void didOpenFileSystem(const WebString& name, const WebURL& rootURL);
+ virtual void didCreateFileWriter(WebFileWriter*, long long length);
+ virtual void didFail(WebFileError error);
+ virtual bool shouldBlockUntilCompletion() const;
+
+ // This internal overload is used by WorkerFileSystemCallbacksBridge to deliver a blob data handle
+ // created on the main thread to an AsyncFileSystemCallback on a background worker thread. The other
+ // virtual method is invoked by the embedder.
+ void didCreateSnapshotFile(const WebFileInfo&, PassRefPtr<WebCore::BlobDataHandle> snapshot);
+
+private:
+ OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
+
+ // Used for createFileWriter callbacks.
+ OwnPtr<WebCore::AsyncFileWriterChromium> m_writer;
+};
+
+} // namespace WebKit
+
+#endif // WebFileSystemCallbacksImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebFontCache.cpp b/chromium/third_party/WebKit/Source/web/WebFontCache.cpp
new file mode 100644
index 00000000000..6cab3be1325
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFontCache.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebFontCache.h"
+
+#include "core/platform/graphics/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();
+}
+
+// static
+void WebFontCache::prune()
+{
+ fontCache()->purgeInactiveFontData();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFontDescription.cpp b/chromium/third_party/WebKit/Source/web/WebFontDescription.cpp
new file mode 100644
index 00000000000..09c6d210a67
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/platform/graphics/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/chromium/third_party/WebKit/Source/web/WebFontImpl.cpp b/chromium/third_party/WebKit/Source/web/WebFontImpl.cpp
new file mode 100644
index 00000000000..cc04c69c5f3
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFontImpl.cpp
@@ -0,0 +1,130 @@
+/*
+ * 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 <skia/ext/platform_canvas.h>
+#include "WebFontDescription.h"
+#include "WebTextRun.h"
+#include "core/platform/graphics/Font.h"
+#include "core/platform/graphics/FontCache.h"
+#include "core/platform/graphics/FontDescription.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/TextRun.h"
+#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebFloatRect.h"
+#include "public/platform/WebRect.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, float letterSpacing, float 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.fontMetrics().ascent();
+}
+
+int WebFontImpl::descent() const
+{
+ return m_font.fontMetrics().descent();
+}
+
+int WebFontImpl::height() const
+{
+ return m_font.fontMetrics().height();
+}
+
+int WebFontImpl::lineSpacing() const
+{
+ return m_font.fontMetrics().lineSpacing();
+}
+
+float WebFontImpl::xHeight() const
+{
+ return m_font.fontMetrics().xHeight();
+}
+
+void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
+ WebColor color, const WebRect& clip, bool canvasIsOpaque,
+ int from, int to) const
+{
+ FontCachePurgePreventer fontCachePurgePreventer;
+ WebCore::FloatRect textClipRect(clip);
+ TextRun textRun(run);
+ TextRunPaintInfo runInfo(textRun);
+ runInfo.from = from;
+ runInfo.to = to == -1 ? textRun.length() : to;
+ runInfo.bounds = textClipRect;
+ GraphicsContext gc(canvas);
+
+ gc.save();
+ gc.setCertainlyOpaque(canvasIsOpaque);
+ gc.setFillColor(color);
+ gc.clip(textClipRect);
+ m_font.drawText(&gc, runInfo, leftBaseline);
+ gc.restore();
+}
+
+int WebFontImpl::calculateWidth(const WebTextRun& run) const
+{
+ FontCachePurgePreventer fontCachePurgePreventer;
+ return m_font.width(run, 0);
+}
+
+int WebFontImpl::offsetForPosition(const WebTextRun& run, float position) const
+{
+ FontCachePurgePreventer fontCachePurgePreventer;
+ return m_font.offsetForPosition(run, position, true);
+}
+
+WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebFloatPoint& leftBaseline, int height, int from, int to) const
+{
+ FontCachePurgePreventer fontCachePurgePreventer;
+ return m_font.selectionRectForText(run, leftBaseline, height, from, to);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFontImpl.h b/chromium/third_party/WebKit/Source/web/WebFontImpl.h
new file mode 100644
index 00000000000..9142c2d15ea
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebFont.h"
+#include "core/platform/graphics/Font.h"
+
+namespace WebCore { class FontDescription; }
+
+namespace WebKit {
+
+class WebFontImpl : public WebFont {
+public:
+ WebFontImpl(const WebCore::FontDescription&, float letterSpacing, float 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/chromium/third_party/WebKit/Source/web/WebFormControlElement.cpp b/chromium/third_party/WebKit/Source/web/WebFormControlElement.cpp
new file mode 100644
index 00000000000..bbaa6479749
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFormControlElement.cpp
@@ -0,0 +1,101 @@
+/*
+ * 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 "core/html/HTMLFormControlElement.h"
+#include "core/html/HTMLFormElement.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebFormControlElement::isEnabled() const
+{
+ return !constUnwrap<HTMLFormControlElement>()->isDisabledFormControl();
+}
+
+bool WebFormControlElement::isReadOnly() const
+{
+ return constUnwrap<HTMLFormControlElement>()->isReadOnly();
+}
+
+WebString WebFormControlElement::formControlName() const
+{
+ return constUnwrap<HTMLFormControlElement>()->name();
+}
+
+WebString WebFormControlElement::formControlType() const
+{
+ return constUnwrap<HTMLFormControlElement>()->type();
+}
+
+void WebFormControlElement::dispatchFormControlChangeEvent()
+{
+ unwrap<HTMLFormControlElement>()->dispatchFormControlChangeEvent();
+}
+
+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();
+}
+
+WebFormElement WebFormControlElement::form() const
+{
+ return WebFormElement(constUnwrap<HTMLFormControlElement>()->form());
+}
+
+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 toHTMLFormControlElement(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFormElement.cpp b/chromium/third_party/WebKit/Source/web/WebFormElement.cpp
new file mode 100644
index 00000000000..c0ce7a2899e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFormElement.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 "WebFormElement.h"
+
+#include "HTMLNames.h"
+#include "WebFormControlElement.h"
+#include "WebInputElement.h"
+#include "core/html/HTMLFormControlElement.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/loader/FormState.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebFormElement::autoComplete() const
+{
+ return constUnwrap<HTMLFormElement>()->shouldAutocomplete();
+}
+
+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 = toHTMLFormControlElement(form->associatedElements()[i]);
+ if (element->hasLocalName(HTMLNames::inputTag)
+ || element->hasLocalName(HTMLNames::selectTag))
+ tempVector.append(element);
+ }
+ result.assign(tempVector);
+}
+
+bool WebFormElement::checkValidityWithoutDispatchingEvents()
+{
+ return unwrap<HTMLFormElement>()->checkValidityWithoutDispatchingEvents();
+}
+
+void WebFormElement::finishRequestAutocomplete(WebFormElement::AutocompleteResult result)
+{
+ unwrap<HTMLFormElement>()->finishRequestAutocomplete(static_cast<HTMLFormElement::AutocompleteResult>(result));
+}
+
+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 toHTMLFormElement(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFrameImpl.cpp b/chromium/third_party/WebKit/Source/web/WebFrameImpl.cpp
new file mode 100644
index 00000000000..baf06cd1d7a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFrameImpl.cpp
@@ -0,0 +1,2495 @@
+/*
+ * 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 "AsyncFileSystemChromium.h"
+#include "DOMUtilitiesPrivate.h"
+#include "EventListenerWrapper.h"
+#include "FindInPageCoordinates.h"
+#include "HTMLNames.h"
+#include "PageOverlay.h"
+#include "V8DOMFileSystem.h"
+#include "V8DirectoryEntry.h"
+#include "V8FileEntry.h"
+#include "WebConsoleMessage.h"
+#include "WebDOMEvent.h"
+#include "WebDOMEventListener.h"
+#include "WebDataSourceImpl.h"
+#include "WebDevToolsAgentPrivate.h"
+#include "WebDocument.h"
+#include "WebFindOptions.h"
+#include "WebFormElement.h"
+#include "WebFrameClient.h"
+#include "WebHistoryItem.h"
+#include "WebIconURL.h"
+#include "WebInputElement.h"
+#include "WebNode.h"
+#include "WebPerformance.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPrintParams.h"
+#include "WebRange.h"
+#include "WebScriptSource.h"
+#include "WebSecurityOrigin.h"
+#include "WebSerializedScriptValue.h"
+#include "WebViewImpl.h"
+#include "bindings/v8/DOMWrapperWorld.h"
+#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "bindings/v8/ScriptController.h"
+#include "bindings/v8/ScriptSourceCode.h"
+#include "bindings/v8/ScriptValue.h"
+#include "bindings/v8/V8GCController.h"
+#include "core/dom/Document.h"
+#include "core/dom/DocumentMarker.h"
+#include "core/dom/DocumentMarkerController.h"
+#include "core/dom/IconURL.h"
+#include "core/dom/MessagePort.h"
+#include "core/dom/Node.h"
+#include "core/dom/NodeTraversal.h"
+#include "core/dom/UserGestureIndicator.h"
+#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/editing/Editor.h"
+#include "core/editing/FrameSelection.h"
+#include "core/editing/InputMethodController.h"
+#include "core/editing/SpellChecker.h"
+#include "core/editing/TextAffinity.h"
+#include "core/editing/TextIterator.h"
+#include "core/editing/htmlediting.h"
+#include "core/editing/markup.h"
+#include "core/history/BackForwardController.h"
+#include "core/history/HistoryItem.h"
+#include "core/html/HTMLCollection.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLFrameOwnerElement.h"
+#include "core/html/HTMLHeadElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLLinkElement.h"
+#include "core/html/HTMLTextAreaElement.h"
+#include "core/html/PluginDocument.h"
+#include "core/inspector/InspectorController.h"
+#include "core/inspector/ScriptCallStack.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FormState.h"
+#include "core/loader/FrameLoadRequest.h"
+#include "core/loader/FrameLoader.h"
+#include "core/loader/IconController.h"
+#include "core/loader/SubstituteData.h"
+#include "core/page/Chrome.h"
+#include "core/page/Console.h"
+#include "core/page/DOMWindow.h"
+#include "core/page/EventHandler.h"
+#include "core/page/FocusController.h"
+#include "core/page/FrameTree.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/Performance.h"
+#include "core/page/PrintContext.h"
+#include "core/page/Settings.h"
+#include "core/platform/AsyncFileSystem.h"
+#include "core/platform/ScrollTypes.h"
+#include "core/platform/ScrollbarTheme.h"
+#include "core/platform/chromium/ClipboardUtilitiesChromium.h"
+#include "core/platform/chromium/TraceEvent.h"
+#include "core/platform/graphics/FontCache.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/GraphicsLayerClient.h"
+#include "core/platform/graphics/skia/SkiaUtils.h"
+#include "core/platform/network/ResourceRequest.h"
+#include "core/rendering/HitTestResult.h"
+#include "core/rendering/RenderBox.h"
+#include "core/rendering/RenderFrame.h"
+#include "core/rendering/RenderLayer.h"
+#include "core/rendering/RenderObject.h"
+#include "core/rendering/RenderTreeAsText.h"
+#include "core/rendering/RenderView.h"
+#include "core/rendering/style/StyleInheritedData.h"
+#include "core/xml/DocumentXPathEvaluator.h"
+#include "core/xml/XPathResult.h"
+#include "modules/filesystem/DOMFileSystem.h"
+#include "modules/filesystem/DirectoryEntry.h"
+#include "modules/filesystem/FileEntry.h"
+#include "modules/filesystem/FileSystemType.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemType.h"
+#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebFloatRect.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebSize.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebVector.h"
+#include "weborigin/KURL.h"
+#include "weborigin/SchemeRegistry.h"
+#include "weborigin/SecurityPolicy.h"
+#include "wtf/CurrentTime.h"
+#include "wtf/HashMap.h"
+#include <algorithm>
+
+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 void frameContentAsPlainText(size_t maxChars, Frame* frame, StringBuilder& output)
+{
+ Document* document = frame->document();
+ if (!document)
+ 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(document->createRange());
+ TrackExceptionState es;
+ range->selectNodeContents(document->body(), es);
+
+ if (!es.hadException()) {
+ // The text iterator will walk nodes giving us text. This is similar to
+ // the plainText() function in core/editing/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()) {
+ it.appendTextToStringBuilder(output, 0, maxChars - output.length());
+ if (output.length() >= maxChars)
+ return; // Filled up the buffer.
+ }
+ }
+
+ // The separator between frames when the frames are converted to plain text.
+ const LChar frameSeparator[] = { '\n', '\n' };
+ const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator);
+
+ // 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.length() >= maxChars - frameSeparatorLength)
+ return;
+
+ output.append(frameSeparator, frameSeparatorLength);
+ frameContentAsPlainText(maxChars, curChild, output);
+ if (output.length() >= 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());
+}
+
+WebPluginContainerImpl* WebFrameImpl::pluginContainerFromNode(WebCore::Frame* frame, const WebNode& node)
+{
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame);
+ if (pluginContainer)
+ return pluginContainer;
+ return static_cast<WebPluginContainerImpl*>(node.pluginContainer());
+}
+
+// Simple class to override some of PrintContext behavior. Some of the methods
+// made virtual so that they can be overridden by ChromePluginPrintContext.
+class ChromePrintContext : public PrintContext {
+ WTF_MAKE_NONCOPYABLE(ChromePrintContext);
+public:
+ ChromePrintContext(Frame* frame)
+ : PrintContext(frame)
+ , m_printedPageWidth(0)
+ {
+ }
+
+ virtual ~ChromePrintContext() { }
+
+ 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 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& context, int pageNumber)
+ {
+ IntRect pageRect = m_pageRects[pageNumber];
+ float scale = m_printedPageWidth / pageRect.width();
+
+ context.save();
+#if OS(UNIX) && !OS(DARWIN)
+ context.scale(WebCore::FloatSize(scale, scale));
+#endif
+ context.translate(static_cast<float>(-pageRect.x()), static_cast<float>(-pageRect.y()));
+ context.clip(pageRect);
+ frame()->view()->paintContents(&context, pageRect);
+ if (context.supportsURLFragments())
+ outputLinkedDestinations(context, frame()->document(), pageRect);
+ context.restore();
+ return scale;
+ }
+
+ void spoolAllPagesWithBoundaries(GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
+ {
+ if (!frame()->document() || !frame()->view() || !frame()->document()->renderer())
+ return;
+
+ frame()->document()->updateLayout();
+
+ float pageHeight;
+ computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
+
+ const float pageWidth = pageSizeInPixels.width();
+ size_t numPages = pageRects().size();
+ int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1;
+
+ // Fill the whole background by white.
+ graphicsContext.setFillColor(Color::white);
+ graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
+
+ graphicsContext.save();
+
+ int currentHeight = 0;
+ for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) {
+ // Draw a line for a page boundary if this isn't the first page.
+ if (pageIndex > 0) {
+ graphicsContext.save();
+ graphicsContext.setStrokeColor(Color(0, 0, 255));
+ graphicsContext.setFillColor(Color(0, 0, 255));
+ graphicsContext.drawLine(IntPoint(0, currentHeight), IntPoint(pageWidth, currentHeight));
+ graphicsContext.restore();
+ }
+
+ graphicsContext.save();
+
+ graphicsContext.translate(0, currentHeight);
+#if !OS(UNIX) || OS(DARWIN)
+ // Account for the disabling of scaling in spoolPage. In the context
+ // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied.
+ float scale = getPageShrink(pageIndex);
+ graphicsContext.scale(WebCore::FloatSize(scale, scale));
+#endif
+ spoolPage(graphicsContext, pageIndex);
+ graphicsContext.restore();
+
+ currentHeight += pageSizeInPixels.height() + 1;
+ }
+
+ graphicsContext.restore();
+ }
+
+ virtual void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
+ {
+ 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, const WebPrintParams& printParams)
+ : ChromePrintContext(frame), m_plugin(plugin), m_pageCount(0), m_printParams(printParams)
+ {
+ }
+
+ virtual ~ChromePluginPrintContext() { }
+
+ virtual void begin(float width, float height)
+ {
+ }
+
+ 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_printParams.printContentArea = IntRect(printRect);
+ m_pageCount = m_plugin->printBegin(m_printParams);
+ }
+
+ virtual int pageCount() const
+ {
+ return m_pageCount;
+ }
+
+ // Spools the printed page, a subrect of 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& context, int pageNumber)
+ {
+ m_plugin->printPage(pageNumber, &context);
+ return 1.0;
+ }
+
+ virtual bool shouldUseBrowserOverlays() const
+ {
+ return false;
+ }
+
+private:
+ // Set when printing.
+ WebPluginContainerImpl* m_plugin;
+ int m_pageCount;
+ WebPrintParams m_printParams;
+
+};
+
+static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader)
+{
+ return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0;
+}
+
+WebFrameImpl::FindMatch::FindMatch(PassRefPtr<Range> range, int ordinal)
+ : m_range(range)
+ , m_ordinal(ordinal)
+{
+}
+
+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::frameForCurrentContext()
+{
+ v8::Handle<v8::Context> context = v8::Context::GetCurrent();
+ if (context.IsEmpty())
+ return 0;
+ return frameForContext(context);
+}
+
+WebFrame* WebFrame::frameForContext(v8::Handle<v8::Context> context)
+{
+ return WebFrameImpl::fromFrame(toFrameIfNotDetached(context));
+}
+
+WebFrame* WebFrame::fromFrameOwnerElement(const WebElement& element)
+{
+ return WebFrameImpl::fromFrameOwnerElement(PassRefPtr<Element>(element).get());
+}
+
+WebString WebFrameImpl::uniqueName() const
+{
+ return frame()->tree()->uniqueName();
+}
+
+WebString WebFrameImpl::assignedName() const
+{
+ return frame()->tree()->name();
+}
+
+void WebFrameImpl::setName(const WebString& name)
+{
+ frame()->tree()->setName(name);
+}
+
+long long WebFrameImpl::identifier() const
+{
+ return m_identifier;
+}
+
+WebVector<WebIconURL> WebFrameImpl::iconURLs(int iconTypesMask) const
+{
+ // The URL to the icon may be in the header. As such, only
+ // ask the loader for the icon if it's finished loading.
+ if (frame()->loader()->state() == FrameStateComplete)
+ return frame()->loader()->icon()->urlsForTypes(iconTypesMask);
+ return WebVector<WebIconURL>();
+}
+
+WebSize WebFrameImpl::scrollOffset() const
+{
+ FrameView* view = frameView();
+ if (!view)
+ return WebSize();
+ return view->scrollOffset();
+}
+
+WebSize WebFrameImpl::minimumScrollOffset() const
+{
+ FrameView* view = frameView();
+ if (!view)
+ return WebSize();
+ return toIntSize(view->minimumScrollPosition());
+}
+
+WebSize WebFrameImpl::maximumScrollOffset() const
+{
+ FrameView* view = frameView();
+ if (!view)
+ return WebSize();
+ return toIntSize(view->maximumScrollPosition());
+}
+
+void WebFrameImpl::setScrollOffset(const WebSize& offset)
+{
+ if (FrameView* view = frameView())
+ view->setScrollOffset(IntPoint(offset.width, offset.height));
+}
+
+WebSize WebFrameImpl::contentsSize() const
+{
+ return frame()->view()->contentsSize();
+}
+
+bool WebFrameImpl::hasVisibleContent() const
+{
+ return frame()->view()->visibleWidth() > 0 && frame()->view()->visibleHeight() > 0;
+}
+
+WebRect WebFrameImpl::visibleContentRect() const
+{
+ return frame()->view()->visibleContentRect();
+}
+
+bool WebFrameImpl::hasHorizontalScrollbar() const
+{
+ return frame() && frame()->view() && frame()->view()->horizontalScrollbar();
+}
+
+bool WebFrameImpl::hasVerticalScrollbar() const
+{
+ return frame() && frame()->view() && frame()->view()->verticalScrollbar();
+}
+
+WebView* WebFrameImpl::view() const
+{
+ return viewImpl();
+}
+
+WebFrame* WebFrameImpl::opener() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->loader()->opener());
+}
+
+void WebFrameImpl::setOpener(const WebFrame* webFrame)
+{
+ frame()->loader()->setOpener(webFrame ? static_cast<const WebFrameImpl*>(webFrame)->frame() : 0);
+}
+
+WebFrame* WebFrameImpl::parent() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->parent());
+}
+
+WebFrame* WebFrameImpl::top() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->top());
+}
+
+WebFrame* WebFrameImpl::firstChild() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->firstChild());
+}
+
+WebFrame* WebFrameImpl::lastChild() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->lastChild());
+}
+
+WebFrame* WebFrameImpl::nextSibling() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->nextSibling());
+}
+
+WebFrame* WebFrameImpl::previousSibling() const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->previousSibling());
+}
+
+WebFrame* WebFrameImpl::traverseNext(bool wrap) const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->traverseNextWithWrap(wrap));
+}
+
+WebFrame* WebFrameImpl::traversePrevious(bool wrap) const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->traversePreviousWithWrap(wrap));
+}
+
+WebFrame* WebFrameImpl::findChildByName(const WebString& name) const
+{
+ if (!frame())
+ return 0;
+ return fromFrame(frame()->tree()->child(name));
+}
+
+WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const
+{
+ if (xpath.isEmpty())
+ return 0;
+
+ Document* document = frame()->document();
+
+ RefPtr<XPathResult> xpathResult = DocumentXPathEvaluator::evaluate(document, xpath, document, 0, XPathResult::ORDERED_NODE_ITERATOR_TYPE, 0, IGNORE_EXCEPTION);
+ if (!xpathResult)
+ return 0;
+
+ Node* node = xpathResult->iterateNext(IGNORE_EXCEPTION);
+ if (!node || !node->isFrameOwnerElement())
+ return 0;
+ HTMLFrameOwnerElement* frameElement = toFrameOwnerElement(node);
+ return fromFrame(frameElement->contentFrame());
+}
+
+WebDocument WebFrameImpl::document() const
+{
+ if (!frame() || !frame()->document())
+ return WebDocument();
+ return WebDocument(frame()->document());
+}
+
+WebPerformance WebFrameImpl::performance() const
+{
+ if (!frame())
+ return WebPerformance();
+ return WebPerformance(frame()->domWindow()->performance());
+}
+
+NPObject* WebFrameImpl::windowObject() const
+{
+ if (!frame())
+ return 0;
+ return frame()->script()->windowScriptNPObject();
+}
+
+void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object)
+{
+ bindToWindowObject(name, object, 0);
+}
+
+void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object, void*)
+{
+ if (!frame() || !frame()->script()->canExecuteScripts(NotAboutToExecuteScript))
+ return;
+ frame()->script()->bindToWindowObject(frame(), String(name), object);
+}
+
+void WebFrameImpl::executeScript(const WebScriptSource& source)
+{
+ ASSERT(frame());
+ TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), OrdinalNumber::first());
+ frame()->script()->executeScript(ScriptSourceCode(source.code, source.url, position));
+}
+
+void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup)
+{
+ ASSERT(frame());
+ RELEASE_ASSERT(worldID > 0);
+ RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
+
+ Vector<ScriptSourceCode> sources;
+ for (unsigned i = 0; i < numSources; ++i) {
+ TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
+ sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
+ }
+
+ frame()->script()->executeScriptInIsolatedWorld(worldID, sources, extensionGroup, 0);
+}
+
+void WebFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSecurityOrigin& securityOrigin)
+{
+ ASSERT(frame());
+ DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get());
+}
+
+void WebFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebString& policy)
+{
+ ASSERT(frame());
+ DOMWrapperWorld::setIsolatedWorldContentSecurityPolicy(worldID, policy);
+}
+
+void WebFrameImpl::addMessageToConsole(const WebConsoleMessage& message)
+{
+ ASSERT(frame());
+
+ MessageLevel webCoreMessageLevel;
+ switch (message.level) {
+ case WebConsoleMessage::LevelDebug:
+ webCoreMessageLevel = DebugMessageLevel;
+ 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()->document()->addConsoleMessage(OtherMessageSource, webCoreMessageLevel, message.text);
+}
+
+void WebFrameImpl::collectGarbage()
+{
+ if (!frame())
+ return;
+ if (!frame()->settings()->isScriptEnabled())
+ return;
+ V8GCController::collectGarbage(v8::Isolate::GetCurrent());
+}
+
+bool WebFrameImpl::checkIfRunInsecureContent(const WebURL& url) const
+{
+ ASSERT(frame());
+ return frame()->loader()->mixedContentChecker()->canRunInsecureContent(frame()->document()->securityOrigin(), url);
+}
+
+v8::Handle<v8::Value> WebFrameImpl::executeScriptAndReturnValue(const WebScriptSource& source)
+{
+ ASSERT(frame());
+
+ // FIXME: This fake user gesture is required to make a bunch of pyauto
+ // tests pass. If this isn't needed in non-test situations, we should
+ // consider removing this code and changing the tests.
+ // http://code.google.com/p/chromium/issues/detail?id=86397
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+
+ TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), OrdinalNumber::first());
+ return frame()->script()->executeScript(ScriptSourceCode(source.code, source.url, position)).v8Value();
+}
+
+void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::Value> >* results)
+{
+ ASSERT(frame());
+ RELEASE_ASSERT(worldID > 0);
+ RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
+
+ Vector<ScriptSourceCode> sources;
+
+ for (unsigned i = 0; i < numSources; ++i) {
+ TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startLine), OrdinalNumber::first());
+ sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
+ }
+
+ if (results) {
+ Vector<ScriptValue> scriptResults;
+ frame()->script()->executeScriptInIsolatedWorld(worldID, sources, extensionGroup, &scriptResults);
+ WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size());
+ for (unsigned i = 0; i < scriptResults.size(); i++)
+ v8Results[i] = v8::Local<v8::Value>::New(scriptResults[i].v8Value());
+ results->swap(v8Results);
+ } else
+ frame()->script()->executeScriptInIsolatedWorld(worldID, sources, extensionGroup, 0);
+}
+
+v8::Handle<v8::Value> WebFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[])
+{
+ ASSERT(frame());
+ return frame()->script()->callFunctionEvenIfScriptDisabled(function, receiver, argc, argv).v8Value();
+}
+
+v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const
+{
+ if (!frame())
+ return v8::Local<v8::Context>();
+ return ScriptController::mainWorldContext(frame());
+}
+
+v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystemType type, const WebString& name, const WebString& path)
+{
+ ASSERT(frame());
+ return toV8(DOMFileSystem::create(frame()->document(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, path.utf8().data()), AsyncFileSystemChromium::create()), v8::Handle<v8::Object>(), frame()->script()->currentWorldContext()->GetIsolate());
+}
+
+v8::Handle<v8::Value> WebFrameImpl::createSerializableFileSystem(WebFileSystemType type, const WebString& name, const WebString& path)
+{
+ ASSERT(frame());
+ RefPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(frame()->document(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, path.utf8().data()), AsyncFileSystemChromium::create());
+ fileSystem->makeClonable();
+ return toV8(fileSystem.release(), v8::Handle<v8::Object>(), frame()->script()->currentWorldContext()->GetIsolate());
+}
+
+v8::Handle<v8::Value> WebFrameImpl::createFileEntry(WebFileSystemType type, const WebString& fileSystemName, const WebString& fileSystemPath, const WebString& filePath, bool isDirectory)
+{
+ ASSERT(frame());
+
+ RefPtr<DOMFileSystemBase> fileSystem = DOMFileSystem::create(frame()->document(), fileSystemName, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, fileSystemPath.utf8().data()), AsyncFileSystemChromium::create());
+ if (isDirectory)
+ return toV8(DirectoryEntry::create(fileSystem, filePath), v8::Handle<v8::Object>(), frame()->script()->currentWorldContext()->GetIsolate());
+ return toV8(FileEntry::create(fileSystem, filePath), v8::Handle<v8::Object>(), frame()->script()->currentWorldContext()->GetIsolate());
+}
+
+void WebFrameImpl::reload(bool ignoreCache)
+{
+ ASSERT(frame());
+ frame()->loader()->reload(ignoreCache ? EndToEndReload : NormalReload);
+}
+
+void WebFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache)
+{
+ ASSERT(frame());
+ frame()->loader()->reload(ignoreCache ? EndToEndReload : NormalReload, overrideUrl);
+}
+
+void WebFrameImpl::loadRequest(const WebURLRequest& request)
+{
+ ASSERT(frame());
+ ASSERT(!request.isNull());
+ const ResourceRequest& resourceRequest = request.toResourceRequest();
+
+ if (resourceRequest.url().protocolIs("javascript")) {
+ loadJavaScriptURL(resourceRequest.url());
+ return;
+ }
+
+ frame()->loader()->load(FrameLoadRequest(0, resourceRequest));
+}
+
+void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item)
+{
+ ASSERT(frame());
+ RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item);
+ ASSERT(historyItem);
+
+ frame()->loader()->prepareForHistoryNavigation();
+ RefPtr<HistoryItem> currentItem = frame()->loader()->history()->currentItem();
+ m_inSameDocumentHistoryLoad = currentItem && currentItem->shouldDoSameDocumentNavigationTo(historyItem.get());
+ frame()->page()->goToItem(historyItem.get());
+ m_inSameDocumentHistoryLoad = false;
+}
+
+void WebFrameImpl::loadData(const WebData& data, const WebString& mimeType, const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachableURL, bool replace)
+{
+ ASSERT(frame());
+
+ // 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 = frame()->loader()->originalRequest();
+ request.setURL(baseURL);
+
+ FrameLoadRequest frameRequest(0, request, SubstituteData(data, mimeType, textEncoding, unreachableURL));
+ ASSERT(frameRequest.substituteData().isValid());
+ frameRequest.setLockBackForwardList(replace);
+ frame()->loader()->load(frameRequest);
+}
+
+void WebFrameImpl::loadHTMLString(const WebData& data, const WebURL& baseURL, const WebURL& unreachableURL, bool replace)
+{
+ ASSERT(frame());
+ loadData(data, WebString::fromUTF8("text/html"), WebString::fromUTF8("UTF-8"), baseURL, unreachableURL, replace);
+}
+
+bool WebFrameImpl::isLoading() const
+{
+ if (!frame())
+ return false;
+ return frame()->loader()->isLoading();
+}
+
+void WebFrameImpl::stopLoading()
+{
+ if (!frame())
+ return;
+ // FIXME: Figure out what we should really do here. It seems like a bug
+ // that FrameLoader::stopLoading doesn't call stopAllLoaders.
+ frame()->loader()->stopAllLoaders();
+ frame()->loader()->stopLoading();
+}
+
+WebDataSource* WebFrameImpl::provisionalDataSource() const
+{
+ ASSERT(frame());
+
+ // We regard the policy document loader as still provisional.
+ DocumentLoader* documentLoader = frame()->loader()->provisionalDocumentLoader();
+ if (!documentLoader)
+ documentLoader = frame()->loader()->policyDocumentLoader();
+
+ return DataSourceForDocLoader(documentLoader);
+}
+
+WebDataSource* WebFrameImpl::dataSource() const
+{
+ ASSERT(frame());
+ return DataSourceForDocLoader(frame()->loader()->documentLoader());
+}
+
+WebHistoryItem WebFrameImpl::previousHistoryItem() const
+{
+ ASSERT(frame());
+ // 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(frame()->loader()->history()->previousItem());
+}
+
+WebHistoryItem WebFrameImpl::currentHistoryItem() const
+{
+ ASSERT(frame());
+
+ // We're shutting down.
+ if (!frame()->loader()->activeDocumentLoader())
+ return WebHistoryItem();
+
+ // 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.
+ // FIXME: Can we make this a plain old getter, instead of worrying about
+ // clobbering here?
+ if (!m_inSameDocumentHistoryLoad && (frame()->loader()->loadType() == FrameLoadTypeStandard
+ || !frame()->loader()->activeDocumentLoader()->isLoadingInAPISense()))
+ frame()->loader()->history()->saveDocumentAndScrollState();
+
+ return WebHistoryItem(frame()->page()->backForward()->currentItem());
+}
+
+void WebFrameImpl::enableViewSourceMode(bool enable)
+{
+ if (frame())
+ frame()->setInViewSourceMode(enable);
+}
+
+bool WebFrameImpl::isViewSourceModeEnabled() const
+{
+ if (!frame())
+ return false;
+ return frame()->inViewSourceMode();
+}
+
+void WebFrameImpl::setReferrerForRequest(WebURLRequest& request, const WebURL& referrerURL)
+{
+ String referrer = referrerURL.isEmpty() ? frame()->loader()->outgoingReferrer() : String(referrerURL.spec().utf16());
+ referrer = SecurityPolicy::generateReferrerHeader(frame()->document()->referrerPolicy(), request.url(), referrer);
+ if (referrer.isEmpty())
+ return;
+ request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer);
+}
+
+void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request)
+{
+ ResourceResponse response;
+ frame()->loader()->client()->dispatchWillSendRequest(0, 0, request.toMutableResourceRequest(), response);
+}
+
+WebURLLoader* WebFrameImpl::createAssociatedURLLoader(const WebURLLoaderOptions& options)
+{
+ return new AssociatedURLLoader(this, options);
+}
+
+unsigned WebFrameImpl::unloadListenerCount() const
+{
+ return frame()->domWindow()->pendingUnloadEventListeners();
+}
+
+bool WebFrameImpl::willSuppressOpenerInNewFrame() const
+{
+ return frame()->loader()->suppressOpenerInNewFrame();
+}
+
+void WebFrameImpl::replaceSelection(const WebString& text)
+{
+ bool selectReplacement = false;
+ bool smartReplace = true;
+ frame()->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);
+}
+
+void WebFrameImpl::insertText(const WebString& text)
+{
+ if (frame()->inputMethodController().hasComposition())
+ frame()->inputMethodController().confirmComposition(text);
+ else
+ frame()->editor()->insertText(text, 0);
+}
+
+void WebFrameImpl::setMarkedText(const WebString& text, unsigned location, unsigned length)
+{
+ Vector<CompositionUnderline> decorations;
+ frame()->inputMethodController().setComposition(text, decorations, location, length);
+}
+
+void WebFrameImpl::unmarkText()
+{
+ frame()->inputMethodController().cancelComposition();
+}
+
+bool WebFrameImpl::hasMarkedText() const
+{
+ return frame()->inputMethodController().hasComposition();
+}
+
+WebRange WebFrameImpl::markedRange() const
+{
+ return frame()->inputMethodController().compositionRange();
+}
+
+bool WebFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length, WebRect& rect) const
+{
+ if ((location + length < location) && (location + length))
+ length = 0;
+
+ RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), location, length);
+ if (!range)
+ return false;
+ IntRect intRect = frame()->editor()->firstRectForRange(range.get());
+ rect = WebRect(intRect);
+ rect = frame()->view()->contentsToWindow(rect);
+ return true;
+}
+
+size_t WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const
+{
+ if (!frame())
+ return notFound;
+
+ IntPoint point = frame()->view()->windowToContents(webPoint);
+ HitTestResult result = frame()->eventHandler()->hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
+ RefPtr<Range> range = frame()->rangeForPoint(result.roundedPointInInnerNodeFrame());
+ if (!range)
+ return notFound;
+
+ size_t location, length;
+ TextIterator::getLocationAndLengthFromRange(frame()->selection()->rootEditableElementOrDocumentElement(), range.get(), location, length);
+ return location;
+}
+
+bool WebFrameImpl::executeCommand(const WebString& name, const WebNode& node)
+{
+ 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);
+
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), node);
+ if (pluginContainer && pluginContainer->executeEditCommand(name))
+ return true;
+
+ bool result = true;
+
+ // Specially handling commands that Editor::execCommand does not directly
+ // support.
+ if (command == "DeleteToEndOfParagraph") {
+ if (!frame()->editor()->deleteWithDirection(DirectionForward, ParagraphBoundary, true, false))
+ frame()->editor()->deleteWithDirection(DirectionForward, CharacterGranularity, true, false);
+ } else if (command == "Indent")
+ frame()->editor()->indent();
+ else if (command == "Outdent")
+ frame()->editor()->outdent();
+ else if (command == "DeleteBackward")
+ result = frame()->editor()->command(AtomicString("BackwardDelete")).execute();
+ else if (command == "DeleteForward")
+ result = frame()->editor()->command(AtomicString("ForwardDelete")).execute();
+ else if (command == "AdvanceToNextMisspelling") {
+ // Wee need to pass false here or else the currently selected word will never be skipped.
+ frame()->editor()->advanceToNextMisspelling(false);
+ } else if (command == "ToggleSpellPanel")
+ frame()->editor()->showSpellingGuessPanel();
+ else
+ result = frame()->editor()->command(command).execute();
+ return result;
+}
+
+bool WebFrameImpl::executeCommand(const WebString& name, const WebString& value, const WebNode& node)
+{
+ ASSERT(frame());
+ String webName = name;
+
+ WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), node);
+ if (pluginContainer && pluginContainer->executeEditCommand(name, value))
+ return true;
+
+ // 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;
+ frame()->editor()->toggleContinuousSpellChecking();
+}
+
+bool WebFrameImpl::isContinuousSpellCheckingEnabled() const
+{
+ return frame()->editor()->isContinuousSpellCheckingEnabled();
+}
+
+void WebFrameImpl::requestTextChecking(const WebElement& webElement)
+{
+ if (webElement.isNull())
+ return;
+ RefPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*>(webElement.constUnwrap<Element>()));
+ frame()->editor()->spellChecker()->requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToCheck, rangeToCheck));
+}
+
+void WebFrameImpl::replaceMisspelledRange(const WebString& text)
+{
+ // If this caret selection has two or more markers, this function replace the range covered by the first marker with the specified word as Microsoft Word does.
+ if (pluginContainerFromFrame(frame()))
+ return;
+ RefPtr<Range> caretRange = frame()->selection()->toNormalizedRange();
+ if (!caretRange)
+ return;
+ Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInRange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
+ if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset())
+ return;
+ RefPtr<Range> markerRange = Range::create(caretRange->ownerDocument(), caretRange->startContainer(), markers[0]->startOffset(), caretRange->endContainer(), markers[0]->endOffset());
+ if (!markerRange)
+ return;
+ if (!frame()->selection()->shouldChangeSelection(markerRange.get()))
+ return;
+ frame()->selection()->setSelection(markerRange.get(), CharacterGranularity);
+ frame()->editor()->replaceSelectionWithText(text, false, false);
+}
+
+void WebFrameImpl::removeSpellingMarkers()
+{
+ frame()->document()->markers()->removeMarkers(DocumentMarker::Spelling | DocumentMarker::Grammar);
+}
+
+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)
+ 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)
+ return WebString();
+
+ return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNonLocalURLs);
+}
+
+void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition position)
+{
+ VisibleSelection selection(position);
+ selection.expandUsingGranularity(WordGranularity);
+
+ if (frame->selection()->shouldChangeSelection(selection)) {
+ TextGranularity granularity = selection.isRange() ? WordGranularity : CharacterGranularity;
+ frame->selection()->setSelection(selection, granularity);
+ }
+}
+
+bool WebFrameImpl::selectWordAroundCaret()
+{
+ FrameSelection* selection = frame()->selection();
+ ASSERT(!selection->isNone());
+ if (selection->isNone() || selection->isRange())
+ return false;
+ selectWordAroundPosition(frame(), selection->selection().visibleStart());
+ return true;
+}
+
+void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent)
+{
+ moveRangeSelection(base, extent);
+}
+
+void WebFrameImpl::selectRange(const WebRange& webRange)
+{
+ if (RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange))
+ frame()->selection()->setSelectedRange(range.get(), WebCore::VP_DEFAULT_AFFINITY, false);
+}
+
+void WebFrameImpl::moveCaretSelectionTowardsWindowPoint(const WebPoint& point)
+{
+ moveCaretSelection(point);
+}
+
+void WebFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& extent)
+{
+ FrameSelection* selection = frame()->selection();
+ if (!selection)
+ return;
+
+ VisiblePosition basePosition = visiblePositionForWindowPoint(base);
+ VisiblePosition extentPosition = visiblePositionForWindowPoint(extent);
+ VisibleSelection newSelection = VisibleSelection(basePosition, extentPosition);
+ if (frame()->selection()->shouldChangeSelection(newSelection))
+ frame()->selection()->setSelection(newSelection, CharacterGranularity);
+}
+
+void WebFrameImpl::moveCaretSelection(const WebPoint& point)
+{
+ Element* editable = frame()->selection()->rootEditableElement();
+ if (!editable)
+ return;
+
+ VisiblePosition position = visiblePositionForWindowPoint(point);
+ if (frame()->selection()->shouldChangeSelection(position))
+ frame()->selection()->moveTo(position, UserTriggered);
+}
+
+void WebFrameImpl::setCaretVisible(bool visible)
+{
+ frame()->selection()->setCaretVisible(visible);
+}
+
+VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& point)
+{
+ FloatPoint unscaledPoint(point);
+ unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFactor());
+
+ HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent;
+ HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unscaledPoint)));
+ frame()->document()->renderView()->layer()->hitTest(request, result);
+
+ Node* node = result.targetNode();
+ if (!node)
+ return VisiblePosition();
+ return frame()->selection()->selection().visiblePositionRespectingEditingBoundary(result.localPoint(), node);
+}
+
+int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& constrainToNode, 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.
+ pluginContainer = static_cast<WebPluginContainerImpl*>(constrainToNode.pluginContainer());
+ }
+
+ if (pluginContainer && pluginContainer->supportsPaginatedPrint())
+ m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginContainer, printParams));
+ else
+ m_printContext = adoptPtr(new ChromePrintContext(frame()));
+
+ FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width), static_cast<float>(printParams.printContentArea.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)
+{
+ ASSERT(m_printContext && page >= 0);
+ return m_printContext->getPageShrink(page);
+}
+
+float WebFrameImpl::printPage(int page, WebCanvas* canvas)
+{
+#if ENABLE(PRINTING)
+ ASSERT(m_printContext && page >= 0 && frame() && frame()->document());
+
+ GraphicsContext graphicsContext(canvas);
+ graphicsContext.setPrinting(true);
+ return m_printContext->spoolPage(graphicsContext, page);
+#else
+ return 0;
+#endif
+}
+
+void WebFrameImpl::printEnd()
+{
+ ASSERT(m_printContext);
+ m_printContext->end();
+ m_printContext.clear();
+}
+
+bool WebFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node)
+{
+ WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFromFrame(frame()) : static_cast<WebPluginContainerImpl*>(node.pluginContainer());
+
+ if (!pluginContainer || !pluginContainer->supportsPaginatedPrint())
+ return false;
+
+ return pluginContainer->isPrintScalingDisabled();
+}
+
+bool WebFrameImpl::hasCustomPageSizeStyle(int pageIndex)
+{
+ return frame()->document()->styleForPage(pageIndex)->pageSizeType() != PAGE_SIZE_AUTO;
+}
+
+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;
+ frame()->document()->pageSizeAndMarginsInPixels(pageIndex, size, marginTop, marginRight, marginBottom, marginLeft);
+ pageSize = size;
+}
+
+WebString WebFrameImpl::pageProperty(const WebString& propertyName, int pageIndex)
+{
+ ASSERT(m_printContext);
+ return m_printContext->pageProperty(frame(), propertyName.utf8().data(), pageIndex);
+}
+
+bool WebFrameImpl::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect)
+{
+ if (!frame() || !frame()->page())
+ return false;
+
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+
+ if (!options.findNext)
+ frame()->page()->unmarkAllTextMatches();
+ else
+ setMarkerActive(m_activeMatch.get(), false);
+
+ if (m_activeMatch && m_activeMatch->ownerDocument() != frame()->document())
+ m_activeMatch = 0;
+
+ // 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.firstRange().get();
+ frame()->selection()->clear();
+ }
+
+ ASSERT(frame() && frame()->view());
+ const FindOptions findOptions = (options.forward ? 0 : Backwards)
+ | (options.matchCase ? 0 : CaseInsensitive)
+ | (wrapWithinFrame ? WrapAround : 0)
+ | (!options.findNext ? StartInSelection : 0);
+ m_activeMatch = frame()->editor()->findStringAndScrollToVisible(searchText, m_activeMatch.get(), findOptions);
+
+ if (!m_activeMatch) {
+ // If we're finding next the next active match might not be in the current frame.
+ // In this case we don't want to clear the matches cache.
+ if (!options.findNext)
+ clearFindMatchesCache();
+ invalidateArea(InvalidateAll);
+ return false;
+ }
+
+#if OS(ANDROID)
+ viewImpl()->zoomToFindInPageRect(frameView()->contentsToWindow(enclosingIntRect(RenderObject::absoluteBoundingBoxRectForRange(m_activeMatch.get()))));
+#endif
+
+ setMarkerActive(m_activeMatch.get(), true);
+ WebFrameImpl* oldActiveFrame = mainFrameImpl->m_currentActiveMatchFrame;
+ mainFrameImpl->m_currentActiveMatchFrame = this;
+
+ // Make sure no node is focused. See http://crbug.com/38700.
+ frame()->document()->setFocusedElement(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 and report it back to the UI.
+ m_locatingActiveRect = true;
+ } else {
+ if (oldActiveFrame != this) {
+ if (options.forward)
+ m_activeMatchIndexInCurrentFrame = 0;
+ else
+ m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1;
+ } else {
+ if (options.forward)
+ ++m_activeMatchIndexInCurrentFrame;
+ else
+ --m_activeMatchIndexInCurrentFrame;
+
+ if (m_activeMatchIndexInCurrentFrame + 1 > m_lastMatchCount)
+ m_activeMatchIndexInCurrentFrame = 0;
+ if (m_activeMatchIndexInCurrentFrame == -1)
+ m_activeMatchIndexInCurrentFrame = m_lastMatchCount - 1;
+ }
+ if (selectionRect) {
+ *selectionRect = frameView()->contentsToWindow(m_activeMatch->boundingBox());
+ reportFindInPageSelection(*selectionRect, m_activeMatchIndexInCurrentFrame + 1, identifier);
+ }
+ }
+
+ return true;
+}
+
+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);
+ clearFindMatchesCache();
+
+ // 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 (reset) {
+ // This is a brand new search, so we need to reset everything.
+ // Scoping is just about to begin.
+ m_scopingInProgress = true;
+
+ // Need to keep the current identifier locally in order to finish the
+ // request in case the frame is detached during the process.
+ m_findRequestIdentifier = identifier;
+
+ // Clear highlighting for this frame.
+ if (frame() && frame()->page() && frame()->editor()->markedTextMatchesAreHighlighted())
+ frame()->page()->unmarkAllTextMatches();
+
+ // Clear the tickmarks and results cache.
+ clearFindMatchesCache();
+
+ // Clear the counters from last operation.
+ m_lastMatchCount = 0;
+ m_nextInvalidateAfter = 0;
+
+ m_resumeScopingFromRange = 0;
+
+ // The view might be null on detached frames.
+ if (frame() && frame()->page())
+ viewImpl()->mainFrameImpl()->m_framesScopingCount++;
+
+ // Now, defer scoping until later to allow find operation to finish quickly.
+ scopeStringMatchesSoon(identifier, searchText, options, false); // false means just reset, so don't do it again.
+ return;
+ }
+
+ if (!shouldScopeMatches(searchText)) {
+ // Note that we want to defer the final update when resetting even if shouldScopeMatches returns false.
+ // This is done in order to prevent sending a final message based only on the results of the first frame
+ // since m_framesScopingCount would be 0 as other frames have yet to reset.
+ finishCurrentScopingEffort(identifier);
+ return;
+ }
+
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+ RefPtr<Range> searchRange(rangeOfContents(frame()->document()));
+
+ Node* originalEndContainer = searchRange->endContainer();
+ int originalEndOffset = searchRange->endOffset();
+
+ TrackExceptionState es, es2;
+ if (m_resumeScopingFromRange) {
+ // 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(es2) + 1, es);
+ if (es.hadException() || es2.hadException()) {
+ if (es2.hadException()) // A non-zero |es| happens when navigating during search.
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ }
+
+ // 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,
+ options.matchCase ? 0 : CaseInsensitive));
+ if (resultRange->collapsed(es)) {
+ if (!resultRange->startContainer()->isInShadowTree())
+ break;
+
+ searchRange->setStartAfter(
+ resultRange->startContainer()->deprecatedShadowAncestorNode(), es);
+ searchRange->setEnd(originalEndContainer, originalEndOffset, es);
+ continue;
+ }
+
+ ++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_currentActiveMatchFrame = this;
+ foundActiveMatch = true;
+ // We also know which tickmark is active now.
+ m_activeMatchIndexInCurrentFrame = 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.
+ reportFindInPageSelection(
+ frameView()->contentsToWindow(resultBounds),
+ m_activeMatchIndexInCurrentFrame + 1,
+ identifier);
+ }
+
+ addMarker(resultRange.get(), foundActiveMatch);
+
+ m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount + matchCount));
+
+ // 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(es), resultRange->endOffset(es), es);
+
+ Node* shadowTreeRoot = searchRange->shadowRoot();
+ if (searchRange->collapsed(es) && shadowTreeRoot)
+ searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount(), es);
+
+ 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.
+ }
+
+ finishCurrentScopingEffort(identifier);
+}
+
+void WebFrameImpl::flushCurrentScopingEffort(int identifier)
+{
+ if (!frame() || !frame()->page())
+ return;
+
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+
+ // This frame has no further scoping left, so it is done. Other frames might,
+ // of course, continue to scope matches.
+ 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);
+}
+
+void WebFrameImpl::finishCurrentScopingEffort(int identifier)
+{
+ flushCurrentScopingEffort(identifier);
+
+ m_scopingInProgress = false;
+ m_lastFindRequestCompletedWithNoMatches = !m_lastMatchCount;
+
+ // 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_activeMatchIndexInCurrentFrame = -1;
+
+ // Last request didn't complete.
+ if (m_scopingInProgress)
+ m_lastFindRequestCompletedWithNoMatches = false;
+
+ m_scopingInProgress = false;
+}
+
+void WebFrameImpl::increaseMatchCount(int count, int identifier)
+{
+ // This function should only be called on the mainframe.
+ ASSERT(!parent());
+
+ if (count)
+ ++m_findMatchMarkersVersion;
+
+ 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()
+{
+ if (m_totalMatchCount > 0)
+ ++m_findMatchMarkersVersion;
+
+ m_totalMatchCount = 0;
+ m_framesScopingCount = 0;
+}
+
+void WebFrameImpl::sendOrientationChangeEvent(int orientation)
+{
+#if ENABLE(ORIENTATION_EVENTS)
+ if (frame())
+ frame()->sendOrientationChangeEvent(orientation);
+#endif
+}
+
+void WebFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOrigin& intendedTargetOrigin, const WebDOMEvent& event)
+{
+ ASSERT(!event.isNull());
+ frame()->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrigin.get(), event, 0);
+}
+
+int WebFrameImpl::findMatchMarkersVersion() const
+{
+ ASSERT(!parent());
+ return m_findMatchMarkersVersion;
+}
+
+void WebFrameImpl::clearFindMatchesCache()
+{
+ if (!m_findMatchesCache.isEmpty())
+ viewImpl()->mainFrameImpl()->m_findMatchMarkersVersion++;
+
+ m_findMatchesCache.clear();
+ m_findMatchRectsAreValid = false;
+}
+
+bool WebFrameImpl::isActiveMatchFrameValid() const
+{
+ WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
+ WebFrameImpl* activeMatchFrame = mainFrameImpl->activeMatchFrame();
+ return activeMatchFrame && activeMatchFrame->m_activeMatch && activeMatchFrame->frame()->tree()->isDescendantOf(mainFrameImpl->frame());
+}
+
+void WebFrameImpl::updateFindMatchRects()
+{
+ IntSize currentContentsSize = contentsSize();
+ if (m_contentsSizeForCurrentFindMatchRects != currentContentsSize) {
+ m_contentsSizeForCurrentFindMatchRects = currentContentsSize;
+ m_findMatchRectsAreValid = false;
+ }
+
+ size_t deadMatches = 0;
+ for (Vector<FindMatch>::iterator it = m_findMatchesCache.begin(); it != m_findMatchesCache.end(); ++it) {
+ if (!it->m_range->boundaryPointsValid() || !it->m_range->startContainer()->inDocument())
+ it->m_rect = FloatRect();
+ else if (!m_findMatchRectsAreValid)
+ it->m_rect = findInPageRectFromRange(it->m_range.get());
+
+ if (it->m_rect.isEmpty())
+ ++deadMatches;
+ }
+
+ // Remove any invalid matches from the cache.
+ if (deadMatches) {
+ Vector<FindMatch> filteredMatches;
+ filteredMatches.reserveCapacity(m_findMatchesCache.size() - deadMatches);
+
+ for (Vector<FindMatch>::const_iterator it = m_findMatchesCache.begin(); it != m_findMatchesCache.end(); ++it)
+ if (!it->m_rect.isEmpty())
+ filteredMatches.append(*it);
+
+ m_findMatchesCache.swap(filteredMatches);
+ }
+
+ // Invalidate the rects in child frames. Will be updated later during traversal.
+ if (!m_findMatchRectsAreValid)
+ for (WebFrame* child = firstChild(); child; child = child->nextSibling())
+ static_cast<WebFrameImpl*>(child)->m_findMatchRectsAreValid = false;
+
+ m_findMatchRectsAreValid = true;
+}
+
+WebFloatRect WebFrameImpl::activeFindMatchRect()
+{
+ ASSERT(!parent());
+
+ if (!isActiveMatchFrameValid())
+ return WebFloatRect();
+
+ return WebFloatRect(findInPageRectFromRange(m_currentActiveMatchFrame->m_activeMatch.get()));
+}
+
+void WebFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects)
+{
+ ASSERT(!parent());
+
+ Vector<WebFloatRect> matchRects;
+ for (WebFrameImpl* frame = this; frame; frame = static_cast<WebFrameImpl*>(frame->traverseNext(false)))
+ frame->appendFindMatchRects(matchRects);
+
+ outputRects = matchRects;
+}
+
+void WebFrameImpl::appendFindMatchRects(Vector<WebFloatRect>& frameRects)
+{
+ updateFindMatchRects();
+ frameRects.reserveCapacity(frameRects.size() + m_findMatchesCache.size());
+ for (Vector<FindMatch>::const_iterator it = m_findMatchesCache.begin(); it != m_findMatchesCache.end(); ++it) {
+ ASSERT(!it->m_rect.isEmpty());
+ frameRects.append(it->m_rect);
+ }
+}
+
+int WebFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRect* selectionRect)
+{
+ ASSERT(!parent());
+
+ WebFrameImpl* bestFrame = 0;
+ int indexInBestFrame = -1;
+ float distanceInBestFrame = FLT_MAX;
+
+ for (WebFrameImpl* frame = this; frame; frame = static_cast<WebFrameImpl*>(frame->traverseNext(false))) {
+ float distanceInFrame;
+ int indexInFrame = frame->nearestFindMatch(point, distanceInFrame);
+ if (distanceInFrame < distanceInBestFrame) {
+ bestFrame = frame;
+ indexInBestFrame = indexInFrame;
+ distanceInBestFrame = distanceInFrame;
+ }
+ }
+
+ if (indexInBestFrame != -1)
+ return bestFrame->selectFindMatch(static_cast<unsigned>(indexInBestFrame), selectionRect);
+
+ return -1;
+}
+
+int WebFrameImpl::nearestFindMatch(const FloatPoint& point, float& distanceSquared)
+{
+ updateFindMatchRects();
+
+ int nearest = -1;
+ distanceSquared = FLT_MAX;
+ for (size_t i = 0; i < m_findMatchesCache.size(); ++i) {
+ ASSERT(!m_findMatchesCache[i].m_rect.isEmpty());
+ FloatSize offset = point - m_findMatchesCache[i].m_rect.center();
+ float width = offset.width();
+ float height = offset.height();
+ float currentDistanceSquared = width * width + height * height;
+ if (currentDistanceSquared < distanceSquared) {
+ nearest = i;
+ distanceSquared = currentDistanceSquared;
+ }
+ }
+ return nearest;
+}
+
+int WebFrameImpl::selectFindMatch(unsigned index, WebRect* selectionRect)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(index < m_findMatchesCache.size());
+
+ RefPtr<Range> range = m_findMatchesCache[index].m_range;
+ if (!range->boundaryPointsValid() || !range->startContainer()->inDocument())
+ return -1;
+
+ // Check if the match is already selected.
+ WebFrameImpl* activeMatchFrame = viewImpl()->mainFrameImpl()->m_currentActiveMatchFrame;
+ if (this != activeMatchFrame || !m_activeMatch || !areRangesEqual(m_activeMatch.get(), range.get())) {
+ if (isActiveMatchFrameValid())
+ activeMatchFrame->setMarkerActive(activeMatchFrame->m_activeMatch.get(), false);
+
+ m_activeMatchIndexInCurrentFrame = m_findMatchesCache[index].m_ordinal - 1;
+
+ // Set this frame as the active frame (the one with the active highlight).
+ viewImpl()->mainFrameImpl()->m_currentActiveMatchFrame = this;
+ viewImpl()->setFocusedFrame(this);
+
+ m_activeMatch = range.release();
+ setMarkerActive(m_activeMatch.get(), true);
+
+ // Clear any user selection, to make sure Find Next continues on from the match we just activated.
+ frame()->selection()->clear();
+
+ // Make sure no node is focused. See http://crbug.com/38700.
+ frame()->document()->setFocusedElement(0);
+ }
+
+ IntRect activeMatchRect;
+ IntRect activeMatchBoundingBox = enclosingIntRect(RenderObject::absoluteBoundingBoxRectForRange(m_activeMatch.get()));
+
+ if (!activeMatchBoundingBox.isEmpty()) {
+ if (m_activeMatch->firstNode() && m_activeMatch->firstNode()->renderer())
+ m_activeMatch->firstNode()->renderer()->scrollRectToVisible(activeMatchBoundingBox,
+ ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
+
+ // Zoom to the active match.
+ activeMatchRect = frameView()->contentsToWindow(activeMatchBoundingBox);
+ viewImpl()->zoomToFindInPageRect(activeMatchRect);
+ }
+
+ if (selectionRect)
+ *selectionRect = activeMatchRect;
+
+ return ordinalOfFirstMatchForFrame(this) + m_activeMatchIndexInCurrentFrame + 1;
+}
+
+WebString WebFrameImpl::contentAsText(size_t maxChars) const
+{
+ if (!frame())
+ return WebString();
+ StringBuilder text;
+ frameContentAsPlainText(maxChars, frame(), text);
+ return text.toString();
+}
+
+WebString WebFrameImpl::contentAsMarkup() const
+{
+ if (!frame())
+ return WebString();
+ return createFullMarkup(frame()->document());
+}
+
+WebString WebFrameImpl::renderTreeAsText(RenderAsTextControls toShow) const
+{
+ RenderAsTextBehavior behavior = RenderAsTextBehaviorNormal;
+
+ if (toShow & RenderAsTextDebug)
+ behavior |= RenderAsTextShowCompositedLayers | RenderAsTextShowAddresses | RenderAsTextShowIDAndClass | RenderAsTextShowLayerNesting;
+
+ if (toShow & RenderAsTextPrinting)
+ behavior |= RenderAsTextPrintingMode;
+
+ return externalRepresentation(frame(), behavior);
+}
+
+WebString WebFrameImpl::markerTextForListItem(const WebElement& webElement) const
+{
+ return WebCore::markerTextForListItem(const_cast<Element*>(webElement.constUnwrap<Element>()));
+}
+
+void WebFrameImpl::printPagesWithBoundaries(WebCanvas* canvas, const WebSize& pageSizeInPixels)
+{
+ ASSERT(m_printContext);
+
+ GraphicsContext graphicsContext(canvas);
+ graphicsContext.setPrinting(true);
+
+ m_printContext->spoolAllPagesWithBoundaries(graphicsContext, FloatSize(pageSizeInPixels.width, pageSizeInPixels.height));
+}
+
+WebRect WebFrameImpl::selectionBoundsRect() const
+{
+ return hasSelection() ? WebRect(IntRect(frame()->selection()->bounds(false))) : WebRect();
+}
+
+bool WebFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const
+{
+ if (!frame())
+ return false;
+ return frame()->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length);
+}
+
+WebString WebFrameImpl::layerTreeAsText(bool showDebugInfo) const
+{
+ if (!frame())
+ return WebString();
+
+ return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesDebugInfo : LayerTreeNormal));
+}
+
+// WebFrameImpl public ---------------------------------------------------------
+
+PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client)
+{
+ return adoptRef(new WebFrameImpl(client));
+}
+
+WebFrameImpl::WebFrameImpl(WebFrameClient* client)
+ : FrameDestructionObserver(0)
+ , m_frameLoaderClient(this)
+ , m_client(client)
+ , m_currentActiveMatchFrame(0)
+ , m_activeMatchIndexInCurrentFrame(-1)
+ , m_locatingActiveRect(false)
+ , m_resumeScopingFromRange(0)
+ , m_lastMatchCount(-1)
+ , m_totalMatchCount(-1)
+ , m_framesScopingCount(-1)
+ , m_findRequestIdentifier(-1)
+ , m_scopingInProgress(false)
+ , m_lastFindRequestCompletedWithNoMatches(false)
+ , m_nextInvalidateAfter(0)
+ , m_findMatchMarkersVersion(0)
+ , m_findMatchRectsAreValid(false)
+ , m_identifier(generateFrameIdentifier())
+ , m_inSameDocumentHistoryLoad(false)
+{
+ WebKit::Platform::current()->incrementStatsCounter(webFrameActiveCount);
+ frameCount++;
+}
+
+WebFrameImpl::~WebFrameImpl()
+{
+ WebKit::Platform::current()->decrementStatsCounter(webFrameActiveCount);
+ frameCount--;
+
+ cancelPendingScopingEffort();
+}
+
+void WebFrameImpl::setWebCoreFrame(WebCore::Frame* frame)
+{
+ ASSERT(frame);
+ observeFrame(frame);
+}
+
+void WebFrameImpl::initializeAsMainFrame(WebCore::Page* page)
+{
+ RefPtr<Frame> mainFrame = Frame::create(page, 0, &m_frameLoaderClient);
+ setWebCoreFrame(mainFrame.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().
+ 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(frame()->page(), ownerElement, &webframe->m_frameLoaderClient);
+ webframe->setWebCoreFrame(childFrame.get());
+
+ childFrame->tree()->setName(request.frameName());
+
+ 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;
+
+ HistoryItem* parentItem = frame()->loader()->history()->currentItem();
+ HistoryItem* childItem = 0;
+ // If we're moving in the back/forward list, we might want to replace the content
+ // of this child frame with whatever was there at that point.
+ if (parentItem && parentItem->children().size() && isBackForwardLoadType(frame()->loader()->loadType()) && !frame()->document()->loadEventFinished())
+ childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueName());
+
+ if (childItem)
+ childFrame->loader()->loadHistoryItem(childItem);
+ else
+ childFrame->loader()->load(FrameLoadRequest(0, request.resourceRequest(), "_self"));
+
+ // 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;
+
+ if (m_client)
+ m_client->didCreateFrame(this, webframe.get());
+
+ return childFrame.release();
+}
+
+void WebFrameImpl::didChangeContentsSize(const IntSize& size)
+{
+ // This is only possible on the main frame.
+ if (m_totalMatchCount > 0) {
+ ASSERT(!parent());
+ ++m_findMatchMarkersVersion;
+ }
+}
+
+void WebFrameImpl::createFrameView()
+{
+ TRACE_EVENT0("webkit", "WebFrameImpl::createFrameView");
+
+ ASSERT(frame()); // If frame() doesn't exist, we probably didn't init properly.
+
+ WebViewImpl* webView = viewImpl();
+ bool isMainFrame = webView->mainFrameImpl()->frame() == frame();
+ if (isMainFrame)
+ webView->suppressInvalidations(true);
+
+ frame()->createView(webView->size(), webView->baseBackgroundColor(), webView->isTransparent(), webView->fixedLayoutSize(), isMainFrame ? webView->isFixedLayoutModeEnabled() : 0);
+ if (webView->shouldAutoResize() && isMainFrame)
+ frame()->view()->enableAutoSizeMode(true, webView->minAutoSize(), webView->maxAutoSize());
+
+ if (isMainFrame)
+ webView->suppressInvalidations(false);
+
+ if (isMainFrame && webView->devToolsAgentPrivate())
+ webView->devToolsAgentPrivate()->mainFrameViewCreated(this);
+}
+
+WebFrameImpl* WebFrameImpl::fromFrame(Frame* frame)
+{
+ if (!frame)
+ return 0;
+ return static_cast<FrameLoaderClientImpl*>(frame->loader()->client())->webFrame();
+}
+
+WebFrameImpl* WebFrameImpl::fromFrameOwnerElement(Element* element)
+{
+ // FIXME: Why do we check specifically for <iframe> and <frame> here? Why can't we get the WebFrameImpl from an <object> element, for example.
+ if (!element || !element->isFrameOwnerElement() || (!element->hasTagName(HTMLNames::iframeTag) && !element->hasTagName(HTMLNames::frameTag)))
+ return 0;
+ HTMLFrameOwnerElement* frameElement = toFrameOwnerElement(element);
+ return fromFrame(frameElement->contentFrame());
+}
+
+WebViewImpl* WebFrameImpl::viewImpl() const
+{
+ if (!frame())
+ return 0;
+ return WebViewImpl::fromPage(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();
+ if (node && node->isInShadowTree()) {
+ Node* host = node->deprecatedShadowAncestorNode();
+ if (host->hasTagName(HTMLNames::inputTag) || isHTMLTextAreaElement(host))
+ node = host;
+ }
+ for (; node; node = node->parentNode()) {
+ if (!node->isElementNode())
+ continue;
+ Element* element = toElement(node);
+ if (element->isFocusable()) {
+ // Found a focusable parent node. Set the active match as the
+ // selection and focus to the focusable node.
+ frame()->selection()->setSelection(m_activeMatch.get());
+ frame()->document()->setFocusedElement(element);
+ 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();
+ for (; node && node != m_activeMatch->pastLastNode(); node = NodeTraversal::next(node)) {
+ if (!node->isElementNode())
+ continue;
+ Element* element = toElement(node);
+ if (element->isFocusable()) {
+ frame()->document()->setFocusedElement(element);
+ return;
+ }
+ }
+
+ // 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()->setFocusedElement(0);
+
+ // Finally clear the active match, for two reasons:
+ // We just finished the find 'session' and we don't want future (potentially
+ // unrelated) find 'sessions' operations to start at the same place.
+ // The WebFrameImpl could get reused and the m_activeMatch could end up pointing
+ // to a document that is no longer valid. Keeping an invalid reference around
+ // is just asking for trouble.
+ m_activeMatch = 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)
+{
+ frame()->view()->setCanHaveScrollbars(canHaveScrollbars);
+}
+
+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.x(), -frameRect.y());
+ view->invalidateRect(contentArea);
+ }
+ }
+
+ if ((area & InvalidateScrollbar) == InvalidateScrollbar) {
+ // Invalidate the vertical scroll bar region for the view.
+ Scrollbar* scrollbar = view->verticalScrollbar();
+ if (scrollbar)
+ scrollbar->invalidate();
+ }
+}
+
+void WebFrameImpl::addMarker(Range* range, bool activeMatch)
+{
+ frame()->document()->markers()->addTextMatchMarker(range, activeMatch);
+}
+
+void WebFrameImpl::setMarkerActive(Range* range, bool active)
+{
+ if (!range || range->collapsed(IGNORE_EXCEPTION))
+ 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.
+ // The user may have closed the tab/application, so abort.
+ // Also ignore detached frames, as many find operations report to the main frame.
+ if (!frame() || !frame()->view() || !frame()->page() || !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_lastFindRequestCompletedWithNoMatches && !m_lastSearchString.isEmpty()) {
+ // 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)
+ return;
+
+ // 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::loadJavaScriptURL(const KURL& url)
+{
+ // This is copied from ScriptController::executeScriptIfJavaScriptURL.
+ // 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 (!frame()->document() || !frame()->page())
+ return;
+
+ RefPtr<Document> ownerDocument(frame()->document());
+
+ // Protect privileged pages against bookmarklets and other javascript manipulations.
+ if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()->document()->url().protocol()))
+ return;
+
+ String script = decodeURLEscapeSequences(url.string().substring(strlen("javascript:")));
+ ScriptValue result = frame()->script()->executeScript(script, true);
+
+ String scriptResult;
+ if (!result.getString(scriptResult))
+ return;
+
+ if (!frame()->navigationScheduler()->locationChangePending())
+ frame()->document()->loader()->replaceDocument(scriptResult, ownerDocument.get());
+}
+
+void WebFrameImpl::willDetachPage()
+{
+ if (!frame() || !frame()->page())
+ return;
+
+ // Do not expect string scoping results from any frames that got detached
+ // in the middle of the operation.
+ if (m_scopingInProgress) {
+
+ // There is a possibility that the frame being detached was the only
+ // pending one. We need to make sure final replies can be sent.
+ flushCurrentScopingEffort(m_findRequestIdentifier);
+
+ cancelPendingScopingEffort();
+ }
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebFrameImpl.h b/chromium/third_party/WebKit/Source/web/WebFrameImpl.h
new file mode 100644
index 00000000000..b6e0b419399
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebFrameImpl.h
@@ -0,0 +1,504 @@
+/*
+ * 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 "WebFrame.h"
+
+#include "FrameLoaderClientImpl.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameDestructionObserver.h"
+#include "core/platform/graphics/FloatRect.h"
+#include "public/platform/WebFileSystemType.h"
+#include "wtf/Compiler.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+class GraphicsContext;
+class HTMLInputElement;
+class HistoryItem;
+class IntSize;
+class KURL;
+class Node;
+class Range;
+class SubstituteData;
+struct FrameLoadRequest;
+struct WindowFeatures;
+}
+
+namespace WebKit {
+class ChromePrintContext;
+class WebDataSourceImpl;
+class WebInputElement;
+class WebFrameClient;
+class WebPerformance;
+class WebPluginContainerImpl;
+class WebView;
+class WebViewImpl;
+struct WebPrintParams;
+
+template <typename T> class WebVector;
+
+// Implementation of WebFrame, note that this is a reference counted object.
+class WebFrameImpl
+ : public WebFrame
+ , public RefCounted<WebFrameImpl>
+ , public WebCore::FrameDestructionObserver {
+public:
+ // WebFrame methods:
+ virtual WebString uniqueName() const;
+ virtual WebString assignedName() const;
+ virtual void setName(const WebString&);
+ virtual long long identifier() const;
+ virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const;
+ virtual WebSize scrollOffset() const;
+ virtual void setScrollOffset(const WebSize&);
+ virtual WebSize minimumScrollOffset() const;
+ virtual WebSize maximumScrollOffset() const;
+ virtual WebSize contentsSize() const;
+ virtual bool hasVisibleContent() const;
+ virtual WebRect visibleContentRect() const;
+ virtual bool hasHorizontalScrollbar() const;
+ virtual bool hasVerticalScrollbar() const;
+ virtual WebView* view() const;
+ virtual WebFrame* opener() const;
+ virtual void setOpener(const WebFrame*);
+ 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 WebPerformance performance() const;
+ virtual NPObject* windowObject() const;
+ virtual void bindToWindowObject(const WebString& name, NPObject*);
+ virtual void bindToWindowObject(const WebString& name, NPObject*, void*);
+ virtual void executeScript(const WebScriptSource&);
+ virtual void executeScriptInIsolatedWorld(
+ int worldID, const WebScriptSource* sources, unsigned numSources,
+ int extensionGroup);
+ virtual void setIsolatedWorldSecurityOrigin(int worldID, const WebSecurityOrigin&);
+ virtual void setIsolatedWorldContentSecurityPolicy(int worldID, const WebString&);
+ virtual void addMessageToConsole(const WebConsoleMessage&);
+ virtual void collectGarbage();
+ virtual bool checkIfRunInsecureContent(const WebURL&) const;
+ virtual v8::Handle<v8::Value> executeScriptAndReturnValue(
+ const WebScriptSource&);
+ virtual void executeScriptInIsolatedWorld(
+ int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
+ int extensionGroup, WebVector<v8::Local<v8::Value> >* results);
+ virtual v8::Handle<v8::Value> callFunctionEvenIfScriptDisabled(
+ v8::Handle<v8::Function>,
+ v8::Handle<v8::Object>,
+ int argc,
+ v8::Handle<v8::Value> argv[]);
+ virtual v8::Local<v8::Context> mainWorldScriptContext() const;
+ virtual v8::Handle<v8::Value> createFileSystem(WebFileSystemType,
+ const WebString& name,
+ const WebString& path);
+ virtual v8::Handle<v8::Value> createSerializableFileSystem(WebFileSystemType,
+ const WebString& name,
+ const WebString& path);
+ virtual v8::Handle<v8::Value> createFileEntry(WebFileSystemType,
+ const WebString& fileSystemName,
+ const WebString& fileSystemPath,
+ const WebString& filePath,
+ bool isDirectory);
+ virtual void reload(bool ignoreCache);
+ virtual void reloadWithOverrideURL(const WebURL& overrideUrl, 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(const WebURLLoaderOptions&);
+ virtual unsigned unloadListenerCount() 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 size_t characterIndexForPoint(const WebPoint&) const;
+ virtual bool executeCommand(const WebString&, const WebNode& = WebNode());
+ virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode());
+ virtual bool isCommandEnabled(const WebString&) const;
+ virtual void enableContinuousSpellChecking(bool);
+ virtual bool isContinuousSpellCheckingEnabled() const;
+ virtual void requestTextChecking(const WebElement&);
+ virtual void replaceMisspelledRange(const WebString&);
+ virtual void removeSpellingMarkers();
+ virtual bool hasSelection() const;
+ virtual WebRange selectionRange() const;
+ virtual WebString selectionAsText() const;
+ virtual WebString selectionAsMarkup() const;
+ virtual bool selectWordAroundCaret();
+ virtual void selectRange(const WebPoint& base, const WebPoint& extent);
+ virtual void selectRange(const WebRange&);
+ virtual void moveCaretSelectionTowardsWindowPoint(const WebPoint&);
+ virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent);
+ virtual void moveCaretSelection(const WebPoint&);
+ virtual void setCaretVisible(bool);
+ virtual int printBegin(const WebPrintParams&,
+ const WebNode& constrainToNode,
+ bool* useBrowserOverlays);
+ virtual float printPage(int pageToPrint, WebCanvas*);
+ virtual float getPrintPageShrink(int page);
+ virtual void printEnd();
+ virtual bool isPrintScalingDisabledForPlugin(const WebNode&);
+ virtual bool hasCustomPageSizeStyle(int pageIndex);
+ virtual bool isPageBoxVisible(int pageIndex);
+ virtual void pageSizeAndMarginsInPixels(int pageIndex,
+ WebSize& pageSize,
+ int& marginTop,
+ int& marginRight,
+ int& marginBottom,
+ int& marginLeft);
+ virtual WebString pageProperty(const WebString& propertyName, int pageIndex);
+ virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&);
+ 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 int findMatchMarkersVersion() const;
+ virtual WebFloatRect activeFindMatchRect();
+ virtual void findMatchRects(WebVector<WebFloatRect>&);
+ virtual int selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionRect);
+
+ virtual void sendOrientationChangeEvent(int orientation);
+
+ virtual void dispatchMessageEventWithOriginCheck(
+ const WebSecurityOrigin& intendedTargetOrigin,
+ const WebDOMEvent&);
+
+ virtual WebString contentAsText(size_t maxChars) const;
+ virtual WebString contentAsMarkup() const;
+ virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTextNormal) const;
+ virtual WebString markerTextForListItem(const WebElement&) const;
+ virtual WebRect selectionBoundsRect() const;
+
+ virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const;
+ virtual WebString layerTreeAsText(bool showDebugInfo = false) const;
+
+ // WebCore::FrameDestructionObserver methods.
+ virtual void willDetachPage();
+
+ static PassRefPtr<WebFrameImpl> create(WebFrameClient* client);
+ virtual ~WebFrameImpl();
+
+ // Called by the WebViewImpl to initialize the main frame for the page.
+ void initializeAsMainFrame(WebCore::Page*);
+
+ PassRefPtr<WebCore::Frame> createChildFrame(
+ const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*);
+
+ void didChangeContentsSize(const WebCore::IntSize&);
+
+ 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*);
+
+ // If the frame hosts a PluginDocument, this method returns the WebPluginContainerImpl
+ // that hosts the plugin. If the provided node is a plugin, then it runs its
+ // WebPluginContainerImpl.
+ static WebPluginContainerImpl* pluginContainerFromNode(WebCore::Frame*, const WebNode&);
+
+ WebViewImpl* viewImpl() const;
+
+ WebCore::FrameView* frameView() const { return frame() ? 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.
+ WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; }
+
+ // Returns the active match in the current frame. Could be a null range if
+ // the local frame has no active match.
+ WebCore::Range* activeMatch() const { return m_activeMatch.get(); }
+
+ // 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);
+
+ 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;
+
+ struct FindMatch {
+ RefPtr<WebCore::Range> m_range;
+
+ // 1-based index within this frame.
+ int m_ordinal;
+
+ // In find-in-page coordinates.
+ // Lazily calculated by updateFindMatchRects.
+ WebCore::FloatRect m_rect;
+
+ FindMatch(PassRefPtr<WebCore::Range>, int ordinal);
+ };
+
+ // 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.
+ };
+
+ explicit WebFrameImpl(WebFrameClient*);
+
+ // Sets the local WebCore frame and registers destruction observers.
+ void setWebCoreFrame(WebCore::Frame*);
+
+ // Notifies the delegate about a new selection rect.
+ void reportFindInPageSelection(
+ const WebRect& selectionRect, int activeMatchOrdinal, int identifier);
+
+ // Clear the find-in-page matches cache forcing rects to be fully
+ // calculated again next time updateFindMatchRects is called.
+ void clearFindMatchesCache();
+
+ // Check if the activeMatchFrame still exists in the frame tree.
+ bool isActiveMatchFrameValid() const;
+
+ // Return the index in the find-in-page cache of the match closest to the
+ // provided point in find-in-page coordinates, or -1 in case of error.
+ // The squared distance to the closest match is returned in the distanceSquared parameter.
+ int nearestFindMatch(const WebCore::FloatPoint&, float& distanceSquared);
+
+ // Select a find-in-page match marker in the current frame using a cache
+ // match index returned by nearestFindMatch. Returns the ordinal of the new
+ // selected match or -1 in case of error. Also provides the bounding box of
+ // the marker in window coordinates if selectionRect is not null.
+ int selectFindMatch(unsigned index, WebRect* selectionRect);
+
+ // Compute and cache the rects for FindMatches if required.
+ // Rects are automatically invalidated in case of content size changes,
+ // propagating the invalidation to child frames.
+ void updateFindMatchRects();
+
+ // Append the find-in-page match rects of the current frame to the provided vector.
+ void appendFindMatchRects(Vector<WebFloatRect>& frameRects);
+
+ // 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);
+
+ // Removes the current frame from the global scoping effort and triggers any
+ // updates if appropriate. This method does not mark the scoping operation
+ // as finished.
+ void flushCurrentScopingEffort(int identifier);
+
+ // Finishes the current scoping effort and triggers any updates if appropriate.
+ void finishCurrentScopingEffort(int identifier);
+
+ // 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();
+
+ void loadJavaScriptURL(const WebCore::KURL&);
+
+ // Returns a hit-tested VisiblePosition for the given point
+ WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&);
+
+ FrameLoaderClientImpl m_frameLoaderClient;
+
+ WebFrameClient* m_client;
+
+ // 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_currentActiveMatchFrame;
+
+ // The range of the active match for the current frame.
+ RefPtr<WebCore::Range> m_activeMatch;
+
+ // The index of the active match for the current frame.
+ int m_activeMatchIndexInCurrentFrame;
+
+ // 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) 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.
+ int 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;
+
+ // Identifier of the latest find-in-page request. Required to be stored in
+ // the frame in order to reply if required in case the frame is detached.
+ int m_findRequestIdentifier;
+
+ // Keeps track of whether there is an scoping effort ongoing in the frame.
+ bool m_scopingInProgress;
+
+ // Keeps track of whether the last find request completed its scoping effort
+ // without finding any matches in this frame.
+ bool m_lastFindRequestCompletedWithNoMatches;
+
+ // 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;
+
+ // Version number incremented on the main frame only whenever the document
+ // find-in-page match markers change. It should be 0 for all other frames.
+ int m_findMatchMarkersVersion;
+
+ // Local cache of the find match markers currently displayed for this frame.
+ Vector<FindMatch> m_findMatchesCache;
+
+ // Determines if the rects in the find-in-page matches cache of this frame
+ // are invalid and should be recomputed.
+ bool m_findMatchRectsAreValid;
+
+ // Contents size when find-in-page match rects were last computed for this
+ // frame's cache.
+ WebCore::IntSize m_contentsSizeForCurrentFindMatchRects;
+
+ // Valid between calls to BeginPrint() and EndPrint(). Containts the print
+ // information. Is used by PrintPage().
+ OwnPtr<ChromePrintContext> m_printContext;
+
+ // The identifier of this frame.
+ long long m_identifier;
+
+ // Ensure we don't overwrite valid history data during same document loads
+ // from HistoryItems
+ bool m_inSameDocumentHistoryLoad;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebGeolocationClientMock.cpp b/chromium/third_party/WebKit/Source/web/WebGeolocationClientMock.cpp
new file mode 100644
index 00000000000..fcef4e9328d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebGeolocationClientMock.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 "WebGeolocationClientMock.h"
+
+#include "WebGeolocationController.h"
+#include "WebGeolocationError.h"
+#include "WebGeolocationPermissionRequest.h"
+#include "WebGeolocationPosition.h"
+#include "core/platform/mock/GeolocationClientMock.h"
+#include "modules/geolocation/Geolocation.h"
+#include "modules/geolocation/GeolocationError.h"
+#include "modules/geolocation/GeolocationPosition.h"
+#include "modules/geolocation/PositionError.h"
+#include "public/platform/WebString.h"
+#include "wtf/CurrentTime.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::setPositionUnavailableError(const WebString& message)
+{
+ m_clientMock->setPositionUnavailableError(message);
+}
+
+void WebGeolocationClientMock::setPermission(bool allowed)
+{
+ m_clientMock->setPermission(allowed);
+}
+
+int WebGeolocationClientMock::numberOfPendingPermissionRequests() const
+{
+ return m_clientMock->numberOfPendingPermissionRequests();
+}
+
+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/chromium/third_party/WebKit/Source/web/WebGeolocationController.cpp b/chromium/third_party/WebKit/Source/web/WebGeolocationController.cpp
new file mode 100644
index 00000000000..9ea91d9580b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "WebGeolocationError.h"
+#include "WebGeolocationPosition.h"
+#include "modules/geolocation/GeolocationController.h"
+#include "modules/geolocation/GeolocationError.h"
+#include "modules/geolocation/GeolocationPosition.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/chromium/third_party/WebKit/Source/web/WebGeolocationError.cpp b/chromium/third_party/WebKit/Source/web/WebGeolocationError.cpp
new file mode 100644
index 00000000000..6284e68c1cd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "modules/geolocation/GeolocationError.h"
+#include "public/platform/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/chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequest.cpp b/chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequest.cpp
new file mode 100644
index 00000000000..49cd34db61d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequest.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "public/platform/WebURL.h"
+#include "WebSecurityOrigin.h"
+#include "core/dom/Document.h"
+#include "core/page/Frame.h"
+#include "modules/geolocation/Geolocation.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSecurityOrigin WebGeolocationPermissionRequest::securityOrigin() const
+{
+ return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin());
+}
+
+void WebGeolocationPermissionRequest::setIsAllowed(bool allowed)
+{
+ m_private->setIsAllowed(allowed);
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequestManager.cpp b/chromium/third_party/WebKit/Source/web/WebGeolocationPermissionRequestManager.cpp
new file mode 100644
index 00000000000..bee4a3c46bc
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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->value;
+ 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->value;
+ 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/chromium/third_party/WebKit/Source/web/WebGeolocationPosition.cpp b/chromium/third_party/WebKit/Source/web/WebGeolocationPosition.cpp
new file mode 100644
index 00000000000..e683f16ee72
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "modules/geolocation/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/chromium/third_party/WebKit/Source/web/WebGlyphCache.cpp b/chromium/third_party/WebKit/Source/web/WebGlyphCache.cpp
new file mode 100644
index 00000000000..12378026bd6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/platform/graphics/GlyphPageTreeNode.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+size_t WebGlyphCache::pageCount()
+{
+ return GlyphPageTreeNode::treeGlyphPageCount();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp b/chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp
new file mode 100644
index 00000000000..570d4b31050
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.cpp
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebHelperPluginImpl.h"
+
+#include "PageWidgetDelegate.h"
+#include "WebDocument.h"
+#include "WebFrameImpl.h"
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "WebWidgetClient.h"
+#include "core/dom/NodeList.h"
+#include "core/html/HTMLPlugInElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/EmptyClients.h"
+#include "core/page/FocusController.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#define addLiteral(literal, writer) writer->addData(literal, sizeof(literal) - 1)
+
+static inline void addString(const String& str, DocumentWriter* writer)
+{
+ CString str8 = str.utf8();
+ writer->addData(str8.data(), str8.length());
+}
+
+static void writeDocument(const String& pluginType, const WebDocument& hostDocument, WebCore::DocumentLoader* loader)
+{
+ // Give the new document the same URL as the hose document so that content
+ // settings and other decisions can be made based on the correct origin.
+ const WebURL& url = hostDocument.url();
+
+ DocumentWriter* writer = loader->beginWriting("text/html", "UTF-8", url);
+
+ addLiteral("<!DOCTYPE html><head><meta charset='UTF-8'></head><body>\n", writer);
+ String objectTag = "<object type=\"" + pluginType + "\"></object>";
+ addString(objectTag, writer);
+ addLiteral("</body>\n", writer);
+
+ loader->endWriting(writer);
+}
+
+class HelperPluginChromeClient : public EmptyChromeClient {
+ WTF_MAKE_NONCOPYABLE(HelperPluginChromeClient);
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ explicit HelperPluginChromeClient(WebHelperPluginImpl* widget)
+ : m_widget(widget)
+ {
+ ASSERT(m_widget->m_widgetClient);
+ }
+
+private:
+ virtual void closeWindowSoon() OVERRIDE
+ {
+ // This should never be called since the only way to close the
+ // invisible page is via closeHelperPlugin().
+ ASSERT_NOT_REACHED();
+ m_widget->closeHelperPlugin();
+ }
+
+ virtual void* webView() const OVERRIDE
+ {
+ return m_widget->m_webView;
+ }
+
+ WebHelperPluginImpl* m_widget;
+};
+
+// WebHelperPluginImpl ----------------------------------------------------------------
+
+WebHelperPluginImpl::WebHelperPluginImpl(WebWidgetClient* client)
+ : m_widgetClient(client)
+ , m_webView(0)
+{
+ ASSERT(client);
+}
+
+WebHelperPluginImpl::~WebHelperPluginImpl()
+{
+ ASSERT(!m_page);
+}
+
+bool WebHelperPluginImpl::initialize(const String& pluginType, const WebDocument& hostDocument, WebViewImpl* webView)
+{
+ ASSERT(webView);
+ m_webView = webView;
+
+ return initializePage(pluginType, hostDocument);
+}
+
+void WebHelperPluginImpl::closeHelperPlugin()
+{
+ if (m_page) {
+ m_page->clearPageGroup();
+ m_page->mainFrame()->loader()->stopAllLoaders();
+ m_page->mainFrame()->loader()->stopLoading();
+ }
+
+ // We must destroy the page now in case the host page is being destroyed, in
+ // which case some of the objects the page depends on may have been
+ // destroyed by the time this->close() is called asynchronously.
+ destroyPage();
+
+ // m_widgetClient might be 0 because this widget might be already closed.
+ if (m_widgetClient) {
+ // closeWidgetSoon() will call this->close() later.
+ m_widgetClient->closeWidgetSoon();
+ }
+}
+
+void WebHelperPluginImpl::initializeFrame(WebFrameClient* client)
+{
+ ASSERT(m_page);
+ RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client);
+ frame->initializeAsMainFrame(m_page.get());
+}
+
+// Returns a pointer to the WebPlugin by finding the single <object> tag in the page.
+WebPlugin* WebHelperPluginImpl::getPlugin()
+{
+ ASSERT(m_page);
+
+ RefPtr<NodeList> objectElements = m_page->mainFrame()->document()->getElementsByTagName(WebCore::HTMLNames::objectTag.localName());
+ ASSERT(objectElements && objectElements->length() == 1);
+ if (!objectElements || objectElements->length() < 1)
+ return 0;
+ Node* node = objectElements->item(0);
+ ASSERT(node->hasTagName(WebCore::HTMLNames::objectTag));
+ WebCore::Widget* widget = toHTMLPlugInElement(node)->pluginWidget();
+ if (!widget)
+ return 0;
+ WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(widget)->plugin();
+ ASSERT(plugin);
+ // If the plugin is a placeholder, it is not useful to the caller, and it
+ // could be replaced at any time. Therefore, do not return it.
+ if (plugin->isPlaceholder())
+ return 0;
+
+ // The plugin was instantiated and will outlive this object.
+ return plugin;
+}
+
+bool WebHelperPluginImpl::initializePage(const String& pluginType, const WebDocument& hostDocument)
+{
+ Page::PageClients pageClients;
+ fillWithEmptyClients(pageClients);
+ m_chromeClient = adoptPtr(new HelperPluginChromeClient(this));
+ pageClients.chromeClient = m_chromeClient.get();
+
+ m_page = adoptPtr(new Page(pageClients));
+ ASSERT(!m_page->settings()->isScriptEnabled());
+ m_page->settings()->setPluginsEnabled(true);
+
+ unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout;
+ m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones));
+
+ m_webView->client()->initializeHelperPluginWebFrame(this);
+
+ // The page's main frame was set in initializeFrame() as a result of the above call.
+ Frame* frame = m_page->mainFrame();
+ ASSERT(frame);
+ frame->loader()->forceSandboxFlags(SandboxAll & ~SandboxPlugins);
+ frame->setView(FrameView::create(frame));
+ // No need to set a size or make it not transparent.
+
+ writeDocument(pluginType, hostDocument, frame->loader()->activeDocumentLoader());
+
+ return true;
+}
+
+void WebHelperPluginImpl::destroyPage()
+{
+ if (!m_page)
+ return;
+
+ if (m_page->mainFrame())
+ m_page->mainFrame()->loader()->frameDetached();
+
+ m_page.clear();
+}
+
+void WebHelperPluginImpl::layout()
+{
+ PageWidgetDelegate::layout(m_page.get());
+}
+
+void WebHelperPluginImpl::setFocus(bool)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void WebHelperPluginImpl::close()
+{
+ ASSERT(!m_page); // Should only be called via closePopup().
+ m_widgetClient = 0;
+ deref();
+}
+
+// WebHelperPlugin ----------------------------------------------------------------
+
+WebHelperPlugin* WebHelperPlugin::create(WebWidgetClient* client)
+{
+ if (!client)
+ CRASH();
+ // A WebHelperPluginImpl instance usually has two references.
+ // - One owned by the instance itself. It represents the visible widget.
+ // - One owned by the hosting element. It's released when the hosting
+ // element asks the WebHelperPluginImpl to close.
+ // We need them because the closing operation is asynchronous and the widget
+ // can be closed while the hosting element is unaware of it.
+ return adoptRef(new WebHelperPluginImpl(client)).leakRef();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.h b/chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.h
new file mode 100644
index 00000000000..0b06b32aa19
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebHelperPluginImpl.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 WebHelperPluginImpl_h
+#define WebHelperPluginImpl_h
+
+#include "WebHelperPlugin.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+
+namespace WebCore {
+class Page;
+}
+
+namespace WebKit {
+
+class HelperPluginChromeClient;
+class WebDocument;
+class WebFrame;
+class WebViewImpl;
+class WebWidgetClient;
+
+// Hosts a simple page that instantiates a plugin using an <object> tag.
+// The widget is offscreen, and the plugin will not receive painting, resize, etc. events.
+class WebHelperPluginImpl : public WebHelperPlugin,
+ public RefCounted<WebHelperPluginImpl> {
+ WTF_MAKE_NONCOPYABLE(WebHelperPluginImpl);
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ virtual ~WebHelperPluginImpl();
+ bool initialize(const String& pluginType, const WebDocument& hostDocument, WebViewImpl*);
+ void closeHelperPlugin();
+
+ // WebHelperPlugin methods:
+ virtual void initializeFrame(WebFrameClient*) OVERRIDE;
+ virtual WebPlugin* getPlugin() OVERRIDE;
+
+private:
+ explicit WebHelperPluginImpl(WebWidgetClient*);
+ bool initializePage(const String& pluginType, const WebDocument& hostDocument);
+ void destroyPage();
+
+ // WebWidget methods:
+ virtual void layout() OVERRIDE;
+ virtual void setFocus(bool) OVERRIDE;
+ virtual void close() OVERRIDE;
+
+ WebWidgetClient* m_widgetClient;
+ WebViewImpl* m_webView;
+ OwnPtr<WebCore::Page> m_page;
+ OwnPtr<HelperPluginChromeClient> m_chromeClient;
+
+ friend class WebHelperPlugin;
+ friend class HelperPluginChromeClient;
+};
+
+} // namespace WebKit
+
+#endif // WebHelperPluginImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebHistoryItem.cpp b/chromium/third_party/WebKit/Source/web/WebHistoryItem.cpp
new file mode 100644
index 00000000000..823c679a877
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebHistoryItem.cpp
@@ -0,0 +1,346 @@
+/*
+ * 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 "WebSerializedScriptValue.h"
+#include "bindings/v8/SerializedScriptValue.h"
+#include "core/history/HistoryItem.h"
+#include "core/html/FormController.h"
+#include "core/platform/network/FormData.h"
+#include "public/platform/WebHTTPBody.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+#include "weborigin/KURL.h"
+#include "wtf/text/StringHash.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+namespace {
+
+void addReferencedFilePaths(HistoryItem* item, HashSet<String>& results)
+{
+ const FormData* formData = item->formData();
+ if (formData) {
+ for (size_t i = 0; i < formData->elements().size(); ++i) {
+ const FormDataElement& element = formData->elements()[i];
+ if (element.m_type == FormDataElement::encodedFile)
+ results.add(element.m_filename);
+ }
+ }
+
+ const Vector<String>& filePaths = FormController::getReferencedFilePaths(item->documentState());
+ for (size_t i = 0; i < filePaths.size(); ++i)
+ results.add(filePaths[i]);
+
+ const HistoryItemVector& children = item->children();
+ for (size_t i = 0; i < children.size(); ++i)
+ addReferencedFilePaths(children[i].get(), results);
+}
+
+} // namespace
+
+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);
+}
+
+float WebHistoryItem::pageScaleFactor() const
+{
+ return m_private->pageScaleFactor();
+}
+
+void WebHistoryItem::setPageScaleFactor(float scale)
+{
+ ensureMutable();
+ m_private->setPageScaleFactor(scale);
+}
+
+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);
+}
+
+WebVector<WebString> WebHistoryItem::getReferencedFilePaths() const
+{
+ HashSet<String> filePaths;
+ addReferencedFilePaths(m_private.get(), filePaths);
+
+ Vector<String> results;
+ copyToVector(filePaths, results);
+ return results;
+}
+
+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/chromium/third_party/WebKit/Source/web/WebHitTestResult.cpp b/chromium/third_party/WebKit/Source/web/WebHitTestResult.cpp
new file mode 100644
index 00000000000..44daec26f5b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebHitTestResult.cpp
@@ -0,0 +1,105 @@
+/*
+* Copyright (C) 2012 Google Inc. 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 "WebHitTestResult.h"
+
+#include "WebElement.h"
+#include "WebNode.h"
+#include "core/dom/Element.h"
+#include "core/dom/Node.h"
+#include "core/editing/VisiblePosition.h"
+#include "core/rendering/HitTestResult.h"
+#include "core/rendering/RenderObject.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebURL.h"
+#include "weborigin/KURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebNode WebHitTestResult::node() const
+{
+ return WebNode(m_private->innerNode());
+}
+
+WebPoint WebHitTestResult::localPoint() const
+{
+ return roundedIntPoint(m_private->localPoint());
+}
+
+WebElement WebHitTestResult::urlElement() const
+{
+ return WebElement(m_private->URLElement());
+}
+
+WebURL WebHitTestResult::absoluteImageURL() const
+{
+ return m_private->absoluteImageURL();
+}
+
+WebURL WebHitTestResult::absoluteLinkURL() const
+{
+ return m_private->absoluteLinkURL();
+}
+
+bool WebHitTestResult::isContentEditable() const
+{
+ return m_private->isContentEditable();
+}
+
+WebHitTestResult::WebHitTestResult(const HitTestResult& result)
+{
+ m_private.reset(new HitTestResult(result));
+}
+
+WebHitTestResult& WebHitTestResult::operator=(const HitTestResult& result)
+{
+ m_private.reset(new HitTestResult(result));
+ return *this;
+}
+
+WebHitTestResult::operator HitTestResult() const
+{
+ return *m_private.get();
+}
+
+bool WebHitTestResult::isNull() const
+{
+ return !m_private.get();
+}
+
+void WebHitTestResult::assign(const WebHitTestResult& info)
+{
+ m_private.reset(new HitTestResult(info));
+}
+
+void WebHitTestResult::reset()
+{
+ m_private.reset(0);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.cpp b/chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.cpp
new file mode 100644
index 00000000000..a66ede6075f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebData.h"
+#include "public/platform/WebIDBCallbacks.h"
+#include "public/platform/WebIDBDatabase.h"
+#include "public/platform/WebIDBDatabaseError.h"
+#include "public/platform/WebIDBKey.h"
+#include "IDBCursorBackendProxy.h"
+#include "IDBDatabaseBackendProxy.h"
+#include "core/dom/DOMError.h"
+#include "modules/indexeddb/IDBCallbacks.h"
+#include "modules/indexeddb/IDBKey.h"
+#include "modules/indexeddb/IDBMetadata.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBCallbacksImpl::WebIDBCallbacksImpl(PassRefPtr<IDBCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+}
+
+WebIDBCallbacksImpl::~WebIDBCallbacksImpl()
+{
+}
+
+void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error)
+{
+ m_callbacks->onError(error);
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList)
+{
+ Vector<String> stringList;
+ for (size_t i = 0; i < webStringList.size(); ++i)
+ stringList.append(webStringList[i]);
+ m_callbacks->onSuccess(stringList);
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key, const WebIDBKey& primaryKey, const WebData& value)
+{
+ m_callbacks->onSuccess(IDBCursorBackendProxy::create(adoptPtr(cursor)), key, primaryKey, value);
+}
+
+void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* webKitInstance, const WebIDBMetadata& metadata)
+{
+ if (m_databaseProxy) {
+ m_callbacks->onSuccess(m_databaseProxy.release(), metadata);
+ return;
+ }
+ RefPtr<IDBDatabaseBackendInterface> localDatabaseProxy = IDBDatabaseBackendProxy::create(adoptPtr(webKitInstance));
+ m_callbacks->onSuccess(localDatabaseProxy.release(), metadata);
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key)
+{
+ m_callbacks->onSuccess(key);
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebData& value)
+{
+ m_callbacks->onSuccess(value);
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebData& value, const WebIDBKey& key, const WebIDBKeyPath& keyPath)
+{
+ m_callbacks->onSuccess(value, key, keyPath);
+}
+
+void WebIDBCallbacksImpl::onSuccess(long long value)
+{
+ m_callbacks->onSuccess(value);
+}
+
+void WebIDBCallbacksImpl::onSuccess()
+{
+ m_callbacks->onSuccess();
+}
+
+void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& primaryKey, const WebData& value)
+{
+ m_callbacks->onSuccess(key, primaryKey, value);
+}
+
+void WebIDBCallbacksImpl::onBlocked(long long oldVersion)
+{
+ m_callbacks->onBlocked(oldVersion);
+}
+
+void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase* database, const WebIDBMetadata& metadata, DataLoss dataLoss)
+{
+ m_databaseProxy = IDBDatabaseBackendProxy::create(adoptPtr(database));
+ m_callbacks->onUpgradeNeeded(oldVersion, m_databaseProxy, metadata, dataLoss);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.h b/chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.h
new file mode 100644
index 00000000000..f90c9000b4e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBCallbacksImpl.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebIDBCallbacks.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+
+class IDBCallbacks;
+class IDBDatabaseBackendInterface;
+
+} // namespace WebCore
+
+namespace WebKit {
+
+class WebIDBCallbacksImpl : public WebIDBCallbacks {
+public:
+ WebIDBCallbacksImpl(PassRefPtr<WebCore::IDBCallbacks>);
+ virtual ~WebIDBCallbacksImpl();
+
+ virtual void onError(const WebIDBDatabaseError&);
+ virtual void onSuccess(const WebVector<WebString>&);
+ virtual void onSuccess(WebIDBCursor*, const WebIDBKey&, const WebIDBKey& primaryKey, const WebData&);
+ virtual void onSuccess(WebIDBDatabase*, const WebIDBMetadata&);
+ virtual void onSuccess(const WebIDBKey&);
+ virtual void onSuccess(const WebData&);
+ virtual void onSuccess(const WebData&, const WebIDBKey&, const WebIDBKeyPath&);
+ virtual void onSuccess(const WebIDBKey&, const WebIDBKey& primaryKey, const WebData&);
+ virtual void onSuccess(long long);
+ virtual void onSuccess();
+ virtual void onBlocked(long long oldVersion);
+ virtual void onUpgradeNeeded(long long oldVersion, WebIDBDatabase*, const WebIDBMetadata&, DataLoss);
+
+private:
+ RefPtr<WebCore::IDBCallbacks> m_callbacks;
+ RefPtr<WebCore::IDBDatabaseBackendInterface> m_databaseProxy;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBCallbacksImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.cpp b/chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.cpp
new file mode 100644
index 00000000000..b6e17584e8a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebIDBDatabaseCallbacksImpl.h"
+
+#include "core/dom/DOMError.h"
+#include "modules/indexeddb/IDBDatabaseCallbacks.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBDatabaseCallbacksImpl::WebIDBDatabaseCallbacksImpl(PassRefPtr<IDBDatabaseCallbacks> callbacks)
+ : m_callbacks(callbacks)
+{
+}
+
+WebIDBDatabaseCallbacksImpl::~WebIDBDatabaseCallbacksImpl()
+{
+}
+
+void WebIDBDatabaseCallbacksImpl::onForcedClose()
+{
+ m_callbacks->onForcedClose();
+}
+
+void WebIDBDatabaseCallbacksImpl::onVersionChange(long long oldVersion, long long newVersion)
+{
+ m_callbacks->onVersionChange(oldVersion, newVersion);
+}
+
+void WebIDBDatabaseCallbacksImpl::onAbort(long long transactionId, const WebIDBDatabaseError& error)
+{
+ m_callbacks->onAbort(transactionId, error);
+}
+
+void WebIDBDatabaseCallbacksImpl::onComplete(long long transactionId)
+{
+ m_callbacks->onComplete(transactionId);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.h b/chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.h
new file mode 100644
index 00000000000..8bd370ddcf0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBDatabaseCallbacksImpl.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 WebIDBDatabaseCallbacksImpl_h
+#define WebIDBDatabaseCallbacksImpl_h
+
+#include "public/platform/WebIDBDatabaseCallbacks.h"
+#include "public/platform/WebString.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore { class IDBDatabaseCallbacks; }
+
+namespace WebKit {
+
+class WebIDBDatabaseCallbacksImpl : public WebIDBDatabaseCallbacks {
+public:
+ WebIDBDatabaseCallbacksImpl(PassRefPtr<WebCore::IDBDatabaseCallbacks>);
+ virtual ~WebIDBDatabaseCallbacksImpl();
+
+ virtual void onForcedClose();
+ virtual void onVersionChange(long long oldVersion, long long newVersion);
+ virtual void onAbort(long long transactionId, const WebIDBDatabaseError&);
+ virtual void onComplete(long long transactionId);
+
+private:
+ RefPtr<WebCore::IDBDatabaseCallbacks> m_callbacks;
+};
+
+} // namespace WebKit
+
+#endif // WebIDBDatabaseCallbacksImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBDatabaseError.cpp b/chromium/third_party/WebKit/Source/web/WebIDBDatabaseError.cpp
new file mode 100644
index 00000000000..16855ae638a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBDatabaseError.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebIDBDatabaseError.h"
+
+#include "core/dom/DOMError.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebIDBDatabaseError::assign(const WebIDBDatabaseError& value)
+{
+ m_private = value.m_private;
+}
+
+void WebIDBDatabaseError::assign(unsigned short code)
+{
+ m_private = DOMError::create(code);
+}
+
+void WebIDBDatabaseError::assign(unsigned short code, const WebString& message)
+{
+ m_private = DOMError::create(code, message);
+}
+
+void WebIDBDatabaseError::reset()
+{
+ m_private.reset();
+}
+
+WebIDBDatabaseError::operator PassRefPtr<DOMError>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBKey.cpp b/chromium/third_party/WebKit/Source/web/WebIDBKey.cpp
new file mode 100644
index 00000000000..a9165b960a2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBKey.cpp
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebIDBKey.h"
+
+#include "modules/indexeddb/IDBKey.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBKey WebIDBKey::createArray(const WebVector<WebIDBKey>& array)
+{
+ WebIDBKey key;
+ key.assignArray(array);
+ 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::createNull()
+{
+ WebIDBKey key;
+ key.assignNull();
+ return key;
+}
+
+void WebIDBKey::assign(const WebIDBKey& value)
+{
+ m_private = value.m_private;
+}
+
+static PassRefPtr<IDBKey> convertFromWebIDBKeyArray(const WebVector<WebIDBKey>& array)
+{
+ IDBKey::KeyArray keys;
+ keys.reserveCapacity(array.size());
+ for (size_t i = 0; i < array.size(); ++i) {
+ switch (array[i].keyType()) {
+ case WebIDBKeyTypeArray:
+ keys.append(convertFromWebIDBKeyArray(array[i].array()));
+ break;
+ case WebIDBKeyTypeString:
+ keys.append(IDBKey::createString(array[i].string()));
+ break;
+ case WebIDBKeyTypeDate:
+ keys.append(IDBKey::createDate(array[i].date()));
+ break;
+ case WebIDBKeyTypeNumber:
+ keys.append(IDBKey::createNumber(array[i].number()));
+ break;
+ case WebIDBKeyTypeInvalid:
+ keys.append(IDBKey::createInvalid());
+ break;
+ case WebIDBKeyTypeNull:
+ case WebIDBKeyTypeMin:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+ return IDBKey::createArray(keys);
+}
+
+static void convertToWebIDBKeyArray(const IDBKey::KeyArray& array, WebVector<WebIDBKey>& result)
+{
+ WebVector<WebIDBKey> keys(array.size());
+ WebVector<WebIDBKey> subkeys;
+ for (size_t i = 0; i < array.size(); ++i) {
+ RefPtr<IDBKey> key = array[i];
+ switch (key->type()) {
+ case IDBKey::ArrayType:
+ convertToWebIDBKeyArray(key->array(), subkeys);
+ keys[i] = WebIDBKey::createArray(subkeys);
+ break;
+ case IDBKey::StringType:
+ keys[i] = WebIDBKey::createString(key->string());
+ break;
+ case IDBKey::DateType:
+ keys[i] = WebIDBKey::createDate(key->date());
+ break;
+ case IDBKey::NumberType:
+ keys[i] = WebIDBKey::createNumber(key->number());
+ break;
+ case IDBKey::InvalidType:
+ keys[i] = WebIDBKey::createInvalid();
+ break;
+ case IDBKey::MinType:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+ result.swap(keys);
+}
+
+void WebIDBKey::assignArray(const WebVector<WebIDBKey>& array)
+{
+ m_private = convertFromWebIDBKeyArray(array);
+}
+
+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 = IDBKey::createInvalid();
+}
+
+void WebIDBKey::assignNull()
+{
+ m_private = 0;
+}
+
+void WebIDBKey::reset()
+{
+ m_private.reset();
+}
+
+WebIDBKeyType WebIDBKey::keyType() const
+{
+ if (!m_private.get())
+ return WebIDBKeyTypeNull;
+ return static_cast<WebIDBKeyType>(m_private->type());
+}
+
+bool WebIDBKey::isValid() const
+{
+ if (!m_private.get())
+ return false;
+ return m_private->isValid();
+}
+
+WebVector<WebIDBKey> WebIDBKey::array() const
+{
+ WebVector<WebIDBKey> keys;
+ convertToWebIDBKeyArray(m_private->array(), keys);
+ return keys;
+}
+
+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
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBKeyPath.cpp b/chromium/third_party/WebKit/Source/web/WebIDBKeyPath.cpp
new file mode 100644
index 00000000000..a9db96ed803
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBKeyPath.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebIDBKeyPath.h"
+
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Vector.h"
+#include "modules/indexeddb/IDBKeyPath.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath)
+{
+ return WebIDBKeyPath(IDBKeyPath(keyPath));
+}
+
+WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>& keyPath)
+{
+ Vector<String> strings;
+ for (size_t i = 0; i < keyPath.size(); ++i)
+ strings.append(keyPath[i]);
+ return WebIDBKeyPath(IDBKeyPath(strings));
+}
+
+WebIDBKeyPath WebIDBKeyPath::createNull()
+{
+ return WebIDBKeyPath(IDBKeyPath());
+}
+
+void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath)
+{
+ ASSERT(keyPath.m_private.get());
+ m_private.reset(new IDBKeyPath(keyPath));
+}
+
+void WebIDBKeyPath::reset()
+{
+ m_private.reset(0);
+}
+
+bool WebIDBKeyPath::isValid() const
+{
+ ASSERT(m_private.get());
+ return m_private->isValid();
+}
+
+WebIDBKeyPathType WebIDBKeyPath::keyPathType() const
+{
+ ASSERT(m_private.get());
+ return static_cast<WebIDBKeyPathType>(m_private->type());
+}
+
+WebVector<WebString> WebIDBKeyPath::array() const
+{
+ ASSERT(m_private.get());
+ ASSERT(m_private->type() == IDBKeyPath::ArrayType);
+ return m_private->array();
+}
+
+WebString WebIDBKeyPath::string() const
+{
+ ASSERT(m_private.get());
+ ASSERT(m_private->type() == IDBKeyPath::StringType);
+ return m_private->string();
+}
+
+WebIDBKeyPath::WebIDBKeyPath(const WebCore::IDBKeyPath& value)
+ : m_private(new IDBKeyPath(value))
+{
+ ASSERT(m_private.get());
+}
+
+WebIDBKeyPath& WebIDBKeyPath::operator=(const WebCore::IDBKeyPath& value)
+{
+ ASSERT(m_private.get());
+ m_private.reset(new IDBKeyPath(value));
+ return *this;
+}
+
+WebIDBKeyPath::operator const WebCore::IDBKeyPath&() const
+{
+ ASSERT(m_private.get());
+ return *(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebIDBKeyRange.cpp b/chromium/third_party/WebKit/Source/web/WebIDBKeyRange.cpp
new file mode 100644
index 00000000000..0e46f0329b4
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBKeyRange.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebIDBKeyRange.h"
+
+#include "public/platform/WebIDBKey.h"
+#include "modules/indexeddb/IDBKey.h"
+#include "modules/indexeddb/IDBKeyRange.h"
+
+using namespace WebCore;
+
+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.isValid() && !upper.isValid())
+ m_private = 0;
+ else
+ m_private = IDBKeyRange::create(lower, upper, lowerOpen ? IDBKeyRange::LowerBoundOpen : IDBKeyRange::LowerBoundClosed, upperOpen ? IDBKeyRange::UpperBoundOpen : IDBKeyRange::UpperBoundClosed);
+}
+
+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/chromium/third_party/WebKit/Source/web/WebIDBMetadata.cpp b/chromium/third_party/WebKit/Source/web/WebIDBMetadata.cpp
new file mode 100644
index 00000000000..c47fc145253
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebIDBMetadata.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "public/platform/WebIDBMetadata.h"
+
+#include "public/platform/WebIDBKeyPath.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+#include "modules/indexeddb/IDBMetadata.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebIDBMetadata::WebIDBMetadata(const WebCore::IDBDatabaseMetadata& metadata)
+{
+ name = metadata.name;
+ version = metadata.version;
+ intVersion = metadata.intVersion;
+ objectStores = WebVector<ObjectStore>(static_cast<size_t>(metadata.objectStores.size()));
+ maxObjectStoreId = metadata.maxObjectStoreId;
+
+ size_t i = 0;
+ for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator storeIterator = metadata.objectStores.begin(); storeIterator != metadata.objectStores.end(); ++storeIterator) {
+ const IDBObjectStoreMetadata& objectStore = storeIterator->value;
+ ObjectStore webObjectStore;
+ webObjectStore.id = objectStore.id;
+ webObjectStore.name = objectStore.name;
+ webObjectStore.keyPath = objectStore.keyPath;
+ webObjectStore.autoIncrement = objectStore.autoIncrement;
+ webObjectStore.indexes = WebVector<Index>(static_cast<size_t>(objectStore.indexes.size()));
+ webObjectStore.maxIndexId = objectStore.maxIndexId;
+
+ size_t j = 0;
+ for (IDBObjectStoreMetadata::IndexMap::const_iterator indexIterator = objectStore.indexes.begin(); indexIterator != objectStore.indexes.end(); ++indexIterator) {
+ const IDBIndexMetadata& index = indexIterator->value;
+ Index webIndex;
+ webIndex.id = index.id;
+ webIndex.name = index.name;
+ webIndex.keyPath = index.keyPath;
+ webIndex.unique = index.unique;
+ webIndex.multiEntry = index.multiEntry;
+ webObjectStore.indexes[j++] = webIndex;
+ }
+ objectStores[i++] = webObjectStore;
+ }
+}
+
+WebIDBMetadata::operator IDBDatabaseMetadata() const
+{
+ IDBDatabaseMetadata db(name, id, version, intVersion, maxObjectStoreId);
+ for (size_t i = 0; i < objectStores.size(); ++i) {
+ const ObjectStore webObjectStore = objectStores[i];
+ IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.id, webObjectStore.keyPath, webObjectStore.autoIncrement, webObjectStore.maxIndexId);
+
+ for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) {
+ const Index webIndex = webObjectStore.indexes[j];
+ IDBIndexMetadata index(webIndex.name, webIndex.id, webIndex.keyPath, webIndex.unique, webIndex.multiEntry);
+ objectStore.indexes.set(index.id, index);
+ }
+ db.objectStores.set(objectStore.id, objectStore);
+ }
+ return db;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebImageCache.cpp b/chromium/third_party/WebKit/Source/web/WebImageCache.cpp
new file mode 100644
index 00000000000..e01762e7016
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebImageCache.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebImageCache.h"
+
+#include "core/platform/graphics/chromium/ImageDecodingStore.h"
+
+using WebCore::ImageDecodingStore;
+
+namespace WebKit {
+
+void WebImageCache::setCacheLimitInBytes(size_t size)
+{
+ ImageDecodingStore::instance()->setCacheLimitInBytes(size);
+}
+
+void WebImageCache::clear()
+{
+ ImageDecodingStore::instance()->clear();
+}
+
+size_t WebImageCache::memoryUsageInBytes()
+{
+ return ImageDecodingStore::instance()->memoryUsageInBytes();
+}
+
+unsigned WebImageCache::cacheEntries()
+{
+ return ImageDecodingStore::instance()->cacheEntries();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebImageDecoder.cpp b/chromium/third_party/WebKit/Source/web/WebImageDecoder.cpp
new file mode 100644
index 00000000000..43262faa6de
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebImageDecoder.cpp
@@ -0,0 +1,115 @@
+/*
+ * 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 "core/platform/SharedBuffer.h"
+#include "core/platform/image-decoders/bmp/BMPImageDecoder.h"
+#include "core/platform/image-decoders/ico/ICOImageDecoder.h"
+#include "wtf/CPU.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "public/platform/WebData.h"
+#include "public/platform/WebImage.h"
+#include "public/platform/WebSize.h"
+
+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();
+ RefPtr<NativeImageSkia> image = frameBuffer->asNewNativeImage();
+ return WebImage(image->bitmap());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebImageSkia.cpp b/chromium/third_party/WebKit/Source/web/WebImageSkia.cpp
new file mode 100644
index 00000000000..b6ba42d1486
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebImageSkia.cpp
@@ -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.
+ */
+
+#include "config.h"
+
+#include <algorithm>
+#include "core/platform/SharedBuffer.h"
+#include "core/platform/graphics/Image.h"
+#include "core/platform/graphics/skia/NativeImageSkia.h"
+#include "core/platform/image-decoders/ImageDecoder.h"
+#include "public/platform/WebData.h"
+#include "public/platform/WebImage.h"
+#include "public/platform/WebSize.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/Vector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize)
+{
+ RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data);
+ OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileIgnored));
+ if (!decoder)
+ return WebImage();
+
+ decoder->setData(buffer.get(), true);
+ if (!decoder->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 = decoder->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 = decoder->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;
+ }
+ }
+
+ ImageFrame* frame = decoder->frameBufferAtIndex(index);
+ if (!frame)
+ return WebImage();
+
+ RefPtr<NativeImageSkia> image = frame->asNewNativeImage();
+ if (!image)
+ return WebImage();
+
+ return WebImage(image->bitmap());
+}
+
+WebVector<WebImage> WebImage::framesFromData(const WebData& data)
+{
+ // This is to protect from malicious images. It should be big enough that it's never hit in pracice.
+ const size_t maxFrameCount = 8;
+
+ RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data);
+ OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileIgnored));
+ if (!decoder)
+ return WebVector<WebImage>();
+
+ decoder->setData(buffer.get(), true);
+ if (!decoder->isSizeAvailable())
+ return WebVector<WebImage>();
+
+ // Frames are arranged by decreasing size, then decreasing bit depth.
+ // Keep the first frame at every size, has the highest bit depth.
+ const size_t frameCount = decoder->frameCount();
+ IntSize lastSize;
+
+ Vector<WebImage> frames;
+ for (size_t i = 0; i < std::min(frameCount, maxFrameCount); ++i) {
+ const IntSize frameSize = decoder->frameSizeAtIndex(i);
+ if (frameSize == lastSize)
+ continue;
+ lastSize = frameSize;
+
+ ImageFrame* frame = decoder->frameBufferAtIndex(i);
+ if (!frame)
+ continue;
+
+ RefPtr<NativeImageSkia> image = frame->asNewNativeImage();
+ if (image && image->isDataComplete())
+ frames.append(WebImage(image->bitmap()));
+ }
+
+ return frames;
+}
+
+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)
+{
+ RefPtr<NativeImageSkia> p;
+ if (image && (p = image->nativeImageForCurrentFrame()))
+ assign(p->bitmap());
+ else
+ reset();
+ return *this;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebInputElement.cpp b/chromium/third_party/WebKit/Source/web/WebInputElement.cpp
new file mode 100644
index 00000000000..fe5de58f935
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebInputElement.cpp
@@ -0,0 +1,287 @@
+/*
+ * 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 "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
+#include "WebNodeCollection.h"
+#include "core/dom/NodeTraversal.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/html/HTMLDataListElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/shadow/TextControlInnerElements.h"
+#include "public/platform/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::isRadioButton() const
+{
+ return constUnwrap<HTMLInputElement>()->isRadioButton();
+}
+
+bool WebInputElement::isCheckbox() const
+{
+ return constUnwrap<HTMLInputElement>()->isCheckbox();
+}
+
+bool WebInputElement::autoComplete() const
+{
+ return constUnwrap<HTMLInputElement>()->shouldAutocomplete();
+}
+
+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 ? DispatchChangeEvent : DispatchNoEvent);
+}
+
+WebString WebInputElement::value() const
+{
+ return constUnwrap<HTMLInputElement>()->value();
+}
+
+WebString WebInputElement::editingValue() const
+{
+ return constUnwrap<HTMLInputElement>()->innerTextValue();
+}
+
+void WebInputElement::setEditingValue(const WebString& value)
+{
+ unwrap<HTMLInputElement>()->setEditingValue(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>()->setAttribute(HTMLNames::placeholderAttr, value);
+}
+
+WebString WebInputElement::placeholder() const
+{
+ return constUnwrap<HTMLInputElement>()->fastGetAttribute(HTMLNames::placeholderAttr);
+}
+
+bool WebInputElement::isAutofilled() const
+{
+ return constUnwrap<HTMLInputElement>()->isAutofilled();
+}
+
+void WebInputElement::setAutofilled(bool autofilled)
+{
+ unwrap<HTMLInputElement>()->setAutofilled(autofilled);
+}
+
+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);
+}
+
+void WebInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
+{
+ unwrap<HTMLInputElement>()->setChecked(nowChecked, sendChangeEvent ? DispatchChangeEvent : DispatchNoEvent);
+}
+
+bool WebInputElement::isChecked() const
+{
+ return constUnwrap<HTMLInputElement>()->checked();
+}
+
+bool WebInputElement::isMultiple() const
+{
+ return constUnwrap<HTMLInputElement>()->multiple();
+}
+
+WebNodeCollection WebInputElement::dataListOptions() const
+{
+ if (RuntimeEnabledFeatures::dataListElementEnabled()) {
+ HTMLDataListElement* dataList = static_cast<HTMLDataListElement*>(constUnwrap<HTMLInputElement>()->list());
+ if (dataList)
+ return WebNodeCollection(dataList->options());
+ }
+ return WebNodeCollection();
+}
+
+WebString WebInputElement::localizeValue(const WebString& proposedValue) const
+{
+ return constUnwrap<HTMLInputElement>()->localizeValue(proposedValue);
+}
+
+bool WebInputElement::isSpeechInputEnabled() const
+{
+#if ENABLE(INPUT_SPEECH)
+ return constUnwrap<HTMLInputElement>()->isSpeechEnabled();
+#else
+ return false;
+#endif
+}
+
+WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const
+{
+#if ENABLE(INPUT_SPEECH)
+ InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
+ if (speechButton)
+ return static_cast<WebInputElement::SpeechInputState>(speechButton->state());
+#endif
+
+ return Idle;
+}
+
+void WebInputElement::startSpeechInput()
+{
+#if ENABLE(INPUT_SPEECH)
+ InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
+ if (speechButton)
+ speechButton->startSpeechInput();
+#endif
+}
+
+void WebInputElement::stopSpeechInput()
+{
+#if ENABLE(INPUT_SPEECH)
+ InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
+ if (speechButton)
+ speechButton->stopSpeechInput();
+#endif
+}
+
+int WebInputElement::defaultMaxLength()
+{
+ return HTMLInputElement::maximumLength;
+}
+
+WebString WebInputElement::directionForFormData() const
+{
+ return constUnwrap<HTMLInputElement>()->directionForFormData();
+}
+
+// FIXME: Remove this once password_generation_manager.h stops using it.
+WebElement WebInputElement::decorationElementFor(void*)
+{
+ return passwordGeneratorButtonElement();
+}
+
+WebElement WebInputElement::passwordGeneratorButtonElement() const
+{
+ return WebElement(constUnwrap<HTMLInputElement>()->passwordGeneratorButtonElement());
+}
+
+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 toHTMLInputElement(m_private.get());
+}
+
+WebInputElement* toWebInputElement(WebElement* webElement)
+{
+ if (!webElement->unwrap<Element>()->hasTagName(HTMLNames::inputTag))
+ return 0;
+
+ return static_cast<WebInputElement*>(webElement);
+}
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebInputEvent.cpp b/chromium/third_party/WebKit/Source/web/WebInputEvent.cpp
new file mode 100644
index 00000000000..5b810249b19
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebInputEvent.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 "WebInputEvent.h"
+
+#include <ctype.h>
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "wtf/Assertions.h"
+#include "wtf/StringExtras.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+struct SameSizeAsWebInputEvent {
+ int inputData[5];
+};
+
+struct SameSizeAsWebKeyboardEvent : public SameSizeAsWebInputEvent {
+ int keyboardData[12];
+};
+
+struct SameSizeAsWebMouseEvent : public SameSizeAsWebInputEvent {
+ int mouseData[10];
+};
+
+struct SameSizeAsWebMouseWheelEvent : public SameSizeAsWebMouseEvent {
+ int mousewheelData[10];
+};
+
+struct SameSizeAsWebGestureEvent : public SameSizeAsWebInputEvent {
+ int gestureData[9];
+};
+
+struct SameSizeAsWebTouchEvent : public SameSizeAsWebInputEvent {
+ WebTouchPoint touchPoints[3 * WebTouchEvent::touchesLengthCap];
+ int touchData[3];
+};
+
+COMPILE_ASSERT(sizeof(WebInputEvent) == sizeof(SameSizeAsWebInputEvent), WebInputEvent_has_gaps);
+COMPILE_ASSERT(sizeof(WebKeyboardEvent) == sizeof(SameSizeAsWebKeyboardEvent), WebKeyboardEvent_has_gaps);
+COMPILE_ASSERT(sizeof(WebMouseEvent) == sizeof(SameSizeAsWebMouseEvent), WebMouseEvent_has_gaps);
+COMPILE_ASSERT(sizeof(WebMouseWheelEvent) == sizeof(SameSizeAsWebMouseWheelEvent), WebMouseWheelEvent_has_gaps);
+COMPILE_ASSERT(sizeof(WebGestureEvent) == sizeof(SameSizeAsWebGestureEvent), WebGestureEvent_has_gaps);
+COMPILE_ASSERT(sizeof(WebTouchEvent) == sizeof(SameSizeAsWebTouchEvent), WebTouchEvent_has_gaps);
+
+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.
+ case VKEY_MEDIA_NEXT_TRACK:
+ return "MediaNextTrack";
+ case VKEY_MEDIA_PREV_TRACK:
+ return "MediaPreviousTrack";
+ case VKEY_MEDIA_STOP:
+ return "MediaStop";
+ case VKEY_MEDIA_PLAY_PAUSE:
+ return "MediaPlayPause";
+ case VKEY_VOLUME_MUTE:
+ return "VolumeMute";
+ case VKEY_VOLUME_DOWN:
+ return "VolumeDown";
+ case VKEY_VOLUME_UP:
+ return "VolumeUp";
+ 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));
+}
+
+// static
+int WebKeyboardEvent::windowsKeyCodeWithoutLocation(int keycode)
+{
+ switch (keycode) {
+ case VK_LCONTROL:
+ case VK_RCONTROL:
+ return VK_CONTROL;
+ case VK_LSHIFT:
+ case VK_RSHIFT:
+ return VK_SHIFT;
+ case VK_LMENU:
+ case VK_RMENU:
+ return VK_MENU;
+ default:
+ return keycode;
+ }
+}
+
+// static
+int WebKeyboardEvent::locationModifiersFromWindowsKeyCode(int keycode)
+{
+ switch (keycode) {
+ case VK_LCONTROL:
+ case VK_LSHIFT:
+ case VK_LMENU:
+ case VK_LWIN:
+ return IsLeft;
+ case VK_RCONTROL:
+ case VK_RSHIFT:
+ case VK_RMENU:
+ case VK_RWIN:
+ return IsRight;
+ default:
+ return 0;
+ }
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebInputEventConversion.cpp b/chromium/third_party/WebKit/Source/web/WebInputEventConversion.cpp
new file mode 100644
index 00000000000..c2735f78667
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebInputEventConversion.cpp
@@ -0,0 +1,748 @@
+/*
+ * 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 "WebInputEvent.h"
+#include "core/dom/EventNames.h"
+#include "core/dom/GestureEvent.h"
+#include "core/dom/KeyboardEvent.h"
+#include "core/dom/MouseEvent.h"
+#include "core/dom/Touch.h"
+#include "core/dom/TouchEvent.h"
+#include "core/dom/TouchList.h"
+#include "core/dom/WheelEvent.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/PlatformMouseEvent.h"
+#include "core/platform/PlatformWheelEvent.h"
+#include "core/platform/ScrollView.h"
+#include "core/platform/Widget.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "core/rendering/RenderObject.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const double millisPerSecond = 1000.0;
+
+static float widgetScaleFactor(const Widget* widget)
+{
+ if (!widget)
+ return 1;
+
+ ScrollView* rootView = widget->root();
+ if (!rootView)
+ return 1;
+
+ return rootView->visibleContentScaleFactor();
+}
+
+// MakePlatformMouseEvent -----------------------------------------------------
+
+PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e)
+{
+ float scale = widgetScaleFactor(widget);
+ // 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 / scale, e.y / scale));
+ m_globalPosition = IntPoint(e.globalX, e.globalY);
+ m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale);
+ m_button = static_cast<MouseButton>(e.button);
+
+ m_modifiers = 0;
+ if (e.modifiers & WebInputEvent::ShiftKey)
+ m_modifiers |= PlatformEvent::ShiftKey;
+ if (e.modifiers & WebInputEvent::ControlKey)
+ m_modifiers |= PlatformEvent::CtrlKey;
+ if (e.modifiers & WebInputEvent::AltKey)
+ m_modifiers |= PlatformEvent::AltKey;
+ if (e.modifiers & WebInputEvent::MetaKey)
+ m_modifiers |= PlatformEvent::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_type = PlatformEvent::MouseMoved;
+ break;
+
+ case WebInputEvent::MouseDown:
+ m_type = PlatformEvent::MousePressed;
+ break;
+
+ case WebInputEvent::MouseUp:
+ m_type = PlatformEvent::MouseReleased;
+ break;
+
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+// PlatformWheelEventBuilder --------------------------------------------------
+
+PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e)
+{
+ float scale = widgetScaleFactor(widget);
+ m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
+ m_globalPosition = IntPoint(e.globalX, e.globalY);
+ m_deltaX = e.deltaX;
+ m_deltaY = e.deltaY;
+ m_wheelTicksX = e.wheelTicksX;
+ m_wheelTicksY = e.wheelTicksY;
+ m_granularity = e.scrollByPage ?
+ ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
+
+ m_type = PlatformEvent::Wheel;
+
+ m_modifiers = 0;
+ if (e.modifiers & WebInputEvent::ShiftKey)
+ m_modifiers |= PlatformEvent::ShiftKey;
+ if (e.modifiers & WebInputEvent::ControlKey)
+ m_modifiers |= PlatformEvent::CtrlKey;
+ if (e.modifiers & WebInputEvent::AltKey)
+ m_modifiers |= PlatformEvent::AltKey;
+ if (e.modifiers & WebInputEvent::MetaKey)
+ m_modifiers |= PlatformEvent::MetaKey;
+
+ m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
+#if OS(DARWIN)
+ m_phase = static_cast<WebCore::PlatformWheelEventPhase>(e.phase);
+ m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(e.momentumPhase);
+ m_timestamp = e.timeStampSeconds;
+ m_scrollCount = 0;
+ m_unacceleratedScrollingDeltaX = e.deltaX;
+ m_unacceleratedScrollingDeltaY = e.deltaY;
+#endif
+}
+
+// PlatformGestureEventBuilder --------------------------------------------------
+
+PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const WebGestureEvent& e)
+{
+ float scale = widgetScaleFactor(widget);
+ switch (e.type) {
+ case WebInputEvent::GestureScrollBegin:
+ m_type = PlatformEvent::GestureScrollBegin;
+ break;
+ case WebInputEvent::GestureScrollEnd:
+ m_type = PlatformEvent::GestureScrollEnd;
+ break;
+ case WebInputEvent::GestureScrollUpdate:
+ m_type = PlatformEvent::GestureScrollUpdate;
+ m_deltaX = e.data.scrollUpdate.deltaX / scale;
+ m_deltaY = e.data.scrollUpdate.deltaY / scale;
+ break;
+ case WebInputEvent::GestureScrollUpdateWithoutPropagation:
+ m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation;
+ m_deltaX = e.data.scrollUpdate.deltaX / scale;
+ m_deltaY = e.data.scrollUpdate.deltaY / scale;
+ break;
+ case WebInputEvent::GestureTap:
+ m_type = PlatformEvent::GestureTap;
+ m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale));
+ // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
+ m_deltaX = static_cast<int>(e.data.tap.tapCount);
+ break;
+ case WebInputEvent::GestureTapUnconfirmed:
+ m_type = PlatformEvent::GestureTapUnconfirmed;
+ m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale));
+ break;
+ case WebInputEvent::GestureTapDown:
+ m_type = PlatformEvent::GestureTapDown;
+ m_area = expandedIntSize(FloatSize(e.data.tapDown.width / scale, e.data.tapDown.height / scale));
+ break;
+ case WebInputEvent::GestureTapCancel:
+ m_type = PlatformEvent::GestureTapDownCancel;
+ break;
+ case WebInputEvent::GestureDoubleTap:
+ // DoubleTap gesture is now handled as PlatformEvent::GestureTap with tap_count = 2. So no
+ // need to convert to a Platfrom DoubleTap gesture. But in WebViewImpl::handleGestureEvent
+ // all WebGestureEvent are converted to PlatformGestureEvent, for completeness and not reach
+ // the ASSERT_NOT_REACHED() at the end, convert the DoubleTap to a NoType.
+ m_type = PlatformEvent::NoType;
+ break;
+ case WebInputEvent::GestureTwoFingerTap:
+ m_type = PlatformEvent::GestureTwoFingerTap;
+ m_area = expandedIntSize(FloatSize(e.data.twoFingerTap.firstFingerWidth / scale, e.data.twoFingerTap.firstFingerHeight / scale));
+ break;
+ case WebInputEvent::GestureLongPress:
+ m_type = PlatformEvent::GestureLongPress;
+ m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale));
+ break;
+ case WebInputEvent::GestureLongTap:
+ m_type = PlatformEvent::GestureLongTap;
+ m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale));
+ break;
+ case WebInputEvent::GesturePinchBegin:
+ m_type = PlatformEvent::GesturePinchBegin;
+ break;
+ case WebInputEvent::GesturePinchEnd:
+ m_type = PlatformEvent::GesturePinchEnd;
+ break;
+ case WebInputEvent::GesturePinchUpdate:
+ m_type = PlatformEvent::GesturePinchUpdate;
+ // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
+ m_deltaX = e.data.pinchUpdate.scale;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
+ m_globalPosition = IntPoint(e.globalX, e.globalY);
+ m_timestamp = e.timeStampSeconds;
+
+ m_modifiers = 0;
+ if (e.modifiers & WebInputEvent::ShiftKey)
+ m_modifiers |= PlatformEvent::ShiftKey;
+ if (e.modifiers & WebInputEvent::ControlKey)
+ m_modifiers |= PlatformEvent::CtrlKey;
+ if (e.modifiers & WebInputEvent::AltKey)
+ m_modifiers |= PlatformEvent::AltKey;
+ if (e.modifiers & WebInputEvent::MetaKey)
+ m_modifiers |= PlatformEvent::MetaKey;
+}
+
+// MakePlatformKeyboardEvent --------------------------------------------------
+
+inline PlatformEvent::Type toPlatformKeyboardEventType(WebInputEvent::Type type)
+{
+ switch (type) {
+ case WebInputEvent::KeyUp:
+ return PlatformEvent::KeyUp;
+ case WebInputEvent::KeyDown:
+ return PlatformEvent::KeyDown;
+ case WebInputEvent::RawKeyDown:
+ return PlatformEvent::RawKeyDown;
+ case WebInputEvent::Char:
+ return PlatformEvent::Char;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return PlatformEvent::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_nativeVirtualKeyCode = e.nativeKeyCode;
+ m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad);
+ m_isSystemKey = e.isSystemKey;
+
+ m_modifiers = 0;
+ if (e.modifiers & WebInputEvent::ShiftKey)
+ m_modifiers |= PlatformEvent::ShiftKey;
+ if (e.modifiers & WebInputEvent::ControlKey)
+ m_modifiers |= PlatformEvent::CtrlKey;
+ if (e.modifiers & WebInputEvent::AltKey)
+ m_modifiers |= PlatformEvent::AltKey;
+ if (e.modifiers & WebInputEvent::MetaKey)
+ m_modifiers |= PlatformEvent::MetaKey;
+
+ // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT
+ // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately,
+ // as in other places in the code.
+ m_windowsVirtualKeyCode = e.windowsKeyCode;
+ if (e.windowsKeyCode == VK_SHIFT) {
+ if (e.modifiers & WebInputEvent::IsLeft)
+ m_windowsVirtualKeyCode = VK_LSHIFT;
+ else if (e.modifiers & WebInputEvent::IsRight)
+ m_windowsVirtualKeyCode = VK_RSHIFT;
+ } else if (e.windowsKeyCode == VK_CONTROL) {
+ if (e.modifiers & WebInputEvent::IsLeft)
+ m_windowsVirtualKeyCode = VK_LCONTROL;
+ else if (e.modifiers & WebInputEvent::IsRight)
+ m_windowsVirtualKeyCode = VK_RCONTROL;
+ } else if (e.windowsKeyCode == VK_MENU) {
+ if (e.modifiers & WebInputEvent::IsLeft)
+ m_windowsVirtualKeyCode = VK_LMENU;
+ else if (e.modifiers & WebInputEvent::IsRight)
+ m_windowsVirtualKeyCode = VK_RMENU;
+ }
+
+}
+
+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;
+}
+
+inline PlatformEvent::Type toPlatformTouchEventType(const WebInputEvent::Type type)
+{
+ switch (type) {
+ case WebInputEvent::TouchStart:
+ return PlatformEvent::TouchStart;
+ case WebInputEvent::TouchMove:
+ return PlatformEvent::TouchMove;
+ case WebInputEvent::TouchEnd:
+ return PlatformEvent::TouchEnd;
+ case WebInputEvent::TouchCancel:
+ return PlatformEvent::TouchCancel;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return PlatformEvent::TouchStart;
+}
+
+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;
+}
+
+inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type)
+{
+ if (type == eventNames().touchendEvent)
+ return WebTouchPoint::StateReleased;
+ if (type == eventNames().touchcancelEvent)
+ return WebTouchPoint::StateCancelled;
+ if (type == eventNames().touchstartEvent)
+ return WebTouchPoint::StatePressed;
+ if (type == eventNames().touchmoveEvent)
+ return WebTouchPoint::StateMoved;
+ return WebTouchPoint::StateUndefined;
+}
+
+PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point)
+{
+ float scale = widgetScaleFactor(widget);
+ m_id = point.id;
+ m_state = toPlatformTouchPointState(point.state);
+ m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scale, point.position.y / scale));
+ m_screenPos = point.screenPosition;
+ m_radiusY = point.radiusY / scale;
+ m_radiusX = point.radiusX / scale;
+ m_rotationAngle = point.rotationAngle;
+ m_force = point.force;
+}
+
+PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTouchEvent& event)
+{
+ m_type = toPlatformTouchEventType(event.type);
+
+ m_modifiers = 0;
+ if (event.modifiers & WebInputEvent::ShiftKey)
+ m_modifiers |= PlatformEvent::ShiftKey;
+ if (event.modifiers & WebInputEvent::ControlKey)
+ m_modifiers |= PlatformEvent::CtrlKey;
+ if (event.modifiers & WebInputEvent::AltKey)
+ m_modifiers |= PlatformEvent::AltKey;
+ if (event.modifiers & WebInputEvent::MetaKey)
+ m_modifiers |= PlatformEvent::MetaKey;
+
+ m_timestamp = event.timeStampSeconds;
+
+ for (unsigned i = 0; i < event.touchesLength; ++i)
+ m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i]));
+}
+
+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;
+}
+
+static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& location, const WebCore::RenderObject& renderObject)
+{
+ return roundedIntPoint(renderObject.absoluteToLocal(location, UseTransforms));
+}
+
+static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& event, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEvent& webEvent)
+{
+ webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond;
+ webEvent.modifiers = getWebInputModifiers(event);
+
+ ScrollView* view = widget.parent();
+ IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y());
+ if (view)
+ windowPoint = view->contentsToWindow(windowPoint);
+ webEvent.globalX = event.screenX();
+ webEvent.globalY = event.screenY();
+ webEvent.windowX = windowPoint.x();
+ webEvent.windowY = windowPoint.y();
+ IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), renderObject);
+ webEvent.x = localPoint.x();
+ webEvent.y = localPoint.y();
+}
+
+WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, 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.
+
+ updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *this);
+
+ switch (event.button()) {
+ case LeftButton:
+ button = WebMouseEvent::ButtonLeft;
+ break;
+ case MiddleButton:
+ button = WebMouseEvent::ButtonMiddle;
+ break;
+ case RightButton:
+ button = WebMouseEvent::ButtonRight;
+ break;
+ }
+ if (event.buttonDown()) {
+ switch (event.button()) {
+ case LeftButton:
+ modifiers |= WebInputEvent::LeftButtonDown;
+ break;
+ case MiddleButton:
+ modifiers |= WebInputEvent::MiddleButtonDown;
+ break;
+ case RightButton:
+ modifiers |= WebInputEvent::RightButtonDown;
+ break;
+ }
+ } else
+ button = WebMouseEvent::ButtonNone;
+ movementX = event.webkitMovementX();
+ movementY = event.webkitMovementY();
+ clickCount = event.detail();
+}
+
+WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event)
+{
+ if (!event.touches())
+ return;
+ if (event.touches()->length() != 1) {
+ if (event.touches()->length() || event.type() != eventNames().touchendEvent || !event.changedTouches() || event.changedTouches()->length() != 1)
+ return;
+ }
+
+ const Touch* touch = event.touches()->length() == 1 ? event.touches()->item(0) : event.changedTouches()->item(0);
+ if (touch->identifier())
+ return;
+
+ if (event.type() == eventNames().touchstartEvent)
+ type = MouseDown;
+ else if (event.type() == eventNames().touchmoveEvent)
+ type = MouseMove;
+ else if (event.type() == eventNames().touchendEvent)
+ type = MouseUp;
+ else
+ return;
+
+ updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *this);
+
+ button = WebMouseEvent::ButtonLeft;
+ modifiers |= WebInputEvent::LeftButtonDown;
+ clickCount = (type == MouseDown || type == MouseUp);
+
+ IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
+ x = localPoint.x();
+ y = localPoint.y();
+}
+
+WebMouseEventBuilder::WebMouseEventBuilder(const WebCore::Widget* widget, const WebCore::PlatformMouseEvent& event)
+{
+ switch (event.type()) {
+ case PlatformEvent::MouseMoved:
+ type = MouseMove;
+ break;
+ case PlatformEvent::MousePressed:
+ type = MouseDown;
+ break;
+ case PlatformEvent::MouseReleased:
+ type = MouseUp;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ type = Undefined;
+ return;
+ }
+
+ modifiers = 0;
+ if (event.modifiers() & PlatformEvent::ShiftKey)
+ modifiers |= ShiftKey;
+ if (event.modifiers() & PlatformEvent::CtrlKey)
+ modifiers |= ControlKey;
+ if (event.modifiers() & PlatformEvent::AltKey)
+ modifiers |= AltKey;
+ if (event.modifiers() & PlatformEvent::MetaKey)
+ modifiers |= MetaKey;
+
+ timeStampSeconds = event.timestamp();
+
+ // 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.
+ IntPoint position = widget->convertToContainingWindow(event.position());
+ float scale = widgetScaleFactor(widget);
+ position.scale(scale, scale);
+ x = position.x();
+ y = position.y();
+ globalX = event.globalPosition().x();
+ globalY = event.globalPosition().y();
+ movementX = event.movementDelta().x() * scale;
+ movementY = event.movementDelta().y() * scale;
+
+ button = static_cast<Button>(event.button());
+ clickCount = event.clickCount();
+}
+
+WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const WheelEvent& event)
+{
+ if (event.type() != eventNames().mousewheelEvent)
+ return;
+ type = WebInputEvent::MouseWheel;
+ updateWebMouseEventFromWebCoreMouseEvent(event, *widget, *renderObject, *this);
+ 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.deltaMode() == WheelEvent::DOM_DELTA_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);
+ if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_NUMPAD)
+ modifiers |= WebInputEvent::IsKeyPad;
+ else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_LEFT)
+ modifiers |= WebInputEvent::IsLeft;
+ else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_RIGHT)
+ modifiers |= WebInputEvent::IsRight;
+
+ timeStampSeconds = event.timeStamp() / millisPerSecond;
+ 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 numberOfCharacters = std::min(event.keyEvent()->text().length(), static_cast<unsigned>(textLengthCap));
+ for (unsigned i = 0; i < numberOfCharacters; ++i) {
+ text[i] = event.keyEvent()->text()[i];
+ unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i];
+ }
+ memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentifier().length());
+}
+
+WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type)
+{
+ switch (type) {
+ case PlatformEvent::KeyUp:
+ return WebInputEvent::KeyUp;
+ case PlatformEvent::KeyDown:
+ return WebInputEvent::KeyDown;
+ case PlatformEvent::RawKeyDown:
+ return WebInputEvent::RawKeyDown;
+ case PlatformEvent::Char:
+ return WebInputEvent::Char;
+ default:
+ return WebInputEvent::Undefined;
+ }
+}
+
+int toWebKeyboardEventModifiers(int modifiers)
+{
+ int newModifiers = 0;
+ if (modifiers & PlatformEvent::ShiftKey)
+ newModifiers |= WebInputEvent::ShiftKey;
+ if (modifiers & PlatformEvent::CtrlKey)
+ newModifiers |= WebInputEvent::ControlKey;
+ if (modifiers & PlatformEvent::AltKey)
+ newModifiers |= WebInputEvent::AltKey;
+ if (modifiers & PlatformEvent::MetaKey)
+ newModifiers |= WebInputEvent::MetaKey;
+ return newModifiers;
+}
+
+WebKeyboardEventBuilder::WebKeyboardEventBuilder(const WebCore::PlatformKeyboardEvent& event)
+{
+ type = toWebKeyboardEventType(event.type());
+ modifiers = toWebKeyboardEventModifiers(event.modifiers());
+ if (event.isAutoRepeat())
+ modifiers |= WebInputEvent::IsAutoRepeat;
+ if (event.isKeypad())
+ modifiers |= WebInputEvent::IsKeyPad;
+ isSystemKey = event.isSystemKey();
+ nativeKeyCode = event.nativeVirtualKeyCode();
+
+ windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode());
+ modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode());
+
+ event.text().copyTo(text, 0, textLengthCap);
+ event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap);
+ memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length()));
+}
+
+static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject)
+{
+ unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap));
+ for (unsigned i = 0; i < numberOfTouches; ++i) {
+ const Touch* touch = touches->item(i);
+
+ WebTouchPoint point;
+ point.id = touch->identifier();
+ point.screenPosition = WebPoint(touch->screenX(), touch->screenY());
+ point.position = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
+ point.radiusX = touch->webkitRadiusX();
+ point.radiusY = touch->webkitRadiusY();
+ point.rotationAngle = touch->webkitRotationAngle();
+ point.force = touch->webkitForce();
+ point.state = toWebTouchPointState(touchType);
+
+ touchPoints[i] = point;
+ }
+ *touchPointsLength = numberOfTouches;
+}
+
+WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event)
+{
+ if (event.type() == eventNames().touchstartEvent)
+ type = TouchStart;
+ else if (event.type() == eventNames().touchmoveEvent)
+ type = TouchMove;
+ else if (event.type() == eventNames().touchendEvent)
+ type = TouchEnd;
+ else if (event.type() == eventNames().touchcancelEvent)
+ type = TouchCancel;
+ else {
+ ASSERT_NOT_REACHED();
+ type = Undefined;
+ return;
+ }
+
+ modifiers = getWebInputModifiers(event);
+ timeStampSeconds = event.timeStamp() / millisPerSecond;
+
+ addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject);
+ addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
+ addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
+}
+
+WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const GestureEvent& event)
+{
+ if (event.type() == eventNames().gesturetapEvent)
+ type = GestureTap;
+ else if (event.type() == eventNames().gesturetapdownEvent)
+ type = GestureTapDown;
+ else if (event.type() == eventNames().gesturescrollstartEvent)
+ type = GestureScrollBegin;
+ else if (event.type() == eventNames().gesturescrollendEvent)
+ type = GestureScrollEnd;
+ else if (event.type() == eventNames().gesturescrollupdateEvent) {
+ type = GestureScrollUpdate;
+ data.scrollUpdate.deltaX = event.deltaX();
+ data.scrollUpdate.deltaY = event.deltaY();
+ }
+
+ timeStampSeconds = event.timeStamp() / millisPerSecond;
+ modifiers = getWebInputModifiers(event);
+
+ globalX = event.screenX();
+ globalY = event.screenY();
+ IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), *renderObject);
+ x = localPoint.x();
+ y = localPoint.y();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebInputEventConversion.h b/chromium/third_party/WebKit/Source/web/WebInputEventConversion.h
new file mode 100644
index 00000000000..14e39ee1b82
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebInputEventConversion.h
@@ -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.
+ */
+
+#ifndef WebInputEventConversion_h
+#define WebInputEventConversion_h
+
+#include "WebInputEvent.h"
+#include "core/platform/PlatformGestureEvent.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/PlatformMouseEvent.h"
+#include "core/platform/PlatformTouchEvent.h"
+#include "core/platform/PlatformWheelEvent.h"
+
+namespace WebCore {
+class GestureEvent;
+class KeyboardEvent;
+class MouseEvent;
+class RenderObject;
+class ScrollView;
+class TouchEvent;
+class WheelEvent;
+class Widget;
+}
+
+namespace WebKit {
+
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebKeyboardEvent;
+class WebTouchEvent;
+class WebGestureEvent;
+
+// 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 PlatformGestureEventBuilder : public WebCore::PlatformGestureEvent {
+public:
+ PlatformGestureEventBuilder(WebCore::Widget*, const WebGestureEvent&);
+};
+
+class PlatformKeyboardEventBuilder : public WebCore::PlatformKeyboardEvent {
+public:
+ PlatformKeyboardEventBuilder(const WebKeyboardEvent&);
+ void setKeyType(Type);
+ bool isCharacterKey() const;
+};
+
+// Converts a WebTouchPoint to a WebCore::PlatformTouchPoint.
+class PlatformTouchPointBuilder : public WebCore::PlatformTouchPoint {
+public:
+ PlatformTouchPointBuilder(WebCore::Widget*, const WebTouchPoint&);
+};
+
+// Converts a WebTouchEvent to a WebCore::PlatformTouchEvent.
+class PlatformTouchEventBuilder : public WebCore::PlatformTouchEvent {
+public:
+ PlatformTouchEventBuilder(WebCore::Widget*, const WebTouchEvent&);
+};
+
+class WebMouseEventBuilder : public WebMouseEvent {
+public:
+ // Converts a WebCore::MouseEvent to a corresponding WebMouseEvent.
+ // 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.
+ WebMouseEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::MouseEvent&);
+ WebMouseEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
+
+ // Converts a WebCore::PlatformMouseEvent to a corresponding WebMouseEvent.
+ // NOTE: This is only implemented for mousepressed, mousereleased, and
+ // mousemoved. If the event mapping fails, the event type will be set to
+ // Undefined.
+ WebMouseEventBuilder(const WebCore::Widget*, const WebCore::PlatformMouseEvent&);
+};
+
+// 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::RenderObject*, const WebCore::WheelEvent&);
+};
+
+// Converts a WebCore::KeyboardEvent or WebCore::PlatformKeyboardEvent to a
+// corresponding WebKeyboardEvent.
+// NOTE: For WebCore::KeyboardEvent, this is only implemented for keydown,
+// keyup, and keypress. If the event mapping fails, the event type will be set
+// to Undefined.
+class WebKeyboardEventBuilder : public WebKeyboardEvent {
+public:
+ WebKeyboardEventBuilder(const WebCore::KeyboardEvent&);
+ WebKeyboardEventBuilder(const WebCore::PlatformKeyboardEvent&);
+};
+
+// Converts a WebCore::TouchEvent to a corresponding WebTouchEvent.
+// NOTE: WebTouchEvents have a cap on the number of WebTouchPoints. Any points
+// exceeding that cap will be dropped.
+class WebTouchEventBuilder : public WebTouchEvent {
+public:
+ WebTouchEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
+};
+
+// Converts WebCore::GestureEvent to a corresponding WebGestureEvent.
+// NOTE: If event mapping fails, the type will be set to Undefined.
+class WebGestureEventBuilder : public WebGestureEvent {
+public:
+ WebGestureEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::GestureEvent&);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebKit.cpp b/chromium/third_party/WebKit/Source/web/WebKit.cpp
new file mode 100644
index 00000000000..e15baa528c1
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebKit.cpp
@@ -0,0 +1,227 @@
+/*
+ * 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 "IDBFactoryBackendProxy.h"
+#include "RuntimeEnabledFeatures.h"
+#include "WebMediaPlayerClientImpl.h"
+#include "WebWorkerClientImpl.h"
+#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8RecursionScope.h"
+#include "core/Init.h"
+#include "core/dom/Microtask.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/page/Settings.h"
+#include "core/platform/LayoutTestSupport.h"
+#include "core/platform/Logging.h"
+#include "core/platform/graphics/MediaPlayer.h"
+#include "core/platform/graphics/chromium/ImageDecodingStore.h"
+#include "core/workers/WorkerGlobalScopeProxy.h"
+#include "wtf/Assertions.h"
+#include "wtf/CryptographicallyRandomNumber.h"
+#include "wtf/MainThread.h"
+#include "wtf/UnusedParam.h"
+#include "wtf/WTF.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/TextEncoding.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebPrerenderingSupport.h"
+#include "public/platform/WebThread.h"
+#include <v8.h>
+
+namespace WebKit {
+
+namespace {
+
+class EndOfTaskRunner : public WebThread::TaskObserver {
+public:
+ virtual void willProcessTask() { }
+ virtual void didProcessTask()
+ {
+ WebCore::Microtask::performCheckpoint();
+ }
+};
+
+} // namespace
+
+static WebThread::TaskObserver* s_endOfTaskRunner = 0;
+
+// 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 bool generateEntropy(unsigned char* buffer, size_t length)
+{
+ if (Platform::current()) {
+ Platform::current()->cryptographicallyRandomValues(buffer, length);
+ return true;
+ }
+ return false;
+}
+
+#ifndef NDEBUG
+static void assertV8RecursionScope()
+{
+ ASSERT(!isMainThread() || WebCore::V8RecursionScope::properlyUsed());
+}
+#endif
+
+void initialize(Platform* platform)
+{
+ initializeWithoutV8(platform);
+
+ v8::V8::SetEntropySource(&generateEntropy);
+ v8::V8::SetArrayBufferAllocator(WebCore::v8ArrayBufferAllocator());
+ static const char* kTypedArraysFlag = "--harmony_array_buffer --harmony_typed_arrays";
+ v8::V8::SetFlagsFromString(kTypedArraysFlag, strlen(kTypedArraysFlag));
+ v8::V8::Initialize();
+ WebCore::V8PerIsolateData::ensureInitialized(v8::Isolate::GetCurrent());
+
+ // currentThread will always be non-null in production, but can be null in Chromium unit tests.
+ if (WebThread* currentThread = platform->currentThread()) {
+#ifndef NDEBUG
+ v8::V8::AddCallCompletedCallback(&assertV8RecursionScope);
+#endif
+ ASSERT(!s_endOfTaskRunner);
+ s_endOfTaskRunner = new EndOfTaskRunner;
+ currentThread->addTaskObserver(s_endOfTaskRunner);
+ }
+}
+
+static double currentTimeFunction()
+{
+ return Platform::current()->currentTime();
+}
+
+static double monotonicallyIncreasingTimeFunction()
+{
+ return Platform::current()->monotonicallyIncreasingTime();
+}
+
+static void cryptographicallyRandomValues(unsigned char* buffer, size_t length)
+{
+ Platform::current()->cryptographicallyRandomValues(buffer, length);
+}
+
+static void callOnMainThreadFunction(WTF::MainThreadFunction function, void* context)
+{
+ Platform::current()->callOnMainThread(function, context);
+}
+
+void initializeWithoutV8(Platform* platform)
+{
+ ASSERT(!s_webKitInitialized);
+ s_webKitInitialized = true;
+
+ ASSERT(platform);
+ Platform::initialize(platform);
+
+ WTF::setRandomSource(cryptographicallyRandomValues);
+ WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction);
+ WTF::initializeMainThread(callOnMainThreadFunction);
+ WebCore::init();
+ WebCore::ImageDecodingStore::initializeOnce();
+
+ // 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.
+ WTF::UTF8Encoding();
+
+ WebCore::setIDBFactoryBackendInterfaceCreateFunction(WebKit::IDBFactoryBackendProxy::create);
+
+ WebCore::MediaPlayer::setMediaEngineCreateFunction(WebKit::WebMediaPlayerClientImpl::create);
+
+ WebCore::WorkerGlobalScopeProxy::setCreateDelegate(WebWorkerClientImpl::createWorkerGlobalScopeProxy);
+}
+
+
+void shutdown()
+{
+ // currentThread will always be non-null in production, but can be null in Chromium unit tests.
+ if (Platform::current()->currentThread()) {
+ ASSERT(s_endOfTaskRunner);
+#ifndef NDEBUG
+ v8::V8::RemoveCallCompletedCallback(&assertV8RecursionScope);
+#endif
+ Platform::current()->currentThread()->removeTaskObserver(s_endOfTaskRunner);
+ delete s_endOfTaskRunner;
+ s_endOfTaskRunner = 0;
+ }
+
+ shutdownWithoutV8();
+
+ WebCore::V8PerIsolateData::dispose(v8::Isolate::GetCurrent());
+ v8::V8::Dispose();
+}
+
+void shutdownWithoutV8()
+{
+ ASSERT(!s_endOfTaskRunner);
+ WebCore::ImageDecodingStore::shutdown();
+ WebCore::shutdown();
+ WTF::shutdown();
+ Platform::shutdown();
+ WebPrerenderingSupport::shutdown();
+}
+
+void setLayoutTestMode(bool value)
+{
+ WebCore::setIsRunningLayoutTest(value);
+}
+
+bool layoutTestMode()
+{
+ return WebCore::isRunningLayoutTest();
+}
+
+void enableLogChannel(const char* name)
+{
+#if !LOG_DISABLED
+ WTFLogChannel* channel = WebCore::getChannelFromName(name);
+ if (channel)
+ channel->state = WTFLogChannelOn;
+#else
+ UNUSED_PARAM(name);
+#endif // !LOG_DISABLED
+}
+
+void resetPluginCache(bool reloadPages)
+{
+ WebCore::Page::refreshPlugins(reloadPages);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebKitUnitTests.isolate b/chromium/third_party/WebKit/Source/web/WebKitUnitTests.isolate
new file mode 100644
index 00000000000..870cd54922f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebKitUnitTests.isolate
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2013 Google Inc. 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.
+#
+
+{
+ 'conditions': [
+ ['OS=="android"', {
+ 'variables': {
+ 'isolate_dependency_tracked': [
+ ],
+ 'isolate_dependency_untracked': [
+ 'tests/data/',
+ ],
+ },
+ }],
+ ],
+}
diff --git a/chromium/third_party/WebKit/Source/web/WebLabelElement.cpp b/chromium/third_party/WebKit/Source/web/WebLabelElement.cpp
new file mode 100644
index 00000000000..59b4ffaba8f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "HTMLNames.h"
+#include "core/html/HTMLLabelElement.h"
+#include "public/platform/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 toHTMLLabelElement(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebMIDIPermissionRequest.cpp b/chromium/third_party/WebKit/Source/web/WebMIDIPermissionRequest.cpp
new file mode 100644
index 00000000000..869fa2ced65
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebMIDIPermissionRequest.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebMIDIPermissionRequest.h"
+
+#include "WebSecurityOrigin.h"
+#include "core/dom/Document.h"
+#include "modules/webmidi/MIDIAccess.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebMIDIPermissionRequest::WebMIDIPermissionRequest(const PassRefPtr<WebCore::MIDIAccess>& midi)
+ : m_private(midi)
+{
+}
+
+WebMIDIPermissionRequest::WebMIDIPermissionRequest(WebCore::MIDIAccess* midi)
+ : m_private(midi)
+{
+}
+
+void WebMIDIPermissionRequest::reset()
+{
+ m_private.reset();
+}
+
+void WebMIDIPermissionRequest::assign(const WebMIDIPermissionRequest& other)
+{
+ m_private = other.m_private;
+}
+
+bool WebMIDIPermissionRequest::equals(const WebMIDIPermissionRequest& n) const
+{
+ return m_private.get() == n.m_private.get();
+}
+
+WebSecurityOrigin WebMIDIPermissionRequest::securityOrigin() const
+{
+ return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin());
+}
+
+void WebMIDIPermissionRequest::setIsAllowed(bool allowed)
+{
+ m_private->setSysExEnabled(allowed);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.cpp b/chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.cpp
new file mode 100644
index 00000000000..a3b4d613f0d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.cpp
@@ -0,0 +1,739 @@
+// 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"
+
+#include "InbandTextTrackPrivateImpl.h"
+#include "WebAudioSourceProvider.h"
+#include "WebDocument.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebHelperPluginImpl.h"
+#include "WebInbandTextTrack.h"
+#include "WebMediaPlayer.h"
+#include "WebMediaSourceImpl.h"
+#include "WebViewImpl.h"
+#include "core/html/HTMLMediaElement.h"
+#include "core/html/TimeRanges.h"
+#include "core/page/Frame.h"
+#include "core/platform/NotImplemented.h"
+#include "core/platform/audio/AudioBus.h"
+#include "core/platform/audio/AudioSourceProvider.h"
+#include "core/platform/audio/AudioSourceProviderClient.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/platform/graphics/IntSize.h"
+#include "core/platform/graphics/MediaPlayer.h"
+#include "core/rendering/RenderLayerCompositor.h"
+#include "core/rendering/RenderView.h"
+#include "modules/mediastream/MediaStreamRegistry.h"
+#include "public/platform/WebCanvas.h"
+#include "public/platform/WebCompositorSupport.h"
+#include "public/platform/WebCString.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "weborigin/KURL.h"
+
+#if OS(ANDROID)
+#include "GrContext.h"
+#include "GrTypes.h"
+#include "SkCanvas.h"
+#include "SkGrPixelRef.h"
+#include "core/platform/graphics/gpu/SharedGraphicsContext3D.h"
+#endif
+
+
+#include "wtf/Assertions.h"
+#include "wtf/text/CString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* client, const WebURL& url, Frame* frame)
+{
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
+
+ if (!webFrame->client())
+ return nullptr;
+ return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client));
+}
+
+WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const
+{
+ return m_webMediaPlayer.get();
+}
+
+// WebMediaPlayerClient --------------------------------------------------------
+
+WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl()
+{
+ // Explicitly destroy the WebMediaPlayer to allow verification of tear down.
+ m_webMediaPlayer.clear();
+
+ // Ensure the m_webMediaPlayer destroyed any WebHelperPlugin used.
+ ASSERT(!m_helperPlugin);
+}
+
+void WebMediaPlayerClientImpl::networkStateChanged()
+{
+ m_client->mediaPlayerNetworkStateChanged();
+}
+
+void WebMediaPlayerClientImpl::readyStateChanged()
+{
+ m_client->mediaPlayerReadyStateChanged();
+}
+
+void WebMediaPlayerClientImpl::timeChanged()
+{
+ m_client->mediaPlayerTimeChanged();
+}
+
+void WebMediaPlayerClientImpl::repaint()
+{
+ if (m_videoLayer)
+ m_videoLayer->invalidate();
+ m_client->mediaPlayerRepaint();
+}
+
+void WebMediaPlayerClientImpl::durationChanged()
+{
+ m_client->mediaPlayerDurationChanged();
+}
+
+void WebMediaPlayerClientImpl::sizeChanged()
+{
+ m_client->mediaPlayerSizeChanged();
+}
+
+void WebMediaPlayerClientImpl::setOpaque(bool opaque)
+{
+ m_opaque = opaque;
+ if (m_videoLayer)
+ m_videoLayer->setOpaque(m_opaque);
+}
+
+double WebMediaPlayerClientImpl::volume() const
+{
+ return m_volume;
+}
+
+void WebMediaPlayerClientImpl::playbackStateChanged()
+{
+ m_client->mediaPlayerPlaybackStateChanged();
+}
+
+WebMediaPlayer::Preload WebMediaPlayerClientImpl::preload() const
+{
+ return static_cast<WebMediaPlayer::Preload>(m_preload);
+}
+
+void WebMediaPlayerClientImpl::keyAdded(const WebString& keySystem, const WebString& sessionId)
+{
+ m_client->mediaPlayerKeyAdded(keySystem, sessionId);
+}
+
+void WebMediaPlayerClientImpl::keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode errorCode, unsigned short systemCode)
+{
+ m_client->mediaPlayerKeyError(keySystem, sessionId, static_cast<MediaPlayerClient::MediaKeyErrorCode>(errorCode), systemCode);
+}
+
+void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL)
+{
+ m_client->mediaPlayerKeyMessage(keySystem, sessionId, message, messageLength, defaultURL);
+}
+
+void WebMediaPlayerClientImpl::keyNeeded(const WebString& keySystem, const WebString& sessionId, const unsigned char* initData, unsigned initDataLength)
+{
+ m_client->mediaPlayerKeyNeeded(keySystem, sessionId, initData, initDataLength);
+}
+
+WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginType, WebFrame* frame)
+{
+ ASSERT(!m_helperPlugin);
+
+ WebViewImpl* webView = static_cast<WebViewImpl*>(frame->view());
+ m_helperPlugin = webView->createHelperPlugin(pluginType, frame->document());
+ if (!m_helperPlugin)
+ return 0;
+
+ WebPlugin* plugin = m_helperPlugin->getPlugin();
+ if (!plugin) {
+ // There is no need to keep the helper plugin around and the caller
+ // should not be expected to call close after a failure (null pointer).
+ closeHelperPlugin();
+ return 0;
+ }
+
+ return plugin;
+}
+
+void WebMediaPlayerClientImpl::closeHelperPlugin()
+{
+ ASSERT(m_helperPlugin);
+ m_helperPlugin->closeHelperPlugin();
+ m_helperPlugin = 0;
+}
+
+void WebMediaPlayerClientImpl::setWebLayer(WebLayer* layer)
+{
+ if (layer == m_videoLayer)
+ return;
+
+ // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc.
+ if (!m_videoLayer || !layer)
+ m_client->mediaPlayerScheduleLayerUpdate();
+
+ if (m_videoLayer)
+ GraphicsLayer::unregisterContentsLayer(m_videoLayer);
+ m_videoLayer = layer;
+ if (m_videoLayer) {
+ m_videoLayer->setOpaque(m_opaque);
+ GraphicsLayer::registerContentsLayer(m_videoLayer);
+ }
+}
+
+void WebMediaPlayerClientImpl::addTextTrack(WebInbandTextTrack* textTrack)
+{
+ m_client->mediaPlayerDidAddTrack(adoptRef(new InbandTextTrackPrivateImpl(textTrack)));
+}
+
+void WebMediaPlayerClientImpl::removeTextTrack(WebInbandTextTrack* textTrack)
+{
+ // The following static_cast is safe, because we created the object with the textTrack
+ // that was passed to addTextTrack. (The object from which we are downcasting includes
+ // WebInbandTextTrack as one of the intefaces from which inherits.)
+ m_client->mediaPlayerDidRemoveTrack(static_cast<InbandTextTrackPrivateImpl*>(textTrack->client()));
+}
+
+// MediaPlayer -------------------------------------------------
+
+void WebMediaPlayerClientImpl::load(const String& url)
+{
+ m_url = KURL(ParsedURLString, url);
+ m_mediaSource = 0;
+ loadRequested();
+}
+
+void WebMediaPlayerClientImpl::load(const String& url, PassRefPtr<WebCore::HTMLMediaSource> mediaSource)
+{
+ m_url = KURL(ParsedURLString, url);
+ m_mediaSource = mediaSource;
+ loadRequested();
+}
+
+void WebMediaPlayerClientImpl::loadRequested()
+{
+ if (m_preload == MediaPlayer::None) {
+#if ENABLE(WEB_AUDIO)
+ m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
+#endif
+ m_webMediaPlayer.clear();
+ m_delayingLoad = true;
+ } else
+ loadInternal();
+}
+
+void WebMediaPlayerClientImpl::loadInternal()
+{
+ m_isMediaStream = WebCore::MediaStreamRegistry::registry().lookupMediaStreamDescriptor(m_url.string());
+
+#if ENABLE(WEB_AUDIO)
+ m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
+#endif
+
+ // FIXME: Remove this cast
+ Frame* frame = static_cast<HTMLMediaElement*>(m_client)->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.
+ m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceleratedCompositing();
+
+ m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame);
+ if (m_webMediaPlayer) {
+#if ENABLE(WEB_AUDIO)
+ // Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
+ m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
+#endif
+
+ WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode>(m_client->mediaPlayerCORSMode());
+ if (m_mediaSource) {
+ m_webMediaPlayer->load(m_url, new WebMediaSourceImpl(m_mediaSource), corsMode);
+ return;
+ }
+ m_webMediaPlayer->load(m_url, corsMode);
+ }
+}
+
+WebLayer* WebMediaPlayerClientImpl::platformLayer() const
+{
+ return m_videoLayer;
+}
+
+void WebMediaPlayerClientImpl::play()
+{
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->play();
+}
+
+void WebMediaPlayerClientImpl::pause()
+{
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->pause();
+}
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+void WebMediaPlayerClientImpl::enterFullscreen()
+{
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->enterFullscreen();
+}
+
+void WebMediaPlayerClientImpl::exitFullscreen()
+{
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->exitFullscreen();
+}
+
+bool WebMediaPlayerClientImpl::canEnterFullscreen() const
+{
+ return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen();
+}
+#endif
+
+MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength)
+{
+ if (!m_webMediaPlayer)
+ return MediaPlayer::InvalidPlayerState;
+
+ WebMediaPlayer::MediaKeyException result = m_webMediaPlayer->generateKeyRequest(keySystem, initData, initDataLength);
+ return static_cast<MediaPlayer::MediaKeyException>(result);
+}
+
+MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId)
+{
+ if (!m_webMediaPlayer)
+ return MediaPlayer::InvalidPlayerState;
+
+ WebMediaPlayer::MediaKeyException result = m_webMediaPlayer->addKey(keySystem, key, keyLength, initData, initDataLength, sessionId);
+ return static_cast<MediaPlayer::MediaKeyException>(result);
+}
+
+MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::cancelKeyRequest(const String& keySystem, const String& sessionId)
+{
+ if (!m_webMediaPlayer)
+ return MediaPlayer::InvalidPlayerState;
+
+ WebMediaPlayer::MediaKeyException result = m_webMediaPlayer->cancelKeyRequest(keySystem, sessionId);
+ return static_cast<MediaPlayer::MediaKeyException>(result);
+}
+
+void WebMediaPlayerClientImpl::prepareToPlay()
+{
+ if (m_delayingLoad)
+ startDelayedLoad();
+}
+
+IntSize WebMediaPlayerClientImpl::naturalSize() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->naturalSize();
+ return IntSize();
+}
+
+bool WebMediaPlayerClientImpl::hasVideo() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->hasVideo();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::hasAudio() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->hasAudio();
+ return false;
+}
+
+double WebMediaPlayerClientImpl::duration() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->duration();
+ return 0.0;
+}
+
+double WebMediaPlayerClientImpl::currentTime() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->currentTime();
+ return 0.0;
+}
+
+void WebMediaPlayerClientImpl::seek(double time)
+{
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->seek(time);
+}
+
+bool WebMediaPlayerClientImpl::seeking() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->seeking();
+ return false;
+}
+
+double WebMediaPlayerClientImpl::rate() const
+{
+ return m_rate;
+}
+
+void WebMediaPlayerClientImpl::setRate(double rate)
+{
+ m_rate = rate;
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->setRate(rate);
+}
+
+bool WebMediaPlayerClientImpl::paused() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->paused();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::supportsFullscreen() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->supportsFullscreen();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::supportsSave() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->supportsSave();
+ return false;
+}
+
+void WebMediaPlayerClientImpl::setVolume(double volume)
+{
+ m_volume = volume;
+ if (m_webMediaPlayer && !m_muted)
+ m_webMediaPlayer->setVolume(volume);
+}
+
+void WebMediaPlayerClientImpl::setMuted(bool muted)
+{
+ m_muted = muted;
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->setVolume(muted ? 0 : m_volume);
+}
+
+MediaPlayer::NetworkState WebMediaPlayerClientImpl::networkState() const
+{
+ if (m_webMediaPlayer)
+ return static_cast<MediaPlayer::NetworkState>(m_webMediaPlayer->networkState());
+ return MediaPlayer::Empty;
+}
+
+MediaPlayer::ReadyState WebMediaPlayerClientImpl::readyState() const
+{
+ if (m_webMediaPlayer)
+ return static_cast<MediaPlayer::ReadyState>(m_webMediaPlayer->readyState());
+ return MediaPlayer::HaveNothing;
+}
+
+double WebMediaPlayerClientImpl::maxTimeSeekable() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->maxTimeSeekable();
+ return 0.0;
+}
+
+PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::buffered() const
+{
+ if (m_webMediaPlayer) {
+ 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();
+}
+
+bool WebMediaPlayerClientImpl::didLoadingProgress() const
+{
+ return m_webMediaPlayer && m_webMediaPlayer->didLoadingProgress();
+}
+
+void WebMediaPlayerClientImpl::paint(GraphicsContext* context, const IntRect& rect)
+{
+ // If we are using GPU to render video, ignore requests to paint frames into
+ // canvas because it will be taken care of by the VideoLayer.
+ if (acceleratedRenderingInUse())
+ return;
+ paintCurrentFrameInContext(context, rect);
+}
+
+void WebMediaPlayerClientImpl::paintCurrentFrameInContext(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 && !context->paintingDisabled()) {
+ // On Android, video frame is emitted as GL_TEXTURE_EXTERNAL_OES texture. We use a different path to
+ // paint the video frame into the context.
+#if OS(ANDROID)
+ if (!m_isMediaStream) {
+ RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get();
+ paintOnAndroid(context, context3D.get(), rect, context->getNormalizedAlpha());
+ return;
+ }
+#endif
+ WebCanvas* canvas = context->canvas();
+ m_webMediaPlayer->paint(canvas, rect, context->getNormalizedAlpha());
+ }
+}
+
+bool WebMediaPlayerClientImpl::copyVideoTextureToPlatformTexture(WebCore::GraphicsContext3D* context, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
+{
+ if (!context || !m_webMediaPlayer)
+ return false;
+ Extensions3D* extensions = context->getExtensions();
+ if (!extensions || !extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy")
+ || !extensions->canUseCopyTextureCHROMIUM(internalFormat, type, level) || !context->makeContextCurrent())
+ return false;
+ WebGraphicsContext3D* webGraphicsContext3D = context->webContext();
+ return m_webMediaPlayer->copyVideoTextureToPlatformTexture(webGraphicsContext3D, texture, level, internalFormat, type, premultiplyAlpha, flipY);
+}
+
+void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload)
+{
+ m_preload = preload;
+
+ if (m_webMediaPlayer)
+ m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preload));
+
+ if (m_delayingLoad && m_preload != MediaPlayer::None)
+ startDelayedLoad();
+}
+
+bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->hasSingleSecurityOrigin();
+ return false;
+}
+
+bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->didPassCORSAccessCheck();
+ return false;
+}
+
+double WebMediaPlayerClientImpl::mediaTimeForTimeValue(double timeValue) const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->mediaTimeForTimeValue(timeValue);
+ return timeValue;
+}
+
+unsigned WebMediaPlayerClientImpl::decodedFrameCount() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->decodedFrameCount();
+ return 0;
+}
+
+unsigned WebMediaPlayerClientImpl::droppedFrameCount() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->droppedFrameCount();
+ return 0;
+}
+
+unsigned WebMediaPlayerClientImpl::audioDecodedByteCount() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->audioDecodedByteCount();
+ return 0;
+}
+
+unsigned WebMediaPlayerClientImpl::videoDecodedByteCount() const
+{
+ if (m_webMediaPlayer)
+ return m_webMediaPlayer->videoDecodedByteCount();
+ return 0;
+}
+
+#if ENABLE(WEB_AUDIO)
+AudioSourceProvider* WebMediaPlayerClientImpl::audioSourceProvider()
+{
+ return &m_audioSourceProvider;
+}
+#endif
+
+bool WebMediaPlayerClientImpl::needsWebLayerForVideo() const
+{
+ return m_needsWebLayerForVideo;
+}
+
+bool WebMediaPlayerClientImpl::supportsAcceleratedRendering() const
+{
+ return !!m_videoLayer;
+}
+
+bool WebMediaPlayerClientImpl::acceleratedRenderingInUse()
+{
+ return m_videoLayer && !m_videoLayer->isOrphan();
+}
+
+PassOwnPtr<MediaPlayer> WebMediaPlayerClientImpl::create(MediaPlayerClient* client)
+{
+ return adoptPtr(new WebMediaPlayerClientImpl(client));
+}
+
+#if OS(ANDROID)
+void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context, WebCore::GraphicsContext3D* context3D, const IntRect& rect, uint8_t alpha)
+{
+ if (!context || !context3D || !m_webMediaPlayer || context->paintingDisabled())
+ return;
+
+ Extensions3D* extensions = context3D->getExtensions();
+ if (!extensions || !extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy")
+ || !context3D->makeContextCurrent())
+ return;
+
+ // Copy video texture into a RGBA texture based bitmap first as video texture on Android is GL_TEXTURE_EXTERNAL_OES
+ // which is not supported by Skia yet. The bitmap's size needs to be the same as the video.
+ int videoWidth = naturalSize().width();
+ int videoHeight = naturalSize().height();
+
+ // Check if we could reuse existing texture based bitmap.
+ // Otherwise, release existing texture based bitmap and allocate a new one based on video size.
+ if (videoWidth != m_bitmap.width() || videoHeight != m_bitmap.height() || !m_texture.get()) {
+ GrTextureDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fWidth = videoWidth;
+ desc.fHeight = videoHeight;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ desc.fFlags = (kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit);
+ GrContext* ct = context3D->grContext();
+ if (!ct)
+ return;
+ m_texture.reset(ct->createUncachedTexture(desc, NULL, 0));
+ if (!m_texture.get())
+ return;
+ m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, videoWidth, videoHeight);
+ m_bitmap.setPixelRef(new SkGrPixelRef(m_texture))->unref();
+ }
+
+ // Copy video texture to bitmap texture.
+ WebGraphicsContext3D* webGraphicsContext3D = context3D->webContext();
+ WebCanvas* canvas = context->canvas();
+ unsigned int textureId = static_cast<unsigned int>(m_texture->getTextureHandle());
+ if (!m_webMediaPlayer->copyVideoTextureToPlatformTexture(webGraphicsContext3D, textureId, 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, true, false))
+ return;
+
+ // Draw the texture based bitmap onto the Canvas. If the canvas is hardware based, this will do a GPU-GPU texture copy. If the canvas is software based,
+ // the texture based bitmap will be readbacked to system memory then draw onto the canvas.
+ SkRect dest;
+ dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
+ SkPaint paint;
+ paint.setAlpha(alpha);
+ // It is not necessary to pass the dest into the drawBitmap call since all the context have been set up before calling paintCurrentFrameInContext.
+ canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint);
+}
+#endif
+
+void WebMediaPlayerClientImpl::startDelayedLoad()
+{
+ ASSERT(m_delayingLoad);
+ ASSERT(!m_webMediaPlayer);
+
+ m_delayingLoad = false;
+
+ loadInternal();
+}
+
+WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client)
+ : m_client(client)
+ , m_isMediaStream(false)
+ , m_delayingLoad(false)
+ , m_preload(MediaPlayer::Auto)
+ , m_videoLayer(0)
+ , m_opaque(false)
+ , m_needsWebLayerForVideo(false)
+ , m_volume(1.0)
+ , m_muted(false)
+ , m_rate(1.0)
+{
+ ASSERT(m_client);
+}
+
+#if ENABLE(WEB_AUDIO)
+void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* provider)
+{
+ MutexLocker locker(provideInputLock);
+
+ if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider)
+ m_webAudioSourceProvider->setClient(0);
+
+ m_webAudioSourceProvider = provider;
+ if (m_webAudioSourceProvider)
+ m_webAudioSourceProvider->setClient(m_client.get());
+}
+
+void WebMediaPlayerClientImpl::AudioSourceProviderImpl::setClient(AudioSourceProviderClient* client)
+{
+ MutexLocker locker(provideInputLock);
+
+ if (client)
+ m_client = adoptPtr(new WebMediaPlayerClientImpl::AudioClientImpl(client));
+ else
+ m_client.clear();
+
+ if (m_webAudioSourceProvider)
+ m_webAudioSourceProvider->setClient(m_client.get());
+}
+
+void WebMediaPlayerClientImpl::AudioSourceProviderImpl::provideInput(AudioBus* bus, size_t framesToProcess)
+{
+ ASSERT(bus);
+ if (!bus)
+ return;
+
+ MutexTryLocker tryLocker(provideInputLock);
+ if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) {
+ bus->zero();
+ return;
+ }
+
+ // Wrap the AudioBus channel data using WebVector.
+ size_t n = bus->numberOfChannels();
+ WebVector<float*> webAudioData(n);
+ for (size_t i = 0; i < n; ++i)
+ webAudioData[i] = bus->channel(i)->mutableData();
+
+ m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
+}
+
+void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate)
+{
+ if (m_client)
+ m_client->setFormat(numberOfChannels, sampleRate);
+}
+
+#endif
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.h b/chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.h
new file mode 100644
index 00000000000..3d9cfc20807
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebMediaPlayerClientImpl.h
@@ -0,0 +1,232 @@
+/*
+ * 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
+
+#include "WebAudioSourceProviderClient.h"
+#include "WebMediaPlayerClient.h"
+#include "core/platform/audio/AudioSourceProvider.h"
+#include "core/platform/graphics/InbandTextTrackPrivate.h"
+#include "core/platform/graphics/MediaPlayer.h"
+#if OS(ANDROID)
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkRefCnt.h"
+#include "third_party/skia/include/gpu/GrTexture.h"
+#endif
+#include "weborigin/KURL.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Threading.h"
+
+namespace WebCore {
+class AudioSourceProviderClient;
+class HTMLMediaSource;
+}
+
+namespace WebKit {
+
+class WebHelperPluginImpl;
+class WebAudioSourceProvider;
+class WebMediaPlayer;
+
+// This class serves as a bridge between WebCore::MediaPlayer and
+// WebKit::WebMediaPlayer.
+class WebMediaPlayerClientImpl : public WebCore::MediaPlayer, public WebMediaPlayerClient {
+
+public:
+ static PassOwnPtr<WebCore::MediaPlayer> create(WebCore::MediaPlayerClient*);
+
+ // Returns the encapsulated WebKit::WebMediaPlayer.
+ WebMediaPlayer* mediaPlayer() const;
+
+ // WebMediaPlayerClient methods:
+ virtual ~WebMediaPlayerClientImpl();
+ virtual void networkStateChanged();
+ virtual void readyStateChanged();
+ virtual void timeChanged();
+ virtual void repaint();
+ virtual void durationChanged();
+ virtual void sizeChanged();
+ virtual void setOpaque(bool);
+ virtual double volume() const;
+ virtual void playbackStateChanged();
+ virtual WebMediaPlayer::Preload preload() const;
+ virtual void keyAdded(const WebString& keySystem, const WebString& sessionId);
+ virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode);
+ virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL);
+ virtual void keyNeeded(const WebString& keySystem, const WebString& sessionId, const unsigned char* initData, unsigned initDataLength);
+ virtual WebPlugin* createHelperPlugin(const WebString& pluginType, WebFrame*);
+ virtual void closeHelperPlugin();
+ virtual bool needsWebLayerForVideo() const;
+ virtual void setWebLayer(WebLayer*);
+ virtual void addTextTrack(WebInbandTextTrack*);
+ virtual void removeTextTrack(WebInbandTextTrack*);
+
+ // MediaPlayer methods:
+ virtual void load(const WTF::String& url) OVERRIDE;
+ virtual void load(const WTF::String& url, PassRefPtr<WebCore::HTMLMediaSource>) OVERRIDE;
+
+ virtual WebKit::WebLayer* platformLayer() const OVERRIDE;
+ virtual void play() OVERRIDE;
+ virtual void pause() OVERRIDE;
+ virtual void prepareToPlay() OVERRIDE;
+ virtual bool supportsFullscreen() const OVERRIDE;
+ virtual bool supportsSave() const OVERRIDE;
+ virtual WebCore::IntSize naturalSize() const OVERRIDE;
+ virtual bool hasVideo() const OVERRIDE;
+ virtual bool hasAudio() const OVERRIDE;
+ virtual double duration() const OVERRIDE;
+ virtual double currentTime() const OVERRIDE;
+ virtual void seek(double time) OVERRIDE;
+ virtual bool seeking() const OVERRIDE;
+ virtual double rate() const OVERRIDE;
+ virtual void setRate(double) OVERRIDE;
+ virtual bool paused() const OVERRIDE;
+ virtual void setVolume(double) OVERRIDE;
+ virtual void setMuted(bool) OVERRIDE;
+ virtual WebCore::MediaPlayer::NetworkState networkState() const OVERRIDE;
+ virtual WebCore::MediaPlayer::ReadyState readyState() const OVERRIDE;
+ virtual double maxTimeSeekable() const OVERRIDE;
+ virtual WTF::PassRefPtr<WebCore::TimeRanges> buffered() const OVERRIDE;
+ virtual bool didLoadingProgress() const OVERRIDE;
+ virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&) OVERRIDE;
+ virtual void paintCurrentFrameInContext(WebCore::GraphicsContext*, const WebCore::IntRect&) OVERRIDE;
+ virtual bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContext3D*, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY) OVERRIDE;
+ virtual void setPreload(WebCore::MediaPlayer::Preload) OVERRIDE;
+ virtual bool hasSingleSecurityOrigin() const OVERRIDE;
+ virtual bool didPassCORSAccessCheck() const OVERRIDE;
+ virtual double mediaTimeForTimeValue(double timeValue) const OVERRIDE;
+ virtual unsigned decodedFrameCount() const OVERRIDE;
+ virtual unsigned droppedFrameCount() const OVERRIDE;
+ virtual unsigned audioDecodedByteCount() const OVERRIDE;
+ virtual unsigned videoDecodedByteCount() const OVERRIDE;
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ virtual void enterFullscreen() OVERRIDE;
+ virtual void exitFullscreen() OVERRIDE;
+ virtual bool canEnterFullscreen() const OVERRIDE;
+#endif
+
+#if ENABLE(WEB_AUDIO)
+ virtual WebCore::AudioSourceProvider* audioSourceProvider() OVERRIDE;
+#endif
+
+ virtual bool supportsAcceleratedRendering() const OVERRIDE;
+
+ virtual WebCore::MediaPlayer::MediaKeyException generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength) OVERRIDE;
+ virtual WebCore::MediaPlayer::MediaKeyException addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId) OVERRIDE;
+ virtual WebCore::MediaPlayer::MediaKeyException cancelKeyRequest(const String& keySystem, const String& sessionId) OVERRIDE;
+
+private:
+ explicit WebMediaPlayerClientImpl(WebCore::MediaPlayerClient*);
+
+ void startDelayedLoad();
+ void loadRequested();
+ void loadInternal();
+
+ bool acceleratedRenderingInUse();
+
+#if OS(ANDROID)
+ // FIXME: This path "only works" on Android. It is a workaround for the problem that Skia could not handle Android's GL_TEXTURE_EXTERNAL_OES
+ // texture internally. It should be removed and replaced by the normal paint path.
+ // https://code.google.com/p/skia/issues/detail?id=1189
+ void paintOnAndroid(WebCore::GraphicsContext* context, WebCore::GraphicsContext3D* context3D, const WebCore::IntRect& rect, uint8_t alpha);
+ SkAutoTUnref<GrTexture> m_texture;
+ SkBitmap m_bitmap;
+#endif
+
+ WebCore::MediaPlayerClient* m_client;
+ OwnPtr<WebMediaPlayer> m_webMediaPlayer;
+ WebCore::KURL m_url;
+ bool m_isMediaStream;
+ bool m_delayingLoad;
+ WebCore::MediaPlayer::Preload m_preload;
+ RefPtr<WebHelperPluginImpl> m_helperPlugin;
+ WebLayer* m_videoLayer;
+ bool m_opaque;
+ bool m_needsWebLayerForVideo;
+ double m_volume;
+ bool m_muted;
+ double m_rate;
+
+#if ENABLE(WEB_AUDIO)
+ // AudioClientImpl wraps an AudioSourceProviderClient.
+ // When the audio format is known, Chromium calls setFormat() which then dispatches into WebCore.
+
+ class AudioClientImpl : public WebKit::WebAudioSourceProviderClient {
+ public:
+ AudioClientImpl(WebCore::AudioSourceProviderClient* client)
+ : m_client(client)
+ {
+ }
+
+ virtual ~AudioClientImpl() { }
+
+ // WebAudioSourceProviderClient
+ virtual void setFormat(size_t numberOfChannels, float sampleRate);
+
+ private:
+ WebCore::AudioSourceProviderClient* m_client;
+ };
+
+ // AudioSourceProviderImpl wraps a WebAudioSourceProvider.
+ // provideInput() calls into Chromium to get a rendered audio stream.
+
+ class AudioSourceProviderImpl : public WebCore::AudioSourceProvider {
+ public:
+ AudioSourceProviderImpl()
+ : m_webAudioSourceProvider(0)
+ {
+ }
+
+ virtual ~AudioSourceProviderImpl() { }
+
+ // Wraps the given WebAudioSourceProvider.
+ void wrap(WebAudioSourceProvider*);
+
+ // WebCore::AudioSourceProvider
+ virtual void setClient(WebCore::AudioSourceProviderClient*);
+ virtual void provideInput(WebCore::AudioBus*, size_t framesToProcess);
+
+ private:
+ WebAudioSourceProvider* m_webAudioSourceProvider;
+ OwnPtr<AudioClientImpl> m_client;
+ Mutex provideInputLock;
+ };
+
+ AudioSourceProviderImpl m_audioSourceProvider;
+#endif
+
+ RefPtr<WebCore::HTMLMediaSource> m_mediaSource;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.cpp b/chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.cpp
new file mode 100644
index 00000000000..16e814836c6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebMediaSourceImpl.h"
+
+#include "MediaSourcePrivateImpl.h"
+#include "WebMediaSourceClient.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebKit {
+
+
+WebMediaSourceImpl::WebMediaSourceImpl(PassRefPtr<WebCore::HTMLMediaSource> mediaSource)
+{
+ m_mediaSource = mediaSource;
+}
+
+WebMediaSourceImpl::~WebMediaSourceImpl()
+{
+}
+
+
+void WebMediaSourceImpl::open(WebMediaSourceClient* client)
+{
+ ASSERT(client);
+ m_mediaSource->setPrivateAndOpen(adoptPtr(new MediaSourcePrivateImpl(adoptPtr(client))));
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.h b/chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.h
new file mode 100644
index 00000000000..a5641f8d606
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebMediaSourceImpl.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 WebMediaSourceImpl_h
+#define WebMediaSourceImpl_h
+
+#include "WebMediaSource.h"
+#include "core/html/HTMLMediaSource.h"
+#include "wtf/RefPtr.h"
+
+namespace WebKit {
+
+class WebMediaSourceImpl : public WebMediaSource {
+public:
+ WebMediaSourceImpl(PassRefPtr<WebCore::HTMLMediaSource>);
+ virtual ~WebMediaSourceImpl();
+
+ // WebMediaSource methods.
+ virtual void open(WebMediaSourceClient*);
+
+private:
+ RefPtr<WebCore::HTMLMediaSource> m_mediaSource;
+};
+
+}
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebMediaStreamRegistry.cpp b/chromium/third_party/WebKit/Source/web/WebMediaStreamRegistry.cpp
new file mode 100644
index 00000000000..077dbd10378
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebMediaStreamRegistry.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebMediaStreamRegistry.h"
+
+#include "core/platform/mediastream/MediaStreamDescriptor.h"
+#include "modules/mediastream/MediaStreamRegistry.h"
+#include "public/platform/WebMediaStream.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "weborigin/KURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebMediaStream WebMediaStreamRegistry::lookupMediaStreamDescriptor(const WebURL& url)
+{
+ return WebMediaStream(MediaStreamRegistry::registry().lookupMediaStreamDescriptor(KURL(url).string()));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebMutationEvent.cpp b/chromium/third_party/WebKit/Source/web/WebMutationEvent.cpp
new file mode 100644
index 00000000000..603ac94fb45
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/dom/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/chromium/third_party/WebKit/Source/web/WebNetworkStateNotifier.cpp b/chromium/third_party/WebKit/Source/web/WebNetworkStateNotifier.cpp
new file mode 100644
index 00000000000..96c18c9984c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebNetworkStateNotifier.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebNetworkStateNotifier.h"
+
+#include "core/platform/network/NetworkStateNotifier.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebNetworkStateNotifier::setOnLine(bool onLine)
+{
+ networkStateNotifier().setOnLine(onLine);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebNode.cpp b/chromium/third_party/WebKit/Source/web/WebNode.cpp
new file mode 100644
index 00000000000..54a6c32f2dd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebNode.cpp
@@ -0,0 +1,276 @@
+/*
+ * 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 "EventListenerWrapper.h"
+#include "FrameLoaderClientImpl.h"
+#include "WebDOMEvent.h"
+#include "WebDOMEventListener.h"
+#include "WebDocument.h"
+#include "WebElement.h"
+#include "WebFrameImpl.h"
+#include "WebNodeList.h"
+#include "WebPluginContainer.h"
+#include "WebPluginContainerImpl.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/dom/Document.h"
+#include "core/dom/Element.h"
+#include "core/dom/Event.h"
+#include "core/dom/Node.h"
+#include "core/dom/NodeList.h"
+#include "core/editing/markup.h"
+#include "core/page/Frame.h"
+#include "core/platform/Widget.h"
+#include "core/rendering/RenderObject.h"
+#include "core/rendering/RenderWidget.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.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)
+{
+ m_private->setNodeValue(value);
+ return true;
+}
+
+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::isLink() const
+{
+ return m_private->isLink();
+}
+
+bool WebNode::isTextNode() const
+{
+ return m_private->isTextNode();
+}
+
+bool WebNode::isFocusable() const
+{
+ if (!m_private->isElementNode())
+ return false;
+ m_private->document()->updateLayoutIgnorePendingStylesheets();
+ return toElement(m_private.get())->isFocusable();
+}
+
+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)
+{
+ // Please do not add more eventTypes to this list without an API review.
+ RELEASE_ASSERT(eventType == "mousedown");
+
+ 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);
+}
+
+bool WebNode::dispatchEvent(const WebDOMEvent& event)
+{
+ if (!event.isNull())
+ return m_private->dispatchEvent(event);
+ return false;
+}
+
+void WebNode::simulateClick()
+{
+ m_private->dispatchSimulatedClick(0);
+}
+
+WebNodeList WebNode::getElementsByTagName(const WebString& tag) const
+{
+ return WebNodeList(m_private->getElementsByTagName(tag));
+}
+
+WebElement WebNode::querySelector(const WebString& tag, WebExceptionCode& ec) const
+{
+ TrackExceptionState es;
+ WebElement element(m_private->querySelector(tag, es));
+ ec = es.code();
+ return element;
+}
+
+WebElement WebNode::rootEditableElement() const
+{
+ return WebElement(m_private->rootEditableElement());
+}
+
+bool WebNode::focused() const
+{
+ return m_private->focused();
+}
+
+bool WebNode::remove()
+{
+ TrackExceptionState es;
+ m_private->remove(es);
+ return !es.hadException();
+}
+
+bool WebNode::hasNonEmptyBoundingBox() const
+{
+ m_private->document()->updateLayoutIgnorePendingStylesheets();
+ return m_private->hasNonEmptyBoundingBox();
+}
+
+WebPluginContainer* WebNode::pluginContainer() const
+{
+ if (isNull())
+ return 0;
+ const Node* coreNode = constUnwrap<Node>();
+ if (coreNode->hasTagName(HTMLNames::objectTag) || coreNode->hasTagName(HTMLNames::embedTag)) {
+ RenderObject* object = coreNode->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = WebCore::toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer())
+ return static_cast<WebPluginContainerImpl*>(widget);
+ }
+ }
+ return 0;
+}
+
+WebElement WebNode::shadowHost() const
+{
+ if (isNull())
+ return WebElement();
+ const Node* coreNode = constUnwrap<Node>();
+ return WebElement(coreNode->shadowHost());
+}
+
+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/chromium/third_party/WebKit/Source/web/WebNodeCollection.cpp b/chromium/third_party/WebKit/Source/web/WebNodeCollection.cpp
new file mode 100644
index 00000000000..6efbe238644
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebNodeCollection.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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 "core/dom/Node.h"
+#include "core/html/HTMLCollection.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.leakRef()))
+{
+}
+
+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
+{
+ Node* node = m_private->item(m_current);
+ if (node)
+ m_current++;
+ return WebNode(node);
+}
+
+WebNode WebNodeCollection::firstItem() const
+{
+ m_current = 0;
+ return nextItem();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebNodeList.cpp b/chromium/third_party/WebKit/Source/web/WebNodeList.cpp
new file mode 100644
index 00000000000..4944ed802e7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/dom/Node.h"
+#include "core/dom/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.leakRef()))
+{
+}
+
+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/chromium/third_party/WebKit/Source/web/WebNotification.cpp b/chromium/third_party/WebKit/Source/web/WebNotification.cpp
new file mode 100644
index 00000000000..bc0f462f4f0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebNotification.cpp
@@ -0,0 +1,175 @@
+/*
+ * 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) || ENABLE(LEGACY_NOTIFICATIONS)
+
+#include "WebTextDirection.h"
+#include "core/dom/Event.h"
+#include "core/dom/UserGestureIndicator.h"
+#include "core/page/WindowFocusAllowedIndicator.h"
+#include "modules/notifications/Notification.h"
+#include "public/platform/WebString.h"
+#include "public/platform/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(); // FIXME: We should use WebPrivatePtr.
+ 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 false;
+}
+
+WebURL WebNotification::url() const
+{
+ return WebURL();
+}
+
+WebURL WebNotification::iconURL() const
+{
+ return m_private->iconURL();
+}
+
+WebString WebNotification::title() const
+{
+ return m_private->title();
+}
+
+WebString WebNotification::body() const
+{
+ return m_private->body();
+}
+
+WebTextDirection WebNotification::direction() const
+{
+ return (m_private->direction() == RTL) ?
+ WebTextDirectionRightToLeft :
+ WebTextDirectionLeftToRight;
+}
+
+WebString WebNotification::replaceId() const
+{
+ return m_private->tag();
+}
+
+void WebNotification::detachPresenter()
+{
+ m_private->detachPresenter();
+}
+
+void WebNotification::dispatchDisplayEvent()
+{
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ dispatchEvent("display");
+#endif
+ dispatchEvent("show");
+}
+
+void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */)
+{
+ // FIXME: errorMessage not supported by WebCore yet
+ dispatchEvent(eventNames().errorEvent);
+}
+
+void WebNotification::dispatchCloseEvent(bool /* byUser */)
+{
+ // FIXME: byUser flag not supported by WebCore yet
+ dispatchEvent(eventNames().closeEvent);
+}
+
+void WebNotification::dispatchClickEvent()
+{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ WindowFocusAllowedIndicator windowFocusAllowed;
+ dispatchEvent(eventNames().clickEvent);
+}
+
+void WebNotification::dispatchEvent(const WTF::AtomicString& type)
+{
+ // Do not dispatch if the context is gone.
+ if (!m_private->scriptExecutionContext())
+ return;
+
+ RefPtr<Event> event = Event::create(type, false, true);
+ m_private->dispatchEvent(event.release());
+}
+
+WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notification)
+ : m_private(static_cast<WebNotificationPrivate*>(notification.leakRef()))
+{
+}
+
+WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification)
+{
+ assign(static_cast<WebNotificationPrivate*>(notification.leakRef()));
+ 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) || ENABLE(LEGACY_NOTIFICATIONS)
diff --git a/chromium/third_party/WebKit/Source/web/WebOptionElement.cpp b/chromium/third_party/WebKit/Source/web/WebOptionElement.cpp
new file mode 100644
index 00000000000..65d9b9e7060
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebOptionElement.cpp
@@ -0,0 +1,101 @@
+/*
+ * 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 "core/html/HTMLOptionElement.h"
+#include "core/html/HTMLSelectElement.h"
+#include "public/platform/WebString.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+using namespace HTMLNames;
+
+namespace WebKit {
+
+void WebOptionElement::setValue(const WebString& newValue)
+{
+ 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>()->hasAttribute(selectedAttr);
+}
+
+void WebOptionElement::setDefaultSelected(bool newSelected)
+{
+ unwrap<HTMLOptionElement>()->setAttribute(selectedAttr, newSelected ? "" : 0);
+}
+
+WebString WebOptionElement::label() const
+{
+ return constUnwrap<HTMLOptionElement>()->label();
+}
+
+bool WebOptionElement::isEnabled() const
+{
+ return !(constUnwrap<HTMLOptionElement>()->isDisabledFormControl());
+}
+
+WebOptionElement::WebOptionElement(const PassRefPtr<HTMLOptionElement>& elem)
+ : WebElement(elem)
+{
+}
+
+WebOptionElement& WebOptionElement::operator=(const PassRefPtr<HTMLOptionElement>& elem)
+{
+ m_private = elem;
+ return *this;
+}
+
+WebOptionElement::operator PassRefPtr<HTMLOptionElement>() const
+{
+ return toHTMLOptionElement(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPagePopupImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPagePopupImpl.cpp
new file mode 100644
index 00000000000..c52a116d0b8
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPagePopupImpl.cpp
@@ -0,0 +1,354 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebPagePopupImpl.h"
+
+#include "PageWidgetDelegate.h"
+#include "WebCursorInfo.h"
+#include "WebInputEventConversion.h"
+#include "WebPagePopup.h"
+#include "WebSettingsImpl.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "WebWidgetClient.h"
+#include "core/dom/ContextFeatures.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/EmptyClients.h"
+#include "core/page/Chrome.h"
+#include "core/page/DOMWindowPagePopup.h"
+#include "core/page/EventHandler.h"
+#include "core/page/FocusController.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/PagePopupClient.h"
+#include "core/page/Settings.h"
+
+using namespace WebCore;
+using namespace std;
+
+namespace WebKit {
+
+class PagePopupChromeClient : public EmptyChromeClient {
+ WTF_MAKE_NONCOPYABLE(PagePopupChromeClient);
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ explicit PagePopupChromeClient(WebPagePopupImpl* popup)
+ : m_popup(popup)
+ {
+ ASSERT(m_popup->widgetClient());
+ }
+
+private:
+ virtual void closeWindowSoon() OVERRIDE
+ {
+ m_popup->closePopup();
+ }
+
+ virtual FloatRect windowRect() OVERRIDE
+ {
+ return FloatRect(m_popup->m_windowRectInScreen.x, m_popup->m_windowRectInScreen.y, m_popup->m_windowRectInScreen.width, m_popup->m_windowRectInScreen.height);
+ }
+
+ virtual void setWindowRect(const FloatRect& rect) OVERRIDE
+ {
+ m_popup->m_windowRectInScreen = IntRect(rect);
+ m_popup->widgetClient()->setWindowRect(m_popup->m_windowRectInScreen);
+ }
+
+ virtual void addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String&) OVERRIDE
+ {
+#ifndef NDEBUG
+ fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8().data());
+#else
+ UNUSED_PARAM(message);
+ UNUSED_PARAM(lineNumber);
+#endif
+ }
+
+ virtual void invalidateContentsAndRootView(const IntRect& paintRect) OVERRIDE
+ {
+ if (paintRect.isEmpty())
+ return;
+ m_popup->widgetClient()->didInvalidateRect(paintRect);
+ }
+
+ virtual void scroll(const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect& clipRect) OVERRIDE
+ {
+ m_popup->widgetClient()->didScrollRect(scrollDelta.width(), scrollDelta.height(), intersection(scrollRect, clipRect));
+ }
+
+ virtual void invalidateContentsForSlowScroll(const IntRect& updateRect) OVERRIDE
+ {
+ invalidateContentsAndRootView(updateRect);
+ }
+
+ virtual void scheduleAnimation() OVERRIDE
+ {
+ m_popup->widgetClient()->scheduleAnimation();
+ }
+
+ virtual WebScreenInfo screenInfo() const OVERRIDE
+ {
+ return m_popup->m_webView->client() ? m_popup->m_webView->client()->screenInfo() : WebScreenInfo();
+ }
+
+ virtual void* webView() const OVERRIDE
+ {
+ return m_popup->m_webView;
+ }
+
+ virtual FloatSize minimumWindowSize() const OVERRIDE
+ {
+ return FloatSize(0, 0);
+ }
+
+ virtual void setCursor(const WebCore::Cursor& cursor) OVERRIDE
+ {
+ if (m_popup->m_webView->client())
+ m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor));
+ }
+
+ virtual void needTouchEvents(bool needsTouchEvents) OVERRIDE
+ {
+ m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents);
+ }
+
+ WebPagePopupImpl* m_popup;
+};
+
+class PagePopupFeaturesClient : public ContextFeaturesClient {
+ virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool) OVERRIDE;
+};
+
+bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType type, bool defaultValue)
+{
+ if (type == ContextFeatures::PagePopup)
+ return true;
+ return defaultValue;
+}
+
+// WebPagePopupImpl ----------------------------------------------------------------
+
+WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client)
+ : m_widgetClient(client)
+ , m_closing(false)
+{
+ ASSERT(client);
+}
+
+WebPagePopupImpl::~WebPagePopupImpl()
+{
+ ASSERT(!m_page);
+}
+
+bool WebPagePopupImpl::initialize(WebViewImpl* webView, PagePopupClient* popupClient, const IntRect&)
+{
+ ASSERT(webView);
+ ASSERT(popupClient);
+ m_webView = webView;
+ m_popupClient = popupClient;
+
+ resize(m_popupClient->contentSize());
+
+ if (!initializePage())
+ return false;
+ m_widgetClient->show(WebNavigationPolicy());
+ setFocus(true);
+
+ return true;
+}
+
+bool WebPagePopupImpl::initializePage()
+{
+ Page::PageClients pageClients;
+ fillWithEmptyClients(pageClients);
+ m_chromeClient = adoptPtr(new PagePopupChromeClient(this));
+ pageClients.chromeClient = m_chromeClient.get();
+
+ m_page = adoptPtr(new Page(pageClients));
+ m_page->settings()->setScriptEnabled(true);
+ m_page->settings()->setAllowScriptsToCloseWindows(true);
+ m_page->setDeviceScaleFactor(m_webView->deviceScaleFactor());
+ m_page->settings()->setDeviceSupportsTouch(m_webView->page()->settings()->deviceSupportsTouch());
+
+ unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout;
+ m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones));
+
+ static ContextFeaturesClient* pagePopupFeaturesClient = new PagePopupFeaturesClient();
+ provideContextFeaturesTo(m_page.get(), pagePopupFeaturesClient);
+ static FrameLoaderClient* emptyFrameLoaderClient = new EmptyFrameLoaderClient();
+ RefPtr<Frame> frame = Frame::create(m_page.get(), 0, emptyFrameLoaderClient);
+ frame->setView(FrameView::create(frame.get()));
+ frame->init();
+ frame->view()->resize(m_popupClient->contentSize());
+ frame->view()->setTransparent(false);
+
+ DOMWindowPagePopup::install(frame->domWindow(), m_popupClient);
+
+ DocumentWriter* writer = frame->loader()->activeDocumentLoader()->beginWriting("text/html", "UTF-8");
+ m_popupClient->writeDocument(*writer);
+ frame->loader()->activeDocumentLoader()->endWriting(writer);
+ return true;
+}
+
+void WebPagePopupImpl::destroyPage()
+{
+ if (!m_page)
+ return;
+
+ if (m_page->mainFrame())
+ m_page->mainFrame()->loader()->frameDetached();
+
+ m_page.clear();
+}
+
+WebSize WebPagePopupImpl::size()
+{
+ return m_popupClient->contentSize();
+}
+
+void WebPagePopupImpl::animate(double)
+{
+ PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime());
+}
+
+void WebPagePopupImpl::layout()
+{
+ PageWidgetDelegate::layout(m_page.get());
+}
+
+void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions)
+{
+ if (!m_closing)
+ PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDelegate::Opaque);
+}
+
+void WebPagePopupImpl::resize(const WebSize& newSize)
+{
+ m_windowRectInScreen = WebRect(m_windowRectInScreen.x, m_windowRectInScreen.y, newSize.width, newSize.height);
+ m_widgetClient->setWindowRect(m_windowRectInScreen);
+
+ if (m_page)
+ m_page->mainFrame()->view()->resize(newSize);
+ m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.height));
+}
+
+bool WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent&)
+{
+ // The main WebView receives key events and forward them to this via handleKeyEvent().
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+bool WebPagePopupImpl::handleCharEvent(const WebKeyboardEvent&)
+{
+ // The main WebView receives key events and forward them to this via handleKeyEvent().
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+bool WebPagePopupImpl::handleGestureEvent(const WebGestureEvent& event)
+{
+ if (m_closing || !m_page || !m_page->mainFrame() || !m_page->mainFrame()->view())
+ return false;
+ Frame& frame = *m_page->mainFrame();
+ return frame.eventHandler()->handleGestureEvent(PlatformGestureEventBuilder(frame.view(), event));
+}
+
+bool WebPagePopupImpl::handleInputEvent(const WebInputEvent& event)
+{
+ if (m_closing)
+ return false;
+ return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, event);
+}
+
+bool WebPagePopupImpl::handleKeyEvent(const PlatformKeyboardEvent& event)
+{
+ if (m_closing || !m_page->mainFrame() || !m_page->mainFrame()->view())
+ return false;
+ return m_page->mainFrame()->eventHandler()->keyEvent(event);
+}
+
+void WebPagePopupImpl::setFocus(bool enable)
+{
+ if (!m_page)
+ return;
+ m_page->focusController().setFocused(enable);
+ if (enable)
+ m_page->focusController().setActive(true);
+}
+
+void WebPagePopupImpl::close()
+{
+ m_closing = true;
+ destroyPage(); // In case closePopup() was not called.
+ m_widgetClient = 0;
+ deref();
+}
+
+void WebPagePopupImpl::closePopup()
+{
+ if (m_page) {
+ m_page->clearPageGroup();
+ m_page->mainFrame()->loader()->stopAllLoaders();
+ m_page->mainFrame()->loader()->stopLoading();
+ DOMWindowPagePopup::uninstall(m_page->mainFrame()->domWindow());
+ }
+ m_closing = true;
+
+ destroyPage();
+
+ // m_widgetClient might be 0 because this widget might be already closed.
+ if (m_widgetClient) {
+ // closeWidgetSoon() will call this->close() later.
+ m_widgetClient->closeWidgetSoon();
+ }
+
+ m_popupClient->didClosePopup();
+}
+
+// WebPagePopup ----------------------------------------------------------------
+
+WebPagePopup* WebPagePopup::create(WebWidgetClient* client)
+{
+ if (!client)
+ CRASH();
+ // A WebPagePopupImpl instance usually has two references.
+ // - One owned by the instance itself. It represents the visible widget.
+ // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
+ // WebPagePopupImpl to close.
+ // We need them because the closing operation is asynchronous and the widget
+ // can be closed while the WebViewImpl is unaware of it.
+ return adoptRef(new WebPagePopupImpl(client)).leakRef();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPagePopupImpl.h b/chromium/third_party/WebKit/Source/web/WebPagePopupImpl.h
new file mode 100644
index 00000000000..a3c1cfb567f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPagePopupImpl.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 WebPagePopupImpl_h
+#define WebPagePopupImpl_h
+
+#include "PageWidgetDelegate.h"
+#include "WebPagePopup.h"
+#include "core/page/PagePopup.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+
+namespace WebCore {
+class Page;
+class PagePopupClient;
+class PlatformKeyboardEvent;
+}
+
+namespace WebKit {
+
+class PagePopupChromeClient;
+class WebViewImpl;
+
+class WebPagePopupImpl : public WebPagePopup,
+ public PageWidgetEventHandler,
+ public WebCore::PagePopup,
+ public RefCounted<WebPagePopupImpl> {
+ WTF_MAKE_NONCOPYABLE(WebPagePopupImpl);
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ virtual ~WebPagePopupImpl();
+ bool initialize(WebViewImpl*, WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView);
+ bool handleKeyEvent(const WebCore::PlatformKeyboardEvent&);
+ void closePopup();
+ WebWidgetClient* widgetClient() const { return m_widgetClient; }
+ bool hasSamePopupClient(WebPagePopupImpl* other) { return other && m_popupClient == other->m_popupClient; }
+
+private:
+ // WebWidget functions
+ virtual WebSize size() OVERRIDE;
+ virtual void animate(double) OVERRIDE;
+ virtual void layout() OVERRIDE;
+ virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
+ virtual void resize(const WebSize&) OVERRIDE;
+ virtual void close() OVERRIDE;
+ virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
+ virtual void setFocus(bool) OVERRIDE;
+
+ // PageWidgetEventHandler functions
+ virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE;
+ virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE;
+ virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE;
+
+ explicit WebPagePopupImpl(WebWidgetClient*);
+ bool initializePage();
+ void destroyPage();
+
+ WebWidgetClient* m_widgetClient;
+ WebRect m_windowRectInScreen;
+ WebViewImpl* m_webView;
+ OwnPtr<WebCore::Page> m_page;
+ OwnPtr<PagePopupChromeClient> m_chromeClient;
+ WebCore::PagePopupClient* m_popupClient;
+ bool m_closing;
+
+ friend class WebPagePopup;
+ friend class PagePopupChromeClient;
+};
+
+} // namespace WebKit
+#endif // WebPagePopupImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebPageSerializer.cpp b/chromium/third_party/WebKit/Source/web/WebPageSerializer.cpp
new file mode 100644
index 00000000000..4d0c25b4d6b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPageSerializer.cpp
@@ -0,0 +1,302 @@
+/*
+ * 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 "HTMLNames.h"
+#include "WebFrame.h"
+#include "WebFrameImpl.h"
+#include "WebPageSerializerClient.h"
+#include "WebPageSerializerImpl.h"
+#include "WebView.h"
+#include "WebViewImpl.h"
+#include "core/dom/Document.h"
+#include "core/dom/Element.h"
+#include "core/html/HTMLAllCollection.h"
+#include "core/html/HTMLFrameOwnerElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLTableElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/archive/MHTMLArchive.h"
+#include "core/page/Frame.h"
+#include "core/page/PageSerializer.h"
+#include "core/platform/SerializedResource.h"
+#include "public/platform/WebCString.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebVector.h"
+#include "weborigin/KURL.h"
+#include "wtf/Vector.h"
+#include "wtf/text/StringConcatenate.h"
+
+using namespace WebCore;
+
+namespace {
+
+KURL getSubResourceURLFromElement(Element* element)
+{
+ ASSERT(element);
+ const QualifiedName* attributeName = 0;
+ if (element->hasTagName(HTMLNames::imgTag) || element->hasTagName(HTMLNames::scriptTag))
+ attributeName = &HTMLNames::srcAttr;
+ else if (element->hasTagName(HTMLNames::inputTag)) {
+ if (toHTMLInputElement(element)->isImageButton())
+ attributeName = &HTMLNames::srcAttr;
+ } else if (element->hasTagName(HTMLNames::bodyTag)
+ || isHTMLTableElement(element)
+ || element->hasTagName(HTMLNames::trTag)
+ || element->hasTagName(HTMLNames::tdTag))
+ attributeName = &HTMLNames::backgroundAttr;
+ else if (element->hasTagName(HTMLNames::blockquoteTag)
+ || element->hasTagName(HTMLNames::qTag)
+ || element->hasTagName(HTMLNames::delTag)
+ || element->hasTagName(HTMLNames::insTag))
+ attributeName = &HTMLNames::citeAttr;
+ else if (element->hasTagName(HTMLNames::linkTag)) {
+ // If the link element is not css, ignore it.
+ if (equalIgnoringCase(element->getAttribute(HTMLNames::typeAttr), "text/css")) {
+ // FIXME: Add support for extracting links of sub-resources which
+ // are inside style-sheet such as @import, @font-face, url(), etc.
+ attributeName = &HTMLNames::hrefAttr;
+ }
+ } else if (element->hasTagName(HTMLNames::objectTag))
+ attributeName = &HTMLNames::dataAttr;
+ else if (element->hasTagName(HTMLNames::embedTag))
+ attributeName = &HTMLNames::srcAttr;
+
+ if (!attributeName)
+ return KURL();
+
+ String value = element->getAttribute(*attributeName);
+ // Ignore javascript content.
+ if (value.isEmpty() || value.stripWhiteSpace().startsWith("javascript:", false))
+ return KURL();
+
+ return element->document()->completeURL(value);
+}
+
+void retrieveResourcesForElement(Element* element,
+ Vector<Frame*>* visitedFrames,
+ Vector<Frame*>* framesToVisit,
+ Vector<KURL>* frameURLs,
+ Vector<KURL>* resourceURLs)
+{
+ // If the node is a frame, we'll process it later in retrieveResourcesForFrame.
+ if ((element->hasTagName(HTMLNames::iframeTag) || element->hasTagName(HTMLNames::frameTag)
+ || element->hasTagName(HTMLNames::objectTag) || element->hasTagName(HTMLNames::embedTag))
+ && element->isFrameOwnerElement()) {
+ Frame* frame = static_cast<HTMLFrameOwnerElement*>(element)->contentFrame();
+ if (frame) {
+ if (!visitedFrames->contains(frame))
+ framesToVisit->append(frame);
+ return;
+ }
+ }
+
+ KURL url = getSubResourceURLFromElement(element);
+ if (url.isEmpty() || !url.isValid())
+ return; // No subresource for this node.
+
+ // Ignore URLs that have a non-standard protocols. Since the FTP protocol
+ // does no have a cache mechanism, we skip it as well.
+ if (!url.protocolIsInHTTPFamily() && !url.isLocalFile())
+ return;
+
+ if (!resourceURLs->contains(url))
+ resourceURLs->append(url);
+}
+
+void retrieveResourcesForFrame(Frame* frame,
+ const WebKit::WebVector<WebKit::WebCString>& supportedSchemes,
+ Vector<Frame*>* visitedFrames,
+ Vector<Frame*>* framesToVisit,
+ Vector<KURL>* frameURLs,
+ Vector<KURL>* resourceURLs)
+{
+ KURL frameURL = frame->loader()->documentLoader()->request().url();
+
+ // If the frame's URL is invalid, ignore it, it is not retrievable.
+ if (!frameURL.isValid())
+ return;
+
+ // Ignore frames from unsupported schemes.
+ bool isValidScheme = false;
+ for (size_t i = 0; i < supportedSchemes.size(); ++i) {
+ if (frameURL.protocolIs(static_cast<CString>(supportedSchemes[i]).data())) {
+ isValidScheme = true;
+ break;
+ }
+ }
+ if (!isValidScheme)
+ return;
+
+ // If we have already seen that frame, ignore it.
+ if (visitedFrames->contains(frame))
+ return;
+ visitedFrames->append(frame);
+ if (!frameURLs->contains(frameURL))
+ frameURLs->append(frameURL);
+
+ // Now get the resources associated with each node of the document.
+ RefPtr<HTMLCollection> allNodes = frame->document()->all();
+ for (unsigned i = 0; i < allNodes->length(); ++i) {
+ Node* node = allNodes->item(i);
+ // We are only interested in HTML resources.
+ if (!node->isElementNode())
+ continue;
+ retrieveResourcesForElement(toElement(node),
+ visitedFrames, framesToVisit,
+ frameURLs, resourceURLs);
+ }
+}
+
+} // namespace
+
+namespace WebKit {
+
+void WebPageSerializer::serialize(WebView* view, WebVector<WebPageSerializer::Resource>* resourcesParam)
+{
+ Vector<SerializedResource> resources;
+ PageSerializer serializer(&resources);
+ serializer.serialize(static_cast<WebViewImpl*>(view)->page());
+
+ Vector<Resource> result;
+ for (Vector<SerializedResource>::const_iterator iter = resources.begin(); iter != resources.end(); ++iter) {
+ Resource resource;
+ resource.url = iter->url;
+ resource.mimeType = iter->mimeType.ascii();
+ // FIXME: we are copying all the resource data here. Idealy we would have a WebSharedData().
+ resource.data = WebCString(iter->data->data(), iter->data->size());
+ result.append(resource);
+ }
+
+ *resourcesParam = result;
+}
+
+static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::EncodingPolicy encodingPolicy)
+{
+ Vector<SerializedResource> resources;
+ PageSerializer serializer(&resources);
+ serializer.serialize(page);
+ Document* document = page->mainFrame()->document();
+ return MHTMLArchive::generateMHTMLData(resources, encodingPolicy, document->title(), document->suggestedMIMEType());
+}
+
+WebCString WebPageSerializer::serializeToMHTML(WebView* view)
+{
+ RefPtr<SharedBuffer> mhtml = serializePageToMHTML(static_cast<WebViewImpl*>(view)->page(), MHTMLArchive::UseDefaultEncoding);
+ // FIXME: we are copying all the data here. Idealy we would have a WebSharedData().
+ return WebCString(mhtml->data(), mhtml->size());
+}
+
+WebCString WebPageSerializer::serializeToMHTMLUsingBinaryEncoding(WebView* view)
+{
+ RefPtr<SharedBuffer> mhtml = serializePageToMHTML(static_cast<WebViewImpl*>(view)->page(), MHTMLArchive::UseBinaryEncoding);
+ // FIXME: we are copying all the data here. Idealy we would have a WebSharedData().
+ return WebCString(mhtml->data(), mhtml->size());
+}
+
+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();
+}
+
+bool WebPageSerializer::retrieveAllResources(WebView* view,
+ const WebVector<WebCString>& supportedSchemes,
+ WebVector<WebURL>* resourceURLs,
+ WebVector<WebURL>* frameURLs) {
+ WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(view->mainFrame());
+ if (!mainFrame)
+ return false;
+
+ Vector<Frame*> framesToVisit;
+ Vector<Frame*> visitedFrames;
+ Vector<KURL> frameKURLs;
+ Vector<KURL> resourceKURLs;
+
+ // Let's retrieve the resources from every frame in this page.
+ framesToVisit.append(mainFrame->frame());
+ while (!framesToVisit.isEmpty()) {
+ Frame* frame = framesToVisit[0];
+ framesToVisit.remove(0);
+ retrieveResourcesForFrame(frame, supportedSchemes,
+ &visitedFrames, &framesToVisit,
+ &frameKURLs, &resourceKURLs);
+ }
+
+ // Converts the results to WebURLs.
+ WebVector<WebURL> resultResourceURLs(resourceKURLs.size());
+ for (size_t i = 0; i < resourceKURLs.size(); ++i) {
+ resultResourceURLs[i] = resourceKURLs[i];
+ // A frame's src can point to the same URL as another resource, keep the
+ // resource URL only in such cases.
+ size_t index = frameKURLs.find(resourceKURLs[i]);
+ if (index != notFound)
+ frameKURLs.remove(index);
+ }
+ *resourceURLs = resultResourceURLs;
+ WebVector<WebURL> resultFrameURLs(frameKURLs.size());
+ for (size_t i = 0; i < frameKURLs.size(); ++i)
+ resultFrameURLs[i] = frameKURLs[i];
+ *frameURLs = resultFrameURLs;
+
+ return true;
+}
+
+WebString WebPageSerializer::generateMetaCharsetDeclaration(const WebString& charset)
+{
+ String charsetString = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + static_cast<const String&>(charset) + "\">";
+ return charsetString;
+}
+
+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 String("<base href=\".\">");
+ String baseString = "<base href=\".\" target=\"" + static_cast<const String&>(baseTarget) + "\">";
+ return baseString;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp
new file mode 100644
index 00000000000..41aa2ba99cc
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp
@@ -0,0 +1,530 @@
+/*
+ * 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 "DOMUtilitiesPrivate.h"
+#include "HTMLNames.h"
+#include "WebFrameImpl.h"
+#include "core/dom/Document.h"
+#include "core/dom/DocumentType.h"
+#include "core/dom/Element.h"
+#include "core/editing/markup.h"
+#include "core/html/HTMLAllCollection.h"
+#include "core/html/HTMLElement.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLHtmlElement.h"
+#include "core/html/HTMLMetaElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoader.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebVector.h"
+#include "weborigin/KURL.h"
+#include "wtf/text/TextEncoding.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 WTF::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 (isHTMLHtmlElement(element)) {
+ // 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->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.clear();
+
+ CString encodedContent = param->textEncoding.normalizeAndEncode(content, WTF::EntitiesForUnencodables);
+
+ // Send result to the client.
+ m_client->didSerializeDataForFrame(param->url,
+ WebCString(encodedContent.data(), encodedContent.length()),
+ status);
+}
+
+void WebPageSerializerImpl::openTagToString(Element* element,
+ SerializeDomParam* param)
+{
+ bool needSkip;
+ StringBuilder result;
+ // Do pre action for open tag.
+ result.append(preActionBeforeSerializeOpenTag(element, param, &needSkip));
+ if (needSkip)
+ return;
+ // Add open tag
+ result.append('<');
+ result.append(element->nodeName().lower());
+ // Go through all attributes and serialize them.
+ if (element->hasAttributes()) {
+ unsigned numAttrs = element->attributeCount();
+ for (unsigned i = 0; i < numAttrs; i++) {
+ result.append(' ');
+ // Add attribute pair
+ const Attribute *attribute = element->attributeItem(i);
+ result.append(attribute->name().toString());
+ result.appendLiteral("=\"");
+ 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.append(attrValue);
+ else {
+ // Get the absolute link
+ WebFrameImpl* subFrame = WebFrameImpl::fromFrameOwnerElement(element);
+ String completeURL = subFrame ? subFrame->frame()->document()->url() :
+ param->document->completeURL(attrValue);
+ // Check whether we have local files for those link.
+ if (m_localLinks.contains(completeURL)) {
+ if (!param->directoryName.isEmpty()) {
+ result.appendLiteral("./");
+ result.append(param->directoryName);
+ result.append('/');
+ }
+ result.append(m_localLinks.get(completeURL));
+ } else
+ result.append(completeURL);
+ }
+ } else {
+ if (param->isHTMLDocument)
+ result.append(m_htmlEntities.convertEntitiesInString(attrValue));
+ else
+ result.append(m_xmlEntities.convertEntitiesInString(attrValue));
+ }
+ }
+ result.append('\"');
+ }
+ }
+
+ // 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('>');
+ // Append the added contents generate in post action of open tag.
+ result.append(addedContents);
+ // Save the result to data buffer.
+ saveHTMLContentToBuffer(result.toString(), param);
+}
+
+// Serialize end tag of an specified element.
+void WebPageSerializerImpl::endTagToString(Element* element,
+ SerializeDomParam* param)
+{
+ bool needSkip;
+ StringBuilder result;
+ // Do pre action for end tag.
+ result.append(preActionBeforeSerializeEndTag(element, param, &needSkip));
+ if (needSkip)
+ return;
+ // Write end tag when element has child/children.
+ if (element->hasChildNodes() || param->haveAddedContentsBeforeEnd) {
+ result.appendLiteral("</");
+ result.append(element->nodeName().lower());
+ result.append('>');
+ } else {
+ // Check whether we have to write end tag for empty element.
+ if (param->isHTMLDocument) {
+ result.append('>');
+ // FIXME: This code is horribly wrong. WebPageSerializerImpl must die.
+ if (!element->isHTMLElement() || !toHTMLElement(element)->ieForbidsInsertHTML()) {
+ // We need to write end tag when it is required.
+ result.appendLiteral("</");
+ result.append(element->nodeName().lower());
+ result.append('>');
+ }
+ } else {
+ // For xml base document.
+ result.appendLiteral(" />");
+ }
+ }
+ // Do post action for end tag.
+ result.append(postActionAfterSerializeEndTag(element, param));
+ // Save the result to data buffer.
+ saveHTMLContentToBuffer(result.toString(), param);
+}
+
+void WebPageSerializerImpl::buildContentForNode(Node* node,
+ SerializeDomParam* param)
+{
+ switch (node->nodeType()) {
+ case Node::ELEMENT_NODE:
+ // Process open tag of element.
+ openTagToString(toElement(node), param);
+ // Walk through the children nodes and process it.
+ for (Node *child = node->firstChild(); child; child = child->nextSibling())
+ buildContentForNode(child, param);
+ // Process end tag of element.
+ endTagToString(toElement(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<HTMLCollection> all = currentDoc->all();
+
+ for (unsigned i = 0; Node* node = all->item(i); i++) {
+ if (!node->isHTMLElement())
+ continue;
+ Element* element = toElement(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 = document->encoding();
+ const WTF::TextEncoding& textEncoding = encoding.isEmpty() ? UTF8Encoding() : WTF::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/chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.h b/chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.h
new file mode 100644
index 00000000000..5cd37fba3f0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPageSerializerImpl.h
@@ -0,0 +1,192 @@
+/*
+ * 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 "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+
+namespace WTF{
+class TextEncoding;
+}
+
+namespace WebCore {
+class Document;
+class Element;
+class Node;
+}
+
+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 WTF::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 WTF::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(WebCore::Element*,
+ SerializeDomParam* param);
+ // Serialize end tag of an specified element.
+ void endTagToString(WebCore::Element*,
+ SerializeDomParam* param);
+ // Build content for a specified node
+ void buildContentForNode(WebCore::Node*,
+ SerializeDomParam* param);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebPasswordFormData.cpp b/chromium/third_party/WebKit/Source/web/WebPasswordFormData.cpp
new file mode 100644
index 00000000000..c3aba9ae1ff
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPasswordFormData.cpp
@@ -0,0 +1,182 @@
+/*
+ * 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 "HTMLNames.h"
+#include "core/dom/Document.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoader.h"
+#include "core/page/Frame.h"
+#include "weborigin/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,
+ const Vector<String>& alternateUserNames,
+ 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;
+
+ result->possibleUserNames = alternateUserNames;
+ 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();
+ result->passwordShouldAutocomplete = password->shouldAutocomplete();
+ }
+ if (oldPassword) {
+ result->oldPasswordElement = oldPassword->name();
+ result->oldPasswordValue = oldPassword->value();
+ }
+}
+
+} // namespace
+
+WebPasswordFormData::WebPasswordFormData(const WebFormElement& webForm)
+{
+ RefPtr<HTMLFormElement> form = webForm.operator PassRefPtr<HTMLFormElement>();
+ 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 = form->document()->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,
+ fields.alternateUserNames,
+ oldPassword, password, this);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.cpp b/chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.cpp
new file mode 100644
index 00000000000..6bac3ef4edf
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.cpp
@@ -0,0 +1,104 @@
+/* ***** 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 "HTMLNames.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLInputElement.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);
+
+ HTMLInputElement* latestInputElement = 0;
+ const Vector<FormAssociatedElement*>& formElements = form->associatedElements();
+ for (size_t i = 0; i < formElements.size(); i++) {
+ if (!formElements[i]->isFormControlElement())
+ continue;
+ HTMLFormControlElement* control = toHTMLFormControlElement(formElements[i]);
+ if (control->isActivatedSubmit())
+ fields->submit = control;
+
+ if (!control->hasTagName(HTMLNames::inputTag))
+ continue;
+
+ HTMLInputElement* inputElement = toHTMLInputElement(control);
+ if (inputElement->isDisabledFormControl())
+ continue;
+
+ if ((fields->passwords.size() < maxPasswords)
+ && inputElement->isPasswordField()) {
+ // We assume that the username is the input element before the
+ // first password element.
+ if (fields->passwords.isEmpty() && latestInputElement) {
+ fields->userName = latestInputElement;
+ // Remove the selected username from alternateUserNames.
+ if (!fields->alternateUserNames.isEmpty() && !latestInputElement->value().isEmpty())
+ fields->alternateUserNames.removeLast();
+ }
+ fields->passwords.append(inputElement);
+ }
+
+ // Various input types such as text, url, email can be a username field.
+ if (inputElement->isTextField() && !inputElement->isPasswordField()) {
+ latestInputElement = inputElement;
+ // We ignore elements that have no value. Unlike userName, alternateUserNames
+ // is used only for autofill, not for form identification, and blank autofill
+ // entries are not useful.
+ if (!inputElement->value().isEmpty())
+ fields->alternateUserNames.append(inputElement->value());
+ }
+ }
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.h b/chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.h
new file mode 100644
index 00000000000..873ede3d74c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPasswordFormUtils.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 WebPasswordFormUtils_h
+#define WebPasswordFormUtils_h
+
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+class HTMLInputElement;
+class HTMLFormControlElement;
+class HTMLFormElement;
+}
+
+namespace WebKit {
+
+// Helper structure to locate username, passwords and submit fields.
+//
+// Note that we don't check autocomplete property here. The applications using
+// password forms can use WebPasswordFormData.passwordShouldAutocomplete to
+// implement their own heuristics related autocomplete.
+struct PasswordFormFields {
+ WebCore::HTMLInputElement* userName;
+ Vector<String> alternateUserNames;
+ 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/chromium/third_party/WebKit/Source/web/WebPerformance.cpp b/chromium/third_party/WebKit/Source/web/WebPerformance.cpp
new file mode 100644
index 00000000000..8f8b5047dab
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/page/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/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
new file mode 100644
index 00000000000..8b0e887a5e0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
@@ -0,0 +1,897 @@
+/*
+ * 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 "ChromeClientImpl.h"
+#include "ScrollbarGroup.h"
+#include "WebCursorInfo.h"
+#include "WebDataSourceImpl.h"
+#include "WebElement.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebPlugin.h"
+#include "WebViewClient.h"
+#include "WebViewImpl.h"
+#include "core/page/Chrome.h"
+#include "core/page/EventHandler.h"
+#include "core/platform/chromium/ClipboardChromium.h"
+#include "core/platform/chromium/support/WrappedResourceResponse.h"
+
+#include "HTMLNames.h"
+#include "WebPrintParams.h"
+#include "bindings/v8/ScriptController.h"
+#include "core/dom/EventNames.h"
+#include "core/dom/GestureEvent.h"
+#include "core/dom/KeyboardEvent.h"
+#include "core/dom/MouseEvent.h"
+#include "core/dom/TouchEvent.h"
+#include "core/dom/UserGestureIndicator.h"
+#include "core/dom/WheelEvent.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLPlugInElement.h"
+#include "core/loader/FormState.h"
+#include "core/loader/FrameLoadRequest.h"
+#include "core/page/FocusController.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/scrolling/ScrollingCoordinator.h"
+#include "core/platform/HostWindow.h"
+#include "core/platform/PlatformGestureEvent.h"
+#include "core/platform/ScrollAnimator.h"
+#include "core/platform/ScrollView.h"
+#include "core/platform/ScrollbarTheme.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/plugins/IFrameShimSupport.h"
+#include "core/rendering/HitTestResult.h"
+#include "core/rendering/RenderBox.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebClipboard.h"
+#include "public/platform/WebCompositorSupport.h"
+#include "public/platform/WebDragData.h"
+#include "public/platform/WebExternalTextureLayer.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLError.h"
+#include "public/platform/WebURLRequest.h"
+#include "public/platform/WebVector.h"
+
+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->updatingControlTints() && m_scrollbarGroup) {
+ // See comment in FrameView::updateControlTints().
+ if (m_scrollbarGroup->horizontalScrollbar())
+ m_scrollbarGroup->horizontalScrollbar()->invalidate();
+ if (m_scrollbarGroup->verticalScrollbar())
+ m_scrollbarGroup->verticalScrollbar()->invalidate();
+ }
+
+ 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->contentsToWindow(IntPoint(0, 0));
+ gc->translate(static_cast<float>(-origin.x()), static_cast<float>(-origin.y()));
+
+ WebCanvas* canvas = gc->canvas();
+
+ IntRect windowRect = view->contentsToWindow(damageRect);
+ m_webPlugin->paint(canvas, windowRect);
+
+ gc->restore();
+}
+
+void WebPluginContainerImpl::invalidateRect(const IntRect& rect)
+{
+ if (!parent())
+ return;
+
+ RenderBox* renderer = toRenderBox(m_element->renderer());
+
+ IntRect dirtyRect = rect;
+ dirtyRect.move(renderer->borderLeft() + renderer->paddingLeft(),
+ renderer->borderTop() + renderer->paddingTop());
+ renderer->repaintRectangle(dirtyRect);
+}
+
+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;
+
+ const WebInputEvent* currentInputEvent = WebViewImpl::currentInputEvent();
+ UserGestureIndicator gestureIndicator(currentInputEvent && WebInputEvent::isUserGestureEventType(currentInputEvent->type) ? DefinitelyProcessingNewUserGesture : PossiblyProcessingUserGesture);
+
+ RefPtr<WebPluginContainerImpl> protector(this);
+ // 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(toMouseEvent(event));
+ else if (event->hasInterface(eventNames().interfaceForWheelEvent))
+ handleWheelEvent(static_cast<WheelEvent*>(event));
+ else if (event->isKeyboardEvent())
+ handleKeyboardEvent(toKeyboardEvent(event));
+ else if (eventNames().isTouchEventType(event->type()))
+ handleTouchEvent(static_cast<TouchEvent*>(event));
+ else if (eventNames().isGestureEventType(event->type()))
+ handleGestureEvent(static_cast<GestureEvent*>(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::clipRectChanged()
+{
+ reportGeometry();
+}
+
+void WebPluginContainerImpl::eventListenersRemoved()
+{
+ // We're no longer registered to receive touch events, so don't try to remove
+ // the touch event handlers in our destructor.
+ m_touchEventRequestType = TouchEventRequestTypeNone;
+}
+
+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();
+}
+
+void WebPluginContainerImpl::setPlugin(WebPlugin* plugin)
+{
+ if (plugin != m_webPlugin) {
+ m_element->resetInstance();
+ m_webPlugin = plugin;
+ }
+}
+
+float WebPluginContainerImpl::deviceScaleFactor()
+{
+ Page* page = m_element->document()->page();
+ if (!page)
+ return 1.0;
+ return page->deviceScaleFactor();
+}
+
+float WebPluginContainerImpl::pageScaleFactor()
+{
+ Page* page = m_element->document()->page();
+ if (!page)
+ return 1.0;
+ return page->pageScaleFactor();
+}
+
+float WebPluginContainerImpl::pageZoomFactor()
+{
+ Frame* frame = m_element->document()->frame();
+ if (!frame)
+ return 1.0;
+ return frame->pageZoomFactor();
+}
+
+void WebPluginContainerImpl::setWebLayer(WebLayer* layer)
+{
+ if (m_webLayer == layer)
+ return;
+
+ // If anyone of the layers is null we need to switch between hardware
+ // and software compositing.
+ if (!m_webLayer || !layer)
+ m_element->scheduleLayerUpdate();
+ if (m_webLayer)
+ GraphicsLayer::unregisterContentsLayer(m_webLayer);
+ if (layer)
+ GraphicsLayer::registerContentsLayer(layer);
+ m_webLayer = layer;
+}
+
+bool WebPluginContainerImpl::supportsPaginatedPrint() const
+{
+ return m_webPlugin->supportsPaginatedPrint();
+}
+
+bool WebPluginContainerImpl::isPrintScalingDisabled() const
+{
+ return m_webPlugin->isPrintScalingDisabled();
+}
+
+int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const
+{
+ return m_webPlugin->printBegin(printParams);
+}
+
+bool WebPluginContainerImpl::printPage(int pageNumber,
+ WebCore::GraphicsContext* gc)
+{
+ gc->save();
+ WebCanvas* canvas = gc->canvas();
+ bool ret = m_webPlugin->printPage(pageNumber, canvas);
+ gc->restore();
+ return ret;
+}
+
+void WebPluginContainerImpl::printEnd()
+{
+ m_webPlugin->printEnd();
+}
+
+void WebPluginContainerImpl::copy()
+{
+ if (!m_webPlugin->hasSelection())
+ return;
+
+ WebKit::Platform::current()->clipboard()->writeHTML(m_webPlugin->selectionAsMarkup(), WebURL(), m_webPlugin->selectionAsText(), false);
+}
+
+bool WebPluginContainerImpl::executeEditCommand(const WebString& name)
+{
+ if (m_webPlugin->executeEditCommand(name))
+ return true;
+
+ if (name != "Copy")
+ return false;
+
+ copy();
+ return true;
+}
+
+bool WebPluginContainerImpl::executeEditCommand(const WebString& name, const WebString& value)
+{
+ return m_webPlugin->executeEditCommand(name, value);
+}
+
+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 = toFrameView(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());
+
+ if (m_scrollbarGroup) {
+ m_scrollbarGroup->scrollAnimator()->contentsResized();
+ m_scrollbarGroup->setFrameRect(frameRect());
+ }
+}
+
+void WebPluginContainerImpl::allowScriptObjects()
+{
+}
+
+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 || !frame->loader()->documentLoader())
+ 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.
+ OwnPtr<WebPluginLoadObserver> observer = adoptPtr(new WebPluginLoadObserver(this, request.url(), notifyData));
+ // FIXME: Calling get here is dangerous! What if observer is freed?
+ m_pluginLoadObservers.append(observer.get());
+ WebDataSourceImpl::setNextPluginLoadObserver(observer.release());
+ }
+
+ FrameLoadRequest frameRequest(frame->document()->securityOrigin(), request.toResourceRequest(), target);
+ UserGestureIndicator gestureIndicator(request.hasUserGesture() ? DefinitelyProcessingNewUserGesture : PossiblyProcessingUserGesture);
+ frame->loader()->load(frameRequest);
+}
+
+void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel)
+{
+ WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page());
+ view->fullFramePluginZoomLevelChanged(zoomLevel);
+}
+
+bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect)
+{
+ Frame* frame = m_element->document()->frame();
+ if (!frame)
+ return false;
+
+ // hitTestResultAtPoint() takes a padding rectangle.
+ // FIXME: We'll be off by 1 when the width or height is even.
+ IntRect documentRect(x() + rect.x, y() + rect.y, rect.width, rect.height);
+ LayoutPoint center = documentRect.center();
+ // Make the rect we're checking (the point surrounded by padding rects) contained inside the requested rect. (Note that -1/2 is 0.)
+ LayoutSize padding((documentRect.width() - 1) / 2, (documentRect.height() - 1) / 2);
+ HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(center, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent, padding);
+ const HitTestResult::NodeSet& nodes = result.rectBasedTestResult();
+ if (nodes.size() != 1)
+ return false;
+ return nodes.first().get() == m_element;
+}
+
+void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType requestType)
+{
+ if (m_touchEventRequestType == requestType)
+ return;
+
+ if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == TouchEventRequestTypeNone)
+ m_element->document()->didAddTouchEventHandler(m_element);
+ else if (requestType == TouchEventRequestTypeNone && m_touchEventRequestType != TouchEventRequestTypeNone)
+ m_element->document()->didRemoveTouchEventHandler(m_element);
+ m_touchEventRequestType = requestType;
+}
+
+void WebPluginContainerImpl::setWantsWheelEvents(bool wantsWheelEvents)
+{
+ if (m_wantsWheelEvents == wantsWheelEvents)
+ return;
+ m_wantsWheelEvents = wantsWheelEvents;
+ if (Page* page = m_element->document()->page()) {
+ if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) {
+ if (parent() && parent()->isFrameView())
+ scrollingCoordinator->frameViewLayoutUpdated(toFrameView(parent()));
+ }
+ }
+}
+
+WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point)
+{
+ ScrollView* view = parent();
+ if (!view)
+ return point;
+ WebPoint windowPoint = view->windowToContents(point);
+ return roundedIntPoint(m_element->renderer()->absoluteToLocal(LayoutPoint(windowPoint), UseTransforms));
+}
+
+WebPoint WebPluginContainerImpl::localToWindowPoint(const WebPoint& point)
+{
+ ScrollView* view = parent();
+ if (!view)
+ return point;
+ IntPoint absolutePoint = roundedIntPoint(m_element->renderer()->localToAbsolute(LayoutPoint(point), UseTransforms));
+ return view->contentsToWindow(absolutePoint);
+}
+
+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);
+}
+
+WebLayer* WebPluginContainerImpl::platformLayer() const
+{
+ return m_webLayer;
+}
+
+NPObject* WebPluginContainerImpl::scriptableObject()
+{
+ return m_webPlugin->scriptableObject();
+}
+
+bool WebPluginContainerImpl::getFormValue(String& value)
+{
+ WebString webValue;
+ if (m_webPlugin->getFormValue(webValue)) {
+ value = webValue;
+ return true;
+ }
+ return false;
+}
+
+bool WebPluginContainerImpl::supportsKeyboardFocus() const
+{
+ return m_webPlugin->supportsKeyboardFocus();
+}
+
+bool WebPluginContainerImpl::canProcessDrag() const
+{
+ return m_webPlugin->canProcessDrag();
+}
+
+bool WebPluginContainerImpl::wantsWheelEvents()
+{
+ return m_wantsWheelEvents;
+}
+
+void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver* observer)
+{
+ size_t pos = m_pluginLoadObservers.find(observer);
+ if (pos == notFound)
+ return;
+ m_pluginLoadObservers.remove(pos);
+}
+
+ScrollbarGroup* WebPluginContainerImpl::scrollbarGroup()
+{
+ if (!m_scrollbarGroup)
+ m_scrollbarGroup = adoptPtr(new ScrollbarGroup(m_element->document()->frame()->view(), frameRect()));
+ return m_scrollbarGroup.get();
+}
+
+void WebPluginContainerImpl::willStartLiveResize()
+{
+ if (m_scrollbarGroup)
+ m_scrollbarGroup->willStartLiveResize();
+}
+
+void WebPluginContainerImpl::willEndLiveResize()
+{
+ if (m_scrollbarGroup)
+ m_scrollbarGroup->willEndLiveResize();
+}
+
+bool WebPluginContainerImpl::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
+{
+ context->save();
+ context->setFillColor(Color(0xCC, 0xCC, 0xCC));
+ context->fillRect(intersection(horizontalOverhangArea, dirtyRect));
+ context->fillRect(intersection(verticalOverhangArea, dirtyRect));
+ context->restore();
+ return true;
+}
+
+// Private methods -------------------------------------------------------------
+
+WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
+ : m_element(element)
+ , m_webPlugin(webPlugin)
+ , m_webLayer(0)
+ , m_touchEventRequestType(TouchEventRequestTypeNone)
+ , m_wantsWheelEvents(false)
+{
+}
+
+WebPluginContainerImpl::~WebPluginContainerImpl()
+{
+ if (m_touchEventRequestType != TouchEventRequestTypeNone)
+ m_element->document()->didRemoveTouchEventHandler(m_element);
+
+ for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
+ m_pluginLoadObservers[i]->clearPluginContainer();
+ m_webPlugin->destroy();
+ if (m_webLayer)
+ GraphicsLayer::unregisterContentsLayer(m_webLayer);
+}
+
+void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
+{
+ ASSERT(parent()->isFrameView());
+
+ if (event->isDragEvent()) {
+ if (m_webPlugin->canProcessDrag())
+ handleDragEvent(event);
+ return;
+ }
+
+ // 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 = toFrameView(parent());
+
+ WebMouseEventBuilder webEvent(this, m_element->renderer(), *event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+
+ if (event->type() == eventNames().mousedownEvent)
+ focusPlugin();
+
+ if (m_scrollbarGroup) {
+ // This needs to be set before the other callbacks in this scope, since
+ // the scroll animator class might query the position in response.
+ m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y()));
+ if (event->type() == eventNames().mousemoveEvent)
+ m_scrollbarGroup->scrollAnimator()->mouseMovedInContentArea();
+ else if (event->type() == eventNames().mouseoverEvent)
+ m_scrollbarGroup->scrollAnimator()->mouseEnteredContentArea();
+ else if (event->type() == eventNames().mouseoutEvent)
+ m_scrollbarGroup->scrollAnimator()->mouseExitedContentArea();
+ }
+
+ 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::handleDragEvent(MouseEvent* event)
+{
+ ASSERT(event->isDragEvent());
+
+ WebDragStatus dragStatus = WebDragStatusUnknown;
+ if (event->type() == eventNames().dragenterEvent)
+ dragStatus = WebDragStatusEnter;
+ else if (event->type() == eventNames().dragleaveEvent)
+ dragStatus = WebDragStatusLeave;
+ else if (event->type() == eventNames().dragoverEvent)
+ dragStatus = WebDragStatusOver;
+ else if (event->type() == eventNames().dropEvent)
+ dragStatus = WebDragStatusDrop;
+
+ if (dragStatus == WebDragStatusUnknown)
+ return;
+
+ ClipboardChromium* clipboard = static_cast<ClipboardChromium*>(event->dataTransfer());
+ WebDragData dragData = clipboard->dataObject();
+ WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation());
+ WebPoint dragScreenLocation(event->screenX(), event->screenY());
+ WebPoint dragLocation(event->absoluteLocation().x() - location().x(), event->absoluteLocation().y() - location().y());
+
+ m_webPlugin->handleDragStatusUpdate(dragStatus, dragData, dragOperationMask, dragLocation, dragScreenLocation);
+}
+
+void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event)
+{
+ WebMouseWheelEventBuilder webEvent(this, m_element->renderer(), *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 OS(DARWIN)
+ 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);
+ }
+
+ // Give the client a chance to issue edit comamnds.
+ WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page());
+ if (m_webPlugin->supportsEditCommands() && view->client())
+ view->client()->handleCurrentKeyboardEvent();
+
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ event->setDefaultHandled();
+}
+
+void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event)
+{
+ switch (m_touchEventRequestType) {
+ case TouchEventRequestTypeNone:
+ return;
+ case TouchEventRequestTypeRaw: {
+ WebTouchEventBuilder webEvent(this, m_element->renderer(), *event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+
+ if (event->type() == eventNames().touchstartEvent)
+ focusPlugin();
+
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ event->setDefaultHandled();
+ // FIXME: Can a plugin change the cursor from a touch-event callback?
+ return;
+ }
+ case TouchEventRequestTypeSynthesizedMouse:
+ synthesizeMouseEventIfPossible(event);
+ return;
+ }
+}
+
+static inline bool gestureScrollHelper(ScrollbarGroup* scrollbarGroup, ScrollDirection positiveDirection, ScrollDirection negativeDirection, float delta)
+{
+ if (!delta)
+ return false;
+ float absDelta = delta > 0 ? delta : -delta;
+ return scrollbarGroup->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPrecisePixel, absDelta);
+}
+
+void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event)
+{
+ WebGestureEventBuilder webEvent(this, m_element->renderer(), *event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) {
+ event->setDefaultHandled();
+ return;
+ }
+
+ if (webEvent.type == WebInputEvent::GestureScrollUpdate || webEvent.type == WebInputEvent::GestureScrollUpdateWithoutPropagation) {
+ if (!m_scrollbarGroup)
+ return;
+ if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollLeft, ScrollRight, webEvent.data.scrollUpdate.deltaX))
+ event->setDefaultHandled();
+ if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollUp, ScrollDown, webEvent.data.scrollUpdate.deltaY))
+ event->setDefaultHandled();
+ }
+ // FIXME: Can a plugin change the cursor from a touch-event callback?
+}
+
+void WebPluginContainerImpl::synthesizeMouseEventIfPossible(TouchEvent* event)
+{
+ WebMouseEventBuilder webEvent(this, m_element->renderer(), *event);
+ if (webEvent.type == WebInputEvent::Undefined)
+ return;
+
+ WebCursorInfo cursorInfo;
+ if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
+ event->setDefaultHandled();
+}
+
+void WebPluginContainerImpl::focusPlugin()
+{
+ Frame* containingFrame = static_cast<FrameView*>(parent())->frame();
+ if (Page* currentPage = containingFrame->page())
+ currentPage->focusController().setFocusedElement(m_element, containingFrame);
+ else
+ containingFrame->document()->setFocusedElement(m_element);
+}
+
+void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect,
+ IntRect& windowRect,
+ IntRect& clipRect,
+ Vector<IntRect>& cutOutRects)
+{
+ windowRect = parent()->contentsToWindow(frameRect);
+
+ // Calculate a clip-rect so that we don't overlap the scrollbars, etc.
+ clipRect = windowClipRect();
+ clipRect.move(-windowRect.x(), -windowRect.y());
+
+ getPluginOcclusions(m_element, this->parent(), 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.
+ clipRect.intersect(
+ m_element->document()->view()->windowClipRectForFrameOwner(m_element, true));
+ }
+
+ return clipRect;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.h b/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.h
new file mode 100644
index 00000000000..5ecc64f2433
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.h
@@ -0,0 +1,202 @@
+/*
+ * 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 "WebPluginContainer.h"
+#include "core/platform/Widget.h"
+#include "core/plugins/PluginView.h"
+
+#include "wtf/OwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Vector.h"
+
+struct NPObject;
+
+namespace WebCore {
+class GestureEvent;
+class HTMLPlugInElement;
+class IntRect;
+class KeyboardEvent;
+class MouseEvent;
+class PlatformGestureEvent;
+class ResourceError;
+class ResourceResponse;
+class TouchEvent;
+class WheelEvent;
+}
+
+namespace WebKit {
+
+struct WebPrintParams;
+
+class ScrollbarGroup;
+class WebPlugin;
+class WebPluginLoadObserver;
+class WebExternalTextureLayer;
+
+class WebPluginContainerImpl : public WebCore::PluginView, public WebPluginContainer {
+public:
+ static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
+ {
+ return adoptRef(new WebPluginContainerImpl(element, webPlugin));
+ }
+
+ // PluginView methods
+ virtual WebLayer* platformLayer() const OVERRIDE;
+ virtual NPObject* scriptableObject() OVERRIDE;
+ virtual bool getFormValue(String&) OVERRIDE;
+ virtual bool supportsKeyboardFocus() const OVERRIDE;
+ virtual bool canProcessDrag() const OVERRIDE;
+ virtual bool wantsWheelEvents() OVERRIDE;
+
+ // 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 void clipRectChanged() OVERRIDE;
+ virtual bool isPluginContainer() const { return true; }
+ virtual void eventListenersRemoved() OVERRIDE;
+
+ // 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 allowScriptObjects();
+ 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);
+ virtual bool isRectTopmost(const WebRect&);
+ virtual void requestTouchEventType(TouchEventRequestType);
+ virtual void setWantsWheelEvents(bool);
+ virtual WebPoint windowToLocalPoint(const WebPoint&);
+ virtual WebPoint localToWindowPoint(const WebPoint&);
+
+ // This cannot be null.
+ WebPlugin* plugin() { return m_webPlugin; }
+ void setPlugin(WebPlugin*);
+
+ virtual float deviceScaleFactor();
+ virtual float pageScaleFactor();
+ virtual float pageZoomFactor();
+
+ virtual void setWebLayer(WebLayer*);
+
+ // 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;
+ // If the plugin content should not be scaled to the printable area of
+ // the page, then this method should return true.
+ bool isPrintScalingDisabled() const;
+ // Sets up printing at the specified WebPrintParams. Returns the number of pages to be printed at these settings.
+ int printBegin(const WebPrintParams&) 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();
+
+ // Pass the edit command to the plugin.
+ bool executeEditCommand(const WebString& name);
+ bool executeEditCommand(const WebString& name, const WebString& value);
+
+ // Resource load events for the plugin's source data:
+ virtual void didReceiveResponse(const WebCore::ResourceResponse&) OVERRIDE;
+ virtual void didReceiveData(const char *data, int dataLength) OVERRIDE;
+ virtual void didFinishLoading() OVERRIDE;
+ virtual void didFailLoading(const WebCore::ResourceError&) OVERRIDE;
+
+ void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
+
+ ScrollbarGroup* scrollbarGroup();
+
+ void willStartLiveResize();
+ void willEndLiveResize();
+
+ bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
+
+private:
+ WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
+ ~WebPluginContainerImpl();
+
+ void handleMouseEvent(WebCore::MouseEvent*);
+ void handleDragEvent(WebCore::MouseEvent*);
+ void handleWheelEvent(WebCore::WheelEvent*);
+ void handleKeyboardEvent(WebCore::KeyboardEvent*);
+ void handleTouchEvent(WebCore::TouchEvent*);
+ void handleGestureEvent(WebCore::GestureEvent*);
+
+ void synthesizeMouseEventIfPossible(WebCore::TouchEvent*);
+
+ void focusPlugin();
+
+ 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;
+
+ WebLayer* m_webLayer;
+
+ // The associated scrollbar group object, created lazily. Used for Pepper
+ // scrollbars.
+ OwnPtr<ScrollbarGroup> m_scrollbarGroup;
+
+ TouchEventRequestType m_touchEventRequestType;
+ bool m_wantsWheelEvents;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebPluginDocument.cpp b/chromium/third_party/WebKit/Source/web/WebPluginDocument.cpp
new file mode 100644
index 00000000000..aa2fba394ee
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/dom/Document.h"
+#include "core/html/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/chromium/third_party/WebKit/Source/web/WebPluginLoadObserver.cpp b/chromium/third_party/WebKit/Source/web/WebPluginLoadObserver.cpp
new file mode 100644
index 00000000000..5ec59a60c73
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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/chromium/third_party/WebKit/Source/web/WebPluginLoadObserver.h b/chromium/third_party/WebKit/Source/web/WebPluginLoadObserver.h
new file mode 100644
index 00000000000..d8231b00566
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "public/platform/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/chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.cpp
new file mode 100644
index 00000000000..514755d2f5a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.cpp
@@ -0,0 +1,369 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebPluginScrollbarImpl.h"
+
+#include "ScrollbarGroup.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPluginScrollbarClient.h"
+#include "WebViewImpl.h"
+#include "core/platform/ScrollAnimator.h"
+#include "core/platform/ScrollTypes.h"
+#include "core/platform/Scrollbar.h"
+#include "core/platform/ScrollbarTheme.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "public/platform/WebCanvas.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebVector.h"
+
+using namespace std;
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPluginScrollbar* WebPluginScrollbar::createForPlugin(Orientation orientation,
+ WebPluginContainer* pluginContainer,
+ WebPluginScrollbarClient* client)
+{
+ WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(pluginContainer);
+ return new WebPluginScrollbarImpl(orientation, plugin->scrollbarGroup(), client);
+}
+
+int WebPluginScrollbar::defaultThickness()
+{
+ return ScrollbarTheme::theme()->scrollbarThickness();
+}
+
+WebPluginScrollbarImpl::WebPluginScrollbarImpl(Orientation orientation,
+ ScrollbarGroup* group,
+ WebPluginScrollbarClient* client)
+ : m_group(group)
+ , m_client(client)
+ , m_scrollOffset(0)
+{
+ m_scrollbar = Scrollbar::createNativeScrollbar(
+ static_cast<ScrollableArea*>(m_group),
+ static_cast<WebCore::ScrollbarOrientation>(orientation),
+ WebCore::RegularScrollbar);
+ m_group->scrollbarCreated(this);
+}
+
+WebPluginScrollbarImpl::~WebPluginScrollbarImpl()
+{
+ m_group->scrollbarDestroyed(this);
+}
+
+void WebPluginScrollbarImpl::setScrollOffset(int scrollOffset)
+{
+ m_scrollOffset = scrollOffset;
+ m_client->valueChanged(this);
+}
+
+void WebPluginScrollbarImpl::invalidateScrollbarRect(const IntRect& rect)
+{
+ WebRect webrect(rect);
+ webrect.x += m_scrollbar->x();
+ webrect.y += m_scrollbar->y();
+ m_client->invalidateScrollbarRect(this, webrect);
+}
+
+void WebPluginScrollbarImpl::getTickmarks(Vector<IntRect>& tickmarks) const
+{
+ WebVector<WebRect> ticks;
+ m_client->getTickmarks(const_cast<WebPluginScrollbarImpl*>(this), &ticks);
+ tickmarks.resize(ticks.size());
+ for (size_t i = 0; i < ticks.size(); ++i)
+ tickmarks[i] = ticks[i];
+}
+
+IntPoint WebPluginScrollbarImpl::convertFromContainingViewToScrollbar(const IntPoint& parentPoint) const
+{
+ IntPoint offset(parentPoint.x() - m_scrollbar->x(), parentPoint.y() - m_scrollbar->y());
+ return m_scrollbar->Widget::convertFromContainingView(offset);
+}
+
+void WebPluginScrollbarImpl::scrollbarStyleChanged()
+{
+ m_client->overlayChanged(this);
+}
+
+bool WebPluginScrollbarImpl::isOverlay() const
+{
+ return m_scrollbar->isOverlayScrollbar();
+}
+
+int WebPluginScrollbarImpl::value() const
+{
+ return m_scrollOffset;
+}
+
+WebPoint WebPluginScrollbarImpl::location() const
+{
+ return m_scrollbar->frameRect().location();
+}
+
+WebSize WebPluginScrollbarImpl::size() const
+{
+ return m_scrollbar->frameRect().size();
+}
+
+bool WebPluginScrollbarImpl::enabled() const
+{
+ return m_scrollbar->enabled();
+}
+
+int WebPluginScrollbarImpl::maximum() const
+{
+ return m_scrollbar->maximum();
+}
+
+int WebPluginScrollbarImpl::totalSize() const
+{
+ return m_scrollbar->totalSize();
+}
+
+bool WebPluginScrollbarImpl::isScrollViewScrollbar() const
+{
+ return m_scrollbar->isScrollViewScrollbar();
+}
+
+bool WebPluginScrollbarImpl::isScrollableAreaActive() const
+{
+ return m_scrollbar->isScrollableAreaActive();
+}
+
+void WebPluginScrollbarImpl::getTickmarks(WebVector<WebRect>& tickmarks) const
+{
+ m_client->getTickmarks(const_cast<WebPluginScrollbarImpl*>(this), &tickmarks);
+}
+
+WebScrollbar::ScrollbarControlSize WebPluginScrollbarImpl::controlSize() const
+{
+ return static_cast<WebScrollbar::ScrollbarControlSize>(m_scrollbar->controlSize());
+}
+
+WebScrollbar::ScrollbarPart WebPluginScrollbarImpl::pressedPart() const
+{
+ return static_cast<WebScrollbar::ScrollbarPart>(m_scrollbar->pressedPart());
+}
+
+WebScrollbar::ScrollbarPart WebPluginScrollbarImpl::hoveredPart() const
+{
+ return static_cast<WebScrollbar::ScrollbarPart>(m_scrollbar->hoveredPart());
+}
+
+WebScrollbar::ScrollbarOverlayStyle WebPluginScrollbarImpl::scrollbarOverlayStyle() const
+{
+ return static_cast<WebScrollbar::ScrollbarOverlayStyle>(m_scrollbar->scrollbarOverlayStyle());
+}
+
+WebScrollbar::Orientation WebPluginScrollbarImpl::orientation() const
+{
+ if (m_scrollbar->orientation() == WebCore::HorizontalScrollbar)
+ return WebScrollbar::Horizontal;
+ return WebScrollbar::Vertical;
+}
+
+bool WebPluginScrollbarImpl::isCustomScrollbar() const
+{
+ return m_scrollbar->isCustomScrollbar();
+}
+
+void WebPluginScrollbarImpl::setLocation(const WebRect& rect)
+{
+ 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();
+ m_scrollbar->setEnabled(m_scrollbar->totalSize() > length);
+ m_scrollbar->setProportion(length, m_scrollbar->totalSize());
+}
+
+void WebPluginScrollbarImpl::setValue(int position)
+{
+ m_group->scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), static_cast<float>(position));
+}
+
+void WebPluginScrollbarImpl::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 WebPluginScrollbarImpl::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;
+
+ m_group->scroll(dir, static_cast<WebCore::ScrollGranularity>(granularity), multiplier);
+}
+
+void WebPluginScrollbarImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ m_scrollbar->paint(&context, rect);
+}
+
+bool WebPluginScrollbarImpl::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 WebPluginScrollbarImpl::isAlphaLocked() const
+{
+ return m_scrollbar->isAlphaLocked();
+}
+
+void WebPluginScrollbarImpl::setIsAlphaLocked(bool flag)
+{
+ return m_scrollbar->setIsAlphaLocked(flag);
+}
+
+bool WebPluginScrollbarImpl::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 WebPluginScrollbarImpl::onMouseUp(const WebInputEvent& event)
+{
+ WebMouseEvent mouseup = *static_cast<const WebMouseEvent*>(&event);
+ if (m_scrollbar->pressedPart() == WebCore::NoPart)
+ return false;
+
+ m_scrollbar->mouseUp(PlatformMouseEventBuilder(m_scrollbar.get(), mouseup));
+ return true;
+}
+
+bool WebPluginScrollbarImpl::onMouseMove(const WebInputEvent& event)
+{
+ WebMouseEvent mousemove = *static_cast<const WebMouseEvent*>(&event);
+ if (m_scrollbar->frameRect().contains(mousemove.x, mousemove.y)
+ || m_scrollbar->pressedPart() != WebCore::NoPart) {
+ mousemove.x -= m_scrollbar->x();
+ mousemove.y -= m_scrollbar->y();
+ m_scrollbar->mouseMoved(PlatformMouseEventBuilder(m_scrollbar.get(), mousemove));
+ return true;
+ }
+
+ if (m_scrollbar->hoveredPart() != WebCore::NoPart && !m_scrollbar->isOverlayScrollbar())
+ m_scrollbar->mouseExited();
+ return false;
+}
+
+bool WebPluginScrollbarImpl::onMouseLeave(const WebInputEvent& event)
+{
+ if (m_scrollbar->hoveredPart() != WebCore::NoPart)
+ m_scrollbar->mouseExited();
+
+ return false;
+}
+
+bool WebPluginScrollbarImpl::onMouseWheel(const WebInputEvent& event)
+{
+ WebMouseWheelEvent mousewheel = *static_cast<const WebMouseWheelEvent*>(&event);
+ PlatformWheelEventBuilder platformEvent(m_scrollbar.get(), mousewheel);
+ return m_group->handleWheelEvent(platformEvent);
+}
+
+bool WebPluginScrollbarImpl::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 m_group->scroll(scrollDirection, scrollGranularity);
+ }
+ return false;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.h b/chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.h
new file mode 100644
index 00000000000..1567cb0482d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPluginScrollbarImpl.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPluginScrollbarImpl_h
+#define WebPluginScrollbarImpl_h
+
+#include "WebPluginScrollbar.h"
+
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+
+namespace WebCore {
+class IntPoint;
+class IntRect;
+class Scrollbar;
+}
+
+namespace WebKit {
+
+class ScrollbarGroup;
+
+class WebPluginScrollbarImpl : public WebPluginScrollbar {
+public:
+ WebPluginScrollbarImpl(Orientation,
+ ScrollbarGroup*,
+ WebPluginScrollbarClient*);
+ ~WebPluginScrollbarImpl();
+
+ void setScrollOffset(int);
+ void invalidateScrollbarRect(const WebCore::IntRect&);
+ // FIXME: Combine this with the other getTickmarks method
+ void getTickmarks(Vector<WebCore::IntRect>&) const;
+ WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::IntPoint& parentPoint) const;
+ void scrollbarStyleChanged();
+
+ int scrollOffset() { return m_scrollOffset; }
+ WebCore::Scrollbar* scrollbar() { return m_scrollbar.get(); }
+
+ // WebKit::WebScrollbar methods
+ virtual bool isOverlay() const OVERRIDE;
+ virtual int value() const OVERRIDE;
+ virtual WebPoint location() const OVERRIDE;
+ virtual WebSize size() const OVERRIDE;
+ virtual bool enabled() const OVERRIDE;
+ virtual int maximum() const OVERRIDE;
+ virtual int totalSize() const OVERRIDE;
+ virtual bool isScrollViewScrollbar() const OVERRIDE;
+ virtual bool isScrollableAreaActive() const OVERRIDE;
+ virtual void getTickmarks(WebVector<WebRect>& tickmarks) const OVERRIDE;
+ virtual WebScrollbar::ScrollbarControlSize controlSize() const OVERRIDE;
+ virtual WebScrollbar::ScrollbarPart pressedPart() const OVERRIDE;
+ virtual WebScrollbar::ScrollbarPart hoveredPart() const OVERRIDE;
+ virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE;
+ virtual WebScrollbar::Orientation orientation() const OVERRIDE;
+ virtual bool isCustomScrollbar() const OVERRIDE;
+
+ // WebKit::WebPluginScrollbar methods
+ virtual void setLocation(const WebRect&) OVERRIDE;
+ virtual void setValue(int position) OVERRIDE;
+ virtual void setDocumentSize(int) OVERRIDE;
+ virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier) OVERRIDE;
+ virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
+ virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
+ virtual bool isAlphaLocked() const OVERRIDE;
+ virtual void setIsAlphaLocked(bool) OVERRIDE;
+
+private:
+ bool onMouseDown(const WebInputEvent&);
+ bool onMouseUp(const WebInputEvent&);
+ bool onMouseMove(const WebInputEvent&);
+ bool onMouseLeave(const WebInputEvent&);
+ bool onMouseWheel(const WebInputEvent&);
+ bool onKeyDown(const WebInputEvent&);
+
+ ScrollbarGroup* m_group;
+ WebPluginScrollbarClient* m_client;
+
+ int m_scrollOffset;
+ RefPtr<WebCore::Scrollbar> m_scrollbar;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp
new file mode 100644
index 00000000000..9be33e8aefb
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.cpp
@@ -0,0 +1,400 @@
+/*
+ * 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 "PopupContainer.h"
+#include "PopupMenuChromium.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebRange.h"
+#include "WebViewClient.h"
+#include "WebWidgetClient.h"
+#include "core/page/FrameView.h"
+#include "core/platform/Cursor.h"
+#include "core/platform/NotImplemented.h"
+#include "core/platform/PlatformGestureEvent.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/PlatformMouseEvent.h"
+#include "core/platform/PlatformWheelEvent.h"
+#include "core/platform/chromium/FramelessScrollView.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/IntRect.h"
+#include "core/platform/graphics/skia/SkiaUtils.h"
+#include "public/platform/WebRect.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 position.
+ m_lastMousePosition = WebPoint(-1, -1);
+}
+
+WebPopupMenuImpl::~WebPopupMenuImpl()
+{
+ if (m_widget)
+ m_widget->setClient(0);
+}
+
+void WebPopupMenuImpl::initialize(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::handleMouseMove(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));
+
+ // We cannot call setToolTipText() in PopupContainer, because PopupContainer is in WebCore, and we cannot refer to WebKit from Webcore.
+ WebCore::PopupContainer* container = static_cast<WebCore::PopupContainer*>(m_widget);
+ client()->setToolTipText(container->getSelectedItemToolTip(), container->menuStyle().textDirection() == WebCore::RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight);
+ }
+}
+
+void WebPopupMenuImpl::handleMouseLeave(const WebMouseEvent& event)
+{
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::handleMouseDown(const WebMouseEvent& event)
+{
+ m_widget->handleMouseDownEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::handleMouseUp(const WebMouseEvent& event)
+{
+ mouseCaptureLost();
+ m_widget->handleMouseReleaseEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::handleMouseWheel(const WebMouseWheelEvent& event)
+{
+ m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event));
+}
+
+bool WebPopupMenuImpl::handleGestureEvent(const WebGestureEvent& event)
+{
+ return m_widget->handleGestureEvent(PlatformGestureEventBuilder(m_widget, event));
+}
+
+bool WebPopupMenuImpl::handleTouchEvent(const WebTouchEvent& event)
+{
+
+ PlatformTouchEventBuilder touchEventBuilder(m_widget, event);
+ bool defaultPrevented(m_widget->handleTouchEvent(touchEventBuilder));
+ return defaultPrevented;
+}
+
+bool WebPopupMenuImpl::handleKeyEvent(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 WebPopupMenu::create.
+}
+
+void WebPopupMenuImpl::willStartLiveResize()
+{
+}
+
+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::willEndLiveResize()
+{
+}
+
+void WebPopupMenuImpl::animate(double)
+{
+}
+
+void WebPopupMenuImpl::layout()
+{
+}
+
+void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions)
+{
+ if (!m_widget)
+ return;
+
+ if (!rect.isEmpty()) {
+ GraphicsContext context(canvas);
+ context.applyDeviceScaleFactor(m_client->deviceScaleFactor());
+ m_widget->paint(&context, rect);
+ }
+}
+
+void WebPopupMenuImpl::themeChanged()
+{
+ notImplemented();
+}
+
+bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ if (!m_widget)
+ return false;
+
+ // FIXME: 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:
+ handleMouseMove(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseLeave:
+ handleMouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseWheel:
+ handleMouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseDown:
+ handleMouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseUp:
+ handleMouseUp(*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 handleKeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+
+ case WebInputEvent::TouchStart:
+ case WebInputEvent::TouchMove:
+ case WebInputEvent::TouchEnd:
+ case WebInputEvent::TouchCancel:
+ return handleTouchEvent(*static_cast<const WebTouchEvent*>(&inputEvent));
+
+ case WebInputEvent::GestureScrollBegin:
+ case WebInputEvent::GestureScrollEnd:
+ case WebInputEvent::GestureScrollUpdate:
+ case WebInputEvent::GestureScrollUpdateWithoutPropagation:
+ case WebInputEvent::GestureFlingStart:
+ case WebInputEvent::GestureFlingCancel:
+ case WebInputEvent::GestureTap:
+ case WebInputEvent::GestureTapUnconfirmed:
+ case WebInputEvent::GestureTapDown:
+ case WebInputEvent::GestureTapCancel:
+ case WebInputEvent::GestureDoubleTap:
+ case WebInputEvent::GestureTwoFingerTap:
+ case WebInputEvent::GestureLongPress:
+ case WebInputEvent::GestureLongTap:
+ case WebInputEvent::GesturePinchBegin:
+ case WebInputEvent::GesturePinchEnd:
+ case WebInputEvent::GesturePinchUpdate:
+ return handleGestureEvent(*static_cast<const WebGestureEvent*>(&inputEvent));
+
+ case WebInputEvent::Undefined:
+ case WebInputEvent::MouseEnter:
+ case WebInputEvent::ContextMenu:
+ return false;
+ }
+ return false;
+}
+
+void WebPopupMenuImpl::mouseCaptureLost()
+{
+}
+
+void WebPopupMenuImpl::setFocus(bool)
+{
+}
+
+void WebPopupMenu::setMinimumRowHeight(int minimumRowHeight)
+{
+ PopupMenuChromium::setMinimumRowHeight(minimumRowHeight);
+}
+
+bool WebPopupMenuImpl::setComposition(const WebString&, const WebVector<WebCompositionUnderline>&, int, int)
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::confirmComposition()
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::confirmComposition(ConfirmCompositionBehavior)
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::confirmComposition(const WebString&)
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::compositionRange(size_t* location, size_t* length)
+{
+ *location = 0;
+ *length = 0;
+ return false;
+}
+
+bool WebPopupMenuImpl::caretOrSelectionRange(size_t* location, size_t* length)
+{
+ *location = 0;
+ *length = 0;
+ return false;
+}
+
+void WebPopupMenuImpl::setTextDirection(WebTextDirection)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// WebCore::HostWindow
+
+void WebPopupMenuImpl::invalidateContentsAndRootView(const IntRect& paintRect)
+{
+ if (paintRect.isEmpty())
+ return;
+ if (m_client)
+ m_client->didInvalidateRect(paintRect);
+}
+
+void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect)
+{
+ invalidateContentsAndRootView(updateRect);
+}
+
+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::screenToRootView(const IntPoint& point) const
+{
+ notImplemented();
+ return IntPoint();
+}
+
+IntRect WebPopupMenuImpl::rootViewToScreen(const IntRect& rect) const
+{
+ notImplemented();
+ return IntRect();
+}
+
+WebScreenInfo WebPopupMenuImpl::screenInfo() const
+{
+ return WebScreenInfo();
+}
+
+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;
+ }
+ if (m_client)
+ m_client->closeWidgetSoon();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.h b/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.h
new file mode 100644
index 00000000000..f2decbb1b55
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebPopupMenuImpl.h
@@ -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.
+ */
+
+#ifndef WebPopupMenuImpl_h
+#define WebPopupMenuImpl_h
+
+#include "WebPopupMenu.h"
+#include "core/platform/chromium/FramelessScrollViewClient.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebSize.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+
+namespace WebCore {
+class Frame;
+class FramelessScrollView;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class Range;
+class Widget;
+}
+
+namespace WebKit {
+class WebGestureEvent;
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebRange;
+struct WebRect;
+class WebTouchEvent;
+
+class WebPopupMenuImpl : public WebPopupMenu,
+ public WebCore::FramelessScrollViewClient,
+ public RefCounted<WebPopupMenuImpl> {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ // WebWidget functions:
+ virtual void close() OVERRIDE;
+ virtual WebSize size() OVERRIDE { return m_size; }
+ virtual void willStartLiveResize() OVERRIDE;
+ virtual void resize(const WebSize&) OVERRIDE;
+ virtual void willEndLiveResize() OVERRIDE;
+ virtual void animate(double frameBeginTime) OVERRIDE;
+ virtual void layout() OVERRIDE;
+ virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
+ virtual void themeChanged() OVERRIDE;
+ virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
+ virtual void mouseCaptureLost() OVERRIDE;
+ virtual void setFocus(bool enable) OVERRIDE;
+ virtual bool setComposition(
+ const WebString& text,
+ const WebVector<WebCompositionUnderline>& underlines,
+ int selectionStart, int selectionEnd) OVERRIDE;
+ virtual bool confirmComposition() OVERRIDE;
+ virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) OVERRIDE;
+ virtual bool confirmComposition(const WebString& text) OVERRIDE;
+ virtual bool compositionRange(size_t* location, size_t* length) OVERRIDE;
+ virtual bool caretOrSelectionRange(size_t* location, size_t* length) OVERRIDE;
+ virtual void setTextDirection(WebTextDirection) OVERRIDE;
+ virtual bool isAcceleratedCompositingActive() const OVERRIDE { return false; }
+
+ // WebPopupMenuImpl
+ void initialize(WebCore::FramelessScrollView* widget, const WebRect& bounds);
+
+ WebWidgetClient* client() { return m_client; }
+
+ void handleMouseMove(const WebMouseEvent&);
+ void handleMouseLeave(const WebMouseEvent&);
+ void handleMouseDown(const WebMouseEvent&);
+ void handleMouseUp(const WebMouseEvent&);
+ void handleMouseDoubleClick(const WebMouseEvent&);
+ void handleMouseWheel(const WebMouseWheelEvent&);
+ bool handleGestureEvent(const WebGestureEvent&);
+ bool handleTouchEvent(const WebTouchEvent&);
+ bool handleKeyEvent(const WebKeyboardEvent&);
+
+ protected:
+ friend class WebPopupMenu; // For WebPopupMenu::create.
+ friend class WTF::RefCounted<WebPopupMenuImpl>;
+
+ WebPopupMenuImpl(WebWidgetClient*);
+ ~WebPopupMenuImpl();
+
+ // WebCore::HostWindow methods:
+ virtual void invalidateContentsAndRootView(const WebCore::IntRect&) OVERRIDE;
+ virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&) OVERRIDE;
+ virtual void scheduleAnimation() OVERRIDE;
+ virtual void scroll(
+ const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
+ const WebCore::IntRect& clipRect) OVERRIDE;
+ virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const OVERRIDE;
+ virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const OVERRIDE;
+ virtual WebScreenInfo screenInfo() const OVERRIDE;
+ virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
+
+ // WebCore::FramelessScrollViewClient methods:
+ virtual void popupClosed(WebCore::FramelessScrollView*) OVERRIDE;
+
+ 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/chromium/third_party/WebKit/Source/web/WebRange.cpp b/chromium/third_party/WebKit/Source/web/WebRange.cpp
new file mode 100644
index 00000000000..907bff54a5c
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebRange.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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 "WebExceptionCode.h"
+#include "WebFrameImpl.h"
+#include "WebNode.h"
+#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "core/dom/Document.h"
+#include "core/dom/Element.h"
+#include "core/dom/Range.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/editing/FrameSelection.h"
+#include "core/editing/TextIterator.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "public/platform/WebFloatQuad.h"
+#include "public/platform/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(WebExceptionCode& exceptionCode) const
+{
+ // FIXME: Create a wrapper class that just sets the internal int.
+ TrackExceptionState es;
+ RefPtr<Node> node(m_private->startContainer(es));
+ exceptionCode = es.code();
+ return node.release();
+}
+
+WebNode WebRange::endContainer(WebExceptionCode& exceptionCode) const
+{
+ // FIXME: Create a wrapper class that just sets the internal int.
+ TrackExceptionState es;
+ RefPtr<Node> node(m_private->endContainer(es));
+ exceptionCode = es.code();
+ return node.release();
+}
+
+WebString WebRange::toHTMLText() const
+{
+ return m_private->toHTML();
+}
+
+WebString WebRange::toPlainText() const
+{
+ return m_private->text();
+}
+
+WebRange WebRange::expandedToParagraph() const
+{
+ WebRange copy(*this);
+ copy.m_private->expand("block", IGNORE_EXCEPTION);
+ return copy;
+}
+
+// static
+WebRange WebRange::fromDocumentRange(WebFrame* frame, int start, int length)
+{
+ WebCore::Frame* webFrame = static_cast<WebFrameImpl*>(frame)->frame();
+ Element* selectionRoot = webFrame->selection()->rootEditableElement();
+ ContainerNode* scope = selectionRoot ? selectionRoot : webFrame->document()->documentElement();
+ return TextIterator::rangeFromLocationAndLength(scope, start, length);
+}
+
+WebVector<WebFloatQuad> WebRange::textQuads() const
+{
+ if (isNull())
+ return WebVector<WebFloatQuad>();
+
+ Frame* frame = m_private->ownerDocument() ? m_private->ownerDocument()->frame() : 0;
+ if (!frame)
+ return WebVector<WebFloatQuad>();
+
+ Vector<FloatQuad> quads;
+ m_private->textQuads(quads);
+ for (unsigned i = 0; i < quads.size(); ++i) {
+ quads[i].setP1(frame->view()->contentsToWindow(roundedIntPoint(quads[i].p1())));
+ quads[i].setP2(frame->view()->contentsToWindow(roundedIntPoint(quads[i].p2())));
+ quads[i].setP3(frame->view()->contentsToWindow(roundedIntPoint(quads[i].p3())));
+ quads[i].setP4(frame->view()->contentsToWindow(roundedIntPoint(quads[i].p4())));
+ }
+
+ return quads;
+}
+
+WebRange::WebRange(const WTF::PassRefPtr<WebCore::Range>& range)
+ : m_private(static_cast<WebRangePrivate*>(range.leakRef()))
+{
+}
+
+WebRange& WebRange::operator=(const WTF::PassRefPtr<WebCore::Range>& range)
+{
+ assign(static_cast<WebRangePrivate*>(range.leakRef()));
+ 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/chromium/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp b/chromium/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
new file mode 100644
index 00000000000..d0954e2750b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
@@ -0,0 +1,395 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "RuntimeEnabledFeatures.h"
+#include "WebMediaPlayerClientImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebRuntimeFeatures::enableStableFeatures(bool enable)
+{
+ RuntimeEnabledFeatures::setStableFeaturesEnabled(enable);
+ // FIXME: enableMediaPlayer does not use RuntimeEnabledFeatures
+ // and does not belong as part of WebRuntimeFeatures.
+ enableMediaPlayer(enable);
+}
+
+void WebRuntimeFeatures::enableExperimentalFeatures(bool enable)
+{
+ RuntimeEnabledFeatures::setExperimentalFeaturesEnabled(enable);
+}
+
+void WebRuntimeFeatures::enableTestOnlyFeatures(bool enable)
+{
+ RuntimeEnabledFeatures::setTestFeaturesEnabled(enable);
+}
+
+void WebRuntimeFeatures::enableApplicationCache(bool enable)
+{
+ RuntimeEnabledFeatures::setApplicationCacheEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isApplicationCacheEnabled()
+{
+ return RuntimeEnabledFeatures::applicationCacheEnabled();
+}
+
+void WebRuntimeFeatures::enableDatabase(bool enable)
+{
+ RuntimeEnabledFeatures::setDatabaseEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isDatabaseEnabled()
+{
+ return RuntimeEnabledFeatures::databaseEnabled();
+}
+
+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::enableEncryptedMedia(bool enable)
+{
+ RuntimeEnabledFeatures::setEncryptedMediaEnabled(enable);
+ // FIXME: Hack to allow MediaKeyError to be enabled for either version.
+ RuntimeEnabledFeatures::setEncryptedMediaAnyVersionEnabled(
+ RuntimeEnabledFeatures::encryptedMediaEnabled()
+ || RuntimeEnabledFeatures::legacyEncryptedMediaEnabled());
+}
+
+bool WebRuntimeFeatures::isEncryptedMediaEnabled()
+{
+ return RuntimeEnabledFeatures::encryptedMediaEnabled();
+}
+
+void WebRuntimeFeatures::enableLegacyEncryptedMedia(bool enable)
+{
+ RuntimeEnabledFeatures::setLegacyEncryptedMediaEnabled(enable);
+ // FIXME: Hack to allow MediaKeyError to be enabled for either version.
+ RuntimeEnabledFeatures::setEncryptedMediaAnyVersionEnabled(
+ RuntimeEnabledFeatures::encryptedMediaEnabled()
+ || RuntimeEnabledFeatures::legacyEncryptedMediaEnabled());
+}
+
+bool WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()
+{
+ return RuntimeEnabledFeatures::legacyEncryptedMediaEnabled();
+}
+
+void WebRuntimeFeatures::enableExperimentalCanvasFeatures(bool enable)
+{
+ RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isExperimentalCanvasFeaturesEnabled()
+{
+ return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled();
+}
+
+void WebRuntimeFeatures::enableFileSystem(bool enable)
+{
+ RuntimeEnabledFeatures::setFileSystemEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isFileSystemEnabled()
+{
+ return RuntimeEnabledFeatures::fileSystemEnabled();
+}
+
+void WebRuntimeFeatures::enableFullscreen(bool enable)
+{
+ RuntimeEnabledFeatures::setFullscreenEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isFullscreenEnabled()
+{
+ return RuntimeEnabledFeatures::fullscreenEnabled();
+}
+
+void WebRuntimeFeatures::enableGamepad(bool enable)
+{
+ RuntimeEnabledFeatures::setGamepadEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isGamepadEnabled()
+{
+ return RuntimeEnabledFeatures::gamepadEnabled();
+}
+
+void WebRuntimeFeatures::enableGeolocation(bool enable)
+{
+ RuntimeEnabledFeatures::setGeolocationEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isGeolocationEnabled()
+{
+ return RuntimeEnabledFeatures::geolocationEnabled();
+}
+
+void WebRuntimeFeatures::enableLazyLayout(bool enable)
+{
+ RuntimeEnabledFeatures::setLazyLayoutEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isLazyLayoutEnabled()
+{
+ return RuntimeEnabledFeatures::lazyLayoutEnabled();
+}
+
+void WebRuntimeFeatures::enableLocalStorage(bool enable)
+{
+ RuntimeEnabledFeatures::setLocalStorageEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isLocalStorageEnabled()
+{
+ return RuntimeEnabledFeatures::localStorageEnabled();
+}
+
+void WebRuntimeFeatures::enableMediaPlayer(bool enable)
+{
+ RuntimeEnabledFeatures::setMediaEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isMediaPlayerEnabled()
+{
+ return RuntimeEnabledFeatures::mediaEnabled();
+}
+
+void WebRuntimeFeatures::enableWebKitMediaSource(bool enable)
+{
+ RuntimeEnabledFeatures::setWebKitMediaSourceEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isWebKitMediaSourceEnabled()
+{
+ return RuntimeEnabledFeatures::webKitMediaSourceEnabled();
+}
+
+void WebRuntimeFeatures::enableMediaStream(bool enable)
+{
+ RuntimeEnabledFeatures::setMediaStreamEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isMediaStreamEnabled()
+{
+ return RuntimeEnabledFeatures::mediaStreamEnabled();
+}
+
+void WebRuntimeFeatures::enableNotifications(bool enable)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ RuntimeEnabledFeatures::setNotificationsEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isNotificationsEnabled()
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ return RuntimeEnabledFeatures::notificationsEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebRuntimeFeatures::enablePagePopup(bool enable)
+{
+ RuntimeEnabledFeatures::setPagePopupEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isPagePopupEnabled()
+{
+ return RuntimeEnabledFeatures::pagePopupEnabled();
+}
+
+void WebRuntimeFeatures::enablePeerConnection(bool enable)
+{
+ RuntimeEnabledFeatures::setPeerConnectionEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isPeerConnectionEnabled()
+{
+ return RuntimeEnabledFeatures::peerConnectionEnabled();
+}
+
+void WebRuntimeFeatures::enableRequestAutocomplete(bool enable)
+{
+ RuntimeEnabledFeatures::setRequestAutocompleteEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isRequestAutocompleteEnabled()
+{
+ return RuntimeEnabledFeatures::requestAutocompleteEnabled();
+}
+
+void WebRuntimeFeatures::enableScriptedSpeech(bool enable)
+{
+ RuntimeEnabledFeatures::setScriptedSpeechEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isScriptedSpeechEnabled()
+{
+ return RuntimeEnabledFeatures::scriptedSpeechEnabled();
+}
+
+void WebRuntimeFeatures::enableSessionStorage(bool enable)
+{
+ RuntimeEnabledFeatures::setSessionStorageEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isSessionStorageEnabled()
+{
+ return RuntimeEnabledFeatures::sessionStorageEnabled();
+}
+
+void WebRuntimeFeatures::enableSpeechInput(bool enable)
+{
+ RuntimeEnabledFeatures::setSpeechInputEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isSpeechInputEnabled()
+{
+ return RuntimeEnabledFeatures::speechInputEnabled();
+}
+
+void WebRuntimeFeatures::enableSpeechSynthesis(bool enable)
+{
+ RuntimeEnabledFeatures::setSpeechSynthesisEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isSpeechSynthesisEnabled()
+{
+ return RuntimeEnabledFeatures::speechSynthesisEnabled();
+}
+
+void WebRuntimeFeatures::enableTouch(bool enable)
+{
+ RuntimeEnabledFeatures::setTouchEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isTouchEnabled()
+{
+ return RuntimeEnabledFeatures::touchEnabled();
+}
+
+void WebRuntimeFeatures::enableWebAnimationsCSS()
+{
+ RuntimeEnabledFeatures::setWebAnimationsEnabled(true);
+ RuntimeEnabledFeatures::setWebAnimationsCSSEnabled(true);
+}
+
+void WebRuntimeFeatures::enableWebAnimationsSVG()
+{
+ RuntimeEnabledFeatures::setWebAnimationsEnabled(true);
+ RuntimeEnabledFeatures::setWebAnimationsSVGEnabled(true);
+}
+
+void WebRuntimeFeatures::enableWebAudio(bool enable)
+{
+ RuntimeEnabledFeatures::setWebAudioEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isWebAudioEnabled()
+{
+ return RuntimeEnabledFeatures::webAudioEnabled();
+}
+
+void WebRuntimeFeatures::enableWebGLDraftExtensions(bool enable)
+{
+ RuntimeEnabledFeatures::setWebGLDraftExtensionsEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isWebGLDraftExtensionsEnabled()
+{
+ return RuntimeEnabledFeatures::webGLDraftExtensionsEnabled();
+}
+
+void WebRuntimeFeatures::enableWebMIDI(bool enable)
+{
+ return RuntimeEnabledFeatures::setWebMIDIEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isWebMIDIEnabled()
+{
+ return RuntimeEnabledFeatures::webMIDIEnabled();
+}
+
+void WebRuntimeFeatures::enableDataListElement(bool enable)
+{
+ RuntimeEnabledFeatures::setDataListElementEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isDataListElementEnabled()
+{
+ return RuntimeEnabledFeatures::dataListElementEnabled();
+}
+
+void WebRuntimeFeatures::enableHTMLImports(bool enable)
+{
+ RuntimeEnabledFeatures::setHTMLImportsEnabled(enable);
+}
+
+bool WebRuntimeFeatures::isHTMLImportsEnabled()
+{
+ return RuntimeEnabledFeatures::htmlImportsEnabled();
+}
+
+void WebRuntimeFeatures::enableCustomElements(bool enable)
+{
+ RuntimeEnabledFeatures::setCustomDOMElementsEnabled(enable);
+}
+
+void WebRuntimeFeatures::enableOverlayScrollbars(bool enable)
+{
+ RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(enable);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.cpp b/chromium/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.cpp
new file mode 100644
index 00000000000..f4773a781b8
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebScopedMicrotaskSuppression.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 "WebScopedMicrotaskSuppression.h"
+
+#include "bindings/v8/V8RecursionScope.h"
+#include "wtf/OwnPtr.h"
+
+namespace WebKit {
+
+#ifndef NDEBUG
+class WebScopedMicrotaskSuppression::Impl : public WebCore::V8RecursionScope::MicrotaskSuppression { };
+#endif
+
+void WebScopedMicrotaskSuppression::initialize()
+{
+#ifndef NDEBUG
+ m_impl.reset(new Impl());
+#endif
+}
+
+void WebScopedMicrotaskSuppression::reset()
+{
+#ifndef NDEBUG
+ m_impl.reset(0);
+#endif
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebScopedUserGesture.cpp b/chromium/third_party/WebKit/Source/web/WebScopedUserGesture.cpp
new file mode 100644
index 00000000000..5bfa63b4ab3
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebScopedUserGesture.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebScopedUserGesture.h"
+
+#include "WebUserGestureToken.h"
+#include "core/dom/UserGestureIndicator.h"
+
+namespace WebKit {
+
+void WebScopedUserGesture::initialize()
+{
+ m_indicator.reset(new WebCore::UserGestureIndicator(WebCore::DefinitelyProcessingNewUserGesture));
+}
+
+void WebScopedUserGesture::initializeWithToken(const WebUserGestureToken& token)
+{
+ if (!token.isNull())
+ m_indicator.reset(new WebCore::UserGestureIndicator(token));
+}
+
+void WebScopedUserGesture::reset()
+{
+ m_indicator.reset(0);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebScriptBindings.cpp b/chromium/third_party/WebKit/Source/web/WebScriptBindings.cpp
new file mode 100644
index 00000000000..5ddcc46b817
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebScriptBindings.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "public/web/WebScriptBindings.h"
+
+#include "bindings/v8/V8Binding.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+v8::Local<v8::String> WebScriptBindings::toV8String(const WebString& string, v8::Isolate* isolate)
+{
+ return v8String(string, isolate);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebScriptController.cpp b/chromium/third_party/WebKit/Source/web/WebScriptController.cpp
new file mode 100644
index 00000000000..82bb4185009
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebScriptController.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebScriptController.h"
+
+#include "bindings/v8/ScriptController.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebScriptController::registerExtension(v8::Extension* extension)
+{
+ ScriptController::registerExtensionIfNeeded(extension);
+}
+
+void WebScriptController::enableV8SingleThreadMode()
+{
+ // FIXME: remove this method after all it's usages are gone.
+}
+
+void WebScriptController::flushConsoleMessages()
+{
+ // FIXME: remove this method after all it's usages are gone.
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebScrollbarThemePainter.cpp b/chromium/third_party/WebKit/Source/web/WebScrollbarThemePainter.cpp
new file mode 100644
index 00000000000..f091e2d95ae
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebScrollbarThemePainter.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "public/platform/WebScrollbarThemePainter.h"
+
+#include "core/platform/Scrollbar.h"
+#include "core/platform/ScrollbarTheme.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "public/platform/WebRect.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebScrollbarThemePainter::assign(const WebScrollbarThemePainter& painter)
+{
+ // This is a pointer to a static object, so no ownership transferral.
+ m_theme = painter.m_theme;
+ m_scrollbar = painter.m_scrollbar;
+}
+
+void WebScrollbarThemePainter::paintScrollbarBackground(WebCanvas* canvas, const WebRect& rect)
+{
+ SkRect clip = SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height);
+ canvas->clipRect(clip);
+
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintScrollbarBackground(&context, m_scrollbar);
+}
+
+void WebScrollbarThemePainter::paintTrackBackground(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintTrackBackground(&context, m_scrollbar, IntRect(rect));
+}
+
+void WebScrollbarThemePainter::paintBackTrackPart(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintTrackPiece(&context, m_scrollbar, IntRect(rect), WebCore::BackTrackPart);
+}
+
+void WebScrollbarThemePainter::paintForwardTrackPart(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintTrackPiece(&context, m_scrollbar, IntRect(rect), WebCore::ForwardTrackPart);
+}
+
+void WebScrollbarThemePainter::paintBackButtonStart(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintButton(&context, m_scrollbar, IntRect(rect), WebCore::BackButtonStartPart);
+}
+
+void WebScrollbarThemePainter::paintBackButtonEnd(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintButton(&context, m_scrollbar, IntRect(rect), WebCore::BackButtonEndPart);
+}
+
+void WebScrollbarThemePainter::paintForwardButtonStart(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintButton(&context, m_scrollbar, IntRect(rect), WebCore::ForwardButtonStartPart);
+}
+
+void WebScrollbarThemePainter::paintForwardButtonEnd(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintButton(&context, m_scrollbar, IntRect(rect), WebCore::ForwardButtonEndPart);
+}
+
+void WebScrollbarThemePainter::paintTickmarks(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintTickmarks(&context, m_scrollbar, IntRect(rect));
+}
+
+void WebScrollbarThemePainter::paintThumb(WebCanvas* canvas, const WebRect& rect)
+{
+ GraphicsContext context(canvas);
+ context.setCertainlyOpaque(false);
+ m_theme->paintThumb(&context, m_scrollbar, IntRect(rect));
+}
+
+WebScrollbarThemePainter::WebScrollbarThemePainter(WebCore::ScrollbarTheme* theme, WebCore::Scrollbar* scrollbar)
+ : m_theme(theme)
+ , m_scrollbar(scrollbar)
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSearchableFormData.cpp b/chromium/third_party/WebKit/Source/web/WebSearchableFormData.cpp
new file mode 100644
index 00000000000..08a51d460b7
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSearchableFormData.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 "WebSearchableFormData.h"
+
+#include "HTMLNames.h"
+#include "WebFormElement.h"
+#include "WebInputElement.h"
+#include "core/dom/Document.h"
+#include "core/html/FormDataList.h"
+#include "core/html/HTMLFormControlElement.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLOptionElement.h"
+#include "core/html/HTMLOptionsCollection.h"
+#include "core/html/HTMLSelectElement.h"
+#include "core/html/HTMLTextAreaElement.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/page/Frame.h"
+#include "core/platform/network/FormDataBuilder.h"
+#include "wtf/text/TextEncoding.h"
+
+using namespace WebCore;
+using namespace HTMLNames;
+
+namespace {
+
+// Gets the encoding for the form.
+void GetFormEncoding(const HTMLFormElement* form, WTF::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 = WTF::TextEncoding(*i);
+ if (encoding->isValid())
+ return;
+ }
+ if (!form->document()->loader())
+ return;
+ *encoding = WTF::TextEncoding(form->document()->encoding());
+}
+
+// Returns true if the submit request results in an HTTP URL.
+bool IsHTTPFormSubmit(const HTMLFormElement* form)
+{
+ // FIXME: This function is insane. This is an overly complicated way to get this information.
+ String action(form->action());
+ // The isNull() check is trying to avoid completeURL returning KURL() when passed a null string.
+ return form->document()->completeURL(action.isNull() ? "" : action).protocolIs("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* control = toHTMLFormControlElement(*i);
+ if (control->isActivatedSubmit()) {
+ // There's a button that is already activated for submit, return 0.
+ return 0;
+ }
+ if (!firstSubmitButton && control->isSuccessfulSubmitButton())
+ firstSubmitButton = control;
+ }
+ return firstSubmitButton;
+}
+
+// Returns true if the selected state of all the options matches the default
+// selected state.
+bool IsSelectInDefaultState(HTMLSelectElement* select)
+{
+ const Vector<HTMLElement*>& listItems = select->listItems();
+ if (select->multiple() || select->size() > 1) {
+ for (Vector<HTMLElement*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) {
+ if (!(*i)->hasLocalName(HTMLNames::optionTag))
+ continue;
+ HTMLOptionElement* optionElement = toHTMLOptionElement(*i);
+ if (optionElement->selected() != optionElement->hasAttribute(selectedAttr))
+ return false;
+ }
+ return true;
+ }
+
+ // The select is rendered as a combobox (called menulist in WebKit). At
+ // least one item is selected, determine which one.
+ HTMLOptionElement* initialSelected = 0;
+ for (Vector<HTMLElement*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) {
+ if (!(*i)->hasLocalName(HTMLNames::optionTag))
+ continue;
+ HTMLOptionElement* optionElement = toHTMLOptionElement(*i);
+ if (optionElement->hasAttribute(selectedAttr)) {
+ // The page specified the option to select.
+ initialSelected = optionElement;
+ break;
+ }
+ if (!initialSelected)
+ initialSelected = optionElement;
+ }
+ return !initialSelected || initialSelected->selected();
+}
+
+// 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(HTMLFormControlElement* formElement)
+{
+ if (formElement->hasTagName(HTMLNames::inputTag)) {
+ const HTMLInputElement* inputElement = toHTMLInputElement(formElement);
+ if (inputElement->isCheckbox() || inputElement->isRadioButton())
+ return inputElement->checked() == inputElement->hasAttribute(checkedAttr);
+ } else if (formElement->hasTagName(HTMLNames::selectTag)) {
+ return IsSelectInDefaultState(toHTMLSelectElement(formElement));
+ }
+ return true;
+}
+
+// Look for a suitable search text field in a given HTMLFormElement
+// Return nothing if one of those items are found:
+// - A text area field
+// - A file upload field
+// - A Password field
+// - More than one text field
+HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement* form)
+{
+ 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* control = toHTMLFormControlElement(*i);
+
+ if (control->isDisabledFormControl() || control->name().isNull())
+ continue;
+
+ if (!IsInDefaultState(control) || isHTMLTextAreaElement(control))
+ return 0;
+
+ if (control->hasTagName(HTMLNames::inputTag) && control->willValidate()) {
+ const HTMLInputElement* input = toHTMLInputElement(control);
+
+ // Return nothing if a file upload field or a password field are found.
+ if (input->isFileUpload() || input->isPasswordField())
+ return 0;
+
+ if (input->isTextField()) {
+ 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 0;
+ }
+ textElement = toHTMLInputElement(control);
+ }
+ }
+ }
+ return textElement;
+}
+
+// Build a search string based on a given HTMLFormElement and HTMLInputElement
+//
+// Search string output example from www.google.com:
+// "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi=&aql=&oq="
+//
+// Return false if the provided HTMLInputElement is not found in the form
+bool buildSearchString(const HTMLFormElement* form, Vector<char>* encodedString, WTF::TextEncoding* encoding, const HTMLInputElement* textElement)
+{
+ bool isElementFound = false;
+
+ // 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* control = toHTMLFormControlElement(*i);
+
+ if (control->isDisabledFormControl() || control->name().isNull())
+ continue;
+
+ FormDataList dataList(*encoding);
+ if (!control->appendFormData(dataList, false))
+ continue;
+
+ const Vector<FormDataList::Item>& items = dataList.items();
+
+ 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 (control == textElement) {
+ encodedString->append("{searchTerms}", 13);
+ isElementFound = true;
+ } else
+ FormDataBuilder::encodeStringAsFormData(*encodedString, j->data());
+ }
+ }
+ return isElementFound;
+}
+} // namespace
+
+namespace WebKit {
+
+WebSearchableFormData::WebSearchableFormData(const WebFormElement& form, const WebInputElement& selectedInputElement)
+{
+ RefPtr<HTMLFormElement> formElement = form.operator PassRefPtr<HTMLFormElement>();
+ HTMLInputElement* inputElement = selectedInputElement.operator PassRefPtr<HTMLInputElement>().get();
+
+ // Only consider forms that GET data.
+ // Allow HTTPS only when an input element is provided.
+ if (equalIgnoringCase(formElement->getAttribute(methodAttr), "post")
+ || (!IsHTTPFormSubmit(formElement.get()) && !inputElement))
+ return;
+
+ Vector<char> encodedString;
+ WTF::TextEncoding encoding;
+
+ GetFormEncoding(formElement.get(), &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;
+ }
+
+ // Look for a suitable search text field in the form when a
+ // selectedInputElement is not provided.
+ if (!inputElement) {
+ inputElement = findSuitableSearchInputElement(formElement.get());
+
+ // Return if no suitable text element has been found.
+ if (!inputElement)
+ 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);
+ }
+
+ bool isValidSearchString = buildSearchString(formElement.get(), &encodedString, &encoding, inputElement);
+
+ if (firstSubmitButton)
+ firstSubmitButton->setActivatedSubmit(false);
+
+ // Return if the search string is not valid.
+ if (!isValidSearchString)
+ return;
+
+ String action(formElement->action());
+ KURL url(formElement->document()->completeURL(action.isNull() ? "" : action));
+ RefPtr<FormData> formData = FormData::create(encodedString);
+ url.setQuery(formData->flattenToString());
+ m_url = url;
+ m_encoding = String(encoding.name());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSecurityOrigin.cpp b/chromium/third_party/WebKit/Source/web/WebSecurityOrigin.cpp
new file mode 100644
index 00000000000..713f29bf18f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSecurityOrigin.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebSecurityOrigin.h"
+
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "weborigin/DatabaseIdentifier.h"
+#include "weborigin/KURL.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebSecurityOriginPrivate : public SecurityOrigin {
+};
+
+WebSecurityOrigin WebSecurityOrigin::createFromDatabaseIdentifier(const WebString& databaseIdentifier)
+{
+ return WebSecurityOrigin(createSecurityOriginFromDatabaseIdentifier(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::isUnique() const
+{
+ ASSERT(m_private);
+ return m_private->isUnique();
+}
+
+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 createDatabaseIdentifierFromSecurityOrigin(m_private);
+}
+
+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.leakRef()))
+{
+}
+
+WebSecurityOrigin& WebSecurityOrigin::operator=(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin)
+{
+ assign(static_cast<WebSecurityOriginPrivate*>(origin.leakRef()));
+ 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;
+}
+
+void WebSecurityOrigin::grantLoadLocalResources() const
+{
+ get()->grantLoadLocalResources();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSecurityPolicy.cpp b/chromium/third_party/WebKit/Source/web/WebSecurityPolicy.cpp
new file mode 100644
index 00000000000..caaecbadb57
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSecurityPolicy.cpp
@@ -0,0 +1,117 @@
+/*
+ * 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 "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "core/loader/FrameLoader.h"
+#include "weborigin/SchemeRegistry.h"
+#include "weborigin/SecurityOrigin.h"
+#include "weborigin/SecurityPolicy.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::registerURLSchemeAsCORSEnabled(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsCORSEnabled(scheme);
+}
+
+void WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme);
+}
+
+void WebSecurityPolicy::registerURLSchemeAsEmptyDocument(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsEmptyDocument(scheme);
+}
+
+void WebSecurityPolicy::addOriginAccessWhitelistEntry(
+ const WebURL& sourceOrigin,
+ const WebString& destinationProtocol,
+ const WebString& destinationHost,
+ bool allowDestinationSubdomains)
+{
+ SecurityPolicy::addOriginAccessWhitelistEntry(
+ *SecurityOrigin::create(sourceOrigin), destinationProtocol,
+ destinationHost, allowDestinationSubdomains);
+}
+
+void WebSecurityPolicy::removeOriginAccessWhitelistEntry(
+ const WebURL& sourceOrigin,
+ const WebString& destinationProtocol,
+ const WebString& destinationHost,
+ bool allowDestinationSubdomains)
+{
+ SecurityPolicy::removeOriginAccessWhitelistEntry(
+ *SecurityOrigin::create(sourceOrigin), destinationProtocol,
+ destinationHost, allowDestinationSubdomains);
+}
+
+void WebSecurityPolicy::resetOriginAccessWhitelists()
+{
+ SecurityPolicy::resetOriginAccessWhitelists();
+}
+
+WebString WebSecurityPolicy::generateReferrerHeader(WebReferrerPolicy referrerPolicy, const WebURL& url, const WebString& referrer)
+{
+ return SecurityPolicy::generateReferrerHeader(static_cast<ReferrerPolicy>(referrerPolicy), url, referrer);
+}
+
+void WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs(const WebString& scheme)
+{
+ SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs(scheme);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSelectElement.cpp b/chromium/third_party/WebKit/Source/web/WebSelectElement.cpp
new file mode 100644
index 00000000000..405aab90de4
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/html/HTMLOptionElement.h"
+#include "core/html/HTMLSelectElement.h"
+#include "public/platform/WebString.h"
+#include "wtf/PassRefPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebSelectElement::setValue(const WebString& value)
+{
+ unwrap<HTMLSelectElement>()->setValue(value);
+}
+
+WebString WebSelectElement::value() const
+{
+ return constUnwrap<HTMLSelectElement>()->value();
+}
+
+WebVector<WebElement> WebSelectElement::listItems() const
+{
+ const Vector<HTMLElement*>& sourceItems = constUnwrap<HTMLSelectElement>()->listItems();
+ WebVector<WebElement> items(sourceItems.size());
+ for (size_t i = 0; i < sourceItems.size(); ++i)
+ items[i] = WebElement(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 toHTMLSelectElement(m_private.get());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSerializedScriptValue.cpp b/chromium/third_party/WebKit/Source/web/WebSerializedScriptValue.cpp
new file mode 100644
index 00000000000..f7965a67bc0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSerializedScriptValue.cpp
@@ -0,0 +1,96 @@
+/*
+ * 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 "bindings/v8/SerializedScriptValue.h"
+#include "public/platform/WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSerializedScriptValue WebSerializedScriptValue::fromString(const WebString& s)
+{
+ return SerializedScriptValue::createFromWire(s);
+}
+
+WebSerializedScriptValue WebSerializedScriptValue::serialize(v8::Handle<v8::Value> value)
+{
+ bool didThrow;
+ WebSerializedScriptValue serializedValue = SerializedScriptValue::create(value, 0, 0, didThrow, v8::Isolate::GetCurrent());
+ if (didThrow)
+ return createInvalid();
+ return serializedValue;
+}
+
+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();
+}
+
+v8::Handle<v8::Value> WebSerializedScriptValue::deserialize()
+{
+ return m_private->deserialize();
+}
+
+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/chromium/third_party/WebKit/Source/web/WebSettingsImpl.cpp b/chromium/third_party/WebKit/Source/web/WebSettingsImpl.cpp
new file mode 100644
index 00000000000..3f6baeea3b6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSettingsImpl.cpp
@@ -0,0 +1,684 @@
+/*
+ * 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 "core/page/Settings.h"
+#include "core/platform/graphics/chromium/DeferredImageDecoder.h"
+#include "wtf/UnusedParam.h"
+
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+
+#if OS(WINDOWS)
+#include "core/rendering/RenderThemeChromiumWin.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSettingsImpl::WebSettingsImpl(Settings* settings)
+ : m_settings(settings)
+ , m_showFPSCounter(false)
+ , m_showPaintRects(false)
+ , m_renderVSyncNotificationEnabled(false)
+ , m_viewportEnabled(false)
+ , m_gestureTapHighlightEnabled(true)
+ , m_autoZoomFocusedNodeToLegibleScale(false)
+ , m_deferredImageDecodingEnabled(false)
+ , m_doubleTapToZoomEnabled(false)
+ , m_supportDeprecatedTargetDensityDPI(false)
+ , m_pinchOverlayScrollbarThickness(0)
+{
+ ASSERT(settings);
+}
+
+void WebSettingsImpl::setStandardFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setStandardFontFamily(font, script);
+}
+
+void WebSettingsImpl::setFixedFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setFixedFontFamily(font, script);
+}
+
+void WebSettingsImpl::setSerifFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setSerifFontFamily(font, script);
+}
+
+void WebSettingsImpl::setSansSerifFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setSansSerifFontFamily(font, script);
+}
+
+void WebSettingsImpl::setCursiveFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setCursiveFontFamily(font, script);
+}
+
+void WebSettingsImpl::setFantasyFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setFantasyFontFamily(font, script);
+}
+
+void WebSettingsImpl::setPictographFontFamily(const WebString& font, UScriptCode script)
+{
+ m_settings->setPictographFontFamily(font, script);
+}
+
+void WebSettingsImpl::setDefaultFontSize(int size)
+{
+ m_settings->setDefaultFontSize(size);
+#if OS(WINDOWS)
+ // 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::setDefaultVideoPosterURL(const WebString& url)
+{
+ m_settings->setDefaultVideoPosterURL(url);
+}
+
+void WebSettingsImpl::setMinimumFontSize(int size)
+{
+ m_settings->setMinimumFontSize(size);
+}
+
+void WebSettingsImpl::setMinimumLogicalFontSize(int size)
+{
+ m_settings->setMinimumLogicalFontSize(size);
+}
+
+void WebSettingsImpl::setDeviceSupportsTouch(bool deviceSupportsTouch)
+{
+ m_settings->setDeviceSupportsTouch(deviceSupportsTouch);
+}
+
+void WebSettingsImpl::setDeviceSupportsMouse(bool deviceSupportsMouse)
+{
+ m_settings->setDeviceSupportsMouse(deviceSupportsMouse);
+}
+
+bool WebSettingsImpl::deviceSupportsTouch()
+{
+ return m_settings->deviceSupportsTouch();
+}
+
+void WebSettingsImpl::setAutoZoomFocusedNodeToLegibleScale(bool autoZoomFocusedNodeToLegibleScale)
+{
+ m_autoZoomFocusedNodeToLegibleScale = autoZoomFocusedNodeToLegibleScale;
+}
+
+void WebSettingsImpl::setTextAutosizingEnabled(bool enabled)
+{
+ m_settings->setTextAutosizingEnabled(enabled);
+}
+
+void WebSettingsImpl::setTextAutosizingFontScaleFactor(float fontScaleFactor)
+{
+ m_settings->setTextAutosizingFontScaleFactor(fontScaleFactor);
+}
+
+void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding)
+{
+ m_settings->setDefaultTextEncodingName((String)encoding);
+}
+
+void WebSettingsImpl::setJavaScriptEnabled(bool enabled)
+{
+ m_settings->setScriptEnabled(enabled);
+}
+
+void WebSettingsImpl::setWebSecurityEnabled(bool enabled)
+{
+ m_settings->setWebSecurityEnabled(enabled);
+}
+
+void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows)
+{
+ m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows);
+}
+
+void WebSettingsImpl::setSupportDeprecatedTargetDensityDPI(bool supportDeprecatedTargetDensityDPI)
+{
+ m_supportDeprecatedTargetDensityDPI = supportDeprecatedTargetDensityDPI;
+}
+
+void WebSettingsImpl::setSupportsMultipleWindows(bool supportsMultipleWindows)
+{
+ m_settings->setSupportsMultipleWindows(supportsMultipleWindows);
+}
+
+void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
+{
+ m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically);
+}
+
+void WebSettingsImpl::setImagesEnabled(bool enabled)
+{
+ m_settings->setImagesEnabled(enabled);
+}
+
+void WebSettingsImpl::setLoadWithOverviewMode(bool enabled)
+{
+ m_settings->setLoadWithOverviewMode(enabled);
+}
+
+void WebSettingsImpl::setPluginsEnabled(bool enabled)
+{
+ m_settings->setPluginsEnabled(enabled);
+}
+
+void WebSettingsImpl::setDOMPasteAllowed(bool enabled)
+{
+ m_settings->setDOMPasteAllowed(enabled);
+}
+
+void WebSettingsImpl::setNeedsSiteSpecificQuirks(bool enabled)
+{
+ m_settings->setNeedsSiteSpecificQuirks(enabled);
+}
+
+void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages)
+{
+ m_settings->setShrinksStandaloneImagesToFit(shrinkImages);
+}
+
+void WebSettingsImpl::setSpatialNavigationEnabled(bool enabled)
+{
+ m_settings->setSpatialNavigationEnabled(enabled);
+}
+
+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::setUseWideViewport(bool useWideViewport)
+{
+ m_settings->setUseWideViewport(useWideViewport);
+}
+
+void WebSettingsImpl::setDoubleTapToZoomEnabled(bool doubleTapToZoomEnabled)
+{
+ m_doubleTapToZoomEnabled = doubleTapToZoomEnabled;
+}
+
+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::setUnsafePluginPastingEnabled(bool enabled)
+{
+ m_settings->setUnsafePluginPastingEnabled(enabled);
+}
+
+void WebSettingsImpl::setDNSPrefetchingEnabled(bool enabled)
+{
+ m_settings->setDNSPrefetchingEnabled(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::setAllowUniversalAccessFromFileURLs(bool allow)
+{
+ m_settings->setAllowUniversalAccessFromFileURLs(allow);
+}
+
+void WebSettingsImpl::setAllowFileAccessFromFileURLs(bool allow)
+{
+ m_settings->setAllowFileAccessFromFileURLs(allow);
+}
+
+void WebSettingsImpl::setTouchDragDropEnabled(bool enabled)
+{
+ m_settings->setTouchDragDropEnabled(enabled);
+}
+
+void WebSettingsImpl::setTouchEditingEnabled(bool enabled)
+{
+ m_settings->setTouchEditingEnabled(enabled);
+}
+
+void WebSettingsImpl::setThreadedHTMLParser(bool enabled)
+{
+ m_settings->setThreadedHTMLParser(enabled);
+}
+
+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::setExperimentalWebSocketEnabled(bool enabled)
+{
+ m_settings->setExperimentalWebSocketEnabled(enabled);
+}
+
+void WebSettingsImpl::setCSSStickyPositionEnabled(bool enabled)
+{
+ m_settings->setCSSStickyPositionEnabled(enabled);
+}
+
+void WebSettingsImpl::setRegionBasedColumnsEnabled(bool enabled)
+{
+ m_settings->setRegionBasedColumnsEnabled(enabled);
+}
+
+void WebSettingsImpl::setExperimentalCSSCustomFilterEnabled(bool enabled)
+{
+ m_settings->setCSSCustomFilterEnabled(enabled);
+}
+
+void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled)
+{
+ m_settings->setOpenGLMultisamplingEnabled(enabled);
+}
+
+void WebSettingsImpl::setPrivilegedWebGLExtensionsEnabled(bool enabled)
+{
+ m_settings->setPrivilegedWebGLExtensionsEnabled(enabled);
+}
+
+void WebSettingsImpl::setRenderVSyncNotificationEnabled(bool enabled)
+{
+ m_renderVSyncNotificationEnabled = enabled;
+}
+
+void WebSettingsImpl::setWebGLErrorsToConsoleEnabled(bool enabled)
+{
+ m_settings->setWebGLErrorsToConsoleEnabled(enabled);
+}
+
+void WebSettingsImpl::setShowFPSCounter(bool show)
+{
+ m_showFPSCounter = show;
+}
+
+void WebSettingsImpl::setShowPaintRects(bool show)
+{
+ m_showPaintRects = show;
+}
+
+void WebSettingsImpl::setEditingBehavior(EditingBehavior behavior)
+{
+ m_settings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(behavior));
+}
+
+void WebSettingsImpl::setAcceleratedCompositingEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingEnabled(enabled);
+ m_settings->setScrollingCoordinatorEnabled(enabled);
+}
+
+void WebSettingsImpl::setForceCompositingMode(bool enabled)
+{
+ m_settings->setForceCompositingMode(enabled);
+}
+
+void WebSettingsImpl::setMockScrollbarsEnabled(bool enabled)
+{
+ m_settings->setMockScrollbarsEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingFor3DTransformsEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForFiltersEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForFiltersEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForVideoEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForVideoEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForOverflowScrollEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForOverflowScrollEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForFixedRootBackgroundEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForFixedRootBackgroundEnabled(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::setAcceleratedCompositingForScrollableFramesEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForScrollableFramesEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedFiltersEnabled(bool enabled)
+{
+ m_settings->setAcceleratedFiltersEnabled(enabled);
+}
+
+void WebSettingsImpl::setAccelerated2dCanvasEnabled(bool enabled)
+{
+ m_settings->setAccelerated2dCanvasEnabled(enabled);
+}
+
+void WebSettingsImpl::setAntialiased2dCanvasEnabled(bool enabled)
+{
+ m_settings->setAntialiased2dCanvasEnabled(enabled);
+}
+
+void WebSettingsImpl::setDeferred2dCanvasEnabled(bool enabled)
+{
+}
+
+void WebSettingsImpl::setDeferredImageDecodingEnabled(bool enabled)
+{
+ DeferredImageDecoder::setEnabled(enabled);
+ m_deferredImageDecodingEnabled = enabled;
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForFixedPositionEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForFixedPositionEnabled(enabled);
+}
+
+void WebSettingsImpl::setAcceleratedCompositingForTransitionEnabled(bool enabled)
+{
+ m_settings->setAcceleratedCompositingForTransitionEnabled(enabled);
+}
+
+void WebSettingsImpl::setMinimumAccelerated2dCanvasSize(int numPixels)
+{
+ m_settings->setMinimumAccelerated2dCanvasSize(numPixels);
+}
+
+void WebSettingsImpl::setMemoryInfoEnabled(bool enabled)
+{
+ m_settings->setMemoryInfoEnabled(enabled);
+}
+
+void WebSettingsImpl::setHyperlinkAuditingEnabled(bool enabled)
+{
+ m_settings->setHyperlinkAuditingEnabled(enabled);
+}
+
+void WebSettingsImpl::setLayoutFallbackWidth(int width)
+{
+ m_settings->setLayoutFallbackWidth(width);
+}
+
+void WebSettingsImpl::setAsynchronousSpellCheckingEnabled(bool enabled)
+{
+ m_settings->setAsynchronousSpellCheckingEnabled(enabled);
+}
+
+void WebSettingsImpl::setUnifiedTextCheckerEnabled(bool enabled)
+{
+ m_settings->setUnifiedTextCheckerEnabled(enabled);
+}
+
+void WebSettingsImpl::setCaretBrowsingEnabled(bool enabled)
+{
+ m_settings->setCaretBrowsingEnabled(enabled);
+}
+
+void WebSettingsImpl::setValidationMessageTimerMagnification(int newValue)
+{
+ m_settings->setValidationMessageTimerMagnification(newValue);
+}
+
+void WebSettingsImpl::setFullScreenEnabled(bool enabled)
+{
+ m_settings->setFullScreenEnabled(enabled);
+}
+
+void WebSettingsImpl::setAllowDisplayOfInsecureContent(bool enabled)
+{
+ m_settings->setAllowDisplayOfInsecureContent(enabled);
+}
+
+void WebSettingsImpl::setAllowRunningOfInsecureContent(bool enabled)
+{
+ m_settings->setAllowRunningOfInsecureContent(enabled);
+}
+
+void WebSettingsImpl::setPasswordEchoEnabled(bool flag)
+{
+ m_settings->setPasswordEchoEnabled(flag);
+}
+
+void WebSettingsImpl::setPasswordEchoDurationInSeconds(double durationInSeconds)
+{
+ m_settings->setPasswordEchoDurationInSeconds(durationInSeconds);
+}
+
+void WebSettingsImpl::setPerTilePaintingEnabled(bool enabled)
+{
+ m_perTilePaintingEnabled = enabled;
+}
+
+void WebSettingsImpl::setShouldPrintBackgrounds(bool enabled)
+{
+ m_settings->setShouldPrintBackgrounds(enabled);
+}
+
+void WebSettingsImpl::setEnableScrollAnimator(bool enabled)
+{
+ m_settings->setScrollAnimatorEnabled(enabled);
+}
+
+void WebSettingsImpl::setEnableTouchAdjustment(bool enabled)
+{
+ m_settings->setTouchAdjustmentEnabled(enabled);
+}
+
+bool WebSettingsImpl::scrollAnimatorEnabled() const
+{
+ return m_settings->scrollAnimatorEnabled();
+}
+
+bool WebSettingsImpl::touchEditingEnabled() const
+{
+ return m_settings->touchEditingEnabled();
+}
+
+void WebSettingsImpl::setVisualWordMovementEnabled(bool enabled)
+{
+ m_settings->setVisualWordMovementEnabled(enabled);
+}
+
+void WebSettingsImpl::setShouldDisplaySubtitles(bool enabled)
+{
+ m_settings->setShouldDisplaySubtitles(enabled);
+}
+
+void WebSettingsImpl::setShouldDisplayCaptions(bool enabled)
+{
+ m_settings->setShouldDisplayCaptions(enabled);
+}
+
+void WebSettingsImpl::setShouldDisplayTextDescriptions(bool enabled)
+{
+ m_settings->setShouldDisplayTextDescriptions(enabled);
+}
+
+void WebSettingsImpl::setShouldRespectImageOrientation(bool enabled)
+{
+ m_settings->setShouldRespectImageOrientation(enabled);
+}
+
+void WebSettingsImpl::setMediaPlaybackRequiresUserGesture(bool required)
+{
+ m_settings->setMediaPlaybackRequiresUserGesture(required);
+}
+
+void WebSettingsImpl::setFixedPositionCreatesStackingContext(bool creates)
+{
+ m_settings->setFixedPositionCreatesStackingContext(creates);
+}
+
+void WebSettingsImpl::setViewportEnabled(bool enabled)
+{
+ m_viewportEnabled = enabled;
+}
+
+void WebSettingsImpl::setSyncXHRInDocumentsEnabled(bool enabled)
+{
+ m_settings->setSyncXHRInDocumentsEnabled(enabled);
+}
+
+void WebSettingsImpl::setCookieEnabled(bool enabled)
+{
+ m_settings->setCookieEnabled(enabled);
+}
+
+void WebSettingsImpl::setGestureTapHighlightEnabled(bool enableHighlight)
+{
+ m_gestureTapHighlightEnabled = enableHighlight;
+}
+
+void WebSettingsImpl::setAllowCustomScrollbarInMainFrame(bool enabled)
+{
+ m_settings->setAllowCustomScrollbarInMainFrame(enabled);
+}
+
+void WebSettingsImpl::setCompositedScrollingForFramesEnabled(bool enabled)
+{
+ m_settings->setCompositedScrollingForFramesEnabled(enabled);
+}
+
+void WebSettingsImpl::setSelectTrailingWhitespaceEnabled(bool enabled)
+{
+ m_settings->setSelectTrailingWhitespaceEnabled(enabled);
+}
+
+void WebSettingsImpl::setSelectionIncludesAltImageText(bool enabled)
+{
+ m_settings->setSelectionIncludesAltImageText(enabled);
+}
+
+void WebSettingsImpl::setSmartInsertDeleteEnabled(bool enabled)
+{
+ m_settings->setSmartInsertDeleteEnabled(enabled);
+}
+
+void WebSettingsImpl::setPinchOverlayScrollbarThickness(int thickness)
+{
+ m_pinchOverlayScrollbarThickness = thickness;
+}
+
+void WebSettingsImpl::setPinchVirtualViewportEnabled(bool enabled)
+{
+ m_settings->setPinchVirtualViewportEnabled(enabled);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSettingsImpl.h b/chromium/third_party/WebKit/Source/web/WebSettingsImpl.h
new file mode 100644
index 00000000000..e10a0eebbac
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSettingsImpl.h
@@ -0,0 +1,198 @@
+/*
+ * 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 bool deviceSupportsTouch();
+ virtual bool scrollAnimatorEnabled() const;
+ virtual bool touchEditingEnabled() const;
+ virtual bool viewportEnabled() const { return m_viewportEnabled; }
+ virtual void setAccelerated2dCanvasEnabled(bool);
+ virtual void setAcceleratedCompositingEnabled(bool);
+ virtual void setAcceleratedCompositingFor3DTransformsEnabled(bool);
+ virtual void setAcceleratedCompositingForAnimationEnabled(bool);
+ virtual void setAcceleratedCompositingForCanvasEnabled(bool);
+ virtual void setAcceleratedCompositingForFiltersEnabled(bool);
+ virtual void setAcceleratedCompositingForFixedPositionEnabled(bool);
+ virtual void setAcceleratedCompositingForOverflowScrollEnabled(bool);
+ virtual void setAcceleratedCompositingForTransitionEnabled(bool);
+ virtual void setAcceleratedCompositingForFixedRootBackgroundEnabled(bool);
+ virtual void setAcceleratedCompositingForPluginsEnabled(bool);
+ virtual void setAcceleratedCompositingForScrollableFramesEnabled(bool);
+ virtual void setAcceleratedCompositingForVideoEnabled(bool);
+ virtual void setAcceleratedFiltersEnabled(bool);
+ virtual void setAllowDisplayOfInsecureContent(bool);
+ virtual void setAllowFileAccessFromFileURLs(bool);
+ virtual void setAllowCustomScrollbarInMainFrame(bool);
+ virtual void setAllowRunningOfInsecureContent(bool);
+ virtual void setAllowScriptsToCloseWindows(bool);
+ virtual void setAllowUniversalAccessFromFileURLs(bool);
+ virtual void setAntialiased2dCanvasEnabled(bool);
+ virtual void setAsynchronousSpellCheckingEnabled(bool);
+ virtual void setAuthorAndUserStylesEnabled(bool);
+ virtual void setAutoZoomFocusedNodeToLegibleScale(bool);
+ virtual void setCaretBrowsingEnabled(bool);
+ virtual void setCompositedScrollingForFramesEnabled(bool);
+ virtual void setCookieEnabled(bool);
+ virtual void setCursiveFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setDNSPrefetchingEnabled(bool);
+ virtual void setDOMPasteAllowed(bool);
+ virtual void setDefaultFixedFontSize(int);
+ virtual void setDefaultFontSize(int);
+ virtual void setDefaultTextEncodingName(const WebString&);
+ virtual void setDefaultVideoPosterURL(const WebString&);
+ virtual void setDeferred2dCanvasEnabled(bool);
+ virtual void setDeferredImageDecodingEnabled(bool);
+ virtual void setDeviceSupportsMouse(bool);
+ virtual void setDeviceSupportsTouch(bool);
+ virtual void setDoubleTapToZoomEnabled(bool);
+ virtual void setDownloadableBinaryFontsEnabled(bool);
+ virtual void setEditableLinkBehaviorNeverLive();
+ virtual void setEditingBehavior(EditingBehavior);
+ virtual void setEnableScrollAnimator(bool);
+ virtual void setEnableTouchAdjustment(bool);
+ virtual void setExperimentalCSSCustomFilterEnabled(bool);
+ virtual void setRegionBasedColumnsEnabled(bool);
+ virtual void setCSSStickyPositionEnabled(bool);
+ virtual void setExperimentalWebGLEnabled(bool);
+ virtual void setExperimentalWebSocketEnabled(bool);
+ virtual void setFantasyFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setFixedFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setFixedPositionCreatesStackingContext(bool);
+ virtual void setForceCompositingMode(bool);
+ virtual void setFullScreenEnabled(bool);
+ virtual void setGestureTapHighlightEnabled(bool);
+ virtual void setHyperlinkAuditingEnabled(bool);
+ virtual void setImagesEnabled(bool);
+ virtual void setJavaEnabled(bool);
+ virtual void setJavaScriptCanAccessClipboard(bool);
+ virtual void setJavaScriptCanOpenWindowsAutomatically(bool);
+ virtual void setJavaScriptEnabled(bool);
+ virtual void setLayoutFallbackWidth(int);
+ virtual void setLoadsImagesAutomatically(bool);
+ virtual void setLoadWithOverviewMode(bool);
+ virtual void setLocalStorageEnabled(bool);
+ virtual void setMediaPlaybackRequiresUserGesture(bool);
+ virtual void setMemoryInfoEnabled(bool);
+ virtual void setMinimumAccelerated2dCanvasSize(int);
+ virtual void setMinimumFontSize(int);
+ virtual void setMinimumLogicalFontSize(int);
+ virtual void setMockScrollbarsEnabled(bool);
+ virtual void setNeedsSiteSpecificQuirks(bool);
+ virtual void setOfflineWebApplicationCacheEnabled(bool);
+ virtual void setOpenGLMultisamplingEnabled(bool);
+ virtual void setPasswordEchoDurationInSeconds(double);
+ virtual void setPasswordEchoEnabled(bool);
+ virtual void setPerTilePaintingEnabled(bool);
+ virtual void setPictographFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setPinchOverlayScrollbarThickness(int);
+ virtual void setPinchVirtualViewportEnabled(bool);
+ virtual void setPluginsEnabled(bool);
+ virtual void setPrivilegedWebGLExtensionsEnabled(bool);
+ virtual void setRenderVSyncNotificationEnabled(bool);
+ virtual void setSansSerifFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setSelectTrailingWhitespaceEnabled(bool);
+ virtual void setSelectionIncludesAltImageText(bool);
+ virtual void setSerifFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setShouldDisplayCaptions(bool);
+ virtual void setShouldDisplaySubtitles(bool);
+ virtual void setShouldDisplayTextDescriptions(bool);
+ virtual void setShouldPrintBackgrounds(bool);
+ virtual void setShouldRespectImageOrientation(bool);
+ virtual void setShowFPSCounter(bool);
+ virtual void setShowPaintRects(bool);
+ virtual void setShrinksStandaloneImagesToFit(bool);
+ virtual void setSmartInsertDeleteEnabled(bool);
+ virtual void setSpatialNavigationEnabled(bool);
+ virtual void setStandardFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON);
+ virtual void setSupportDeprecatedTargetDensityDPI(bool);
+ virtual void setSupportsMultipleWindows(bool);
+ virtual void setSyncXHRInDocumentsEnabled(bool);
+ virtual void setTextAreasAreResizable(bool);
+ virtual void setTextAutosizingEnabled(bool);
+ virtual void setTextAutosizingFontScaleFactor(float);
+ virtual void setTouchDragDropEnabled(bool);
+ virtual void setTouchEditingEnabled(bool);
+ virtual void setThreadedHTMLParser(bool);
+ virtual void setUnifiedTextCheckerEnabled(bool);
+ virtual void setUnsafePluginPastingEnabled(bool);
+ virtual void setUserStyleSheetLocation(const WebURL&);
+ virtual void setUsesEncodingDetector(bool);
+ virtual void setUseWideViewport(bool);
+ virtual void setValidationMessageTimerMagnification(int);
+ virtual void setViewportEnabled(bool);
+ virtual void setVisualWordMovementEnabled(bool);
+ virtual void setWebAudioEnabled(bool);
+ virtual void setWebGLErrorsToConsoleEnabled(bool);
+ virtual void setWebSecurityEnabled(bool);
+ virtual void setXSSAuditorEnabled(bool);
+
+ bool showFPSCounter() const { return m_showFPSCounter; }
+ bool showPaintRects() const { return m_showPaintRects; }
+ bool renderVSyncNotificationEnabled() const { return m_renderVSyncNotificationEnabled; }
+ bool autoZoomFocusedNodeToLegibleScale() const { return m_autoZoomFocusedNodeToLegibleScale; }
+ bool gestureTapHighlightEnabled() const { return m_gestureTapHighlightEnabled; }
+ bool doubleTapToZoomEnabled() const { return m_doubleTapToZoomEnabled; }
+ bool perTilePaintingEnabled() const { return m_perTilePaintingEnabled; }
+ bool supportDeprecatedTargetDensityDPI() const { return m_supportDeprecatedTargetDensityDPI; }
+ int pinchOverlayScrollbarThickness() const { return m_pinchOverlayScrollbarThickness; }
+
+private:
+ WebCore::Settings* m_settings;
+ bool m_showFPSCounter;
+ bool m_showPaintRects;
+ bool m_renderVSyncNotificationEnabled;
+ bool m_viewportEnabled;
+ bool m_gestureTapHighlightEnabled;
+ bool m_autoZoomFocusedNodeToLegibleScale;
+ bool m_deferredImageDecodingEnabled;
+ bool m_doubleTapToZoomEnabled;
+ bool m_perTilePaintingEnabled;
+ bool m_supportDeprecatedTargetDensityDPI;
+ int m_pinchOverlayScrollbarThickness;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp b/chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
new file mode 100644
index 00000000000..59d9ef1681d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
@@ -0,0 +1,457 @@
+/*
+ * 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 "public/platform/WebFileError.h"
+#include "public/platform/WebMessagePortChannel.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "wtf/MainThread.h"
+#include "WebDataSourceImpl.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebRuntimeFeatures.h"
+#include "WebSettings.h"
+#include "WebSharedWorkerClient.h"
+#include "WebView.h"
+#include "WorkerFileSystemClient.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/dom/Document.h"
+#include "core/dom/MessageEvent.h"
+#include "core/dom/MessagePortChannel.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h"
+#include "core/html/HTMLFormElement.h"
+#include "core/inspector/WorkerDebuggerAgent.h"
+#include "core/inspector/WorkerInspectorController.h"
+#include "core/loader/FrameLoadRequest.h"
+#include "core/loader/FrameLoader.h"
+#include "core/page/Page.h"
+#include "core/page/PageGroup.h"
+#include "core/workers/SharedWorkerGlobalScope.h"
+#include "core/workers/SharedWorkerThread.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "core/workers/WorkerThreadStartupData.h"
+#include "modules/webdatabase/DatabaseTask.h"
+#include "weborigin/KURL.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// 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();
+ }
+}
+
+WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client)
+ : m_webView(0)
+ , m_askedToTerminate(false)
+ , m_client(client)
+ , m_pauseWorkerContextOnStart(false)
+{
+ initializeWebKitStaticValues();
+}
+
+WebSharedWorkerImpl::~WebSharedWorkerImpl()
+{
+ ASSERT(m_webView);
+ WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+ if (webFrame)
+ webFrame->setClient(0);
+ m_webView->close();
+}
+
+void WebSharedWorkerImpl::stopWorkerThread()
+{
+ if (m_askedToTerminate)
+ return;
+ m_askedToTerminate = true;
+ if (m_workerThread)
+ m_workerThread->stop();
+}
+
+void WebSharedWorkerImpl::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);
+ m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled());
+ // FIXME: Settings information should be passed to the Worker process from Browser process when the worker
+ // is created (similar to RenderThread::OnCreateNewView).
+ 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 length = static_cast<int>(content.length());
+ RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length));
+ webFrame->frame()->loader()->load(FrameLoadRequest(0, ResourceRequest(url), SubstituteData(buffer, "text/html", "UTF-8", KURL())));
+
+ // This document will be used as 'loading context' for the worker.
+ m_loadingDocument = webFrame->frame()->document();
+}
+
+void WebSharedWorkerImpl::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* WebSharedWorkerImpl::createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient* appcacheHostClient)
+{
+ if (client())
+ return client()->createApplicationCacheHost(appcacheHostClient);
+ return 0;
+}
+
+// WorkerObjectProxy -----------------------------------------------------------
+
+void WebSharedWorkerImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageTask, AllowCrossThreadAccess(this),
+ message->toWireString(), channels));
+}
+
+void WebSharedWorkerImpl::postMessageTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr,
+ String message,
+ PassOwnPtr<MessagePortChannelArray> channels)
+{
+ if (!thisPtr->client())
+ return;
+
+ WebMessagePortChannelArray webChannels(channels ? 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 WebSharedWorkerImpl::postExceptionToWorkerObject(const String& errorMessage,
+ int lineNumber,
+ int columnNumber,
+ const String& sourceURL)
+{
+ WebWorkerBase::dispatchTaskToMainThread(
+ createCallbackTask(&postExceptionTask, AllowCrossThreadAccess(this),
+ errorMessage, lineNumber,
+ sourceURL));
+}
+
+void WebSharedWorkerImpl::postExceptionTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr,
+ const String& errorMessage,
+ int lineNumber, const String& sourceURL)
+{
+ if (!thisPtr->client())
+ return;
+
+ thisPtr->client()->postExceptionToWorkerObject(errorMessage,
+ lineNumber,
+ sourceURL);
+}
+
+void WebSharedWorkerImpl::postConsoleMessageToWorkerObject(MessageSource source,
+ MessageLevel level,
+ const String& message,
+ int lineNumber,
+ const String& sourceURL)
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this), source, level, message, lineNumber, sourceURL));
+}
+
+void WebSharedWorkerImpl::postConsoleMessageTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr,
+ int source,
+ int level,
+ const String& message,
+ int lineNumber,
+ const String& sourceURL)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->postConsoleMessageToWorkerObject(source, level, message, lineNumber, sourceURL);
+}
+
+void WebSharedWorkerImpl::postMessageToPageInspector(const String& message)
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToPageInspectorTask, AllowCrossThreadAccess(this), message));
+}
+
+void WebSharedWorkerImpl::postMessageToPageInspectorTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& message)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->dispatchDevToolsMessage(message);
+}
+
+void WebSharedWorkerImpl::updateInspectorStateCookie(const WTF::String& cookie)
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&updateInspectorStateCookieTask, AllowCrossThreadAccess(this), cookie));
+}
+
+void WebSharedWorkerImpl::updateInspectorStateCookieTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& cookie)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->saveDevToolsAgentState(cookie);
+}
+
+void WebSharedWorkerImpl::confirmMessageFromWorkerObject(bool hasPendingActivity)
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, AllowCrossThreadAccess(this),
+ hasPendingActivity));
+}
+
+void WebSharedWorkerImpl::confirmMessageTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr,
+ bool hasPendingActivity)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->confirmMessageFromWorkerObject(hasPendingActivity);
+}
+
+void WebSharedWorkerImpl::reportPendingActivity(bool hasPendingActivity)
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&reportPendingActivityTask,
+ AllowCrossThreadAccess(this),
+ hasPendingActivity));
+}
+
+void WebSharedWorkerImpl::reportPendingActivityTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr,
+ bool hasPendingActivity)
+{
+ if (!thisPtr->client())
+ return;
+ thisPtr->client()->reportPendingActivity(hasPendingActivity);
+}
+
+void WebSharedWorkerImpl::workerGlobalScopeClosed()
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerGlobalScopeClosedTask,
+ AllowCrossThreadAccess(this)));
+}
+
+void WebSharedWorkerImpl::workerGlobalScopeClosedTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr)
+{
+ if (thisPtr->client())
+ thisPtr->client()->workerContextClosed();
+
+ thisPtr->stopWorkerThread();
+}
+
+void WebSharedWorkerImpl::workerGlobalScopeDestroyed()
+{
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerGlobalScopeDestroyedTask,
+ AllowCrossThreadAccess(this)));
+}
+
+void WebSharedWorkerImpl::workerGlobalScopeDestroyedTask(ScriptExecutionContext* context,
+ WebSharedWorkerImpl* thisPtr)
+{
+ if (thisPtr->client())
+ thisPtr->client()->workerContextDestroyed();
+ // The lifetime of this proxy is controlled by the worker context.
+ delete thisPtr;
+}
+
+// WorkerLoaderProxy -----------------------------------------------------------
+
+void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+ ASSERT(m_loadingDocument->isDocument());
+ m_loadingDocument->postTask(task);
+}
+
+bool WebSharedWorkerImpl::postTaskForModeToWorkerGlobalScope(
+ PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
+{
+ m_workerThread->runLoop().postTaskForMode(task, mode);
+ return true;
+}
+
+WebWorkerBase* WebSharedWorkerImpl::toWebWorkerBase()
+{
+ return this;
+}
+
+
+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, channel.release()));
+ if (listener)
+ listener->connected();
+}
+
+void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, 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);
+ WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
+ ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScope());
+ workerGlobalScope->dispatchEvent(createConnectEvent(port));
+}
+
+void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType policyType, long long)
+{
+ initializeLoader(url);
+
+ WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart;
+ OwnPtr<WorkerClients> workerClients = WorkerClients::create();
+ provideLocalFileSystemToWorker(workerClients.get(), WorkerFileSystemClient::create());
+ OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(url, userAgent, sourceCode, startMode, contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::HeaderType>(policyType), workerClients.release());
+ setWorkerThread(SharedWorkerThread::create(name, *this, *this, startupData.release()));
+
+ workerThread()->start();
+}
+
+void WebSharedWorkerImpl::terminateWorkerContext()
+{
+ stopWorkerThread();
+}
+
+void WebSharedWorkerImpl::clientDestroyed()
+{
+ m_client = 0;
+}
+
+void WebSharedWorkerImpl::pauseWorkerContextOnStart()
+{
+ m_pauseWorkerContextOnStart = true;
+}
+
+static void resumeWorkerContextTask(ScriptExecutionContext* context, bool)
+{
+ toWorkerGlobalScope(context)->workerInspectorController()->resume();
+}
+
+void WebSharedWorkerImpl::resumeWorkerContext()
+{
+ m_pauseWorkerContextOnStart = false;
+ if (workerThread())
+ workerThread()->runLoop().postTaskForMode(createCallbackTask(resumeWorkerContextTask, true), WorkerDebuggerAgent::debuggerTaskMode);
+}
+
+static void connectToWorkerContextInspectorTask(ScriptExecutionContext* context, bool)
+{
+ toWorkerGlobalScope(context)->workerInspectorController()->connectFrontend();
+}
+
+void WebSharedWorkerImpl::attachDevTools()
+{
+ workerThread()->runLoop().postTaskForMode(createCallbackTask(connectToWorkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode);
+}
+
+static void reconnectToWorkerContextInspectorTask(ScriptExecutionContext* context, const String& savedState)
+{
+ WorkerInspectorController* ic = toWorkerGlobalScope(context)->workerInspectorController();
+ ic->restoreInspectorStateFromCookie(savedState);
+ ic->resume();
+}
+
+void WebSharedWorkerImpl::reattachDevTools(const WebString& savedState)
+{
+ workerThread()->runLoop().postTaskForMode(createCallbackTask(reconnectToWorkerContextInspectorTask, String(savedState)), WorkerDebuggerAgent::debuggerTaskMode);
+}
+
+static void disconnectFromWorkerContextInspectorTask(ScriptExecutionContext* context, bool)
+{
+ toWorkerGlobalScope(context)->workerInspectorController()->disconnectFrontend();
+}
+
+void WebSharedWorkerImpl::detachDevTools()
+{
+ workerThread()->runLoop().postTaskForMode(createCallbackTask(disconnectFromWorkerContextInspectorTask, true), WorkerDebuggerAgent::debuggerTaskMode);
+}
+
+static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, const String& message)
+{
+ toWorkerGlobalScope(context)->workerInspectorController()->dispatchMessageFromFrontend(message);
+}
+
+void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message)
+{
+ workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspectorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode);
+ WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread());
+}
+
+WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
+{
+ return new WebSharedWorkerImpl(client);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.h b/chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.h
new file mode 100644
index 00000000000..94a5c646e13
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSharedWorkerImpl.h
@@ -0,0 +1,186 @@
+/*
+ * 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"
+
+#include "WebCommonWorkerClient.h"
+#include "WebContentSecurityPolicy.h"
+#include "WebFrameClient.h"
+#include "WebSharedWorkerClient.h"
+#include "WebWorkerBase.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerObjectProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
+
+
+namespace WebKit {
+class WebApplicationCacheHost;
+class WebApplicationCacheHostClient;
+class WebWorkerClient;
+class WebSecurityOrigin;
+class WebString;
+class WebURL;
+class WebView;
+class WebWorker;
+class WebSharedWorkerClient;
+// 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 WebCore::WorkerObjectProxy
+ , public WebCore::WorkerLoaderProxy
+ , public WebWorkerBase
+ , public WebFrameClient
+ , public WebSharedWorker {
+public:
+ explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
+
+ virtual void postMessageToWorkerObject(
+ PassRefPtr<WebCore::SerializedScriptValue>,
+ PassOwnPtr<WebCore::MessagePortChannelArray>);
+ virtual void postExceptionToWorkerObject(
+ const WTF::String&, int, int, const WTF::String&);
+ virtual void postConsoleMessageToWorkerObject(
+ WebCore::MessageSource, WebCore::MessageLevel,
+ const WTF::String&, int, const WTF::String&);
+ virtual void postMessageToPageInspector(const WTF::String&);
+ virtual void updateInspectorStateCookie(const WTF::String&);
+ virtual void confirmMessageFromWorkerObject(bool);
+ virtual void reportPendingActivity(bool);
+ virtual void workerGlobalScopeClosed();
+ virtual void workerGlobalScopeDestroyed();
+ virtual WebView* view() const { return m_webView; }
+
+ // WebCore::WorkerLoaderProxy methods:
+ virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+ virtual bool postTaskForModeToWorkerGlobalScope(
+ PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode);
+ virtual WebWorkerBase* toWebWorkerBase() OVERRIDE;
+
+ // WebFrameClient methods to support resource loading thru the 'shadow page'.
+ virtual void didCreateDataSource(WebFrame*, WebDataSource*);
+ virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient*);
+
+
+ // WebSharedWorker methods:
+ virtual bool isStarted();
+
+ virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& userAgent, const WebString& sourceCode, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType, long long cacheId);
+
+ virtual void connect(WebMessagePortChannel*, ConnectListener*);
+ virtual void terminateWorkerContext();
+ virtual void clientDestroyed();
+
+ virtual void pauseWorkerContextOnStart();
+ virtual void resumeWorkerContext();
+ virtual void attachDevTools();
+ virtual void reattachDevTools(const WebString& savedState);
+ virtual void detachDevTools();
+ virtual void dispatchDevToolsMessage(const WebString&);
+
+
+ // WebWorkerBase methods:
+ WebCore::WorkerLoaderProxy* workerLoaderProxy() { return this; }
+ WebCommonWorkerClient* commonClient() { return m_client; }
+
+private:
+ virtual ~WebSharedWorkerImpl();
+
+ WebSharedWorkerClient* client() { return m_client; }
+
+ 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&);
+
+
+ static void connectTask(WebCore::ScriptExecutionContext*, PassOwnPtr<WebCore::MessagePortChannel>);
+ // Tasks that are run on the main thread.
+ static void postMessageTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* thisPtr,
+ WTF::String message,
+ PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+ static void postExceptionTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* thisPtr,
+ const WTF::String& message,
+ int lineNumber,
+ const WTF::String& sourceURL);
+ static void postConsoleMessageTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* thisPtr,
+ int source,
+ int level,
+ const WTF::String& message,
+ int lineNumber,
+ const WTF::String& sourceURL);
+ static void postMessageToPageInspectorTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl*, const WTF::String&);
+ static void updateInspectorStateCookieTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const WTF::String& cookie);
+ static void confirmMessageTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* thisPtr,
+ bool hasPendingActivity);
+ static void reportPendingActivityTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* thisPtr,
+ bool hasPendingActivity);
+ static void workerGlobalScopeClosedTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* thisPtr);
+ static void workerGlobalScopeDestroyedTask(
+ WebCore::ScriptExecutionContext*,
+ WebSharedWorkerImpl* 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;
+
+ WebSharedWorkerClient* m_client;
+ bool m_pauseWorkerContextOnStart;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebSocket.cpp b/chromium/third_party/WebKit/Source/web/WebSocket.cpp
new file mode 100644
index 00000000000..845332343fe
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSocket.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebSocket.h"
+
+#include "WebSocketImpl.h"
+
+namespace WebKit {
+
+WebSocket* WebSocket::create(const WebDocument& document, WebSocketClient* client)
+{
+ if (!client)
+ return 0;
+
+ OwnPtr<WebSocketImpl> websocket = adoptPtr(new WebSocketImpl(document, client));
+ if (websocket && websocket->isNull())
+ return 0;
+ return websocket.leakPtr();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSocketImpl.cpp b/chromium/third_party/WebKit/Source/web/WebSocketImpl.cpp
new file mode 100644
index 00000000000..48c3fb9c165
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSocketImpl.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2011, 2012 Google Inc. 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 "WebSocketImpl.h"
+
+#include "WebDocument.h"
+#include "WebSocketClient.h"
+#include "core/dom/Document.h"
+#include "core/page/ConsoleTypes.h"
+#include "core/page/Settings.h"
+#include "modules/websockets/MainThreadWebSocketChannel.h"
+#include "modules/websockets/WebSocketChannel.h"
+#include "modules/websockets/WebSocketChannelClient.h"
+#include "public/platform/WebArrayBuffer.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "wtf/ArrayBuffer.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSocketImpl::WebSocketImpl(const WebDocument& document, WebSocketClient* client)
+ : m_client(client)
+ , m_binaryType(BinaryTypeBlob)
+{
+ RefPtr<Document> coreDocument = PassRefPtr<Document>(document);
+ Settings* settings = coreDocument->settings();
+ if (settings && settings->experimentalWebSocketEnabled()) {
+ // FIXME: Create an "experimental" WebSocketChannel instead of a MainThreadWebSocketChannel.
+ m_private = MainThreadWebSocketChannel::create(coreDocument.get(), this);
+ } else
+ m_private = MainThreadWebSocketChannel::create(coreDocument.get(), this);
+}
+
+WebSocketImpl::~WebSocketImpl()
+{
+ m_private->disconnect();
+}
+
+WebSocket::BinaryType WebSocketImpl::binaryType() const
+{
+ return m_binaryType;
+}
+
+bool WebSocketImpl::setBinaryType(BinaryType binaryType)
+{
+ if (binaryType > BinaryTypeArrayBuffer)
+ return false;
+ m_binaryType = binaryType;
+ return true;
+}
+
+void WebSocketImpl::connect(const WebURL& url, const WebString& protocol)
+{
+ m_private->connect(url, protocol);
+}
+
+WebString WebSocketImpl::subprotocol()
+{
+ return m_private->subprotocol();
+}
+
+WebString WebSocketImpl::extensions()
+{
+ return m_private->extensions();
+}
+
+bool WebSocketImpl::sendText(const WebString& message)
+{
+ return m_private->send(message) == WebSocketChannel::SendSuccess;
+}
+
+bool WebSocketImpl::sendArrayBuffer(const WebArrayBuffer& webArrayBuffer)
+{
+ return m_private->send(*PassRefPtr<ArrayBuffer>(webArrayBuffer), 0, webArrayBuffer.byteLength()) == WebSocketChannel::SendSuccess;
+}
+
+unsigned long WebSocketImpl::bufferedAmount() const
+{
+ return m_private->bufferedAmount();
+}
+
+void WebSocketImpl::close(int code, const WebString& reason)
+{
+ m_private->close(code, reason);
+}
+
+void WebSocketImpl::fail(const WebString& reason)
+{
+ m_private->fail(reason, ErrorMessageLevel);
+}
+
+void WebSocketImpl::disconnect()
+{
+ m_private->disconnect();
+ m_client = 0;
+}
+
+void WebSocketImpl::didConnect()
+{
+ m_client->didConnect();
+}
+
+void WebSocketImpl::didReceiveMessage(const String& message)
+{
+ m_client->didReceiveMessage(WebString(message));
+}
+
+void WebSocketImpl::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData)
+{
+ switch (m_binaryType) {
+ case BinaryTypeBlob:
+ // FIXME: Handle Blob after supporting WebBlob.
+ break;
+ case BinaryTypeArrayBuffer:
+ m_client->didReceiveArrayBuffer(WebArrayBuffer(ArrayBuffer::create(binaryData->data(), binaryData->size())));
+ break;
+ }
+}
+
+void WebSocketImpl::didReceiveMessageError()
+{
+ m_client->didReceiveMessageError();
+}
+
+void WebSocketImpl::didUpdateBufferedAmount(unsigned long bufferedAmount)
+{
+ m_client->didUpdateBufferedAmount(bufferedAmount);
+}
+
+void WebSocketImpl::didStartClosingHandshake()
+{
+ m_client->didStartClosingHandshake();
+}
+
+void WebSocketImpl::didClose(unsigned long bufferedAmount, ClosingHandshakeCompletionStatus status, unsigned short code, const String& reason)
+{
+ m_client->didClose(bufferedAmount, static_cast<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(reason));
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSocketImpl.h b/chromium/third_party/WebKit/Source/web/WebSocketImpl.h
new file mode 100644
index 00000000000..a30aba8bafb
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSocketImpl.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011, 2012 Google Inc. 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 WebSocketImpl_h
+#define WebSocketImpl_h
+
+#include "WebSocket.h"
+#include "WebSocketClient.h"
+#include "modules/websockets/WebSocketChannelClient.h"
+#include "public/platform/WebCommon.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore { class MainThreadWebSocketChannel; }
+
+namespace WebKit {
+
+class WebDocument;
+class WebString;
+class WebURL;
+
+class WebSocketImpl : public WebSocket, public WebCore::WebSocketChannelClient {
+public:
+ WebSocketImpl(const WebDocument&, WebSocketClient*);
+ virtual ~WebSocketImpl();
+
+ bool isNull() const { return !m_private; }
+
+ virtual BinaryType binaryType() const OVERRIDE;
+ virtual bool setBinaryType(BinaryType) OVERRIDE;
+ virtual void connect(const WebURL&, const WebString& protocol) OVERRIDE;
+ virtual WebString subprotocol() OVERRIDE;
+ virtual WebString extensions() OVERRIDE;
+ virtual bool sendText(const WebString&) OVERRIDE;
+ virtual bool sendArrayBuffer(const WebArrayBuffer&) OVERRIDE;
+ virtual unsigned long bufferedAmount() const OVERRIDE;
+ virtual void close(int code, const WebString& reason) OVERRIDE;
+ virtual void fail(const WebString& reason) OVERRIDE;
+ virtual void disconnect() OVERRIDE;
+
+ // WebSocketChannelClient
+ virtual void didConnect() OVERRIDE;
+ virtual void didReceiveMessage(const String& message) OVERRIDE;
+ virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) OVERRIDE;
+ virtual void didReceiveMessageError() OVERRIDE;
+ virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE;
+ virtual void didStartClosingHandshake() OVERRIDE;
+ virtual void didClose(unsigned long bufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE;
+
+private:
+ RefPtr<WebCore::MainThreadWebSocketChannel> m_private;
+ WebSocketClient* m_client;
+ BinaryType m_binaryType;
+};
+
+} // namespace WebKit
+
+#endif // WebWebSocketChannelImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebSpeechGrammar.cpp b/chromium/third_party/WebKit/Source/web/WebSpeechGrammar.cpp
new file mode 100644
index 00000000000..f1bdefaa45a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSpeechGrammar.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 ``AS IS'' AND ANY
+ * EXPRESS OR 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 "WebSpeechGrammar.h"
+
+#include "modules/speech/SpeechGrammar.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebKit {
+
+void WebSpeechGrammar::reset()
+{
+ m_private.reset();
+}
+
+void WebSpeechGrammar::assign(const WebSpeechGrammar& other)
+{
+ m_private = other.m_private;
+}
+
+WebSpeechGrammar::WebSpeechGrammar(const PassRefPtr<WebCore::SpeechGrammar>& value)
+ : m_private(value)
+{
+}
+
+WebSpeechGrammar& WebSpeechGrammar::operator=(const WTF::PassRefPtr<WebCore::SpeechGrammar>& value)
+{
+ m_private = value;
+ return *this;
+}
+
+WebURL WebSpeechGrammar::src() const
+{
+ WEBKIT_ASSERT(m_private.get());
+ return m_private->src();
+}
+
+float WebSpeechGrammar::weight() const
+{
+ WEBKIT_ASSERT(m_private.get());
+ return m_private->weight();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSpeechInputResult.cpp b/chromium/third_party/WebKit/Source/web/WebSpeechInputResult.cpp
new file mode 100644
index 00000000000..20d7b3cbc2d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSpeechInputResult.cpp
@@ -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.
+ *
+ * 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"
+
+#if ENABLE(INPUT_SPEECH)
+
+#include "core/page/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::assign(const WebString& utterance, double confidence)
+{
+ m_private = WebCore::SpeechInputResult::create(utterance, confidence);
+}
+
+void WebSpeechInputResult::assign(const WebSpeechInputResult& other)
+{
+ m_private = WebCore::SpeechInputResult::create(*other.m_private.get());
+}
+
+WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_SPEECH)
diff --git a/chromium/third_party/WebKit/Source/web/WebSpeechRecognitionHandle.cpp b/chromium/third_party/WebKit/Source/web/WebSpeechRecognitionHandle.cpp
new file mode 100644
index 00000000000..42f91c23c0b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSpeechRecognitionHandle.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 ``AS IS'' AND ANY
+ * EXPRESS OR 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 "WebSpeechRecognitionHandle.h"
+
+#include "modules/speech/SpeechRecognition.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebSpeechRecognitionHandle::reset()
+{
+ m_private.reset();
+}
+
+void WebSpeechRecognitionHandle::assign(const WebSpeechRecognitionHandle& other)
+{
+ m_private = other.m_private;
+}
+
+bool WebSpeechRecognitionHandle::equals(const WebSpeechRecognitionHandle& other) const
+{
+ return m_private.get() == other.m_private.get();
+}
+
+bool WebSpeechRecognitionHandle::lessThan(const WebSpeechRecognitionHandle& other) const
+{
+ return m_private.get() < other.m_private.get();
+}
+
+WebSpeechRecognitionHandle::WebSpeechRecognitionHandle(const PassRefPtr<SpeechRecognition>& speechRecognition)
+ : m_private(speechRecognition)
+{
+}
+
+WebSpeechRecognitionHandle& WebSpeechRecognitionHandle::operator=(const PassRefPtr<SpeechRecognition>& speechRecognition)
+{
+ m_private = speechRecognition;
+ return *this;
+}
+
+WebSpeechRecognitionHandle::operator PassRefPtr<SpeechRecognition>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp b/chromium/third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp
new file mode 100644
index 00000000000..979bafa0eb4
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSpeechRecognitionResult.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 ``AS IS'' AND ANY
+ * EXPRESS OR 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 "WebSpeechRecognitionResult.h"
+
+#include "modules/speech/SpeechRecognitionAlternative.h"
+#include "modules/speech/SpeechRecognitionResult.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/Vector.h"
+
+namespace WebKit {
+
+void WebSpeechRecognitionResult::assign(const WebSpeechRecognitionResult& other)
+{
+ m_private = other.m_private;
+}
+
+void WebSpeechRecognitionResult::assign(const WebVector<WebString>& transcripts, const WebVector<float>& confidences, bool final)
+{
+ ASSERT(transcripts.size() == confidences.size());
+
+ Vector<RefPtr<WebCore::SpeechRecognitionAlternative> > alternatives(transcripts.size());
+ for (size_t i = 0; i < transcripts.size(); ++i)
+ alternatives[i] = WebCore::SpeechRecognitionAlternative::create(transcripts[i], confidences[i]);
+
+ m_private = WebCore::SpeechRecognitionResult::create(alternatives, final);
+}
+
+void WebSpeechRecognitionResult::reset()
+{
+ m_private.reset();
+}
+
+WebSpeechRecognitionResult::operator PassRefPtr<WebCore::SpeechRecognitionResult>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp b/chromium/third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.cpp
new file mode 100644
index 00000000000..3fbeca6956a
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebStorageEventDispatcherImpl.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 "WebStorageEventDispatcher.h"
+
+#include "StorageAreaProxy.h"
+#include "WebViewImpl.h"
+#include "public/platform/WebURL.h"
+#include "weborigin/KURL.h"
+#include "weborigin/SecurityOrigin.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebKit {
+
+void WebStorageEventDispatcher::dispatchLocalStorageEvent(
+ const WebString& key, const WebString& oldValue,
+ const WebString& newValue, const WebURL& origin,
+ const WebURL& pageURL, WebStorageArea* sourceAreaInstance,
+ bool originatedInProcess)
+{
+ RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::create(origin);
+ WebCore::StorageAreaProxy::dispatchLocalStorageEvent(
+ key, oldValue, newValue, securityOrigin.get(), pageURL,
+ sourceAreaInstance, originatedInProcess);
+}
+
+void WebStorageEventDispatcher::dispatchSessionStorageEvent(
+ const WebString& key, const WebString& oldValue,
+ const WebString& newValue, const WebURL& origin,
+ const WebURL& pageURL, const WebStorageNamespace& sessionNamespace,
+ WebStorageArea* sourceAreaInstance, bool originatedInProcess)
+{
+ RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::create(origin);
+ WebCore::StorageAreaProxy::dispatchSessionStorageEvent(
+ key, oldValue, newValue, securityOrigin.get(), pageURL,
+ sessionNamespace, sourceAreaInstance, originatedInProcess);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebSurroundingText.cpp b/chromium/third_party/WebKit/Source/web/WebSurroundingText.cpp
new file mode 100644
index 00000000000..887eba737ff
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebSurroundingText.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebSurroundingText.h"
+
+#include "WebHitTestResult.h"
+#include "core/dom/Element.h"
+#include "core/dom/Node.h"
+#include "core/dom/Range.h"
+#include "core/dom/Text.h"
+#include "core/editing/SurroundingText.h"
+#include "core/editing/VisiblePosition.h"
+#include "core/rendering/RenderObject.h"
+#include "public/platform/WebPoint.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& nodePoint, size_t maxLength)
+{
+ const Node* node = webNode.constUnwrap<Node>();
+ if (!node || !node->renderer())
+ return;
+
+ m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(nodePoint))), maxLength));
+}
+
+WebString WebSurroundingText::textContent() const
+{
+ return m_private->content();
+}
+
+size_t WebSurroundingText::hitOffsetInTextContent() const
+{
+ return m_private->positionOffsetInContent();
+}
+
+WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent, size_t endOffsetInContent)
+{
+ return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInContent);
+}
+
+bool WebSurroundingText::isNull() const
+{
+ return !m_private.get();
+}
+
+void WebSurroundingText::reset()
+{
+ m_private.reset(0);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebTestingSupport.cpp b/chromium/third_party/WebKit/Source/web/WebTestingSupport.cpp
new file mode 100644
index 00000000000..f74f9f0a143
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebTestingSupport.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebTestingSupport.h"
+
+#include "WebCoreTestSupport.h"
+#include "WebFrame.h"
+#include <v8/include/v8.h>
+
+namespace WebKit {
+
+void WebTestingSupport::injectInternalsObject(WebFrame* frame)
+{
+ v8::HandleScope handleScope;
+ WebCoreTestSupport::injectInternalsObject(frame->mainWorldScriptContext());
+}
+
+void WebTestingSupport::resetInternalsObject(WebFrame* frame)
+{
+ v8::HandleScope handleScope;
+ WebCoreTestSupport::resetInternalsObject(frame->mainWorldScriptContext());
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp b/chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.cpp
new file mode 100644
index 00000000000..0edfbf20d03
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.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 "WebTextCheckingCompletionImpl.h"
+
+#include "EditorClientImpl.h"
+#include "WebTextCheckingResult.h"
+#include "core/editing/SpellChecker.h"
+#include "core/platform/text/TextCheckerClient.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Assertions.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static Vector<TextCheckingResult> toCoreResults(const WebVector<WebTextCheckingResult>& results)
+{
+ Vector<TextCheckingResult> coreResults;
+ for (size_t i = 0; i < results.size(); ++i)
+ coreResults.append(results[i]);
+ return coreResults;
+}
+
+void WebTextCheckingCompletionImpl::didFinishCheckingText(const WebVector<WebTextCheckingResult>& results)
+{
+ m_request->didSucceed(toCoreResults(results));
+ delete this;
+}
+
+void WebTextCheckingCompletionImpl::didCancelCheckingText()
+{
+ m_request->didCancel();
+ delete this;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.h b/chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.h
new file mode 100644
index 00000000000..a738dd9ab22
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebTextCheckingCompletionImpl.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:
+ *
+ * * 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 WebTextCheckingCompletionImpl_h
+#define WebTextCheckingCompletionImpl_h
+
+#include "WebTextCheckingCompletion.h"
+#include "core/platform/text/TextChecking.h"
+#include "wtf/RefPtr.h"
+
+namespace WebKit {
+
+class EditorClientImpl;
+
+class WebTextCheckingCompletionImpl : public WebTextCheckingCompletion {
+public:
+ explicit WebTextCheckingCompletionImpl(WTF::PassRefPtr<WebCore::TextCheckingRequest> request)
+ : m_request(request)
+ {
+ }
+
+ virtual void didFinishCheckingText(const WebVector<WebTextCheckingResult>&) OVERRIDE;
+ virtual void didCancelCheckingText() OVERRIDE;
+
+private:
+ virtual ~WebTextCheckingCompletionImpl() { }
+
+ WTF::RefPtr<WebCore::TextCheckingRequest> m_request;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebTextCheckingResult.cpp b/chromium/third_party/WebKit/Source/web/WebTextCheckingResult.cpp
new file mode 100644
index 00000000000..bd4f58f7ccb
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebTextCheckingResult.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebTextCheckingResult.h"
+
+#include "core/platform/text/TextCheckerClient.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebTextCheckingResult::operator TextCheckingResult() const
+{
+ TextCheckingResult result;
+ result.type = static_cast<TextCheckingType>(type);
+ result.location = location;
+ result.length = length;
+ result.replacement = replacement;
+ result.hash = hash;
+ if (result.type == TextCheckingTypeGrammar) {
+ GrammarDetail detail;
+ detail.location = 0;
+ detail.length = length;
+ detail.userDescription = replacement;
+ result.details.append(detail);
+ }
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebTextInputInfo.cpp b/chromium/third_party/WebKit/Source/web/WebTextInputInfo.cpp
new file mode 100644
index 00000000000..7a0d87636fd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebTextInputInfo.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebTextInputInfo.h"
+
+namespace WebKit {
+
+bool WebTextInputInfo::equals(const WebTextInputInfo& other) const
+{
+ return type == other.type
+ && value == other.value
+ && selectionStart == other.selectionStart
+ && selectionEnd == other.selectionEnd
+ && compositionStart == other.compositionStart
+ && compositionEnd == other.compositionEnd;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebTextRun.cpp b/chromium/third_party/WebKit/Source/web/WebTextRun.cpp
new file mode 100644
index 00000000000..13c3d9fff15
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "core/platform/graphics/TextRun.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebTextRun::operator WebCore::TextRun() const
+{
+ return TextRun(text, 0, 0, TextRun::AllowTrailingExpansion, rtl ? RTL : LTR, directionalOverride);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebURLLoadTiming.cpp b/chromium/third_party/WebKit/Source/web/WebURLLoadTiming.cpp
new file mode 100644
index 00000000000..d2060919bf2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/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 "public/platform/WebURLLoadTiming.h"
+
+#include "core/platform/network/ResourceLoadTiming.h"
+#include "public/platform/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;
+}
+
+double WebURLLoadTiming::proxyStart() const
+{
+ return m_private->proxyStart;
+}
+
+void WebURLLoadTiming::setProxyStart(double start)
+{
+ m_private->proxyStart = start;
+}
+
+double WebURLLoadTiming::proxyEnd() const
+{
+ return m_private->proxyEnd;
+}
+
+void WebURLLoadTiming::setProxyEnd(double end)
+{
+ m_private->proxyEnd = end;
+}
+
+double WebURLLoadTiming::dnsStart() const
+{
+ return m_private->dnsStart;
+}
+
+void WebURLLoadTiming::setDNSStart(double start)
+{
+ m_private->dnsStart = start;
+}
+
+double WebURLLoadTiming::dnsEnd() const
+{
+ return m_private->dnsEnd;
+}
+
+void WebURLLoadTiming::setDNSEnd(double end)
+{
+ m_private->dnsEnd = end;
+}
+
+double WebURLLoadTiming::connectStart() const
+{
+ return m_private->connectStart;
+}
+
+void WebURLLoadTiming::setConnectStart(double start)
+{
+ m_private->connectStart = start;
+}
+
+double WebURLLoadTiming::connectEnd() const
+{
+ return m_private->connectEnd;
+}
+
+void WebURLLoadTiming::setConnectEnd(double end)
+{
+ m_private->connectEnd = end;
+}
+
+double WebURLLoadTiming::sendStart() const
+{
+ return m_private->sendStart;
+}
+
+void WebURLLoadTiming::setSendStart(double start)
+{
+ m_private->sendStart = start;
+}
+
+double WebURLLoadTiming::sendEnd() const
+{
+ return m_private->sendEnd;
+}
+
+void WebURLLoadTiming::setSendEnd(double end)
+{
+ m_private->sendEnd = end;
+}
+
+double WebURLLoadTiming::receiveHeadersEnd() const
+{
+ return m_private->receiveHeadersEnd;
+}
+
+void WebURLLoadTiming::setReceiveHeadersEnd(double end)
+{
+ m_private->receiveHeadersEnd = end;
+}
+
+double WebURLLoadTiming::sslStart() const
+{
+ return m_private->sslStart;
+}
+
+void WebURLLoadTiming::setSSLStart(double start)
+{
+ m_private->sslStart = start;
+}
+
+double WebURLLoadTiming::sslEnd() const
+{
+ return m_private->sslEnd;
+}
+
+void WebURLLoadTiming::setSSLEnd(double 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/chromium/third_party/WebKit/Source/web/WebUserGestureIndicator.cpp b/chromium/third_party/WebKit/Source/web/WebUserGestureIndicator.cpp
new file mode 100644
index 00000000000..1a12fb25719
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebUserGestureIndicator.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebUserGestureIndicator.h"
+
+#include "WebUserGestureToken.h"
+#include "core/dom/UserGestureIndicator.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebUserGestureIndicator::isProcessingUserGesture()
+{
+ return UserGestureIndicator::processingUserGesture();
+}
+
+bool WebUserGestureIndicator::consumeUserGesture()
+{
+ return UserGestureIndicator::consumeUserGesture();
+}
+
+WebUserGestureToken WebUserGestureIndicator::currentUserGestureToken()
+{
+ return WebUserGestureToken(UserGestureIndicator::currentToken());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebUserGestureToken.cpp b/chromium/third_party/WebKit/Source/web/WebUserGestureToken.cpp
new file mode 100644
index 00000000000..43c078c2ac4
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebUserGestureToken.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WebUserGestureToken.h"
+
+#include "core/dom/UserGestureIndicator.h"
+
+namespace WebKit {
+
+bool WebUserGestureToken::hasGestures() const
+{
+ return !m_token.isNull() && m_token->hasGestures();
+}
+
+void WebUserGestureToken::setOutOfProcess()
+{
+ m_token->setOutOfProcess();
+}
+
+void WebUserGestureToken::setJavascriptPrompt()
+{
+ m_token->setJavascriptPrompt();
+}
+
+WebUserGestureToken::WebUserGestureToken(PassRefPtr<WebCore::UserGestureToken> token)
+{
+ m_token = token;
+}
+
+WebUserGestureToken::operator PassRefPtr<WebCore::UserGestureToken>() const
+{
+ return m_token.get();
+}
+
+void WebUserGestureToken::assign(const WebUserGestureToken& other)
+{
+ m_token = other.m_token;
+}
+
+void WebUserGestureToken::reset()
+{
+ m_token.reset();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebUserMediaRequest.cpp b/chromium/third_party/WebKit/Source/web/WebUserMediaRequest.cpp
new file mode 100644
index 00000000000..d3e5042a73e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebUserMediaRequest.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "WebUserMediaRequest.h"
+
+#include "public/platform/WebMediaConstraints.h"
+#include "public/platform/WebMediaStream.h"
+#include "public/platform/WebMediaStreamSource.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Vector.h"
+#include "WebDocument.h"
+#include "WebSecurityOrigin.h"
+#include "core/dom/Document.h"
+#include "core/platform/mediastream/MediaConstraints.h"
+#include "core/platform/mediastream/MediaStreamDescriptor.h"
+#include "core/platform/mediastream/MediaStreamSource.h"
+#include "modules/mediastream/UserMediaRequest.h"
+#include "weborigin/SecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebUserMediaRequest::WebUserMediaRequest(const PassRefPtr<UserMediaRequest>& request)
+ : m_private(request)
+{
+}
+
+WebUserMediaRequest::WebUserMediaRequest(UserMediaRequest* request)
+ : m_private(request)
+{
+}
+
+void WebUserMediaRequest::reset()
+{
+ m_private.reset();
+}
+
+bool WebUserMediaRequest::audio() const
+{
+ ASSERT(!isNull());
+ return m_private->audio();
+}
+
+bool WebUserMediaRequest::video() const
+{
+ ASSERT(!isNull());
+ return m_private->video();
+}
+
+WebMediaConstraints WebUserMediaRequest::audioConstraints() const
+{
+ ASSERT(!isNull());
+ return m_private->audioConstraints();
+}
+
+WebMediaConstraints WebUserMediaRequest::videoConstraints() const
+{
+ ASSERT(!isNull());
+ return m_private->videoConstraints();
+}
+
+WebSecurityOrigin WebUserMediaRequest::securityOrigin() const
+{
+ ASSERT(!isNull() && m_private->scriptExecutionContext());
+ return WebSecurityOrigin(m_private->scriptExecutionContext()->securityOrigin());
+}
+
+WebDocument WebUserMediaRequest::ownerDocument() const
+{
+ ASSERT(!isNull());
+ return WebDocument(m_private->ownerDocument());
+}
+
+void WebUserMediaRequest::requestSucceeded(const WebMediaStream& streamDescriptor)
+{
+ ASSERT(!isNull() && !streamDescriptor.isNull());
+ m_private->succeed(streamDescriptor);
+}
+
+void WebUserMediaRequest::requestFailed(const WebString& description)
+{
+ ASSERT(!isNull());
+ m_private->fail(description);
+}
+
+void WebUserMediaRequest::requestFailedConstraint(const WebString& constraintName, const WebString& description)
+{
+ ASSERT(!isNull());
+ m_private->failConstraint(constraintName, description);
+}
+
+bool WebUserMediaRequest::equals(const WebUserMediaRequest& other) const
+{
+ if (isNull() || other.isNull())
+ return false;
+ return m_private.get() == other.m_private.get();
+}
+
+void WebUserMediaRequest::assign(const WebUserMediaRequest& other)
+{
+ m_private = other.m_private;
+}
+
+WebUserMediaRequest::operator UserMediaRequest*() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.cpp b/chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.cpp
new file mode 100644
index 00000000000..954b533f5a0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebViewBenchmarkSupportImpl.h"
+
+#include "WebViewImpl.h"
+#include "core/page/FrameView.h"
+#include "core/platform/graphics/FloatSize.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/platform/graphics/IntRect.h"
+#include "core/platform/graphics/IntSize.h"
+
+#include "public/platform/WebCanvas.h"
+#include "wtf/CurrentTime.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/Vector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebViewBenchmarkSupportImpl::paintLayer(PaintClient* paintClient, GraphicsLayer& layer, const IntRect& clip)
+{
+ WebSize canvasSize(clip.width(), clip.height());
+ WebCanvas* canvas = paintClient->willPaint(canvasSize);
+ GraphicsContext context(canvas);
+
+ layer.paintGraphicsLayerContents(context, clip);
+ paintClient->didPaint(canvas);
+}
+
+void WebViewBenchmarkSupportImpl::acceleratedPaintUnclipped(PaintClient* paintClient, GraphicsLayer& layer)
+{
+ FloatSize layerSize = layer.size();
+ IntRect clip(0, 0, layerSize.width(), layerSize.height());
+
+ if (layer.drawsContent())
+ paintLayer(paintClient, layer, clip);
+
+ const Vector<GraphicsLayer*>& children = layer.children();
+ Vector<GraphicsLayer*>::const_iterator it;
+ for (it = children.begin(); it != children.end(); ++it)
+ acceleratedPaintUnclipped(paintClient, **it);
+}
+
+void WebViewBenchmarkSupportImpl::softwarePaint(PaintClient* paintClient, PaintMode paintMode)
+{
+ WebSize size = m_webViewImpl->size();
+ WebRect paintSize;
+ switch (paintMode) {
+ case PaintModeEverything:
+ if (m_webViewImpl->page() && m_webViewImpl->page()->mainFrame()) {
+ FrameView* view = m_webViewImpl->page()->mainFrame()->view();
+ IntSize contentsSize = view->contentsSize();
+ paintSize = WebRect(0, 0, contentsSize.width(), contentsSize.height());
+ } else
+ paintSize = WebRect(0, 0, size.width, size.height);
+ break;
+ }
+
+ WebSize canvasSize(paintSize.width, paintSize.height);
+ WebCanvas* canvas = paintClient->willPaint(canvasSize);
+ m_webViewImpl->paint(canvas, paintSize);
+ paintClient->didPaint(canvas);
+}
+
+void WebViewBenchmarkSupportImpl::paint(PaintClient* paintClient, PaintMode paintMode)
+{
+ m_webViewImpl->layout();
+ if (!m_webViewImpl->isAcceleratedCompositingActive())
+ return softwarePaint(paintClient, paintMode);
+ GraphicsLayer* layer = m_webViewImpl->rootGraphicsLayer();
+ switch (paintMode) {
+ case PaintModeEverything:
+ acceleratedPaintUnclipped(paintClient, *layer);
+ break;
+ }
+}
+}
diff --git a/chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.h b/chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.h
new file mode 100644
index 00000000000..9a612cd6480
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebViewBenchmarkSupportImpl.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 WebViewBenchmarkSupportImpl_h
+#define WebViewBenchmarkSupportImpl_h
+
+#include "WebViewBenchmarkSupport.h"
+
+namespace WebCore {
+class IntRect;
+class GraphicsLayer;
+}
+
+namespace WebKit {
+class WebViewImpl;
+
+class WebViewBenchmarkSupportImpl : public WebViewBenchmarkSupport {
+public:
+ explicit WebViewBenchmarkSupportImpl(WebViewImpl* webViewImpl) : m_webViewImpl(webViewImpl) { }
+ virtual ~WebViewBenchmarkSupportImpl() { }
+
+ // Paints the WebViewImpl onto canvases created from the PaintClient.
+ // If we're in accelerated mode, a new canvas is created for each graphics
+ // layer. Layout() will be called on the web view prior to painting.
+ virtual void paint(PaintClient*, PaintMode) OVERRIDE;
+
+private:
+ void paintLayer(PaintClient*, WebCore::GraphicsLayer&, const WebCore::IntRect& clip);
+
+ // Paints the given graphics layer hierarchy to canvases created by the
+ // canvas factory.
+ void acceleratedPaintUnclipped(PaintClient*, WebCore::GraphicsLayer&);
+ void softwarePaint(PaintClient*, PaintMode);
+
+ WebViewImpl* m_webViewImpl;
+};
+}
+
+#endif // WebViewBenchmarkSupportImpl_h
diff --git a/chromium/third_party/WebKit/Source/web/WebViewImpl.cpp b/chromium/third_party/WebKit/Source/web/WebViewImpl.cpp
new file mode 100644
index 00000000000..2c8e3da8b0b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -0,0 +1,4086 @@
+/*
+ * Copyright (C) 2011, 2012 Google Inc. 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 "public/platform/Platform.h"
+#include "public/platform/WebDragData.h"
+#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebGestureCurve.h"
+#include "public/platform/WebImage.h"
+#include "public/platform/WebLayer.h"
+#include "public/platform/WebLayerTreeView.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+#include "wtf/CurrentTime.h"
+#include "wtf/MainThread.h"
+#include "wtf/RefPtr.h"
+#include "wtf/TemporaryChange.h"
+#include "wtf/Uint8ClampedArray.h"
+#include "AutofillPopupMenuClient.h"
+#include "CSSValueKeywords.h"
+#include "CompositionUnderlineVectorBuilder.h"
+#include "ContextFeaturesClientImpl.h"
+#include "DeviceOrientationClientProxy.h"
+#include "FullscreenController.h"
+#include "GeolocationClientProxy.h"
+#include "GraphicsLayerFactoryChromium.h"
+#include "HTMLNames.h"
+#include "LinkHighlight.h"
+#include "LocalFileSystemClient.h"
+#include "PageWidgetDelegate.h"
+#include "PinchViewports.h"
+#include "PopupContainer.h"
+#include "PrerendererClientImpl.h"
+#include "SpeechInputClientImpl.h"
+#include "SpeechRecognitionClientProxy.h"
+#include "ValidationMessageClientImpl.h"
+#include "ViewportAnchor.h"
+#include "WebAccessibilityObject.h"
+#include "WebActiveWheelFlingParameters.h"
+#include "WebAutofillClient.h"
+#include "WebDevToolsAgentImpl.h"
+#include "WebDevToolsAgentPrivate.h"
+#include "WebFrameImpl.h"
+#include "WebHelperPluginImpl.h"
+#include "WebHitTestResult.h"
+#include "WebInputElement.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebMediaPlayerAction.h"
+#include "WebNode.h"
+#include "WebPagePopupImpl.h"
+#include "WebPlugin.h"
+#include "WebPluginAction.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPopupMenuImpl.h"
+#include "WebRange.h"
+#include "WebSettingsImpl.h"
+#include "WebTextInputInfo.h"
+#include "WebViewClient.h"
+#include "WebWindowFeatures.h"
+#include "core/accessibility/AXObjectCache.h"
+#include "core/css/resolver/StyleResolver.h"
+#include "core/dom/Document.h"
+#include "core/dom/DocumentMarkerController.h"
+#include "core/dom/KeyboardEvent.h"
+#include "core/dom/NodeRenderStyle.h"
+#include "core/dom/Text.h"
+#include "core/dom/WheelEvent.h"
+#include "core/editing/Editor.h"
+#include "core/editing/FrameSelection.h"
+#include "core/editing/InputMethodController.h"
+#include "core/editing/TextIterator.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLMediaElement.h"
+#include "core/html/HTMLTextAreaElement.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/inspector/InspectorController.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoader.h"
+#include "core/loader/UniqueIdentifier.h"
+#include "core/page/Chrome.h"
+#include "core/page/ContextMenuController.h"
+#include "core/page/DragController.h"
+#include "core/page/DragSession.h"
+#include "core/page/EventHandler.h"
+#include "core/page/FocusController.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameTree.h"
+#include "core/page/FrameView.h"
+#include "core/page/Page.h"
+#include "core/page/PageGroup.h"
+#include "core/page/PageGroupLoadDeferrer.h"
+#include "core/page/PagePopupClient.h"
+#include "core/page/PointerLockController.h"
+#include "core/page/Settings.h"
+#include "core/page/TouchDisambiguation.h"
+#include "core/platform/ContextMenu.h"
+#include "core/platform/ContextMenuItem.h"
+#include "core/platform/Cursor.h"
+#include "core/platform/DragData.h"
+#include "core/platform/MIMETypeRegistry.h"
+#include "core/platform/NotImplemented.h"
+#include "core/platform/PlatformGestureEvent.h"
+#include "core/platform/PlatformKeyboardEvent.h"
+#include "core/platform/PlatformMouseEvent.h"
+#include "core/platform/PlatformWheelEvent.h"
+#include "core/platform/PopupMenuClient.h"
+#include "core/platform/Timer.h"
+#include "core/platform/chromium/ChromiumDataObject.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "core/platform/chromium/TraceEvent.h"
+#include "core/platform/chromium/support/WebActiveGestureAnimation.h"
+#include "core/platform/graphics/Color.h"
+#include "core/platform/graphics/ColorSpace.h"
+#include "core/platform/graphics/Extensions3D.h"
+#include "core/platform/graphics/FontCache.h"
+#include "core/platform/graphics/FontDescription.h"
+#include "core/platform/graphics/GraphicsContext.h"
+#include "core/platform/graphics/GraphicsContext3D.h"
+#include "core/platform/graphics/Image.h"
+#include "core/platform/graphics/ImageBuffer.h"
+#include "core/platform/graphics/chromium/LayerPainterChromium.h"
+#include "core/platform/graphics/gpu/SharedGraphicsContext3D.h"
+#include "core/rendering/RenderView.h"
+#include "core/rendering/RenderWidget.h"
+#include "core/rendering/TextAutosizer.h"
+#include "modules/geolocation/GeolocationController.h"
+#include "weborigin/SchemeRegistry.h"
+#include "weborigin/SecurityOrigin.h"
+#include "weborigin/SecurityPolicy.h"
+#include "painting/ContinuousPainter.h"
+
+#if ENABLE(DEFAULT_RENDER_THEME)
+#include "core/platform/chromium/PlatformThemeChromiumDefault.h"
+#include "core/rendering/RenderThemeChromiumDefault.h"
+#endif
+
+#if OS(WINDOWS)
+#if !ENABLE(DEFAULT_RENDER_THEME)
+#include "core/rendering/RenderThemeChromiumWin.h"
+#endif
+#else
+#include "core/rendering/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;
+using namespace std;
+
+// The following constants control parameters for automated scaling of webpages
+// (such as due to a double tap gesture or find in page etc.). These are
+// experimentally determined.
+static const int touchPointPadding = 32;
+static const int nonUserInitiatedPointPadding = 11;
+static const float minScaleDifference = 0.01f;
+static const float doubleTapZoomContentDefaultMargin = 5;
+static const float doubleTapZoomContentMinimumMargin = 2;
+static const double doubleTapZoomAnimationDurationInSeconds = 0.25;
+static const float doubleTapZoomAlreadyLegibleRatio = 1.2f;
+
+static const double multipleTargetsZoomAnimationDurationInSeconds = 0.25;
+static const double findInPageAnimationDurationInSeconds = 0;
+
+// Constants for viewport anchoring on resize.
+static const float viewportAnchorXCoord = 0.5f;
+static const float viewportAnchorYCoord = 0;
+
+// Constants for zooming in on a focused text field.
+static const double scrollAndScaleAnimationDurationInSeconds = 0.2;
+static const int minReadableCaretHeight = 18;
+static const float minScaleChangeToTriggerZoom = 1.05f;
+static const float leftBoxRatio = 0.3f;
+static const int caretPadding = 10;
+
+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;
+
+// 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()
+{
+ DEFINE_STATIC_LOCAL(Vector<PageGroupLoadDeferrer*>, deferrerStack, ());
+ return deferrerStack;
+}
+
+// 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.)
+};
+
+static bool shouldUseExternalPopupMenus = false;
+
+static int webInputEventKeyStateToPlatformEventKeyState(int webInputEventKeyState)
+{
+ int platformEventKeyState = 0;
+ if (webInputEventKeyState & WebInputEvent::ShiftKey)
+ platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::ShiftKey;
+ if (webInputEventKeyState & WebInputEvent::ControlKey)
+ platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::CtrlKey;
+ if (webInputEventKeyState & WebInputEvent::AltKey)
+ platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::AltKey;
+ if (webInputEventKeyState & WebInputEvent::MetaKey)
+ platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::MetaKey;
+ return platformEventKeyState;
+}
+
+// WebView ----------------------------------------------------------------
+
+WebView* WebView::create(WebViewClient* client)
+{
+ // Pass the WebViewImpl's self-reference to the caller.
+ return adoptRef(new WebViewImpl(client)).leakRef();
+}
+
+void WebView::setUseExternalPopupMenus(bool useExternalPopupMenus)
+{
+ shouldUseExternalPopupMenus = useExternalPopupMenus;
+}
+
+void WebView::updateVisitedLinkState(unsigned long long linkHash)
+{
+ Page::visitedStateChanged(PageGroup::sharedGroup(), linkHash);
+}
+
+void WebView::resetVisitedLinkState()
+{
+ Page::allVisitedStateChanged(PageGroup::sharedGroup());
+}
+
+void WebView::willEnterModalLoop()
+{
+ PageGroup* pageGroup = PageGroup::sharedGroup();
+
+ // We allow deferring inspector only when it is running in a separate process (no pages in a shared group)
+ // to support debugger tests in DRT.
+ if (pageGroup->pages().isEmpty())
+ pageGroup = PageGroup::inspectorGroup();
+
+ 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(page());
+}
+
+void WebViewImpl::initializeHelperPluginFrame(WebFrameClient* client)
+{
+ RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client);
+}
+
+void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
+{
+ m_autofillClient = autofillClient;
+}
+
+void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient)
+{
+ if (devToolsClient)
+ m_devToolsAgent = adoptPtr(new WebDevToolsAgentImpl(this, devToolsClient));
+ else
+ m_devToolsAgent.clear();
+}
+
+void WebViewImpl::setValidationMessageClient(WebValidationMessageClient* client)
+{
+ ASSERT(client);
+ m_validationMessage = ValidationMessageClientImpl::create(*this, *client);
+ m_page->setValidationMessageClient(m_validationMessage.get());
+}
+
+void WebViewImpl::setPermissionClient(WebPermissionClient* permissionClient)
+{
+ m_permissionClient = permissionClient;
+ m_featureSwitchClient->setPermissionClient(permissionClient);
+}
+
+void WebViewImpl::setPrerendererClient(WebPrerendererClient* prerendererClient)
+{
+ providePrerendererClientTo(m_page.get(), new PrerendererClientImpl(prerendererClient));
+}
+
+void WebViewImpl::setSpellCheckClient(WebSpellCheckClient* spellCheckClient)
+{
+ m_spellCheckClient = spellCheckClient;
+}
+
+void WebViewImpl::setPasswordGeneratorClient(WebPasswordGeneratorClient* client)
+{
+ m_passwordGeneratorClient = client;
+}
+
+WebViewImpl::WebViewImpl(WebViewClient* client)
+ : m_client(client)
+ , m_autofillClient(0)
+ , m_permissionClient(0)
+ , m_spellCheckClient(0)
+ , m_passwordGeneratorClient(0)
+ , m_chromeClientImpl(this)
+ , m_contextMenuClientImpl(this)
+ , m_dragClientImpl(this)
+ , m_editorClientImpl(this)
+ , m_inspectorClientImpl(this)
+ , m_backForwardClientImpl(this)
+ , m_shouldAutoResize(false)
+ , m_observedNewNavigation(false)
+#ifndef NDEBUG
+ , m_newNavigationLoader(0)
+#endif
+ , m_zoomLevel(0)
+ , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
+ , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
+ , m_savedPageScaleFactor(0)
+ , m_doubleTapZoomPageScaleFactor(0)
+ , m_doubleTapZoomPending(false)
+ , m_enableFakePageScaleAnimationForTesting(false)
+ , m_fakePageScaleAnimationPageScaleFactor(0)
+ , m_fakePageScaleAnimationUseAnchor(false)
+ , m_contextMenuAllowed(false)
+ , m_doingDragAndDrop(false)
+ , m_ignoreInputEvents(false)
+ , m_suppressNextKeypressEvent(false)
+ , m_imeAcceptEvents(true)
+ , m_operationsAllowed(WebDragOperationNone)
+ , m_dragOperation(WebDragOperationNone)
+ , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl()))
+ , m_autofillPopupShowing(false)
+ , m_autofillPopup(0)
+ , m_isTransparent(false)
+ , m_tabsToLinks(false)
+ , m_benchmarkSupport(this)
+ , m_layerTreeView(0)
+ , m_rootLayer(0)
+ , m_rootGraphicsLayer(0)
+ , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this)))
+ , m_isAcceleratedCompositingActive(false)
+ , m_layerTreeViewCommitsDeferred(false)
+ , m_compositorCreationFailed(false)
+ , m_recreatingGraphicsContext(false)
+#if ENABLE(INPUT_SPEECH)
+ , m_speechInputClient(SpeechInputClientImpl::create(client))
+#endif
+ , m_speechRecognitionClient(SpeechRecognitionClientProxy::create(client ? client->speechRecognizer() : 0))
+ , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
+ , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
+ , m_emulatedTextZoomFactor(1)
+ , m_userMediaClientImpl(this)
+ , m_midiClientImpl(this)
+#if ENABLE(NAVIGATOR_CONTENT_UTILS)
+ , m_navigatorContentUtilsClient(NavigatorContentUtilsClientImpl::create(this))
+#endif
+ , m_flingModifier(0)
+ , m_flingSourceDevice(false)
+ , m_fullscreenController(FullscreenController::create(this))
+ , m_showFPSCounter(false)
+ , m_showPaintRects(false)
+ , m_showDebugBorders(false)
+ , m_continuousPaintingEnabled(false)
+ , m_showScrollBottleneckRects(false)
+ , m_baseBackgroundColor(Color::white)
+{
+ Page::PageClients pageClients;
+ pageClients.chromeClient = &m_chromeClientImpl;
+ pageClients.contextMenuClient = &m_contextMenuClientImpl;
+ pageClients.editorClient = &m_editorClientImpl;
+ pageClients.dragClient = &m_dragClientImpl;
+ pageClients.inspectorClient = &m_inspectorClientImpl;
+ pageClients.backForwardClient = &m_backForwardClientImpl;
+
+ m_page = adoptPtr(new Page(pageClients));
+ provideUserMediaTo(m_page.get(), &m_userMediaClientImpl);
+ provideMIDITo(m_page.get(), &m_midiClientImpl);
+#if ENABLE(INPUT_SPEECH)
+ provideSpeechInputTo(m_page.get(), m_speechInputClient.get());
+#endif
+ provideSpeechRecognitionTo(m_page.get(), m_speechRecognitionClient.get());
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ provideNotification(m_page.get(), notificationPresenterImpl());
+#endif
+#if ENABLE(NAVIGATOR_CONTENT_UTILS)
+ provideNavigatorContentUtilsTo(m_page.get(), m_navigatorContentUtilsClient.get());
+#endif
+
+ provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get());
+ provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
+ provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get());
+ m_geolocationClientProxy->setController(GeolocationController::from(m_page.get()));
+
+ provideLocalFileSystemTo(m_page.get(), LocalFileSystemClient::create());
+
+ m_page->setGroupType(Page::SharedPageGroup);
+
+ unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout;
+ m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones));
+
+ if (m_client) {
+ setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor);
+ setVisibilityState(m_client->visibilityState(), true);
+ }
+
+ m_inspectorSettingsMap = adoptPtr(new SettingsMap);
+}
+
+WebViewImpl::~WebViewImpl()
+{
+ ASSERT(!m_page);
+}
+
+RenderTheme* WebViewImpl::theme() const
+{
+ return m_page ? m_page->theme() : RenderTheme::defaultTheme().get();
+}
+
+WebFrameImpl* WebViewImpl::mainFrameImpl()
+{
+ return m_page ? WebFrameImpl::fromFrame(m_page->mainFrame()) : 0;
+}
+
+bool WebViewImpl::tabKeyCyclesThroughElements() const
+{
+ ASSERT(m_page);
+ return m_page->tabKeyCyclesThroughElements();
+}
+
+void WebViewImpl::setTabKeyCyclesThroughElements(bool value)
+{
+ if (m_page)
+ m_page->setTabKeyCyclesThroughElements(value);
+}
+
+void WebViewImpl::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event)
+{
+ // If there is a 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 an element from immediately
+ // reopening the same popup.
+ RefPtr<WebCore::PopupContainer> selectPopup;
+ RefPtr<WebPagePopupImpl> pagePopup;
+ if (event.button == WebMouseEvent::ButtonLeft) {
+ selectPopup = m_selectPopup;
+ pagePopup = m_pagePopup;
+ hidePopups();
+ ASSERT(!m_selectPopup);
+ ASSERT(!m_pagePopup);
+ }
+
+ m_lastMouseDownPoint = WebPoint(event.x, event.y);
+
+ 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));
+ 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;
+ TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this);
+ }
+ }
+
+ PageWidgetEventHandler::handleMouseDown(mainFrame, event);
+
+ 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();
+ }
+
+ if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.get())) {
+ // That click triggered a page popup that is the same as the one we just closed.
+ // It needs to be closed.
+ closePagePopup(m_pagePopup.get());
+ }
+
+ // 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(UNIX)
+ 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.position());
+ 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::handleMouseUp(Frame& mainFrame, const WebMouseEvent& event)
+{
+ PageWidgetEventHandler::handleMouseUp(mainFrame, 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::handleMouseWheel(Frame& mainFrame, const WebMouseWheelEvent& event)
+{
+ hidePopups();
+ return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
+}
+
+void WebViewImpl::scrollBy(const WebFloatSize& delta)
+{
+ if (m_flingSourceDevice == WebGestureEvent::Touchpad) {
+ WebMouseWheelEvent syntheticWheel;
+ const float tickDivisor = WebCore::WheelEvent::TickMultiplier;
+
+ syntheticWheel.deltaX = delta.width;
+ syntheticWheel.deltaY = delta.height;
+ syntheticWheel.wheelTicksX = delta.width / tickDivisor;
+ syntheticWheel.wheelTicksY = delta.height / tickDivisor;
+ syntheticWheel.hasPreciseScrollingDeltas = true;
+ syntheticWheel.x = m_positionOnFlingStart.x;
+ syntheticWheel.y = m_positionOnFlingStart.y;
+ syntheticWheel.globalX = m_globalPositionOnFlingStart.x;
+ syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
+ syntheticWheel.modifiers = m_flingModifier;
+
+ if (m_page && m_page->mainFrame() && m_page->mainFrame()->view())
+ handleMouseWheel(*m_page->mainFrame(), syntheticWheel);
+ } else {
+ WebGestureEvent syntheticGestureEvent;
+
+ syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdateWithoutPropagation;
+ syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width;
+ syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height;
+ syntheticGestureEvent.x = m_positionOnFlingStart.x;
+ syntheticGestureEvent.y = m_positionOnFlingStart.y;
+ syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x;
+ syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y;
+ syntheticGestureEvent.modifiers = m_flingModifier;
+ syntheticGestureEvent.sourceDevice = WebGestureEvent::Touchscreen;
+
+ if (m_page && m_page->mainFrame() && m_page->mainFrame()->view())
+ handleGestureEvent(syntheticGestureEvent);
+ }
+}
+
+bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
+{
+ bool eventSwallowed = false;
+ bool eventCancelled = false; // for disambiguation
+
+ // Special handling for slow-path fling gestures, which have no PlatformGestureEvent equivalent.
+ switch (event.type) {
+ case WebInputEvent::GestureFlingStart: {
+ if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures()) {
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+ }
+ m_client->cancelScheduledContentIntents();
+ m_positionOnFlingStart = WebPoint(event.x / pageScaleFactor(), event.y / pageScaleFactor());
+ m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
+ m_flingModifier = event.modifiers;
+ m_flingSourceDevice = event.sourceDevice;
+ OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize()));
+ m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this);
+ scheduleAnimation();
+ eventSwallowed = true;
+
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+ }
+ case WebInputEvent::GestureFlingCancel:
+ if (m_gestureAnimation) {
+ m_gestureAnimation.clear();
+ if (m_layerTreeView)
+ m_layerTreeView->didStopFlinging();
+ eventSwallowed = true;
+ }
+
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+ default:
+ break;
+ }
+
+ PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
+
+ // Handle link highlighting outside the main switch to avoid getting lost in the
+ // complicated set of cases handled below.
+ switch (event.type) {
+ case WebInputEvent::GestureTapDown:
+ // Queue a highlight animation, then hand off to regular handler.
+#if OS(LINUX)
+ if (settingsImpl()->gestureTapHighlightEnabled())
+ enableTapHighlight(platformEvent);
+#endif
+ break;
+ case WebInputEvent::GestureTapCancel:
+ case WebInputEvent::GestureTap:
+ case WebInputEvent::GestureLongPress:
+ if (m_linkHighlight)
+ m_linkHighlight->startHighlightAnimationIfNeeded();
+ break;
+ default:
+ break;
+ }
+
+ switch (event.type) {
+ case WebInputEvent::GestureTap: {
+ m_client->cancelScheduledContentIntents();
+ if (detectContentOnTouch(platformEvent.position())) {
+ eventSwallowed = true;
+ break;
+ }
+
+ RefPtr<WebCore::PopupContainer> selectPopup;
+ selectPopup = m_selectPopup;
+ hideSelectPopup();
+ ASSERT(!m_selectPopup);
+
+ // Don't trigger a disambiguation popup on sites designed for mobile devices.
+ // Instead, assume that the page has been designed with big enough buttons and links.
+ if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) {
+ // FIXME: didTapMultipleTargets should just take a rect instead of
+ // an event.
+ WebGestureEvent scaledEvent = event;
+ scaledEvent.x = event.x / pageScaleFactor();
+ scaledEvent.y = event.y / pageScaleFactor();
+ scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor();
+ scaledEvent.data.tap.height = event.data.tap.height / pageScaleFactor();
+ IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, scaledEvent.data.tap.height);
+ Vector<IntRect> goodTargets;
+ findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets);
+ // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
+ // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101
+ if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(scaledEvent, goodTargets)) {
+ eventSwallowed = true;
+ eventCancelled = true;
+ break;
+ }
+ }
+
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
+
+ if (m_selectPopup && m_selectPopup == selectPopup) {
+ // That tap triggered a select popup which is the same as the one that
+ // was showing before the tap. It means the user tapped 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();
+ }
+
+ break;
+ }
+ case WebInputEvent::GestureTwoFingerTap:
+ case WebInputEvent::GestureLongPress:
+ case WebInputEvent::GestureLongTap: {
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ break;
+
+ m_client->cancelScheduledContentIntents();
+ m_page->contextMenuController().clearContextMenu();
+ m_contextMenuAllowed = true;
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
+ m_contextMenuAllowed = false;
+
+ break;
+ }
+ case WebInputEvent::GestureTapDown: {
+ m_client->cancelScheduledContentIntents();
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
+ break;
+ }
+ case WebInputEvent::GestureDoubleTap:
+ if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) {
+ m_client->cancelScheduledContentIntents();
+ animateDoubleTapZoom(platformEvent.position());
+ }
+ // GestureDoubleTap is currently only used by Android for zooming. For WebCore,
+ // GestureTap with tap count = 2 is used instead. So we drop GestureDoubleTap here.
+ eventSwallowed = true;
+ break;
+ case WebInputEvent::GestureScrollBegin:
+ case WebInputEvent::GesturePinchBegin:
+ m_client->cancelScheduledContentIntents();
+ case WebInputEvent::GestureScrollEnd:
+ case WebInputEvent::GestureScrollUpdate:
+ case WebInputEvent::GestureScrollUpdateWithoutPropagation:
+ case WebInputEvent::GestureTapCancel:
+ case WebInputEvent::GestureTapUnconfirmed:
+ case WebInputEvent::GesturePinchEnd:
+ case WebInputEvent::GesturePinchUpdate: {
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+}
+
+void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters& parameters)
+{
+ TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation");
+ ASSERT(!m_gestureAnimation);
+ m_positionOnFlingStart = parameters.point;
+ m_globalPositionOnFlingStart = parameters.globalPoint;
+ m_flingModifier = parameters.modifiers;
+ OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAnimationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters.cumulativeScroll));
+ m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.release(), this, parameters.startTime);
+ scheduleAnimation();
+}
+
+bool WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds)
+{
+ WebPoint clampedPoint = targetPosition;
+ if (!useAnchor) {
+ clampedPoint = clampOffsetAtScale(targetPosition, newScale);
+ if (!durationInSeconds) {
+ setPageScaleFactor(newScale, clampedPoint);
+ return false;
+ }
+ }
+ if (useAnchor && newScale == pageScaleFactor())
+ return false;
+
+ if (m_enableFakePageScaleAnimationForTesting) {
+ m_fakePageScaleAnimationTargetPosition = targetPosition;
+ m_fakePageScaleAnimationUseAnchor = useAnchor;
+ m_fakePageScaleAnimationPageScaleFactor = newScale;
+ } else {
+ if (!m_layerTreeView)
+ return false;
+ m_layerTreeView->startPageScaleAnimation(targetPosition, useAnchor, newScale, durationInSeconds);
+ }
+ return true;
+}
+
+void WebViewImpl::enableFakePageScaleAnimationForTesting(bool enable)
+{
+ m_enableFakePageScaleAnimationForTesting = enable;
+}
+
+WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport()
+{
+ return &m_benchmarkSupport;
+}
+
+void WebViewImpl::setShowFPSCounter(bool show)
+{
+ if (m_layerTreeView) {
+ TRACE_EVENT0("webkit", "WebViewImpl::setShowFPSCounter");
+ m_layerTreeView->setShowFPSCounter(show);
+ }
+ m_showFPSCounter = show;
+}
+
+void WebViewImpl::setShowPaintRects(bool show)
+{
+ if (m_layerTreeView) {
+ TRACE_EVENT0("webkit", "WebViewImpl::setShowPaintRects");
+ m_layerTreeView->setShowPaintRects(show);
+ }
+ m_showPaintRects = show;
+}
+
+void WebViewImpl::setShowDebugBorders(bool show)
+{
+ if (m_layerTreeView)
+ m_layerTreeView->setShowDebugBorders(show);
+ m_showDebugBorders = show;
+}
+
+void WebViewImpl::setContinuousPaintingEnabled(bool enabled)
+{
+ if (m_layerTreeView) {
+ TRACE_EVENT0("webkit", "WebViewImpl::setContinuousPaintingEnabled");
+ m_layerTreeView->setContinuousPaintingEnabled(enabled);
+ }
+ m_continuousPaintingEnabled = enabled;
+ m_client->scheduleAnimation();
+}
+
+void WebViewImpl::setShowScrollBottleneckRects(bool show)
+{
+ if (m_layerTreeView)
+ m_layerTreeView->setShowScrollBottleneckRects(show);
+ m_showScrollBottleneckRects = show;
+}
+
+bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event)
+{
+ ASSERT((event.type == WebInputEvent::RawKeyDown)
+ || (event.type == WebInputEvent::KeyDown)
+ || (event.type == WebInputEvent::KeyUp));
+
+ // Halt an in-progress fling on a key event.
+ if (m_gestureAnimation) {
+ m_gestureAnimation.clear();
+ if (m_layerTreeView)
+ m_layerTreeView->didStopFlinging();
+ }
+
+ // 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;
+
+ // If there is a select popup, it should be the one processing the event,
+ // not the page.
+ if (m_selectPopup)
+ return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+ if (m_pagePopup) {
+ m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+ // We need to ignore the next Char event after this otherwise pressing
+ // enter when selecting an item in the popup will go to the page.
+ if (WebInputEvent::RawKeyDown == event.type)
+ m_suppressNextKeypressEvent = true;
+ return true;
+ }
+
+ // Give Autocomplete a chance to consume the key events it is interested in.
+ if (autocompleteHandleKeyEvent(event))
+ return true;
+
+ RefPtr<Frame> frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ EventHandler* handler = frame->eventHandler();
+ if (!handler)
+ return keyEventDefault(event);
+
+#if !OS(DARWIN)
+ const WebInputEvent::Type contextMenuTriggeringEventType =
+#if OS(WINDOWS)
+ WebInputEvent::KeyUp;
+#elif OS(UNIX)
+ 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(DARWIN)
+
+ 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.)
+ Element* element = focusedElement();
+ if (!element || !element->renderer() || !element->renderer()->isEmbeddedObject())
+ m_suppressNextKeypressEvent = true;
+ }
+ return true;
+ }
+
+ return keyEventDefault(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) {
+ Element* element = focusedElement();
+ if (!element) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+ if (!element->hasTagName(HTMLNames::inputTag)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ int selectedIndex = m_autofillPopup->selectedIndex();
+
+ if (!m_autofillPopupClient->canRemoveSuggestionAtIndex(selectedIndex))
+ return false;
+
+ WebString name = WebInputElement(toHTMLInputElement(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::handleCharEvent(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;
+
+ // If there is a select popup, it should be the one processing the event,
+ // not the page.
+ if (m_selectPopup)
+ return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+ if (m_pagePopup)
+ return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+
+ 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;
+}
+
+WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, bool ignoreClipping)
+{
+ if (!mainFrameImpl())
+ return WebRect();
+
+ // Use the rect-based hit test to find the node.
+ IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rect.x, rect.y));
+ HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0);
+ HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResultAtPoint(point, hitType, IntSize(rect.width, rect.height));
+
+ Node* node = result.innerNonSharedNode();
+ if (!node)
+ return WebRect();
+
+ // Find the block type node based on the hit node.
+ while (node && (!node->renderer() || node->renderer()->isInline()))
+ node = node->parentNode();
+
+ // Return the bounding box in the window coordinate system.
+ if (node) {
+ IntRect rect = node->Node::pixelSnappedBoundingBox();
+ Frame* frame = node->document()->frame();
+ return frame->view()->contentsToWindow(rect);
+ }
+ return WebRect();
+}
+
+WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin)
+{
+ WebSize maxSize;
+ if (mainFrame())
+ maxSize = mainFrame()->contentsSize();
+ IntSize scrollOffset;
+ if (mainFrame())
+ scrollOffset = mainFrame()->scrollOffset();
+ int leftMargin = targetMargin;
+ int rightMargin = targetMargin;
+
+ const int absoluteSourceX = source.x + scrollOffset.width();
+ if (leftMargin > absoluteSourceX) {
+ leftMargin = absoluteSourceX;
+ rightMargin = max(leftMargin, minimumMargin);
+ }
+
+ const int maximumRightMargin = maxSize.width - (source.width + absoluteSourceX);
+ if (rightMargin > maximumRightMargin) {
+ rightMargin = maximumRightMargin;
+ leftMargin = min(leftMargin, max(rightMargin, minimumMargin));
+ }
+
+ const int newWidth = source.width + leftMargin + rightMargin;
+ const int newX = source.x - leftMargin;
+
+ ASSERT(newWidth >= 0);
+ ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width);
+
+ return WebRect(newX, source.y, newWidth, source.height);
+}
+
+void WebViewImpl::computeScaleAndScrollForBlockRect(const WebRect& blockRect, float padding, float& scale, WebPoint& scroll, bool& doubleTapShouldZoomOut)
+{
+ scale = pageScaleFactor();
+ scroll.x = scroll.y = 0;
+
+ WebRect rect = blockRect;
+
+ bool scaleUnchanged = true;
+ if (!rect.isEmpty()) {
+ // Pages should be as legible as on desktop when at dpi scale, so no
+ // need to zoom in further when automatically determining zoom level
+ // (after double tap, find in page, etc), though the user should still
+ // be allowed to manually pinch zoom in further if they desire.
+ const float defaultScaleWhenAlreadyLegible = minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
+ float legibleScale = 1;
+ if (page() && page()->settings())
+ legibleScale *= page()->settings()->textAutosizingFontScaleFactor();
+ if (legibleScale < defaultScaleWhenAlreadyLegible)
+ legibleScale = (scale == minimumPageScaleFactor()) ? defaultScaleWhenAlreadyLegible : minimumPageScaleFactor();
+
+ float defaultMargin = doubleTapZoomContentDefaultMargin;
+ float minimumMargin = doubleTapZoomContentMinimumMargin;
+ // We want the margins to have the same physical size, which means we
+ // need to express them in post-scale size. To do that we'd need to know
+ // the scale we're scaling to, but that depends on the margins. Instead
+ // we express them as a fraction of the target rectangle: this will be
+ // correct if we end up fully zooming to it, and won't matter if we
+ // don't.
+ rect = widenRectWithinPageBounds(rect,
+ static_cast<int>(defaultMargin * rect.width / m_size.width),
+ static_cast<int>(minimumMargin * rect.width / m_size.width));
+ // Fit block to screen, respecting limits.
+ scale = static_cast<float>(m_size.width) / rect.width;
+ scale = min(scale, legibleScale);
+ scale = clampPageScaleFactorToLimits(scale);
+
+ scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference;
+ }
+
+ bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPageScaleFactor
+ && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor())
+ || m_doubleTapZoomPending;
+
+ doubleTapShouldZoomOut = rect.isEmpty() || scaleUnchanged || stillAtPreviousDoubleTapScale;
+
+ // FIXME: If this is being called for auto zoom during find in page,
+ // then if the user manually zooms in it'd be nice to preserve the
+ // relative increase in zoom they caused (if they zoom out then it's ok
+ // to zoom them back in again). This isn't compatible with our current
+ // double-tap zoom strategy (fitting the containing block to the screen)
+ // though.
+
+ float screenWidth = m_size.width / scale;
+ float screenHeight = m_size.height / scale;
+
+ // Scroll to vertically align the block.
+ if (rect.height < screenHeight) {
+ // Vertically center short blocks.
+ rect.y -= 0.5 * (screenHeight - rect.height);
+ } else {
+ // Ensure position we're zooming to (+ padding) isn't off the bottom of
+ // the screen.
+ rect.y = max<float>(rect.y, blockRect.y + padding - screenHeight);
+ } // Otherwise top align the block.
+
+ // Do the same thing for horizontal alignment.
+ if (rect.width < screenWidth)
+ rect.x -= 0.5 * (screenWidth - rect.width);
+ else
+ rect.x = max<float>(rect.x, blockRect.x + padding - screenWidth);
+ scroll.x = rect.x;
+ scroll.y = rect.y;
+
+ scale = clampPageScaleFactorToLimits(scale);
+ scroll = mainFrameImpl()->frameView()->windowToContents(scroll);
+ scroll = clampOffsetAtScale(scroll, scale);
+}
+
+static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame)
+{
+ if (!node || !node->renderer())
+ return false;
+
+ ECursor cursor = node->renderer()->style()->cursor();
+ return cursor == CURSOR_POINTER
+ || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey));
+}
+
+Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
+{
+ if (!m_page || !m_page->mainFrame())
+ return 0;
+
+ Node* bestTouchNode = 0;
+
+ IntPoint touchEventLocation(tapEvent.position());
+ m_page->mainFrame()->eventHandler()->adjustGesturePosition(tapEvent, touchEventLocation);
+
+ IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(touchEventLocation);
+ HitTestResult result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::DisallowShadowContent);
+ bestTouchNode = result.targetNode();
+
+ // Make sure our highlight candidate uses a hand cursor as a heuristic to
+ // choose appropriate targets.
+ while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame()))
+ bestTouchNode = bestTouchNode->parentNode();
+
+ // We should pick the largest enclosing node with hand cursor set.
+ while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), false, m_page->mainFrame()))
+ bestTouchNode = bestTouchNode->parentNode();
+
+ return bestTouchNode;
+}
+
+void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent)
+{
+ // Always clear any existing highlight when this is invoked, even if we don't get a new target to highlight.
+ m_linkHighlight.clear();
+
+ Node* touchNode = bestTapNode(tapEvent);
+
+ if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosingLayer())
+ return;
+
+ Color highlightColor = touchNode->renderer()->resolveColor(CSSPropertyWebkitTapHighlightColor);
+ // Safari documentation for -webkit-tap-highlight-color says if the specified color has 0 alpha,
+ // then tap highlighting is disabled.
+ // http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safaricssref/articles/standardcssproperties.html
+ if (!highlightColor.alpha())
+ return;
+
+ m_linkHighlight = LinkHighlight::create(touchNode, this);
+}
+
+void WebViewImpl::animateDoubleTapZoom(const IntPoint& point)
+{
+ if (!mainFrameImpl())
+ return;
+
+ WebRect rect(point.x(), point.y(), touchPointPadding, touchPointPadding);
+ WebRect blockBounds = computeBlockBounds(rect, false);
+
+ float scale;
+ WebPoint scroll;
+ bool doubleTapShouldZoomOut;
+
+ computeScaleAndScrollForBlockRect(blockBounds, touchPointPadding, scale, scroll, doubleTapShouldZoomOut);
+
+ bool isAnimating;
+
+ if (doubleTapShouldZoomOut) {
+ scale = minimumPageScaleFactor();
+ isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->windowToContents(point), true, scale, doubleTapZoomAnimationDurationInSeconds);
+ } else {
+ isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoomAnimationDurationInSeconds);
+ }
+
+ if (isAnimating) {
+ m_doubleTapZoomPageScaleFactor = scale;
+ m_doubleTapZoomPending = true;
+ }
+}
+
+void WebViewImpl::zoomToFindInPageRect(const WebRect& rect)
+{
+ if (!mainFrameImpl())
+ return;
+
+ WebRect blockBounds = computeBlockBounds(rect, true);
+
+ if (blockBounds.isEmpty()) {
+ // Keep current scale (no need to scroll as x,y will normally already
+ // be visible). FIXME: Revisit this if it isn't always true.
+ return;
+ }
+
+ float scale;
+ WebPoint scroll;
+ bool doubleTapShouldZoomOut;
+
+ computeScaleAndScrollForBlockRect(blockBounds, nonUserInitiatedPointPadding, scale, scroll, doubleTapShouldZoomOut);
+
+ startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInSeconds);
+}
+
+bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect)
+{
+ if (!mainFrameImpl())
+ return false;
+
+ float scale;
+ WebPoint scroll;
+ bool doubleTapShouldZoomOut;
+
+ computeScaleAndScrollForBlockRect(rect, nonUserInitiatedPointPadding, scale, scroll, doubleTapShouldZoomOut);
+
+ if (scale <= pageScaleFactor())
+ return false;
+
+ startPageScaleAnimation(scroll, false, scale, multipleTargetsZoomAnimationDurationInSeconds);
+ return true;
+}
+
+void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandlers)
+{
+ if (m_client)
+ m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
+}
+
+void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers)
+{
+ if (m_client)
+ m_client->hasTouchEventHandlers(hasTouchHandlers);
+}
+
+bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point)
+{
+ // FIXME: Implement this. Note that the point must be divided by pageScaleFactor.
+ return true;
+}
+
+#if !OS(DARWIN)
+// 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 OS(DARWIN)
+ // Control-Up/Down should be PageUp/Down on Mac.
+ if (modifiers & WebMouseEvent::ControlKey) {
+ if (keyCode == VKEY_UP)
+ keyCode = VKEY_PRIOR;
+ else if (keyCode == VKEY_DOWN)
+ keyCode = VKEY_NEXT;
+ }
+#endif
+ 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)
+ 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);
+ m_selectPopup = 0;
+ }
+}
+
+PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView)
+{
+ ASSERT(client);
+ if (hasOpenedPopup())
+ hidePopups();
+ ASSERT(!m_pagePopup);
+
+ WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage);
+ ASSERT(popupWidget);
+ m_pagePopup = static_cast<WebPagePopupImpl*>(popupWidget);
+ if (!m_pagePopup->initialize(this, client, originBoundsInRootView)) {
+ m_pagePopup->closePopup();
+ m_pagePopup = 0;
+ }
+ return m_pagePopup.get();
+}
+
+void WebViewImpl::closePagePopup(PagePopup* popup)
+{
+ ASSERT(popup);
+ WebPagePopupImpl* popupImpl = static_cast<WebPagePopupImpl*>(popup);
+ ASSERT(m_pagePopup.get() == popupImpl);
+ if (m_pagePopup.get() != popupImpl)
+ return;
+ m_pagePopup->closePopup();
+ m_pagePopup = 0;
+}
+
+void WebViewImpl::hideAutofillPopup()
+{
+ if (m_autofillPopupShowing) {
+ m_autofillPopup->hidePopup();
+ m_autofillPopupShowing = false;
+ }
+}
+
+WebHelperPluginImpl* WebViewImpl::createHelperPlugin(const String& pluginType, const WebDocument& hostDocument)
+{
+ WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypeHelperPlugin);
+ ASSERT(popupWidget);
+ WebHelperPluginImpl* helperPlugin = static_cast<WebHelperPluginImpl*>(popupWidget);
+
+ if (!helperPlugin->initialize(pluginType, hostDocument, this)) {
+ helperPlugin->closeHelperPlugin();
+ helperPlugin = 0;
+ }
+ return helperPlugin;
+}
+
+Frame* WebViewImpl::focusedWebCoreFrame() const
+{
+ return m_page ? m_page->focusController().focusedOrMainFrame() : 0;
+}
+
+WebViewImpl* WebViewImpl::fromPage(Page* page)
+{
+ if (!page)
+ return 0;
+
+ ChromeClientImpl* chromeClient = static_cast<ChromeClientImpl*>(page->chrome().client());
+ return static_cast<WebViewImpl*>(chromeClient->webView());
+}
+
+// WebWidget ------------------------------------------------------------------
+
+void WebViewImpl::close()
+{
+ if (m_page) {
+ // Initiate shutdown for the entire frameset. This will cause a lot of
+ // notifications to be sent.
+ if (m_page->mainFrame())
+ m_page->mainFrame()->loader()->frameDetached();
+
+ m_page.clear();
+ }
+
+ // Should happen after m_page.clear().
+ if (m_devToolsAgent)
+ 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::willStartLiveResize()
+{
+ if (mainFrameImpl() && mainFrameImpl()->frameView())
+ mainFrameImpl()->frameView()->willStartLiveResize();
+
+ Frame* frame = mainFrameImpl()->frame();
+ WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame);
+ if (pluginContainer)
+ pluginContainer->willStartLiveResize();
+}
+
+WebSize WebViewImpl::size()
+{
+ return m_size;
+}
+
+void WebViewImpl::resize(const WebSize& newSize)
+{
+ if (m_shouldAutoResize || m_size == newSize)
+ return;
+
+ FrameView* view = mainFrameImpl()->frameView();
+ if (!view)
+ return;
+
+ WebSize oldSize = m_size;
+ float oldPageScaleFactor = pageScaleFactor();
+ int oldContentsWidth = contentsSize().width();
+
+ m_size = newSize;
+
+ bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled() && oldSize.width && oldContentsWidth;
+ ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler());
+ if (shouldAnchorAndRescaleViewport) {
+ viewportAnchor.setAnchor(view->visibleContentRect(),
+ FloatSize(viewportAnchorXCoord, viewportAnchorYCoord));
+ }
+
+ // Set the fixed layout size from the viewport constraints before resizing.
+ updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()->viewportArguments());
+
+ WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate();
+ if (agentPrivate)
+ agentPrivate->webViewResized(newSize);
+ if (!agentPrivate || !agentPrivate->metricsOverridden()) {
+ WebFrameImpl* webFrame = mainFrameImpl();
+ if (webFrame->frameView()) {
+ webFrame->frameView()->resize(m_size);
+ if (m_pinchViewports)
+ m_pinchViewports->setViewportSize(m_size);
+ }
+ }
+
+ if (settings()->viewportEnabled()) {
+ // Relayout immediately to recalculate the minimum scale limit.
+ if (view->needsLayout())
+ view->layout();
+
+ if (shouldAnchorAndRescaleViewport) {
+ float viewportWidthRatio = static_cast<float>(newSize.width) / oldSize.width;
+ float contentsWidthRatio = static_cast<float>(contentsSize().width()) / oldContentsWidth;
+ float scaleMultiplier = viewportWidthRatio / contentsWidthRatio;
+
+ IntSize viewportSize = view->visibleContentRect().size();
+ if (scaleMultiplier != 1) {
+ float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier;
+ viewportSize.scale(pageScaleFactor() / newPageScaleFactor);
+ IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(viewportSize);
+ setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale);
+ } else {
+ IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnchor.computeOrigin(viewportSize), pageScaleFactor());
+ updateMainFrameScrollPosition(scrollOffsetAtNewScale, false);
+ }
+ }
+ }
+
+ sendResizeEventAndRepaint();
+}
+
+void WebViewImpl::willEndLiveResize()
+{
+ if (mainFrameImpl() && mainFrameImpl()->frameView())
+ mainFrameImpl()->frameView()->willEndLiveResize();
+
+ Frame* frame = mainFrameImpl()->frame();
+ WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame);
+ if (pluginContainer)
+ pluginContainer->willEndLiveResize();
+}
+
+void WebViewImpl::willEnterFullScreen()
+{
+ m_fullscreenController->willEnterFullScreen();
+}
+
+void WebViewImpl::didEnterFullScreen()
+{
+ m_fullscreenController->didEnterFullScreen();
+}
+
+void WebViewImpl::willExitFullScreen()
+{
+ m_fullscreenController->willExitFullScreen();
+}
+
+void WebViewImpl::didExitFullScreen()
+{
+ m_fullscreenController->didExitFullScreen();
+}
+
+void WebViewImpl::animate(double monotonicFrameBeginTime)
+{
+ TRACE_EVENT0("webkit", "WebViewImpl::animate");
+
+ if (!monotonicFrameBeginTime)
+ monotonicFrameBeginTime = monotonicallyIncreasingTime();
+
+ // Create synthetic wheel events as necessary for fling.
+ if (m_gestureAnimation) {
+ if (m_gestureAnimation->animate(monotonicFrameBeginTime))
+ scheduleAnimation();
+ else {
+ m_gestureAnimation.clear();
+ if (m_layerTreeView)
+ m_layerTreeView->didStopFlinging();
+
+ PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd,
+ m_positionOnFlingStart, m_globalPositionOnFlingStart, 0, 0, 0,
+ false, false, false, false);
+
+ mainFrameImpl()->frame()->eventHandler()->handleGestureScrollEnd(endScrollEvent);
+ }
+ }
+
+ if (!m_page)
+ return;
+
+ PageWidgetDelegate::animate(m_page.get(), monotonicFrameBeginTime);
+
+ if (m_continuousPaintingEnabled) {
+ ContinuousPainter::setNeedsDisplayRecursive(m_rootGraphicsLayer, m_pageOverlays.get());
+ m_client->scheduleAnimation();
+ }
+}
+
+void WebViewImpl::layout()
+{
+ TRACE_EVENT0("webkit", "WebViewImpl::layout");
+ PageWidgetDelegate::layout(m_page.get());
+ if (m_layerTreeView)
+ m_layerTreeView->setBackgroundColor(backgroundColor());
+
+ if (m_linkHighlight)
+ m_linkHighlight->updateGeometry();
+}
+
+void WebViewImpl::enterForceCompositingMode(bool enter)
+{
+ if (page()->settings()->forceCompositingMode() == enter)
+ return;
+
+ TRACE_EVENT1("webkit", "WebViewImpl::enterForceCompositingMode", "enter", enter);
+ settingsImpl()->setForceCompositingMode(enter);
+ if (enter) {
+ if (!m_page)
+ return;
+ Frame* mainFrame = m_page->mainFrame();
+ if (!mainFrame)
+ return;
+ mainFrame->view()->updateCompositingLayersAfterStyleChange();
+ }
+}
+
+void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect)
+{
+ ASSERT(m_layerTreeView);
+
+ SkBitmap target;
+ target.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height(), rect.width() * 4);
+ target.allocPixels();
+ m_layerTreeView->compositeAndReadback(target.getPixels(), rect);
+#if (!SK_R32_SHIFT && SK_B32_SHIFT == 16)
+ // The compositor readback always gives back pixels in BGRA order, but for
+ // example Android's Skia uses RGBA ordering so the red and blue channels
+ // need to be swapped.
+ uint8_t* pixels = reinterpret_cast<uint8_t*>(target.getPixels());
+ for (size_t i = 0; i < target.getSize(); i += 4)
+ std::swap(pixels[i], pixels[i + 2]);
+#endif
+ canvas->writePixels(target, rect.x(), rect.y());
+}
+
+void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions option)
+{
+#if !OS(ANDROID)
+ // ReadbackFromCompositorIfAvailable is the only option available on non-Android.
+ // Ideally, Android would always use ReadbackFromCompositorIfAvailable as well.
+ ASSERT(option == ReadbackFromCompositorIfAvailable);
+#endif
+
+ if (option == ReadbackFromCompositorIfAvailable && isAcceleratedCompositingActive()) {
+ // 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(0, 0), m_layerTreeView->deviceViewportSize()));
+ doPixelReadbackToCanvas(canvas, resizeRect);
+ }
+ } else {
+ FrameView* view = page()->mainFrame()->view();
+ PaintBehavior oldPaintBehavior = view->paintBehavior();
+ if (isAcceleratedCompositingActive()) {
+ ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent);
+ view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
+ }
+
+ double paintStart = currentTime();
+ PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque);
+ double paintEnd = currentTime();
+ double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart);
+ WebKit::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
+ WebKit::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
+
+ if (isAcceleratedCompositingActive()) {
+ ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent);
+ view->setPaintBehavior(oldPaintBehavior);
+ }
+ }
+}
+
+bool WebViewImpl::isTrackingRepaints() const
+{
+ if (!page())
+ return false;
+ FrameView* view = page()->mainFrame()->view();
+ return view->isTrackingRepaints();
+}
+
+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::setNeedsRedraw()
+{
+ if (m_layerTreeView && isAcceleratedCompositingActive())
+ m_layerTreeView->setNeedsRedraw();
+}
+
+void WebViewImpl::enterFullScreenForElement(WebCore::Element* element)
+{
+ m_fullscreenController->enterFullScreenForElement(element);
+}
+
+void WebViewImpl::exitFullScreenForElement(WebCore::Element* element)
+{
+ m_fullscreenController->exitFullScreenForElement(element);
+}
+
+bool WebViewImpl::hasHorizontalScrollbar()
+{
+ return mainFrameImpl()->frameView()->horizontalScrollbar();
+}
+
+bool WebViewImpl::hasVerticalScrollbar()
+{
+ return mainFrameImpl()->frameView()->verticalScrollbar();
+}
+
+const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
+
+bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ TRACE_EVENT0("input", "WebViewImpl::handleInputEvent");
+ // If we've started a drag and drop operation, ignore input events until
+ // we're done.
+ if (m_doingDragAndDrop)
+ return true;
+
+ if (m_devToolsAgent && m_devToolsAgent->handleInputEvent(m_page.get(), inputEvent))
+ return true;
+
+ // Report the event to be NOT processed by WebKit, so that the browser can handle it appropriately.
+ if (m_ignoreInputEvents)
+ return false;
+
+ TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent, &inputEvent);
+
+ if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) {
+ pointerLockMouseEvent(inputEvent);
+ return true;
+ }
+
+ if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) {
+ TRACE_EVENT1("input", "captured mouse event", "type", 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);
+ return true;
+ }
+
+ return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);
+}
+
+void WebViewImpl::setCursorVisibilityState(bool isVisible)
+{
+ if (m_page)
+ m_page->setIsCursorVisible(isVisible);
+}
+
+void WebViewImpl::mouseCaptureLost()
+{
+ TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
+ m_mouseCaptureNode = 0;
+}
+
+void WebViewImpl::setFocus(bool enable)
+{
+ m_page->focusController().setFocused(enable);
+ if (enable) {
+ m_page->focusController().setActive(true);
+ RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame();
+ if (focusedFrame) {
+ Element* element = focusedFrame->document()->focusedElement();
+ if (element && 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.
+ if (element->isTextFormControl()) {
+ element->updateFocusAppearance(true);
+ } else if (element->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(element, 0, Position::PositionIsOffsetInAnchor);
+ focusedFrame->selection()->setSelection(
+ VisibleSelection(position, SEL_DEFAULT_AFFINITY));
+ }
+ }
+ }
+ m_imeAcceptEvents = true;
+ } else {
+ hidePopups();
+
+ // Clear focus on the currently focused frame if any.
+ if (!m_page)
+ return;
+
+ Frame* frame = m_page->mainFrame();
+ if (!frame)
+ return;
+
+ RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame();
+ if (focusedFrame) {
+ // Finish an ongoing composition to delete the composition node.
+ if (focusedFrame->inputMethodController().hasComposition()) {
+ if (m_autofillClient)
+ m_autofillClient->setIgnoreTextChanges(true);
+
+ focusedFrame->inputMethodController().confirmComposition();
+
+ if (m_autofillClient)
+ m_autofillClient->setIgnoreTextChanges(false);
+ }
+ 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.
+ InputMethodController& inputMethodController = focused->inputMethodController();
+ if (!editor->canEdit() && !inputMethodController.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.
+ RefPtr<Range> range = inputMethodController.compositionRange();
+ if (range) {
+ Node* node = range->startContainer();
+ 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;
+ inputMethodController.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.
+ inputMethodController.setComposition(String(text),
+ CompositionUnderlineVectorBuilder(underlines),
+ selectionStart, selectionEnd);
+
+ return inputMethodController.hasComposition();
+}
+
+bool WebViewImpl::confirmComposition()
+{
+ return confirmComposition(DoNotKeepSelection);
+}
+
+bool WebViewImpl::confirmComposition(ConfirmCompositionBehavior selectionBehavior)
+{
+ return confirmComposition(WebString(), selectionBehavior);
+}
+
+bool WebViewImpl::confirmComposition(const WebString& text)
+{
+ return confirmComposition(text, DoNotKeepSelection);
+}
+
+bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBehavior selectionBehavior)
+{
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused || !m_imeAcceptEvents)
+ return false;
+ Editor* editor = focused->editor();
+ InputMethodController& inputMethodController = focused->inputMethodController();
+ if (!editor || (!inputMethodController.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.
+ RefPtr<Range> range = inputMethodController.compositionRange();
+ if (range) {
+ Node* node = range->startContainer();
+ if (!node || !node->isContentEditable())
+ return false;
+ }
+
+ if (inputMethodController.hasComposition()) {
+ if (text.length()) {
+ inputMethodController.confirmComposition(String(text));
+ } else {
+ size_t location;
+ size_t length;
+ caretOrSelectionRange(&location, &length);
+
+ inputMethodController.confirmComposition();
+ if (selectionBehavior == KeepSelection)
+ editor->setSelectionOffsets(location, location + length);
+ }
+ } else
+ editor->insertText(String(text), 0);
+
+ return true;
+}
+
+bool WebViewImpl::compositionRange(size_t* location, size_t* length)
+{
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused || !focused->selection() || !m_imeAcceptEvents)
+ return false;
+
+ RefPtr<Range> range = focused->inputMethodController().compositionRange();
+ if (!range)
+ return false;
+
+ if (TextIterator::getLocationAndLengthFromRange(focused->selection()->rootEditableElementOrDocumentElement(), range.get(), *location, *length))
+ return true;
+ return false;
+}
+
+WebTextInputInfo WebViewImpl::textInputInfo()
+{
+ WebTextInputInfo info;
+
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return info;
+
+ FrameSelection* selection = focused->selection();
+ if (!selection)
+ return info;
+
+ Node* node = selection->selection().rootEditableElement();
+ if (!node)
+ return info;
+
+ info.inputMode = inputModeOfFocusedElement();
+
+ info.type = textInputType();
+ if (info.type == WebTextInputTypeNone)
+ return info;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return info;
+
+ info.value = plainText(rangeOfContents(node).get());
+
+ if (info.value.isEmpty())
+ return info;
+
+ size_t location;
+ size_t length;
+ RefPtr<Range> range = selection->selection().firstRange();
+ if (range && TextIterator::getLocationAndLengthFromRange(selection->rootEditableElement(), range.get(), location, length)) {
+ info.selectionStart = location;
+ info.selectionEnd = location + length;
+ }
+ range = focused->inputMethodController().compositionRange();
+ if (range && TextIterator::getLocationAndLengthFromRange(selection->rootEditableElement(), range.get(), location, length)) {
+ info.compositionStart = location;
+ info.compositionEnd = location + length;
+ }
+
+ return info;
+}
+
+WebTextInputType WebViewImpl::textInputType()
+{
+ Element* element = focusedElement();
+ if (!element)
+ return WebTextInputTypeNone;
+
+ if (element->hasTagName(HTMLNames::inputTag)) {
+ HTMLInputElement* input = toHTMLInputElement(element);
+
+ if (input->isDisabledOrReadOnly())
+ return WebTextInputTypeNone;
+
+ if (input->isPasswordField())
+ return WebTextInputTypePassword;
+ if (input->isSearchField())
+ return WebTextInputTypeSearch;
+ if (input->isEmailField())
+ return WebTextInputTypeEmail;
+ if (input->isNumberField())
+ return WebTextInputTypeNumber;
+ if (input->isTelephoneField())
+ return WebTextInputTypeTelephone;
+ if (input->isURLField())
+ return WebTextInputTypeURL;
+ if (input->isDateField())
+ return WebTextInputTypeDate;
+ if (input->isDateTimeLocalField())
+ return WebTextInputTypeDateTimeLocal;
+ if (input->isMonthField())
+ return WebTextInputTypeMonth;
+ if (input->isTimeField())
+ return WebTextInputTypeTime;
+ if (input->isWeekField())
+ return WebTextInputTypeWeek;
+ if (input->isTextField())
+ return WebTextInputTypeText;
+
+ return WebTextInputTypeNone;
+ }
+
+ if (isHTMLTextAreaElement(element)) {
+ if (toHTMLTextAreaElement(element)->isDisabledOrReadOnly())
+ return WebTextInputTypeNone;
+ return WebTextInputTypeTextArea;
+ }
+
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+ if (element->isHTMLElement()) {
+ if (toHTMLElement(element)->isDateTimeFieldElement())
+ return WebTextInputTypeDateTimeField;
+ }
+#endif
+
+ if (element->shouldUseInputMethod())
+ return WebTextInputTypeContentEditable;
+
+ return WebTextInputTypeNone;
+}
+
+WebString WebViewImpl::inputModeOfFocusedElement()
+{
+ Element* element = focusedElement();
+ if (!element)
+ return WebString();
+
+ if (element->hasTagName(HTMLNames::inputTag)) {
+ const HTMLInputElement* input = toHTMLInputElement(element);
+ if (input->supportsInputModeAttribute())
+ return input->fastGetAttribute(HTMLNames::inputmodeAttr).lower();
+ return WebString();
+ }
+ if (isHTMLTextAreaElement(element)) {
+ const HTMLTextAreaElement* textarea = toHTMLTextAreaElement(element);
+ return textarea->fastGetAttribute(HTMLNames::inputmodeAttr).lower();
+ }
+
+ return WebString();
+}
+
+bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
+{
+ const Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+ FrameSelection* selection = frame->selection();
+ if (!selection)
+ return false;
+
+ if (selection->isCaret())
+ anchor = focus = selection->absoluteCaretBounds();
+ else {
+ RefPtr<Range> selectedRange = frame->selection()->toNormalizedRange();
+ if (!selectedRange)
+ return false;
+
+ RefPtr<Range> range(Range::create(selectedRange->startContainer()->document(),
+ selectedRange->startContainer(),
+ selectedRange->startOffset(),
+ selectedRange->startContainer(),
+ selectedRange->startOffset()));
+ anchor = frame->editor()->firstRectForRange(range.get());
+
+ range = Range::create(selectedRange->endContainer()->document(),
+ selectedRange->endContainer(),
+ selectedRange->endOffset(),
+ selectedRange->endContainer(),
+ selectedRange->endOffset());
+ focus = frame->editor()->firstRectForRange(range.get());
+ }
+
+ IntRect scaledAnchor(frame->view()->contentsToWindow(anchor));
+ IntRect scaledFocus(frame->view()->contentsToWindow(focus));
+ scaledAnchor.scale(pageScaleFactor());
+ scaledFocus.scale(pageScaleFactor());
+ anchor = scaledAnchor;
+ focus = scaledFocus;
+
+ if (!frame->selection()->selection().isBaseFirst())
+ std::swap(anchor, focus);
+ return true;
+}
+
+bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const
+{
+ const Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+ FrameSelection* selection = frame->selection();
+ if (!selection)
+ return false;
+ if (!selection->toNormalizedRange())
+ return false;
+ start = selection->start().primaryDirection() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight;
+ end = selection->end().primaryDirection() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight;
+ return true;
+}
+
+bool WebViewImpl::isSelectionAnchorFirst() const
+{
+ const Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+ FrameSelection* selection = frame->selection();
+ if (!selection)
+ return false;
+ return selection->selection().isBaseFirst();
+}
+
+bool WebViewImpl::setEditableSelectionOffsets(int start, int end)
+{
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return false;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return false;
+
+ return editor->setSelectionOffsets(start, end);
+}
+
+bool WebViewImpl::setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines)
+{
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return false;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return false;
+
+ InputMethodController& inputMethodController = focused->inputMethodController();
+ inputMethodController.cancelComposition();
+
+ if (compositionStart == compositionEnd)
+ return true;
+
+ inputMethodController.setCompositionFromExistingText(CompositionUnderlineVectorBuilder(underlines), compositionStart, compositionEnd);
+
+ return true;
+}
+
+void WebViewImpl::extendSelectionAndDelete(int before, int after)
+{
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return;
+
+ FrameSelection* selection = focused->selection();
+ if (!selection)
+ return;
+
+ size_t location;
+ size_t length;
+ RefPtr<Range> range = selection->selection().firstRange();
+ if (range && TextIterator::getLocationAndLengthFromRange(selection->rootEditableElement(), range.get(), location, length)) {
+ editor->setSelectionOffsets(max(static_cast<int>(location) - before, 0), location + length + after);
+ focused->document()->execCommand("delete", true);
+ }
+}
+
+bool WebViewImpl::isSelectionEditable() const
+{
+ const Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+ return frame->selection()->isContentEditable();
+}
+
+WebColor WebViewImpl::backgroundColor() const
+{
+ if (isTransparent())
+ return Color::transparent;
+ if (!m_page)
+ return m_baseBackgroundColor;
+ FrameView* view = m_page->mainFrame()->view();
+ StyleColor backgroundColor = view->documentBackgroundColor();
+ if (!backgroundColor.isValid())
+ return m_baseBackgroundColor;
+ return backgroundColor.rgb();
+}
+
+bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length)
+{
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return false;
+
+ FrameSelection* selection = focused->selection();
+ if (!selection)
+ return false;
+
+ RefPtr<Range> range = selection->selection().firstRange();
+ if (!range)
+ return false;
+
+ if (TextIterator::getLocationAndLengthFromRange(selection->rootEditableElementOrTreeScopeRootNode(), range.get(), *location, *length))
+ return true;
+ return false;
+}
+
+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
+{
+ return m_isAcceleratedCompositingActive;
+}
+
+void WebViewImpl::willCloseLayerTreeView()
+{
+ setIsAcceleratedCompositingActive(false);
+ m_layerTreeView = 0;
+}
+
+void WebViewImpl::didAcquirePointerLock()
+{
+ if (page())
+ page()->pointerLockController().didAcquirePointerLock();
+}
+
+void WebViewImpl::didNotAcquirePointerLock()
+{
+ if (page())
+ page()->pointerLockController().didNotAcquirePointerLock();
+}
+
+void WebViewImpl::didLosePointerLock()
+{
+ if (page())
+ page()->pointerLockController().didLosePointerLock();
+}
+
+void WebViewImpl::didChangeWindowResizerRect()
+{
+ if (mainFrameImpl()->frameView())
+ mainFrameImpl()->frameView()->windowResizerRectChanged();
+}
+
+// WebView --------------------------------------------------------------------
+
+WebSettingsImpl* WebViewImpl::settingsImpl()
+{
+ if (!m_webSettings)
+ m_webSettings = adoptPtr(new WebSettingsImpl(m_page->settings()));
+ ASSERT(m_webSettings);
+ return m_webSettings.get();
+}
+
+WebSettings* WebViewImpl::settings()
+{
+ return settingsImpl();
+}
+
+WebString WebViewImpl::pageEncoding() const
+{
+ if (!m_page)
+ return WebString();
+
+ // FIXME: Is this check needed?
+ if (!m_page->mainFrame()->document()->loader())
+ return WebString();
+
+ return m_page->mainFrame()->document()->encoding();
+}
+
+void WebViewImpl::setPageEncoding(const WebString& encodingName)
+{
+ if (!m_page)
+ 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()->reload(NormalReload, KURL(), 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)
+ return;
+ Frame* frame = page()->focusController().focusedOrMainFrame();
+ if (Document* document = frame->document())
+ document->setFocusedElement(0);
+ page()->focusController().setInitialFocus(reverse ? FocusDirectionBackward : FocusDirectionForward);
+}
+
+void WebViewImpl::clearFocusedNode()
+{
+ RefPtr<Frame> frame = focusedWebCoreFrame();
+ if (!frame)
+ return;
+
+ RefPtr<Document> document = frame->document();
+ if (!document)
+ return;
+
+ RefPtr<Element> oldFocusedElement = document->focusedElement();
+
+ // Clear the focused node.
+ document->setFocusedElement(0);
+
+ if (!oldFocusedElement)
+ 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 (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormControl())
+ frame->selection()->clear();
+}
+
+void WebViewImpl::scrollFocusedNodeIntoView()
+{
+ if (Element* element = focusedElement())
+ element->scrollIntoViewIfNeeded(true);
+}
+
+void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
+{
+ Frame* frame = page()->mainFrame();
+ Element* element = focusedElement();
+ if (!frame || !frame->view() || !element)
+ return;
+
+ if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) {
+ frame->view()->scrollElementToRect(element, IntRect(rect.x, rect.y, rect.width, rect.height));
+ return;
+ }
+
+ float scale;
+ IntPoint scroll;
+ bool needAnimation;
+ computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation);
+ if (needAnimation)
+ startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnimationDurationInSeconds);
+}
+
+void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float& newScale, IntPoint& newScroll, bool& needAnimation)
+{
+ focusedNode->document()->updateLayoutIgnorePendingStylesheets();
+
+ // 'caret' is rect encompassing the blinking cursor.
+ IntRect textboxRect = focusedNode->document()->view()->contentsToWindow(pixelSnappedIntRect(focusedNode->Node::boundingBox()));
+ WebRect caret, unusedEnd;
+ selectionBounds(caret, unusedEnd);
+ IntRect unscaledCaret = caret;
+ unscaledCaret.scale(1 / pageScaleFactor());
+ caret = unscaledCaret;
+
+ // Pick a scale which is reasonably readable. This is the scale at which
+ // the caret height will become minReadableCaretHeight (adjusted for dpi
+ // and font scale factor).
+ float targetScale = 1;
+ if (page() && page()->settings())
+ targetScale *= page()->settings()->textAutosizingFontScaleFactor();
+
+ newScale = clampPageScaleFactorToLimits(minReadableCaretHeight * targetScale / caret.height);
+ const float deltaScale = newScale / pageScaleFactor();
+
+ // Convert the rects to absolute space in the new scale.
+ IntRect textboxRectInDocumentCoordinates = textboxRect;
+ textboxRectInDocumentCoordinates.move(mainFrame()->scrollOffset());
+ IntRect caretInDocumentCoordinates = caret;
+ caretInDocumentCoordinates.move(mainFrame()->scrollOffset());
+
+ int viewWidth = m_size.width / newScale;
+ int viewHeight = m_size.height / newScale;
+
+ if (textboxRectInDocumentCoordinates.width() <= viewWidth) {
+ // Field is narrower than screen. Try to leave padding on left so field's
+ // label is visible, but it's more important to ensure entire field is
+ // onscreen.
+ int idealLeftPadding = viewWidth * leftBoxRatio;
+ int maxLeftPaddingKeepingBoxOnscreen = viewWidth - textboxRectInDocumentCoordinates.width();
+ newScroll.setX(textboxRectInDocumentCoordinates.x() - min<int>(idealLeftPadding, maxLeftPaddingKeepingBoxOnscreen));
+ } else {
+ // Field is wider than screen. Try to left-align field, unless caret would
+ // be offscreen, in which case right-align the caret.
+ newScroll.setX(max<int>(textboxRectInDocumentCoordinates.x(), caretInDocumentCoordinates.x() + caretInDocumentCoordinates.width() + caretPadding - viewWidth));
+ }
+ if (textboxRectInDocumentCoordinates.height() <= viewHeight) {
+ // Field is shorter than screen. Vertically center it.
+ newScroll.setY(textboxRectInDocumentCoordinates.y() - (viewHeight - textboxRectInDocumentCoordinates.height()) / 2);
+ } else {
+ // Field is taller than screen. Try to top align field, unless caret would
+ // be offscreen, in which case bottom-align the caret.
+ newScroll.setY(max<int>(textboxRectInDocumentCoordinates.y(), caretInDocumentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding - viewHeight));
+ }
+
+ needAnimation = false;
+ // If we are at less than the target zoom level, zoom in.
+ if (deltaScale > minScaleChangeToTriggerZoom)
+ needAnimation = true;
+ // If the caret is offscreen, then animate.
+ IntRect sizeRect(0, 0, viewWidth, viewHeight);
+ if (!sizeRect.contains(caret))
+ needAnimation = true;
+ // If the box is partially offscreen and it's possible to bring it fully
+ // onscreen, then animate.
+ if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectInDocumentCoordinates.height()) && !sizeRect.contains(textboxRect))
+ needAnimation = true;
+}
+
+void WebViewImpl::advanceFocus(bool reverse)
+{
+ page()->focusController().advanceFocus(reverse ? FocusDirectionBackward : FocusDirectionForward);
+}
+
+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 {
+ float zoomFactor = static_cast<float>(zoomLevelToZoomFactor(m_zoomLevel));
+ if (textOnly)
+ frame->setPageAndTextZoomFactors(1, zoomFactor * m_emulatedTextZoomFactor);
+ else
+ frame->setPageAndTextZoomFactors(zoomFactor, m_emulatedTextZoomFactor);
+ }
+ 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 = max(min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel);
+ m_client->zoomLevelChanged();
+}
+
+double WebView::zoomLevelToZoomFactor(double zoomLevel)
+{
+ return pow(textSizeMultiplierRatio, zoomLevel);
+}
+
+double WebView::zoomFactorToZoomLevel(double factor)
+{
+ // Since factor = 1.2^level, level = log(factor) / log(1.2)
+ return log(factor) / log(textSizeMultiplierRatio);
+}
+
+float WebViewImpl::pageScaleFactor() const
+{
+ if (!page())
+ return 1;
+
+ return page()->pageScaleFactor();
+}
+
+float WebViewImpl::clampPageScaleFactorToLimits(float scaleFactor) const
+{
+ return m_pageScaleConstraintsSet.finalConstraints().clampToConstraints(scaleFactor);
+}
+
+IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale)
+{
+ FrameView* view = mainFrameImpl()->frameView();
+ if (!view)
+ return offset;
+
+ IntPoint maxScrollExtent(contentsSize().width() - view->scrollOrigin().x(), contentsSize().height() - view->scrollOrigin().y());
+ FloatSize scaledSize = view->unscaledVisibleContentSize();
+ scaledSize.scale(1 / scale);
+
+ IntPoint clampedOffset = offset;
+ clampedOffset = clampedOffset.shrunkTo(maxScrollExtent - expandedIntSize(scaledSize));
+ clampedOffset = clampedOffset.expandedTo(-view->scrollOrigin());
+
+ return clampedOffset;
+}
+
+void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin)
+{
+ if (!page())
+ return;
+
+ IntPoint newScrollOffset = origin;
+ scaleFactor = clampPageScaleFactorToLimits(scaleFactor);
+ newScrollOffset = clampOffsetAtScale(newScrollOffset, scaleFactor);
+
+ page()->setPageScaleFactor(scaleFactor, newScrollOffset);
+}
+
+void WebViewImpl::setPageScaleFactorPreservingScrollOffset(float scaleFactor)
+{
+ if (clampPageScaleFactorToLimits(scaleFactor) == pageScaleFactor())
+ return;
+
+ IntPoint scrollOffset(mainFrame()->scrollOffset().width, mainFrame()->scrollOffset().height);
+ setPageScaleFactor(scaleFactor, scrollOffset);
+}
+
+float WebViewImpl::deviceScaleFactor() const
+{
+ if (!page())
+ return 1;
+
+ return page()->deviceScaleFactor();
+}
+
+void WebViewImpl::setDeviceScaleFactor(float scaleFactor)
+{
+ if (!page())
+ return;
+
+ page()->setDeviceScaleFactor(scaleFactor);
+
+ if (m_layerTreeView)
+ m_layerTreeView->setDeviceScaleFactor(scaleFactor);
+}
+
+bool WebViewImpl::isFixedLayoutModeEnabled() const
+{
+ if (!page())
+ return false;
+
+ Frame* frame = page()->mainFrame();
+ if (!frame || !frame->view())
+ return false;
+
+ return frame->view()->useFixedLayout();
+}
+
+void WebViewImpl::enableFixedLayoutMode(bool enable)
+{
+ if (!page())
+ return;
+
+ Frame* frame = page()->mainFrame();
+ if (!frame || !frame->view())
+ return;
+
+ frame->view()->setUseFixedLayout(enable);
+
+ if (m_isAcceleratedCompositingActive)
+ updateLayerTreeViewport();
+}
+
+
+void WebViewImpl::enableAutoResizeMode(const WebSize& minSize, const WebSize& maxSize)
+{
+ m_shouldAutoResize = true;
+ m_minAutoSize = minSize;
+ m_maxAutoSize = maxSize;
+ configureAutoResizeMode();
+}
+
+void WebViewImpl::disableAutoResizeMode()
+{
+ m_shouldAutoResize = false;
+ configureAutoResizeMode();
+}
+
+void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConstraints)
+{
+ if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints())
+ return;
+
+ m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints);
+
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ mainFrameImpl()->frameView()->setNeedsLayout();
+}
+
+void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverride)
+{
+ PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstraints();
+ constraints.initialScale = initialPageScaleFactorOverride;
+
+ if (constraints == m_pageScaleConstraintsSet.userAgentConstraints())
+ return;
+
+ m_pageScaleConstraintsSet.setNeedsReset(true);
+ setUserAgentPageScaleConstraints(constraints);
+}
+
+void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale)
+{
+ PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstraints();
+ constraints.minimumScale = minPageScale;
+ constraints.maximumScale = maxPageScale;
+ setUserAgentPageScaleConstraints(constraints);
+}
+
+void WebViewImpl::setIgnoreViewportTagScaleLimits(bool ignore)
+{
+ PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstraints();
+ if (ignore) {
+ constraints.minimumScale = m_pageScaleConstraintsSet.defaultConstraints().minimumScale;
+ constraints.maximumScale = m_pageScaleConstraintsSet.defaultConstraints().maximumScale;
+ } else {
+ constraints.minimumScale = -1;
+ constraints.maximumScale = -1;
+ }
+ setUserAgentPageScaleConstraints(constraints);
+}
+
+void WebViewImpl::refreshPageScaleFactorAfterLayout()
+{
+ if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()->view())
+ return;
+ FrameView* view = page()->mainFrame()->view();
+
+ updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()->viewportArguments());
+ m_pageScaleConstraintsSet.computeFinalConstraints();
+
+ if (settings()->viewportEnabled()) {
+ int verticalScrollbarWidth = 0;
+ if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScrollbar())
+ verticalScrollbarWidth = view->verticalScrollbar()->width();
+ m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(m_size, contentsSize(), verticalScrollbarWidth);
+ }
+
+ float newPageScaleFactor = pageScaleFactor();
+ if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.finalConstraints().initialScale != -1) {
+ newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initialScale;
+ m_pageScaleConstraintsSet.setNeedsReset(false);
+ }
+ setPageScaleFactorPreservingScrollOffset(newPageScaleFactor);
+
+ updateLayerTreeViewport();
+
+ // Relayout immediately to avoid violating the rule that needsLayout()
+ // isn't set at the end of a layout.
+ if (view->needsLayout())
+ view->layout();
+}
+
+void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments& arguments)
+{
+ if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height)
+ return;
+
+ m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, page()->settings()->layoutFallbackWidth());
+
+ if (settingsImpl()->supportDeprecatedTargetDensityDPI())
+ m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView(arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor(), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMode());
+
+ WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedConstraints().layoutSize);
+
+ if (page()->settings() && page()->settings()->textAutosizingEnabled() && page()->mainFrame()
+ && layoutSize.width != fixedLayoutSize().width)
+ page()->mainFrame()->document()->textAutosizer()->recalculateMultipliers();
+
+ setFixedLayoutSize(layoutSize);
+}
+
+IntSize WebViewImpl::contentsSize() const
+{
+ RenderView* root = page()->mainFrame()->contentRenderer();
+ if (!root)
+ return IntSize();
+ return root->documentRect().size();
+}
+
+WebSize WebViewImpl::contentsPreferredMinimumSize()
+{
+ Document* document = m_page->mainFrame()->document();
+ if (!document || !document->renderView() || !document->documentElement())
+ return WebSize();
+
+ layout();
+ FontCachePurgePreventer fontCachePurgePreventer; // Required by minPreferredLogicalWidth().
+ IntSize preferredMinimumSize(document->renderView()->minPreferredLogicalWidth(), document->documentElement()->scrollHeight());
+ preferredMinimumSize.scale(zoomLevelToZoomFactor(zoomLevel()));
+ return preferredMinimumSize;
+}
+
+float WebViewImpl::minimumPageScaleFactor() const
+{
+ return m_pageScaleConstraintsSet.finalConstraints().minimumScale;
+}
+
+float WebViewImpl::maximumPageScaleFactor() const
+{
+ return m_pageScaleConstraintsSet.finalConstraints().maximumScale;
+}
+
+void WebViewImpl::saveScrollAndScaleState()
+{
+ m_savedPageScaleFactor = pageScaleFactor();
+ m_savedScrollOffset = mainFrame()->scrollOffset();
+}
+
+void WebViewImpl::restoreScrollAndScaleState()
+{
+ if (!m_savedPageScaleFactor)
+ return;
+
+ startPageScaleAnimation(IntPoint(m_savedScrollOffset), false, m_savedPageScaleFactor, scrollAndScaleAnimationDurationInSeconds);
+ resetSavedScrollAndScaleState();
+}
+
+void WebViewImpl::resetSavedScrollAndScaleState()
+{
+ m_savedPageScaleFactor = 0;
+ m_savedScrollOffset = IntSize();
+}
+
+void WebViewImpl::resetScrollAndScaleState()
+{
+ page()->setPageScaleFactor(1, IntPoint());
+
+ // Clear out the values for the current history item. This will prevent the history item from clobbering the
+ // value determined during page scale initialization, which may be less than 1.
+ page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
+ page()->mainFrame()->loader()->history()->clearScrollPositionAndViewState();
+ m_pageScaleConstraintsSet.setNeedsReset(true);
+
+ // Clobber saved scales and scroll offsets.
+ if (FrameView* view = page()->mainFrame()->document()->view())
+ view->cacheCurrentScrollPosition();
+ resetSavedScrollAndScaleState();
+}
+
+WebSize WebViewImpl::fixedLayoutSize() const
+{
+ if (!page())
+ return WebSize();
+
+ Frame* frame = page()->mainFrame();
+ if (!frame || !frame->view())
+ return WebSize();
+
+ return frame->view()->fixedLayoutSize();
+}
+
+void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
+{
+ if (!page())
+ return;
+
+ Frame* frame = page()->mainFrame();
+ if (!frame || !frame->view())
+ return;
+
+ frame->view()->setFixedLayoutSize(layoutSize);
+}
+
+void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
+ const WebPoint& location)
+{
+ HitTestResult result = hitTestResultForWindowPos(location);
+ RefPtr<Node> node = result.innerNonSharedNode();
+ if (!isHTMLVideoElement(node.get()) && !node->hasTagName(HTMLNames::audioTag))
+ return;
+
+ RefPtr<HTMLMediaElement> mediaElement =
+ static_pointer_cast<HTMLMediaElement>(node);
+ switch (action.type) {
+ case WebMediaPlayerAction::Play:
+ if (action.enable)
+ mediaElement->play();
+ else
+ mediaElement->pause();
+ 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::performPluginAction(const WebPluginAction& action,
+ const WebPoint& location)
+{
+ HitTestResult result = hitTestResultForWindowPos(location);
+ RefPtr<Node> node = result.innerNonSharedNode();
+ if (!node->hasTagName(HTMLNames::objectTag) && !node->hasTagName(HTMLNames::embedTag))
+ return;
+
+ RenderObject* object = node->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer()) {
+ WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget);
+ switch (action.type) {
+ case WebPluginAction::Rotate90Clockwise:
+ plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise);
+ break;
+ case WebPluginAction::Rotate90Counterclockwise:
+ plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclockwise);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+ }
+}
+
+WebHitTestResult WebViewImpl::hitTestResultAt(const WebPoint& point)
+{
+ IntPoint scaledPoint = point;
+ scaledPoint.scale(1 / pageScaleFactor(), 1 / pageScaleFactor());
+ return hitTestResultForWindowPos(scaledPoint);
+}
+
+void WebViewImpl::copyImageAt(const WebPoint& point)
+{
+ if (!m_page)
+ 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, PlatformEvent::MouseMoved, 0, false, false, false,
+ false, 0);
+ m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme,
+ static_cast<DragOperation>(operation));
+}
+
+void WebViewImpl::dragSourceMovedTo(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation)
+{
+}
+
+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,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed,
+ int keyModifiers)
+{
+ ASSERT(!m_currentDragData);
+
+ m_currentDragData = webDragData;
+ m_operationsAllowed = operationsAllowed;
+
+ return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter, keyModifiers);
+}
+
+WebDragOperation WebViewImpl::dragTargetDragOver(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed,
+ int keyModifiers)
+{
+ m_operationsAllowed = operationsAllowed;
+
+ return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver, keyModifiers);
+}
+
+void WebViewImpl::dragTargetDragLeave()
+{
+ ASSERT(m_currentDragData);
+
+ DragData dragData(
+ m_currentDragData.get(),
+ IntPoint(),
+ IntPoint(),
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_page->dragController().dragExited(&dragData);
+
+ // FIXME: why is the drag scroll timer not stopped here?
+
+ m_dragOperation = WebDragOperationNone;
+ m_currentDragData = 0;
+}
+
+void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ int keyModifiers)
+{
+ ASSERT(m_currentDragData);
+
+ // 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;
+ }
+
+ m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventKeyState(keyModifiers));
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_page->dragController().performDrag(&dragData);
+
+ m_dragOperation = WebDragOperationNone;
+ m_currentDragData = 0;
+}
+
+void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers)
+{
+ Vector<uint32_t> result;
+ for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ const Vector<DocumentMarker*>& documentMarkers = frame->document()->markers()->markers();
+ for (size_t i = 0; i < documentMarkers.size(); ++i)
+ result.append(documentMarkers[i]->hash());
+ }
+ markers->assign(result);
+}
+
+WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPoint, const WebPoint& screenPoint, DragAction dragAction, int keyModifiers)
+{
+ ASSERT(m_currentDragData);
+
+ m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventKeyState(keyModifiers));
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ DragSession dragSession;
+ if (dragAction == DragEnter)
+ dragSession = m_page->dragController().dragEntered(&dragData);
+ else
+ dragSession = m_page->dragController().dragUpdated(&dragData);
+
+ DragOperation dropEffect = dragSession.operation;
+
+ // Mask the drop effect operation against the drag source's allowed operations.
+ if (!(dropEffect & dragData.draggingSourceOperationMask()))
+ dropEffect = DragOperationNone;
+
+ m_dragOperation = static_cast<WebDragOperation>(dropEffect);
+
+ return m_dragOperation;
+}
+
+void WebViewImpl::sendResizeEventAndRepaint()
+{
+ // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent
+ // as part of layout. Layout is also responsible for sending invalidations
+ // to the embedder. This method and all callers may be wrong. -- eseidel.
+ if (mainFrameImpl()->frameView()) {
+ // Enqueues the resize event.
+ mainFrameImpl()->frame()->eventHandler()->sendResizeEvent();
+ }
+
+ if (m_client) {
+ if (isAcceleratedCompositingActive()) {
+ updateLayerTreeViewport();
+ } else {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ m_client->didInvalidateRect(damagedRect);
+ }
+ }
+ if (m_pageOverlays)
+ m_pageOverlays->update();
+}
+
+void WebViewImpl::configureAutoResizeMode()
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view())
+ return;
+
+ mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoResize, m_minAutoSize, m_maxAutoSize);
+}
+
+unsigned long WebViewImpl::createUniqueIdentifierForRequest()
+{
+ return createUniqueIdentifier();
+}
+
+void WebViewImpl::inspectElementAt(const WebPoint& point)
+{
+ if (!m_page)
+ return;
+
+ if (point.x == -1 || point.y == -1)
+ m_page->inspectorController()->inspect(0);
+ else {
+ HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitTestRequest::ReadOnly | HitTestRequest::AllowChildFrameContent | HitTestRequest::IgnorePointerEventsNone;
+ HitTestRequest request(hitType);
+
+ HitTestResult result(m_page->mainFrame()->view()->windowToContents(point));
+ m_page->mainFrame()->contentRenderer()->hitTest(request, result);
+ Node* node = result.innerNode();
+ if (!node && m_page->mainFrame()->document())
+ node = m_page->mainFrame()->document()->documentElement();
+ m_page->inspectorController()->inspect(node);
+ }
+}
+
+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>& itemIDs,
+ int separatorIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == itemIDs.size());
+
+ if (names.isEmpty()) {
+ hideAutofillPopup();
+ return;
+ }
+
+ RefPtr<Element> element = focusedElement();
+ // 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 (!element || element != PassRefPtr<Node>(node)) {
+ hideAutofillPopup();
+ return;
+ }
+
+ HTMLInputElement* inputElem = toHTMLInputElement(element.get());
+
+ // The first time the Autofill popup is shown we'll create the client and
+ // the popup.
+ if (!m_autofillPopupClient)
+ m_autofillPopupClient = adoptPtr(new AutofillPopupMenuClient);
+
+ m_autofillPopupClient->initialize(
+ inputElem, names, labels, icons, itemIDs, separatorIndex);
+
+ if (!m_autofillPopup) {
+ PopupContainerSettings popupSettings = autofillPopupSettings;
+ popupSettings.deviceSupportsTouch = settingsImpl()->deviceSupportsTouch();
+ m_autofillPopup = PopupContainer::create(m_autofillPopupClient.get(),
+ PopupContainer::Suggestion,
+ popupSettings);
+ }
+
+ if (m_autofillPopupShowing) {
+ refreshAutofillPopup();
+ } else {
+ m_autofillPopupShowing = true;
+ IntRect rect = element->pixelSnappedBoundingBox();
+ m_autofillPopup->showInRect(FloatQuad(rect), rect.size(), element->ownerDocument()->view(), 0);
+ }
+}
+
+void WebViewImpl::hidePopups()
+{
+ hideSelectPopup();
+ hideAutofillPopup();
+ if (m_pagePopup)
+ closePagePopup(m_pagePopup.get());
+}
+
+void WebViewImpl::performCustomContextMenuAction(unsigned action)
+{
+ if (!m_page)
+ return;
+ ContextMenu* menu = m_page->contextMenuController().contextMenu();
+ if (!menu)
+ return;
+ const ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + action));
+ if (item)
+ m_page->contextMenuController().contextMenuItemSelected(item);
+ m_page->contextMenuController().clearContextMenu();
+}
+
+void WebViewImpl::showContextMenu()
+{
+ if (!page())
+ return;
+
+ page()->contextMenuController().clearContextMenu();
+ m_contextMenuAllowed = true;
+ if (Frame* focusedFrame = page()->focusController().focusedOrMainFrame())
+ focusedFrame->eventHandler()->sendContextMenuEventForKey();
+ m_contextMenuAllowed = false;
+}
+
+// WebView --------------------------------------------------------------------
+
+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::setBaseBackgroundColor(WebColor color)
+{
+ if (m_baseBackgroundColor == color)
+ return;
+
+ m_baseBackgroundColor = color;
+
+ m_page->mainFrame()->view()->setBaseBackgroundColor(color);
+
+ if (m_layerTreeView)
+ m_layerTreeView->setBackgroundColor(backgroundColor());
+}
+
+void WebViewImpl::setIsActive(bool active)
+{
+ if (page())
+ page()->focusController().setActive(active);
+}
+
+bool WebViewImpl::isActive() const
+{
+ return page() ? page()->focusController().isActive() : false;
+}
+
+void WebViewImpl::setDomainRelaxationForbidden(bool forbidden, const WebString& scheme)
+{
+ SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, String(scheme));
+}
+
+void WebViewImpl::setWindowFeatures(const WebWindowFeatures& features)
+{
+ m_page->chrome().setWindowFeatures(features);
+}
+
+void WebViewImpl::setScrollbarColors(unsigned inactiveColor,
+ unsigned activeColor,
+ unsigned trackColor) {
+#if ENABLE(DEFAULT_RENDER_THEME)
+ PlatformThemeChromiumDefault::setScrollbarColors(inactiveColor, activeColor, trackColor);
+#endif
+}
+
+void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor,
+ unsigned activeForegroundColor,
+ unsigned inactiveBackgroundColor,
+ unsigned inactiveForegroundColor) {
+#if ENABLE(DEFAULT_RENDER_THEME)
+ RenderThemeChromiumDefault::setSelectionColors(activeBackgroundColor, activeForegroundColor, inactiveBackgroundColor, inactiveForegroundColor);
+ theme()->platformColorsDidChange();
+#endif
+}
+
+void WebView::addUserStyleSheet(const WebString& sourceCode,
+ const WebVector<WebString>& patternsIn,
+ WebView::UserContentInjectIn injectIn,
+ WebView::UserStyleInjectionTime injectionTime)
+{
+ Vector<String> patterns;
+ for (size_t i = 0; i < patternsIn.size(); ++i)
+ patterns.append(patternsIn[i]);
+
+ PageGroup* pageGroup = PageGroup::sharedGroup();
+
+ // 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->addUserStyleSheet(sourceCode, WebURL(), patterns, Vector<String>(),
+ static_cast<UserContentInjectedFrames>(injectIn),
+ UserStyleAuthorLevel,
+ static_cast<WebCore::UserStyleInjectionTime>(injectionTime));
+}
+
+void WebView::removeAllUserContent()
+{
+ PageGroup::sharedGroup()->removeAllUserContent();
+}
+
+void WebViewImpl::didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPage)
+{
+ if (isNewNavigation)
+ *isNewNavigation = m_observedNewNavigation;
+
+#ifndef NDEBUG
+ ASSERT(!m_observedNewNavigation
+ || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoader);
+ m_newNavigationLoader = 0;
+#endif
+ m_observedNewNavigation = false;
+ if (*isNewNavigation && !isNavigationWithinPage)
+ m_pageScaleConstraintsSet.setNeedsReset(true);
+
+ // Make sure link highlight from previous page is cleared.
+ m_linkHighlight.clear();
+ m_gestureAnimation.clear();
+ if (m_layerTreeView)
+ m_layerTreeView->didStopFlinging();
+ resetSavedScrollAndScaleState();
+}
+
+void WebViewImpl::layoutUpdated(WebFrameImpl* webframe)
+{
+ if (!m_client || webframe != mainFrameImpl())
+ return;
+
+ if (m_layerTreeViewCommitsDeferred) {
+ // If we finished a layout while in deferred commit mode,
+ // that means it's time to start producing frames again so un-defer.
+ if (m_layerTreeView)
+ m_layerTreeView->setDeferCommits(false);
+ m_layerTreeViewCommitsDeferred = false;
+ }
+
+ if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame()->view()) {
+ WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size();
+ if (frameSize != m_size) {
+ m_size = frameSize;
+ m_client->didAutoResize(m_size);
+ sendResizeEventAndRepaint();
+ }
+ }
+
+ if (m_pageScaleConstraintsSet.constraintsDirty())
+ refreshPageScaleFactorAfterLayout();
+
+ m_client->didUpdateLayout();
+}
+
+void WebViewImpl::didChangeContentsSize()
+{
+ m_pageScaleConstraintsSet.didChangeContentsSize(contentsSize(), pageScaleFactor());
+}
+
+void WebViewImpl::deviceOrPageScaleFactorChanged()
+{
+ if (pageScaleFactor() && pageScaleFactor() != 1)
+ enterForceCompositingMode(true);
+ m_pageScaleConstraintsSet.setNeedsReset(false);
+ updateLayerTreeViewport();
+}
+
+bool WebViewImpl::useExternalPopupMenus()
+{
+ return shouldUseExternalPopupMenus;
+}
+
+void WebViewImpl::setEmulatedTextZoomFactor(float textZoomFactor)
+{
+ m_emulatedTextZoomFactor = textZoomFactor;
+ Frame* frame = mainFrameImpl()->frame();
+ if (frame)
+ frame->setPageAndTextZoomFactors(frame->pageZoomFactor(), m_emulatedTextZoomFactor);
+}
+
+void WebViewImpl::startDragging(Frame* frame,
+ const WebDragData& dragData,
+ WebDragOperationsMask mask,
+ const WebImage& dragImage,
+ const WebPoint& dragImageOffset)
+{
+ if (!m_client)
+ return;
+ ASSERT(!m_doingDragAndDrop);
+ m_doingDragAndDrop = true;
+ m_client->startDragging(WebFrameImpl::fromFrame(frame), 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;
+}
+
+void WebViewImpl::addPageOverlay(WebPageOverlay* overlay, int zOrder)
+{
+ if (!m_pageOverlays)
+ m_pageOverlays = PageOverlayList::create(this);
+
+ m_pageOverlays->add(overlay, zOrder);
+}
+
+void WebViewImpl::removePageOverlay(WebPageOverlay* overlay)
+{
+ if (m_pageOverlays && m_pageOverlays->remove(overlay) && m_pageOverlays->empty())
+ m_pageOverlays = nullptr;
+}
+
+void WebViewImpl::setOverlayLayer(WebCore::GraphicsLayer* layer)
+{
+ if (m_rootGraphicsLayer) {
+ if (layer->parent() != m_rootGraphicsLayer)
+ m_rootGraphicsLayer->addChild(layer);
+ }
+}
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_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;
+ }
+
+ WebRect newWidgetRect = m_autofillPopup->refresh(focusedElement()->pixelSnappedBoundingBox());
+ // Let's resize the backing window if necessary.
+ WebPopupMenuImpl* popupMenu = static_cast<WebPopupMenuImpl*>(m_autofillPopup->client());
+ if (popupMenu && popupMenu->client()->windowRect() != newWidgetRect)
+ popupMenu->client()->setWindowRect(newWidgetRect);
+}
+
+Element* WebViewImpl::focusedElement()
+{
+ Frame* frame = m_page->focusController().focusedFrame();
+ if (!frame)
+ return 0;
+
+ Document* document = frame->document();
+ if (!document)
+ return 0;
+
+ return document->focusedElement();
+}
+
+HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos)
+{
+ IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos));
+ return m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
+}
+
+void WebViewImpl::setTabsToLinks(bool enable)
+{
+ m_tabsToLinks = enable;
+}
+
+bool WebViewImpl::tabsToLinks() const
+{
+ return m_tabsToLinks;
+}
+
+void WebViewImpl::suppressInvalidations(bool enable)
+{
+ if (m_client)
+ m_client->suppressCompositorScheduling(enable);
+}
+
+bool WebViewImpl::allowsAcceleratedCompositing()
+{
+ return !m_compositorCreationFailed;
+}
+
+void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
+{
+ suppressInvalidations(true);
+
+ if (page()->settings()->pinchVirtualViewportEnabled()) {
+ if (!m_pinchViewports)
+ m_pinchViewports = PinchViewports::create(this);
+
+ m_pinchViewports->setOverflowControlsHostLayer(layer);
+ m_pinchViewports->setViewportSize(mainFrameImpl()->frame()->view()->frameRect().size());
+ if (layer) {
+ m_rootGraphicsLayer = m_pinchViewports->rootGraphicsLayer();
+ m_rootLayer = m_pinchViewports->rootGraphicsLayer()->platformLayer();
+ m_pinchViewports->registerViewportLayersWithTreeView(m_layerTreeView);
+ } else {
+ m_rootGraphicsLayer = 0;
+ m_rootLayer = 0;
+ m_pinchViewports->clearViewportLayersForTreeView(m_layerTreeView);
+ }
+ } else {
+ m_rootGraphicsLayer = layer;
+ m_rootLayer = layer ? layer->platformLayer() : 0;
+ }
+
+ setIsAcceleratedCompositingActive(layer);
+
+ if (m_layerTreeView) {
+ if (m_rootLayer)
+ m_layerTreeView->setRootLayer(*m_rootLayer);
+ else
+ m_layerTreeView->clearRootLayer();
+ }
+
+ suppressInvalidations(false);
+}
+
+void WebViewImpl::scheduleCompositingLayerSync()
+{
+ m_layerTreeView->setNeedsRedraw();
+}
+
+void WebViewImpl::scrollRootLayerRect(const IntSize&, const IntRect&)
+{
+ updateLayerTreeViewport();
+}
+
+void WebViewImpl::invalidateRect(const IntRect& rect)
+{
+ if (m_isAcceleratedCompositingActive) {
+ ASSERT(m_layerTreeView);
+ updateLayerTreeViewport();
+ } else if (m_client)
+ m_client->didInvalidateRect(rect);
+}
+
+WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const
+{
+ return m_graphicsLayerFactory.get();
+}
+
+WebCore::RenderLayerCompositor* WebViewImpl::compositor() const
+{
+ if (!page()
+ || !page()->mainFrame()
+ || !page()->mainFrame()->document()
+ || !page()->mainFrame()->document()->renderView())
+ return 0;
+ return page()->mainFrame()->document()->renderView()->compositor();
+}
+
+void WebViewImpl::registerForAnimations(WebLayer* layer)
+{
+ if (m_layerTreeView)
+ m_layerTreeView->registerForAnimations(layer);
+}
+
+WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer()
+{
+ return m_rootGraphicsLayer;
+}
+
+void WebViewImpl::scheduleAnimation()
+{
+ if (isAcceleratedCompositingActive() && Platform::current()->isThreadedCompositingEnabled()) {
+ ASSERT(m_layerTreeView);
+ m_layerTreeView->setNeedsAnimate();
+ return;
+ }
+ if (m_client)
+ m_client->scheduleAnimation();
+}
+
+void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
+{
+ WebKit::Platform::current()->histogramEnumeration("GPU.setIsAcceleratedCompositingActive", active * 2 + m_isAcceleratedCompositingActive, 4);
+
+ if (m_isAcceleratedCompositingActive == active)
+ return;
+
+ if (!active) {
+ m_isAcceleratedCompositingActive = false;
+ // We need to finish all GL rendering before sending didDeactivateCompositor() to prevent
+ // flickering when compositing turns off. This is only necessary if we're not in
+ // force-compositing-mode.
+ if (m_layerTreeView && !page()->settings()->forceCompositingMode())
+ m_layerTreeView->finishAllRendering();
+ m_client->didDeactivateCompositor();
+ if (!m_layerTreeViewCommitsDeferred
+ && WebKit::Platform::current()->isThreadedCompositingEnabled()) {
+ ASSERT(m_layerTreeView);
+ // In threaded compositing mode, force compositing mode is always on so setIsAcceleratedCompositingActive(false)
+ // means that we're transitioning to a new page. Suppress commits until WebKit generates invalidations so
+ // we don't attempt to paint too early in the next page load.
+ m_layerTreeView->setDeferCommits(true);
+ m_layerTreeViewCommitsDeferred = true;
+ }
+ } else if (m_layerTreeView) {
+ m_isAcceleratedCompositingActive = true;
+ updateLayerTreeViewport();
+ if (m_pageOverlays)
+ m_pageOverlays->update();
+
+ m_client->didActivateCompositor(0);
+ } else {
+ TRACE_EVENT0("webkit", "WebViewImpl::setIsAcceleratedCompositingActive(true)");
+
+ m_client->initializeLayerTreeView();
+ m_layerTreeView = m_client->layerTreeView();
+ if (m_layerTreeView) {
+ m_layerTreeView->setRootLayer(*m_rootLayer);
+
+ bool visible = page()->visibilityState() == PageVisibilityStateVisible;
+ m_layerTreeView->setVisible(visible);
+ m_layerTreeView->setDeviceScaleFactor(page()->deviceScaleFactor());
+ m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor());
+ m_layerTreeView->setBackgroundColor(backgroundColor());
+ m_layerTreeView->setHasTransparentBackground(isTransparent());
+ updateLayerTreeViewport();
+ m_client->didActivateCompositor(0);
+ m_isAcceleratedCompositingActive = true;
+ m_compositorCreationFailed = false;
+ if (m_pageOverlays)
+ m_pageOverlays->update();
+ m_layerTreeView->setShowFPSCounter(m_showFPSCounter);
+ m_layerTreeView->setShowPaintRects(m_showPaintRects);
+ m_layerTreeView->setShowDebugBorders(m_showDebugBorders);
+ m_layerTreeView->setContinuousPaintingEnabled(m_continuousPaintingEnabled);
+ m_layerTreeView->setShowScrollBottleneckRects(m_showScrollBottleneckRects);
+ } else {
+ m_isAcceleratedCompositingActive = false;
+ m_client->didDeactivateCompositor();
+ m_compositorCreationFailed = true;
+ }
+ }
+ if (page())
+ page()->mainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositingActive);
+}
+
+void WebViewImpl::updateMainFrameScrollPosition(const IntPoint& scrollPosition, bool programmaticScroll)
+{
+ FrameView* frameView = page()->mainFrame()->view();
+ if (!frameView)
+ return;
+
+ if (frameView->scrollPosition() == scrollPosition)
+ return;
+
+ bool oldProgrammaticScroll = frameView->inProgrammaticScroll();
+ frameView->setInProgrammaticScroll(programmaticScroll);
+ frameView->notifyScrollPositionChanged(scrollPosition);
+ frameView->setInProgrammaticScroll(oldProgrammaticScroll);
+}
+
+void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScaleDelta)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ if (pageScaleDelta == 1) {
+ TRACE_EVENT_INSTANT2("webkit", "WebViewImpl::applyScrollAndScale::scrollBy", "x", scrollDelta.width, "y", scrollDelta.height);
+ WebSize webScrollOffset = mainFrame()->scrollOffset();
+ IntPoint scrollOffset(webScrollOffset.width + scrollDelta.width, webScrollOffset.height + scrollDelta.height);
+ updateMainFrameScrollPosition(scrollOffset, false);
+ } else {
+ // The page scale changed, so apply a scale and scroll in a single
+ // operation.
+ WebSize scrollOffset = mainFrame()->scrollOffset();
+ scrollOffset.width += scrollDelta.width;
+ scrollOffset.height += scrollDelta.height;
+
+ WebPoint scrollPoint(scrollOffset.width, scrollOffset.height);
+ setPageScaleFactor(pageScaleFactor() * pageScaleDelta, scrollPoint);
+ m_doubleTapZoomPending = false;
+ }
+}
+
+void WebViewImpl::didExitCompositingMode()
+{
+ ASSERT(m_isAcceleratedCompositingActive);
+ setIsAcceleratedCompositingActive(false);
+ m_compositorCreationFailed = true;
+ m_client->didInvalidateRect(IntRect(0, 0, m_size.width, m_size.height));
+
+ // Force a style recalc to remove all the composited layers.
+ m_page->mainFrame()->document()->setNeedsStyleRecalc();
+
+ if (m_pageOverlays)
+ m_pageOverlays->update();
+}
+
+void WebViewImpl::updateLayerTreeViewport()
+{
+ if (!page() || !m_layerTreeView)
+ return;
+
+ m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor());
+}
+
+void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex)
+{
+ if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestionsCount())
+ m_autofillPopupClient->valueChanged(listIndex);
+}
+
+bool WebViewImpl::detectContentOnTouch(const WebPoint& position)
+{
+ HitTestResult touchHit = hitTestResultForWindowPos(position);
+
+ if (touchHit.isContentEditable())
+ return false;
+
+ Node* node = touchHit.innerNode();
+ if (!node || !node->isTextNode())
+ return false;
+
+ // Ignore when tapping on links or nodes listening to click events, unless the click event is on the
+ // body element, in which case it's unlikely that the original node itself was intended to be clickable.
+ for (; node && !node->hasTagName(HTMLNames::bodyTag); node = node->parentNode()) {
+ if (node->isLink() || node->willRespondToTouchEvents() || node->willRespondToMouseClickEvents())
+ return false;
+ }
+
+ WebContentDetectionResult content = m_client->detectContentAround(touchHit);
+ if (!content.isValid())
+ return false;
+
+ m_client->scheduleContentIntent(content.intent());
+ return true;
+}
+
+void WebViewImpl::didProgrammaticallyScroll(const WebCore::IntPoint& scrollPoint)
+{
+ m_client->didProgrammaticallyScroll(scrollPoint);
+}
+
+void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState,
+ bool isInitialState) {
+ if (!page())
+ return;
+
+ ASSERT(visibilityState == WebPageVisibilityStateVisible
+ || visibilityState == WebPageVisibilityStateHidden
+ || visibilityState == WebPageVisibilityStatePrerender
+ || visibilityState == WebPageVisibilityStatePreview);
+ m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int>(visibilityState)), isInitialState);
+
+ if (m_layerTreeView) {
+ bool visible = visibilityState == WebPageVisibilityStateVisible;
+ m_layerTreeView->setVisible(visible);
+ }
+}
+
+bool WebViewImpl::requestPointerLock()
+{
+ return m_client && m_client->requestPointerLock();
+}
+
+void WebViewImpl::requestPointerUnlock()
+{
+ if (m_client)
+ m_client->requestPointerUnlock();
+}
+
+bool WebViewImpl::isPointerLocked()
+{
+ return m_client && m_client->isPointerLocked();
+}
+
+void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event)
+{
+ AtomicString eventType;
+ switch (event.type) {
+ case WebInputEvent::MouseDown:
+ eventType = eventNames().mousedownEvent;
+ break;
+ case WebInputEvent::MouseUp:
+ eventType = eventNames().mouseupEvent;
+ break;
+ case WebInputEvent::MouseMove:
+ eventType = eventNames().mousemoveEvent;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event);
+
+ if (page())
+ page()->pointerLockController().dispatchLockedMouseEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent),
+ eventType);
+}
+
+bool WebViewImpl::shouldDisableDesktopWorkarounds()
+{
+ ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewportArguments();
+ return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.userZoom
+ || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != ViewportArguments::ValueAuto);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebViewImpl.h b/chromium/third_party/WebKit/Source/web/WebViewImpl.h
new file mode 100644
index 00000000000..03795c80ce2
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebViewImpl.h
@@ -0,0 +1,837 @@
+/*
+ * 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 "BackForwardClientImpl.h"
+#include "ChromeClientImpl.h"
+#include "ContextMenuClientImpl.h"
+#include "DragClientImpl.h"
+#include "EditorClientImpl.h"
+#include "InspectorClientImpl.h"
+#include "MIDIClientImpl.h"
+#include "NotificationPresenterImpl.h"
+#include "PageOverlayList.h"
+#include "PageWidgetDelegate.h"
+#include "UserMediaClientImpl.h"
+#include "WebInputEvent.h"
+#include "WebNavigationPolicy.h"
+#include "WebView.h"
+#include "WebViewBenchmarkSupportImpl.h"
+#include "core/page/PagePopupDriver.h"
+#include "core/page/PageScaleConstraintsSet.h"
+#include "core/platform/graphics/FloatSize.h"
+#include "core/platform/graphics/GraphicsContext3D.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+#include "core/platform/graphics/IntPoint.h"
+#include "core/platform/graphics/IntRect.h"
+#include "public/platform/WebFloatQuad.h"
+#include "public/platform/WebGestureCurveTarget.h"
+#include "public/platform/WebLayer.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebSize.h"
+#include "public/platform/WebString.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/RefCounted.h"
+
+namespace WebCore {
+class ChromiumDataObject;
+class Color;
+class DocumentLoader;
+class FloatSize;
+class Frame;
+class GraphicsContext3D;
+class GraphicsLayerFactory;
+class HistoryItem;
+class HitTestResult;
+class KeyboardEvent;
+class Page;
+class PageGroup;
+class PagePopup;
+class PagePopupClient;
+class PlatformKeyboardEvent;
+class PopupContainer;
+class PopupMenuClient;
+class Range;
+class RenderLayerCompositor;
+class RenderTheme;
+class Widget;
+}
+
+namespace WebKit {
+class AutocompletePopupMenuClient;
+class AutofillPopupMenuClient;
+class ContextFeaturesClientImpl;
+class ContextMenuClientImpl;
+class DeviceOrientationClientProxy;
+class GeolocationClientProxy;
+class LinkHighlight;
+class PinchViewports;
+class PrerendererClientImpl;
+class SpeechInputClientImpl;
+class SpeechRecognitionClientProxy;
+class UserMediaClientImpl;
+class ValidationMessageClientImpl;
+class WebAccessibilityObject;
+class WebActiveGestureAnimation;
+class WebCompositorImpl;
+class WebDevToolsAgentClient;
+class WebDevToolsAgentPrivate;
+class WebDocument;
+class WebFrameImpl;
+class WebGestureEvent;
+class WebHelperPluginImpl;
+class WebImage;
+class WebKeyboardEvent;
+class WebLayerTreeView;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebPagePopupImpl;
+class WebPrerendererClient;
+class WebSettingsImpl;
+class WebTouchEvent;
+class WebViewBenchmarkSupport;
+class FullscreenController;
+
+class WebViewImpl : public WebView
+ , public RefCounted<WebViewImpl>
+ , public WebGestureCurveTarget
+ , public WebCore::PagePopupDriver
+ , public PageWidgetEventHandler {
+public:
+
+ // WebWidget methods:
+ virtual void close();
+ virtual WebSize size();
+ virtual void willStartLiveResize();
+ virtual void resize(const WebSize&);
+ virtual void willEndLiveResize();
+ virtual void willEnterFullScreen();
+ virtual void didEnterFullScreen();
+ virtual void willExitFullScreen();
+ virtual void didExitFullScreen();
+ virtual void animate(double);
+ virtual void layout();
+ virtual void enterForceCompositingMode(bool enable) OVERRIDE;
+ virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable);
+ virtual bool isTrackingRepaints() const OVERRIDE;
+ virtual void themeChanged();
+ virtual void setNeedsRedraw();
+ virtual bool handleInputEvent(const WebInputEvent&);
+ virtual void setCursorVisibilityState(bool isVisible);
+ virtual bool hasTouchEventHandlersAt(const WebPoint&);
+ virtual void applyScrollAndScale(const WebSize&, float);
+ 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(ConfirmCompositionBehavior selectionBehavior);
+ virtual bool confirmComposition(const WebString& text);
+ virtual bool compositionRange(size_t* location, size_t* length);
+ virtual WebTextInputInfo textInputInfo();
+ virtual bool setEditableSelectionOffsets(int start, int end);
+ virtual bool setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines);
+ virtual void extendSelectionAndDelete(int before, int after);
+ virtual bool isSelectionEditable() const;
+ virtual WebColor backgroundColor() const;
+ virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const;
+ virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const;
+ virtual bool isSelectionAnchorFirst() const;
+ virtual bool caretOrSelectionRange(size_t* location, size_t* length);
+ virtual void setTextDirection(WebTextDirection direction);
+ virtual bool isAcceleratedCompositingActive() const;
+ virtual void willCloseLayerTreeView();
+ virtual void didAcquirePointerLock();
+ virtual void didNotAcquirePointerLock();
+ virtual void didLosePointerLock();
+ virtual void didChangeWindowResizerRect();
+ virtual void didExitCompositingMode();
+
+ // WebView methods:
+ virtual void initializeMainFrame(WebFrameClient*);
+ virtual void initializeHelperPluginFrame(WebFrameClient*);
+ virtual void setAutofillClient(WebAutofillClient*);
+ virtual void setDevToolsAgentClient(WebDevToolsAgentClient*);
+ virtual void setPermissionClient(WebPermissionClient*);
+ virtual void setPrerendererClient(WebPrerendererClient*) OVERRIDE;
+ virtual void setSpellCheckClient(WebSpellCheckClient*);
+ virtual void setValidationMessageClient(WebValidationMessageClient*) OVERRIDE;
+ virtual void setPasswordGeneratorClient(WebPasswordGeneratorClient*) OVERRIDE;
+ virtual WebSettings* settings();
+ virtual WebString pageEncoding() const;
+ virtual void setPageEncoding(const WebString& encoding);
+ virtual bool isTransparent() const;
+ virtual void setIsTransparent(bool value);
+ virtual void setBaseBackgroundColor(WebColor);
+ 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 void setWindowFeatures(const WebWindowFeatures&);
+ 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 void scrollFocusedNodeIntoRect(const WebRect&);
+ virtual void zoomToFindInPageRect(const WebRect&);
+ virtual void advanceFocus(bool reverse);
+ virtual double zoomLevel();
+ virtual double setZoomLevel(bool textOnly, double zoomLevel);
+ virtual void zoomLimitsChanged(double minimumZoomLevel,
+ double maximumZoomLevel);
+ virtual void setInitialPageScaleOverride(float);
+ virtual bool zoomToMultipleTargetsRect(const WebRect&);
+ virtual float pageScaleFactor() const;
+ virtual void setPageScaleFactorPreservingScrollOffset(float);
+ virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin);
+ virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale);
+ virtual float minimumPageScaleFactor() const;
+ virtual float maximumPageScaleFactor() const;
+ virtual void saveScrollAndScaleState();
+ virtual void restoreScrollAndScaleState();
+ virtual void resetScrollAndScaleState();
+ virtual void setIgnoreViewportTagScaleLimits(bool);
+ virtual WebSize contentsPreferredMinimumSize();
+
+ virtual float deviceScaleFactor() const;
+ virtual void setDeviceScaleFactor(float);
+ virtual bool isFixedLayoutModeEnabled() const;
+ virtual void enableFixedLayoutMode(bool enable);
+ virtual WebSize fixedLayoutSize() const;
+ virtual void setFixedLayoutSize(const WebSize&);
+ virtual void enableAutoResizeMode(
+ const WebSize& minSize,
+ const WebSize& maxSize);
+ virtual void disableAutoResizeMode();
+ virtual void performMediaPlayerAction(
+ const WebMediaPlayerAction& action,
+ const WebPoint& location);
+ virtual void performPluginAction(
+ const WebPluginAction&,
+ const WebPoint&);
+ virtual WebHitTestResult hitTestResultAt(const WebPoint&);
+ 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&,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed,
+ int keyModifiers);
+ virtual WebDragOperation dragTargetDragOver(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed,
+ int keyModifiers);
+ virtual void dragTargetDragLeave();
+ virtual void dragTargetDrop(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ int keyModifiers);
+ virtual void spellingMarkers(WebVector<uint32_t>* markers);
+ 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>& itemIDs,
+ int separatorIndex);
+ virtual void hidePopups();
+ virtual void selectAutofillSuggestionAtIndex(unsigned listIndex);
+ 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);
+ virtual void showContextMenu();
+ virtual void addPageOverlay(WebPageOverlay*, int /* zOrder */);
+ virtual void removePageOverlay(WebPageOverlay*);
+ virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&);
+ virtual WebViewBenchmarkSupport* benchmarkSupport();
+ virtual void setShowPaintRects(bool);
+ virtual void setShowDebugBorders(bool);
+ virtual void setShowFPSCounter(bool);
+ virtual void setContinuousPaintingEnabled(bool);
+ virtual void setShowScrollBottleneckRects(bool);
+
+ // WebViewImpl
+
+ void suppressInvalidations(bool enable);
+ void invalidateRect(const WebCore::IntRect&);
+
+ void setIgnoreInputEvents(bool newValue);
+ WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
+
+ WebCore::Color baseBackgroundColor() const { return m_baseBackgroundColor; }
+
+ PageOverlayList* pageOverlays() const { return m_pageOverlays.get(); }
+
+ void setOverlayLayer(WebCore::GraphicsLayer*);
+
+ const WebPoint& lastMouseDownPoint() const
+ {
+ return m_lastMouseDownPoint;
+ }
+
+ WebCore::Frame* focusedWebCoreFrame() const;
+
+ // Returns the currently focused Element or null if no element has focus.
+ WebCore::Element* focusedElement();
+
+ static WebViewImpl* fromPage(WebCore::Page*);
+
+ WebViewClient* client()
+ {
+ return m_client;
+ }
+
+ WebAutofillClient* autofillClient()
+ {
+ return m_autofillClient;
+ }
+
+ WebPermissionClient* permissionClient()
+ {
+ return m_permissionClient;
+ }
+
+ WebSpellCheckClient* spellCheckClient()
+ {
+ return m_spellCheckClient;
+ }
+
+ WebPasswordGeneratorClient* passwordGeneratorClient() const
+ {
+ return m_passwordGeneratorClient;
+ }
+
+ // 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 mouseContextMenu(const WebMouseEvent&);
+ void mouseDoubleClick(const WebMouseEvent&);
+
+ bool detectContentOnTouch(const WebPoint&);
+ bool startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
+
+ void numberOfWheelEventHandlersChanged(unsigned);
+ void hasTouchEventHandlers(bool);
+
+ // WebGestureCurveTarget implementation for fling.
+ virtual void scrollBy(const WebFloatSize&);
+
+ // 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. isNavigationWithinPage will be true if the navigation does
+ // not take the user away from the current page.
+ void didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPage);
+
+ // Indicates two things:
+ // 1) This view may have a new layout now.
+ // 2) Calling layout() is a no-op.
+ // After calling WebWidget::layout(), expect to get this notification
+ // unless the view did not need a layout.
+ void layoutUpdated(WebFrameImpl*);
+
+ void didChangeContentsSize();
+ void deviceOrPageScaleFactorChanged();
+
+ // 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;
+ }
+
+ bool shouldAutoResize() const
+ {
+ return m_shouldAutoResize;
+ }
+
+ WebCore::IntSize minAutoSize() const
+ {
+ return m_minAutoSize;
+ }
+
+ WebCore::IntSize maxAutoSize() const
+ {
+ return m_maxAutoSize;
+ }
+
+ // Sets the emulated text zoom factor
+ // (may not be 1 in the device metrics emulation mode).
+ void setEmulatedTextZoomFactor(float);
+
+ // Returns the emulated text zoom factor
+ // (which may not be 1 in the device metrics emulation mode).
+ float emulatedTextZoomFactor() const
+ {
+ return m_emulatedTextZoomFactor;
+ }
+
+ void updatePageDefinedPageScaleConstraints(const WebCore::ViewportArguments&);
+
+ // Start a system drag and drop operation.
+ void startDragging(
+ WebCore::Frame*,
+ const WebDragData& dragData,
+ WebDragOperationsMask mask,
+ const WebImage& dragImage,
+ const WebPoint& dragImageOffset);
+
+ void autofillPopupDidHide()
+ {
+ m_autofillPopupShowing = false;
+ }
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_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);
+ // PagePopupDriver functions.
+ virtual WebCore::PagePopup* openPagePopup(WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView) OVERRIDE;
+ virtual void closePagePopup(WebCore::PagePopup*) OVERRIDE;
+
+ void hideAutofillPopup();
+
+ // Creates a Helper Plugin of |pluginType| for |hostDocument|.
+ WebHelperPluginImpl* createHelperPlugin(const String& pluginType, const WebDocument& hostDocument);
+
+ // 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;
+ }
+
+ WebCore::GraphicsLayer* rootGraphicsLayer();
+ bool allowsAcceleratedCompositing();
+ void setRootGraphicsLayer(WebCore::GraphicsLayer*);
+ void scheduleCompositingLayerSync();
+ void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect);
+ WebCore::GraphicsLayerFactory* graphicsLayerFactory() const;
+ WebCore::RenderLayerCompositor* compositor() const;
+ void registerForAnimations(WebLayer*);
+ void scheduleAnimation();
+
+ void didProgrammaticallyScroll(const WebCore::IntPoint& scrollPoint);
+
+ virtual void setVisibilityState(WebPageVisibilityState, bool);
+
+ WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); }
+ bool hasOpenedPopup() const { return m_selectPopup || m_pagePopup; }
+
+ // 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);
+
+ void computeScaleAndScrollForBlockRect(const WebRect& blockRect, float padding, float& scale, WebPoint& scroll, bool& doubleTapShouldZoomOut);
+ WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent);
+ void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent);
+ void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float& scale, WebCore::IntPoint& scroll, bool& needAnimation);
+
+ void animateDoubleTapZoom(const WebCore::IntPoint&);
+
+ void enableFakePageScaleAnimationForTesting(bool);
+ bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; }
+ WebCore::IntPoint fakePageScaleAnimationTargetPositionForTesting() const { return m_fakePageScaleAnimationTargetPosition; }
+ float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageScaleAnimationPageScaleFactor; }
+ bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageScaleAnimationUseAnchor; }
+
+ void enterFullScreenForElement(WebCore::Element*);
+ void exitFullScreenForElement(WebCore::Element*);
+
+ // Exposed for the purpose of overriding device metrics.
+ void sendResizeEventAndRepaint();
+
+ // Exposed for testing purposes.
+ bool hasHorizontalScrollbar();
+ bool hasVerticalScrollbar();
+
+ // Pointer Lock calls allow a page to capture all mouse events and
+ // disable the system cursor.
+ virtual bool requestPointerLock();
+ virtual void requestPointerUnlock();
+ virtual bool isPointerLocked();
+
+ // Heuristic-based function for determining if we should disable workarounds
+ // for viewing websites that are not optimized for mobile devices.
+ bool shouldDisableDesktopWorkarounds();
+
+ // Exposed for tests.
+ LinkHighlight* linkHighlight() { return m_linkHighlight.get(); }
+
+ WebSettingsImpl* settingsImpl();
+
+ // Returns the bounding box of the block type node touched by the WebRect.
+ WebRect computeBlockBounds(const WebRect&, bool ignoreClipping);
+
+ WebCore::IntPoint clampOffsetAtScale(const WebCore::IntPoint& offset, float scale);
+
+private:
+ void refreshPageScaleFactorAfterLayout();
+ void setUserAgentPageScaleConstraints(WebCore::PageScaleConstraints newConstraints);
+ float clampPageScaleFactorToLimits(float) const;
+ WebCore::IntSize contentsSize() const;
+
+ void resetSavedScrollAndScaleState();
+
+ void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition, bool programmaticScroll);
+
+ friend class WebView; // So WebView::Create can call our constructor
+ friend class WTF::RefCounted<WebViewImpl>;
+ friend void setCurrentInputEventForTest(const WebInputEvent*);
+
+ enum DragAction {
+ DragEnter,
+ DragOver
+ };
+
+ WebViewImpl(WebViewClient*);
+ virtual ~WebViewImpl();
+
+ WebTextInputType textInputType();
+
+ WebString inputModeOfFocusedElement();
+
+ // Returns true if the event was actually processed.
+ bool keyEventDefault(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();
+
+ bool confirmComposition(const WebString& text, ConfirmCompositionBehavior);
+
+ // 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,
+ int keyModifiers);
+
+ void configureAutoResizeMode();
+
+ void setIsAcceleratedCompositingActive(bool);
+ void doComposite();
+ void doPixelReadbackToCanvas(WebCanvas*, const WebCore::IntRect&);
+ void reallocateRenderer();
+ void updateLayerTreeViewport();
+
+ // Helper function: Widens the width of |source| by the specified margins
+ // while keeping it smaller than page width.
+ WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin);
+
+ void pointerLockMouseEvent(const WebInputEvent&);
+
+ // PageWidgetEventHandler functions
+ virtual void handleMouseDown(WebCore::Frame&, const WebMouseEvent&) OVERRIDE;
+ virtual void handleMouseUp(WebCore::Frame&, const WebMouseEvent&) OVERRIDE;
+ virtual bool handleMouseWheel(WebCore::Frame&, const WebMouseWheelEvent&) OVERRIDE;
+ virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE;
+ virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE;
+ virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE;
+
+ WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
+ WebAutofillClient* m_autofillClient;
+ WebPermissionClient* m_permissionClient;
+ WebSpellCheckClient* m_spellCheckClient;
+ WebPasswordGeneratorClient* m_passwordGeneratorClient;
+
+ ChromeClientImpl m_chromeClientImpl;
+ ContextMenuClientImpl m_contextMenuClientImpl;
+ DragClientImpl m_dragClientImpl;
+ EditorClientImpl m_editorClientImpl;
+ InspectorClientImpl m_inspectorClientImpl;
+ BackForwardClientImpl m_backForwardClientImpl;
+
+ WebSize m_size;
+ // If true, automatically resize the render view around its content.
+ bool m_shouldAutoResize;
+ // The lower bound on the size when auto-resizing.
+ WebCore::IntSize m_minAutoSize;
+ // The upper bound on the size when auto-resizing.
+ WebCore::IntSize m_maxAutoSize;
+
+ 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;
+
+ WebCore::PageScaleConstraintsSet m_pageScaleConstraintsSet;
+
+ // Saved page scale state.
+ float m_savedPageScaleFactor; // 0 means that no page scale factor is saved.
+ WebCore::IntSize m_savedScrollOffset;
+
+ // The scale moved to by the latest double tap zoom, if any.
+ float m_doubleTapZoomPageScaleFactor;
+ // Have we sent a double-tap zoom and not yet heard back the scale?
+ bool m_doubleTapZoomPending;
+
+ // Used for testing purposes.
+ bool m_enableFakePageScaleAnimationForTesting;
+ WebCore::IntPoint m_fakePageScaleAnimationTargetPosition;
+ float m_fakePageScaleAnimationPageScaleFactor;
+ bool m_fakePageScaleAnimationUseAnchor;
+
+ 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;
+
+ // Represents whether or not this object should process incoming IME events.
+ bool m_imeAcceptEvents;
+
+ // 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;
+
+ // Context-based feature switches.
+ OwnPtr<ContextFeaturesClientImpl> m_featureSwitchClient;
+
+ // 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;
+
+ // The popup associated with an input element.
+ RefPtr<WebPagePopupImpl> m_pagePopup;
+
+ OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
+ OwnPtr<PageOverlayList> m_pageOverlays;
+
+ // 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;
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ // The provider of desktop notifications;
+ NotificationPresenterImpl m_notificationPresenter;
+#endif
+
+ // If set, the (plugin) node which has mouse capture.
+ RefPtr<WebCore::Node> m_mouseCaptureNode;
+
+ WebViewBenchmarkSupportImpl m_benchmarkSupport;
+
+ WebCore::IntRect m_rootLayerScrollDamage;
+ WebLayerTreeView* m_layerTreeView;
+ WebLayer* m_rootLayer;
+ WebCore::GraphicsLayer* m_rootGraphicsLayer;
+ OwnPtr<WebCore::GraphicsLayerFactory> m_graphicsLayerFactory;
+ bool m_isAcceleratedCompositingActive;
+ bool m_layerTreeViewCommitsDeferred;
+ bool m_compositorCreationFailed;
+ // If true, the graphics context is being restored.
+ bool m_recreatingGraphicsContext;
+ static const WebInputEvent* m_currentInputEvent;
+ OwnPtr<PinchViewports> m_pinchViewports;
+
+#if ENABLE(INPUT_SPEECH)
+ OwnPtr<SpeechInputClientImpl> m_speechInputClient;
+#endif
+ OwnPtr<SpeechRecognitionClientProxy> m_speechRecognitionClient;
+
+ OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
+ OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
+
+ float m_emulatedTextZoomFactor;
+
+ UserMediaClientImpl m_userMediaClientImpl;
+ MIDIClientImpl m_midiClientImpl;
+#if ENABLE(NAVIGATOR_CONTENT_UTILS)
+ OwnPtr<NavigatorContentUtilsClientImpl> m_navigatorContentUtilsClient;
+#endif
+ OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
+ WebPoint m_positionOnFlingStart;
+ WebPoint m_globalPositionOnFlingStart;
+ int m_flingModifier;
+ bool m_flingSourceDevice;
+ OwnPtr<LinkHighlight> m_linkHighlight;
+ OwnPtr<ValidationMessageClientImpl> m_validationMessage;
+ OwnPtr<FullscreenController> m_fullscreenController;
+
+ bool m_showFPSCounter;
+ bool m_showPaintRects;
+ bool m_showDebugBorders;
+ bool m_continuousPaintingEnabled;
+ bool m_showScrollBottleneckRects;
+ WebColor m_baseBackgroundColor;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebWorkerBase.cpp b/chromium/third_party/WebKit/Source/web/WebWorkerBase.cpp
new file mode 100644
index 00000000000..115b8383a0d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebWorkerBase.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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 "core/dom/CrossThreadTask.h"
+
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "wtf/MainThread.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static void invokeTaskMethod(void* param)
+{
+ ScriptExecutionContext::Task* task =
+ static_cast<ScriptExecutionContext::Task*>(param);
+ task->performTask(0);
+ delete task;
+}
+
+
+void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+ callOnMainThread(invokeTaskMethod, task.leakPtr());
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebWorkerBase.h b/chromium/third_party/WebKit/Source/web/WebWorkerBase.h
new file mode 100644
index 00000000000..918861ecb51
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebWorkerBase.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 WebWorkerBase_h
+#define WebWorkerBase_h
+
+#include "WebCommonWorkerClient.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerObjectProxy.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
+
+
+namespace WebKit {
+class WebView;
+
+// Base class for WebSharedWorkerImpl, WebWorkerClientImpl and (defunct) WebWorkerImpl
+// containing common interface for shared workers and dedicated in-proc workers implementation.
+//
+// FIXME: Rename this class into WebWorkerBase, merge existing WebWorkerBase and WebSharedWorker.
+class WebWorkerBase {
+public:
+ virtual WebCore::WorkerLoaderProxy* workerLoaderProxy() = 0;
+ virtual WebCommonWorkerClient* commonClient() = 0;
+ virtual WebView* view() const = 0;
+
+ // Executes the given task on the main thread.
+ static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.cpp b/chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.cpp
new file mode 100644
index 00000000000..a4d5ed566ba
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.cpp
@@ -0,0 +1,157 @@
+/*
+ * 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"
+
+#include "bindings/v8/WorkerScriptController.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/dom/Document.h"
+#include "core/dom/ErrorEvent.h"
+#include "core/dom/MessageEvent.h"
+#include "core/dom/MessagePort.h"
+#include "core/dom/MessagePortChannel.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/inspector/ScriptCallStack.h"
+#include "core/loader/FrameLoaderClient.h"
+#include "core/page/Frame.h"
+#include "core/page/Page.h"
+#include "core/page/PageGroup.h"
+#include "core/workers/DedicatedWorkerThread.h"
+#include "core/workers/Worker.h"
+#include "core/workers/WorkerClients.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerMessagingProxy.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/Threading.h"
+
+#include "FrameLoaderClientImpl.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebPermissionClient.h"
+#include "WebViewImpl.h"
+#include "WorkerFileSystemClient.h"
+#include "core/dom/default/chromium/PlatformMessagePortChannelChromium.h"
+#include "public/platform/WebFileSystemCallbacks.h"
+#include "public/platform/WebMessagePortChannel.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Chromium-specific decorator of WorkerMessagingProxy.
+
+// static
+WorkerGlobalScopeProxy* WebWorkerClientImpl::createWorkerGlobalScopeProxy(Worker* worker)
+{
+ if (worker->scriptExecutionContext()->isDocument()) {
+ Document* document = toDocument(worker->scriptExecutionContext());
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ OwnPtr<WorkerClients> workerClients = WorkerClients::create();
+ provideLocalFileSystemToWorker(workerClients.get(), WorkerFileSystemClient::create());
+ WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker, webFrame, workerClients.release());
+ return proxy;
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void WebWorkerClientImpl::terminateWorkerGlobalScope()
+{
+ m_webFrame = 0;
+ WebCore::WorkerMessagingProxy::terminateWorkerGlobalScope();
+}
+
+WebWorkerBase* WebWorkerClientImpl::toWebWorkerBase()
+{
+ return this;
+}
+
+WebView* WebWorkerClientImpl::view() const
+{
+ if (askedToTerminate())
+ return 0;
+ return m_webFrame->view();
+}
+
+bool WebWorkerClientImpl::allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
+{
+ if (askedToTerminate())
+ return false;
+ WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
+ if (!webView)
+ return false;
+ return !webView->permissionClient() || webView->permissionClient()->allowDatabase(m_webFrame, name, displayName, estimatedSize);
+}
+
+bool WebWorkerClientImpl::allowFileSystem()
+{
+ if (askedToTerminate())
+ return false;
+ WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
+ if (!webView)
+ return false;
+ return !webView->permissionClient() || webView->permissionClient()->allowFileSystem(m_webFrame);
+}
+
+void WebWorkerClientImpl::openFileSystem(WebFileSystemType type, long long size, bool create,
+ WebFileSystemCallbacks* callbacks)
+{
+ if (askedToTerminate()) {
+ callbacks->didFail(WebFileErrorAbort);
+ return;
+ }
+ m_webFrame->client()->openFileSystem(m_webFrame, type, size, create, callbacks);
+}
+
+bool WebWorkerClientImpl::allowIndexedDB(const WebString& name)
+{
+ if (askedToTerminate())
+ return false;
+ WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
+ if (!webView)
+ return false;
+ return !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(m_webFrame, name, WebSecurityOrigin());
+}
+
+WebWorkerClientImpl::WebWorkerClientImpl(Worker* worker, WebFrameImpl* webFrame, PassOwnPtr<WorkerClients> workerClients)
+ : WebCore::WorkerMessagingProxy(worker, workerClients)
+ , m_webFrame(webFrame)
+{
+}
+
+WebWorkerClientImpl::~WebWorkerClientImpl()
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.h b/chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.h
new file mode 100644
index 00000000000..93d154cd903
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebWorkerClientImpl.h
@@ -0,0 +1,98 @@
+/*
+ * 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
+
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/workers/WorkerGlobalScopeProxy.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerMessagingProxy.h"
+#include "core/workers/WorkerObjectProxy.h"
+
+#include "WebWorkerBase.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemType.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
+
+
+namespace WebKit {
+class WebWorker;
+class WebFrameImpl;
+
+// This class provides chromium implementation for WorkerGlobalScopeProxy, WorkerObjectProxy amd WorkerLoaderProxy
+// for in-proc dedicated workers. It also acts as a bridge for workers to chromium implementation of file systems,
+// databases and other related functionality.
+//
+// In essence, this class decorates WorkerMessagingProxy.
+//
+// It is imperative that this class inherit from WorkerMessagingProxy rather than delegate to an instance of
+// WorkerMessagingProxy, because that class tracks and reports its activity to outside callers, and manages
+// its own lifetime, via calls to workerObjectDestroyed, workerGlobalScopeDestroyed, workerGlobalScopeClosed, etc. It
+// is basically impossible to correctly manage the lifetime of this class separately from WorkerMessagingProxy.
+class WebWorkerClientImpl : public WebCore::WorkerMessagingProxy
+ , public WebWorkerBase
+ , public WebCommonWorkerClient {
+public:
+ // WebCore::WorkerGlobalScopeProxy Factory.
+ static WebCore::WorkerGlobalScopeProxy* createWorkerGlobalScopeProxy(WebCore::Worker*);
+
+ // WebCore::WorkerGlobalScopeProxy methods:
+ // These are called on the thread that created the worker. In the renderer
+ // process, this will be the main WebKit thread.
+ virtual void terminateWorkerGlobalScope() OVERRIDE;
+
+ // WebCore::WorkerLoaderProxy methods
+ virtual WebWorkerBase* toWebWorkerBase() OVERRIDE;
+
+ // WebWorkerBase methods:
+ virtual WebCore::WorkerLoaderProxy* workerLoaderProxy() OVERRIDE { return this; }
+ virtual WebCommonWorkerClient* commonClient() OVERRIDE { return this; }
+ virtual WebView* view() const OVERRIDE;
+
+ // WebCommonWorkerClient methods:
+ virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) OVERRIDE;
+ virtual bool allowFileSystem();
+ virtual void openFileSystem(WebFileSystemType, long long size, bool create,
+ WebFileSystemCallbacks*) OVERRIDE;
+ virtual bool allowIndexedDB(const WebString& name) OVERRIDE;
+
+private:
+ WebWorkerClientImpl(WebCore::Worker*, WebFrameImpl*, PassOwnPtr<WebCore::WorkerClients>);
+ virtual ~WebWorkerClientImpl();
+
+ WebFrameImpl* m_webFrame;
+};
+
+} // namespace WebKit;
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/WebWorkerInfo.cpp b/chromium/third_party/WebKit/Source/web/WebWorkerInfo.cpp
new file mode 100644
index 00000000000..896ea672105
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebWorkerInfo.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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 "WebWorkerInfo.h"
+
+#include "core/workers/WorkerThread.h"
+
+namespace WebKit {
+
+unsigned WebWorkerInfo::dedicatedWorkerCount()
+{
+ return WebCore::WorkerThread::workerThreadCount();
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/WebWorkerRunLoop.cpp b/chromium/third_party/WebKit/Source/web/WebWorkerRunLoop.cpp
new file mode 100644
index 00000000000..d68e60f3fee
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WebWorkerRunLoop.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "public/platform/WebWorkerRunLoop.h"
+
+#include "core/workers/WorkerRunLoop.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+namespace {
+
+class TaskForwarder : public ScriptExecutionContext::Task {
+public:
+ static PassOwnPtr<TaskForwarder> create(PassOwnPtr<WebWorkerRunLoop::Task> task)
+ {
+ return adoptPtr(new TaskForwarder(task));
+ }
+
+ virtual void performTask(ScriptExecutionContext*)
+ {
+ m_task->Run();
+ }
+
+private:
+ TaskForwarder(PassOwnPtr<WebWorkerRunLoop::Task> task)
+ : m_task(task)
+ {
+ }
+
+ OwnPtr<WebWorkerRunLoop::Task> m_task;
+};
+
+}
+
+WebWorkerRunLoop::WebWorkerRunLoop(WorkerRunLoop* workerRunLoop)
+ : m_workerRunLoop(workerRunLoop)
+{
+}
+
+bool WebWorkerRunLoop::postTask(Task* task)
+{
+ return m_workerRunLoop->postTask(TaskForwarder::create(adoptPtr(task)));
+}
+
+bool WebWorkerRunLoop::equals(const WebWorkerRunLoop& o) const
+{
+ return m_workerRunLoop == o.m_workerRunLoop;
+}
+
+bool WebWorkerRunLoop::lessThan(const WebWorkerRunLoop& o) const
+{
+ return m_workerRunLoop < o.m_workerRunLoop;
+}
+
+}
diff --git a/chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.cpp b/chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.cpp
new file mode 100644
index 00000000000..cfadb8ae1a6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2010, 2013 Google Inc. 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 "WorkerAllowMainThreadBridgeBase.h"
+
+#include "wtf/MainThread.h"
+
+namespace {
+
+// Observes the worker context and notifies the bridge. This is kept
+// separate from the bridge so that it's destroyed correctly by ~Observer.
+class WorkerGlobalScopeObserver : public WebCore::WorkerGlobalScope::Observer {
+public:
+ static PassOwnPtr<WorkerGlobalScopeObserver> create(WebCore::WorkerGlobalScope* context, PassRefPtr<WebKit::WorkerAllowMainThreadBridgeBase> bridge)
+ {
+ return adoptPtr(new WorkerGlobalScopeObserver(context, bridge));
+ }
+
+ // WorkerGlobalScope::Observer method.
+ virtual void notifyStop()
+ {
+ if (!m_bridge)
+ return;
+ m_bridge->cancel();
+ }
+
+private:
+ WorkerGlobalScopeObserver(WebCore::WorkerGlobalScope* context, PassRefPtr<WebKit::WorkerAllowMainThreadBridgeBase> bridge)
+ : WebCore::WorkerGlobalScope::Observer(context)
+ , m_bridge(bridge)
+ {
+ }
+
+ RefPtr<WebKit::WorkerAllowMainThreadBridgeBase> m_bridge;
+};
+
+}
+
+namespace WebKit {
+
+WorkerAllowMainThreadBridgeBase::WorkerAllowMainThreadBridgeBase(WebCore::WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase)
+ : m_webWorkerBase(webWorkerBase)
+ , m_workerGlobalScopeObserver(WorkerGlobalScopeObserver::create(workerGlobalScope, this).leakPtr())
+{
+}
+
+void WorkerAllowMainThreadBridgeBase::postTaskToMainThread(PassOwnPtr<AllowParams> params)
+{
+ WebWorkerBase::dispatchTaskToMainThread(
+ createCallbackTask(&WorkerAllowMainThreadBridgeBase::allowTask, params, this));
+}
+
+// static
+void WorkerAllowMainThreadBridgeBase::allowTask(WebCore::ScriptExecutionContext*, PassOwnPtr<AllowParams> params, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge)
+{
+ ASSERT(isMainThread());
+ if (!bridge)
+ return;
+ MutexLocker locker(bridge->m_mutex);
+ if (!bridge->m_webWorkerBase)
+ return;
+ WebCommonWorkerClient* commonClient = bridge->m_webWorkerBase->commonClient();
+ if (!commonClient)
+ return;
+ bool allow = bridge->allowOnMainThread(commonClient, params.get());
+ bridge->m_webWorkerBase->workerLoaderProxy()->postTaskForModeToWorkerGlobalScope(
+ createCallbackTask(&didComplete, bridge, allow), params->m_mode.isolatedCopy());
+}
+
+// static
+void WorkerAllowMainThreadBridgeBase::didComplete(WebCore::ScriptExecutionContext* context, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge, bool result)
+{
+ bridge->m_result = result;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.h b/chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.h
new file mode 100644
index 00000000000..3c9cd5a52c3
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WorkerAllowMainThreadBridgeBase.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010, 2013 Google Inc. 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 "WebWorkerBase.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/platform/CrossThreadCopier.h"
+#include "core/workers/WorkerGlobalScope.h"
+
+namespace WebKit {
+
+// Base class for worker thread bridges. This class adds an observer to
+// WorkerGlobalScope so that it doesn't try to use deleted pointers when
+// WorkerGlobalScope is destroyed.
+class WorkerAllowMainThreadBridgeBase : public ThreadSafeRefCounted<WorkerAllowMainThreadBridgeBase> {
+ WTF_MAKE_NONCOPYABLE(WorkerAllowMainThreadBridgeBase);
+public:
+ WorkerAllowMainThreadBridgeBase(WebCore::WorkerGlobalScope*, WebWorkerBase*);
+
+ virtual ~WorkerAllowMainThreadBridgeBase()
+ {
+ }
+
+ // This class is passed across threads, so subclasses if it should make sure
+ // any string fields are copied.
+ class AllowParams {
+ public:
+ AllowParams(const String& mode)
+ : m_mode(mode.isolatedCopy())
+ {
+ }
+
+ virtual ~AllowParams()
+ {
+ }
+
+ String m_mode;
+ };
+
+ // These methods are invoked on the worker context.
+ void cancel()
+ {
+ MutexLocker locker(m_mutex);
+ m_webWorkerBase = 0;
+ }
+
+ bool result()
+ {
+ return m_result;
+ }
+
+ virtual bool allowOnMainThread(WebCommonWorkerClient*, AllowParams*) = 0;
+
+protected:
+ void postTaskToMainThread(PassOwnPtr<AllowParams>);
+
+private:
+ static void allowTask(WebCore::ScriptExecutionContext*, PassOwnPtr<AllowParams>, PassRefPtr<WorkerAllowMainThreadBridgeBase>);
+ static void didComplete(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerAllowMainThreadBridgeBase>, bool);
+
+ Mutex m_mutex;
+ WebWorkerBase* m_webWorkerBase;
+ WebCore::WorkerGlobalScope::Observer* m_workerGlobalScopeObserver;
+ bool m_result;
+};
+
+} // namespace WebKit
+
diff --git a/chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.cpp b/chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.cpp
new file mode 100644
index 00000000000..3039116540b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.cpp
@@ -0,0 +1,494 @@
+/*
+ * Copyright (C) 2010, 2012 Google Inc. 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"
+
+#include "WebCommonWorkerClient.h"
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebWorkerBase.h"
+#include "bindings/v8/WorkerScriptController.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/platform/network/BlobData.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerLoaderProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "public/platform/WebFileInfo.h"
+#include "public/platform/WebFileSystemEntry.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "weborigin/KURL.h"
+#include "wtf/MainThread.h"
+#include "wtf/Threading.h"
+#include "wtf/UnusedParam.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;
+ newInfo.platformPath.assign(info.platformPath);
+ 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.isolatedCopy();
+ }
+ 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 WebURL& rootURL)
+ {
+ m_bridge->didOpenFileSystemOnMainThread(name, rootURL, 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 didCreateSnapshotFile(const WebFileInfo& info)
+ {
+ // It's important to create a BlobDataHandle that refers to the platform file path prior
+ // to return from this method so the underlying file will not be deleted.
+ OwnPtr<BlobData> blobData = BlobData::create();
+ blobData->appendFile(info.platformPath);
+ RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(blobData.release(), info.length);
+ m_bridge->didCreateSnapshotFileOnMainThread(info, m_mode, snapshotBlob);
+ delete this;
+ }
+
+ virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
+ {
+ m_bridge->didReadDirectoryOnMainThread(entries, hasMore, m_mode);
+ delete this;
+ }
+
+ virtual bool shouldBlockUntilCompletion() const
+ {
+ return false;
+ }
+
+private:
+ MainThreadFileSystemCallbacks(PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+ : m_bridge(bridge)
+ , m_mode(mode)
+ {
+ ASSERT(m_bridge);
+ }
+
+ RefPtr<WorkerFileSystemCallbacksBridge> m_bridge;
+ const String m_mode;
+};
+
+// Observes the worker context. By keeping this separate, it is easier to verify
+// that it only gets deleted on the worker context thread which is verified by ~Observer.
+class WorkerFileSystemContextObserver : public WebCore::WorkerGlobalScope::Observer {
+public:
+ static PassOwnPtr<WorkerFileSystemContextObserver> create(WorkerGlobalScope* context, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge)
+ {
+ return adoptPtr(new WorkerFileSystemContextObserver(context, bridge));
+ }
+
+ // WorkerGlobalScope::Observer method.
+ virtual void notifyStop()
+ {
+ m_bridge->stop();
+ }
+
+private:
+ WorkerFileSystemContextObserver(WorkerGlobalScope* context, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge)
+ : WebCore::WorkerGlobalScope::Observer(context)
+ , m_bridge(bridge)
+ {
+ }
+
+ RefPtr<WorkerFileSystemCallbacksBridge> m_bridge;
+};
+
+void WorkerFileSystemCallbacksBridge::stop()
+{
+ ASSERT(m_workerGlobalScope->isContextThread());
+ {
+ MutexLocker locker(m_loaderProxyMutex);
+ m_workerLoaderProxy = 0;
+ }
+
+ if (m_callbacksOnWorkerThread)
+ m_callbacksOnWorkerThread->didFail(WebFileErrorAbort);
+
+ cleanUpAfterCallback();
+}
+
+void WorkerFileSystemCallbacksBridge::cleanUpAfterCallback()
+{
+ ASSERT(m_workerGlobalScope->isContextThread());
+
+ m_callbacksOnWorkerThread = 0;
+ if (m_workerGlobalScopeObserver) {
+ WorkerFileSystemContextObserver* observer = m_workerGlobalScopeObserver;
+ m_workerGlobalScopeObserver = 0;
+ // The next line may delete this.
+ delete observer;
+ }
+}
+
+void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(WebCommonWorkerClient* commonClient, WebFileSystemType type, long long size, bool create, const String& mode)
+{
+ dispatchTaskToMainThread(
+ createCallbackTask(&openFileSystemOnMainThread,
+ AllowCrossThreadAccess(commonClient), type, size, create,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postMoveToMainThread(WebFileSystem* fileSystem, const KURL& sourcePath, const KURL& destinationPath, const String& mode)
+{
+ dispatchTaskToMainThread(
+ createCallbackTask(&moveOnMainThread,
+ AllowCrossThreadAccess(fileSystem), sourcePath, destinationPath,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCopyToMainThread(WebFileSystem* fileSystem, const KURL& sourcePath, const KURL& destinationPath, const String& mode)
+{
+ dispatchTaskToMainThread(
+ createCallbackTask(&copyOnMainThread,
+ AllowCrossThreadAccess(fileSystem), sourcePath, destinationPath,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postRemoveToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&removeOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&removeRecursivelyOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&readMetadataOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCreateFileToMainThread(WebFileSystem* fileSystem, const KURL& path, bool exclusive, const String& mode)
+{
+ dispatchTaskToMainThread(
+ createCallbackTask(&createFileOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path, exclusive,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCreateDirectoryToMainThread(WebFileSystem* fileSystem, const KURL& path, bool exclusive, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&createDirectoryOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path, exclusive,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postFileExistsToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&fileExistsOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postDirectoryExistsToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&directoryExistsOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&readDirectoryOnMainThread,
+ AllowCrossThreadAccess(fileSystem), path,
+ this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
+{
+ ASSERT(fileSystem);
+ dispatchTaskToMainThread(
+ createCallbackTask(&createSnapshotFileOnMainThread,
+ AllowCrossThreadAccess(fileSystem),
+ path, this, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystemType type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ if (!commonClient)
+ bridge->didFailOnMainThread(WebFileErrorAbort, mode);
+ else {
+ commonClient->openFileSystem(type, size, create, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+ }
+}
+
+void WorkerFileSystemCallbacksBridge::moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& sourcePath, const KURL& destinationPath, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->move(sourcePath, destinationPath, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& sourcePath, const KURL& destinationPath, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->copy(sourcePath, destinationPath, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->remove(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->removeRecursively(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->readMetadata(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, bool exclusive, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->createFile(path, exclusive, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, bool exclusive, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->createDirectory(path, exclusive, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->fileExists(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->directoryExists(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->readDirectory(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
+void WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
+{
+ fileSystem->createSnapshotFileAndReadMetadata(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 KURL& rootURL, const String& mode)
+{
+ mayPostTaskToWorker(createCallbackTask(&didOpenFileSystemOnWorkerThread,
+ this, name, rootURL), 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::didCreateSnapshotFileOnMainThread(const WebFileInfo& info, const String& mode, PassRefPtr<BlobDataHandle> snapshotBlob)
+{
+ mayPostTaskToWorker(createCallbackTask(&didCreateSnapshotFileOnWorkerThread, this, info, snapshotBlob), mode);
+}
+
+void WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>& entries, bool hasMore, const String& mode)
+{
+ mayPostTaskToWorker(
+ createCallbackTask(&didReadDirectoryOnWorkerThread,
+ this, entries, hasMore), mode);
+}
+
+WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacksImpl* callbacks)
+ : m_workerLoaderProxy(workerLoaderProxy)
+ , m_workerGlobalScope(scriptExecutionContext)
+ , m_workerGlobalScopeObserver(WorkerFileSystemContextObserver::create(toWorkerGlobalScope(m_workerGlobalScope), this).leakPtr())
+ , m_callbacksOnWorkerThread(callbacks)
+{
+ ASSERT(m_workerGlobalScope->isContextThread());
+}
+
+WorkerFileSystemCallbacksBridge::~WorkerFileSystemCallbacksBridge()
+{
+ ASSERT(!m_callbacksOnWorkerThread);
+}
+
+void WorkerFileSystemCallbacksBridge::didFailOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, WebFileError error)
+{
+ bridge->m_callbacksOnWorkerThread->didFail(error);
+}
+
+void WorkerFileSystemCallbacksBridge::didOpenFileSystemOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& name, const KURL& rootURL)
+{
+ bridge->m_callbacksOnWorkerThread->didOpenFileSystem(name, rootURL);
+}
+
+void WorkerFileSystemCallbacksBridge::didSucceedOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge)
+{
+ bridge->m_callbacksOnWorkerThread->didSucceed();
+}
+
+void WorkerFileSystemCallbacksBridge::didReadMetadataOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebFileInfo& info)
+{
+ bridge->m_callbacksOnWorkerThread->didReadMetadata(info);
+}
+
+void WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebFileInfo& info, PassRefPtr<BlobDataHandle> snapshotBlob)
+{
+ bridge->m_callbacksOnWorkerThread->didCreateSnapshotFile(info, snapshotBlob);
+}
+
+void WorkerFileSystemCallbacksBridge::didReadDirectoryOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebVector<WebFileSystemEntry>& entries, bool hasMore)
+{
+ bridge->m_callbacksOnWorkerThread->didReadDirectory(entries, hasMore);
+}
+
+
+void WorkerFileSystemCallbacksBridge::runTaskOnMainThread(WebCore::ScriptExecutionContext* scriptExecutionContext, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, PassOwnPtr<WebCore::ScriptExecutionContext::Task> taskToRun)
+{
+ ASSERT(isMainThread());
+ 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_workerGlobalScope->isContextThread());
+ taskToRun->performTask(scriptExecutionContext);
+
+ // taskToRun does the callback.
+ bridge->cleanUpAfterCallback();
+
+ // WorkerFileSystemCallbacksBridge may be deleted here when bridge goes out of scope.
+}
+
+void WorkerFileSystemCallbacksBridge::dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task> task)
+{
+ ASSERT(m_workerLoaderProxy);
+ ASSERT(m_workerGlobalScope->isContextThread());
+ WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&runTaskOnMainThread, RefPtr<WorkerFileSystemCallbacksBridge>(this).release(), task));
+}
+
+void WorkerFileSystemCallbacksBridge::mayPostTaskToWorker(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
+{
+ // Relies on its caller (MainThreadFileSystemCallbacks:did*) to keep WorkerFileSystemCallbacksBridge alive.
+ ASSERT(isMainThread());
+
+ MutexLocker locker(m_loaderProxyMutex);
+ if (m_workerLoaderProxy)
+ m_workerLoaderProxy->postTaskForModeToWorkerGlobalScope(createCallbackTask(&runTaskOnWorkerThread, this, task), mode);
+}
+
+} // namespace WebCore
diff --git a/chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.h b/chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.h
new file mode 100644
index 00000000000..9a06603e5c6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WorkerFileSystemCallbacksBridge.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2010, 2012 Google Inc. 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
+
+#include "core/dom/ScriptExecutionContext.h"
+#include "public/platform/WebFileError.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemType.h"
+#include "public/platform/WebVector.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
+#include "wtf/Threading.h"
+
+namespace WebCore {
+class BlobDataHandle;
+class WorkerLoaderProxy;
+}
+
+namespace WebKit {
+
+class AsyncFileSystem;
+class MainThreadFileSystemCallbacks;
+class WebCommonWorkerClient;
+class ThreadableCallbacksBridgeWrapper;
+class WebFileSystemCallbacksImpl;
+class WorkerFileSystemContextObserver;
+struct WebFileInfo;
+struct WebFileSystemEntry;
+
+// Used to post a openFileSystem request to the main thread and get called back for the request.
+//
+// Lifetime for this class is maintained by posted "tasks" which ref count it and by MainThreadFileSystemCallbacks.
+// Either a task finishing or the MainThreadFileSystemCallbacks being deleted may release the last ref on WorkerFileSystemCallbacksBridge.
+//
+// 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).
+class WorkerFileSystemCallbacksBridge : public ThreadSafeRefCounted<WorkerFileSystemCallbacksBridge> {
+public:
+ ~WorkerFileSystemCallbacksBridge();
+
+ void stop();
+
+ static PassRefPtr<WorkerFileSystemCallbacksBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerGlobalScope, WebFileSystemCallbacksImpl* callbacks)
+ {
+ return adoptRef(new WorkerFileSystemCallbacksBridge(workerLoaderProxy, workerGlobalScope, 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*, WebFileSystemType, long long size, bool create, const String& mode);
+ void postMoveToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, const String& mode);
+ void postCopyToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, const String& mode);
+ void postRemoveToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
+ void postRemoveRecursivelyToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
+ void postReadMetadataToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
+ void postCreateFileToMainThread(WebFileSystem*, const WebCore::KURL& path, bool exclusive, const String& mode);
+ void postCreateDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path, bool exclusive, const String& mode);
+ void postFileExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
+ void postDirectoryExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
+ void postReadDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
+ void postCreateSnapshotFileToMainThread(WebFileSystem*, const WebCore::KURL& 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 WebCore::KURL& rootURL, const String& mode);
+ void didSucceedOnMainThread(const String& mode);
+ void didReadMetadataOnMainThread(const WebFileInfo&, const String& mode);
+ void didCreateSnapshotFileOnMainThread(const WebFileInfo&, const String& mode, PassRefPtr<WebCore::BlobDataHandle> snapshotBlob);
+ void didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>&, bool hasMore, const String& mode);
+
+private:
+ WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy*, WebCore::ScriptExecutionContext*, WebFileSystemCallbacksImpl*);
+
+ // Methods that are to be called on the main thread.
+ static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystemType, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, bool exclusive, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, bool exclusive, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+ static void createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
+
+ friend class MainThreadFileSystemCallbacks;
+
+ // Methods that dispatch WebFileSystemCallbacks on the worker threads.
+ static void didFailOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, WebFileError);
+ static void didOpenFileSystemOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& name, const WebCore::KURL& rootPath);
+ static void didSucceedOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>);
+ static void didReadMetadataOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&);
+ static void didCreateSnapshotFileOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&, PassRefPtr<WebCore::BlobDataHandle> snapshotBlob);
+ static void didReadDirectoryOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebVector<WebFileSystemEntry>&, bool hasMore);
+
+ static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<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);
+
+ void cleanUpAfterCallback();
+
+ Mutex m_loaderProxyMutex;
+ WebCore::WorkerLoaderProxy* m_workerLoaderProxy;
+
+ WebCore::ScriptExecutionContext* m_workerGlobalScope;
+
+ // Must be deleted on the WorkerGlobalScope thread.
+ WorkerFileSystemContextObserver* m_workerGlobalScopeObserver;
+
+ // This is self-destructed and must be fired on the worker thread.
+ WebFileSystemCallbacksImpl* m_callbacksOnWorkerThread;
+};
+
+} // namespace WebCore
+
+#endif // WorkerFileSystemCallbacksBridge_h
diff --git a/chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.cpp b/chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.cpp
new file mode 100644
index 00000000000..4daa833e9cb
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 "WorkerFileSystemClient.h"
+
+#include "WebFileSystemCallbacksImpl.h"
+#include "WebWorkerBase.h"
+#include "WorkerAllowMainThreadBridgeBase.h"
+#include "WorkerFileSystemCallbacksBridge.h"
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/platform/AsyncFileSystemCallbacks.h"
+#include "core/workers/WorkerGlobalScope.h"
+#include "core/workers/WorkerThread.h"
+#include "public/platform/WebFileError.h"
+#include "public/platform/WebFileSystem.h"
+#include "public/platform/WebFileSystemType.h"
+#include "wtf/MainThread.h"
+#include "wtf/Threading.h"
+#include "wtf/text/WTFString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+namespace {
+
+// This class is used to route the result of the WebWorkerBase::allowFileSystem
+// call back to the worker context.
+class AllowFileSystemMainThreadBridge : public WorkerAllowMainThreadBridgeBase {
+public:
+ static PassRefPtr<AllowFileSystemMainThreadBridge> create(WebCore::WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode)
+ {
+ return adoptRef(new AllowFileSystemMainThreadBridge(workerGlobalScope, webWorkerBase, mode));
+ }
+
+private:
+ AllowFileSystemMainThreadBridge(WebCore::WorkerGlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase, const String& mode)
+ : WorkerAllowMainThreadBridgeBase(workerGlobalScope, webWorkerBase)
+ {
+ postTaskToMainThread(adoptPtr(new AllowParams(mode)));
+ }
+
+ virtual bool allowOnMainThread(WebCommonWorkerClient* commonClient, AllowParams*)
+ {
+ ASSERT(isMainThread());
+ return commonClient->allowFileSystem();
+ }
+};
+
+} // namespace
+
+PassOwnPtr<FileSystemClient> WorkerFileSystemClient::create()
+{
+ return adoptPtr(static_cast<FileSystemClient*>(new WorkerFileSystemClient()));
+}
+
+WorkerFileSystemClient::~WorkerFileSystemClient()
+{
+}
+
+bool WorkerFileSystemClient::allowFileSystem(ScriptExecutionContext* context)
+{
+ WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
+ WebCore::WorkerThread* workerThread = workerGlobalScope->thread();
+ WorkerRunLoop& runLoop = workerThread->runLoop();
+ WebCore::WorkerLoaderProxy* workerLoaderProxy = &workerThread->workerLoaderProxy();
+
+ String mode = "allowFileSystemMode";
+ mode.append(String::number(runLoop.createUniqueId()));
+
+ RefPtr<AllowFileSystemMainThreadBridge> bridge = AllowFileSystemMainThreadBridge::create(workerGlobalScope, workerLoaderProxy->toWebWorkerBase(), mode);
+
+ // Either the bridge returns, or the queue gets terminated.
+ // FIXME: This synchoronous execution should be replaced with better model.
+ if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated) {
+ bridge->cancel();
+ return false;
+ }
+
+ return bridge->result();
+}
+
+void WorkerFileSystemClient::openFileSystem(ScriptExecutionContext* context, WebCore::FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType synchronousType, long long size, OpenFileSystemMode openMode)
+{
+ WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
+ WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase());
+ WebCore::WorkerThread* workerThread = workerGlobalScope->thread();
+ WorkerRunLoop& runLoop = workerThread->runLoop();
+ WebCore::WorkerLoaderProxy* workerLoaderProxy = &workerThread->workerLoaderProxy();
+
+ String mode = "openFileSystemMode";
+ mode.append(String::number(runLoop.createUniqueId()));
+
+ RefPtr<WorkerFileSystemCallbacksBridge> bridge = WorkerFileSystemCallbacksBridge::create(workerLoaderProxy, workerGlobalScope, new WebFileSystemCallbacksImpl(callbacks));
+ bridge->postOpenFileSystemToMainThread(webWorker->commonClient(), static_cast<WebFileSystemType>(type), size, openMode == CreateFileSystemIfNotPresent, mode);
+
+ if (synchronousType == SynchronousFileSystem) {
+ // FIXME: This synchoronous execution should be replaced with better model.
+ if (runLoop.runInMode(workerGlobalScope, mode) == MessageQueueTerminated)
+ bridge->stop();
+ }
+}
+
+void WorkerFileSystemClient::deleteFileSystem(WebCore::ScriptExecutionContext*, WebCore::FileSystemType, PassOwnPtr<WebCore::AsyncFileSystemCallbacks>)
+{
+ ASSERT_NOT_REACHED();
+}
+
+WorkerFileSystemClient::WorkerFileSystemClient()
+{
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.h b/chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.h
new file mode 100644
index 00000000000..48cfebf3212
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/WorkerFileSystemClient.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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 WorkerFileSystemClient_h
+#define WorkerFileSystemClient_h
+
+#include "modules/filesystem/FileSystemClient.h"
+#include "wtf/Forward.h"
+
+namespace WebKit {
+
+class WorkerFileSystemClient : public WebCore::FileSystemClient {
+public:
+ static PassOwnPtr<FileSystemClient> create();
+ virtual ~WorkerFileSystemClient();
+
+ virtual bool allowFileSystem(WebCore::ScriptExecutionContext*) OVERRIDE;
+ virtual void openFileSystem(WebCore::ScriptExecutionContext*, WebCore::FileSystemType, PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::FileSystemSynchronousType, long long size, WebCore::OpenFileSystemMode) OVERRIDE;
+ virtual void deleteFileSystem(WebCore::ScriptExecutionContext*, WebCore::FileSystemType, PassOwnPtr<WebCore::AsyncFileSystemCallbacks>) OVERRIDE;
+
+private:
+ WorkerFileSystemClient();
+};
+
+} // namespace WebKit
+
+#endif // WorkerFileSystemClient_h
diff --git a/chromium/third_party/WebKit/Source/web/android/WebInputEventFactory.cpp b/chromium/third_party/WebKit/Source/web/android/WebInputEventFactory.cpp
new file mode 100644
index 00000000000..5b204cdbb5f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/android/WebInputEventFactory.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "core/platform/chromium/KeyCodeConversion.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+#include "wtf/Assertions.h"
+
+namespace WebKit {
+
+WebKeyboardEvent WebInputEventFactory::keyboardEvent(WebInputEvent::Type type,
+ int modifiers,
+ double timeStampSeconds,
+ int keycode,
+ WebUChar unicodeCharacter,
+ bool isSystemKey)
+{
+ WebKeyboardEvent result;
+
+ result.type = type;
+ result.modifiers = modifiers;
+ result.timeStampSeconds = timeStampSeconds;
+ int windowsKeyCode = WebCore::windowsKeyCodeForKeyEvent(keycode);
+ result.windowsKeyCode = WebKeyboardEvent::windowsKeyCodeWithoutLocation(windowsKeyCode);
+ result.modifiers |= WebKeyboardEvent::locationModifiersFromWindowsKeyCode(windowsKeyCode);
+ result.nativeKeyCode = keycode;
+ result.unmodifiedText[0] = unicodeCharacter;
+ if (result.windowsKeyCode == WebCore::VKEY_RETURN) {
+ // This is the same behavior as GTK:
+ // 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';
+ }
+ result.text[0] = result.unmodifiedText[0];
+ result.setKeyIdentifierFromWindowsKeyCode();
+ result.isSystemKey = isSystemKey;
+
+ return result;
+}
+
+WebMouseEvent WebInputEventFactory::mouseEvent(MouseEventType type,
+ WebMouseEvent::Button button,
+ double timeStampSeconds,
+ int windowX,
+ int windowY,
+ int modifiers,
+ int clickCount)
+{
+ WebMouseEvent result;
+
+ result.x = windowX;
+ result.y = windowY;
+ result.windowX = windowX;
+ result.windowY = windowY;
+ result.timeStampSeconds = timeStampSeconds;
+ result.clickCount = clickCount;
+ result.modifiers = modifiers;
+
+ switch (type) {
+ case MouseEventTypeDown:
+ result.type = WebInputEvent::MouseDown;
+ result.button = button;
+ break;
+ case MouseEventTypeUp:
+ result.type = WebInputEvent::MouseUp;
+ result.button = button;
+ break;
+ case MouseEventTypeMove:
+ result.type = WebInputEvent::MouseMove;
+ result.button = WebMouseEvent::ButtonNone;
+ break;
+ };
+
+ return result;
+}
+
+// WebMouseWheelEvent ------------------------------------------------------------
+
+WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(MouseWheelDirectionType direction,
+ double timeStampSeconds,
+ int windowX,
+ int windowY)
+{
+ WebMouseWheelEvent result;
+
+ result.type = WebInputEvent::MouseWheel;
+ result.x = windowX;
+ result.y = windowY;
+ result.windowX = windowX;
+ result.windowY = windowY;
+ result.timeStampSeconds = timeStampSeconds;
+ result.button = WebMouseEvent::ButtonNone;
+
+ // The below choices are matched from GTK.
+ static const float scrollbarPixelsPerTick = 160.0f / 3.0f;
+
+ switch (direction) {
+ case MouseWheelDirectionTypeUp:
+ result.deltaY = scrollbarPixelsPerTick;
+ result.wheelTicksY = 1;
+ break;
+ case MouseWheelDirectionTypeDown:
+ result.deltaY = -scrollbarPixelsPerTick;
+ result.wheelTicksY = -1;
+ break;
+ case MouseWheelDirectionTypeLeft:
+ result.deltaX = scrollbarPixelsPerTick;
+ result.wheelTicksX = 1;
+ break;
+ case MouseWheelDirectionTypeRight:
+ result.deltaX = -scrollbarPixelsPerTick;
+ result.wheelTicksX = -1;
+ break;
+ }
+
+ return result;
+}
+
+// WebGestureEvent ------------------------------------------------------------
+
+// FIXME: remove this obsolete version
+WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
+ double timeStampSeconds,
+ int x,
+ int y,
+ float,
+ float,
+ int modifiers) {
+ return gestureEvent(type, timeStampSeconds, x, y, modifiers);
+}
+
+WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
+ double timeStampSeconds,
+ int x,
+ int y,
+ int modifiers)
+{
+ WebGestureEvent result;
+
+ result.type = type;
+ result.x = x;
+ result.y = y;
+ result.timeStampSeconds = timeStampSeconds;
+ result.modifiers = modifiers;
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/default/WebRenderTheme.cpp b/chromium/third_party/WebKit/Source/web/default/WebRenderTheme.cpp
new file mode 100644
index 00000000000..57362b5bc1f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/default/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 "WebView.h"
+#include "core/rendering/RenderThemeChromiumDefault.h"
+
+using WebCore::RenderTheme;
+using WebCore::RenderThemeChromiumDefault;
+
+namespace WebKit {
+
+void setCaretBlinkInterval(double interval)
+{
+ RenderThemeChromiumDefault::setCaretBlinkInterval(interval);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/gtk/WebInputEventFactory.cpp b/chromium/third_party/WebKit/Source/web/gtk/WebInputEventFactory.cpp
new file mode 100644
index 00000000000..ea66d6309d0
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/gtk/WebInputEventFactory.cpp
@@ -0,0 +1,628 @@
+/*
+ * 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 "core/platform/chromium/KeyCodeConversion.h"
+#include "core/platform/chromium/KeyboardCodes.h"
+
+#include "WebInputEvent.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "wtf/Assertions.h"
+
+namespace {
+
+// For click count tracking.
+static int gNumClicks = 0;
+static GdkWindow* gLastClickEventWindow = 0;
+static gint gLastClickTime = 0;
+static gint gLastClickX = 0;
+static gint gLastClickY = 0;
+static WebKit::WebMouseEvent::Button gLastClickButton = WebKit::WebMouseEvent::ButtonNone;
+
+bool shouldForgetPreviousClick(GdkWindow* window, gint time, gint x, gint y)
+{
+ static GtkSettings* settings = gtk_settings_get_default();
+
+ if (window != gLastClickEventWindow)
+ return true;
+
+ gint doubleClickTime = 250;
+ gint doubleClickDistance = 5;
+ g_object_get(G_OBJECT(settings),
+ "gtk-double-click-time", &doubleClickTime,
+ "gtk-double-click-distance", &doubleClickDistance, NULL);
+ return (time - gLastClickTime) > doubleClickTime
+ || abs(x - gLastClickX) > doubleClickDistance
+ || abs(y - gLastClickY) > doubleClickDistance;
+}
+
+void resetClickCountState()
+{
+ gNumClicks = 0;
+ gLastClickEventWindow = 0;
+ gLastClickTime = 0;
+ gLastClickX = 0;
+ gLastClickY = 0;
+ gLastClickButton = WebKit::WebMouseEvent::ButtonNone;
+}
+
+bool isKeyPadKeyval(guint keyval)
+{
+ // Keypad keyvals all fall into one range.
+ return keyval >= GDK_KP_Space && keyval <= GDK_KP_9;
+}
+
+} // 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 (state & GDK_META_MASK)
+ modifiers |= WebInputEvent::MetaKey;
+ 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);
+}
+
+// Normalizes event->state to make it Windows/Mac compatible. Since the way
+// of setting modifier mask on X is very different than Windows/Mac as shown
+// in http://crbug.com/127142#c8, the normalization is necessary.
+static guint normalizeEventState(const GdkEventKey* event)
+{
+ guint mask = 0;
+ switch (gdkEventToWindowsKeyCode(event)) {
+ case WebCore::VKEY_CONTROL:
+ case WebCore::VKEY_LCONTROL:
+ case WebCore::VKEY_RCONTROL:
+ mask = GDK_CONTROL_MASK;
+ break;
+ case WebCore::VKEY_SHIFT:
+ case WebCore::VKEY_LSHIFT:
+ case WebCore::VKEY_RSHIFT:
+ mask = GDK_SHIFT_MASK;
+ break;
+ case WebCore::VKEY_MENU:
+ case WebCore::VKEY_LMENU:
+ case WebCore::VKEY_RMENU:
+ mask = GDK_MOD1_MASK;
+ break;
+ case WebCore::VKEY_CAPITAL:
+ mask = GDK_LOCK_MASK;
+ break;
+ default:
+ return event->state;
+ }
+ if (event->type == GDK_KEY_PRESS)
+ return event->state | mask;
+ return event->state & ~mask;
+}
+
+// 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(normalizeEventState(event));
+
+ 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.
+ int windowsKeyCode = gdkEventToWindowsKeyCode(event);
+ result.windowsKeyCode = WebKeyboardEvent::windowsKeyCodeWithoutLocation(windowsKeyCode);
+ result.modifiers |= WebKeyboardEvent::locationModifiersFromWindowsKeyCode(windowsKeyCode);
+ 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?
+ if (isKeyPadKeyval(event->keyval))
+ result.modifiers |= WebInputEvent::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();
+ };
+
+ 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;
+
+ if (result.type == WebInputEvent::MouseDown) {
+ bool forgetPreviousClick = shouldForgetPreviousClick(event->window, event->time, event->x, event->y);
+
+ if (!forgetPreviousClick && result.button == gLastClickButton)
+ ++gNumClicks;
+ else {
+ gNumClicks = 1;
+
+ gLastClickEventWindow = event->window;
+ gLastClickX = event->x;
+ gLastClickY = event->y;
+ gLastClickButton = result.button;
+ }
+ gLastClickTime = event->time;
+ }
+ result.clickCount = gNumClicks;
+
+ 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;
+
+ if (shouldForgetPreviousClick(event->window, event->time, event->x, event->y))
+ resetClickCountState();
+
+ 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;
+
+ if (shouldForgetPreviousClick(event->window, event->time, event->x, event->y))
+ resetClickCountState();
+
+ 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/chromium/third_party/WebKit/Source/web/linux/WebFontInfo.cpp b/chromium/third_party/WebKit/Source/web/linux/WebFontInfo.cpp
new file mode 100644
index 00000000000..45a56ccf196
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/linux/WebFontInfo.cpp
@@ -0,0 +1,335 @@
+/*
+ * 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 "public/platform/linux/WebFontFamily.h"
+#include "wtf/HashMap.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicStringHash.h"
+#include <fontconfig/fontconfig.h>
+#include <string.h>
+#include <unicode/utf16.h>
+
+namespace WebKit {
+
+static bool useSubpixelPositioning = false;
+
+void WebFontInfo::setSubpixelPositioning(bool subpixelPositioning)
+{
+ useSubpixelPositioning = subpixelPositioning;
+}
+
+class FontResource {
+public:
+ // Note: We pass the charset explicitly as callers
+ // should not create FontResource entries without knowing
+ // that the FcPattern contains a valid charset.
+ FontResource(FcPattern* pattern, FcCharSet* charSet)
+ : m_supportedCharacters(charSet)
+ {
+ ASSERT(pattern);
+ ASSERT(charSet);
+ m_family.name = fontName(pattern);
+ m_family.isBold = fontIsBold(pattern);
+ m_family.isItalic = fontIsItalic(pattern);
+ }
+ const WebFontFamily& family() const { return m_family; }
+ bool hasGlyphForCharacter(WebUChar32 c)
+ {
+ return m_supportedCharacters && FcCharSetHasChar(m_supportedCharacters, c);
+ }
+
+private:
+ static WebCString fontName(FcPattern* pattern)
+ {
+ FcChar8* familyName;
+ if (FcPatternGetString(pattern, FC_FAMILY, 0, &familyName) != FcResultMatch)
+ return WebCString();
+
+ // FCChar8 is unsigned char, so we cast to char for WebCString.
+ const char* charFamily = reinterpret_cast<char*>(familyName);
+ // FIXME: This should use WebString instead, and we should be
+ // explicit about which encoding we're using. Right now callers
+ // assume that this is utf8, but that may be wrong!
+ return WebCString(charFamily, strlen(charFamily));
+ }
+
+ static bool fontIsBold(FcPattern* pattern)
+ {
+ int weight;
+ if (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) != FcResultMatch)
+ return false;
+ return weight >= FC_WEIGHT_BOLD;
+ }
+
+ static bool fontIsItalic(FcPattern* pattern)
+ {
+ int slant;
+ if (FcPatternGetInteger(pattern, FC_SLANT, 0, &slant) != FcResultMatch)
+ return false;
+ return slant != FC_SLANT_ROMAN;
+ }
+
+ WebFontFamily m_family;
+ // m_supportedCharaters is owned by the parent
+ // FcFontSet and should never be freed.
+ FcCharSet* m_supportedCharacters;
+};
+
+
+class FontResourceSet {
+ WTF_MAKE_NONCOPYABLE(FontResourceSet);
+public:
+ // FontResourceSet takes ownership of the passed FcFontSet.
+ static PassOwnPtr<FontResourceSet> createForLocale(const char* locale)
+ {
+ FcFontSet* fontSet = createFcFontSetForLocale(locale);
+ return adoptPtr(new FontResourceSet(fontSet));
+ }
+
+ ~FontResourceSet()
+ {
+ m_fallbackList.clear();
+ FcFontSetDestroy(m_fontSet);
+ }
+
+ WebFontFamily familyForChar(WebUChar32 c)
+ {
+ Vector<FontResource>::iterator itr = m_fallbackList.begin();
+ for (; itr != m_fallbackList.end(); itr++) {
+ if (itr->hasGlyphForCharacter(c))
+ return itr->family();
+ }
+ // The previous code just returned garbage if the user didn't
+ // have the necessary fonts, this seems better than garbage.
+ // Current callers happen to ignore any values with an empty family string.
+ return WebFontFamily();
+ }
+
+private:
+ static FcFontSet* createFcFontSetForLocale(const char* locale)
+ {
+ ASSERT(locale);
+ FcPattern* pattern = FcPatternCreate();
+ // FcChar* is unsigned char* so we have to cast.
+ FcPatternAddString(pattern, FC_LANG, reinterpret_cast<const FcChar8*>(locale));
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ // The result parameter returns if any fonts were found.
+ // We already handle empty FcFontSets correctly, so we ignore the param.
+ FcResult result;
+ // Unfortunately we cannot use "trim" as FCFontSort ignores
+ // FC_SCALABLE and we don't want bitmap fonts. If we used
+ // trim it might trim scalable fonts which only added characters
+ // covered by an earlier bitmap font. Instead we trim ourselves
+ // in fillFallbackList until FcFontSort is fixed:
+ // https://bugs.freedesktop.org/show_bug.cgi?id=67845
+ FcFontSet* fontSet = FcFontSort(0, pattern, FcFalse, 0, &result);
+ FcPatternDestroy(pattern);
+
+ // The caller will take ownership of this FcFontSet.
+ return fontSet;
+ }
+
+ explicit FontResourceSet(FcFontSet* fontSet)
+ : m_fontSet(fontSet)
+ {
+ fillFallbackList();
+ }
+
+ void fillFallbackList()
+ {
+ ASSERT(m_fallbackList.isEmpty());
+ if (!m_fontSet)
+ return;
+
+ FcCharSet* allGlyphs = FcCharSetCreate();
+
+ for (int i = 0; i < m_fontSet->nfont; ++i) {
+ FcPattern* pattern = m_fontSet->fonts[i];
+
+ // Ignore any bitmap fonts users may still have installed from last century.
+ FcBool isScalable;
+ if (FcPatternGetBool(pattern, FC_SCALABLE, 0, &isScalable) != FcResultMatch
+ || !isScalable)
+ continue;
+
+ // Ignore any fonts FontConfig knows about, but that we don't have persmision to read.
+ FcChar8* cFilename;
+ if (FcPatternGetString(pattern, FC_FILE, 0, &cFilename) != FcResultMatch)
+ continue;
+ if (access(reinterpret_cast<char*>(cFilename), R_OK))
+ continue;
+
+ // Make sure this font can tell us what characters it has glyphs for.
+ FcCharSet* charSet;
+ if (FcPatternGetCharSet(pattern, FC_CHARSET, 0, &charSet) != FcResultMatch)
+ continue;
+
+ FcBool addsGlyphs = FcFalse;
+ // FcCharSetMerge returns false on failure (out of memory, etc.)
+ if (!FcCharSetMerge(allGlyphs, charSet, &addsGlyphs) || addsGlyphs)
+ m_fallbackList.append(FontResource(pattern, charSet));
+ }
+ // FIXME: We could cache allGlyphs, or even send it to the renderer
+ // to avoid it needing to call us for glyphs we won't have.
+ FcCharSetDestroy(allGlyphs);
+ }
+
+ FcFontSet* m_fontSet; // Owned by this object.
+ // FontResource has a FcCharset* which points into the FcFontSet.
+ // If the FcFontSet is ever destoryed, the fallbackList
+ // must be cleared first.
+ Vector<FontResource> m_fallbackList;
+};
+
+class FontSetCache {
+public:
+ static FontSetCache& shared()
+ {
+ DEFINE_STATIC_LOCAL(FontSetCache, cache, ());
+ return cache;
+ }
+
+ WebFontFamily fontFamilyForCharInLocale(WebUChar32 c, const char* locale)
+ {
+ LocaleToFontResource::iterator itr = m_setsByLocale.find(locale);
+ if (itr == m_setsByLocale.end()) {
+ OwnPtr<FontResourceSet> newEntry = FontResourceSet::createForLocale(locale);
+ itr = m_setsByLocale.add(locale, newEntry.release()).iterator;
+ }
+ return itr.get()->value->familyForChar(c);
+ }
+ // FIXME: We may wish to add a way to prune the cache at a later time.
+
+private:
+ // FIXME: This shouldn't need to be AtomicString, but
+ // currently HashTraits<const char*> isn't smart enough
+ // to hash the string (only does pointer compares).
+ typedef HashMap<AtomicString, OwnPtr<FontResourceSet> > LocaleToFontResource;
+ LocaleToFontResource m_setsByLocale;
+};
+
+void WebFontInfo::familyForChar(WebUChar32 c, const char* locale, WebFontFamily* family)
+{
+ *family = FontSetCache::shared().fontFamilyForCharInLocale(c, locale);
+}
+
+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)
+ 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->useSubpixelRendering = 0;
+ break;
+ case FC_RGBA_RGB:
+ case FC_RGBA_BGR:
+ case FC_RGBA_VRGB:
+ case FC_RGBA_VBGR:
+ out->useSubpixelRendering = 1;
+ break;
+ default:
+ // This includes FC_RGBA_UNKNOWN.
+ out->useSubpixelRendering = 2;
+ break;
+ }
+ }
+
+ // FontConfig doesn't provide parameters to configure whether subpixel
+ // positioning should be used or not, so we just use a global setting.
+ out->useSubpixelPositioning = useSubpixelPositioning;
+
+ FcPatternDestroy(match);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/linux/WebFontRenderStyle.cpp b/chromium/third_party/WebKit/Source/web/linux/WebFontRenderStyle.cpp
new file mode 100644
index 00000000000..fe3e05efe37
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/linux/WebFontRenderStyle.cpp
@@ -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:
+ *
+ * * 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 "core/platform/graphics/chromium/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->useSubpixelRendering = useSubpixelRendering;
+ out->useSubpixelPositioning = useSubpixelPositioning;
+}
+
+void WebFontRenderStyle::setDefaults()
+{
+ useBitmaps = 2;
+ useAutoHint = 2;
+ useHinting = 2;
+ hintStyle = 0;
+ useAntiAlias = 2;
+ useSubpixelRendering = 2;
+ useSubpixelPositioning = 2;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/linux/WebFontRendering.cpp b/chromium/third_party/WebKit/Source/web/linux/WebFontRendering.cpp
new file mode 100644
index 00000000000..03b92dcf82b
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/linux/WebFontRendering.cpp
@@ -0,0 +1,95 @@
+/*
+ * 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 "core/platform/graphics/FontPlatformData.h"
+
+#if OS(LINUX) && !OS(ANDROID)
+#include "WebFontInfo.h"
+#endif
+
+using WebCore::FontPlatformData;
+
+namespace WebKit {
+
+// static
+void WebFontRendering::setHinting(SkPaint::Hinting hinting)
+{
+ FontPlatformData::setHinting(hinting);
+}
+
+// static
+void WebFontRendering::setAutoHint(bool useAutoHint)
+{
+ FontPlatformData::setAutoHint(useAutoHint);
+}
+
+// static
+void WebFontRendering::setUseBitmaps(bool useBitmaps)
+{
+ FontPlatformData::setUseBitmaps(useBitmaps);
+}
+
+// static
+void WebFontRendering::setAntiAlias(bool useAntiAlias)
+{
+ FontPlatformData::setAntiAlias(useAntiAlias);
+}
+
+// static
+void WebFontRendering::setSubpixelRendering(bool useSubpixelRendering)
+{
+ FontPlatformData::setSubpixelRendering(useSubpixelRendering);
+}
+
+// static
+void WebFontRendering::setSubpixelPositioning(bool useSubpixelPositioning)
+{
+ FontPlatformData::setSubpixelPositioning(useSubpixelPositioning);
+#if OS(LINUX) && !OS(ANDROID)
+ WebFontInfo::setSubpixelPositioning(useSubpixelPositioning);
+#endif
+}
+
+// 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/chromium/third_party/WebKit/Source/web/mac/WebInputEventFactory.mm b/chromium/third_party/WebKit/Source/web/mac/WebInputEventFactory.mm
new file mode 100644
index 00000000000..da074e05811
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/mac/WebInputEventFactory.mm
@@ -0,0 +1,958 @@
+/*
+ * 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 <AvailabilityMacros.h>
+#import <Cocoa/Cocoa.h>
+
+#include "WebInputEvent.h"
+#import "core/platform/cocoa/KeyEventCocoa.h"
+#include "wtf/ASCIICType.h"
+
+#if __MAC_OS_X_VERSION_MAX_ALLOWED == 1060
+
+// Additional Lion APIs.
+enum {
+ NSEventPhaseNone = 0,
+ NSEventPhaseBegan = 0x1 << 0,
+ NSEventPhaseStationary = 0x1 << 1,
+ NSEventPhaseChanged = 0x1 << 2,
+ NSEventPhaseEnded = 0x1 << 3,
+ NSEventPhaseCancelled = 0x1 << 4
+};
+typedef NSUInteger NSEventPhase;
+
+@interface NSEvent (LionSDKDeclarations)
+- (NSEventPhase)phase;
+- (NSEventPhase)momentumPhase;
+@end
+
+#endif // __MAC_OS_X_VERSION_MAX_ALLOWED == 1060
+
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+
+// Additional Mountain Lion APIs.
+enum {
+ NSEventPhaseMayBegin = 0x1 << 5
+};
+
+#endif // __MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+
+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;
+ }
+
+ 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)
+{
+ int code = 0;
+ // There are several kinds of characters for which we produce key code from char code:
+ // 1. Roman letters. Windows keyboard layouts affect both virtual key codes and character codes for these,
+ // so e.g. 'A' gets the same keyCode on QWERTY, AZERTY or Dvorak layouts.
+ // 2. Keys for which there is no known Mac virtual key codes, like PrintScreen.
+ // 3. Certain punctuation keys. On Windows, these are also remapped depending on current keyboard layout,
+ // but see comment in windowsKeyCodeForCharCode().
+ if (!isKeypadEvent(event) && ([event type] == NSKeyDown || [event type] == NSKeyUp)) {
+ // Cmd switches Roman letters for Dvorak-QWERTY layout, so try modified characters first.
+ NSString* s = [event characters];
+ code = [s length] > 0 ? WebCore::windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0;
+ if (code)
+ return code;
+
+ // Ctrl+A on an AZERTY keyboard would get VK_Q keyCode if we relied on -[NSEvent keyCode] below.
+ s = [event charactersIgnoringModifiers];
+ code = [s length] > 0 ? WebCore::windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0;
+ if (code)
+ return code;
+ }
+
+ // Map Mac virtual key code directly to Windows one for any keys not handled above.
+ // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboard ('A') and on Russian keyboard (CYRILLIC LETTER EF).
+ return WebCore::windowsKeyCodeForKeyCode([event keyCode]);
+}
+
+static WebInputEvent::Type gestureEventTypeForEvent(NSEvent *event)
+{
+ switch ([event type]) {
+ case NSEventTypeBeginGesture:
+ return WebInputEvent::GestureScrollBegin;
+ case NSEventTypeEndGesture:
+ return WebInputEvent::GestureScrollEnd;
+ default:
+ ASSERT_NOT_REACHED();
+ return WebInputEvent::GestureScrollEnd;
+ }
+}
+
+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;
+
+ result->movementX = [event deltaX];
+ result->movementY = [event deltaY];
+}
+
+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;
+
+ int windowsKeyCode = windowsKeyCodeForKeyEvent(event);
+ result.windowsKeyCode = WebKeyboardEvent::windowsKeyCodeWithoutLocation(windowsKeyCode);
+ result.modifiers |= WebKeyboardEvent::locationModifiersFromWindowsKeyCode(windowsKeyCode);
+ 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 ---------------------------------------------------------
+
+static WebMouseWheelEvent::Phase phaseForNSEventPhase(NSEventPhase eventPhase)
+{
+ uint32_t phase = WebMouseWheelEvent::PhaseNone;
+ if (eventPhase & NSEventPhaseBegan)
+ phase |= WebMouseWheelEvent::PhaseBegan;
+ if (eventPhase & NSEventPhaseStationary)
+ phase |= WebMouseWheelEvent::PhaseStationary;
+ if (eventPhase & NSEventPhaseChanged)
+ phase |= WebMouseWheelEvent::PhaseChanged;
+ if (eventPhase & NSEventPhaseEnded)
+ phase |= WebMouseWheelEvent::PhaseEnded;
+ if (eventPhase & NSEventPhaseCancelled)
+ phase |= WebMouseWheelEvent::PhaseCancelled;
+ if (eventPhase & NSEventPhaseMayBegin)
+ phase |= WebMouseWheelEvent::PhaseMayBegin;
+ return static_cast<WebMouseWheelEvent::Phase>(phase);
+}
+
+static WebMouseWheelEvent::Phase phaseForEvent(NSEvent *event)
+{
+ if (![event respondsToSelector:@selector(phase)])
+ return WebMouseWheelEvent::PhaseNone;
+
+ NSEventPhase eventPhase = [event phase];
+ return phaseForNSEventPhase(eventPhase);
+}
+
+static WebMouseWheelEvent::Phase momentumPhaseForEvent(NSEvent *event)
+{
+ if (![event respondsToSelector:@selector(momentumPhase)])
+ return WebMouseWheelEvent::PhaseNone;
+
+ NSEventPhase eventMomentumPhase = [event momentumPhase];
+ return phaseForNSEventPhase(eventMomentumPhase);
+}
+
+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;
+ result.hasPreciseScrollingDeltas = true;
+ } 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];
+
+ result.phase = phaseForEvent(event);
+ result.momentumPhase = momentumPhaseForEvent(event);
+
+ return result;
+}
+
+WebGestureEvent WebInputEventFactory::gestureEvent(NSEvent *event, NSView *view)
+{
+ WebGestureEvent result;
+
+ // Use a temporary WebMouseEvent to get the location.
+ WebMouseEvent temp;
+
+ setWebEventLocationFromEventInView(&temp, event, view);
+ result.x = temp.x;
+ result.y = temp.y;
+ result.globalX = temp.globalX;
+ result.globalY = temp.globalY;
+
+ result.type = gestureEventTypeForEvent(event);
+ result.modifiers = modifiersFromEvent(event);
+ result.timeStampSeconds = [event timestamp];
+
+ return result;
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/mac/WebSubstringUtil.mm b/chromium/third_party/WebKit/Source/web/mac/WebSubstringUtil.mm
new file mode 100644
index 00000000000..fc472b9e99d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/mac/WebSubstringUtil.mm
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. 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 "WebSubstringUtil.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "WebFrameImpl.h"
+#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "core/dom/Document.h"
+#include "core/dom/Element.h"
+#include "core/dom/Node.h"
+#include "core/dom/Range.h"
+#include "core/editing/FrameSelection.h"
+#include "core/editing/TextIterator.h"
+#include "core/html/HTMLElement.h"
+#include "core/page/Frame.h"
+#include "core/page/FrameView.h"
+#include "core/platform/graphics/Font.h"
+#include "core/platform/graphics/mac/ColorMac.h"
+#include "core/rendering/RenderObject.h"
+#include "core/rendering/style/RenderStyle.h"
+#include "public/platform/WebRect.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+NSAttributedString* WebSubstringUtil::attributedSubstringInRange(WebFrame* webFrame, size_t location, size_t length)
+{
+ Frame* frame = static_cast<WebFrameImpl*>(webFrame)->frame();
+ if (frame->view()->needsLayout())
+ frame->view()->layout();
+
+ RefPtr<Range> range(TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length));
+ if (!range)
+ return nil;
+
+ NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init];
+ NSMutableDictionary* attrs = [NSMutableDictionary dictionary];
+
+ unsigned position = 0;
+ for (TextIterator it(range.get()); !it.atEnd() && [string length] < length; it.advance()) {
+ unsigned numCharacters = it.length();
+ if (!numCharacters)
+ continue;
+
+ Node* container = it.range()->startContainer(IGNORE_EXCEPTION);
+ RenderObject* renderer = container->renderer();
+ ASSERT(renderer);
+ if (!renderer)
+ continue;
+
+ RenderStyle* style = renderer->style();
+ NSFont* font = style->font().primaryFont()->getNSFont();
+ // If the platform font can't be loaded, it's likely that the site is
+ // using a web font. For now, just use the default font instead.
+ // TODO(rsesek): Change the font activation flags to allow other processes
+ // to use the font.
+ if (!font)
+ font = [NSFont systemFontOfSize:style->font().size()];
+ [attrs setObject:font forKey:NSFontAttributeName];
+
+ if (style->visitedDependentColor(CSSPropertyColor).alpha())
+ [attrs setObject:nsColor(renderer->resolveColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
+ else
+ [attrs removeObjectForKey:NSForegroundColorAttributeName];
+ if (style->visitedDependentColor(CSSPropertyBackgroundColor).alpha())
+ [attrs setObject:nsColor(renderer->resolveColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
+ else
+ [attrs removeObjectForKey:NSBackgroundColorAttributeName];
+
+ Vector<UChar> characters;
+ it.appendTextTo(characters);
+ NSString* substring =
+ [[[NSString alloc] initWithCharacters:characters.data()
+ length:characters.size()] autorelease];
+ [string replaceCharactersInRange:NSMakeRange(position, 0)
+ withString:substring];
+ [string setAttributes:attrs range:NSMakeRange(position, numCharacters)];
+ position += numCharacters;
+ }
+ return [string autorelease];
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.cpp b/chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.cpp
new file mode 100644
index 00000000000..dc0f826ae3f
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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. 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 GOOGLE 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 "ContinuousPainter.h"
+
+#include "PageOverlayList.h"
+#include "core/platform/chromium/TraceEvent.h"
+#include "core/platform/graphics/GraphicsLayer.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void ContinuousPainter::setNeedsDisplayRecursive(GraphicsLayer* layer, PageOverlayList* pageOverlays)
+{
+ if (!layer)
+ return;
+
+ if (pageOverlays && pageOverlays->findGraphicsLayer(layer) != WTF::notFound)
+ return;
+
+ TRACE_EVENT0("webkit", "ContinuousPainter::setNeedsDisplayRecursive");
+ layer->setNeedsDisplay();
+
+ setNeedsDisplayRecursive(layer->maskLayer(), pageOverlays);
+ setNeedsDisplayRecursive(layer->replicaLayer(), pageOverlays);
+
+ const Vector<GraphicsLayer*>& children = layer->children();
+ Vector<GraphicsLayer*>::const_iterator it;
+ for (it = children.begin(); it != children.end(); ++it)
+ setNeedsDisplayRecursive(*it, pageOverlays);
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.h b/chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.h
new file mode 100644
index 00000000000..c60f3fe2e38
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/painting/ContinuousPainter.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 Google Inc. 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. 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 GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ContinuousPainter_h
+#define ContinuousPainter_h
+
+namespace WebCore {
+class GraphicsLayer;
+}
+
+namespace WebKit {
+class PageOverlayList;
+
+// This class is responsible for calling setNeedsDisplay on all
+// GraphicsLayers in continuous painting mode.
+class ContinuousPainter {
+public:
+ // Calls setNeedsDisplay on the layer, then recursively calls
+ // on mask layers, replica layers and all child layers.
+ // Overlays are excluded, because they impact the page paint time metric.
+ static void setNeedsDisplayRecursive(WebCore::GraphicsLayer*, PageOverlayList*);
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/painting/PaintAggregator.cpp b/chromium/third_party/WebKit/Source/web/painting/PaintAggregator.cpp
new file mode 100644
index 00000000000..7093ae40c18
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/painting/PaintAggregator.cpp
@@ -0,0 +1,371 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 "PaintAggregator.h"
+#include "public/platform/Platform.h"
+using namespace WebCore;
+
+namespace WebKit {
+
+// ----------------------------------------------------------------------------
+// ALGORITHM NOTES
+//
+// We attempt to maintain a scroll rect in the presence of invalidations that
+// are contained within the scroll rect. If an invalidation crosses a scroll
+// rect, then we just treat the scroll rect as an invalidation rect.
+//
+// For invalidations performed prior to scrolling and contained within the
+// scroll rect, we offset the invalidation rects to account for the fact that
+// the consumer will perform scrolling before painting.
+//
+// We only support scrolling along one axis at a time. A diagonal scroll will
+// therefore be treated as an invalidation.
+// ----------------------------------------------------------------------------
+
+// If the combined area of paint rects contained within the scroll rect grows
+// too large, then we might as well just treat the scroll rect as a paint rect.
+// This constant sets the max ratio of paint rect area to scroll rect area that
+// we will tolerate before dograding the scroll into a repaint.
+static const float maxRedundantPaintToScrollArea = 0.8f;
+
+// The maximum number of paint rects. If we exceed this limit, then we'll
+// start combining paint rects (see CombinePaintRects). This limiting is
+// important since the WebKit code associated with deciding what to paint given
+// a paint rect can be significant.
+static const size_t maxPaintRects = 5;
+
+// If the combined area of paint rects divided by the area of the union of all
+// paint rects exceeds this threshold, then we will combine the paint rects.
+static const float maxPaintRectsAreaRatio = 0.7f;
+
+static int calculateArea(const IntRect& rect)
+{
+ return rect.size().width() * rect.size().height();
+}
+
+// Subtracts out the intersection of |a| and |b| from |a|, assuming |b| fully
+// overlaps with |a| in either the x- or y-direction. If there is no full
+// overlap, then |a| is returned.
+static IntRect subtractIntersection(const IntRect& a, const IntRect& b)
+{
+ // boundary cases:
+ if (!a.intersects(b))
+ return a;
+ if (b.contains(a))
+ return IntRect();
+
+ int rx = a.x();
+ int ry = a.y();
+ int rr = a.maxX();
+ int rb = a.maxY();
+
+ if (b.y() <= a.y() && b.maxY() >= a.maxY()) {
+ // complete intersection in the y-direction
+ if (b.x() <= a.x())
+ rx = b.maxX();
+ else
+ rr = b.x();
+ } else if (b.x() <= a.x() && b.maxX() >= a.maxX()) {
+ // complete intersection in the x-direction
+ if (b.y() <= a.y())
+ ry = b.maxY();
+ else
+ rb = b.y();
+ }
+ return IntRect(rx, ry, rr - rx, rb - ry);
+}
+
+// Returns true if |a| and |b| share an entire edge (i.e., same width or same
+// height), and the rectangles do not overlap.
+static bool sharesEdge(const IntRect& a, const IntRect& b)
+{
+ return (a.y() == b.y() && a.height() == b.height() && (a.x() == b.maxX() || a.maxX() == b.x()))
+ || (a.x() == b.x() && a.width() == b.width() && (a.y() == b.maxY() || a.maxY() == b.y()));
+}
+
+PaintAggregator::PendingUpdate::PendingUpdate()
+{
+}
+
+PaintAggregator::PendingUpdate::~PendingUpdate()
+{
+}
+
+IntRect PaintAggregator::PendingUpdate::calculateScrollDamage() const
+{
+ // Should only be scrolling in one direction at a time.
+ ASSERT(!(scrollDelta.x() && scrollDelta.y()));
+
+ IntRect damagedRect;
+
+ // Compute the region we will expose by scrolling, and paint that into a
+ // shared memory section.
+ if (scrollDelta.x()) {
+ int dx = scrollDelta.x();
+ damagedRect.setY(scrollRect.y());
+ damagedRect.setHeight(scrollRect.height());
+ if (dx > 0) {
+ damagedRect.setX(scrollRect.x());
+ damagedRect.setWidth(dx);
+ } else {
+ damagedRect.setX(scrollRect.maxX() + dx);
+ damagedRect.setWidth(-dx);
+ }
+ } else {
+ int dy = scrollDelta.y();
+ damagedRect.setX(scrollRect.x());
+ damagedRect.setWidth(scrollRect.width());
+ if (dy > 0) {
+ damagedRect.setY(scrollRect.y());
+ damagedRect.setHeight(dy);
+ } else {
+ damagedRect.setY(scrollRect.maxY() + dy);
+ damagedRect.setHeight(-dy);
+ }
+ }
+
+ // In case the scroll offset exceeds the width/height of the scroll rect
+ return intersection(scrollRect, damagedRect);
+}
+
+IntRect PaintAggregator::PendingUpdate::calculatePaintBounds() const
+{
+ IntRect bounds;
+ for (size_t i = 0; i < paintRects.size(); ++i)
+ bounds.unite(paintRects[i]);
+ return bounds;
+}
+
+bool PaintAggregator::hasPendingUpdate() const
+{
+ return !m_update.scrollRect.isEmpty() || !m_update.paintRects.isEmpty();
+}
+
+void PaintAggregator::clearPendingUpdate()
+{
+ m_update = PendingUpdate();
+}
+
+void PaintAggregator::popPendingUpdate(PendingUpdate* update)
+{
+ // Combine paint rects if their combined area is not sufficiently less than
+ // the area of the union of all paint rects. We skip this if there is a
+ // scroll rect since scrolling benefits from smaller paint rects.
+ if (m_update.scrollRect.isEmpty() && m_update.paintRects.size() > 1) {
+ int paintArea = 0;
+ IntRect unionRect;
+ for (size_t i = 0; i < m_update.paintRects.size(); ++i) {
+ paintArea += calculateArea(m_update.paintRects[i]);
+ unionRect.unite(m_update.paintRects[i]);
+ }
+ int unionArea = calculateArea(unionRect);
+ if (float(paintArea) / float(unionArea) > maxPaintRectsAreaRatio)
+ combinePaintRects();
+ }
+ *update = m_update;
+ clearPendingUpdate();
+}
+
+void PaintAggregator::invalidateRect(const IntRect& rect)
+{
+ // Combine overlapping paints using smallest bounding box.
+ for (size_t i = 0; i < m_update.paintRects.size(); ++i) {
+ const IntRect& existingRect = m_update.paintRects[i];
+ if (existingRect.contains(rect)) // Optimize out redundancy.
+ return;
+ if (rect.intersects(existingRect) || sharesEdge(rect, existingRect)) {
+ // Re-invalidate in case the union intersects other paint rects.
+ IntRect combinedRect = unionRect(existingRect, rect);
+ m_update.paintRects.remove(i);
+ invalidateRect(combinedRect);
+ return;
+ }
+ }
+
+ // Add a non-overlapping paint.
+ m_update.paintRects.append(rect);
+
+ // If the new paint overlaps with a scroll, then it forces an invalidation of
+ // the scroll. If the new paint is contained by a scroll, then trim off the
+ // scroll damage to avoid redundant painting.
+ if (!m_update.scrollRect.isEmpty()) {
+ if (shouldInvalidateScrollRect(rect))
+ invalidateScrollRect();
+ else if (m_update.scrollRect.contains(rect)) {
+ m_update.paintRects[m_update.paintRects.size() - 1] =
+ subtractIntersection(rect, m_update.calculateScrollDamage());
+ if (m_update.paintRects[m_update.paintRects.size() - 1].isEmpty())
+ m_update.paintRects.remove(m_update.paintRects.size() - 1);
+ }
+ }
+
+ if (m_update.paintRects.size() > maxPaintRects)
+ combinePaintRects();
+
+ // Track how large the paintRects vector grows during an invalidation
+ // sequence. Note: A subsequent invalidation may end up being combined
+ // with all existing paints, which means that tracking the size of
+ // paintRects at the time when popPendingUpdate() is called may mask
+ // certain performance problems.
+ WebKit::Platform::current()->histogramCustomCounts("MPArch.RW_IntermediatePaintRectCount",
+ m_update.paintRects.size(), 1, 100, 50);
+}
+
+void PaintAggregator::scrollRect(int dx, int dy, const IntRect& clipRect)
+{
+ // We only support scrolling along one axis at a time.
+ if (dx && dy) {
+ invalidateRect(clipRect);
+ return;
+ }
+
+ // We can only scroll one rect at a time.
+ if (!m_update.scrollRect.isEmpty() && m_update.scrollRect != clipRect) {
+ invalidateRect(clipRect);
+ return;
+ }
+
+ // Again, we only support scrolling along one axis at a time. Make sure this
+ // update doesn't scroll on a different axis than any existing one.
+ if ((dx && m_update.scrollDelta.y()) || (dy && m_update.scrollDelta.x())) {
+ invalidateRect(clipRect);
+ return;
+ }
+
+ // The scroll rect is new or isn't changing (though the scroll amount may
+ // be changing).
+ m_update.scrollRect = clipRect;
+ m_update.scrollDelta.move(dx, dy);
+
+ // We might have just wiped out a pre-existing scroll.
+ if (m_update.scrollDelta == IntPoint()) {
+ m_update.scrollRect = IntRect();
+ return;
+ }
+
+ // Adjust any contained paint rects and check for any overlapping paints.
+ for (size_t i = 0; i < m_update.paintRects.size(); ++i) {
+ if (m_update.scrollRect.contains(m_update.paintRects[i])) {
+ m_update.paintRects[i] = scrollPaintRect(m_update.paintRects[i], dx, dy);
+ // The rect may have been scrolled out of view.
+ if (m_update.paintRects[i].isEmpty()) {
+ m_update.paintRects.remove(i);
+ i--;
+ }
+ } else if (m_update.scrollRect.intersects(m_update.paintRects[i])) {
+ invalidateScrollRect();
+ return;
+ }
+ }
+
+ // If the new scroll overlaps too much with contained paint rects, then force
+ // an invalidation of the scroll.
+ if (shouldInvalidateScrollRect(IntRect()))
+ invalidateScrollRect();
+}
+
+IntRect PaintAggregator::scrollPaintRect(const IntRect& paintRect, int dx, int dy) const
+{
+ IntRect result = paintRect;
+
+ result.move(dx, dy);
+ result = intersection(m_update.scrollRect, result);
+
+ // Subtract out the scroll damage rect to avoid redundant painting.
+ return subtractIntersection(result, m_update.calculateScrollDamage());
+}
+
+bool PaintAggregator::shouldInvalidateScrollRect(const IntRect& rect) const
+{
+ if (!rect.isEmpty()) {
+ if (!m_update.scrollRect.intersects(rect))
+ return false;
+
+ if (!m_update.scrollRect.contains(rect))
+ return true;
+ }
+
+ // Check if the combined area of all contained paint rects plus this new
+ // rect comes too close to the area of the scrollRect. If so, then we
+ // might as well invalidate the scroll rect.
+
+ int paintArea = calculateArea(rect);
+ for (size_t i = 0; i < m_update.paintRects.size(); ++i) {
+ const IntRect& existingRect = m_update.paintRects[i];
+ if (m_update.scrollRect.contains(existingRect))
+ paintArea += calculateArea(existingRect);
+ }
+ int scrollArea = calculateArea(m_update.scrollRect);
+ if (float(paintArea) / float(scrollArea) > maxRedundantPaintToScrollArea)
+ return true;
+
+ return false;
+}
+
+void PaintAggregator::invalidateScrollRect()
+{
+ IntRect scrollRect = m_update.scrollRect;
+ m_update.scrollRect = IntRect();
+ m_update.scrollDelta = IntPoint();
+ invalidateRect(scrollRect);
+}
+
+void PaintAggregator::combinePaintRects()
+{
+ // Combine paint rects do to at most two rects: one inside the scrollRect
+ // and one outside the scrollRect. If there is no scrollRect, then just
+ // use the smallest bounding box for all paint rects.
+ //
+ // NOTE: This is a fairly simple algorithm. We could get fancier by only
+ // combining two rects to get us under the maxPaintRects limit, but if we
+ // reach this method then it means we're hitting a rare case, so there's no
+ // need to over-optimize it.
+ //
+ if (m_update.scrollRect.isEmpty()) {
+ IntRect bounds = m_update.calculatePaintBounds();
+ m_update.paintRects.clear();
+ m_update.paintRects.append(bounds);
+ } else {
+ IntRect inner, outer;
+ for (size_t i = 0; i < m_update.paintRects.size(); ++i) {
+ const IntRect& existingRect = m_update.paintRects[i];
+ if (m_update.scrollRect.contains(existingRect))
+ inner.unite(existingRect);
+ else
+ outer.unite(existingRect);
+ }
+ m_update.paintRects.clear();
+ m_update.paintRects.append(inner);
+ m_update.paintRects.append(outer);
+ }
+}
+
+} // namespace WebKit
diff --git a/chromium/third_party/WebKit/Source/web/painting/PaintAggregator.h b/chromium/third_party/WebKit/Source/web/painting/PaintAggregator.h
new file mode 100644
index 00000000000..96afe10d84e
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/painting/PaintAggregator.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 PaintAggregator_h
+#define PaintAggregator_h
+
+#include "core/platform/graphics/IntPoint.h"
+#include "core/platform/graphics/IntRect.h"
+#include "wtf/Vector.h"
+
+namespace WebKit {
+
+// This class is responsible for aggregating multiple invalidation and scroll
+// commands to produce a scroll and repaint sequence.
+class PaintAggregator {
+public:
+ // This structure describes an aggregation of invalidateRect and scrollRect
+ // calls. If |scrollRect| is non-empty, then that rect should be scrolled
+ // by the amount specified by |scrollDelta|. If |paintRects| is non-empty,
+ // then those rects should be repainted. If |scrollRect| and |paintRects|
+ // are non-empty, then scrolling should be performed before repainting.
+ // |scrollDelta| can only specify scrolling in one direction (i.e., the x
+ // and y members cannot both be non-zero).
+ struct PendingUpdate {
+ PendingUpdate();
+ ~PendingUpdate();
+
+ // Returns the rect damaged by scrolling within |scrollRect| by
+ // |scrollDelta|. This rect must be repainted.
+ WebCore::IntRect calculateScrollDamage() const;
+
+ // Returns the smallest rect containing all paint rects.
+ WebCore::IntRect calculatePaintBounds() const;
+
+ WebCore::IntPoint scrollDelta;
+ WebCore::IntRect scrollRect;
+ WTF::Vector<WebCore::IntRect> paintRects;
+ };
+
+ // There is a PendingUpdate if invalidateRect or scrollRect were called and
+ // ClearPendingUpdate was not called.
+ bool hasPendingUpdate() const;
+ void clearPendingUpdate();
+
+ // Fills |update| and clears the pending update.
+ void popPendingUpdate(PendingUpdate*);
+
+ // The given rect should be repainted.
+ void invalidateRect(const WebCore::IntRect&);
+
+ // The given rect should be scrolled by the given amounts.
+ void scrollRect(int dx, int dy, const WebCore::IntRect& clipRect);
+
+private:
+ WebCore::IntRect scrollPaintRect(const WebCore::IntRect& paintRect, int dx, int dy) const;
+ bool shouldInvalidateScrollRect(const WebCore::IntRect&) const;
+ void invalidateScrollRect();
+ void combinePaintRects();
+
+ PendingUpdate m_update;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/chromium/third_party/WebKit/Source/web/web.gyp b/chromium/third_party/WebKit/Source/web/web.gyp
new file mode 100644
index 00000000000..de6124ae572
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/web.gyp
@@ -0,0 +1,320 @@
+#
+# Copyright (C) 2011 Google Inc. 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.
+#
+
+{
+ 'includes': [
+ '../build/win/precompile.gypi',
+ '../bindings/bindings.gypi',
+ '../core/core.gypi',
+ '../core/features.gypi',
+ '../modules/modules.gypi',
+ '../wtf/wtf.gypi',
+ 'web.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'webkit',
+ 'type': '<(component)',
+ 'variables': { 'enable_wexit_time_destructors': 1, },
+ 'dependencies': [
+ '../core/core.gyp:webcore',
+ '../modules/modules.gyp:modules',
+ '<(DEPTH)/skia/skia.gyp:skia',
+ '<(DEPTH)/third_party/angle_dx11/src/build_angle.gyp:translator_glsl',
+ '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
+ '<(DEPTH)/third_party/npapi/npapi.gyp:npapi',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ 'blink_common',
+ ],
+ 'export_dependent_settings': [
+ '<(DEPTH)/skia/skia.gyp:skia',
+ '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
+ '<(DEPTH)/third_party/npapi/npapi.gyp:npapi',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ ],
+ 'include_dirs': [
+ '../../public/web',
+ '../web',
+ '<(DEPTH)/third_party/angle_dx11/include',
+ '<(DEPTH)/third_party/skia/include/utils',
+ ],
+ 'defines': [
+ 'WEBKIT_IMPLEMENTATION=1',
+ 'INSIDE_WEBKIT',
+ ],
+ 'sources': [
+ '<@(webcore_platform_support_files)',
+ '<@(web_files)',
+ ],
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'dependencies': [
+ '../core/core.gyp:webcore_derived',
+ '../core/core.gyp:webcore_test_support',
+ '<(DEPTH)/base/base.gyp:test_support_base',
+ '<(DEPTH)/testing/gmock.gyp:gmock',
+ '<(DEPTH)/testing/gtest.gyp:gtest',
+ '<(DEPTH)/third_party/icu/icu.gyp:*',
+ '<(libjpeg_gyp_path):libjpeg',
+ '<(DEPTH)/third_party/libpng/libpng.gyp:libpng',
+ '<(DEPTH)/third_party/libwebp/libwebp.gyp:libwebp',
+ '<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
+ '<(DEPTH)/third_party/libxslt/libxslt.gyp:libxslt',
+ '<(DEPTH)/third_party/modp_b64/modp_b64.gyp:modp_b64',
+ '<(DEPTH)/third_party/ots/ots.gyp:ots',
+ '<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
+ '<(DEPTH)/url/url.gyp:url_lib',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ # We must not add webkit_support here because of cyclic dependency.
+ ],
+ 'export_dependent_settings': [
+ '<(DEPTH)/url/url.gyp:url_lib',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ ],
+ 'include_dirs': [
+ # WARNING: Do not view this particular case as a precedent for
+ # including WebCore headers in DumpRenderTree project.
+ '../core/testing/v8', # for WebCoreTestSupport.h, needed to link in window.internals code.
+ ],
+ 'sources': [
+ '<@(bindings_unittest_files)',
+ '<@(core_unittest_files)',
+ '<@(modules_unittest_files)',
+ '<@(web_unittest_files)',
+ 'WebTestingSupport.cpp',
+ 'tests/WebUnitTests.cpp', # Components test runner support.
+ ],
+ 'conditions': [
+ ['OS=="win" or OS=="mac"', {
+ 'dependencies': [
+ '<(DEPTH)/third_party/nss/nss.gyp:*',
+ ],
+ }],
+ ['clang==1', {
+ # FIXME: It would be nice to enable this in shared builds too,
+ # but the test files have global constructors from the GTEST macro
+ # and we pull in the test files into the webkit target in the
+ # shared build.
+ 'cflags!': ['-Wglobal-constructors'],
+ 'xcode_settings': {
+ 'WARNING_CFLAGS!': ['-Wglobal-constructors'],
+ },
+ }],
+ ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'conditions': [
+ ['incremental_chrome_dll==1', {
+ 'UseLibraryDependencyInputs': "true",
+ }],
+ ],
+ },
+ },
+ }],
+ ['OS == "linux"', {
+ 'dependencies': [
+ '<(DEPTH)/build/linux/system.gyp:fontconfig',
+ ],
+ 'include_dirs': [
+ '../../public/web/linux',
+ ],
+ }, {
+ 'sources/': [
+ ['exclude', 'linux/'],
+ ],
+ }],
+ ['use_x11 == 1', {
+ 'dependencies': [
+ '<(DEPTH)/build/linux/system.gyp:x11',
+ ],
+ 'include_dirs': [
+ '../../public/web/x11',
+ ],
+ }, {
+ 'sources/': [
+ ['exclude', 'x11/'],
+ ]
+ }],
+ ['toolkit_uses_gtk == 1', {
+ 'dependencies': [
+ '<(DEPTH)/build/linux/system.gyp:gtk',
+ ],
+ 'include_dirs': [
+ '../../public/web/gtk',
+ ],
+ }, { # else: toolkit_uses_gtk != 1
+ 'sources/': [
+ ['exclude', 'gtk/'],
+ ],
+ }],
+ ['OS=="android"', {
+ 'include_dirs': [
+ '../../public/web/android',
+ '../../public/web/linux', # We need linux/WebFontRendering.h on Android.
+ ],
+ }, { # else: OS!="android"
+ 'sources/': [
+ ['exclude', 'android/'],
+ ],
+ }],
+ ['OS=="mac"', {
+ 'include_dirs': [
+ '../../public/web/mac',
+ ],
+ 'link_settings': {
+ 'libraries': [
+ '$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
+ '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
+ ],
+ },
+ }, { # else: OS!="mac"
+ 'sources/': [
+ ['exclude', 'mac/'],
+ ],
+ }],
+ ['OS=="win"', {
+ 'include_dirs': [
+ '../../public/web/win',
+ ],
+ }, { # else: OS!="win"
+ 'sources/': [
+ ['exclude', 'win/']
+ ],
+ 'variables': {
+ # FIXME: Turn on warnings on Windows.
+ 'chromium_code': 1,
+ }
+ }],
+ ['use_default_render_theme==1', {
+ 'include_dirs': [
+ '../../public/web/default',
+ ],
+ }, { # else use_default_render_theme==0
+ 'sources/': [
+ ['exclude', 'default/WebRenderTheme.cpp'],
+ ],
+ }],
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '../../',
+ ],
+ },
+ 'target_conditions': [
+ ['OS=="android"', {
+ 'sources/': [
+ ['include', '^linux/WebFontRendering\\.cpp$'],
+ ['include', '^linux/WebFontRenderStyle\\.cpp$'],
+ ],
+ }],
+ ],
+ },
+ {
+ 'target_name': 'webkit_test_support',
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'type': 'none',
+ }, {
+ 'type': 'static_library',
+ 'dependencies': [
+ '../core/core.gyp:webcore_test_support',
+ '../wtf/wtf.gyp:wtf',
+ '<(DEPTH)/skia/skia.gyp:skia',
+ ],
+ 'include_dirs': [
+ '../../public/web',
+ '../core/testing/v8', # for WebCoreTestSupport.h, needed to link in window.internals code.
+ '../../',
+ ],
+ 'sources': [
+ 'WebTestingSupport.cpp',
+ ],
+ }],
+ ],
+ },
+ {
+ 'target_name': 'blink_common',
+ 'type': '<(component)',
+ 'variables': { 'enable_wexit_time_destructors': 1 },
+ 'dependencies': [
+ '../wtf/wtf.gyp:wtf',
+ '<(DEPTH)/skia/skia.gyp:skia',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ ],
+ 'export_dependent_settings': [
+ '<(DEPTH)/skia/skia.gyp:skia',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ ],
+ 'defines': [
+ 'INSIDE_WEBKIT',
+ 'BLINK_COMMON_IMPLEMENTATION=1',
+ ],
+ 'include_dirs': [
+ '..',
+ '../..',
+ ],
+ 'sources': [
+ '../core/platform/chromium/support/WebCString.cpp',
+ '../core/platform/chromium/support/WebString.cpp',
+ 'WebCommon.cpp',
+ ],
+ },
+ ], # targets
+ 'conditions': [
+ ['gcc_version>=46', {
+ 'target_defaults': {
+ # Disable warnings about c++0x compatibility, as some names (such
+ # as nullptr) conflict with upcoming c++0x types.
+ 'cflags_cc': ['-Wno-c++0x-compat'],
+ },
+ }],
+ ['OS=="mac"', {
+ 'targets': [
+ {
+ 'target_name': 'copy_mesa',
+ 'type': 'none',
+ 'dependencies': ['<(DEPTH)/third_party/mesa/mesa.gyp:osmesa'],
+ 'copies': [{
+ 'destination': '<(PRODUCT_DIR)/DumpRenderTree.app/Contents/MacOS/',
+ 'files': ['<(PRODUCT_DIR)/osmesa.so'],
+ }],
+ },
+ ],
+ }],
+ ['clang==1', {
+ 'target_defaults': {
+ 'cflags': ['-Wglobal-constructors'],
+ 'xcode_settings': {
+ 'WARNING_CFLAGS': ['-Wglobal-constructors'],
+ },
+ },
+ }],
+ ], # conditions
+}
diff --git a/chromium/third_party/WebKit/Source/web/web.gypi b/chromium/third_party/WebKit/Source/web/web.gypi
new file mode 100644
index 00000000000..05b6fafd052
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/web.gypi
@@ -0,0 +1,378 @@
+{
+ 'variables': {
+ 'web_files': [
+ 'ApplicationCacheHost.cpp',
+ 'ApplicationCacheHostInternal.h',
+ 'AssertMatchingEnums.cpp',
+ 'AssociatedURLLoader.cpp',
+ 'AssociatedURLLoader.h',
+ 'AsyncFileSystemChromium.cpp',
+ 'AsyncFileSystemChromium.h',
+ 'AsyncFileWriterChromium.cpp',
+ 'AsyncFileWriterChromium.h',
+ 'AutofillPopupMenuClient.cpp',
+ 'AutofillPopupMenuClient.h',
+ 'BackForwardClientImpl.cpp',
+ 'BackForwardClientImpl.h',
+ 'ChromeClientImpl.cpp',
+ 'ChromeClientImpl.h',
+ 'ColorChooserPopupUIController.cpp',
+ 'ColorChooserPopupUIController.h',
+ 'ColorChooserUIController.cpp',
+ 'ColorChooserUIController.h',
+ 'CompositionUnderlineBuilder.h',
+ 'CompositionUnderlineVectorBuilder.cpp',
+ 'CompositionUnderlineVectorBuilder.h',
+ 'ContextFeaturesClientImpl.cpp',
+ 'ContextFeaturesClientImpl.h',
+ 'ContextMenuClientImpl.cpp',
+ 'ContextMenuClientImpl.h',
+ 'DOMUtilitiesPrivate.cpp',
+ 'DOMUtilitiesPrivate.h',
+ 'DatabaseObserver.cpp',
+ 'DateTimeChooserImpl.cpp',
+ 'DateTimeChooserImpl.h',
+ 'DeviceOrientationClientProxy.cpp',
+ 'DeviceOrientationClientProxy.h',
+ 'DragClientImpl.cpp',
+ 'DragClientImpl.h',
+ 'EditorClientImpl.cpp',
+ 'EditorClientImpl.h',
+ 'EventListenerWrapper.cpp',
+ 'EventListenerWrapper.h',
+ 'ExternalDateTimeChooser.cpp',
+ 'ExternalDateTimeChooser.h',
+ 'ExternalPopupMenu.cpp',
+ 'ExternalPopupMenu.h',
+ 'FindInPageCoordinates.cpp',
+ 'FindInPageCoordinates.h',
+ 'FrameLoaderClientImpl.cpp',
+ 'FrameLoaderClientImpl.h',
+ 'FullscreenController.cpp',
+ 'FullscreenController.h',
+ 'GeolocationClientProxy.cpp',
+ 'GeolocationClientProxy.h',
+ 'GraphicsLayerFactoryChromium.cpp',
+ 'GraphicsLayerFactoryChromium.h',
+ 'IDBCursorBackendProxy.cpp',
+ 'IDBCursorBackendProxy.h',
+ 'IDBDatabaseBackendProxy.cpp',
+ 'IDBDatabaseBackendProxy.h',
+ 'IDBFactoryBackendProxy.cpp',
+ 'IDBFactoryBackendProxy.h',
+ 'InbandTextTrackPrivateImpl.cpp',
+ 'InbandTextTrackPrivateImpl.h',
+ 'InspectorClientImpl.cpp',
+ 'InspectorClientImpl.h',
+ 'InspectorFrontendClientImpl.cpp',
+ 'InspectorFrontendClientImpl.h',
+ 'LinkHighlight.cpp',
+ 'LinkHighlight.h',
+ 'LocalFileSystemClient.cpp',
+ 'LocalFileSystemClient.h',
+ 'MIDIClientImpl.cpp',
+ 'MIDIClientImpl.h',
+ 'MediaSourcePrivateImpl.cpp',
+ 'MediaSourcePrivateImpl.h',
+ 'NotificationPresenterImpl.cpp',
+ 'NotificationPresenterImpl.h',
+ 'PageOverlay.cpp',
+ 'PageOverlay.h',
+ 'PageOverlayList.cpp',
+ 'PageOverlayList.h',
+ 'PageWidgetDelegate.cpp',
+ 'PageWidgetDelegate.h',
+ 'PinchViewports.cpp',
+ 'PinchViewports.h',
+ 'PopupContainer.cpp',
+ 'PopupContainer.h',
+ 'PopupListBox.cpp',
+ 'PopupListBox.h',
+ 'PopupMenuChromium.cpp',
+ 'PopupMenuChromium.h',
+ 'PrerendererClientImpl.cpp',
+ 'PrerendererClientImpl.h',
+ 'ScrollbarGroup.cpp',
+ 'ScrollbarGroup.h',
+ 'SharedWorkerRepository.cpp',
+ 'SourceBufferPrivateImpl.cpp',
+ 'SourceBufferPrivateImpl.h',
+ 'SpeechInputClientImpl.cpp',
+ 'SpeechInputClientImpl.h',
+ 'SpeechRecognitionClientProxy.cpp',
+ 'SpeechRecognitionClientProxy.h',
+ 'StorageAreaProxy.cpp',
+ 'StorageAreaProxy.h',
+ 'StorageNamespaceProxy.cpp',
+ 'StorageNamespaceProxy.h',
+ 'StorageQuotaChromium.cpp',
+ 'UserMediaClientImpl.cpp',
+ 'UserMediaClientImpl.h',
+ 'ValidationMessageClientImpl.cpp',
+ 'ValidationMessageClientImpl.h',
+ 'ViewportAnchor.cpp',
+ 'ViewportAnchor.h',
+ 'WebAccessibilityObject.cpp',
+ 'WebArrayBufferView.cpp',
+ 'WebBindings.cpp',
+ 'WebBlob.cpp',
+ 'WebBlobData.cpp',
+ 'WebCache.cpp',
+ 'WebCachedURLRequest.cpp',
+ 'WebColorName.cpp',
+ 'WebCrossOriginPreflightResultCache.cpp',
+ 'WebCustomElement.cpp',
+ 'WebDOMActivityLogger.cpp',
+ 'WebDOMCustomEvent.cpp',
+ 'WebDOMEvent.cpp',
+ 'WebDOMEventListener.cpp',
+ 'WebDOMEventListenerPrivate.cpp',
+ 'WebDOMEventListenerPrivate.h',
+ 'WebDOMMessageEvent.cpp',
+ 'WebDOMMouseEvent.cpp',
+ 'WebDOMMutationEvent.cpp',
+ 'WebDOMProgressEvent.cpp',
+ 'WebDOMResourceProgressEvent.cpp',
+ 'WebDataSourceImpl.cpp',
+ 'WebDataSourceImpl.h',
+ 'WebDatabase.cpp',
+ 'WebDevToolsAgentImpl.cpp',
+ 'WebDevToolsAgentImpl.h',
+ 'WebDevToolsFrontendImpl.cpp',
+ 'WebDevToolsFrontendImpl.h',
+ 'WebDeviceOrientation.cpp',
+ 'WebDeviceOrientationClientMock.cpp',
+ 'WebDeviceOrientationController.cpp',
+ 'WebDocument.cpp',
+ 'WebDocumentType.cpp',
+ 'WebDragData.cpp',
+ 'WebElement.cpp',
+ 'WebEntities.cpp',
+ 'WebEntities.h',
+ 'WebFileChooserCompletionImpl.cpp',
+ 'WebFileChooserCompletionImpl.h',
+ 'WebFileSystemCallbacksImpl.cpp',
+ 'WebFileSystemCallbacksImpl.h',
+ 'WebFontCache.cpp',
+ 'WebFontDescription.cpp',
+ 'WebFontImpl.cpp',
+ 'WebFontImpl.h',
+ 'WebFormControlElement.cpp',
+ 'WebFormElement.cpp',
+ 'WebFrameImpl.cpp',
+ 'WebFrameImpl.h',
+ 'WebGeolocationClientMock.cpp',
+ 'WebGeolocationController.cpp',
+ 'WebGeolocationError.cpp',
+ 'WebGeolocationPermissionRequest.cpp',
+ 'WebGeolocationPermissionRequestManager.cpp',
+ 'WebGeolocationPosition.cpp',
+ 'WebGlyphCache.cpp',
+ 'WebHelperPluginImpl.cpp',
+ 'WebHelperPluginImpl.h',
+ 'WebHistoryItem.cpp',
+ 'WebHitTestResult.cpp',
+ 'WebIDBCallbacksImpl.cpp',
+ 'WebIDBCallbacksImpl.h',
+ 'WebIDBDatabaseCallbacksImpl.cpp',
+ 'WebIDBDatabaseCallbacksImpl.h',
+ 'WebIDBDatabaseError.cpp',
+ 'WebIDBKey.cpp',
+ 'WebIDBKeyPath.cpp',
+ 'WebIDBKeyRange.cpp',
+ 'WebIDBMetadata.cpp',
+ 'WebImageCache.cpp',
+ 'WebImageDecoder.cpp',
+ 'WebImageSkia.cpp',
+ 'WebInputElement.cpp',
+ 'WebInputEvent.cpp',
+ 'WebInputEventConversion.cpp',
+ 'WebInputEventConversion.h',
+ 'WebKit.cpp',
+ 'WebLabelElement.cpp',
+ 'WebMIDIPermissionRequest.cpp',
+ 'WebMediaPlayerClientImpl.cpp',
+ 'WebMediaPlayerClientImpl.h',
+ 'WebMediaSourceImpl.cpp',
+ 'WebMediaSourceImpl.h',
+ 'WebMediaStreamRegistry.cpp',
+ 'WebNetworkStateNotifier.cpp',
+ 'WebNode.cpp',
+ 'WebNodeCollection.cpp',
+ 'WebNodeList.cpp',
+ 'WebNotification.cpp',
+ 'WebOptionElement.cpp',
+ 'WebPagePopupImpl.cpp',
+ 'WebPagePopupImpl.h',
+ 'WebPageSerializer.cpp',
+ 'WebPageSerializerImpl.cpp',
+ 'WebPageSerializerImpl.h',
+ 'WebPasswordFormData.cpp',
+ 'WebPasswordFormUtils.cpp',
+ 'WebPasswordFormUtils.h',
+ 'WebPerformance.cpp',
+ 'WebPluginContainerImpl.cpp',
+ 'WebPluginContainerImpl.h',
+ 'WebPluginDocument.cpp',
+ 'WebPluginLoadObserver.cpp',
+ 'WebPluginLoadObserver.h',
+ 'WebPluginScrollbarImpl.cpp',
+ 'WebPluginScrollbarImpl.h',
+ 'WebPopupMenuImpl.cpp',
+ 'WebPopupMenuImpl.h',
+ 'WebRange.cpp',
+ 'WebRuntimeFeatures.cpp',
+ 'WebScopedMicrotaskSuppression.cpp',
+ 'WebScopedUserGesture.cpp',
+ 'WebScopedUserGesture.cpp',
+ 'WebScriptBindings.cpp',
+ 'WebScriptController.cpp',
+ 'WebScrollbarThemePainter.cpp',
+ 'WebSearchableFormData.cpp',
+ 'WebSecurityOrigin.cpp',
+ 'WebSecurityPolicy.cpp',
+ 'WebSelectElement.cpp',
+ 'WebSerializedScriptValue.cpp',
+ 'WebSettingsImpl.cpp',
+ 'WebSettingsImpl.h',
+ 'WebSharedWorkerImpl.cpp',
+ 'WebSharedWorkerImpl.h',
+ 'WebSocket.cpp',
+ 'WebSocketImpl.cpp',
+ 'WebSocketImpl.h',
+ 'WebSpeechGrammar.cpp',
+ 'WebSpeechInputResult.cpp',
+ 'WebSpeechRecognitionHandle.cpp',
+ 'WebSpeechRecognitionResult.cpp',
+ 'WebStorageEventDispatcherImpl.cpp',
+ 'WebSurroundingText.cpp',
+ 'WebTextCheckingCompletionImpl.cpp',
+ 'WebTextCheckingCompletionImpl.h',
+ 'WebTextCheckingResult.cpp',
+ 'WebTextInputInfo.cpp',
+ 'WebTextRun.cpp',
+ 'WebURLLoadTiming.cpp',
+ 'WebUserGestureIndicator.cpp',
+ 'WebUserGestureToken.cpp',
+ 'WebUserMediaRequest.cpp',
+ 'WebViewBenchmarkSupportImpl.cpp',
+ 'WebViewBenchmarkSupportImpl.h',
+ 'WebViewImpl.cpp',
+ 'WebViewImpl.h',
+ 'WebWorkerBase.cpp',
+ 'WebWorkerBase.h',
+ 'WebWorkerClientImpl.cpp',
+ 'WebWorkerClientImpl.h',
+ 'WebWorkerInfo.cpp',
+ 'WebWorkerRunLoop.cpp',
+ 'WorkerAllowMainThreadBridgeBase.cpp',
+ 'WorkerAllowMainThreadBridgeBase.h',
+ 'WorkerFileSystemCallbacksBridge.cpp',
+ 'WorkerFileSystemCallbacksBridge.h',
+ 'WorkerFileSystemClient.cpp',
+ 'WorkerFileSystemClient.h',
+ 'android/WebInputEventFactory.cpp',
+ 'default/WebRenderTheme.cpp',
+ 'gtk/WebInputEventFactory.cpp',
+ 'linux/WebFontInfo.cpp',
+ 'linux/WebFontRenderStyle.cpp',
+ 'linux/WebFontRendering.cpp',
+ 'mac/WebInputEventFactory.mm',
+ 'mac/WebSubstringUtil.mm',
+ 'painting/ContinuousPainter.cpp',
+ 'painting/ContinuousPainter.h',
+ 'painting/PaintAggregator.cpp',
+ 'painting/PaintAggregator.h',
+ 'win/WebInputEventFactory.cpp',
+ ],
+ 'web_unittest_files': [
+ 'tests/AssociatedURLLoaderTest.cpp',
+ 'tests/ChromeClientImplTest.cpp',
+ 'tests/CustomEventTest.cpp',
+ 'tests/DragImageTest.cpp',
+ 'tests/FakeWebPlugin.cpp',
+ 'tests/FakeWebPlugin.h',
+ 'tests/FilterOperationsTest.cpp',
+ 'tests/FrameLoaderClientImplTest.cpp',
+ 'tests/FrameTestHelpers.cpp',
+ 'tests/FrameTestHelpers.h',
+ 'tests/GraphicsLayerTest.cpp',
+ 'tests/ImageFilterBuilderTest.cpp',
+ 'tests/ImageLayerChromiumTest.cpp',
+ 'tests/KeyboardTest.cpp',
+ 'tests/LinkHighlightTest.cpp',
+ 'tests/ListenerLeakTest.cpp',
+ 'tests/MemoryInfo.cpp',
+ 'tests/OpaqueRectTrackingContentLayerDelegateTest.cpp',
+ 'tests/OpenTypeVerticalDataTest.cpp',
+ 'tests/PageSerializerTest.cpp',
+ 'tests/PaintAggregatorTest.cpp',
+ 'tests/PopupContainerTest.cpp',
+ 'tests/PrerenderingTest.cpp',
+ 'tests/ProgrammaticScrollTest.cpp',
+ 'tests/RegionTest.cpp',
+ 'tests/RenderLayerBackingTest.cpp',
+ 'tests/RenderTableCellTest.cpp',
+ 'tests/RenderTableRowTest.cpp',
+ 'tests/ScrollingCoordinatorChromiumTest.cpp',
+ 'tests/URLTestHelpers.cpp',
+ 'tests/URLTestHelpers.h',
+ 'tests/WebFrameTest.cpp',
+ 'tests/WebImageTest.cpp',
+ 'tests/WebInputEventConversionTest.cpp',
+ 'tests/WebInputEventFactoryTestMac.mm',
+ 'tests/WebPageNewSerializerTest.cpp',
+ 'tests/WebPageSerializerTest.cpp',
+ 'tests/WebPluginContainerTest.cpp',
+ 'tests/WebURLRequestTest.cpp',
+ 'tests/WebURLResponseTest.cpp',
+ 'tests/WebUserGestureTokenTest.cpp',
+ 'tests/WebViewTest.cpp',
+ ],
+ 'conditions': [
+ ['OS=="win"',
+ {
+ 'web_unittest_files': [
+ 'tests/LocaleWinTest.cpp',
+ # FIXME: Port PopupMenuTest to Linux and Mac.
+ 'tests/PopupMenuTest.cpp',
+ 'tests/TransparencyWinTest.cpp',
+ 'tests/UniscribeHelperTest.cpp',
+ 'tests/WebPageNewSerializerTest.cpp',
+ 'tests/WebPageSerializerTest.cpp',
+ ],
+ }
+ ],
+ ['OS=="mac"',
+ {
+ 'web_unittest_files': [
+ 'tests/LocaleMacTest.cpp',
+ ],
+ }
+ ],
+ ['OS!="mac"',
+ {
+ 'web_unittest_files': [
+ # Mac uses ScrollAnimatorMac instead of ScrollAnimatorNone.
+ 'tests/ScrollAnimatorNoneTest.cpp',
+ ],
+ }
+ ],
+ ['os_posix==1 and OS!="mac"',
+ {
+ 'web_unittest_files': [
+ 'tests/LocaleICUTest.cpp',
+ ],
+ }
+ ],
+ ['toolkit_uses_gtk == 1',
+ {
+ 'web_unittest_files': [
+ 'tests/KeyCodeConversionTestGtk.cpp',
+ 'tests/WebInputEventFactoryTestGtk.cpp',
+ ],
+ }
+ ],
+ ],
+ },
+}
diff --git a/chromium/third_party/WebKit/Source/web/web_tests.gyp b/chromium/third_party/WebKit/Source/web/web_tests.gyp
new file mode 100644
index 00000000000..a0bd82ea5db
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/web_tests.gyp
@@ -0,0 +1,164 @@
+#
+# Copyright (C) 2011 Google Inc. 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.
+#
+
+{
+ 'includes': [
+ '../bindings/bindings.gypi',
+ '../core/core.gypi',
+ '../core/features.gypi',
+ '../modules/modules.gypi',
+ '../web/web.gypi',
+ '../wtf/wtf.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'webkit_unit_tests',
+ 'type': 'executable',
+ 'variables': { 'enable_wexit_time_destructors': 1, },
+ 'msvs_guid': '7CEFE800-8403-418A-AD6A-2D52C6FC3EAD',
+ 'dependencies': [
+ '../../public/blink.gyp:blink',
+ '../testing/testing.gyp:DumpRenderTree_resources',
+ '<(DEPTH)/base/base.gyp:base',
+ '<(DEPTH)/base/base.gyp:base_i18n',
+ '<(DEPTH)/base/base.gyp:test_support_base',
+ '<(DEPTH)/testing/gmock.gyp:gmock',
+ '<(DEPTH)/testing/gtest.gyp:gtest',
+ '<(DEPTH)/third_party/libwebp/libwebp.gyp:libwebp',
+ '<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
+ '<(DEPTH)/url/url.gyp:url_lib',
+ '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ '<(DEPTH)/content/content.gyp:content_webkit_unit_test_support',
+ ],
+ 'sources': [
+ '../web/tests/RunAllTests.cpp',
+ ],
+ 'include_dirs': [
+ '../../public/web',
+ '../web',
+ 'src',
+ ],
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'defines': [
+ 'WEBKIT_DLL_UNITTEST',
+ ],
+ }, {
+ 'dependencies': [
+ '../core/core.gyp:webcore',
+ ],
+ 'defines': [
+ 'WEBKIT_IMPLEMENTATION=1',
+ 'INSIDE_WEBKIT',
+ ],
+ 'sources': [
+ '<@(bindings_unittest_files)',
+ '<@(core_unittest_files)',
+ '<@(modules_unittest_files)',
+ '<@(web_unittest_files)',
+ ],
+ 'conditions': [
+ ['toolkit_uses_gtk == 1', {
+ 'include_dirs': [
+ '../../public/web/gtk',
+ ],
+ 'variables': {
+ # FIXME: Enable warnings on other platforms.
+ 'chromium_code': 1,
+ },
+ }],
+ ],
+ }],
+ ['OS=="win" and component!="shared_library"', {
+ 'configurations': {
+ 'Debug_Base': {
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
+ },
+ },
+ },
+ },
+ }],
+ ['OS=="android" and gtest_target_type == "shared_library"', {
+ 'type': 'shared_library',
+ 'dependencies': [
+ '<(DEPTH)/testing/android/native_test.gyp:native_test_native_code',
+ '<(DEPTH)/tools/android/forwarder2/forwarder.gyp:forwarder2',
+ ],
+ }],
+ ['OS=="mac"', {
+ 'include_dirs': [
+ '../../public/web/mac',
+ ],
+ }],
+ [ 'os_posix==1 and OS!="mac" and OS!="android" and OS!="ios" and linux_use_tcmalloc==1', {
+ 'dependencies': [
+ '<(DEPTH)/base/allocator/allocator.gyp:allocator',
+ ],
+ }],
+ ],
+ }
+ ], # targets
+ 'conditions': [
+ ['gcc_version>=46', {
+ 'target_defaults': {
+ # Disable warnings about c++0x compatibility, as some names (such
+ # as nullptr) conflict with upcoming c++0x types.
+ 'cflags_cc': ['-Wno-c++0x-compat'],
+ },
+ }],
+ ['OS=="android" and android_webview_build==0 and gtest_target_type == "shared_library"', {
+ # Wrap libwebkit_unit_tests.so into an android apk for execution.
+ 'targets': [{
+ 'target_name': 'webkit_unit_tests_apk',
+ 'type': 'none',
+ 'dependencies': [
+ '<(DEPTH)/base/base.gyp:base_java',
+ '<(DEPTH)/net/net.gyp:net_java',
+ 'webkit_unit_tests',
+ ],
+ 'variables': {
+ 'test_suite_name': 'webkit_unit_tests',
+ 'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)webkit_unit_tests<(SHARED_LIB_SUFFIX)',
+ },
+ 'includes': [ '../../../../build/apk_test.gypi' ],
+ }],
+ }],
+ ['clang==1', {
+ 'target_defaults': {
+ 'cflags': ['-Wunused-parameter'],
+ 'xcode_settings': {
+ 'WARNING_CFLAGS': ['-Wunused-parameter'],
+ },
+ },
+ }],
+ ],
+}
diff --git a/chromium/third_party/WebKit/Source/web/win/WebInputEventFactory.cpp b/chromium/third_party/WebKit/Source/web/win/WebInputEventFactory.cpp
new file mode 100644
index 00000000000..4ce69f0ef98
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/win/WebInputEventFactory.cpp
@@ -0,0 +1,490 @@
+/*
+ * 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 isKeyDown(WPARAM wparam)
+{
+ return GetKeyState(wparam) & 0x8000;
+}
+
+static int getLocationModifier(WPARAM wparam, LPARAM lparam)
+{
+ int modifier = 0;
+ switch (wparam) {
+ case VK_RETURN:
+ if ((lparam >> 16) & KF_EXTENDED)
+ modifier = WebInputEvent::IsKeyPad;
+ 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:
+ if (!((lparam >> 16) & KF_EXTENDED))
+ modifier = WebInputEvent::IsKeyPad;
+ 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:
+ modifier = WebInputEvent::IsKeyPad;
+ break;
+ case VK_SHIFT:
+ if (isKeyDown(VK_LSHIFT))
+ modifier = WebInputEvent::IsLeft;
+ else if (isKeyDown(VK_RSHIFT))
+ modifier = WebInputEvent::IsRight;
+ break;
+ case VK_CONTROL:
+ if (isKeyDown(VK_LCONTROL))
+ modifier = WebInputEvent::IsLeft;
+ else if (isKeyDown(VK_RCONTROL))
+ modifier = WebInputEvent::IsRight;
+ break;
+ case VK_MENU:
+ if (isKeyDown(VK_LMENU))
+ modifier = WebInputEvent::IsLeft;
+ else if (isKeyDown(VK_RMENU))
+ modifier = WebInputEvent::IsRight;
+ break;
+ case VK_LWIN:
+ modifier = WebInputEvent::IsLeft;
+ break;
+ case VK_RWIN:
+ modifier = WebInputEvent::IsRight;
+ break;
+ }
+
+ ASSERT(!modifier
+ || modifier == WebInputEvent::IsKeyPad
+ || modifier == WebInputEvent::IsLeft
+ || modifier == WebInputEvent::IsRight);
+ return modifier;
+}
+
+// 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 = static_cast<int>(wparam);
+ // Record the scan code (along with other context bits) for this key event.
+ result.nativeKeyCode = static_cast<int>(lparam);
+
+ 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;
+
+ result.modifiers |= getLocationModifier(wparam, lparam);
+
+ 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/chromium/third_party/WebKit/Source/web/x11/WebScreenInfoFactory.cpp b/chromium/third_party/WebKit/Source/web/x11/WebScreenInfoFactory.cpp
new file mode 100644
index 00000000000..e305d0c6bdd
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/web/x11/WebScreenInfoFactory.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 Google Inc. 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 {
+
+// FIXME: Take an X window and use XRandR to find the dimensions of the monitor
+// that it's on (probably using XRRGetScreenInfo() and XRRConfigSizes() from
+// X11/extensions/Xrandr.h). GDK provides a gdk_screen_get_monitor_geometry()
+// function, but it appears to return stale data after the screen is resized.
+WebScreenInfo WebScreenInfoFactory::screenInfo(Display* display, int screenNumber)
+{
+ // XDisplayWidth() and XDisplayHeight() return cached values. To ensure that
+ // we return the correct dimensions after the screen is resized, query the
+ // root window's geometry each time.
+ Window root = RootWindow(display, screenNumber);
+ Window rootRet;
+ int x, y;
+ unsigned int width, height, border, depth;
+ XGetGeometry(
+ display, root, &rootRet, &x, &y, &width, &height, &border, &depth);
+
+ WebScreenInfo results;
+
+ // FIXME: Initialize the device scale factor.
+ // FIXME: Not all screens use 8bpp.
+ results.depthPerComponent = 8;
+ results.depth = depth;
+ results.isMonochrome = depth == 1;
+ results.rect = WebRect(x, y, width, height);
+ // FIXME: Query the _NET_WORKAREA property from EWMH.
+ results.availableRect = results.rect;
+
+ return results;
+}
+
+} // namespace WebKit